undefined reference to ST2MS and MS2ST

Discussions and support about ChibiOS/RT, the free embedded RTOS.
e11i0t23
Posts: 11
Joined: Thu Feb 21, 2019 8:46 pm
Has thanked: 5 times

undefined reference to ST2MS and MS2ST

Postby e11i0t23 » Thu Feb 21, 2019 9:04 pm

Hi,

We are working to upgrade qmk firmware from a very old version of chibios from github commit 587968d6cbc2b0e1c7147540872f2a67e59ca18b to the latest version official version of chibios however are running into the issue of getting
[*]

Code: Select all

...tmk_core/common/chibios/timer.c:37: undefined reference to `ST2MS'

[*]

Code: Select all

...tmk_core/common/chibios/timer.c:39: undefined reference to `MS2ST'


this file includes "ch.h" however we cant find defines of ST2MS or MS2ST anywhere in the new chibios where it used to be.

any information on this would be helpful

Thanks in advance
Elliot

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: undefined reference to ST2MS and MS2ST

Postby Giovanni » Thu Feb 21, 2019 9:51 pm

Hi,

In recent version of RT there are two different types one for absolute time (systime_t) and one for intervales (sysinterval_t), because of this those macros have been renamed to TIME_MS2I(msecs) etc, look into chtime.h, all time/interval-related macros and functions are there.

Giovanni

e11i0t23
Posts: 11
Joined: Thu Feb 21, 2019 8:46 pm
Has thanked: 5 times

Re: undefined reference to ST2MS and MS2ST

Postby e11i0t23 » Thu Feb 21, 2019 11:35 pm

Thank you for the reply that really helped

we are also using your usb_driver files you made our version has some edits but is based on your 2016 version and since updating chibios and not this file it now gives the following error

Code: Select all

tmk_core/protocol/chibios/usb_driver.c:128:3: warning: initialization makes integer from pointer without a cast
   _write, _read, _put, _get,
   ^
tmk_core/protocol/chibios/usb_driver.c:128:3: warning: (near initialization for 'vmt.instance_offset')
tmk_core/protocol/chibios/usb_driver.c:128:3: warning: initialization from incompatible pointer type
tmk_core/protocol/chibios/usb_driver.c:128:3: warning: (near initialization for 'vmt.write')
tmk_core/protocol/chibios/usb_driver.c:128:3: warning: initialization from incompatible pointer type
tmk_core/protocol/chibios/usb_driver.c:128:3: warning: (near initialization for 'vmt.read')
tmk_core/protocol/chibios/usb_driver.c:128:3: warning: initialization from incompatible pointer type
tmk_core/protocol/chibios/usb_driver.c:128:3: warning: (near initialization for 'vmt.put')
tmk_core/protocol/chibios/usb_driver.c:129:3: warning: initialization from incompatible pointer type
   _putt, _gett, _writet, _readt
   ^
tmk_core/protocol/chibios/usb_driver.c:129:3: warning: (near initialization for 'vmt.get')
tmk_core/protocol/chibios/usb_driver.c:129:3: warning: initialization from incompatible pointer type
tmk_core/protocol/chibios/usb_driver.c:129:3: warning: (near initialization for 'vmt.putt')
tmk_core/protocol/chibios/usb_driver.c:129:3: warning: initialization from incompatible pointer type
tmk_core/protocol/chibios/usb_driver.c:129:3: warning: (near initialization for 'vmt.gett')
tmk_core/protocol/chibios/usb_driver.c:130:1: warning: initialization from incompatible pointer type
 };
 ^
tmk_core/protocol/chibios/usb_driver.c:130:1: warning: (near initialization for 'vmt.writet')


lines 127 through 130 are

Code: Select all

static const struct QMKUSBDriverVMT vmt = {
  _write, _read, _put, _get,
  _putt, _gett, _writet, _readt
};


i wonder if you could provide any help here as well as this has also only stopped working since the update

faisal
Posts: 374
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 44 times
Been thanked: 60 times

Re: undefined reference to ST2MS and MS2ST

Postby faisal » Fri Feb 22, 2019 12:12 am

e11i0t23 wrote:Thank you for the reply that really helped

we are also using your usb_driver files you made our version has some edits but is based on your 2016 version and since updating chibios and not this file it now gives the following error

Code: Select all

