@@ -182,75 +182,44 @@ NB: It's also possible to run qdl from the host while the baord is not connected
182182
183183Want to join in the development? Changes welcome! See [CONTRIBUTING.md file](CONTRIBUTING.md) for step by step instructions.
184184
185- # ## Test an image locally with qemu
185+ # ## Boot an image locally with QEMU (helper script)
186186
187- You can boot an image locally with qemu as follows:
187+ Use the ` scripts/run-qemu.py` helper to boot generated disk images under QEMU. It automatically:
188+ - Detects your OS and locates an aarch64 UEFI firmware (Debian/Ubuntu: qemu-efi-aarch64; macOS Homebrew: edk2-aarch64).
189+ - Presents the image via SCSI with the correct sector size (4096 for UFS, 512 for SD/eMMC).
190+ - Creates a temporary qcow2 copy-on-write overlay by default (your base image remains unchanged).
191+ - Provides GUI display by default (Gtk on Linux, Cocoa on macOS) and headless mode with ` --headless` .
188192
189- 1. Install dependencies. ` qemu-system-arm` is required together with
190- an aarch64 build of UEFI. On Debian and Ubuntu, this is provided by the
191- ` qemu-system-arm` package which recommends ` qemu-efi-aarch64` :
192- ` ` ` bash
193- sudo apt install qemu-system-arm qemu-efi-aarch64
194- ` ` `
195-
196- 1. As above under " Usage" , build the disk image from the root filesystem
197- tarball if you haven' t done this already:
198- ```bash
199- debos debos-recipes/qualcomm-linux-debian-image.yaml
200- ```
201-
202- 1. Run qemu as follows:
203- ```bash
204- # SCSI is required to present a device with a matching 4096 sector size
205- # inside the VM
206- qemu-system-aarch64 -cpu cortex-a57 -m 2048 -M virt -nographic \
207- -device virtio-scsi-pci,id=scsi1 \
208- -device scsi-hd,bus=scsi1.0,drive=disk1,physical_block_size=4096,logical_block_size=4096 \
209- -drive if=none,file=disk-ufs.img,format=raw,id=disk1 \
210- -bios /usr/share/AAVMF/AAVMF_CODE.fd
211- ```
212-
213- #### Copy on write
193+ Dependencies:
194+ - Debian/Ubuntu: ` sudo apt install qemu-efi-aarch64 qemu-system-arm qemu-utils`
195+ - macOS (Homebrew): ` brew install qemu`
214196
215- Instead of modifying `file-ufs.img`, you can arrange copy-on-write, for example
216- to reproduce the same first boot multiple times:
197+ Basic usage:
198+ ` ` ` bash
199+ # Auto-detects disk-ufs.img or disk-sdcard.img in the current directory
200+ scripts/run-qemu.py
217201
218- 1. Prepare a qcow file to contain the writes, backed by `disk-ufs.img`:
219- ```bash
220- qemu-img create -b disk-ufs.img -f qcow -F raw disk1.qcow
221- ```
202+ # Explicit storage type (sector size set accordingly)
203+ scripts/run-qemu.py --storage ufs
204+ scripts/run-qemu.py --storage sdcard
222205
223- 1. Run qemu as follows:
224- ```bash
225- qemu-system-aarch64 -cpu cortex-a57 -m 2048 -M virt -nographic \
226- -device virtio-scsi-pci,id=scsi1 \
227- -device scsi-hd,bus=scsi1.0,drive=disk1,physical_block_size=4096,logical_block_size=4096 \
228- -drive if=none,file=disk1.img,format=qcow,id=disk1 \
229- -bios /usr/share/AAVMF/AAVMF_CODE.fd
230- ```
206+ # Use a specific image path
207+ scripts/run-qemu.py --image /path/to/disk-ufs.img
231208
232- #### Direct kernel boot
209+ # Run headless (no GUI), with serial console on stdio
210+ scripts/run-qemu.py --headless
233211
234- For debugging purposes, it is sometimes useful to boot the kernel directly, for
235- example to confirm that an issue in the image lies in the bootloader
236- installation. You can do this as follows:
212+ # Disable the COW overlay to persist changes to the image
213+ scripts/run-qemu.py --no-cow
237214
238- 1. Extract the rootfs:
239- ```bash
240- mkdir rootfs
241- tar xzC rootfs -f rootfs.tar.gz
242- ```
215+ # Pass extra QEMU arguments (example: 4 vCPUs and 4 GiB RAM)
216+ scripts/run-qemu.py --qemu-args " -smp 4 -m 4096"
217+ ` ` `
243218
244- 2. Run qemu against the kernel and initrd present inside the rootfs directly:
245- ```bash
246- qemu-system-aarch64 -cpu cortex-a57 -m 2048 -M virt -nographic \
247- -device virtio-scsi-pci,id=scsi1 \
248- -device scsi-hd,bus=scsi1.0,drive=disk1,physical_block_size=4096,logical_block_size=4096 \
249- -drive if=none,file=disk-ufs.img,format=raw,id=disk1 \
250- -kernel rootfs/boot/vmlinuz-*
251- -initrd rootfs/boot/initrd.img-*
252- -append root=/dev/sda2
253- ```
219+ Notes:
220+ - If neither ` disk-ufs.img` nor ` disk-sdcard.img` is found and ` --image` is not provided, the script will exit with an error.
221+ - On Linux, the script looks for ` /usr/share/qemu-efi-aarch64/QEMU_EFI.fd` . On macOS with Homebrew, it uses ` share/qemu/edk2-aarch64-code.fd` from the ` qemu` formula.
222+ - The overlay is cleaned up automatically when QEMU exits. Use ` --no-cow` to make changes persistent on the base image.
254223
255224# # Reporting Issues
256225
0 commit comments