Skip to content

How to build a ScreenInvader sd card image

Amir Hassan edited this page Dec 12, 2021 · 29 revisions

This a guide for how to build a ScreenInvader sd card image. There are 2 targets: release and debug. "release" builds an armhf image that you can write to a sd card and boot with your Bananapi. "debug" builds a x86_64 image suitable for booting with QEMU only. If you want to test or implement new features you are strongly adviced to build a "debug" image.

We will start with building a debian jessie chroot with all required tools and dependencies and use that to create the actual Screeninvader image.

Debootstrap a debian bullseye with build essentials

debootstrap --variant=buildd --arch amd64 bullseye ScreenInvaderBuild/ http://ftp.at.debian.org/debian/

Setup the chroot environment to bind /dev tree

mount --bind /dev ScreenInvaderBuild/dev

Load required kernel modules

modprobe binfmt_misc
modprobe loop maxpart=63

"chroot in" to the chroot environment

chroot ScreenInvaderBuild

*** At this point you are in the chroot environment

export PATH=/bin:/sbin:/usr/bin:/usr/sbin
mount -t proc none proc
mount -t sysfs none sys
mount -t tmpfs none tmp

Install additional dependencies in the chroot build-environment

dpkg --add-architecture aarch64
apt-get update
apt-get install binfmt-support qemu qemu-user-static debootstrap dosfstools parted kpartx apt-cacher-ng whois extlinux git-core dpkg-sig nodejs u-boot-tools libncurses5-dev npm sshpass node-ws gcc-arm-none-eabi sudo vim

Start apt-cacher-ng and binfmt-support in chroot

/etc/init.d/apt-cacher-ng start
/etc/init.d/binfmt-support start

Create a local GPG Key for package signing

You may first need to install rng-tools to generate enough entropy in the debroot:

apt-get install rng-tools
echo HRNGDEVICE=/dev/urandom >> /etc/default/rng-tools
/etc/init.d/rng-tools start

Then, generate a key:

gpg --gen-key

Make a ScreenInvader disk image (This takes up to an hour. please be patient.)

git clone https://github.com/screeninvader/ScreenInvader.git
cd ScreenInvader
make debug

screeninvader.dd file will now contain a bootable virtual image for your needs: