System Workbench for MCU Your solution for Micro-Controller Development Build easily your STM32-based embedded systems with the free Ac6 OpenSTM32 integrated development environment Ac6-Tools offers a complete approach, ready to work and expandable for your future needs. The system clock have to be configured. It can be done by using the STM32CubeMX clock configuration feature or by the reference manual. In this example the system clock is fed by the internal PLL (Phase Locked Loop), which is sourced by an external 8 MHz crystal oscillator (HSE). Browse other questions tagged c eclipse arm stm32 or ask your own question. The Overflow Blog Podcast 334: A curious journey from personal trainer to frontend mentor.
I have always wanted to build with an ARM MCU, STM32 was on top of my to-learn list.
Happily, not so long ago a respected colleague lent me an STM32 Nucleo board to play with, as usual, it stayed in its box for a while and then I started learning about the STM32 MCU and the toolchain and the capabilities of that great MCU.
GitHub is where people build software. More than 50 million people use GitHub to discover, fork, and contribute to over 100 million projects.
So in this introductory post, I will discuss how to setup your Linux development environment and your arm-gcc toolchain to start compiling and running code on your STM32 MCU.
I will be using the SW4STM32
(System Workbench for STM32), it's a free development environment based on Eclipse and GCC, it supports mostly all the STM32 boards and microcontroller.
I went with SW4STM32
since it supports STM32 Nucleo boards, which I will be using through my experimentation with STM32 L4-series of ultra-low power microcontrollers, specifically, the NUCLEO-L452RERev C with the STM32L452RE
MCU onboard.
Register on AC6/OpenSTM32 Website
You would need to register on the OpenSTM32 Community Site, to be able to download the installer and follow instructions — yes, I know, it's just the way it is for now at least —
Install SW4STM32 Bare Metal Edition
Install System Workbench for STM32 - Bare Metal Edition by following the instructions on the OpenSTM32 website, there are two options, either by using the installer or by installing from Eclipse.
Ping me with any questions/issues regarding installation on Linux and I might be able to help 😄
STM32CubeL4 is the MCU Full Package for the STM32L4 Series as STMicroelectronics state on their STM32CubeL4 Github page.
It hosts very valuable examples and saves you some good time diving into SMT32L4 MCUs. Not only that, but it also includes project setups for multiple development environments including SW4STM32, MDK-ARM and EWARM.
I suggest you clone it or download it as a ZIP file into your machine using git
,
Let's start with the simplest of examples, the GPIO_EXTI
, EXTI stands for external interrupt line. You can find the example and project setup directories under the following path in the STM32CubeL4 repository:
The GPIO_EXTI
example demonstrates setting up an interrupt triggered by the falling edge of the PC.13
pin which is connected to the blue push button labelled USER
on the Nucleo board, this interrupt will control LED LD2
that is toggled On and Off as the user hits the USER
button.
Method A: Create New C Project
This method is only recommended if you are starting a project from scratch, I would suggest you follow on with Method B below, which is what I did in my experiment.
Now, let's start by creating a new C project from the menu click on File
> New
> C Project
,
Fill out the Project name
text field with your preferred value.
For Project type
choose Executable
-> Ac6 STM32 MCU Project
.
For Toolchains
there should be a single option: Ac6 STM32 MCU GCC
.
Now, click Next >
to proceed.
For the next window it would be Configurations, I'm using the defaults, so just hit Next >
if you are following along.
Now, the Target Configuration window, start by the Board
tab and select the correct board, for me, it's the NUCLEO-L452RE
,
So I'm choosing Series
as STM32L4
and Board
as NUCLEO-L452RE
.
You should end up with a window setup like this screenshot below,
Click Next >
, and you should see the Project Firmware Configuration window.
I will choose the Hardware Abstraction Layer (Cube HAL)
, if the firmware is available in your machine you should click on Download target firmware
button and wait for it to finish. In my case, I downloaded the firmware: STM32Cube_FW_L4_V1.13.0
.
Finally, click Finish
and we are done creating and configuring the C project.
Method B: Import Existing project (Recommended)
From File
choose Import
, and you should get the Import
window, now, select this import wizard option General > Existing Projects into Workspace
, then click Next >
.
Now click on Browse...
next to the select root directory: label.
You should now browse to the location where you downloaded the STM32CubeL4
git repository, and choose the SW4STM32
directory under GPIO_EXTI
project; I have mine in the following location,
Now, hit Finish
Project Explorer
If you follow up using Method B, you should end up with something similar to the following in the Project Explorer,
Build Project
Select the Project in the Project Explorer tab; Click on Project
in menu bar > Build All
.
Another method is to simply hit the hammer icon in the toolbar or Ctrl+B
.
Program Chip
Just follow the following steps to program the STM32 MCU and you are done 😉
Right-Click
on Project in the Project Explorer tab;From the menu, select Target
menu > click on Program Chip...
option
Test Program
Now you should be able to toggle the LD2
LED every time you push the blue USER
push-button 😄
Enjoy this little video in my tweet:
Day 21
After so much failing trials I finally got my first program to build and run for STM32L452 using a NUCLEO-L452RE dev board. See the outcome in the video attached
🎉
Feels great sharing my victory moment with you all!#STM32#100DaysOfCode#SW4STM32#STM32CubeL4#hardwarepic.twitter.com/qmcBQ4XyC2
Please feel free to ask about any missing details or suggest modifications or comment 😄
Now the OpenSTM32 system workbench is downloaded into the Software and Toolchain folder (Figure 1).
System Workbench For Stm32 Tutorial
Figure 1. STM32 installer downloaded into Software and Toolchain folder.
Now let's install that software.
Steps:
1. Click on the STM32 installer shown in Figure 1.
2. Now it is trying to install (Figure 2). In Figure 3, you can see that it is throwing some errors. But it is trying to execute that exe. Please be patient.
Figure 3. Machine is trying to execute the exe in spite of error.
3. After that, you will get the window, as shown in Figure 4, and just click next.
Figure 4. Popup containing information about STM32 system workbench.
4. Accept the terms of the license agreement and click next (Figure 5).
5. Then it will ask you to select the installation path (Figure 6), the place where exactly you want to store these installation files. You have to select your drive here. By default, it will consider a C drive. If you don't have enough memory in your C drive, then you can change it. Now let's change the drive to D drive, as shown in Figure 7. Then click next. It will create the folder AC6SystemWorkbench.
Figure 6. Choosing the installation path.
6. It will install the STM32 system workbench, a driver for in-circuit debugger and programmer, i.e., ST-Link version 2 and driver for that, and the ST-Link server. All three packs marked in Figure 8 are going to be installed. Now let's click next.
Figure 8. Selecting the packs to install.
7. After that, you will get a setup shortcuts window (Figure 9). Just click on next.
8. After that, you will see another popup window showing the installation settings. The popup shown in Figure 10 contains information about the installation path and chosen installation packs. Let's click next.
Figure 10. Information of installation settings.
9. Now the software is being installed (Figure 11). MAC and Ubuntu guys, for you also, this window will pop up when you run your binaries, and then you have to install this software.
10. You should see the system workbench folder in D drive now. Observe Figure 12. System workbench folder has been created, and all the files are being copied into that folder (Figure 13). Let's wait until it finishes the installation.
Figure 12. System workbench folder created in D drive.
Figure 13. Copying all the files into the system workbench folder.
11. It is throwing some errors, as shown in Figure 14. Now you can click yes to continue the installation.
Happily, not so long ago a respected colleague lent me an STM32 Nucleo board to play with, as usual, it stayed in its box for a while and then I started learning about the STM32 MCU and the toolchain and the capabilities of that great MCU.
GitHub is where people build software. More than 50 million people use GitHub to discover, fork, and contribute to over 100 million projects.
So in this introductory post, I will discuss how to setup your Linux development environment and your arm-gcc toolchain to start compiling and running code on your STM32 MCU.
I will be using the SW4STM32
(System Workbench for STM32), it's a free development environment based on Eclipse and GCC, it supports mostly all the STM32 boards and microcontroller.
I went with SW4STM32
since it supports STM32 Nucleo boards, which I will be using through my experimentation with STM32 L4-series of ultra-low power microcontrollers, specifically, the NUCLEO-L452RERev C with the STM32L452RE
MCU onboard.
Register on AC6/OpenSTM32 Website
You would need to register on the OpenSTM32 Community Site, to be able to download the installer and follow instructions — yes, I know, it's just the way it is for now at least —
Install SW4STM32 Bare Metal Edition
Install System Workbench for STM32 - Bare Metal Edition by following the instructions on the OpenSTM32 website, there are two options, either by using the installer or by installing from Eclipse.
Ping me with any questions/issues regarding installation on Linux and I might be able to help 😄
STM32CubeL4 is the MCU Full Package for the STM32L4 Series as STMicroelectronics state on their STM32CubeL4 Github page.
It hosts very valuable examples and saves you some good time diving into SMT32L4 MCUs. Not only that, but it also includes project setups for multiple development environments including SW4STM32, MDK-ARM and EWARM.
I suggest you clone it or download it as a ZIP file into your machine using git
,
Let's start with the simplest of examples, the GPIO_EXTI
, EXTI stands for external interrupt line. You can find the example and project setup directories under the following path in the STM32CubeL4 repository:
The GPIO_EXTI
example demonstrates setting up an interrupt triggered by the falling edge of the PC.13
pin which is connected to the blue push button labelled USER
on the Nucleo board, this interrupt will control LED LD2
that is toggled On and Off as the user hits the USER
button.
Method A: Create New C Project
This method is only recommended if you are starting a project from scratch, I would suggest you follow on with Method B below, which is what I did in my experiment.
Now, let's start by creating a new C project from the menu click on File
> New
> C Project
,
Fill out the Project name
text field with your preferred value.
For Project type
choose Executable
-> Ac6 STM32 MCU Project
.
For Toolchains
there should be a single option: Ac6 STM32 MCU GCC
.
Now, click Next >
to proceed.
For the next window it would be Configurations, I'm using the defaults, so just hit Next >
if you are following along.
Now, the Target Configuration window, start by the Board
tab and select the correct board, for me, it's the NUCLEO-L452RE
,
So I'm choosing Series
as STM32L4
and Board
as NUCLEO-L452RE
.
You should end up with a window setup like this screenshot below,
Click Next >
, and you should see the Project Firmware Configuration window.
I will choose the Hardware Abstraction Layer (Cube HAL)
, if the firmware is available in your machine you should click on Download target firmware
button and wait for it to finish. In my case, I downloaded the firmware: STM32Cube_FW_L4_V1.13.0
.
Finally, click Finish
and we are done creating and configuring the C project.
Method B: Import Existing project (Recommended)
From File
choose Import
, and you should get the Import
window, now, select this import wizard option General > Existing Projects into Workspace
, then click Next >
.
Now click on Browse...
next to the select root directory: label.
You should now browse to the location where you downloaded the STM32CubeL4
git repository, and choose the SW4STM32
directory under GPIO_EXTI
project; I have mine in the following location,
Now, hit Finish
Project Explorer
If you follow up using Method B, you should end up with something similar to the following in the Project Explorer,
Build Project
Select the Project in the Project Explorer tab; Click on Project
in menu bar > Build All
.
Another method is to simply hit the hammer icon in the toolbar or Ctrl+B
.
Program Chip
Just follow the following steps to program the STM32 MCU and you are done 😉
Right-Click
on Project in the Project Explorer tab;From the menu, select Target
menu > click on Program Chip...
option
Test Program
Now you should be able to toggle the LD2
LED every time you push the blue USER
push-button 😄
Enjoy this little video in my tweet:
Day 21
After so much failing trials I finally got my first program to build and run for STM32L452 using a NUCLEO-L452RE dev board. See the outcome in the video attached
🎉
Feels great sharing my victory moment with you all!#STM32#100DaysOfCode#SW4STM32#STM32CubeL4#hardwarepic.twitter.com/qmcBQ4XyC2
Please feel free to ask about any missing details or suggest modifications or comment 😄
Now the OpenSTM32 system workbench is downloaded into the Software and Toolchain folder (Figure 1).
System Workbench For Stm32 Tutorial
Figure 1. STM32 installer downloaded into Software and Toolchain folder.
Now let's install that software.
Steps:
1. Click on the STM32 installer shown in Figure 1.
2. Now it is trying to install (Figure 2). In Figure 3, you can see that it is throwing some errors. But it is trying to execute that exe. Please be patient.
Figure 3. Machine is trying to execute the exe in spite of error.
3. After that, you will get the window, as shown in Figure 4, and just click next.
Figure 4. Popup containing information about STM32 system workbench.
4. Accept the terms of the license agreement and click next (Figure 5).
5. Then it will ask you to select the installation path (Figure 6), the place where exactly you want to store these installation files. You have to select your drive here. By default, it will consider a C drive. If you don't have enough memory in your C drive, then you can change it. Now let's change the drive to D drive, as shown in Figure 7. Then click next. It will create the folder AC6SystemWorkbench.
Figure 6. Choosing the installation path.
6. It will install the STM32 system workbench, a driver for in-circuit debugger and programmer, i.e., ST-Link version 2 and driver for that, and the ST-Link server. All three packs marked in Figure 8 are going to be installed. Now let's click next.
Figure 8. Selecting the packs to install.
7. After that, you will get a setup shortcuts window (Figure 9). Just click on next.
8. After that, you will see another popup window showing the installation settings. The popup shown in Figure 10 contains information about the installation path and chosen installation packs. Let's click next.
Figure 10. Information of installation settings.
9. Now the software is being installed (Figure 11). MAC and Ubuntu guys, for you also, this window will pop up when you run your binaries, and then you have to install this software.
10. You should see the system workbench folder in D drive now. Observe Figure 12. System workbench folder has been created, and all the files are being copied into that folder (Figure 13). Let's wait until it finishes the installation.
Figure 12. System workbench folder created in D drive.
Figure 13. Copying all the files into the system workbench folder.
11. It is throwing some errors, as shown in Figure 14. Now you can click yes to continue the installation.
Figure 14. Error thrown while installing the software.
12. The installation is complete (Figure 15) and now let's click next.
13. After clicking next, it will ask your permission to install the device driver (Figure 16). Let's click next here.
Figure 16. Granting permission to install the device driver.
14. Now the ST-Link drivers are successfully installed on your computer (Figure 17). Now let's click finish. After that, you will get a processing window (Figure 18), click next.
Figure 17. Completion of ST-Link device driver installation.
15. STM32 system workbench installation has been completed successfully (Figure 19), and you can click done.
Figure 19. Completion of STM32 system workbench.
16. The system workbench for the STM32 microcontroller is successfully installed in the D drive, as shown in Figure 20.
Figure 20. System workbench for STM32 microcontroller installed in D drive.
Steps to launch the application:
1. The application is installed under the Ac6 folder.
2. You can see the installed application under the Ac6 folder, as shown in Figure 21. Just double-click over that to launch the open STM32 system workbench. This is one method.
Figure 21. Launching the application installed under the Ac6 folder.
System Workbench For Stm32 Generate Hex File
3. Otherwise, if you are on Windows, you can go to all files, find the system workbench (Figure 22), and then launch it.