在执行裸机程序后如何在没有用户干预的情况下干净地退出QEMU? [英] How to cleanly exit QEMU after executing bare metal program without user intervention?

查看:166
本文介绍了在执行裸机程序后如何在没有用户干预的情况下干净地退出QEMU?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为ARM系统组装交叉编译单元测试设备,并使用qemu-system-arm在主机上运行测试.具体来说,我使用qemu来模拟Stellaris LM3S6965评估板,因为它包含与目标环境类似的Cortex M3处理器.在qemu中运行的二进制文件是使用ARM的GNU工具构建的.

I am assembling a cross compiling unit testing rig for an ARM system and running the tests on a host machine with qemu-system-arm. Specifically, I'm using qemu to emulate the Stellaris LM3S6965 eval board as it contains a Cortex M3 processor like my target environment. The binary run in qemu is built with GNU Tools for ARM.

不涉及任何操作系统.该测试套件在-nographic模式下作为带有qemu的裸机应用程序运行.工具链和测试装置本身都运行良好.而且测试成功完成并在qemu内产生测试结果也很好.

There is no OS involved. The test suite is run as a bare metal application with qemu in -nographic mode. The toolchain and the test rig itself are working fine. And the tests successfully run to completion and produce test results within qemu just fine as well.

问题在于使用自动构建工具(在这种情况下为Rake)包装qemu.除了键盘命令,我还没有找到一种好的方法来导致qemu在测试套件运行并退出其结果后退出.这会导致构建环境挂起/依靠用户干预.

The problem is in wrapping up qemu in an automated build tool (Rake in this case). Other than keyboard commands I have not yet found a good way to cause qemu to exit after the test suite runs and spits out its results. This causes the build environment to hang / rely on user intervention.

我看上去高低不平,没有找到关于程序终止后如何完成简单退出的好信息.我确实找到了一些使用-no-reboot选项运行qemu的建议,然后从仿真器中运行的程序触发系统重置.我已经试过了.可行...有点.我在执行main()之后将适当的值写入仿真处理器的复位向量,这确实会触发复位.运行测试套件后,qemu报告捕获系统重置.但是,它将其报告为硬件错误,转储寄存器内容,然后退出愤怒(下面的错误消息).尽管这确实在测试套件运行后完成了退出,但是由于qemu退出并出现错误情况,因此它破坏了自动构建脚本.

I have looked high and low and have found no good sources on how to accomplish a simple exit after program termination. I did find a couple suggestions of running qemu with the -no-reboot option and then triggering a system reset from the program running in the emulator. I have tried this. It works… kinda. I write the appropriate values to the emulated processor's reset vector after main() executes, and this does trigger a reset. After running the test suite qemu reports catching a system reset. However, it reports this as a hardware error, dumps register contents, and then exits angry (error message below). While this does accomplish exiting after the test suite runs, it then breaks the automated build script due to qemu exiting with an error condition.

qemu: hardware error: System reset

我想避免破解将键盘命令插入到构建中以模拟用户干预的行为.我也想避免依赖qemu以错误状态退出.

I'd like to avoid hacking the insertion of keyboard commands into the build to simulate user intervention. I'd also like to avoid relying on qemu exiting in an error state.

看来我已经接近干净的出口了,但还不在那里.搜索qemu错误消息(如上所述)除与切向相关的错误报告外,没有产生任何相关文档.

It seems I'm close to a clean exit but not quite there. Searching for the qemu error message (above) has produced no relevant documentation other than tangentially related bug reports.

是否存在一种机制,该机制导致main()在我丢失的裸机程序中返回后退出qemu?此-no-reboot +系统重置策略可以工作吗?如果是这样,还有什么需要让qemu干净地退出?

Is there a mechanism for causing qemu to exit after main() returns in a bare metal program that I'm missing? Will this -no-reboot + system reset strategy work? If so, what else is necessary to allow qemu to exit cleanly?

推荐答案

对我来说,最干净的选择是获取一个稳定版本的Qemu的源代码,该版本接近我们正在使用的版本.以下是Qemu来源的1.1.2版本.

The cleanest option for me was to grab the source for a stable version of Qemu close to the one we were already using. The following refers to version 1.1.2 of the Qemu source.

我修改了armv7m_nvic.c中Cortex M3 + Stellaris LM3S6965评估板的复位矢量处理仿真.我将hw_error()调用替换为qemu_system_reset_request()的调用.此内部系统调用将重置虚拟机,但也会响应-no-reboot命令行选项以进行干净关机,如我最初的问题中所述.

I modified the emulation of the reset vector handling for the Cortex M3 + Stellaris LM3S6965 eval board in armv7m_nvic.c. I replaced the hw_error() call with a call to qemu_system_reset_request(). This internal system call will reset a virtual machine but also responds to the -no-reboot command line option for a clean shutdown as discussed in my original question.

这些在获取快照后,构建说明为我工作Qemu 1.1.2 .我遇到了几个构建错误,但是网络搜索很快解决了每个问题.

These build instructions worked for me after grabbing a snapshot of Qemu 1.1.2. I encountered several build errors, but web searches quickly resolved each issue.

这篇关于在执行裸机程序后如何在没有用户干预的情况下干净地退出QEMU?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