Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DietPi-Build | Add support for Sparky SBC #6391

Merged
merged 1 commit into from
May 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .build/images/dietpi-build
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ case $HW_MODEL in
'68.1') iname='NanoPiM4' HW_ARCH=3 partition_start=16 root_size=752;;
'68.2') iname='NanoPCT4' HW_ARCH=3 partition_start=16 root_size=752;;
'68.3') iname='NanoPiNEO4' HW_ARCH=3 partition_start=16 root_size=752;;
70) iname='SparkySBC' HW_ARCH=2 partition_start=8 boot_size=48 root_size=712 boot_fstype='fat16';;
72) iname='ROCKPi4' HW_ARCH=3 partition_start=16 root_size=752;;
73) iname='ROCKPiS' HW_ARCH=3 partition_start=16 root_size=752;;
74) iname='RadxaZero' HW_ARCH=3 partition_start=4 root_size=764;;
Expand Down Expand Up @@ -459,7 +460,7 @@ export FP_ROOT_DEV CLONING_TOOL OUTPUT_IMG_NAME MOUNT_IT='Off' SKIP_ARCHIVE SKIP
[[ $EDITION && $EDITION != 'all' ]] || bash -c "$(curl -sSf "https://raw.githubusercontent.com/$G_GITOWNER/DietPi/$G_GITBRANCH/.build/images/dietpi-imager")" 'DietPi-Imager' "$OUTPUT_IMG_NAME.img" || exit 1

# Amiberry edition: Install automatically on first boot, enable autostart option and onboard audio on RPi
if [[ $EDITION =~ ^(Amiberry|all)$ ]]
if [[ $EDITION == 'Amiberry' || ( $EDITION == 'all' && $HW_MODEL == 0 ) ]]
then
G_EXEC mv "$OUTPUT_IMG_NAME.img" "${OUTPUT_IMG_NAME}_Amiberry.img"
OUTPUT_IMG_NAME="${OUTPUT_IMG_NAME}_Amiberry"
Expand Down Expand Up @@ -498,7 +499,7 @@ then
fi

# AlloGUI edition: Pre-install Allo GUI with all managed audiophile software
if [[ $EDITION =~ ^(AlloGUI|all)$ ]]
if [[ $EDITION == 'AlloGUI' || ( $EDITION == 'all' && $HW_MODEL =~ ^(0|70)$ ) ]]
then
G_EXEC mv "$OUTPUT_IMG_NAME.img" "${OUTPUT_IMG_NAME%_Amiberry}_AlloGUI.img"
OUTPUT_IMG_NAME="${OUTPUT_IMG_NAME%_Amiberry}_AlloGUI"
Expand Down
122 changes: 33 additions & 89 deletions .build/images/dietpi-installer
Original file line number Diff line number Diff line change
Expand Up @@ -1053,19 +1053,19 @@ _EOF_
# Workaround for Odroid N2 failing to boot from eMMC: https://forum.armbian.com/topic/20206-odroid-n2-issues-with-recent-firmware-and-emmc-modules/#comment-142409
elif (( $G_HW_MODEL == 15 ))
then
G_EXEC curl -sSfO 'https://dietpi.com/downloads/binaries/u-boot-odroidn2.bin.gz'
G_EXEC gzip -d u-boot-odroidn2.bin.gz
G_EXEC dd if=u-boot-odroidn2.bin "of=$BOOT_DEVICE" bs=512 seek=1 conv=notrunc,fdatasync
G_EXEC rm u-boot-odroidn2.bin
G_EXEC curl -sSfo u-boot.gz 'https://dietpi.com/downloads/binaries/u-boot-odroidn2.bin.gz'
G_EXEC gzip -d u-boot.gz
G_EXEC dd if=u-boot "of=$BOOT_DEVICE" bs=512 seek=1 conv=notrunc,fdatasync
G_EXEC rm u-boot

# Workaround for NanoPi R1 failing boot: https://github.com/MichaIng/DietPi/issues/5927
elif (( $G_HW_MODEL == 48 ))
then
G_EXEC curl -sSfO 'https://dietpi.com/downloads/binaries/u-boot-nanopir1.bin.gz'
G_EXEC gzip -d u-boot-nanopir1.bin.gz
G_EXEC curl -sSfo u-boot.gz 'https://dietpi.com/downloads/binaries/u-boot-nanopir1.bin.gz'
G_EXEC gzip -d u-boot.gz
G_EXEC dd if=/dev/zero "of=$BOOT_DEVICE" bs=1K count=1023 seek=1 conv=notrunc,fdatasync
G_EXEC dd if=u-boot-nanopir1.bin "of=$BOOT_DEVICE" bs=1K seek=8 conv=notrunc,fdatasync
G_EXEC rm u-boot-nanopir1.bin
G_EXEC dd if=u-boot "of=$BOOT_DEVICE" bs=1K seek=8 conv=notrunc,fdatasync
G_EXEC rm u-boot
fi

