在QEMU上模拟ARM系统



如何设置QEMU以模拟ARM Cortex M3系统?

我正在尝试从头开始为基于ARM的芯片构建内核(C和/或程序集(。为了首先实现这一点,我必须在QEMU上模拟系统本身,以便运行我的代码。我使用的微控制器是NXP LPC1768(Cortex M3,512KB闪存,64KB SRAM,以太网(。

如果有人能帮忙,我将不胜感激。我目前无法访问物理LPC1768。

您将使用qemu-system-arm命令。添加-machine help参数当前会输出111台受支持机器的列表。你可以将其过滤到像这样的Cortex-M3机器上,其当前输出为:

% qemu-system-arm -machine help | grep Cortex-M3 | grep -v Cortex-M33
lm3s6965evb          Stellaris LM3S6965EVB (Cortex-M3)
lm3s811evb           Stellaris LM3S811EVB (Cortex-M3)
mps2-an385           ARM MPS2 with AN385 FPGA image for Cortex-M3
mps2-an511           ARM MPS2 with AN511 DesignStart FPGA image for Cortex-M3
netduino2            Netduino 2 Machine (Cortex-M3)
stm32vldiscovery     ST STM32VLDISCOVERY (Cortex-M3)

我相信你所问的最接近NXP芯片的选择是netduino2机器中的STM32F2。在那台机器上启动你的固件:

qemu-system-arm -M netduino2 -kernel firmware.bin

以下是qemu文档中的相关页面,了解更多信息:https://www.qemu.org/docs/master/system/arm/stm32.html

下一步,假设您想使用gdb进行调试,一个更完整的示例如下。在一个终端中,您启动模拟,在启动时用-S标志冻结CPU:

qemu-system-arm -cpu cortex-m3 -machine netduino2 -gdb tcp::3333 -S -nographic -kernel firmware.bin

然后在另一个终端中,启动一个gdb客户端:

arm-none-eabi-gdb firmware.bin

然后在(gdb)提示下,连接:

target remote :3333

最新更新