Page 1 of 1
EXTDriver compilation problem migrating from Chibios 16.1.0 to 18.2.x
Posted: Wed Dec 05, 2018 10:30 am
by icastell
Hello forum.
I am working porting a Chibios project from 16.1.0 to 18.2.x for a STM32 microcontroller.
Read this migration guide:
http://chibios.org/dokuwiki/doku.php?id ... te_chibiosAnd followed this steps:
Checked out this Chibios and Chibios-Contrib branches (git repo):
* Chibios brach HEAD detached at origin/stable_18.2.x [https://github.com/ChibiOS/ChibiOS.git]
* Chibios-Contrib HEAD detached at origin/chibios-17.6.x [https://github.com/ChibiOS/ChibiOS-Contrib.git]
Upgraded Makefile compilation system.
Upgraded chconf.h, halconf.h and mcuconf.h configuration files (maintaining values from original project).
The migrated project includes variable HAL_USE_EXT with value TRUE (halconf.h)
When I compile with "make", I'm getting this error:
Code: Select all
./ChibiOS/os/hal/ports/STM32/LLD/EXTIv1/hal_ext_lld.h:30:29: fatal error: hal_ext_lld_isr.h: No such file or directory
That missing file is found inside this directory:
Code: Select all
./ChibiOS-Contrib/os/hal/ports/NRF5/NRF51822/hal_ext_lld_isr.h
That file refers to a platform different from STM32 (NRF51822).
What should be the proper way to fix this?
A step-by-step guide with the common problems and solutions would be really helpful.
Re: EXTDriver compilation problem migrating from Chibios 16.1.0 to 18.2.x
Posted: Wed Dec 05, 2018 10:40 am
by Giovanni
Hi,
The EXT driver is no more supported in 18.2, now PAL driver has a convenient callback capability but the project needs changes.
What is your use case?
Giovanni
Re: EXTDriver compilation problem migrating from Chibios 16.1.0 to 18.2.x
Posted: Wed Dec 05, 2018 11:34 am
by icastell
The idea is quite simple: the hardware of our sensor emits an interrupt each time it has new data available. That interrupt is connected with an interrupt handler (HIDSensorIntHookI) using the EXT Driver. That interrupt handlers emits a data_ready_event. A thread registed to that data_ready_event, reads data from sensor and saves data into a buffer (updating last value read). Last data collected and stored into the buffer are sent to the host of the USB bus.
Our main.c defines this extcfg variable:
Code: Select all
EXTConfig extcfg = {
{
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_FALLING_EDGE | EXT_CH_MODE_AUTOSTART | EXT_MODE_GPIOA, HIDSensorIntHookI},
{EXT_CH_MODE_DISABLED, NULL},
{EXT_CH_MODE_DISABLED, NULL},
....
}
};
This is the code related with the interrupt handler:
Code: Select all
void HIDSensorInt1HookI(EXTDriver *extp, expchannel_t channel) {
(void) extp;
(void) channel;
HIDSensorAccelerometerDataReadyHookI(NULL);
}
void HIDSensorAccelerometerDataReadyHookI(void *arg) {
(void)arg;
chSysLockFromISR();
chEvtBroadcastI(&accelerometer_base.data_ready_event);
chSysUnlockFromISR();
}
And this is the code in our main function related with the EXT driver:
Code: Select all
int main(void)
{
halInit();
chSysInit();
wdgStart(&WDGD1, &wdgcfg);
extStart(&EXTD1, &extcfg);
extChannelEnable(&EXTD1, 0);
...
}
If you need other details, please let me know.
Thanks a lot in advance.
Re: EXTDriver compilation problem migrating from Chibios 16.1.0 to 18.2.x
Posted: Wed Dec 05, 2018 11:36 am
by Giovanni
Hi,
That is much easier now using the PAL driver callbacks. Look at the demo under \testhal\STM32\multi\PAL, there is an example with callbacks but also other ways to detect GPIO events.
Giovanni
Re: EXTDriver compilation problem migrating from Chibios 16.1.0 to 18.2.x
Posted: Mon Dec 10, 2018 11:59 am
by icastell
Hello again.
I am having compiler/linker issues with the migration of ChibiOS project from 16.1.0 to 18.2.x
The main 18.2.x Makefile includes this set of .mk files:
Code: Select all
include $(CHIBIOS)/os/license/license.mk
include $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_stm32f0xx.mk
include $(CHIBIOS)/os/hal/hal.mk
include $(CHIBIOS)/os/hal/ports/STM32/STM32F0xx/platform.mk
include $(CHIBIOS)/os/hal/osal/rt/osal.mk
include $(CHIBIOS_CONTRIB_PRJ/os/hal/boards/ST_STM32F072B_PRJ/board.mk
include $(CHIBIOS)/os/rt/rt.mk
include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v6m.mk
include $(CHIBIOS)/tools/mk/autobuild.mk
With that Makefile, I get this compilation error:
Code: Select all
./ChibiOS/os/hal/include/hal.h:165:27: fatal error: hal_community.h: No such file or directory
Ok, that hal_community.h file is defined here:
Code: Select all
./ChibiOS-Contrib/os/hal/include/hal_community.h
So I append the hal.mk file from CHIBIOS_CONTRIB in the main Makefile:
Code: Select all
include $(CHIBIOS_CONTRIB)/os/hal/hal.mk
But after that I get a lot of warnings like this:
Code: Select all
ChibiOS/os/common/startup/ARMCMx/compilers/GCC/rules.mk:229: target 'build/obj/hal.o' given more than once in the same rule
And a lot of linking errors like this:
Code: Select all
(.text+0x0): multiple definition of `stStartAlarm'
build/obj/hal_st.o (symbol from plugin):(.text+0x0): first defined here
build/obj/hal_st.o (symbol from plugin): In function `stGetAlarm':
In my working project (ChibiOS 16.1.0), the main Makefile just includes the hal.mk from CHIBIOS_CONTRIB (not from CHIBIOS):
Code: Select all
include $(CHIBIOS_CONTRIB)/os/hal/hal.mk
But with 18.2.x if I try the same (just include the hal.mk from CHIBIOS_CONTRIB), I get this linker error:
Code: Select all
main.c:197: undefined reference to `palEnableLineEvent'
That palEnableLineEvent is defined here:
So it seems mandatory to include CHIBIOS hal.mk.
What is the proper way to write the main Makefile to work with PAL and HID subsystems all together?
Thanks a lot in advance!
Re: EXTDriver compilation problem migrating from Chibios 16.1.0 to 18.2.x
Posted: Mon Dec 10, 2018 1:17 pm
by Giovanni
Hi,
Sorry I can't help with community maintained code. It is not necessarily aligned with mainline development, this is why it is kept separated.
You could take the HID code out of community repository and compile it as part of your application, this could simplify integration.
Giovanni
Re: EXTDriver compilation problem migrating from Chibios 16.1.0 to 18.2.x
Posted: Mon Dec 10, 2018 5:10 pm
by icastell
I fixed the compilation issues. To do that:
1) Moved hal_usb_hid.c and hal_usb_hid.h from Chibios-Contrib/ to Chibios/
2) Modified hal.mk properly
3) Set HAL_USE_COMMUNITY to FALSE
After that the project with PAL and HID compiles fine. I am still working in the migration of PAL related stuff.
I will continue with the migration and will check if everything works as expected.
I will update the progress done here.
Thanks a lot!
Re: EXTDriver compilation problem migrating from Chibios 16.1.0 to 18.2.x
Posted: Tue Dec 11, 2018 3:47 pm
by icastell
Ok, I finally replaced completely the EXT by the PAL module in my project. This is the current situation:
Code: Select all
#define LINE_SENSOR_X PAL_LINE(GPIOA, 2U)
#define LINE_SENSOR_Y PAL_LINE(GPIOA, 3U)
#define LINE_BUTTON_X PAL_LINE(GPIOB, 6U)
#define LINE_BUTTON_Y PAL_LINE(GPIOB, 7U)
Code: Select all
/* Enable events on falling edge of the sensor lines */
palEnableLineEvent(LINE_SENSOR_X, PAL_EVENT_MODE_FALLING_EDGE);
palEnableLineEvent(LINE_SENSOR_Y, PAL_EVENT_MODE_FALLING_EDGE);
palSetLineCallback(LINE_SENSOR_X, HIDSensorInt1HookI, NULL);
palSetLineCallback(LINE_SENSOR_Y, HIDSensorInt2HookI, NULL);
/* Enable events on both edges of the button lines */
palEnableLineEvent(LINE_BUTTON_X, PAL_EVENT_MODE_BOTH_EDGES);
palEnableLineEvent(LINE_BUTTON_Y, PAL_EVENT_MODE_BOTH_EDGES);
palSetLineCallback(LINE_BUTTON_X, HIDButtonGPIOHookI, NULL);
palSetLineCallback(LINE_BUTTON_Y, HIDButtonGPIOHookI, NULL);
The callbacks defined are called fine (I checked that switching some leds on/off). The remaining source code should work as expected (it was working fine with Chibios 16.1.x). But it doesn't work (sensors don't report data, buttons don't report key press/release). So, time to debug this...