Page 1 of 1

Running ChibiOS demo on an Olimex STM32F405 and ST-Link V2 through OpenOCD

Posted: Sat Feb 11, 2017 8:37 am
by nick.wernicke
Hello everyone and Happy Valentines Day! I am (of course) having trouble running ChibiOS on an Olimex STM32F405, and I am not sure exactly where my problem(s) is(are). Development env is Windows 8.1 Eclipse Mars.2 Release (4.5.2) with the GNU plugins including OpenOCD. I am using an ST-Link V2 from Adafruit as debug tool.

I followed the instructions on how to set up eclipse and use/import a ChibiOS demo.
http://www.chibios.org/dokuwiki/doku.ph ... s:eclipse1
http://gnuarmeclipse.github.io/debug/openocd/

I used the RT-STM32F407 Discovery demo, and switched the linker script in the makefile from STM32F407 to STM32F405. I also changed the led blink function to GPIOC pin 12, which is the LED on the Olimex STM32F405. The demo compiles with no errors. I don't know if these two changes are sufficient to get ChibiOS running on an Olimex STM32F405 board.

I am able to use the STM32 ST-LINK utility to load the demo onto the Olimex STM32F405, and I can read the code back from the registers, but the LED does not blink. I do not know how to verify that the code is loaded correctly or that the processor is executing code or in a soft reset or w/e. Since the LED doesn't blink when loading the bin file directly, I wonder if the RT STM32F407 Discovery demo is not the right source, or maybe there is not a ChibiOS demo that can work with the Olimex STM32F405. I hope that ChibiOS can work with the F405 as I am a fan of the qfp-64 package due to its small size, fast processor and CAN bus port.

When I try and use OpenOCD to debug the software from inside Eclipse, it seems to load but then stops. All the text is red, not sure if that's normal or not. I used these commands from the debug instructions, but with monitor stm32f4x mass_erase 0 instead of stm32f1x. My project name is ch.

monitor soft_reset_halt
monitor soft_reset_halt
monitor wait_halt
monitor poll
monitor flash probe 0
monitor stm32f4x mass_erase 0
monitor flash write_bank 0 build/ch.bin 0
monitor soft_reset_halt

The solution is probably very simple, but I have been trying for a few weeks to get this to work and I have no idea what else to try. I can post the gdb openocd debug log if that will help. I am not sure if my ChibiOS example code is incorrect or if my OpenOCD settings are incorrect, and I am not sure how to debug beyond this point.

Thank you for reading and for any help you can provide. God bless.

Re: Running ChibiOS demo on an Olimex STM32F405 and ST-Link V2 through OpenOCD

Posted: Sat Feb 11, 2017 9:15 am
by steved
When you 'moved' the LED to a different pin, did you make sure the pin was set up as an output?

Suggest you download ChibiStudio, which is already set up for everything and just needs unzipping. Even if you don't keep it, it should help you understand what's not set up right.

Re: Running ChibiOS demo on an Olimex STM32F405 and ST-Link V2 through OpenOCD

Posted: Sat Feb 11, 2017 5:46 pm
by Giovanni
Correct suggestion.

In general, when porting a demo to another board it is required to create new "board files", see /os/hal/boards/xxxxxx/board.c|h|mk.

Those files are not manually written but generated starting from an XML description file with extension .chcfg. You need to add a folder in that boards directory (or in your project if you prefer), add a sub-folder cfg and copy a .chcfg file in there. Modify the chcfg file to fit you board then generate the files using the plugin included in ChibiStudio: select the .chcfg file in project explorer and a button appears in the toolbar, click, done. Note that the XML editor in eclipse is required, it also allows schema-driven editing, so you cannot do it wrong.

You can also install the generator plugin in your Eclipse environment by adding http://www.chibios.org/eclipse/chibistudio to the update sites. In ChibiStudio everything is pre-configured conveniently, including XML editors, Java support packages and other things.

Giovanni

Re: Running ChibiOS demo on an Olimex STM32F405 and ST-Link V2 through OpenOCD

Posted: Sun Feb 12, 2017 8:23 am
by nick.wernicke
Aha! The LED IS BLINKING AND THE CODE IS PAUSING AT BREAKPOINTS!

I had to add a line based on the Olimex Schematic to set the Olimex LED pin to an output:
palSetPadMode(GPIOC, 12, PAL_MODE_OUTPUT_PUSHPULL);

Thank you so much Steve and Giovanni. Chibistudio is pretty much an "easy button" for embedded programming.