qemu-arm
[Top][All Lists]
Advanced

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

Re: Hello world example with qemu-system-arm


From: James Gutbub
Subject: Re: Hello world example with qemu-system-arm
Date: Fri, 13 May 2022 15:59:11 -0700

Thank you kindly for your very informative/helpful response!

 

I am pursuing the qemu-arm path (although I may also consider qemu-system-arm at some point).

 

I am trying with the below sequence of compiling a simple ASM test, linking, and executing using qemu-arm (I tried with v6.0.0 and v7.0.0 compiled locally in CentOS Stream 8) and cannot progress past an error.

 

I am trying with cortex-r5f (-march=armv7-r) and also cortex-a7 (-march=armv7-a)

 

startup.s file contents:

 

.global _Reset

_Reset:

LDR sp, =_stack

ORR r1, r1

ORR r2, r2

ORR r3, r3

ORR r4, r4

B .

 

arm-none-eabi-as  -march=armv7-a startup.s -o startup.o

arm-none-eabi-ld  startup.o -Map=test.map -o test.elf -e _Reset

 

qemu-arm -cpu cortex-a7 -d in_asm,exec,cpu,int,unimp,guest_errors,nochain -D test.log test.elf

 

qemu-arm: Unable to reserve 0xffff0000 bytes of virtual address space at 0x1000 (Permission denied) for use as guest address space (check your virtual memory ulimit setting, min_mmap_addr or reserve less using -R option)

 

I checked the output of ‘ulimit -a’ and got the below so I don’t believe I have any restrictions to allocate the requested virtual memory:

 

ulimit -a

core file size          (blocks, -c) 0

data seg size           (kbytes, -d) unlimited

scheduling priority             (-e) 0

file size               (blocks, -f) unlimited

pending signals                 (-i) 255393

max locked memory       (kbytes, -l) 64

max memory size         (kbytes, -m) unlimited

open files                      (-n) 1024

pipe size            (512 bytes, -p) 8

POSIX message queues     (bytes, -q) 819200

real-time priority              (-r) 0

stack size              (kbytes, -s) 8192

cpu time               (seconds, -t) unlimited

max user processes              (-u) 255393

virtual memory          (kbytes, -v) unlimited

file locks                      (-x) unlimited

 

Looked kind of similar to this issue but wasn’t sure if maybe I have some other issue -https://gitlab.com/qemu-project/qemu/-/issues/447

 

Any tips you could recommend would be greatly appreciated.

 

Kind Regards,

James G.


On Thu, May 12, 2022 at 1:35 AM Peter Maydell <peter.maydell@linaro.org> wrote:
On Wed, 11 May 2022 at 20:50, James Gutbub <jgutbub@asu.edu> wrote:
> I am digging into qemu-system-arm to try and execute some simulation
> environment unit tests with no underlying board/device interaction,
> at most I need semihosting to print out some results.

> The intended target for my hello world using arm-none-eabi-gcc
> is Cortex-R5F (e.g. -mcpu=cortex-r5 -mfpu=vfpv3-d16 -mfloat-abi=hard).

> I am not finding a way to successfully execute my hello world example
> using ‘qemu-system-arm -cpu cortex-r5f -M none -nographic -semihosting’
> and the payload variants below:

You need to specify a real machine type. QEMU is not designed
to provide a "just the CPU" emulation environment. There are
two modes:

 (1) system emulation, with qemu-system-arm, which gives you
a model of some actual board. Your guest code usually needs
to be written to work on that board (at a minimum, linked to
an address where the board has RAM)
 (2) usermode emulation, with qemu-arm, which runs code at
emulated EL0 (userspace) with access to Linux syscalls and
also the semihosting ABI

You're also at a disadvantage in wanting Cortex-R5F : we have
no system emulation board models where that is the main CPU.
(We have it for some Xilinx board models which have Cortex-A72
cores for the main processors and also some auxiilary R5 cores.)

Depending on what your code is doing, you may be able to use
option 2. In particular your code would have to:
 * not touch any devices or other SoC or board hardware
 * be happy running only at EL0
 * only use memory which is in the ELF file's code/data/bss
   (unless you want to allocate more with Linux syscalls)

It's perhaps not impossible to get something executing with
the 'none' type, but this is definitely not a supported
use case, so you're on your own if you want to experiment.
As a starting hint, the 'none' board defaults to "no RAM",
so unless you tell QEMU to allocate some then there's nowhere
for your code to execute from.

Whichever way you want to go on this, for any kind of "I'm
not sure why my code is failing to start" question I recommend
the use of the -d debug options to tell you where the CPU
is trying to execute instructions from and what they are.
-d in_asm,exec,cpu,int,unimp,guest_errors,nochain is usually
a good set of options; but watch out that 'in_asm' shows
when insns are translated, not when they are executed.
-D file to dump to file rather than the terminal.

thanks
-- PMM

reply via email to

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