# RPi
Expand Down Expand Up @@ -1122,15 +1122,35 @@ _EOF_
G_EXEC rm package.deb

# VisionFive 2
elif [[ $G_HW_MODEL == 81 ]]
elif (( $G_HW_MODEL == 81 ))
then
[[ -f '/boot/extlinux/extlinux.conf' ]] && G_EXEC rm /boot/extlinux/extlinux.conf
G_EXEC curl -sSfo package.deb 'https://dietpi.com/downloads/binaries/linux-image-visionfive2.deb'
[[ -f '/boot/extlinux/extlinux.conf' ]] && G_EXEC rm /boot/extlinux/extlinux.conf
G_EXEC_OUTPUT=1 G_EXEC dpkg -i package.deb
G_EXEC rm package.deb
G_EXEC sed -i "s/root=[^[:blank:]]*/root=PARTUUID=$(findmnt -Ufnro PARTUUID -M /)/" /boot/extlinux/extlinux.conf
G_EXEC sed -i "s/rootfstype=[^[:blank:]]*/rootfstype=$(findmnt -Ufnro FSTYPE -M /)/" /boot/extlinux/extlinux.conf

# Sparky SBC
elif (( $G_HW_MODEL == 70 ))
then
G_EXEC curl -sSfo package.deb 'https://dietpi.com/downloads/binaries/firmware-sparkysbc.deb'
[[ -f '/boot/uenv.txt' ]] && G_EXEC rm /boot/uenv.txt
G_EXEC_OUTPUT=1 G_EXEC dpkg -i package.deb
G_EXEC rm package.deb

G_EXEC curl -sSfo u-boot.gz 'https://dietpi.com/downloads/binaries/u-boot-sparkysbc.img.gz'
G_EXEC gzip -d u-boot.gz
G_EXEC dd if=u-boot "of=$BOOT_DEVICE" bs=1 count=442 conv=notrunc,fdatasync
G_EXEC dd if=u-boot "of=$BOOT_DEVICE" bs=512 skip=1 seek=1 conv=notrunc,fdatasync
G_EXEC rm u-boot

# Use performance governor for stability
G_CONFIG_INJECT 'CONFIG_CPU_GOVERNOR=' 'CONFIG_CPU_GOVERNOR=performance' /boot/dietpi.txt

# Apply Lighttpd as default webserver, since Apache does not run on Linux 3.10: https://dietpi.com/forum/t/allogui-not-working-apache-service-doesnt-start/15708
G_CONFIG_INJECT 'AUTO_SETUP_WEB_SERVER_INDEX=' 'AUTO_SETUP_WEB_SERVER_INDEX=-2' /boot/dietpi.txt

# Armbian grab currently installed packages
elif [[ $G_HW_MODEL != 75 && $(dpkg-query -Wf '${Package} ') == *'armbian'* ]]
then
Expand Down Expand Up @@ -1196,8 +1216,8 @@ _EOF_
G_EXEC rm -Rf /etc/apt/sources.list.d/{,.??,.[^.]}*
G_EXEC eval "echo 'deb https://apt.armbian.com/ $DISTRO_TARGET_NAME main' > /etc/apt/sources.list.d/dietpi-armbian.list"

# Generic kernel + device tree + U-Boot package auto detect + initramfs-tools (not required on Sparky SBC)
elif (( $G_HW_MODEL != 75 && $G_HW_MODEL != 70 ))
# Generic kernel + device tree + U-Boot package auto detect + initramfs-tools
elif (( $G_HW_MODEL != 75 ))
then
mapfile -t apackages < <(dpkg-query -Wf '${Package}\n' | grep -E '^linux-(image|dtb|u-boot)-|^u-boot')
[[ ${apackages[0]} ]] || G_DIETPI-NOTIFY 2 'Unable to find kernel packages for installation. Assuming non-APT/.deb kernel installation.'
Expand Down Expand Up @@ -1809,84 +1829,8 @@ _EOF_'
G_EXEC eval 'echo -e '\''apm = 127\nforce_spindown_time = 120'\'' > /etc/hdparm.conf'
fi

