How to completely exit QEMU after running an open metal program without user intervention?

I am building an installation to test the assembly unit for an ARM system and run the tests on the host machine with qemu-system-arm. In particular, I use qemu to emulate the Evaluation Stellaris LM3S6965 platform, because it contains a Cortex M3 processor, such as my target environment. Qemu's binary launch is built using the GNU tools for ARM.

No OS. The test suite runs as a bare metal application with qemu in mode -nographic. The tool chain and the test setup itself are operating normally. And the tests run successfully to completion and give test results in qemu just fine.

The problem is ending qemu in an automated build tool (in this case Rake). Besides the keyboard commands, I have not yet found a good way to get qemu to exit after running the test suite and splashing out its results. This leads to the fact that the build environment is dependent on user intervention.

I looked high and low and did not find good sources on how to perform a simple exit after the program ends. I found a couple of suggestions about starting qemu with an option -no-reboot, and then starting the reset system from a program running in the emulator. I have tried this. It works ... curious. I write the corresponding values ​​for the emulated processor reset vector after execution main(), and this causes a reset to fire. After starting the test suite, qemu reports a catch on the reset system. However, he reports this as a hardware error, the contents of the register are reset, and then out of anger (error message below). Although it ends after the test suite starts, it then interrupts the automatic build of the script due to qemu exiting with an error condition.

qemu: hardware error: System reset

, . qemu .

, , . qemu (. ) , .

qemu , main() , ? -no-reboot + system reset ? , , qemu ?

+6
5

, Qemu, , . 1.1.2 Qemu.

reset Evaluation Cortex M3 + Stellaris LM3S6965 armv7m_nvic.c. hw_error() qemu_system_reset_request(). reset , -no-reboot , .

Qemu 1.1 0,2. , .

+1

Angel ARM. . - ARM. angel_SWIreason_ReportException (0x18) ADP_Stopped_ApplicationExit, QEMU , .

QEMU -semihosting, :

qemu-system-arm -nographic -semihosting -kernel your_binary

, QEMU ( - ):

register int reg0 asm("r0");
register int reg1 asm("r1");

reg0 = 0x18;    // angel_SWIreason_ReportException
reg1 = 0x20026; // ADP_Stopped_ApplicationExit

asm("svc 0x00123456");  // make semihosting call

github, .

+4

, , ( ); QEMU "exit QEMU". , , , ( QEMU, ).

+1

aarch64

fooobar.com/questions/1602636/... A32, A64:

.global main
main:
    /* 0x20026 == ADP_Stopped_ApplicationExit */
    mov x1, #0x26
    movk x1, #2, lsl #16
    str x1, [sp,#0]

    /* Exit status code. Host QEMU process exits with that status. */
    mov x0, #0
    str x0, [sp,#8]

    /* x1 contains the address of parameter block.
     * Any memory address could be used. */
    mov x1, sp

    /* SYS_EXIT */
    mov w0, #0x18

    /* Do the semihosting call on A64. */
    hlt 0xf000

GitHub:

: https://developer.arm.com/docs/100863/latest

0

ARMv7M qEmu ( TI Stellaris LM3S6965) AICRCR ( ). SYSRESETREQ , .

AICRCR 0x5FA VECTKEY, .

ARMv7M qEmu.

SCB->AIRCR = (0x5FA << SCB_AIRCR_VECTKEY_Pos) | SCB_AIRCR_SYSRESETREQ_Msk;

qEmu, qEmu -no-reboot.

0

All Articles