A Better Template For Your STM32 F3 Dev Board

If you’ve picked up one of those really cool STM32 ARM dev boards, you’ve probably poked around looking for a good toolchain. No fear, then, because [Matt] has your back. He put together a template for the ARM Cortex-M4 powered STM32 board.

[Matt] had been using a template for the STM32 F4 we’d covered before, but found the implementation a bit lacking. Wanting to exploit the functionality of his fancy STM32 F3 board, [Matt] took the F0 template whipped up by our very own [Mike S] and got it to work with the newer, fancier dev board.

There are a few bonuses to using [Matt]’s template; the ARM chip in the F3 Discovery board has a hardware floating-point unit that is inaccessible using the Code Sourcery G++: Lite Edition toolchain. [Matt]’s use of gcc-arm-embedded allows access to the hardware FPU, a great benefit for a great board.

20 thoughts on “A Better Template For Your STM32 F3 Dev Board

  1. I’d like to ask why nobody uses the pure CMSIS directly from ARM http://www.arm.com/products/processors/cortex-m/cortex-microcontroller-software-interface-standard.php. It has better license than that stm liberty and is somehow ‘clean’ just add flash and ram addresses to .ld and vendor specific interrupts name to .s template.

    And I’d also like to ask, why is everybody using commercial partialy-closed-source CS G++ when we have https://launchpad.net/gcc-arm-embedded and others that just work!

    1. CMSIS is just an abstraction layer for the core peripherals (NVIC, systick timer). The vendor peripheral libraries are layered on top of CMSIS. Also why not just build directly from FSF sources without going through any “platform” or vendor.

      1. I’m sorry. I may have incorrectly used the word ‘pure’. In the package I provided the link for are linker script and startup script templates that just work for any Cortex M. The linker script in the complete template presented here is from Raisonance toolchain and startup script from Attolic. This is what I consider ‘less’ pure than those very generic files directly from ARM.

        For the CS G++: It contains some inside startup routines “cs3” for which source code is hard to obtain. (At least in the past you could have done it by obtaining demo version with full source codes. The lite version’s sources does not include these cs3 routines!) Linker script and startup script actually hook into these cs3 routines. GCC toolchain I provided link for work as good as CS G++ and it’s really opensource and the above mentioned templates work with it.

        Vendor specific files have to be included of course, however linker and startup script do not have to be one of them. Just stm32f30.x, stm32f30x_conf.h and stm32f30x_system.h (+ ST’s Standart Peripheral Library).
        Btw. I do not like FSF and almost hate Richard Stallman with his ideas and points of view.

        1. “Btw. I do not like FSF and almost hate Richard Stallman with his ideas and points of view.”
          What has that to do with anything? If it’s such a big deal maybe you should buy a compiler and stop using GCC.

          1. Actually you (or someone with the same nickname) mentioned FSF first by this sentence: “Also why not just build directly from FSF sources without going through any “platform” or vendor.” which I got as a sarcasm and I took a rather defensive stance!
            I must admit my first post is badly written. All I wanted to say: “Hey why has this guy used modified Reisonance + Attolic scripts mix when there are templates directly from ARM distributed with CMSIS implementation example.”

        2. Just so you know, your need to make off topic derisive comments about Stallman says A LOT more about you than you might like, and actually very little (if anything) about Stallman ;)

    2. I’ve dumped cs gcc some time ago for summon-arm-toolkit. I’m not fond of CS at all. I think it’s quite popular because quite some tutorials say “install codesourcery gcc”. And once you have it, it tends to stick.
      BTW, it might very well be a good environment if you’re a professional developer, when a support option might be very useful. But for hacking, leave it alone.

    1. People keep saying that but it’s not in the ChibiOS_2.4.3.zip Under boards there are five folders for STM Discovery boards and none are for the F3. There’s the 8L, 8S, 32F4, 32L and 32VL.

      Please tell us WHERE this STM32F3 Discovery version of ChibiOS can be found.

  2. That chip is beautiful, I am using it with it’s DSP and floating point accelerator to do FFT and it is blazing fast.
    4 X 12 bits AD, 2DA !
    Not to say that i can put the results over usb in CDC mode.
    And all this with a single chip, +4 caps, not even a crystal!

    1. The STM32F3 absolutely needs a crystal for USB communications. It’s just that on the Discovery board the debug interface MCU also acts as a USB-serial converter for the main MCU.

  3. Hi, I’m Matt that posted the modified template.

    The chip is supposed to have 48K RAM, but it sounds like 8K of this is special “core-coupled” RAM with a different memory mapping. Right now, I tell the linker scripts that the board only has 32K RAM just to be safe. If someone figures out how to properly deal with this (I’m a n00b when it comes to linker scripts), I’ll update the repository.

    Thanks!

    1. I’m sorry. You can’t use the CCM like ordinary memory. It’s completely off the bus matrix. You cannot use DMA, etc. for it. The way to use it in C++/C is to define new section in liker script just like FLASH or RAM and then use it like int x __attribute__ ((section (“CCM”))) = 0; // where CCM is name of your new section. I have not tested it, but it should work this or similar way. Remember, don’t use it for DMA and peripherals, however the processor should have faster read and write accesses to this memory than to main SRAM.

      1. I seem to recall the spec saying that this CCM is on the instruction bus, so they recommended putting critical code sections in it. Can you use a similar notation with functions, or is that limited to variables? Or would I have to modify assembly to get code in CCM?

        1. >Can you use a similar notation with functions,

          Yes, you can tell GCC what section to put a function into via the section attribute. I use this (not on STM32) to put a function into RAM (data section) after boot so that it’s available after the ROM has been disabled as part of a “reboot into RAM” system. You will probably get some linker warnings though. I think really though you should be using the CCM for the “hot” section. If you give functions the hot attribute GCC will pay more attention optimizing that function because you have told it that it gets called a lot and it should try to put it in the hot section.

Leave a 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.