From 8fc8e4bb98f257d6bbe5a5ff716b0f8c97ec879a Mon Sep 17 00:00:00 2001 From: MichaIng Date: Mon, 16 Oct 2023 01:17:15 +0200 Subject: [PATCH] v8.23 - VisionFive 2 | Bump kernel and apply 8 GB and model A overlays automatically on update as well as on first boot. Also inform users about the U-Boot environment change, needed to boot our image with latest StarFive U-Boot release. --- .build/images/dietpi-installer | 6 ++- .update/patches | 50 ++++++++++++++++- .../lib/dietpi/services/dietpi-firstboot.bash | 54 +++++++++++++++---- 3 files changed, 99 insertions(+), 11 deletions(-) diff --git a/.build/images/dietpi-installer b/.build/images/dietpi-installer index e029ea8268..20d0dff59c 100755 --- a/.build/images/dietpi-installer +++ b/.build/images/dietpi-installer @@ -1230,11 +1230,15 @@ _EOF_ elif (( $G_HW_MODEL == 81 )) then 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 + dpkg-deb -I linux-image-visionfive2.deb conffiles | while read -r line + do + [[ -f $line ]] && G_EXEC rm "$line" + done 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 + aPACKAGES_REQUIRED_INSTALL+=('libubootenv-tool') # Sparky SBC elif (( $G_HW_MODEL == 70 )) diff --git a/.update/patches b/.update/patches index 99147ef48e..c0dccf86c8 100755 --- a/.update/patches +++ b/.update/patches @@ -1470,12 +1470,60 @@ Patch_8_23() G_EXEC rm package.deb # VisionFive 2 - elif (( $G_HW_MODEL == 81 )) && dpkg --compare-versions "$(dpkg-query -Wf '${Version}' linux-image-visionfive2 2> /dev/null)" lt-nl 6.1.55-dietpi1 + elif (( $G_HW_MODEL == 81 )) && dpkg --compare-versions "$(dpkg-query -Wf '${Version}' linux-image-visionfive2 2> /dev/null)" lt-nl 6.1.58-dietpi1 then G_DIETPI-NOTIFY 2 'Updating RISC-V StarFive VisionFive 2 kernel ...' G_EXEC_OUTPUT=1 G_EXEC curl -fo package.deb 'https://dietpi.com/downloads/binaries/linux-image-visionfive2.deb' G_EXEC_OUTPUT=1 G_EXEC dpkg -i --force-confdef,confold package.deb G_EXEC rm package.deb + local serial overlays=() + read -r serial < /proc/device-tree/serial-number + if [[ $serial == 'VF7110A1-'* ]] + then + G_DIETPI-NOTIFY 2 'A revision detected, applying device tree overlay to fix Ethernet ...' + read -ra overlays < <(mawk '$1=="fdtoverlays"{$1="";print}' /boot/extlinux/extlinux.conf) + local add=1 + for i in "${overlays[@]}" + do + [[ $i == '/usr/lib/linux-image-visionfive2/starfive/vf2-overlay/ethernet-A12.dtbo' ]] || continue + G_DIETPI-NOTIFY 2 'A revision Ethernet overlay was applied already ...' + add=0 + done + if (( $add )) + then + overlays+=('/usr/lib/linux-image-visionfive2/starfive/vf2-overlay/ethernet-A12.dtbo') + G_CONFIG_INJECT 'fdtoverlays[[:blank:]]' "fdtoverlays ${overlays[@]}" /boot/extlinux/extlinux.conf + fi + fi + if [[ $serial == *'-D008E000-'* ]] + then + G_DIETPI-NOTIFY 2 '8 GB RAM model detected, applying device tree overlay to make all 8 GB available to the system ...' + read -ra overlays < <(mawk '$1=="fdtoverlays"{$1="";print}' /boot/extlinux/extlinux.conf) + local add=1 + for i in "${overlays[@]}" + do + [[ $i == '/usr/lib/linux-image-visionfive2/starfive/vf2-overlay/8GB.dtbo' ]] || continue + G_DIETPI-NOTIFY 2 '8 GB RAM overlay was applied already ...' + add=0 + done + if (( $add )) + then + overlays+=('/usr/lib/linux-image-visionfive2/starfive/vf2-overlay/8GB.dtbo') + G_CONFIG_INJECT 'fdtoverlays[[:blank:]]' "fdtoverlays ${overlays[@]}" /boot/extlinux/extlinux.conf + fi + fi + G_AGI libubootenv-tool + G_WHIP_MSG '[ INFO ] VisionFive 2 U-Boot environment and boot priorities +\nThe latest StarFive U-Boot release does not support our image anymore without adjusting the U-Boot environment. +\nThe kernel package we just installed comes with the needed config files to change the U-Boot environment. We took the chance to ship a generic default which allows to boot from all filesystems on all partitions from all boot media, including NVMe, USB, eMMC, SD cards and DHCP/TFTP. +\nEspecially before updating to latest SPI bootloader, we recommend to flash this environment, right after you rebooted the system, with the following command: +# fw_setenv +\nAfterwards, you can print the U-Boot environment via "fw_printenv" and set individual variables via +# fw_setenv name value +\nThe "boot_targets" variabe takes a list of targets, which U-Boot tries to boot from left to right. The default is +# fw_setenv boot_targets "mmc1 usb0 nvme0 mmc0 dhcp" +\n"mnc1" is the SD card, "mmc0" the eMMC module. +\nPlease report back if you face any issues with this U-Boot environment, e.g. also with other distributions.' fi # ADS-B Feeder used to install two service files that aren't needed: https://github.com/MichaIng/DietPi/pull/6661 if [[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[141\]=2' /boot/dietpi/.installed diff --git a/rootfs/var/lib/dietpi/services/dietpi-firstboot.bash b/rootfs/var/lib/dietpi/services/dietpi-firstboot.bash index b4ce9e6fee..6d7228f48d 100755 --- a/rootfs/var/lib/dietpi/services/dietpi-firstboot.bash +++ b/rootfs/var/lib/dietpi/services/dietpi-firstboot.bash @@ -114,24 +114,60 @@ _EOF_ *'T6'*) [[ -f '/etc/udev/rules.d/dietpi-eth-leds.rules' ]] && rm /etc/udev/rules.d/dietpi-eth-leds.rules;; *) :;; esac + + # VisionFive 2 + elif [[ $G_HW_MODEL == 81 && -f '/proc/device-tree/serial-number' ]] + then + local serial overlays=() + read -r serial < /proc/device-tree/serial-number + if [[ $serial == 'VF7110A1-'* ]] + then + G_DIETPI-NOTIFY 2 'A revision detected, applying device tree overlay to fix Ethernet ...' + read -ra overlays < <(mawk '$1=="fdtoverlays"{$1="";print}' /boot/extlinux/extlinux.conf) + local add=1 + for i in "${overlays[@]}" + do + [[ $i == '/usr/lib/linux-image-visionfive2/starfive/vf2-overlay/ethernet-A12.dtbo' ]] || continue + G_DIETPI-NOTIFY 2 'A revision Ethernet overlay was applied already ...' + add=0 + done + if (( $add )) + then + overlays+=('/usr/lib/linux-image-visionfive2/starfive/vf2-overlay/ethernet-A12.dtbo') + G_CONFIG_INJECT 'fdtoverlays[[:blank:]]' "fdtoverlays ${overlays[@]}" /boot/extlinux/extlinux.conf + fi + fi + if [[ $serial == *'-D008E000-'* ]] + then + G_DIETPI-NOTIFY 2 '8 GB RAM model detected, applying device tree overlay to make all 8 GB available to the system ...' + read -ra overlays < <(mawk '$1=="fdtoverlays"{$1="";print}' /boot/extlinux/extlinux.conf) + local add=1 + for i in "${overlays[@]}" + do + [[ $i == '/usr/lib/linux-image-visionfive2/starfive/vf2-overlay/8GB.dtbo' ]] || continue + G_DIETPI-NOTIFY 2 '8 GB RAM overlay was applied already ...' + add=0 + done + if (( $add )) + then + overlays+=('/usr/lib/linux-image-visionfive2/starfive/vf2-overlay/8GB.dtbo') + G_CONFIG_INJECT 'fdtoverlays[[:blank:]]' "fdtoverlays ${overlays[@]}" /boot/extlinux/extlinux.conf + fi + fi fi # End user automated script - if [[ -f '/boot/Automation_Custom_PreScript.sh' ]]; then - - G_DIETPI-NOTIFY 2 'Running custom script, please wait...' + if [[ -f '/boot/Automation_Custom_PreScript.sh' ]] + then + G_DIETPI-NOTIFY 2 'Running custom script, please wait ...' chmod +x /boot/Automation_Custom_PreScript.sh - if /boot/Automation_Custom_PreScript.sh 2>&1 | tee /var/tmp/dietpi/logs/dietpi-automation_custom_prescript.log; then - + if /boot/Automation_Custom_PreScript.sh 2>&1 | tee /var/tmp/dietpi/logs/dietpi-automation_custom_prescript.log + then G_DIETPI-NOTIFY 0 'Custom script' - else - G_DIETPI-NOTIFY 1 'Custom script: Please see the log file for more information: - /var/tmp/dietpi/logs/dietpi-automation_custom_prescript.log' - fi - fi # Apply swap settings