Post by jj0 on Dec 30, 2021 11:40:36 GMT
I've created a 'fake upgrade' that provides a method to allow THE64 (both Mini and Maxi/VIC-20 models) to boot from USB as well as from the internal NAND. It uses a Trojan Horse (or is it Matroshka?) approach, by modifying the NANDA (/dev/nanda) image. Normally this NANDA contains a combination of Linux kernel + initial ramdisk packed in the Android Boot Image format. The update replaces this with a kernel that is actually a modern (mainline v2021.10) USB-boot capable u-boot bootloader + an initial ramdisk that is actually a repacked Android Boot Image of the original Linux kernel + initial ramdisk. This repacked Android Boot Image is created on the fly from the actual /dev/nanda to ensure that it is compatible with the THE64 model the fake update is applied to. The original NANDA content is backed up first and can be restored if required via FEL mode or a command line shell.
Upon boot, THE64 first loads its own standard (legacy v2011.09) u-boot bootloader from NAND as normal. This then loads the NANDA content (as normal) and executes it. That starts the new u-boot which if a USB stick is inserted checks for bootable content on the USB stick. If there is bootable content it loads/executes it, if there isn't it proceeds with booting the original THE64 kernel.
Bootable content on the USB stick can be a uEnv.txt file (containing u-boot environment variables), a boot.scr (containing a script with u-boot instructions) in the root or 'boot' directory of a FAT or EXT2/3/4 first partition, or a saved u-boot environment (uboot.env) in a FAT first partition, or a combination of these.
Both the UART and HDMI are used for output and both UART and a USB (or Maxi/VIC-20) keyboard are used for input. Booting can be interrupted by pressing the 'j' key or CTRL-C though if there's a boot.scr loaded this will be executed anyway.
To install this, download this 7z file and extract it to a USB stick that you know works for updates to THE64. Then apply the update. The screen will provide information on the backed up NANDA filename and on progress of applying the update. If there are any errors during the process before writing to the NANDA it will stop. If there are errors when it (tries to) write to NANDA it will drop into a command-line shell.
USE THIS AT YOUR OWN RISK:
Once you have this installed you can experiment with loading your own kernels etc or load existing Linux OS distributions by writing the relevant OS image to a USB stick and adding an appropriate uEnv.txt to the / or /boot folder to modify the OS behaviour for booting from USB instead of SD/mmc. I've included some example uEnv files in the 'Mini/Example uEnv' and 'Maxi/Example uEnv' directories for booting:
For the Mini:For the Maxi:
All of these support having the rootfs on USB.
(links are actual as of 30th december 2021)
While these images boot fine, there are hardware differences (amount of memory, having a built-in Ethernet port, available PMIC, ...) between the full-fledged SBC's that these images are for and the Mini/Maxi so they could do with some tweaking of e.g. script.bin or the .dts/.dtb files.
Other uses could be to boot into 'THE64' mode from an USB stick or probably to convert a PAL Mini to NTSC and vice versa.
Changelog:
Upon boot, THE64 first loads its own standard (legacy v2011.09) u-boot bootloader from NAND as normal. This then loads the NANDA content (as normal) and executes it. That starts the new u-boot which if a USB stick is inserted checks for bootable content on the USB stick. If there is bootable content it loads/executes it, if there isn't it proceeds with booting the original THE64 kernel.
Bootable content on the USB stick can be a uEnv.txt file (containing u-boot environment variables), a boot.scr (containing a script with u-boot instructions) in the root or 'boot' directory of a FAT or EXT2/3/4 first partition, or a saved u-boot environment (uboot.env) in a FAT first partition, or a combination of these.
Both the UART and HDMI are used for output and both UART and a USB (or Maxi/VIC-20) keyboard are used for input. Booting can be interrupted by pressing the 'j' key or CTRL-C though if there's a boot.scr loaded this will be executed anyway.
To install this, download this 7z file and extract it to a USB stick that you know works for updates to THE64. Then apply the update. The screen will provide information on the backed up NANDA filename and on progress of applying the update. If there are any errors during the process before writing to the NANDA it will stop. If there are errors when it (tries to) write to NANDA it will drop into a command-line shell.
USE THIS AT YOUR OWN RISK:
- I've tested in on my Mini, Maxi and VIC-20 without issues but your results might vary
- Take care to ensure your THE64 has enough power when you apply the fake upgrade
- Store the NANDA backup (located in the THE64_USB_boot/Backup directory) somewhere safe
- Only install this if you are willing to experiment with USB booting and accept the risk of messing up your THE64
Once you have this installed you can experiment with loading your own kernels etc or load existing Linux OS distributions by writing the relevant OS image to a USB stick and adding an appropriate uEnv.txt to the / or /boot folder to modify the OS behaviour for booting from USB instead of SD/mmc. I've included some example uEnv files in the 'Mini/Example uEnv' and 'Maxi/Example uEnv' directories for booting:
For the Mini:
- Armbian_5.90_Orangepipcplus_Ubuntu_xenial_default_3.4.113_desktop
- Armbian_20.11.6_Orangepipcplus_focal_current_5.10.4
All of these support having the rootfs on USB.
(links are actual as of 30th december 2021)
While these images boot fine, there are hardware differences (amount of memory, having a built-in Ethernet port, available PMIC, ...) between the full-fledged SBC's that these images are for and the Mini/Maxi so they could do with some tweaking of e.g. script.bin or the .dts/.dtb files.
Other uses could be to boot into 'THE64' mode from an USB stick or probably to convert a PAL Mini to NTSC and vice versa.
Changelog:
- v1.1: Fixed bug in the Mini version bug preventing it to boot from the internal firmware.
- v1.0: Initial release
The moment the Mini version v1.0 has a bug preventing it to boot from the internal firmware. You have to have a USB stick with this uEnv.txt (29B) on it. This will be fixed in the next release. Thanks spannernick for testing and discovering that it didn't work on a standard Mini (mine has 512MB).