This Wiki page contains information how to use the System Workbench for STM32 IDE, also known as SW4STM32.
The System Workbench toolchain, called SW4STM32, is a free multi-OS software development environment based on Eclipse IDE for C/C++ developers (Eclipse CDT). It supports the full range of STM32 microcontrollers and associated boards. It is also used by Modtronix for our STM32 based boards. There is a lot of information available online if you get stuck.
Without using SW4STM32, it is very time consuming getting the GCC C/C++ compiler and debugger working. SW4STM32 makes STM32 development very easy by providing a single tool that can be used for entire software development cycle.
Installation is quite simple, and basically just involves downloading and installing the app from openstm32.org. After installation, it is often required to check for updates in Eclipse(SW4STM32) to update to the latest version.
The “System Workbench for STM32” user forum also contains a lot of useful information, and is located here. You will find help on their site relating to installation, debugging, programming of STM32 target, importing mbed project, importing STM32Cube(STM32CubeMX) projects and more.
Because SW4STM32 is an Eclipse based tool, projects are always part of a workspace. Many Modtronix example and source code downloads include a SW4STM32 workspace with projects. To see if a download has a SW4STM32 workspace, look for a “SW4STM32” folder in the root directory. This is the SW4STM32 workspace folder, and will contains one or more SW4STM32 projects. The SW4STM32 IDE can be used to compile, debug and program the target board using a ST-Link or CMSIS-DAP based programmer/debugger.
STM32 based software meant for the SW4STM32 IDE is contained in a workspace, with one or more projects. This workspace and project(s) can be imported into SW4STM32:
To program(run) and debug a target board, it must be connected to the PC using a supported programmer/debugger. This tutorial supports:
All new Modtronix STM32 based projects will use CMSIS-DAP programming/debugging by default. The reason is that our boards are designed for the mbed environment, and this is the default programmer/debugger used by mbed.
To use CMSIS-DAP programming/debugging:
To configure an imported project to use this programmer/debugger is quite simple. Follow these steps:
After completing this one time setup, the board can be programmed via the <Run><Run>(Ctrl-F11) command, and debugged via the <Run><Debug>(F11) command.
For this to work, the target must be connected to a ST-Link/V2-1 programmer(SWD mode), like the Modtronix PGM-NUCLEO. The picture on the right shows the PGM-NUCLEO connected to the NZ32-SC151 target board.
To debug and program the target board, we first have to create a new Debug Configuration. This only has to be done once. Once done, the board can be debugged via <Run><Debug>(F11) menu, and programmed via the <Run><Run>(Ctrl-F11) menu. To create a new Debug Configuration do the following:.
The recommended programmer for Modtronix NZ32 STM32 based boards is the PGM-NUCLEO programmer. It requires the ST-Link/V2(ST-Link/V2-1) USB Drivers. Just search the net for “st link usb drivers”. At the time of writing this, they were available here.
Note that the USB Driver application supplied by ST will NOT install the drivers on your computer! By default, it will create a “STMicroelectronics” folder in “Program Files (x86)” directory. This folder will contain the USB drivers for 32-bit and 64-bit operating system. You will have to install the correct driver on your system (located in ”..\Program Files (x86)\STMicroelectronics“ folder) to complete the installation.
Seeing that the PGM-NUCLEO programmer is actually the programming part of a NUCLEO-F411RE board, the Nucleo documentation is also relevant. Useful information can be found here, and on the NUCLEO-F411RE page on mbed.org (“Nucleo ST-LINK/V2 driver installation and firmware upgrade” section at bottom of page).
To import a new library or source code is very simple:
There are many free libraries provided on mbed. For example, Modtronix provides many free libraries on our mbed project page. For this example we will import the modtronix_LCD2S library into our project:
mbed projects can be imported and compiled using SW4STM32. See this page on openstm32.org for detailed description. If link is broken, search internet for “Importing mbed project System Workbench for STM32”
STMCubeMX projects can be imported and compiled using SW4STM32. See this page on openstm32.org for detailed description. If link is broken, search internet for “Importing STM32CubeMX project System Workbench for STM32”
Once the project is all configured and building, there are many additional settings that can be fine tuned and personalized. When searching online, include “Eclipse CDT” with your search text. This IDE is based on Eclipse CDT.
After importing a workspace/project, optimization seems to be disabled by default. The code size of the built project can be significantly reduced by enabling Optimization. To enable compiler optimization, do the following (click image on right to enlarge):
Newlib is a highly optimized version of the standard C library. It also seems to be called MicroLib or nano library. It has been designed for use with embedded applications where memory resources are limited. To minimize code size, it has less functionality than the default standard C library. For details, click here. For details about the Keil version of MicroLib, see this page. To use Newlib in stead of the standard C library, do the following (click image on right to enlarge):
The time taken to build a project can be greatly reduced by enabling parallel build. To enable it, do the following (click image on right to enlarge):
When building the project, I get the error message “fatal error: filename.h: No such file or directory”
Answer: First check if the given file actually exists. Next, ensure the file path where this file is located is included in the “Paths and Symbols” properties:
printf does not work with float data types.
Answer: For float to work with printf, the ”-u _printf_float“ flag must be added to the linker. This will however increase the code size quite a bit, about 4kByte for our test. If possible, alternative methods should be used. To enable float for printf, do the following: