README.md

QEMU Model for Gigadevice GD32F30X SoC

Project Description

This is the most complete model of the GD32F30X SoC for QEMU to date, built on the top of currently existing STM32 components in QEMU and adapted to the specific features of GD32. The model includes almost all peripherals available in real hardware.

Implemented Peripherals

Inherited and enhanced from STM32 models:

  • ADC (with the ability to set channel values via QMP and DMA support)
  • USART (with RX DMA support)
  • SPI (with DMA support)
  • TIMER
  • EXTI

Newly added models:

  • GPIO
  • CRC
  • RTC
  • AFIO
  • I2C (with full slave functionality support)
  • FMC
  • RCU
  • USBD
  • CAN
  • FWDGT
  • DMA (with programmable interrupts connected to peripherals)

Usage Examples

Quick boot via kernel

build-qemu/qemu-system-arm -M olimexino-gd32 -kernel zephyr.bin -serial none -serial mon:stdio -nographic

Boot via flash image file

dd if=/dev/zero count=256 bs=1024 | tr '\0' '\377' > flash.bin
dd if=zephyr.bin of=flash.bin conv=notrunc
build-qemu/qemu-system-arm -M olimexino-gd32 -drive format=raw,if=pflash,id=mtd0,file=flash.bin -serial none -serial mon:stdio -nographic

Loading and debugging via gdb

build-qemu/qemu-system-arm -M olimexino-gd32 -serial none -serial mon:stdio -nographic -s -S

Then in gdb:

arm-none-eabi-gdb ./build/zephyr-gpio-shell/zephyr/zephyr.elf -ex 'target remote localhost:1234'

(gdb) load
(gdb) continue

Using gpiodev

Available ports: gpioA, gpioB, gpioC, gpioD, gpioE, gpioF, gpioG.

-gpiodev chardev,id=gpioA,chardev=gd32-gpioA -chardev socket,path=/tmp/gd32-gpioA,id=gd32-gpioA,server=on,wait=off

Using remote-i2c-master

-device remote-i2c-controller,i2cbus=i2c0.0,devname=i2c-33

Using CDC ACM Host Module

-usb -chardev pty,id=acm -device cdc-acm-host,chardev=acm

Using ADC via QMP

Channel values can be set via the QMP interface:

{ "execute": "qom-set", "arguments": { "path": "/machine/unattached/device[0]/adc[0]/", "property": "input[0]", "value": 1500 } }

Cross-Compiler

Uses zephyr-sdk-0.16.8/arm-zephyr-eabi.

Quick zephyr-gpio-shell build

git submodule update --init --recursive -- zephyr
git submodule update --init --recursive -- zephyr-gpio-shell
python -m venv venv
. venv/bin/activate
pip install west
pip install pyelftools
make .zephyr-sdk
west init -l zephyr
west update

cd modules/hal/gigadevice
git remote add gd32f303x https://gitflic.ru/project/maquefel/hal_gigadevice.git
git fetch gd32f303x
git checkout gd32f303x
cd ../../..
build/zephyr-gpio-shell/zephyr/zephyr.bin

Conclusion

The GD32F30X model in QEMU is ready for use in real projects and allows you to:

  • Test firmware without physical hardware
  • Identify errors early in the development cycle
  • Save on infrastructure and equipment costs
  • Work on projects even before physical prototypes are available
Конвейеры
0 успешных
0 с ошибкой