2

I would like to emulate using QEMU the bare metal Raspberry Pi examples provided in this link https://github.com/dwelch67/raspberrypi.

Could someone let me know which commandline arguments should I use to get QEMU running. I checked in the internet and found that almost all the QEMU raspberry Pi tutorials emulates a GNU/Linux distro.

I found one link https://balau82.wordpress.com/2010/02/28/hello-world-for-bare-metal-arm-using-qemu/ but there the hardware used is versatilepb

Also I would like to know which commandline arguments for QEMU should I use to get the multicore support in Raspberry Pi2. Do I need to use the SMP parameter as mentioned here ?

  • 1
    raspberrypi.org has a bare-metal forum you might ask there about the state of the qemu port or how to run it. – old_timer Aug 25 '15 at 0:11
1

bztsrc/raspi3-tutorial

https://github.com/bztsrc/raspi3-tutorial

# Get QEMU v2.12.0 for -M raspi3
# https://github.com/bztsrc/raspi3-tutorial
git clone git://git.qemu.org/qemu.git
cd qemu
git checkout v2.12.0
./configure --target-list=aarch64-softmmu
make -j`nproc`
export PATH="$(pwd)/aarch64-softmmu:${PATH}"
cd ..

# Get source.
git clone https://github.com/bztsrc/raspi3-tutorial
cd raspi3-tutorial
git checkout efdae4e4b23c5b0eb96292f2384dfc8b5bc87538

# Setup to use the host precompiled cross compiler.
# https://github.com/bztsrc/raspi3-tutorial/issues/30
sudo apt-get install gcc-aarch64-linux-gnu
find . -name Makefile | xargs sed -i 's/aarch64-elf-/aarch64-linux-gnu-/'

# Compile and run stuff.
cd 05_uart0
make
../../qemu/aarch64-softmmu/qemu-system-aarch64 -M raspi3 -kernel kernel8.img -serial stdio

Outcome: UART0 prints on terminal:

My serial number is: 0000000000000000

UART1 can be used instead of UART0 e.g. for tutorial 03_uart1 with:

-serial null -serial stdio

as explained at: https://github.com/bztsrc/raspi3-tutorial/pull/34

Here is a related non-RPI-specific QEMU question: https://stackoverflow.com/questions/38914019/how-to-make-bare-metal-arm-programs-and-run-them-on-qemu

Tested on Ubuntu 18.04 host.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.