# Sparky SBC
if (( $G_HW_MODEL == 70 ))
then
# Install latest kernel/drivers
G_EXEC curl -sSf 'https://raw.githubusercontent.com/sparky-sbc/sparky-test/master/dragon_fly_check/uImage' -o /boot/uImage
G_EXEC curl -sSfO 'https://raw.githubusercontent.com/sparky-sbc/sparky-test/master/dragon_fly_check/3.10.38.bz2'
G_EXEC rm -Rf /lib/modules/*
G_EXEC tar -xf 3.10.38.bz2 -C /lib/modules/
G_EXEC rm 3.10.38.bz2
# - USB audio update
G_EXEC curl -sSf 'https://raw.githubusercontent.com/sparky-sbc/sparky-test/master/dsd-marantz/snd-usb-audio.ko' -o /lib/modules/3.10.38/kernel/sound/usb/snd-usb-audio.ko
# - Ethernet update
G_EXEC curl -sSf 'https://raw.githubusercontent.com/sparky-sbc/sparky-test/master/sparky-eth/ethernet.ko' -o /lib/modules/3.10.38/kernel/drivers/net/ethernet/acts/ethernet.ko

# Boot args
cat << '_EOF_' > /boot/uenv.txt
uenvcmd=setenv os_type linux;
bootargs=earlyprintk clk_ignore_unused selinux=0 scandelay console=tty0 loglevel=1 real_rootflag=rw root=/dev/mmcblk0p2 rootwait init=/lib/systemd/systemd aotg.urb_fix=1 aotg.aotg1_speed=0 net.ifnames=0 systemd.unified_cgroup_hierarchy=0
_EOF_
# Blacklist GPU and touch screen modules: https://github.com/MichaIng/DietPi/issues/699#issuecomment-271362441
cat << '_EOF_' > /etc/modprobe.d/dietpi-disable_sparkysbc_touchscreen.conf
blacklist owl_camera
blacklist gsensor_stk8313
blacklist ctp_ft5x06
blacklist ctp_gsl3680
blacklist gsensor_bma222
blacklist gsensor_mir3da
_EOF_
cat << '_EOF_' > /etc/modprobe.d/dietpi-disable_sparkysbc_gpu.conf
blacklist pvrsrvkm
blacklist drm
blacklist videobuf2_vmalloc
blacklist bc_example
_EOF_
# Use performance gov for stability
G_CONFIG_INJECT 'CONFIG_CPU_GOVERNOR=' 'CONFIG_CPU_GOVERNOR=performance' /boot/dietpi.txt

# Install script to toggle between USB and onboard Ethernet automatically
cat << '_EOF_' > /var/lib/dietpi/services/dietpi-sparkysbc_ethernet.sh
#!/bin/dash
# Called from: /etc/systemd/system/dietpi-sparkysbc_ethernet.service
# We need to wait until USB Ethernet is established on USB bus, which takes much longer than onboard init.
sleep 20
# Disable onboard Ethernet if USB Ethernet is found
if ip a s eth1 > /dev/null 2>&1; then
echo 'blacklist ethernet' > /etc/modprobe.d/dietpi-disable_sparkysbc_ethernet.conf
reboot
# Enable onboard Ethernet if no adapter is found
elif ! ip a s eth0 > /dev/null 2>&1; then
rm -f /etc/modprobe.d/dietpi-disable_sparkysbc_ethernet.conf
reboot
fi
_EOF_
G_EXEC chmod +x /var/lib/dietpi/services/dietpi-sparkysbc_ethernet.sh
cat << '_EOF_' > /etc/systemd/system/dietpi-sparkysbc_ethernet.service
[Unit]
Description=Sparky SBC auto detect and toggle onboard/USB Ethernet
Wants=network-online.target
After=network-online.target
[Service]
RemainAfterExit=yes
ExecStart=/var/lib/dietpi/services/dietpi-sparkysbc_ethernet.sh
[Install]
WantedBy=multi-user.target
_EOF_
G_EXEC systemctl enable dietpi-sparkysbc_ethernet

# Apply Lighttpd as default webserver, since Apache does not run on Linux 3.10: https://dietpi.com/forum/t/allogui-not-working-apache-service-doesnt-start/15708
G_CONFIG_INJECT 'AUTO_SETUP_WEB_SERVER_INDEX=' 'AUTO_SETUP_WEB_SERVER_INDEX=-2' /boot/dietpi.txt

# RPi
elif (( $G_HW_MODEL < 10 ))
if (( $G_HW_MODEL < 10 ))
then
# Apply minimum GPU memory split for server usage: This applies a custom dtoverlay to disable VCSM: https://github.com/MichaIng/DietPi/pull/3900
/boot/dietpi/func/dietpi-set_hardware gpumemsplit 16
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/dietpi-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ jobs:
'"-m 68.1 -d 6", "-m 68.1 -d 7", '\
'"-m 68.2 -d 6", "-m 68.2 -d 7", '\
'"-m 68.3 -d 6", "-m 68.3 -d 7", '\
'"-m 70 -d 6 -e all", '\
'"-m 72 -d 6", "-m 72 -d 7", '\
'"-m 73 -d 6", "-m 73 -d 7", '\
'"-m 74 -d 6", "-m 74 -d 7", '\
Expand Down