@@ -183,6 +183,76 @@ NB: It's also possible to run qdl from the host while the baord is not connected
183183
184184Want to join in the development? Changes welcome! See [CONTRIBUTING.md file](CONTRIBUTING.md) for step by step instructions.
185185
186+ ### Test an image locally with qemu
187+
188+ You can boot an image locally with qemu as follows:
189+
190+ 1. Install dependencies. `qemu-system-arm` is required together with
191+ an aarch64 build of UEFI. On Debian and Ubuntu, this is provided by the
192+ `qemu-system-arm` package which recommends `qemu-efi-aarch64`:
193+ ```bash
194+ sudo apt install qemu-system-arm qemu-efi-aarch64
195+ ```
196+
197+ 1. As above under "Usage", build the disk image from the root filesystem
198+ tarball if you haven' t done this already:
199+ ` ` ` bash
200+ debos debos-recipes/qualcomm-linux-debian-image.yaml
201+ ` ` `
202+
203+ 1. Run qemu as follows:
204+ ` ` ` bash
205+ # SCSI is required to present a device with a matching 4096 sector size
206+ # inside the VM
207+ qemu-system-aarch64 -cpu cortex-a57 -m 2048 -M virt -nographic \
208+ -device virtio-scsi-pci,id=scsi1 \
209+ -device scsi-hd,bus=scsi1.0,drive=disk1,physical_block_size=4096,logical_block_size=4096 \
210+ -drive if=none,file=disk-ufs.img,format=raw,id=disk1 \
211+ -bios /usr/share/AAVMF/AAVMF_CODE.fd
212+ ` ` `
213+
214+ # ### Copy on write
215+
216+ Instead of modifying ` file-ufs.img` , you can arrange copy-on-write, for example
217+ to reproduce the same first boot multiple times:
218+
219+ 1. Prepare a qcow file to contain the writes, backed by ` disk-ufs.img` :
220+ ` ` ` bash
221+ qemu-img create -b disk-ufs.img -f qcow -F raw disk1.qcow
222+ ` ` `
223+
224+ 1. Run qemu as follows:
225+ ` ` ` bash
226+ qemu-system-aarch64 -cpu cortex-a57 -m 2048 -M virt -nographic \
227+ -device virtio-scsi-pci,id=scsi1 \
228+ -device scsi-hd,bus=scsi1.0,drive=disk1,physical_block_size=4096,logical_block_size=4096 \
229+ -drive if=none,file=disk1.img,format=qcow,id=disk1 \
230+ -bios /usr/share/AAVMF/AAVMF_CODE.fd
231+ ` ` `
232+
233+ # ### Direct kernel boot
234+
235+ For debugging purposes, it is sometimes useful to boot the kernel directly, for
236+ example to confirm that an issue in the image lies in the bootloader
237+ installation. You can do this as follows:
238+
239+ 1. Extract the rootfs:
240+ ` ` ` bash
241+ mkdir rootfs
242+ tar xzC rootfs -f rootfs.tar.gz
243+ ` ` `
244+
245+ 2. Run qemu against the kernel and initrd present inside the rootfs directly:
246+ ` ` ` bash
247+ qemu-system-aarch64 -cpu cortex-a57 -m 2048 -M virt -nographic \
248+ -device virtio-scsi-pci,id=scsi1 \
249+ -device scsi-hd,bus=scsi1.0,drive=disk1,physical_block_size=4096,logical_block_size=4096 \
250+ -drive if=none,file=disk-ufs.img,format=raw,id=disk1 \
251+ -kernel rootfs/boot/vmlinuz-*
252+ -initrd rootfs/boot/initrd.img-*
253+ -append root=/dev/sda2
254+ ` ` `
255+
186256# # Reporting Issues
187257
188258We' 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