I'll illustrate this minor bug / missing #error using the Discovery-G++ STM32 demo.
Error message:
build/obj/st_lld.o (symbol from plugin): In function st_lld_init':
(.text+0x0): multiple definition ofVectorB0'
build/obj/gpt_lld.o (symbol from plugin):(.text+0x0): first defined here
When I ran into this message I at first had no clue what was going on. As it turns out, it's pretty obvious once you find out that in RT 3.0 the systick timer stuff uses TIM2 as 32-bit systick timer by default.
I suppose something similar happens if you use TIM2 in ICU/PWM mode, plus the same should happen for other timers. At the least, it is significantly easiert to screw up your systick timer if the code doesn't compiletime-check for this error.
I believe ChibiOS should print meaningful error messages if someone makes the same mistake in the future, especially for those who try to port RT 2.x code to 3.x.
I added a patch that should catch all cases where the TIM2..5 systick timer being used for GPT/ICU/PWM yields an #error.
Hi, is that the right patch?
Sorry, I seem to have submitted the same patch twice. Here's the correct one.
Hi, the solution is not general enough, also GPT, PWM and ICU drivers would need similar checks and for all the timers.
This something for post-3.0.0, to be fixed together with the other issue related to timers: shared IRQs preventing the use of all timers in all drivers.
Giovanni
I agree about this not being neccessary for 3.0 release.
I added code for TIM2..5 because in svn trunk only TIM2..5 are supported (see STM32/TIMv1/st_lld.c:41++) or:
error "STM32_ST_USE_TIMER specifies an unsupported timer"
Therefore I don't see any point in adding checks for other timers right now considering they are not supported at all.
If you mean other microcontrollers (e.g. LPC), I suppose it's necessary to add some checks there.
Also I'm not sure if it makes sense to add duplicate checks to ICU/PWM/GPT drivers. As the ST driver check yields an #error message (and not a #warning).
If you mean disallowing e.g. GPT5 and PWM5 being enabled at the same time, I disagree - I can think of usecases where one might want to use PWM and GPT for the same timer in the same program without having them enabled concurrently at any single time. As far as I know, the systick timer needs to be reserved for the kernel at all times.
Last edit: Uli Köhler 2015-03-23