Skip to content

Commit 0dd38a4

Browse files
committed
Merge branch 'master' of https://github.com/volumio/Build
2 parents 507333c + 2c4bb1b commit 0dd38a4

File tree

3 files changed

+328
-0
lines changed

3 files changed

+328
-0
lines changed

build.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,10 @@ case "$DEVICE" in
350350
check_os_release "armv7" "$VERSION" "$DEVICE"
351351
sh scripts/nanopineo2image.sh -v "$VERSION" -p "$PATCH" -a armv7
352352
;;
353+
nanopineo3) echo 'Writing NanoPi-NEO3 armv7 Image File'
354+
check_os_release "armv7" "$VERSION" "$DEVICE"
355+
sh scripts/nanopineo3image.sh -v "$VERSION" -p "$PATCH" -a armv7
356+
;;
353357
nanopineo) echo 'Writing NanoPi-NEO (Air) Image File'
354358
check_os_release "armv7" "$VERSION" "$DEVICE"
355359
sh scripts/nanopineoimage.sh -v "$VERSION" -p "$PATCH" -a armv7

scripts/nanopineo3config.sh

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#!/bin/bash
2+
3+
PATCH=$(cat /patch)
4+
5+
# This script will be run in chroot under qemu.
6+
echo "Initializing.."
7+
. init.sh
8+
9+
echo "Creating \"fstab\""
10+
echo "# NanoPI Neo3 fstab" > /etc/fstab
11+
echo "" >> /etc/fstab
12+
echo "proc /proc proc defaults 0 0
13+
/dev/mmcblk0p1 /boot vfat defaults,utf8,user,rw,umask=111,dmask=000 0 1
14+
tmpfs /var/log tmpfs size=20M,nodev,uid=1000,mode=0777,gid=4, 0 0
15+
tmpfs /var/spool/cups tmpfs defaults,noatime,mode=0755 0 0
16+
tmpfs /var/spool/cups/tmp tmpfs defaults,noatime,mode=0755 0 0
17+
tmpfs /tmp tmpfs defaults,noatime,mode=0755 0 0
18+
tmpfs /dev/shm tmpfs defaults,nosuid,noexec,nodev 0 0
19+
" >> /etc/fstab
20+
21+
echo "Creating boot config"
22+
echo "label kernel-5.4
23+
kernel /Image
24+
fdt /rk3328-nanopi-neo3-rev00.dtb
25+
initrd /uInitrd
26+
append earlycon=uart8250,mmio32,0xff130000 console=ttyS2,1500000 console=tty1 imgpart=/dev/mmcblk0p2 imgfile=/volumio_current.sqsh hwdevice=nanopineo3 bootdev=mmcblk0
27+
"> /boot/extlinux/extlinux.conf
28+
29+
echo "Fixing armv8 deprecated instruction emulation with armv7 rootfs"
30+
echo "abi.cp15_barrier=2" >> /etc/sysctl.conf
31+
32+
echo "Installing additional packages"
33+
apt-get update
34+
apt-get -y install device-tree-compiler u-boot-tools
35+
36+
echo "Cleaning APT Cache and remove policy file"
37+
rm -f /var/lib/apt/lists/*archive*
38+
apt-get clean
39+
40+
echo "Adding custom modules overlay, squashfs and nls_cp437"
41+
echo "overlay" >> /etc/initramfs-tools/modules
42+
echo "squashfs" >> /etc/initramfs-tools/modules
43+
echo "nls_cp437" >> /etc/initramfs-tools/modules
44+
45+
echo "Copying volumio initramfs updater"
46+
cd /root/
47+
mv volumio-init-updater /usr/local/sbin
48+
49+
#On The Fly Patch
50+
if [ "$PATCH" = "volumio" ]; then
51+
echo "No Patch To Apply"
52+
else
53+
echo "Applying Patch ${PATCH}"
54+
PATCHPATH=/${PATCH}
55+
cd $PATCHPATH
56+
#Check the existence of patch script
57+
if [ -f "patch.sh" ]; then
58+
sh patch.sh
59+
else
60+
echo "Cannot Find Patch File, aborting"
61+
fi
62+
if [ -f "install.sh" ]; then
63+
sh install.sh
64+
fi
65+
cd /
66+
rm -rf ${PATCH}
67+
fi
68+
rm /patch
69+
70+
echo "Changing to 'modules=dep'"
71+
echo "(otherwise neo3 may not boot due to uInitrd 4MB limit)"
72+
sed -i "s/MODULES=most/MODULES=list/g" /etc/initramfs-tools/initramfs.conf
73+
74+
echo "Installing winbind here, since it freezes networking"
75+
apt-get update
76+
apt-get install -y winbind libnss-winbind
77+
78+
echo "Cleaning APT Cache and remove policy file"
79+
rm -f /var/lib/apt/lists/*archive*
80+
apt-get clean
81+
rm /usr/sbin/policy-rc.d
82+
83+
#First Boot operations
84+
echo "Signalling the init script to re-size the volumio data partition"
85+
touch /boot/resize-volumio-datapart
86+
87+
echo "Creating initramfs 'volumio.initrd'"
88+
mkinitramfs-custom.sh -o /tmp/initramfs-tmp
89+
90+
echo "Creating uImage from 'volumio.initrd'"
91+
mkimage -A arm64 -O linux -T ramdisk -C none -a 0 -e 0 -n uInitrd -d /boot/volumio.initrd /boot/uInitrd
92+
93+
echo "Removing unnecessary /boot files"
94+
rm /boot/volumio.initrd

scripts/nanopineo3image.sh

Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
#!/bin/sh
2+
3+
# Build Architecture Debian 32bit
4+
ARCH="armv7"
5+
6+
while getopts ":v:p:a:" opt; do
7+
case $opt in
8+
v)
9+
VERSION=$OPTARG
10+
;;
11+
p)
12+
PATCH=$OPTARG
13+
;;
14+
a)
15+
ARCH=$OPTARG
16+
;;
17+
esac
18+
done
19+
20+
BUILDDATE=$(date -I)
21+
IMG_FILE="Volumio${VERSION}-${BUILDDATE}-nanopineo3.img"
22+
23+
if [ "$ARCH" = arm ]; then
24+
DISTRO="Raspbian"
25+
else
26+
DISTRO="Debian 32bit"
27+
fi
28+
29+
echo "Creating Image File ${IMG_FILE} with ${DISTRO} rootfs"
30+
31+
dd if=/dev/zero of=${IMG_FILE} bs=1M count=2800
32+
33+
echo "Creating Image Bed"
34+
LOOP_DEV=`losetup -f --show ${IMG_FILE}`
35+
# Note: leave the first 20Mb free for the firmware (effectively needs ~16Mb)
36+
parted -s "${LOOP_DEV}" mklabel msdos
37+
parted -s "${LOOP_DEV}" mkpart primary fat32 20 84
38+
parted -s "${LOOP_DEV}" mkpart primary ext3 84 2500
39+
parted -s "${LOOP_DEV}" mkpart primary ext3 2500 100%
40+
parted -s "${LOOP_DEV}" set 1 boot on
41+
parted -s "${LOOP_DEV}" print
42+
partprobe "${LOOP_DEV}"
43+
kpartx -s -a "${LOOP_DEV}"
44+
45+
BOOT_PART=`echo /dev/mapper/"$( echo ${LOOP_DEV} | sed -e 's/.*\/\(\w*\)/\1/' )"p1`
46+
SYS_PART=`echo /dev/mapper/"$( echo ${LOOP_DEV} | sed -e 's/.*\/\(\w*\)/\1/' )"p2`
47+
DATA_PART=`echo /dev/mapper/"$( echo ${LOOP_DEV} | sed -e 's/.*\/\(\w*\)/\1/' )"p3`
48+
echo "Using: " ${BOOT_PART}
49+
echo "Using: " ${SYS_PART}
50+
echo "Using: " ${DATA_PART}
51+
if [ ! -b "${BOOT_PART}" ]
52+
then
53+
echo "${BOOT_PART} doesn't exist"
54+
exit 1
55+
fi
56+
57+
echo "Creating boot and rootfs filesystems"
58+
mkfs -t vfat -n BOOT "${BOOT_PART}"
59+
mkfs -F -t ext4 -O ^metadata_csum,^64bit -L volumio "${SYS_PART}" || mkfs -F -t ext4 -L volumio "${SYS_PART}"
60+
mkfs -F -t ext4 -O ^metadata_csum,^64bit -L volumio_data "${DATA_PART}" || mkfs -F -t ext4 -L volumio_data "${DATA_PART}"
61+
sync
62+
63+
echo "Preparing for the nanopi-neo3 kernel/ platform files"
64+
if [ -d platform-nanopi/nanopi-neo3 ]
65+
then
66+
echo "Platform folder already exists - keeping it"
67+
# if you really want to re-clone from the repo, then delete the platform-nanopi folder
68+
# that will refresh the platform files, see below
69+
cd platform-nanopi
70+
if [ -f nanopi-neo3.tar.xz ]; then
71+
echo "Found a new tarball, unpacking..."
72+
rm -r nanopi-neo3
73+
tar xfJ nanopi-neo3.tar.xz
74+
rm nanopi-neo3.tar.xz
75+
fi
76+
cd ..
77+
else
78+
if [ ! -d platform-nanopi ]; then
79+
mkdir platform-nanopi
80+
fi
81+
cd platform-nanopi
82+
[ ! -f nanopi-neo3.tar.xz ] || rm nanopi-neo3.tar.xz
83+
wget https://github.com/volumio/platform-nanopi/raw/master/nanopi-neo3.tar.xz
84+
echo "Unpacking the Neo3 platform files"
85+
tar xfJ nanopi-neo3.tar.xz
86+
rm nanopi-neo3.tar.xz
87+
cd ..
88+
fi
89+
90+
echo "Copying the bootloader"
91+
dd if=platform-nanopi/nanopi-neo3/u-boot/idbloader.bin of=${LOOP_DEV} seek=64 conv=notrunc
92+
dd if=platform-nanopi/nanopi-neo3/u-boot/uboot.img of=${LOOP_DEV} seek=16384 conv=notrunc
93+
dd if=platform-nanopi/nanopi-neo3/u-boot/trust.bin of=${LOOP_DEV} seek=24576 conv=notrunc
94+
sync
95+
96+
echo "Preparing for Volumio rootfs"
97+
if [ -d /mnt ]
98+
then
99+
echo "/mount folder exist"
100+
else
101+
mkdir /mnt
102+
fi
103+
if [ -d /mnt/volumio ]
104+
then
105+
echo "Volumio Temp Directory Exists - Cleaning it"
106+
rm -rf /mnt/volumio/*
107+
else
108+
echo "Creating Volumio Temp Directory"
109+
mkdir /mnt/volumio
110+
fi
111+
112+
echo "Creating mount point for the images partition"
113+
mkdir /mnt/volumio/images
114+
mount -t ext4 "${SYS_PART}" /mnt/volumio/images
115+
mkdir /mnt/volumio/rootfs
116+
mkdir /mnt/volumio/rootfs/boot
117+
mount -t vfat "${BOOT_PART}" /mnt/volumio/rootfs/boot
118+
119+
echo "Copying Volumio RootFs"
120+
cp -pdR build/$ARCH/root/* /mnt/volumio/rootfs
121+
122+
echo "Copying nanopineo3 boot files"
123+
cp -R platform-nanopi/nanopi-neo3/boot/* /mnt/volumio/rootfs/boot
124+
125+
echo "Copying nanopineo3 modules and firmware"
126+
cp -pdR platform-nanopi/nanopi-neo3/lib/modules /mnt/volumio/rootfs/lib/
127+
cp -R platform-nanopi/nanopi-neo3/firmware/* /mnt/volumio/rootfs/lib/firmware
128+
129+
echo "Preparing to run chroot for more nanopineo3 configuration"
130+
cp scripts/nanopineo3config.sh /mnt/volumio/rootfs
131+
cp scripts/initramfs/init.nextarm /mnt/volumio/rootfs/root/init
132+
cp scripts/initramfs/mkinitramfs-custom.sh /mnt/volumio/rootfs/usr/local/sbin
133+
#copy the scripts for updating from usb
134+
wget -P /mnt/volumio/rootfs/root http://repo.volumio.org/Volumio2/Binaries/volumio-init-updater
135+
136+
mount /dev /mnt/volumio/rootfs/dev -o bind
137+
mount /proc /mnt/volumio/rootfs/proc -t proc
138+
mount /sys /mnt/volumio/rootfs/sys -t sysfs
139+
echo $PATCH > /mnt/volumio/rootfs/patch
140+
141+
echo "UUID_DATA=$(blkid -s UUID -o value ${DATA_PART})
142+
UUID_IMG=$(blkid -s UUID -o value ${SYS_PART})
143+
UUID_BOOT=$(blkid -s UUID -o value ${BOOT_PART})
144+
" > /mnt/volumio/rootfs/root/init.sh
145+
chmod +x /mnt/volumio/rootfs/root/init.sh
146+
147+
if [ -f "/mnt/volumio/rootfs/$PATCH/patch.sh" ] && [ -f "config.js" ]; then
148+
if [ -f "UIVARIANT" ] && [ -f "variant.js" ]; then
149+
UIVARIANT=$(cat "UIVARIANT")
150+
echo "Configuring variant $UIVARIANT"
151+
echo "Starting config.js for variant $UIVARIANT"
152+
node config.js $PATCH $UIVARIANT
153+
echo $UIVARIANT > /mnt/volumio/rootfs/UIVARIANT
154+
else
155+
echo "Starting config.js"
156+
node config.js $PATCH
157+
fi
158+
fi
159+
160+
chroot /mnt/volumio/rootfs /bin/bash -x <<'EOF'
161+
su -
162+
/nanopineo3config.sh
163+
EOF
164+
165+
UIVARIANT_FILE=/mnt/volumio/rootfs/UIVARIANT
166+
if [ -f "${UIVARIANT_FILE}" ]; then
167+
echo "Starting variant.js"
168+
node variant.js
169+
rm $UIVARIANT_FILE
170+
fi
171+
172+
#cleanup
173+
rm /mnt/volumio/rootfs/root/init.sh /mnt/volumio/rootfs/nanopineo3config.sh /mnt/volumio/rootfs/root/init
174+
175+
echo "Unmounting Temp devices"
176+
umount -l /mnt/volumio/rootfs/dev
177+
umount -l /mnt/volumio/rootfs/proc
178+
umount -l /mnt/volumio/rootfs/sys
179+
180+
echo "==> nanopineo3 device installed"
181+
182+
sync
183+
184+
echo "Finalizing Rootfs creation"
185+
sh scripts/finalize.sh
186+
187+
echo "Preparing rootfs base for SquashFS"
188+
189+
if [ -d /mnt/squash ]; then
190+
echo "Volumio SquashFS Temp Dir Exists - Cleaning it"
191+
rm -rf /mnt/squash/*
192+
else
193+
echo "Creating Volumio SquashFS Temp Dir"
194+
mkdir /mnt/squash
195+
fi
196+
197+
echo "Copying Volumio rootfs to Temp Dir"
198+
cp -rp /mnt/volumio/rootfs/* /mnt/squash/
199+
200+
if [ -e /mnt/kernel_current.tar ]; then
201+
echo "Volumio Kernel Partition Archive exists - Cleaning it"
202+
rm -rf /mnt/kernel_current.tar
203+
fi
204+
205+
echo "Creating Kernel Partition Archive"
206+
tar cf /mnt/kernel_current.tar --exclude='resize-volumio-datapart' -C /mnt/squash/boot/ .
207+
208+
echo "Removing the Kernel"
209+
rm -rf /mnt/squash/boot/*
210+
211+
echo "Creating SquashFS, removing any previous one"
212+
rm -r Volumio.sqsh
213+
mksquashfs /mnt/squash/* Volumio.sqsh
214+
215+
echo "Squash filesystem created"
216+
echo "Cleaning squash environment"
217+
rm -rf /mnt/squash
218+
219+
#copy the squash image inside the boot partition
220+
cp Volumio.sqsh /mnt/volumio/images/volumio_current.sqsh
221+
sync
222+
echo "Unmounting Temp Devices"
223+
umount -l /mnt/volumio/images
224+
umount -l /mnt/volumio/rootfs/boot
225+
226+
dmsetup remove_all
227+
losetup -d ${LOOP_DEV}
228+
sync
229+
230+
md5sum "$IMG_FILE" > "${IMG_FILE}.md5"

0 commit comments

Comments
 (0)