This Wiki page contains information how to use the System Workbench for STM32 IDE(also known as SW4STM32) with Modtronix STM32 based boards(NZ32-SC151 for example), and a CMSIS-DAP programmer/debugger.
Many Modtronix example and source code downloads include a SW4STM32 workspace with projects. SW4STM32 is an Eclipse based tool, meaning projects are always part of a workspace. 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 by following these simplified steps (see below for details):
After all software has been installed, the workspace/project can be imported into SW4STM32:
The firmware on the target board can be updated via the USB bootloader, or by using a ST-Link programmer.
Next step is to program and debug the target board. 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:.
System Workbench for STM32 is based on the Eclipse IDE for C/C++ developers (Eclipse CDT). There is a lot of information available online if you get stuck. 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.
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):
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: