Chainloaded uboot images for amlogic


Recommended Posts

@lanefu - for those amlogic tv boxes chainloading u-boot means the old legacy u-boot on the box is loading a mainline u-boot.bin (which has nice features like extlinux.conf support and allocates less memory for itself) which is then loading the kernel

 

@SteeMan - this looks a bit like this box has a non standard mmc setup which might be not so easy to track down (one would need to extract the android dtb from the box - see: https://github.com/hexdump0815/u-boot-misc/tree/master/misc.h616-legacy/android-device-tree-copy and then the mmc entries should be compared to the android dtbs of other boxes where emmc works - here is for instance my h96max-x3 android dtb: https://github.com/hexdump0815/linux-mainline-and-mali-amlogic-kernel/blob/master/misc.aml/dtb/meson-sm1-h96max-x3.dts.android - this is a big puzzle and a lot of trial and error might be required without the guarantee to get it working)

 

the patch is to remove some code which will not work in our scenario (getting linux working on it) - it looks like the mainline u-boot code for the s905x3 i used as a base was only done for android which has a different partition (+table) setup than what we plan to use

 

the uEnv.txt file is read before extlinux.conf, so things can be set there which partially cannot be defined in the extlinux.conf (which is quite limited) - in armbian that file usually is called armbianEnv.txt i think, so you should maybe adjust the filename to be in sync with armbian if you want to get it closer to a standard armbian setup

 

just an idea: you might also try the newer u-boot 2021.01 or soon the upcoming 2021.04, but i think nothing really changed in there for amlogic

 

@lcapriotti - it would be very helpful if you could find out how you got it to work on your box - this might getting this resolved easier for @SteeMan maybe

 

good luck and best wishes - hexdump

Link to post
Share on other sites
Armbian is a community driven open source project. Do you like to contribute your code?

31 minutes ago, lanefu said:

Interesting I'll have to learn more about extlinux.conf 

One of the interesting features of extlinux.conf is the ability to present a boot menu.  I have played around with it a bit to have different kernel versions installed and switch between them at boot time.  With a boot menu and hdmi support in u-boot, it brings some nice capabilities.

Link to post
Share on other sites
17 hours ago, hexdump said:

 

@lcapriotti - it would be very helpful if you could find out how you got it to work on your box - this might getting this resolved easier for @SteeMan maybe

What I *think* I have done is:

 

use sm1-u-boot.bin from https://github.com/hexdump0815/u-boot-misc/releases/tag/200926-01 

dd the file to an SD card and boot from it

dd the file to the emmc once booted from the SD card

 

Not 100% sure though

Link to post
Share on other sites

@lcapriotti thanks for uploading that file.  That file is identical to hexdump's sm1-u-boot.bin file linked to above.  The mystery remains why you originally had the same issue that I am seeing with the tx3 box not being able to access emmc with this u-boot.  But as you report you are no longer having that problem.

Link to post
Share on other sites

maybe upgraded or downgraded android on the box, i.e. different version of the legacy u-boot? - in case both of you have a serial console connected you might compare the u-boot version strings from early boot ...

Link to post
Share on other sites

that log looks like my mainline u-boot is not chainloaded but has replaced the legacy u-boot (as there is no sign of a legacy u-boot in the log) ... this works quite well for me but is not tested too well and worst case you can brick the box - but looks like you got it working well too :)

 

maybe you wiped your emmc (accidently?) and by chance had the proper u-boot at the proper place on the sd card ... if the box does not find a boot loader on emmc then it will try to boot from sd card ... or you even by chance replaced the bootloader on emmc with my mainline u-boot ...

Link to post
Share on other sites

@hexdump

 

Thank you for your work on these chain loaders. It has enabled me to do something I have wanted for a long time.

 

I have your g12a-u-boot.bin (renamed to u-boot.ext) running on my Ugoos AM6 plus, in a multi-os boot setup, with all OSes installed on the SD (utilizing the vendor boot for the all boot stages except the last, which is in u-boot.ext). Currently, I can boot into Armbian Meson64 (Hirsute flavor, built in QEMU based on the rootfs file tree), Manjaro ARM (for VIM3/Ugoos, copied from distro image), and a Armbian Buster mini as rescue (also from QEMU/rootfs).

 

By writing the entries in extlinux.conf according to the correct menu syntax (inferred from e.g. pxe_utils.c in u-boot source, see below) one can select which kernel+initrd+dtb to load, and which root file system to mount. (One has to be quick at the second prompt to make the OS selection. This prompt appears at the sysboot stage, after u-boot autoload has timed out. Perhaps the sysboot timeout can be extended a bit? Edit: The TIMEOUT keyword does not seem to take effect.)

 

On all the OSes I have kept their original /boot dir and then added a new mount point /boot_FAT32 where the first FAT32 partition is located (with extlinux.conf, kernels+initrds+dtbs, and u-boot.ext), and updated the local /etc/fstab accordingly. Then it is simple to propagate the changes made to /boot under a running OS also to the boot partition. The SD layout/geometry is essentially: From the first available sector (2048, no gap needed) and 300M onwards; the kernel+initrd+dtbs and extlinux.conf stuff on a FAT32 partition. The follows, after perhaps a common swap partition, a number of ext4 partitions with the different OSes.

 

Here is what the extlinux.conf can look like

 

Spoiler



TIMEOUT 20
MENU TITLE Multi-OS-USB

# Partition 5
 LABEL Manjaro
  LINUX /auxboot/Manjaro/Image
  INITRD /auxboot/Manjaro/initramfs-linux.img
  FDT /auxboot/Manjaro/meson-g12b-ugoos-am6-plus.dtb
  APPEND root=UUID=XXXXXXX-8c29-48c2-94a6-b14b9cc76a44 rootflags=data=writeback rw console=ttyAML0,115200n8 console=tty0 no_console_suspend consoleblank=0 fsck.fix=yes fsck.repair=yes net.ifnames=0

# Partition 6
 LABEL ArmbianHirsute
  LINUX /auxboot/ArmbHirsute/vmlinuz
  INITRD /auxboot/ArmbHirsute/initrd.img
  FDT /auxboot/ArmbHirsute/meson-g12b-ugoos-am6.dtb
  APPEND root=UUID=XXXXXXX-e7a8-42f7-813d-1907d72f739d rootflags=data=writeback rw console=ttyAML0,115200n8 console=tty0 no_console_suspend consoleblank=0 fsck.fix=yes fsck.repair=yes net.ifnames=0

 

 

P.S. I know it is hard to compile these loaders correctly: From u-boot-amlogic (custodian) have have managed to compile, starting with different defconfigs, chain loaders that boot but with; no (HDMI) screen, green screen (several flavors), and indeed, purple-pinkish screen, but not one single working properly. Doh.

Link to post
Share on other sites