I am trying to emulate dual cores(ARM cortex M7) on QEMU, in a baremetal environment. I need to understand the best approach for the same.

I tried running two instances of QEMU, and defined semaphores for synchronization in the shared memory part. But seems like it is not supported on bare metal. I tried to manually implement semaphores, but then i am getting the following error:

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)

i have used the following command to run this:

./qemu-system-arm -M lm3s811evb -kernel write_hello.elf -nographic

even by trying different machine names, i am getting the same result.

1

There are 1 best solutions below

1
Peter Maydell On

In general, QEMU supports multiple cores when it is emulating a board type that permits them. So for instance because x86 PC hardware can be multicore, QEMU allows you to emulate a multicore system. But where the hardware we're emulating is single-core only, you can't emulate more than one core.

If you want a dual-core M-profile system you need to select a board type which models a board which has more than one core. The lm3s811evb is a single-core Cortex-M3 board, so that is what it gives you.

The only current M-profile boards which QEMU emulates which have more than one core are:

  • mps3-an521 (two Cortex-M33)
  • mps3-an524 (two Cortex-M33)

These are both models of FPGA images that run on the Arm MPS3 devboard, so you can check the appnote documentation for them to see if they are suitable:

If you need a board with specifically two Cortex-M7 CPUs you will need to write an emulation of it yourself.

The error message you quote about Lockup, by the way, means your guest code has crashed in an unrecoverable manner -- on a real hardware CPU it would go into Lockup mode and sit there doing nothing. You'll need to debug your guest code to figure out why.