initial commit - working archlinuxarm boot for versatile express emulation

This commit is contained in:
Andreas Grapentin 2017-12-27 17:08:03 +01:00
commit 282f805d6d
No known key found for this signature in database
GPG Key ID: 7171986E4B745536
3 changed files with 96 additions and 0 deletions

7
.gitignore vendored Normal file

@ -0,0 +1,7 @@
# image files
*.qcow2
*.raw
# tarballs
*.tar.*

64
create.sh Executable file

@ -0,0 +1,64 @@
#!/bin/bash
set -eu
# this script prepares an archlinuxarm image for use with start.sh
OUTFILE=${OUTFILE:-armv7h.raw}
SIZE=${SIZE:-64G}
_builddir=build
_outfile=$_builddir/$(basename $OUTFILE)
mkdir -p $_builddir
# create an empty image
rm -f $_outfile
qemu-img create -f raw $_outfile $SIZE
# setup an available loop device
_loopdev=$(losetup -f --show $_outfile)
# setup an error exit handler for cleanup
function cleanup {
echo "exiting due to earlier errors..." >&2
for part in p1 p2; do
umount $_loopdev$part || true
done
losetup -d $_loopdev || true
rm -rf $_builddir/boot $_builddir/root
rm -f $_outfile
}
trap cleanup ERR
# fetch latest archlinuxarm tarball
wget -nc http://os.archlinuxarm.org/os/ArchLinuxARM-armv7-latest.tar.gz
# following are the installation instructions provided on
# https://archlinuxarm.org/platforms/armv7/arm/versatile-express
dd if=/dev/zero of=$_loopdev bs=1M count=8
parted -s $_loopdev \
mklabel gpt \
mkpart ESP fat32 1MiB 513MiB \
set 1 boot on \
mkpart primary ext4 513MiB 100%
mkfs.vfat -F 32 ${_loopdev}p1
mkdir -p $_builddir/boot
mount ${_loopdev}p1 $_builddir/boot
mkfs.ext4 ${_loopdev}p2
mkdir $_builddir/root
mount ${_loopdev}p2 $_builddir/root
bsdtar -vxpf ArchLinuxARM-armv7-latest.tar.gz -C $_builddir/root
sync
mv -v $_builddir/root/boot/* $_builddir/boot
cat >> $_builddir/root/etc/fstab << EOF
/dev/mmcblk0p1 /boot vfat defaults 0 0
EOF
# tie up any loose ends
for part in p1 p2; do
umount $_loopdev$part
done
losetup -d $_loopdev
mv -v $_outfile $OUTFILE
rm -rf $_builddir

25
start.sh Executable file

@ -0,0 +1,25 @@
#!/bin/bash
IMAGE=${IMAGE:-armv7h.raw}
_loopdev=$(sudo losetup -f --show $IMAGE)
_bootdir=.boot
function cleanup {
sudo umount ${_loopdev}p1
sudo losetup -d $_loopdev
rm -rf $_bootdir
}
trap cleanup EXIT
mkdir -p $_bootdir
sudo mount ${_loopdev}p1 $_bootdir
qemu-system-arm \
-M vexpress-a9 \
-dtb $_bootdir/dtbs/vexpress-v2p-ca9.dtb \
-kernel $_bootdir/zImage \
--append "root=/dev/mmcblk0p2 rw roottype=ext4 console=ttyAMA0" \
-drive if=sd,driver=raw,cache=writeback,file=$IMAGE \
--nographic \
-snapshot