tmk_core/protocol/chibios/usb_driver.c:128:3: warning: initialization makes integer from pointer without a cast
   _write, _read, _put, _get,
   ^
tmk_core/protocol/chibios/usb_driver.c:128:3: warning: (near initialization for 'vmt.instance_offset')
tmk_core/protocol/chibios/usb_driver.c:128:3: warning: initialization from incompatible pointer type
tmk_core/protocol/chibios/usb_driver.c:128:3: warning: (near initialization for 'vmt.write')
tmk_core/protocol/chibios/usb_driver.c:128:3: warning: initialization from incompatible pointer type
tmk_core/protocol/chibios/usb_driver.c:128:3: warning: (near initialization for 'vmt.read')
tmk_core/protocol/chibios/usb_driver.c:128:3: warning: initialization from incompatible pointer type
tmk_core/protocol/chibios/usb_driver.c:128:3: warning: (near initialization for 'vmt.put')
tmk_core/protocol/chibios/usb_driver.c:129:3: warning: initialization from incompatible pointer type
   _putt, _gett, _writet, _readt
   ^
tmk_core/protocol/chibios/usb_driver.c:129:3: warning: (near initialization for 'vmt.get')
tmk_core/protocol/chibios/usb_driver.c:129:3: warning: initialization from incompatible pointer type
tmk_core/protocol/chibios/usb_driver.c:129:3: warning: (near initialization for 'vmt.putt')
tmk_core/protocol/chibios/usb_driver.c:129:3: warning: initialization from incompatible pointer type
tmk_core/protocol/chibios/usb_driver.c:129:3: warning: (near initialization for 'vmt.gett')
tmk_core/protocol/chibios/usb_driver.c:130:1: warning: initialization from incompatible pointer type
 };
 ^
tmk_core/protocol/chibios/usb_driver.c:130:1: warning: (near initialization for 'vmt.writet')


lines 127 through 130 are

Code: Select all

static const struct QMKUSBDriverVMT vmt = {
  _write, _read, _put, _get,
  _putt, _gett, _writet, _readt
};


i wonder if you could provide any help here as well as this has also only stopped working since the update



Your QMKUSBDriverVMT struct inherits from BaseSequentialStream in hal_stream.h. That has been updated to add _base_object_methods (hal_objects.h) used for multiple inheritance. _base_object_methods just contains a size_t instance_offset; . So add a "(size_t)0" as the first element of your vmt. hal_channels.h (BaseAsynchronousChannel, which you directly inherit from) has added a ioctl like api called ctl - which you will have to add to your struct as well. See hal_serial.c for an example of what your vmt should look like:

https://github.com/ChibiOS/ChibiOS/blob ... ial.c#L117

faisal
Posts: 374
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 44 times
Been thanked: 60 times

Re: undefined reference to ST2MS and MS2ST

Postby faisal » Fri Feb 22, 2019 12:33 am

Oh yeah, QMK is cool. Rock on. :) Glad the project is moving to the latest release.

e11i0t23
Posts: 11
Joined: Thu Feb 21, 2019 8:46 pm
Has thanked: 5 times

Re: undefined reference to ST2MS and MS2ST

Postby e11i0t23 » Fri Feb 22, 2019 12:45 am

Thank you again, you are all very supportive and really helping us to progress where our shortcomings fall

Code: Select all

Compiling: keyboards/cannonkeys/bluepill/ws2812.c                                                  keyboards/cannonkeys/bluepill/ws2812.c:49:3: error: initialization from incompatible pointer type [-Werror]
   PORT_WS2812,
   ^
keyboards/cannonkeys/bluepill/ws2812.c:49:3: error: (near initialization for 'spicfg.end_cb') [-Werror]
keyboards/cannonkeys/bluepill/ws2812.c:50:3: error: initialization makes pointer from integer without a cast [-Werror]
   PIN_WS2812,
   ^
keyboards/cannonkeys/bluepill/ws2812.c:50:3: error: (near initialization for 'spicfg.ssport') [-Werror]
cc1: all warnings being treated as errors


similarly im guessing an update has been made to the layout of the following code to break this section as well or has been renamed?

Code: Select all

 static const SPIConfig spicfg = {
  NULL,
  PORT_WS2812,
  PIN_WS2812,
  SPI_CR1_BR_1|SPI_CR1_BR_0 // baudrate : fpclk / 8 => 1tick is 0.32us (2.25 MHz)
};
I think this is fixed now
Last edited by e11i0t23 on Fri Feb 22, 2019 1:40 am, edited 1 time in total.

