@@ -182,6 +182,76 @@ 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
186+
187+ You can boot an image locally with qemu as follows:
188+
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
214+
215+ Instead of modifying `file-ufs.img`, you can arrange copy-on-write, for example
216+ to reproduce the same first boot multiple times:
217+
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+ ```
222+
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+ ```
231+
232+ #### Direct kernel boot
233+
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:
237+
238+ 1. Extract the rootfs:
239+ ```bash
240+ mkdir rootfs
241+ tar xzC rootfs -f rootfs.tar.gz
242+ ```
243+
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+ ```
254+
185255## Reporting Issues
186256
187257We' d love to hear if you run into issues or have ideas for improvements. [Report an Issue on GitHub](../../issues) to discuss, and try to include as much information as possible on your specific environment.
0 commit comments