Building The Stm32f4 Discovery Toolchain For Mac

Posted on

Some hard work has gone into making it possible to. The board boasts an ARM Cortex-M3 processor, which can be programmed via the mini-USB port on the side. But the company only supports development through their IDE’s which don’t run natively on Linux. The stlink project aims to solve this, providing a toolchain, and making it possible to flash the microcontroller via the USB connection.

  1. Building The Stm32f4 Discovery Toolchain For Mac Free

The github project linked above also includes (pdf). In addition to a walk through on compiling the software packages, it includes a simple blink program that you can use to test out your hardware., the familiar open-source debugger, is used to flash the chip.

This is a bare-bones tutorial so if you end up posting about your experiences using this toolchain with the Discovery boards. Thanks Texane Posted in, Tagged, Post navigation. ST is giving out free samples in the US / Canada of their ARM Cortex F4 part. I’ve never purchased the older Discovery boards since there were so many cheap or free Alternatives that actually work well on Linux. But this might be worth the effort due to the price and flexibility of the ARM GCC toolchain.

My free board arrived about a week ago. I tried this yesterday and had luck. I installed the arm toolchain through Ubuntu 11.10: sudo apt-get install gcc-arm-linux-gnueabi Then installed a few st-link requirements: sudo apt-get install libsgutils2-dev sudo apt-get install libusb-1.0-0-dev Get the st-link software from Texane: git clone stlink.git Compile the st-link sofware per the README and useful PDF that is included. Copy the udev rules to /etc/udev/rules.d/ and restart the udev service. There will a device node now at /dev/stm32lstlink2./st-util port /dev/stm32lstlink2 GDB can connect with: target remote:4242 I hope that this helps others. I look forward to seeing your results so that we may be able to get some code up and running on this board.

I was able to compile some example code and modify it for the STM32F4DISCOVERY, but it failed to load. I think that it’s a code problem on my part. Thanks to Texane and others for the great work on this. There are a bunch that aren’t too painful.

Anything that has a built-in JTAG interface that will work with OpenOCD should be fairly painless to get working. For example, any of the Stellaris eval kits which tend to include an FTDI-based (FT2232) JTAG interface are usable with OpenOCD. STM32F boards are pretty easy to work with if you at the very least have a serial interface to them and can control the BOOT0/BOOT1 pins since they all have a serial bootloader. There are various tools out there that should work with these (, ). Also, for the STM32F4DISCOVERY board, it should be possible to use the branch of dfu-util that Roger mentioned in this thread to program the board when put into DFU mode (which he describes how to do). Compiling dfu-util out of there can be a slight bit of a pain though since not only do you need libusb and pkg-config for the autogen.sh to work, but you also need autotools to pick up on the pkg.m4 file so that they can properly generate the configure script.

When having got libusb and pkg-config from homebrew, I did something similar to A number of LPC-based boards can be programmed using lpc21isp which has compiled fine for me on OS X: OpenOCD can be a little irritating to get started with, but it does work with a lot of JTAG interfaces (both built-in to eval boards and stand-alone) and getting a working JTAG programmer is probably one of the most universal ways to program a wide range of hardware. Toolchains are also fun, but I have a Makefile to help with that on OS X using the G Lite sources.

Please, read carefully. Thanks to the feedbacks I have received, I reached to the conclusion that it's really hard to cover a topic like this one in the room of a blog post. So, I started writing a book about the STM32 platform. In the free book sample you can find the whole complete procedure better explained. You can download it.

Building The Stm32f4 Discovery Toolchain For Mac

I recently got in my hands a new development board from STMicroelectronics: STM32Nucleo. It's a development board based on the STM32 MCU and it is compatible with the Arduino UNO pinout. This means that it's possible to use the hundreds of shields available for the Arduino. However this is true in theory, since the most important aspect of Arduino's world is the software (based on libraries, examples, and so on) made for this popular platform.

Building The Stm32f4 Discovery Toolchain For Mac Free

There are a lot of tutorials and guides around about how to start programming with the STM32 platform. ST provides an official framework, called, born to speed up the development process on this platform. STM32 is a really powerful yet complex platform, and the learning curve of this microcontroller can be really high compared to a simpler platform like the Atmel AVR (Arduino is nothing more than a huge boilerplate of code around AVR family). However STM32Cube is not sufficient to start developing with your Nucleo board. You also need an IDE (not strictly needed, but really useful) and a compiler suite. ST provides official support (with documentation and examples) only for commercial IDE like IAR.

