STM32 F4 Discovery Tutorial Using Open Source Tools

[Pulko Mandy] got his hands on the new STM32 F3 Discovery board. He’s a fan of the open source tools just like we are, so he posted a guide covering the use of an open source toolchain with the F3 hardware.

This board was just announced earlier this month but there is already support for it in OpenOCD. It’s not all that different from the F4 board, which we would think made the process a bit easier. [Pulko] is using the Sourcery CodeBench Lite toolchain, which works for pretty much all of the ARM chips out there. It is GCC based and comes with GDB for debugging (along with all the other tools you would expect). He did created his own Linker script and startup code. These are crucial for ARM so it’s nice that he provided them for us. He finishes up the guide by showing how OpenOCD can be used to flash the code to the chip and how it works with the debugger.

[Photo source]

19 thoughts on “STM32 F4 Discovery Tutorial Using Open Source Tools

    1. It took me less than a few hours (mostly due to pebkac) to build a toolchain from scratch to program a chibios demo into my disco F4. Thanks gentoo for crossdev.
      I still have to test debug with texane (I use another tool for flashing, don’t remember name).
      Chibios gives already all linker, rtos files and drivers. Ready to code!

    1. The goal was to understand (and explain) what is going on. I see some people handling linker scripts as ‘black magic’, and relying on toolchain vendor wizards to do it for them. I made a linker script and startup code as simple as possible so everyone can understand what’s going on.

  1. I picked up an older discovery board thinking it was such a steal at $10, but I wasn’t too impressed that I had to register in order to get the dev tools.

    Eventually I registered for the tools (twice) and never got the software, so this board sits with my other unused dev boards. Maybe they don’t like Canadians?

      1. Ya I had the STM8S board, so the 32-bit tools ain’t no good. This was a few years ago that I bought the board and ran into this problem, so maybe there are some open tools nowadays.

        My point was that out of the box, the thing was unusable :(

    1. It shouldn’t be very hard to make it work on the F4, but don’t have the hardware.
      Anyway :
      * STM32F4 Discovery is supported out of the box by OpenOCD git tree (I don’t know about the 0.6.0 release, it might have it as well). So, no need to apply patches and get a config file.
      * The startup should be identical for any Cortex-M device.
      * The linker script needs to be changed. At the top of it you’ll find some lines defining the flash and ram size and address. Just change these to match the memory map of the F4 chip, which you can find in the Reference Manual for it.

      Also remember that this is a very minimal approach to the startup, you’ll need to setup most of the hardware from C code (the most important part being the system clock, which isn’t changed by the startup so is likely to be some slow internal RC oscillator default setting).

  2. Hi guys,
    I would like to ask you a couple of questions:

    you can simulate a stm32 debug with OpenOCD (without hardware)? if so, how?
    I read somewhere that you can not do, for the simulation using qemu, but only for m3 stellaris, and not to those of the ST.

    with a debug in ram you have the ability to have multiple breakpoints, but have never been able to debug in ram, even changing the ld script. Can you give me a hint?

    Thanks

  3. It’s the process of working through the various stages of mind over matter principles.
    Costs will have to include things like pre-surgical tests, surgeon’s fees and hospital fees.
    If parents are capable of putting their own issues aside for the sake of their children, whatever setup the family ends up with after mediation in divorce will work.

  4. I usually do not leave a leave a response, however I browsed a few responses on STM32 F4 Discovery tutorial uszing open source tools | Hackaday.

    I actually do have 2 questions foor you if it’s okay.

    Could it be only mme or does it look as iif like some
    of the rsmarks come across aas if they are left by brain dead folks?
    :-P And, if you are writing at other online social sites, I’d like to follow
    everything fresh you have to post. Could you make a list oof all of alll your
    shared sites like your linkedin profile, Facebook pave or
    twitter feed?

Leave a Reply to ayuda psicologicaCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.