12345678910111213141516171819202122232425262728293031323334353637 |
- #!/bin/bash
- set -e
- SCRIPT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
- image="./workspace/nixos-rpi2.img"
- mountdir="/mnt/nixos-rpi2"
- dtb="bcm2836-rpi-2-b.dtb"
- kernel="zImage"
- loop=`losetup -f --show -P "$image"`
- echo "created loopback device $loop"
- mkdir -p "$mountdir"
- mount "${loop}p2" "$mountdir"
- echo "mounted to $mountdir"
- dtb_path=`find "$mountdir/nix/store/" -name "$dtb" | head -n1`
- cp "$dtb_path" .
- kernel_path=`find "$mountdir/nix/store/" -name "$kernel" | head -n1`
- cp "$kernel_path" .
- cd "$mountdir"
- # bash
- cd "$SCRIPT_PATH"
- umount "$mountdir"
- losetup -d "$loop"
- #qemu-system-arm -kernel "$kernel" -cpu arm1176 -m 256 -M versatilepb -serial stdio -append "root=/dev/sda2 rootfstype=ext4 rw" -dtb "$dtb" -hda "$image" -no-reboot
- qemu-img resize "$image" 4G
- qemu-system-arm -M raspi2b -append "rw earlyprintk loglevel=8 console=ttyAMA0,115200 dwc_otg.lpm_enable=0 root=/dev/sda2 rootdelay=1" -sd "$image" -dtb "$dtb" -kernel "$kernel" -m 1G -smp 4 -serial stdio -usb -device usb-mouse -device usb-kbd 2>&1 | tee qemu.log
|