qemu-arm
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-arm] Running qemu-system-arm with stm32f303


From: Peter Maydell
Subject: Re: [Qemu-arm] Running qemu-system-arm with stm32f303
Date: Tue, 13 Feb 2018 23:33:36 +0000

On 11 January 2018 at 00:07, patrick JP <address@hidden> wrote:
> Hello,
> I am running QEMU v2.11.0 to run my .elf, a bare metal code.
> The .elf runs in my stm32f303 board, flashed via stm32flash.
> My objective is to run the .elf in my machine to do testes over the serial
> communication, running socat PTY,link to create a bridge between
> /dev/deviceIn and /dev/deviceOut, where /dev/deviceIn would be qemu -serial
> argument and /dev/deviceOut the path for my python script.

Hi -- just noticed this mail to the list a bit late, but:

> Right now, I am running:
>
> qemu-system-arm -machine versatilepb -cpu cortex-m3 -nographic -monitor null
> -serial null -semihosting -device loader,file=file.elf
> output: segmentation fault (core dumped)

This is an incorrect commandline. The "versatilepb" machine
will not work with M profile CPUs: it is a development
board for the ARM926 CPU. (I really should make this
fail with a helpful error message rather than crash.)

To use the cortex-m3 or -m4 you need to use one of the machine
models that works with it, which is

lm3s6965evb          Stellaris LM3S6965EVB
lm3s811evb           Stellaris LM3S811EVB
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

(if your QEMU is older you may not see all of these.)

Generally you should select the machine with -machine,
and let it take care of picking the right CPU.

netduino2 is probably the best bet as it is an stm32f205,
but you should check that your test binaries are built to
be able to run on whatever board you pick. (In particular,
don't build them to use the FPU, because QEMU's M profile
CPUs don't emulate the FPU yet.)

Also, if you pass '-serial null' you're telling QEMU to throw
away any serial output to /dev/null, which is probably not what
you want.

> qemu-arm -d cpu,in_asm -cpu cortex-m3 -B 0x08000000 file.elf
> log: https://pastebin.com/FyA1pc8m

qemu-arm is for running single Linux binaries, not bare metal
executables. If you try to run a bare metal executable it
will crash as soon as it tries to look at an address
which hasn't had RAM allocated for it, which is what that
log file shows is happening. For M profile binaries it
doesn't make a great deal of sense to try to use qemu-arm.

I would start by getting your test binary to run "by hand".
Once you've done that there's things you can do (as James
Hanley suggests) to arrange to connect the serial port
up to a TCP socket or a FIFO or whatever your test harness
should be talking to.

One final point: I would recommend that you make sure
you're using QEMU 2.11, because we did a lot of bug
fixing on M profile emulation recently.

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]