-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run RPi OS on qemu #8
Comments
I'd like to share some of my experience.
|
Thanks a lot @lizhuohua! Looks like it is more work than I originally envisioned. I'll probably add an optional exercise to port RPi OS on qemu to all of the lessons. |
Here is a QEMU / gem5 Buildroot non-RPI ( Here is another repo of interest: https://github.com/s-matyukevich/raspberry-pi-os which just worked on QEMU, minimal getting started: https://raspberrypi.stackexchange.com/questions/34733/how-to-do-qemu-emulation-for-bare-metal-raspberry-pi-images/85135#85135 Step debugging the source code mentioned in this repo is something I will do later on. |
@lizhuohua QEMU (2.12.0) also supports UART1 (mini UART). Please check the following command in lesson02. |
@chishiro Great, it works! Many thanks! |
I can't get qemu's four cores to work. There should be 4 cores enabled by default. I use the same code for pi plus additional modifications. But I only get one core's result. Is there anything I missed? |
As far as I understand, for now quemu always run in a single core mode when emulating ARM in top of x86. https://lwn.net/Articles/697265 |
@s-matyukevich But I checked the original patch, there is a definition for default core number. And I tried |
I did some testing with my solution for exercice 1.3. Loading the kernel to address I got similar results with @evopen solution too. |
@evopen @bl4ckout31 I am not sure about the CPU issue. Maybe multiple CPUs are supported only when you run qemu in KVM mode using some ARM device? You can try to install qemu on Raspbian and test it from there. (I personally think that emulating Raspberry PI from Raspberry PI is definitely cool :) ) |
Another solution for using the mini UART in qemu while keeping access to the monitor and GUI is this:
In the view menu you'll now have a Here's also a no GUI option that allows you to retain access to the qemu monitor. Since it makes use of multiple terminals, you'll want tu use tmux or screen obviously. Start with a terminal that will serve as your serial terminal: # create a pair of FIFOs for mini_uart (do this only once)
mkfifo uart1.{in,out}
# redirect the terminal IO to the FIFOs
cat <uart1.out >&1 & cat <&0 >uart.in Then run qemu in another terminal: qemu-system-aarch64 -m 128 -M raspi3 -cpu cortex-a53 -kernel kernel8.img -nographic \
-serial null -chardev pipe,id=uart1,path=uart1 -serial chardev:uart1 The qemu monitor will be accessible from this terminal. |
I think we should not use elf file for qemu. Although it runs as expected, but it's actually running from 0x30 which is the entry point for elf file. And somehow it jump to 0x0. EDIT: I gave up trying to find thre reason of multicore problem to img kernel. It seem qemu modifies my img kernel and add some startup code to put the other 3 cores to idle using WFE instruction. So the best solution is to use elf with Maybe it's something to do with multiboot? idk |
Hello all |
Hey, here's a way to run QEMU without needing qemu-system-aarch64 -m 128 -M raspi3 -cpu cortex-a53 -kernel kernel8.img -nographic \
-serial null -chardev stdio,id=uart1 -serial chardev:uart1 -monitor none |
When I running your command in osx with lesson01-exercise1, I got this cpu statistic.(use
|
Hello.
Qemu sets the main core to addr 0 and all the other cores to 0x300.
So the main core starts to execute "bootloader" code. The code of the "bootloader" can be found in qemu sources. It simply branches to our "kernel.img".
Cores spin on "raspi_spintables". To wake up cores we need to do 2 things.
I prepared function which wakes up core:
It gets 2 arguments. x0 is for mpidr_el1 value and x1 is for starting address. |
You can check my solution for multicore boot. It works on both qemu and raspberry pi: |
Thanks, I will try this soon, I was just noticing yesterday that the latest armstub code is putting the cores to sleep (at least that's what it seemed like it's doing to me): https://github.com/raspberrypi/tools/blob/master/armstubs/armstub8.S
|
No description provided.
The text was updated successfully, but these errors were encountered: