-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-hikey960-rootfs
executable file
·79 lines (65 loc) · 2.97 KB
/
create-hikey960-rootfs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
if [ $(whoami) != "root" ]; then
echo "$0 can only be run as root!\n"
exit 1
fi
if [ ! -d "$1" ]; then
echo "Usage: $0 installdir"
exit 1
fi
EXTRA_PACKAGES="bc,build-essential,bzip2,ca-certificates,dbus"
EXTRA_PACKAGES+=",chrpath,crda,diffstat,git,git-man,dh-python"
EXTRA_PACKAGES+=",fakeroot,file,firmware-ti-connectivity,gawk"
EXTRA_PACKAGES+=",groff-base,iw,less,wpasupplicant"
EXTRA_PACKAGES+=",openssh-client,openssh-server,openssh-sftp-server"
EXTRA_PACKAGES+=",net-tools,locales,libncurses5-dev,manpages-dev"
EXTRA_PACKAGES+=",ntpdate,pciutils,python,rename,repo,rsync,scons"
EXTRA_PACKAGES+=",sudo,tcpd,unzip,xml-core"
EXTRA_PACKAGES+=",shared-mime-info,opencl-c-headers,ocl-icd-opencl-dev"
EXTRA_PACKAGES+=",ocl-icd-dev,man-db,libxml2,libpam-systemd,krb5-locales"
#EXTRA_PACKAGES+=",chrpath,cpp,cpp-6,crda,dbus,dh-python,diffstat"
#EXTRA_PACKAGES+=",dpkg-dev,fakeroot,file,firmware-ti-connectivity"
#EXTRA_PACKAGES+=",g++,g++-6,gawk,gcc,gcc-6,git,git-man,groff-base"
#EXTRA_PACKAGES+=",iw,krb5-locales,less,libasan3,libatomic1,libc-dev-bin"
#EXTRA_PACKAGES+=",libc-l10n,libc6-dev,libcc1-0,libcurl3-gnutls,libdbus-1-3"
#EXTRA_PACKAGES+=",libdpkg-perl,libedit2,liberror-perl,libexpat1,libfakeroot"
#EXTRA_PACKAGES+="
# handle pre-requisites
apt install qemu-user-static binfmt-support debootstrap
# Do the first-stage debootstrap
debootstrap --foreign --arch=arm64 --include=$EXTRA_PACKAGES \
--components=main,non-free,contrib stretch $1
# Copy qemu-aarch64-static to the root filesystem to enable emulation
cp /usr/bin/qemu-aarch64-static $1/usr/bin
# Set up the chroot
mount --bind /dev $1/dev
mount --bind /dev/pts $1/dev/pts
mount --bind /proc $1/proc
mount --bind /sys $1/sys
mount --bind /run $1/run
# Do the second-stage debootstrap
chroot $1 /debootstrap/debootstrap --second-stage
umount $1/dev/pts
umount $1/dev
umount $1/proc
umount $1/sys
umount $1/run
echo "hikey960" > $1/etc/hostname
# Download, extract and put the mali library in the correct position
TMPFILE=$(mktemp tmp.XXXXXXXX.tar.gz)
TMPDIR=$(mktemp -d)
wget --quiet https://developer.arm.com/-/media/Files/downloads/mali-drivers/user-space/HiKey%20960/mali-G71_r9p0-01rel0_linux_1fbdev.tar.gz -O $TMPFILE
tar xvf $TMPFILE -C $TMPDIR
cp $TMPDIR/fbdev/libmali.so $1/usr/lib/aarch64-linux-gnu/
cp $TMPDIR/fbdev/liboffline_compiler_api_gles.so $1/usr/lib/aarch64-linux-gnu/
# Add the libmali.so to the OpenCL vendors
mkdir -p $1/etc/OpenCL/vendors/
echo "libmali.so" > $1/etc/OpenCL/vendors/mali.icd
# configure the fstab
echo "
/dev/root / auto defaults 1 1
proc /proc proc defaults 0 0
devpts /dev/pts devpts mode=0620,gid=5 0 0
tmpfs /run tmpfs mode=0755,nodev,nosuid,strictatime 0 0
# uncomment this if your device has a SD/MMC/Transflash slot
#/dev/mmcblk0p1 /media/card auto defaults,sync,noauto 0 0" > $1/etc/fstab