Developing and Debugging Zephyr RTOS on GD32 MCUs with the IAR Arm Toolchain

2026-06-30

This article mainly introduces how to develop and debug Zephyr RTOS on GD32 microcontrollers using the IAR Arm toolchain.

Prerequisites

Zephyr Beginners: Refer to the official Zephyr Getting Started Guide — Zephyr Project Documentation:

https://docs.zephyrproject.org/latest/develop/getting_started/index.html

IAR Embedded Workbench for Arm: Version 9.70.1 and above supports Zephyr.

GD32 Zephyr Development Guide: Refer to the Chinese getting-started document hosted on GitHub:

https://github.com/GD32-MCU-IOT/gd32_zephyr/blob/main/gd32mcu_zephyr_get_start_cn.md

Step-by-Step Guide to GD32 MCU Zephyr Development with the IAR Arm Toolchain

1 Development Environment

- Operating System: Windows 11

- Command Line Interface: Windows PowerShell

- IAR Arm Toolchain: EWARM 9.70.4

- Hardware Evaluation Board: GD32H759I_EVAL

2 Install System Dependencies

First install the system dependency packages required for Zephyr development.

Follow the installation steps from the official guide at:

https://docs.zephyrproject.org/latest/develop/getting_started/index.html

Minimum version requirements for core components including CMake, Python, and the Devicetree Compiler are listed below.

未标题-1.png

Run the following commands to verify successful installation:

# Check CMake version
cmake --version

# Check Python version
py --version

# Check Devicetree Compiler version
dtc –version

3 Configure Python Environment

3.1 Create a Python Virtual Environment

# Create workspace directory
mkdir -p ./zephyrproject

# Create virtual environment with Python 3.12
py -3.12 -m venv ./zephyrproject/.venv

# Activate the virtual environment
./zephyrproject/.venv/Scripts/Activate.ps1

图片2.png

3.2 Upgrade pip and Install West

# Upgrade pip to the latest release
pip install --upgrade pip

# Install the West meta-tool
pip install west

图片3.png

3.3 Verify West Installation

# Check West version (v1.5.0 or higher required)
west –version

图片4.png

4 Retrieve Zephyr Source Code

4.1 Initialize West Workspace with Custom GD32 Repository

# Navigate to project root
cd ./zephyrproject

# Initialize West workspace using GD32 customized Zephyr repo
west init -m https://github.com/GD32-MCU-IOT/gd32_zephyr.git .

图片5.png

4.2 Export Zephyr CMake Package

# Export Zephyr CMake package to auto-load build templates
west zephyr-export

图片6.png

4.3 Update All West Modules

# Pull and sync all dependent West modules
west update

图片7.png

This operation may take several minutes, as West will download the Zephyr kernel and all mandatory modules.

5 Install Python Dependencies for Zephyr

# Enter the Zephyr source folder
cd zephyr

# Install all Python dependencies specified by West
python -m pip install @((west packages pip) -split ' ')

图片8.png

6 Install Zephyr SDK

6.1 Download and Install the Full SDK

# Install the official Zephyr SDK (versions subject to updates; check latest releases)
west sdk install

图片9.png

If only the Arm GCC toolchain is required, run the command below:

west sdk install -t arm-zephyr-eabi

7 Persistent Environment Setup

Every time you open a new PowerShell window and enter the development directory, reactivate the Zephyr environment:

# Activate the preconfigured Python virtual environment
./zephyrproject/.venv/Scripts/Activate.ps1

图片10.png

8 Validate Full Installation

8.1 Build the Sample Hello World Application

# Navigate to the Zephyr source root
cd ./zephyrproject/zephyr

# Build Hello World sample targeting GD32H759I_EVAL board
west build -p always -b gd32h759i_eval samples/hello_world

图片8.1.png图片8.10.png

9 Build Projects with the IAR Arm Toolchain

9.1 Set Environment Variables for IAR Toolchain

# Specify IAR as the active Zephyr toolchain variant
$En

# Specify the local installation path of IAR Arm toolchain
$En

9.2 Build Hello World Using IAR Compilation Chain

# Rebuild Hello World sample with IAR toolchain for GD32H759I_EVAL
west build -p always -b gd32h759i_eval samples/hello_world

图片9.2.png图片9.20.png

10 Debug with the IAR Arm Toolchain

1. Create a new debug project in IAR Embedded Workbench for Arm, and select the Externally built executable project type.

未标题-10.0.png 

2. Follow the configuration steps documented in readme_external_binary.txt to complete project setup:

- Import the compiled ELF binary file

- Select the target chip: navigate to Options > General Options > Target > Device

- Configure debug adapter driver: navigate to Options > Debugger > Setup > Driver

- Enable Zephyr-aware debugging plugins: check relevant options under Options > Debugger > Plugins (requires enabling the CONFIG_DEBUG_THREAD_INFO Kconfig option during project build)

未标题-10.11.png 

3. Flash firmware and start debugging.

4. Open the Zephyr dropdown menu in the top IAR menu bar to view runtime Zephyr system information.

未标题-10.12.png 

11 Static Code Analysis via IAR C-STAT

The C-STAT static analysis tool integrated into the IAR Arm toolchain supports static code scanning for Zephyr projects. Execute the command below to run analysis:

west build -p always -b gd32h759i_eval samples/hello_world -DZEPHYR_SCA_VARIANT=iar_c_stat

图片11。0.png图片11。1.png

For further details, refer to the official documentation: IAR C-STAT support — Zephyr Project Documentation

https://docs.zephyrproject.org/latest/develop/sca/iar_c_stat.html

Summary

This article outlines the complete workflow for developing and debugging Zephyr RTOS on GD32 MCUs running on Windows with the IAR Arm toolchain. Equivalent procedures can be applied to Linux-based development environments for IAR-powered Zephyr development.

References

1. https://www.zephyrproject.org/learn-about/

2. https://docs.zephyrproject.org/latest/develop/getting_started/index.html

3. https://docs.zephyrproject.org/latest/develop/toolchains/iar_arm_toolchain.html

4. https://mypages.iar.com/s/article/Debugging-an-externally-built-executable-file?language=en_US

5. https://github.com/GD32-MCU-IOT/gd32_zephyr

6. https://docs.zephyrproject.org/latest/develop/sca/iar_c_stat.html

7. https://www.iar.com/zh/blog/static-code-analysis-in-zephyr-build-safer-cleaner-code-with-iar-c-stat

TOP

Info

Please log in to submit your request and receive relevant materials and support.

Info

Please complete your profile to submit your request and receive relevant materials and support.

标题

简介
  • Accept

  • Decline