qemu-arm
[Top][All Lists]
Advanced

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

Re: [Qemu-arm] QEMU user mode for cortex M


From: Massimiliano Cialdi
Subject: Re: [Qemu-arm] QEMU user mode for cortex M
Date: Sun, 17 Mar 2019 12:10:51 +0100

I did it.

File main.c:

--------8<------------------------
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    printf("Hallo ARM world!\n");
    exit(0);
}
--------8<------------------------

compiled with:
/opt/gcc-arm-none-eabi-8-2018-q4-major/bin/arm-none-eabi-gcc
-std=gnu11 -mcpu=cortex-m4 -mthumb  -fno-common -specs=rdimon.specs
-Wl,--cref,-Map=main.map  -O0 -g3 main.c -o main.elf

I run it with qemu user mode, and it works:
~/Downloads/qemu/qemu-3.1.0/arm-linux-user/qemu-arm -D prova.out -d
in_asm,cpu,nochain,unimp,guest_errors -cpu cortex-m4 main.elf
Hallo ARM world!


probably works by accident, but I have achieved my goal. Any comment?

best regards
Max


On Sat, Mar 16, 2019 at 9:34 PM Massimiliano Cialdi <address@hidden> wrote:
>
> On Sat, Mar 16, 2019 at 1:01 PM Alex Bennée <address@hidden> wrote:
> >
> >
> > Massimiliano Cialdi <address@hidden> writes:
> >
> > > I have my exetutable compiled with
> > > /opt/gcc-arm-none-eabi-8-2018-q4-major/bin/arm-none-eabi-gcc -std=gnu11
> > > -mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=fpv5-d16 -fno-common
> > > -specs=rdimon.specs -Wl,--cref,-Map=main.map main.c -o main.elf
> >
> > I thought you wanted to target a cortex-m4?
> yes.
> I tried to compile it like this.:
> /opt/gcc-arm-none-eabi-8-2018-q4-major/bin/arm-none-eabi-gcc
> -std=gnu11 -mcpu=cortex-m4 -mthumb  -fno-common -specs=rdimon.specs
> -Wl,--cref,-Map=main.map -T prova.ld -O0 -g3 main.c -o main.elf
> The linker script is attached
>
> I don't know how to compile with arm-linux-gnueabihf-gcc
>
> >
> > Have a look at how test-armv6m-undef is built. It is the simplest
> > dumbest M profile image you can build with a kernel that maps to 0 and a
> > simple reset vector at the start of the vector table:
> I don't want to have to deal with interrupt vectors and memory layouts.
> Just see "hallo world!" on the output.
>
>
>
> > I don't know what the virt machine defaults to for CPU but I'm fairly
> > sure it's not an m-profile CPU.
> I had only tried the machine none and virt... I didn't know which one
> to choose for cortex M4
>
>
> > It's hard to say without seeing what your test is doing. However I can force
> > a cortex-m4 on a microbit and run the following ok:
> >
> >   ./qemu-system-arm  -monitor none -display none \
> >                      -chardev file,path=test-armv6m-undef.out,id=output \
> >                      -semihosting -M microbit \
> >                      -cpu cortex-m4 \
> >                      -kernel tests/test-armv6m-undef
> >                      -d in_asm,cpu,nochain
>
> tried with:
> ~/Downloads/qemu/qemu-3.1.0/arm-softmmu/qemu-system-arm -d
> in_asm,cpu,nochain,unimp,guest_errors -chardev
> file,path=prova.out,id=output -machine microbit -cpu cortex-m4
> -monitor null -serial null  -semihosting -nographic
> -semihosting-config enable=on,target=native  -kernel main.elf
> ----------------
> IN:
> 0x00000000:  00000000  andeq    r0, r0, r0
>
> R00=00000000 R01=00000000 R02=00000000 R03=00000000
> R04=00000000 R05=00000000 R06=00000000 R07=00000000
> R08=00000000 R09=00000000 R10=00000000 R11=00000000
> R12=00000000 R13=00000000 R14=ffffffff R15=00000000
> XPSR=40000000 -Z-- A priv-thread
> nrf51_soc.private: unimplemented device write (size 4, value 0x0,
> offset 0xfffffe0)
> nrf51_soc.private: unimplemented device write (size 4, value 0x0,
> offset 0xfffffe4)
> nrf51_soc.private: unimplemented device write (size 4, value 0x0,
> offset 0xfffffe8)
> nrf51_soc.private: unimplemented device write (size 4, value 0x0,
> offset 0xfffffec)
> nrf51_soc.private: unimplemented device write (size 4, value 0x0,
> offset 0xffffff0)
> nrf51_soc.private: unimplemented device write (size 4, value
> 0xffffffff, offset 0xffffff4)
> nrf51_soc.private: unimplemented device write (size 4, value 0x0,
> offset 0xffffff8)
> nrf51_soc.private: unimplemented device write (size 4, value
> 0x40000000, offset 0xffffffc)
> ----------------
> IN:
> 0x00000000:  00000000  andeq    r0, r0, r0
>
> R00=00000000 R01=00000000 R02=00000000 R03=00000000
> R04=00000000 R05=00000000 R06=00000000 R07=00000000
> R08=00000000 R09=00000000 R10=00000000 R11=00000000
> R12=00000000 R13=ffffffe0 R14=fffffff9 R15=00000000
> XPSR=40000003 -Z-- A handler
> qemu: fatal: Lockup: can't escalate 3 to HardFault (current priority -1)
>
> R00=00000000 R01=00000000 R02=00000000 R03=00000000
> R04=00000000 R05=00000000 R06=00000000 R07=00000000
> R08=00000000 R09=00000000 R10=00000000 R11=00000000
> R12=00000000 R13=ffffffe0 R14=fffffff9 R15=00000000
> XPSR=40000003 -Z-- A handler
> FPSCR: 00000000
> Aborted (core dumped)
>
>
> still no success
>
> best regards
> Max
>
>
> --
> Et nunc, auxilium solis, vincam!
> Oppugnatio solaris!
> VIS!
>
> Massimiliano Cialdi
> address@hidden



-- 
Et nunc, auxilium solis, vincam!
Oppugnatio solaris!
VIS!

Massimiliano Cialdi
address@hidden



reply via email to

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