ChibiOS on the Spark Core
Posted: Mon Jul 07, 2014 9:47 pm
Hi all,
I'm trying to run ChibiOS on the Spark Core http://docs.spark.io/hardware/.
It features a STM32F103CB, so I started by using the demo in demos/ARMCM3-STM32F103 as a template and modified main.c to just blink a led in a thread.
I copied board.c, board.h and board.mk from boards/MAPLEMINI_STM32_F103 (same MCU) to boards/SPARK_STM32_F103 and disabled everything in halconf.h except for TM and PAL.
Since the Spark Core comes with a bootloader https://github.com/spark/bootloader, I modified (as stated in various posts in these forums) the linker script with the new flash starting point (0x8005000 instead of 0x8000000) and set the CORTEX_VTOR_INIT to 0x5000 in chconf.h
Sadly, I don't have a JTAG, so my only means of debugging are the three leds on the board (RGB).
At first, nothing worked and fiddling with the code I found that CORTEX_VTOR_INIT was the culprit: by setting it to 0x0000 chSysInit() is executed without errors, otherwise it hangs.
With this fix, the leds started to turn on but they were not turning off because the code was entering chThdSleepMilliseconds and never leaving. Removing the call to chThdSleepMilliseconds and replacing it with a loop "solved" the issue and the led blinked.
I changed the main thread to blink the blue led and the other thread to blink the green led (both NORMALPRIO): only the main thread was blinking. Adding a chThdYield to both threads, they started to blink blue and green alternately.
I suspected that interrupts are not served correctly, expecially the SysTick, so I tried to turn on a led in the SysTick hook...and it seems to never be called...
Any suggestion/hint/idea of what is going wrong?
Thank you.
P.S.
I'm using the gcc arm toolchain with the ChibiOS Makefile. You can find in attachment the project together with the linker script and the original linker scripts of the Spark Core firmware.
I'm trying to run ChibiOS on the Spark Core http://docs.spark.io/hardware/.
It features a STM32F103CB, so I started by using the demo in demos/ARMCM3-STM32F103 as a template and modified main.c to just blink a led in a thread.
I copied board.c, board.h and board.mk from boards/MAPLEMINI_STM32_F103 (same MCU) to boards/SPARK_STM32_F103 and disabled everything in halconf.h except for TM and PAL.
Since the Spark Core comes with a bootloader https://github.com/spark/bootloader, I modified (as stated in various posts in these forums) the linker script with the new flash starting point (0x8005000 instead of 0x8000000) and set the CORTEX_VTOR_INIT to 0x5000 in chconf.h
Sadly, I don't have a JTAG, so my only means of debugging are the three leds on the board (RGB).
At first, nothing worked and fiddling with the code I found that CORTEX_VTOR_INIT was the culprit: by setting it to 0x0000 chSysInit() is executed without errors, otherwise it hangs.
With this fix, the leds started to turn on but they were not turning off because the code was entering chThdSleepMilliseconds and never leaving. Removing the call to chThdSleepMilliseconds and replacing it with a loop "solved" the issue and the led blinked.
I changed the main thread to blink the blue led and the other thread to blink the green led (both NORMALPRIO): only the main thread was blinking. Adding a chThdYield to both threads, they started to blink blue and green alternately.
I suspected that interrupts are not served correctly, expecially the SysTick, so I tried to turn on a led in the SysTick hook...and it seems to never be called...
Any suggestion/hint/idea of what is going wrong?
Thank you.
P.S.
I'm using the gcc arm toolchain with the ChibiOS Makefile. You can find in attachment the project together with the linker script and the original linker scripts of the Spark Core firmware.