使用 QEMU 运行 Embassy 示例

1

项目:embassy 中的 examples/stm32f1

board:stm32vldiscovery

microcontroler:stm32f100rbt6

项目用到的芯片是 stm32f103c8,但这里模拟的芯片是 stm32f100rbt6

1
2
3
4
qemu-system-arm \
-M stm32vldiscovery \
-kernel target/thumbv7m-none-eabi/release/blinky \
-s -S
1
2
3
arm-none-eabi-gdb \
-ex 'file target/thumbv7m-none-eabi/release/blinky' \
-ex 'target remote localhost:1234'

运行结果是 qemu 中没有任何输出,陷入了某个循环。GDB 查看,具体如下:

1
2
3
4
Program received signal SIGINT, Interrupt.
cortex_m_rt::HardFault_ (warning: Could not fetch required XPSR content. Further unwinding is impossible.
ef=0x20004fe0) at src/lib.rs:1046
1046 loop {}

似乎是某种初始化过程?但这个循环一直跳不出来,还是 cortex_m_rt::HardFault_ 指代发生了某种错误?

2

项目:stm32f401_embassy

board:netduinoplus2

microcontroler:stm32f405rgt6

项目用到的芯片是 stm32f401,但这里模拟的芯片是 stm32f405rgt6

1
2
3
4
qemu-system-arm \
-M netduinoplus2 \
-kernel target/thumbv7em-none-eabi/release/stm32f401_embassy \
-s -S
1
2
3
arm-none-eabi-gdb \
-ex 'file target/thumbv7em-none-eabi/release/stm32f401_embass' \
-ex 'target remote localhost:1234'

运行结果是 qemu 中没有任何输出,陷入了某个循环。GDB 查看,具体如下:

1
2
3
Program received signal SIGINT, Interrupt.
0x0800369c in embassy_stm32::rcc::_version::init (config=...) at src/rcc/f247.rs:136
136 PWR.cr1().modify(|w| w.set_vos(crate::pac::pwr::vals::Vos::SCALE1));

似乎也是某种初始化过程?循环也是一直跳不出来。

3

项目:embassy 中的 examples/stm32l4

board:b-l475e-iot01a

microcontroler:stm32l475vg

b-l475e-iot01a 这块板子在 qemu 9.0.0 以上的官方版本中有支持,而且其 MCU stm32l475vg 在 embassy-stm32 中也有支持

1
2
3
4
qemu-system-arm \
-M b-l475e-iot01a \
-kernel target/thumbv7em-none-eabi/release/blinky \
-s -S
1
2
3
arm-none-eabi-gdb \
-ex 'file target/thumbv7em-none-eabi/debug/blinky' \
-ex 'target remote localhost:1234'

芯片型号都已经完全对上了,初始化还是过不去,难绷

4

项目:embassy 中的 examples/stm32f1

board:BluePill

microcontroler:stm32f103

这一次尝试参考了博客:QEMU 仿真模拟 STM32F103 开发板。其中用到了一个经第三方修改后的 QEMU 版本:xPack QEMU Arm

1
2
3
qemu-system-gnuarmeclipse \
-board BluePill \
-image target/thumbv7m-none-eabi/debug/blinky
1
2
3
arm-none-eabi-gdb \
-ex 'file target/thumbv7m-none-eabi/release/blinky' \
-ex 'target remote localhost:1234'

可以通过初始化过程,程序可以运行

gdb 连不上,错误信息如下:

1
2
warning: Can not parse XML target description; XML support was disabled at compile time
Truncated register 18 in remote 'g' packet

通过 apt 包管理器下载了 gdb-multiarch,使用 gdb-multiarch 可以正常调试