And this is a great problem if you want simply to experiment with a low-cost platform like Nucleo (it costs less than €15). The good news is that you don't need a 5.000 dollars IDE: Eclipse and GCC is all you need (plus some other tools that we'll see in the next parts of this series). The bad one is the it's not simple or fast to setup-up a working tool-chain. I spent more than two weekends to setup a working environment to code, compile, flash and debug applications on my STM32Nucleo board, doing several errors before obtaining a fully working environment.

In this series, made of three parts, I want to share how to setup a tool-chain for STM32 platform. At the end of this first post we'll be able to compile an example program for the Nucleo (a simple blinking LED - the ' hello world' in electronics) and to upload it on our board using from ST.

I'll not show you too many details at once (but I assume that you know C language and fundamentals of MCU programming). To setup the tool-chain we'll use these two fundamental tools:. Eclipse: it's a popular free and OpenSource IDE, widely used in the Java world, but also available for C/C programming. We'll use the latest stable version: 4.4 (called Luna). GCC for ARM-Cortex: STM32 is a family of microcontrollers with an ARM-Cortex core (M0, M3, M4, etc). This means that we can use one of the best compiler (or, probably, the best) available for free. We'll use the cross-compiler version for ARM-Cortex platform.

The minimum system and hardware requirements of this series are:. Windows XP SP3 32bit (the whole series is based on XP, but I think that Vista and 7 are also fine - for a 64bit platform, choose the corresponding package). An STM32Nucelo development board (the specific model is not relevant) - I'll base the examples on my board, STM32Nucleo-F401RE. Java 7 update 71 or later - please, ensure you have the latest Java 7 version before you start installing other software (you can download it from ); don't say I didn't warn you. Warning: I strongly suggest you to use a virtual machine to do all experiments. I advise against using a development/production PC you use for work. Is a free virtualization software you can use to do experiments with STM32 platform.

When you'll be confident with the whole tool-chain, you can simply move it to the real PC without any risk. Install Eclipse Luna The first step is to install Eclipse. Actually, Eclipse is not strictly required to start programming with the Nucleo board. GCC and few other tools are sufficient to compile and flash your MCU. If you are among those who like to code using just editor (like myself), I'll write about this topic in a next post. In this series I'll try to keep low the learning curve and so I assume the use of Eclipse IDE. This tutorial is based on the latest version of Eclipse, called Luna (4.4 release).

