1234567891011121314151617181920212223242526272829303132333435363738 |
- #!/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-img resize -f raw "$image" 4G
- qemu-system-arm -M raspi2b \
- -append "rw earlyprintk loglevel=8 console=ttyAMA0,115200 dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootdelay=1" \
- -drive file="$image",format=raw,if=sd \
- -dtb "$dtb" -kernel "$kernel" -m 1G -smp 4 \
- -serial stdio -usb -device usb-mouse -device usb-kbd 2>&1 | tee qemu.log
|