- Framework:
FreeRTOS / HAL
- Toolchain:
ARM GCC
- Builder:
Make
- Configuration:
STM32CubeMX
- Board:
Nucleo C031C6
- MCU:
STM32C031C6
- CPU:
ARM Cortex-M0+
- Clock:
4-48 MHz
- RAM:
12 KB
- Flash:
32 KB
- CPU:
- MCU:
- IDE:
VSCode
- Simulation:
Wokwi
- CI/CD:
GitHub Actions
+Wokwi CI
- Arm GNU Toolchain for compilation
- If you have STM32CubeIDE or STM32CubeCLT installed, you may be able to use the toolchain that comes with them.
- Make sure the
arm-none-eabi
executables are in yourPATH
. - Make sure to update the C/C++ extension configuration.
- GNU Make (Make for Windows) for building
- STM32CubeMX + STM32CubeC0 + X-CUBE-FREERTOS for configuration / code generation
- Clone this repo
- Open it in VSCode
- Install the recommended extensions
- Run the debugger on the
Build & Debug
task
VSCode will automatically build the project, start the Wokwi simulator and attach the debugger.
The simulation will be paused for the debugger to attach. Once ready, you can continue by clicking ⏯️ or pressing F5
.
Run make
from the terminal or use the Makefile Tools extension.
By default the build will be in debug mode. To build for release, set DEBUG=0
in the Makefile
.
- Install Wokwi extension for VSCode
- Command Palette ->
Wokwi: Request a New License
and get license from wokwi.com - Command Palette ->
Wokwi: Select Config File
and selectWokwi/wokwi.toml
- Command Palette ->
Wokwi: Start Simulator
Notes:
- You will see the serial output directly in the Wokwi terminal.
- The simulation only runs while the Wokwi tab is visible in VSCode.
- The simulation requires an internet connection. You can get a license for offline use.
- You can add more components to the simulation by editing
Wokwi/diagram.json
and restarting the simulator.
Relevant files:
Wokwi/wokwi.toml
- See documentation.Wokwi/diagram.json
- See diagram format and board details.
- Install C/C++ extension for VSCode
- Start simulation
- Run VSCode debugger on
Debug
task
Notes:
gdbServerPort = <port>
inWokwi/wokwi.toml
is used to forward the GDB server to a local TCP port.- Make sure to update the launch configuration if you make changes.
- Install Serial Monitor extension for VSCode
- Command Palette ->
Serial Monitor: Focus on Serial Monitor View
- Monitor Mode:
TCP
- Host:localhost
- Port:4000
- Start simulation
- Click
Start Monitoring
Notes:
- The serial interface corresponds to the
VCOM
(BSP abstraction ofUART2
) on the Nucleo C031C6. rfc2217ServerPort = <port>
inWokwi/wokwi.toml
is used to forward the serial port to a local TCP port.- The serial monitor can be used to send data to the simulation.
- However, it does not append
\r
or\n
to the input, and there is no way to send either. So use another separator for inputs.
- However, it does not append
To monitor the FreeRTOS tasks and queues
- Install Embedded Tools extension for VSCode
- Start debugging
- Go to the
Embedded Tools
tab in the panel (which contains the terminal etc.)
RTOS Views is another good extension for FreeRTOS task inspection.
Configured in .github/workflows/ci.yml
.
Upon push to GitHub, the workflow will build and test the project in Wokwi simulator.
See Wokwi CI for more details.
This project was initially generated using STM32CubeMX.
You can open Nucleo-C031C6-FreeRTOS.ioc
in STM32CubeMX to reconfigure the project and regenerate the code.
The generated code has some issues. Check or run fix_MX_codegen.py
for the fixes.
The main user code is in Core/Src/main.c
and Core/Src/app_freertos.c
.
The FreeRTOS configuration is in Core/Inc/FreeRTOSConfig.h
.
It is recommended that you write your code within the USER CODE
sections, as STM32CubeMX will overwrite the rest of the files if you use it to reconfigure the project and regenerate the code. (Hence the need for the fix_MX_codegen.py
script.)
Relevant documentation:
Notes:
- This project integrates
- the Nucleo-C031C6 BSP code for the onboard LED (
PA5
), user button (PC13
,EXTI
), and VCOM (USAR2
:PA2
&PA3
) - the CMSIS-RTOS API v2
- the Nucleo-C031C6 BSP code for the onboard LED (
- Originally based on Wokwi/stm32-hello-wokwi.
- Big thanks to the Wokwi team for their amazing work on the simulator and various integrations.
- Also thanks to the Open-Source and Embedded communities online.