You can download the 'Eclipse IDE for C/C Developers' release. This release is especially designed to develop application with C/C programming language. The downloaded file is just a ZIP archive. You can expand it in the C: STM32Toolchain folder ( N.B.: that path is not mandatory, but I'll assume that you install the whole tool-chain in that location during these tutorials. If you decide to install the tool-chain elsewhere, please adapt my instructions consequently).

When finished, you can launch the C: STM32Toolchain eclipse eclipse.exe executable. The first time Eclipse starts, it will ask your for the default projects folder. I suggest to use the path C: STM32Toolchain projects. When the IDE is started, go to Help-Install New Software. Next, select the C/C Development Tools repository and check only the entry 'CDT Main Feature', as shown in the following picture.

Now, click on 'Next' and follow the instructions. The installation requires some time to finish.

At the end, restart the IDE as requested. Install the GNU ARM plug-ins for Eclipse Now we have to install the. These plug-ins add a rich sets of features to Eclipse CDT to interface GCC ARM tool-chain. Moreover, they provide specific functionalities for the STM32 platform. Plug-ins are developed and maintained by Liviu Ionescu, who did a really excellent work in providing support for the GCC ARM tool-chain.

Without these plug-ins it's almost impossible to develop and run code with Eclipse for the STM32 platform. To install GCC ARM plug-ins go to Help-Install New Software. And click on the ' Add.' Fill the text fields in the following way:.

Vdo cdr 2005 keygen for mac. Name: GNU ARM Eclipse Plug-ins. Location: and click the ' OK' button. After a while, the complete list of available plug-ins will be shown. Select plug-ins to install as in the following picture: Then, click on ' Next' and follow the instructions. Restart the IDE when requested. Install the GCC ARM tool-chain The next step is to install the GCC tool-chain for the ARM Cortex platform.

You can download a prebuild version for your operating system from this. I successfully tested the release.

You can download the and start the installation. When asked, install the tool-chain in the following directory C: STM32Toolchain gnu-arm 4.8-2014q3 (as I said before, you can choose the path you want, but I'll assume this path in the next steps). IMPORTANT: I strongly suggest to leave unchecked the entry ' Add path to environment variable', especially if you have other compilers or IDE installed on your PC (for example, if you use MinGW or similar package manager for Windows). Now go on with the next step.

Install the Build Tools Windows historically lacks of some tools that are a must in the UNIX world. One of these is make, the tool made by Richard Stallman that controls the compilation process of programs written in C/C. If you have already installed a product like MinGW or similar, you can skip this process. If not, you can install the Build Tools package made by the same author of GCC ARM plug-ins for Eclipse. You can download setup program from. When asked, install the tools in these folder: C: STM32Toolchain Build Tools. Restart Eclipse.

Install the ST Link drivers for STM32Nucleo board This is a really important step. Pay attention to the next instructions. Before installing any other piece of software, it's convenient to install the drivers for the STM32Nucleo board. Important: before install drivers, disconnect the board from the USB port! One of the key feature of Nucleo board is that it already provides the on-chip programmer for STM32 MCUs: the ST-Link.

In fact, Nucleo boards are made of two parts: the ST-Link programmer (the one with USB connector) and the target board (the one with Arduino-style expansion headers). It's important to highlight that different from the commercial ST-Link programmer, the Nucleo board provides a more recent version of ST-Link: the 2.1 version. This means that you have to update your drivers even if you already have an ST-Link programmer.

You can download the latest drivers from. Install the drivers and check that everything works correctly.

When you connect your board to the PC, you should see two new peripherals: the ST-Link programmer and a Virtual Com Port. If everything works correctly, you can go to the next step. Important: some Nucleo boards (like the mine) need a firmware update of the ST-Link part. After installed the drivers, you can download the firmware update from and follow the instructions. This step is really important! Install STM32CubeMX and ST-Link Utility When a STM32 MCU starts, it needs an hardware configuration to work correctly. This configuration is dependent of the specific MCU and the chosen hardware configuration.

This configuration must be performed when the CPU boots-up. Unfortunately, this is not a trivial task and it requires a deep knowledge of the specific MCU. However, we have a more short way to do this work. ST provides a dedicated tool that generates the initialization code for us. This tool is called STM32CubeMX and it will come really useful in the next part of this tutorial. So you can start to download it from (you'll find the download link at the bottom of page).

Install it following the suggested configuration. To simplify this part of the tutorial we won't use any debugging tool inside the Eclipse IDE, but we'll use the official ST-Link Utility tool to flash our Nucleo boards. You can download this tool from. Install it following the suggested configuration. For the sake of completeness, I've to say that ST distributes a CubeMX version as Eclipse plug-in.

Unfortunately, this plug-in seems not working correctly. My Eclipse crashed and it's totally unusable unless I don't remove the CubeMX plug-in. Probably this plug-in isn't still tested with the Luna version.

For this reason, I'll use the standalone version in these tutorials. Start STM32CubeMX and go to ' New Project'. Click on the tab 'Board Selector'.

In ' Type of Board' choose Nucleo. In the ' MCU Series' drop-down list choose your Nucleo target MCU version. Next, in the column labeled ' Peripheral Selection'add ' 1' to rows Led and Button.

In the ' Board List' table, choose your exactly Nucleo version. Click on ' OK'. CubeMX will show your target Nucleo MCU and its configuration. A description of the CubeMX software is out of the goals of this tutorial. I'll give a deep description of this tool in a next post. We only use it to generate the right oscillator configuration.

Go to ' Project-Generate Code' and fill the fields like in the following picture. Click on ' OK' button. CubeMX will ask us if we want to download the latest version of STM32Cube framework. In our case, we can choose 'NO' since the GNU ARM plug-in already provides the latest framework version. Click on 'Continue' in the next message box. When the generation ends, click on 'Open Folder' and go inside the ' src' folder.

Open 'main.c' file and copy the whole content of the function SystemClockConfig(void). If you have the same Nucleo board I have, the generated code will be equal to this one. HALRCCClockConfig ( & RCCClkInitStruct, FLASHLATENCY2 ); This code is the right configuration for the system clock of our Nucleo board. As you can see, STM32 MCUs have a non-trivial clock configuration.

CubeMX dramatically simplify this step, allowing us to concentrate on the application development. Copy the generate code inside the SystemClockConfig function. Now, go back to Eclipse and open the file initializehardware.c contained in the ' src' folder.

Substitute the whole content of configuresystemclock(void) function with the one we have copied before. Now go to ' include' folder and edit the file BlinkLed.h. Go to line 30 and modify the LED port configuration in the following way. Attention: I spent 4 damned hours before I've understood that ST-Link Utility doesn't load the.hex file every time it changes. This means that you are uploading the previous version of binary file.

You have to reload it manually. To do this, click with the right button on tab named 'test1.hex' and choose 'Open file', as shown in the following picture. Mission accomplished. We've successfully programmed our Nucleo board. In the next post I'll show how to configure Eclipse to flash the MCU and to do step-by-step debugging. This article is part of a series made of three posts. The second part is, the third.

Dear Carmine, thanks a lot for this very good tutorial. Instead fo the Nucleo board I use a STM32F4Discovery and observe the following thing: After flashing the board I get a message like ' 10:34:48: Device ID:0x413 10:34:48: Device flash Size: 1MBytes 10:34:48: Device family:STM32F40xx/F41xx 10:34:52: Memory programmed in 1s and 14ms. 10:34:52: Verification.OK ' in the ST-Link Utility Console.

What seems to be OK, but the LED does not blink. Only after disconnecting and connecting the board the LED starts flashing. I can modify the code in eclipse (change the LED pin in the BlinkLED.h ' #define BLINKPINNUMBER (14)' to somethimg between 12 and 15) and after flashing it is the same game.

Only after a short unpugging of the board the LED (depending on the selected pin number) starts to flash. Pressing the reset button does not help. Furthermore the green/red LED continously changes colour after flashing the code. Is the flash procedur not compleately finished? Hi Carmine, Thank for your hint.

I found the problem. I think I installed the Drivers and ST-Link Utility in the wrong order. Now i works fine. But I'm faced with a new problem: After 'Generate Code' of a new project in STM32CubeMX you propose to '. “Open Folder” and go inside the “src” folder.

Open “main.c” file. ', but in my case: - After 'Open Folder' nothing hapens, I even cannot close STM32CubeMX. I have to close it via the Task-Manager. If instead 'Close' is pressed everything is fine and the 'main.c' is newly build and can be open via the Windows Explorer. If instead 'Open Project' is pressed I get the message 'Please install TrueSTUDIO 4.3.1 to open the project. Or associate the file type of your project with the toolchain in your Toolchain in System Default Tollchain settings' Is there anything I have to take care for if I install TrueSTUDIO 4.3.1 or newer?

Hi Sloth, I made a test project and you are right: the initializehardware.c file is not generated. The file in system-src-cortexm should not modified, because it's part of the official STM32Cube-F1 library. If you see inside that file, all functions are declared as attribute((weak)). This means they can be overridden in another file.

However, I suggest starting add clock configuration in that file and see if the board works correctly. Unfortunately, I haven't a F-103RB board to do tests. I decided to buy one as soon as possible. For those of you are having problems to follow my instructions on Nucleo-F1 boards, I reached to the conclusion that for STM32-F1 the author of GNU ARM Eclipse plug-in hasn't implemented yet templates for HAL drivers (those contained in STCube-F1 framework). This post explains this: So, the generated project template is for the old and unsupported Standard Peripherals Library (STD) from ST. My instructions can't work.

I'm going to write down instructions to create a complete bare-bone template for F1 boards, but I need the time and a F1 Nucleo board to do tests. Please stay tuned 😉. Beautifully detailed tutorial - unfortunately I followed all the steps and it isn't working for my STM32F411:). I'll need to meditate over it during the weekend and see what's wrong. I'm very new to ARM and 32Bit MCUs, bought my first one yesterday.

My experience is more with the 8-bit AVRs and PICs. I'd like to know what you think of using mbed.org for developing projects on this board - any problems/issues you see? It's very simple to get started using mbed.

Most of the other IDEs have a limitation on 32K code size, but mbed.org doesn't seem to have that and it.appears. to be free. Beautifully detailed tutorial - unfortunately I followed all the steps and it isn't working for my STM32F411:). I'll need to meditate over it during the weekend and see what's wrong. I'm aware of the fact that these instructions are not complete and don't perfect match all STM32 sub-families.

To address this, I've decided to writing a more deep 'tutorial' in a form of book. I'll publish it soon (I've decided to start publishing the first five chapters - almost 120 pages).

If you are interested in knowing when, you can. I'd like to know what you think of using mbed.org for developing projects on this board - any problems/issues you see? It's very simple to get started using mbed. Most of the other IDEs have a limitation on 32K code size, but mbed.org doesn't seem to have that and it.appears. to be free. Simply, I've no opinions about mbed.

I'am always skeptical when it comes to these giant pieces of code, especially when dealing with the hardware. Moreover, all this stuff around IoT world is still unclear where it's going. I like to play with STM32 HAL for the moment, especially to develop 'commercial' products (for hobbyists probably worth a look).

Okay I got it to work for the Nucleo-F411RE (MCU STM32F411RET6). I made a mistake in setting the pin configurations in BlinkLed.h. There is a #IF condition for the pinouts depending on the board and I set the ones for the board which wasn't correct. So I removed the #IF #ENDIF lines and just had the definitions for the pins: #define BLINKPORTNUMBER (0) #define BLINKPINNUMBER (5) #define BLINKACTIVELOW (0) and it started working. A few points though - 1) The programmer LED keeps blinking in a red-green dance as long as it's connected to the ST-LINK Utility. Stops blinking if we disconnect it.

2) The function in initializehardware.c for me is SystemClockConfig(void) and I just replaced the contents of this function with the STM32CubeMX output as explained in the tutorial. Thanks once again! Dear Carmine, My question is about setting up the toolchain on a Macbook Pro with Mac OS X 10.11.3 (El capitan) as per your book version 0.8 (bought in Feb 23). I have tried several times to register to book's forum page but with no success.

Building The Stm32f4 Discovery Toolchain For Mac

So, I have nothing to do but to write the issue here. Basically I am unable to establish proper connection between my Mac and Nucleo board (with the latest FW version). I guess the problem may have some roots on libusb-1.0 installation (section 2.4.4, p.84). The issue surfaces by executing the openOCD test script as given in the text, p.86. OpenOCD exits with Error: read version failed. I have tried to connect to board with stlink (texane) but./st-info -descr command result in !

sendrecv. So this is not a openOCD issue.

Building

A short googling revealed several similar forum entries but with no solutions, e.g., One specific entry for a similar but not exactly the same issue states that this is an issue in El Capitan which will be corrected by the latest OS X release, i.e., 10.11.4. I am curious that if you have some sort of solution for this, or may be I am making something totally wrong.

Your help will be greatly appreciated. Regards, Mert PS. Just a small comment. In order to build openOCD on El Capitan I have to patch openOCD as per Change 2838. In this command, boards should be board. $./src/openocd -f boards/.cfg.

Hi Carmine, I have gotten my st-link utility to program my nucleo again, but this time when I try build a project, it does not generate the hex file I need. It worked the first time, I dont know what I did different this time. Will you have a look at this error and point me in the right direction? Hi Carmine, thanks for the tutorial, It is very usefull, and i have got the complete book. Howver I have a problem with the ST-LINK utility when i want o program the board I use the nucleo board STM32L053R8. I have buils the envrionnment with eclipse following the tutorial ad modiye some parts for the specific board, using stm32 cube I have update the firmware.

With ST-LINKUpgrade when i program the board with mbed ( drop the binary on the device), it works When i use the stm32 st-link utility, it detects the board ( flask size and core), but i have always this error 'No elf loader found for this operation' so whan i want to download the. Hex file, it doenst work. So do you have an idea of the problem, what can be worng? Cannot complete the install because one or more required items could not be found.

I'm a software developer and hardware designer in Italy, where I live in the countryside close to Naples. I spend half of my professional career working on distributed system, coding thousands line of code in Python, my favorite programming language. Since 2010 I've started diving in the electronics world, and my actually interests and work activities are about circuit design and firmware development.

I'm one of the founders of a company that develops, produces and sell wireless automation systems. More about me.