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.

Comments

  1. Grawp says:

    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!

    • asdf says:

      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.

      • Grawp says:

        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.

        • asdf says:

          “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.

          • Grawp says:

            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.”

        • Cyril says:

          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 ;)

          • heh says:

            It says that he’s a sane individual, whereas we already knew that isn’t Stallman’s case, so yeah, nothing new there.

    • hans says:

      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.

  2. mabl says:

    You may also want to check out ChibiOS which has native support for the F3 Discovery.

  3. jacques says:

    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!

  4. Matt says:

    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!

    • Grawp says:

      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.

      • Matt says:

        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?

        • Grawp says:

          I’ve done little googling and found this http://ez.analog.com/thread/10607. Why this works is explained in ld manual http://www.math.utah.edu/docs/info/ld_3.html#SEC18 look for AT command.
          Thank you for asking this! You gave me an idea. I’m going to put quaternions calculations to CCM for my quadcopter project.

        • cantido says:

          >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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 92,391 other followers