rewrite workaround to support both qemu-arm 2.8.0 and below. Still recommended to upgrade

This commit is contained in:
nacho 2017-04-26 16:44:14 +02:00
parent 5714dfb32e
commit 4676084b68
2 changed files with 11 additions and 4 deletions

View File

@ -9,4 +9,6 @@ unzip raspbian_lite_latest.zip
sudo ./qemu-pi.sh *-raspbian-jessie-lite.img
```
Note that it is recommended to use `qemu-arm` not older than 2.8.0 (see code)
See details on https://ownyourbits.com/2017/02/06/raspbian-on-qemu-with-network-access/

View File

@ -115,11 +115,16 @@ KERNEL=="sda", SYMLINK+="mmcblk0"
KERNEL=="sda?", SYMLINK+="mmcblk0p%n"
KERNEL=="sda2", SYMLINK+="root"
EOF
# Fix a well documented issue - the kernel panics as init exits;
# Work around a known issue with qemu-arm, versatile board and raspbian for at least qemu-arm < 2.8.0
# This works but modifies the image so it is recommended to upgrade QEMU
# Ref: http://stackoverflow.com/questions/38837606/emulate-raspberry-pi-raspbian-with-qemu
cat > tmpmnt/etc/ld.so.preload <<EOF
#/usr/lib/arm-linux-gnueabihf/libarmmem.so
EOF
QEMU_MAJOR=$( qemu-system-arm --version | head -1 | grep -oP '\d+.\d+.\d+' | cut -d. -f1 )
QEMU_MINOR=$( qemu-system-arm --version | head -1 | grep -oP '\d+.\d+.\d+' | cut -d. -f2 )
if [[ $QEMU_MAJOR == 2 ]] && [[ $QEMU_MINOR < 8 ]]; then sed -i '/^[^#].*libarmmem.so/s/^\(.*\)$/#\1/' tmpmnt/etc/ld.so.preload; fi
if [[ $QEMU_MAJOR < 2 ]] ; then sed -i '/^[^#].*libarmmem.so/s/^\(.*\)$/#\1/' tmpmnt/etc/ld.so.preload; fi
umount -l tmpmnt
rmdir tmpmnt &>/dev/null