6.7 KiB
FSFW demo with FreeRTOS OSAL on the STM32H743ZI
This demo can be run on a STM32H743ZI-Nucleo board with the FreeRTOS OSAL.
General Information
The board is flashed and debugged with OpenOCD and this README specifies on how to make this work with the Eclipse IDE. Other IDEs or the command line can be used as well as long as long as OpenOCD integration is given. The example demo uses newlib nano. Some system calls were overriden so the C and C++ stdio functions work. IO is sent via the HUART3, so debug output can be read directly from the USB connection to the board.
Prerequisite
- MSYS2 installed on Windows. Not required on Linux.
- GNU ARM Toolchain installed, recommended to add binaries to system path.
- Recommended for application code development: Eclipse for C/C++ installed with the Eclipse MCU plugin
- OpenOCD installed for Eclipse debugging
- STM32 USB drivers installed, separate steps for Windows or Linux
Building the software with CMake
On Windows, the following steps should be performed inside the MinGW64 console after installing MSYS2. It is recommended to still use git for Windows for the git related steps.
-
Clone this repository
git clone https://egit.irs.uni-stuttgart.de/fsfw/fsfw_example.git
-
Set up submodules
git submodule init git submodule update
-
Navigate into the cloned repository and create a folder for the build. We will create a Debug build folder.
mkdir Debug cd Debug
-
Ensure that the ARM compiler has been added to the path and can be called from the command line. For example, the following command should work:
arm-none-eabi-gdb --version
Now we will create the build configuration for cross-compilation of an ARM target. On Linux, run the following command:
cmake -G "Unix Makefiles" -DOS_FSFW=freertos -DCMAKE_BUILD_TYPE=Debug -DTGT_BSP=arm/stm32h743zi-nucleo ..
On Windows, use the following command:
cmake -G "MinGW Makefiles" -DOS_FSFW=freertos -DCMAKE_BUILD_TYPE=Debug -DTGT_BSP=arm/stm32h743zi-nucleo ..
The build configuration can also be performed with the shell scripts located inside
cmake/scripts/FreeRTOS
or the Python helper scriptcmake_build_config.py
insidecmake/scripts
. -
Build the application
cmake --build . -j
The application will be located inside the Debug folder and has been compiled for the flash memory.
-
You can test the application by first connecting the STM32H743ZI-Nucleo via USB. The device should now show up in the list of connected devices (make sure the USB drivers are installed as well). Drag and drop the binary file into the connected device to flash it. The debug output is also sent via the connected USB port and a blink pattern (1 second interval) can be used to verify the software is running properly.
Setting up the prerequisites
Windows
It is recommended to install MSYS2 first. Open MinGW64 and run the following commands to update it and install make and cmake (replace x86_64 if compiling on different architecture):
pacman -Syuuu
pacman -S mingw-w64-x86_64-make mingw-w64-x86_64-cmake
The code needs to be compiled for the ARM target system and we will use the GNU ARM Toolchain.
-
Install NodeJS LTS. Add nodejs folder (e.g. "C:\Program Files\nodejs") to system variables. Test by running
npm --version
in command line -
Install XPM
npm install --global xpm
-
Install gnu-arm Toolchain for Eclipse (version can be specified)
xpm install --global @xpack-dev-tools/arm-none-eabi-gcc@latest xpm install --global @xpack-dev-tools/windows-build-tools@latest
Install OpenOCD for STM32 debugging
xpm install --global @xpack-dev-tools/openocd@latest
-
Add arm-none-eabi-gcc binary location in the xPack folder to system variables. These are usually located in C:\Users<...>\AppData\Roaming\xPacks@gnu-mcu-eclipse\arm-none-eabi-gcc<version>.content\bin . Alternatively, if you want to keep the environment and the path clean, add it temporarily with
SET PATH=%PATH%;c:\pathtotoolchain
. -
Install the STM32 USB drivers
If you don't want to install nodejs you may go with the four-command manual installation.
Linux
Install the GNU ARM toolchain like explained above, but for Linux, the Windows Build Tools package is not required.
On Linux, the a path can be added to the system variables by adding
export PATH=$PATH:<..../@gnu-mcu-eclipse/arm-none-eabi-gcc/<version>/.content/bin>
to the .profile
or .bashrc
file. Alternatively, if you want to keep the environment and the
path clean, add it temporarily with export PATH=%PATH%;c:\pathtotoolchain
.
To install general buildtools for the linux binary, run:
sudo apt-get install build-essential
Install the USB drivers on Linux by following these instructions.
Setting up Eclipse for OpenOCD debugging
The separate Eclipse README specifies how to set up Eclipse. The STM32 configuration uses the xPacks OpenOCD and the xPacks ARM Toolchain, so those should be installed as well. OpenOCD should be configured correctly in the STM32 launch configurations.
Troubleshooting
OpenOCD errors
If you get the following error in OpenOCD: "Error: auto_probe failed", this could be related from switching between FreeRTOS and RTEMS. You can try the following steps:
-
First way: Flash the binary manually by drag & droping the binary into the USB drive manually once
-
Second way: Add -c "gdb_memory_map disable" to the OpenOCD arguments (in Eclipse) and run once. Debugging might not be possible, so remove it for subsequent runs.
-
Third way: Add the following lines to the
stm32h7x.cfg
file located inside the OpenOCD folder inside thescripts/target
folder:$_CHIPNAME.cpu configure -event gdb-attach { halt } $_CHIPNAME.cpu configure -event gdb-attach { reset init }