STM32F405: GCC5 not working correctly
Posted: Mon Sep 19, 2016 12:34 pm
Hi all,
I am encoutering some strange issues with GCC5 (5.2.1, 5.3.1, and 5.4.1) when running code on a STM32F405(RGT6). Compiling the same project with GCC 4.9.3 works fine, though.
What I do:
My system starts with a custom bootloader, which again loads the OS (ChibiOS/RT 3.1.4, ChibiOS/HAL 4.0.6 (branch stable_16.1.x)). The first line of my main() is the usual halInit() function, which already fails with GCC5. More specifically, I tracked the problematic code down to be one or multiple of the rccReset-functions in in the hal_lld.c file (lines 118-121), which are called within hal_lld_init(). Actually this is the very first code to be executed, except for the function calls. I even extracted these lines and put them at the beginning of my main() to avoid any memory access by function calls, but the issue persisted.
What happens:
Executing these lines causes the system to halt (or at least nothing is executed).
Since the problematic function calls just set some RCC registers to ¬0 and back to 0, my best guess is that GCC5 does not handle the volatile qualifier correctly. Has anyone similar issues or can reproduce this behavior? Or do you have any further ideas what I might be doing wrong?
I tested my system by lighting up a LED from the bootloader code (GPIO output is driven low) but configured my board.h to set the GPIO output to high on startup. However, even setting the RCC_AHB1RSTR register resets the GPIO configuration so it will not pull down anymore and the LED should turn off. This is not the case with GCC5, which I interpret that the RCC_AHB1RSTR register is not set/reset correctly.
Best regards,
Thomas
I am encoutering some strange issues with GCC5 (5.2.1, 5.3.1, and 5.4.1) when running code on a STM32F405(RGT6). Compiling the same project with GCC 4.9.3 works fine, though.
What I do:
My system starts with a custom bootloader, which again loads the OS (ChibiOS/RT 3.1.4, ChibiOS/HAL 4.0.6 (branch stable_16.1.x)). The first line of my main() is the usual halInit() function, which already fails with GCC5. More specifically, I tracked the problematic code down to be one or multiple of the rccReset-functions in in the hal_lld.c file (lines 118-121), which are called within hal_lld_init(). Actually this is the very first code to be executed, except for the function calls. I even extracted these lines and put them at the beginning of my main() to avoid any memory access by function calls, but the issue persisted.
What happens:
Executing these lines causes the system to halt (or at least nothing is executed).
Since the problematic function calls just set some RCC registers to ¬0 and back to 0, my best guess is that GCC5 does not handle the volatile qualifier correctly. Has anyone similar issues or can reproduce this behavior? Or do you have any further ideas what I might be doing wrong?
I tested my system by lighting up a LED from the bootloader code (GPIO output is driven low) but configured my board.h to set the GPIO output to high on startup. However, even setting the RCC_AHB1RSTR register resets the GPIO configuration so it will not pull down anymore and the LED should turn off. This is not the case with GCC5, which I interpret that the RCC_AHB1RSTR register is not set/reset correctly.
Best regards,
Thomas