e11i0t23
Posts: 11
Joined: Thu Feb 21, 2019 8:46 pm
Has thanked: 5 times

Re: undefined reference to ST2MS and MS2ST

Postby e11i0t23 » Fri Feb 22, 2019 1:34 am

Your QMKUSBDriverVMT struct inherits from BaseSequentialStream in hal_stream.h. That has been updated to add _base_object_methods (hal_objects.h) used for multiple inheritance. _base_object_methods just contains a size_t instance_offset; . So add a "(size_t)0" as the first element of your vmt. hal_channels.h (BaseAsynchronousChannel, which you directly inherit from) has added a ioctl like api called ctl - which you will have to add to your struct as well. See hal_serial.c for an example of what your vmt should look like:

https://github.com/ChibiOS/ChibiOS/blob ... ial.c#L117


This managed to fix part of the error however created new errors and also didn't fully fix the problem as we still get

Code: Select all

Compiling: tmk_core/protocol/chibios/usb_driver.c                                                  tmk_core/protocol/chibios/usb_driver.c:130:3: error: initialization from incompatible pointer type [-Werror]
   _putt, _gett, _writet, _readt,
   ^
tmk_core/protocol/chibios/usb_driver.c:130:3: error: (near initialization for 'vmt.putt') [-Werror]
tmk_core/protocol/chibios/usb_driver.c:130:3: error: initialization from incompatible pointer type [-Werror]
tmk_core/protocol/chibios/usb_driver.c:130:3: error: (near initialization for 'vmt.gett') [-Werror]
tmk_core/protocol/chibios/usb_driver.c:130:3: error: initialization from incompatible pointer type [-Werror]
tmk_core/protocol/chibios/usb_driver.c:130:3: error: (near initialization for 'vmt.writet') [-Werror]
tmk_core/protocol/chibios/usb_driver.c:130:3: error: initialization from incompatible pointer type [-Werror]
tmk_core/protocol/chibios/usb_driver.c:130:3: error: (near initialization for 'vmt.readt') [-Werror]
tmk_core/protocol/chibios/usb_driver.c:131:3: error: '_ctl' undeclared here (not in a function)
   _ctl
   ^
cc1: all warnings being treated as errors

faisal
Posts: 374
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 44 times
Been thanked: 60 times

Re: undefined reference to ST2MS and MS2ST

Postby faisal » Fri Feb 22, 2019 2:19 am

e11i0t23 wrote:Thank you again, you are all very supportive and really helping us to progress where our shortcomings fall

Code: Select all

Compiling: keyboards/cannonkeys/bluepill/ws2812.c                                                  keyboards/cannonkeys/bluepill/ws2812.c:49:3: error: initialization from incompatible pointer type [-Werror]
   PORT_WS2812,
   ^
keyboards/cannonkeys/bluepill/ws2812.c:49:3: error: (near initialization for 'spicfg.end_cb') [-Werror]
keyboards/cannonkeys/bluepill/ws2812.c:50:3: error: initialization makes pointer from integer without a cast [-Werror]
   PIN_WS2812,
   ^
keyboards/cannonkeys/bluepill/ws2812.c:50:3: error: (near initialization for 'spicfg.ssport') [-Werror]
cc1: all warnings being treated as errors


similarly im guessing an update has been made to the layout of the following code to break this section as well or has been renamed?

Code: Select all

 static const SPIConfig spicfg = {
  NULL,
  PORT_WS2812,
  PIN_WS2812,
  SPI_CR1_BR_1|SPI_CR1_BR_0 // baudrate : fpclk / 8 => 1tick is 0.32us (2.25 MHz)
};
I think this is fixed now


Regarding the SPIConfig structure and really all other similar structs - you should separate out the platform agnostic (portable) parts of the structure, and the processor/board specific parts.

For example, your struct could look like this:

Code: Select all

static const SPIConfig spicfg = {
  NULL,
  PORT_WS2812,
  PIN_WS2812,
  PORTAB_SPI_CONFIG
};


And you can put this in your config.h (or wherever it is appropriate to put platform specific details .. probably the same place where PORT/PIN definitions are):

Code: Select all

#define PORTAB_SPI_CONFIG \
SPI_CR1_BR_1|SPI_CR1_BR_0 // baudrate : fpclk / 8 => 1tick is 0.32us (2.25 MHz)
Last edited by faisal on Fri Feb 22, 2019 2:27 am, edited 2 times in total.

faisal
Posts: 374
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 44 times
Been thanked: 60 times

Re: undefined reference to ST2MS and MS2ST

Postby faisal » Fri Feb 22, 2019 2:25 am

e11i0t23 wrote:
Your QMKUSBDriverVMT struct inherits from BaseSequentialStream in hal_stream.h. That has been updated to add _base_object_methods (hal_objects.h) used for multiple inheritance. _base_object_methods just contains a size_t instance_offset; . So add a "(size_t)0" as the first element of your vmt. hal_channels.h (BaseAsynchronousChannel, which you directly inherit from) has added a ioctl like api called ctl - which you will have to add to your struct as well. See hal_serial.c for an example of what your vmt should look like:

https://github.com/ChibiOS/ChibiOS/blob ... ial.c#L117


This managed to fix part of the error however created new errors and also didn't fully fix the problem as we still get

Code: Select all

Compiling: tmk_core/protocol/chibios/usb_driver.c                                                  tmk_core/protocol/chibios/usb_driver.c:130:3: error: initialization from incompatible pointer type [-Werror]
   _putt, _gett, _writet, _readt,
   ^
tmk_core/protocol/chibios/usb_driver.c:130:3: error: (near initialization for 'vmt.putt') [-Werror]
tmk_core/protocol/chibios/usb_driver.c:130:3: error: initialization from incompatible pointer type [-Werror]
tmk_core/protocol/chibios/usb_driver.c:130:3: error: (near initialization for 'vmt.gett') [-Werror]
tmk_core/protocol/chibios/usb_driver.c:130:3: error: initialization from incompatible pointer type [-Werror]
tmk_core/protocol/chibios/usb_driver.c:130:3: error: (near initialization for 'vmt.writet') [-Werror]
tmk_core/protocol/chibios/usb_driver.c:130:3: error: initialization from incompatible pointer type [-Werror]
tmk_core/protocol/chibios/usb_driver.c:130:3: error: (near initialization for 'vmt.readt') [-Werror]
tmk_core/protocol/chibios/usb_driver.c:131:3: error: '_ctl' undeclared here (not in a function)
   _ctl
   ^
cc1: all warnings being treated as errors


The compiler is complaining about an incompatible pointer type. _putt, _gett, and so on are function pointers. Thus, the function declarations must not match up.

Looking at your file https://github.com/qmk/qmk_firmware/blo ... b_driver.c, and comparing it with https://github.com/ChibiOS/ChibiOS/blob ... l_serial.c shows that this is indeed the case. In most places systime_t timeout is now sysinterval_t timeout .

Look at all the functions you are adding to the VMT, and make sure the function declarations are correct.

e11i0t23
Posts: 11
Joined: Thu Feb 21, 2019 8:46 pm
Has thanked: 5 times

Re: undefined reference to ST2MS and MS2ST

Postby e11i0t23 » Fri Feb 22, 2019 3:51 pm

Thank you again for your great help we are making great progress

we now are getting the following

Code: Select all

lib/chibios/os/hal/ports/STM32/LLD/DMAv1/stm32_dma.c:556:3: error: 'endid' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   for (i = startid; i <= endid; i++) {
   ^
lib/chibios/os/hal/ports/STM32/LLD/DMAv1/stm32_dma.c:556:34: error: 'startid' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   for (i = startid; i <= endid; i++) {
                                  ^
cc1: all warnings being treated as errors
 [ERRORS]
 |
 |
 |
tmk_core/rules.mk:372: recipe for target '.build/obj_handwired_co60_rev6/lib/chibios/os/hal/ports/STM32/LLD/DMAv1/stm32_dma.o' failed
make[1]: *** [.build/obj_handwired_co60_rev6/lib/chibios/os/hal/ports/STM32/LLD/DMAv1/stm32_dma.o] Error 1
Makefile:535: recipe for target 'handwired/co60/rev6:default' failed


Ithink this is todo with a value not being initialized however cant figure out what it needs to be defined to and in which conf file


Return to “ChibiOS/RT”

Who is online

Users browsing this forum: No registered users and 9 guests