Build U-Boot from denx u-boot source

Hi, I want to know if there is a way to build U-Boot from denx source. I was looking but there’s no support for BPI-M5 but for Odroid C4. I want to run kernel 5.X mainline.

Does Odroid C4 have the same CPU as M5? If so I believe you just have to adjust the pinmuxing. Check if odroid-c4 has a DTS file, and change the muxing accordingly. You might be limited on the types of boot though. Ethernet booting might not working if PHYs are different

In fact, the last mainline kernel provide the dts for BPI-M5, the thing is I don’t know how made the right kernel configs for BPI-M5 in the menuconfig, boot.ini settings and overlays.

This is what I want to do:

https://linux-meson.com/doku.php

Settings and overlays are usually independent from kernel (they run before everything). So you should be okay by just copying the ones from the original image.

The menuconfig part I would try running defconfig (make ARCH=arm64 defconfig) and try to boot with this. Might boot, but miss the necessary modules for other IC on the board. For those you can go in Device Drivers menu and select the ones on your board (’/’ key brings the search menu, it helps finding most of the drivers).

Have you tried the doku tutorial you shared, where did it took you?

Thanks for your help Otavio, I tried with 5.14 mainline Kernel source and defconfig, the good thing with 5.14 mainline Kernel source is that comes with dtbs for bananna pi m5. At last I made it boot but ethernet is not working, It’s good to kwon (I’m not an expert on this matters) that the overlays are usually independent from kernel.

If it boots is a very good sign. Do you reach a bash terminal? The usual handover process is something like: Power->Pre-boot routines (overlays and U-Boot PSL)->U-Boot->Kernel + DTS->/sbin/init->bash

If you can see Kernel messages but no terminal all you have to do is double check /sbin/init and your bash (some images uses busybox for this).

The missing ethernet, most likely is just a missing driver. From the photos it seems like M5 uses a Realtek as PHY, but I couldn’t discern the part number. M5 and Odroid-C4 seems to have similar design, the latest uses a Realtek RTL8211F. Check if your board has the same one (the Phy is the closest to the Ethernet Jack, it has a crab as logo).

On menuconfig, navigate to Device Drivers->Network Device Support->Ethernet Driver Support and look if Realtek Devices is checked (with a * not a M), if it’s try checking all other Realtek options (RTL-8139, RTL-8129 and 8169), if you still can’t get a connection you might need the firmware binaries. What distro are you using, try searching for “firmware-realtek” with your distro name on google.

Hi Otavio, thanks for your help, your tip for ethernet works well but have some issues due tmp free space, I don’t understand why if I used the same root file system without that trouble. By other hand, I’ve found that there is an update for BPI-M5 support on https://source.denx.de/u-boot/custodians/u-boot-amlogic, it supposed to build an U-Boot for Amlogic but I don’t know how to burning into SD Card after build process.

You might be missing a tmp partition or not big enough, that’s usually on “/tmp/”. Can you see that folder on the root of the system? What lsblk returns? On SD based systems is a good thing to mount /var/log and /tmp on RAM filesystems (ramfs) or more durable memories, Banana Pi W2 for example has a eMMC Flash so my lsblk reads like:

mmcblk1      179:0    0  7.3G  0 disk
├─mmcblk1p1  179:1    0    1G  0 part  /var
└─mmcblk1p2  179:2    0    1G  0 part  /tmp
mmcblk1boot0 179:8    0    4M  1 disk
mmcblk1boot1 179:16   0    4M  1 disk
mmcblk1rpmb  179:24   0  512K  0 disk
mmcblk0      179:32   0 29.7G  0 disk
├─mmcblk0p1  179:33   0  256M  0 part  /boot
└─mmcblk0p2  179:34   0  3.7G  0 part  /

Try checking where your device is mounting /tmp, if M5 has some sort of flash change /etc/fstab to mount /tmp there. U-boot usually provides flashing documentation, boot.ini probably contains the boot binary it will run, copy the binary generated on u-boot (u-boot.bin usually) to the root of your SD card and copy the name to boot.ini.

This might also be helpful: https://www.cnx-software.com/2016/11/19/how-to-create-a-bootable-recovery-sd-card-for-amlogic-tv-boxes/

I try the https://u-boot.readthedocs.io/en/latest/board/amlogic/odroid-c4.html method without success, BPI-M5 have the same file scheme but it doesn’t work.

USB/SD and eMMC images can be created with the same u-boot and instructions as any mainline u-boot using Amlogic GXBB/GXL/GXM/G12A/G12B/SM1 board/device:

  dd if="/path/to/u-boot.bin.sd.bin" of="/dev/mmcblkX" conv=fsync,notrunc bs=1 count=444
  dd if="/path/to/u-boot.bin.sd.bin" of="/dev/mmcblkX" conv=fsync,notrunc bs=512 skip=1 seek=1

Feel free to use: https://chewitt.libreelec.tv/testing/u-boot/u-boot.bin.sd.bin-bananapi-m5

Source: https://github.com/chewitt/u-boot/commits/amlogic-2021.07 which includes M5 support.

2 Likes

Hey,

I am still stuck after kernel is loaded using this uboot.

I am sure it’s not the uboot but the linux kernel.
I am using upstream kernel without any m5 specific patch.

I will have to look deeper into the things i might have missed.

Log here.

NOTICE:  BL31: v1.3(release):4fc40b1                                             
NOTICE:  BL31: Built : 15:57:33, May 22 2019                                     
NOTICE:  BL31: G12A normal boot!                                                 
NOTICE:  BL31: BL33 decompress pass                                              
ERROR:   Error initializing runtime service opteed_fast                          
                                                                                 
                                                                                 
U-Boot 2021.07 (Sep 30 2021 - 06:38:04 +0000) odroid-c4/hc4                      
                                                                                 
Model: Hardkernel ODROID-C4                                                      
SoC:   Amlogic Meson SM1 (S905X3) Revision 2b:c (10:2)                           
DRAM:  3.8 GiB                                                                   
MMC:   sd@ffe05000: 0, mmc@ffe07000: 1                                           
Loading Environment from nowhere... OK                                           
In:    serial                                                                    
Out:   serial                                                                    
Err:   serial                                                                    
Board variant: c4                                                                
Net:   eth0: ethernet@ff3f0000                                                   
Hit any key to stop autoboot:  0                                                 
switch to partitions #0, OK                                                      
mmc0 is current device                                                           
Scanning mmc 0:1...                                                              
Found /extlinux/extlinux.conf                                                    
Retrieving file: /extlinux/extlinux.conf                                         
324 bytes read in 2 ms (158.2 KiB/s)                                             
1:      Manjaro ARM                                                              
Retrieving file: /initramfs-linux.img                                            
13223803 bytes read in 566 ms (22.3 MiB/s)                                       
Retrieving file: /Image                                                          
30624256 bytes read in 1308 ms (22.3 MiB/s)                                      
append: root=PARTUUID=76d8f071-02 rootflags=data=writeback rw console=ttyAML0,11s
Retrieving file: /dtbs/amlogic/meson-sm1-bananapi-m5.dtb                         
73627 bytes read in 7 ms (10 MiB/s)                                              
Moving Image from 0x8080000 to 0x8200000, end=a010000                            
## Flattened Device Tree blob at 08008000                                        
   Booting using the fdt blob at 0x8008000                                       
   Loading Ramdisk to 3f363000, end 3ffff77b ... OK                              
   Loading Device Tree to 000000003f34e000, end 000000003f362f9a ... OK          
                                                                                 
Starting kernel ...                                                              
                                                                                 
[    0.132503] kvm: pmu event creation failed -2                                 

Add earlycon to boot params and you should get more output. The kvm: pmu: failure is probably harmless (KVM support is not an essential thing).

Yes kvm is just the first log and nothing is shown. Ill try earlycon and see what is causing it to not boot.

I tried to add earlycon but still nothing showing, I am assuming it is getting stuck before it could post logs. 2 of the leds stops once kernel is loaded.

I am not sure what could be causing this. Is there any patch needed for m5 ? I will have to investigate further to see why it is not booting.

I am using the uboot from your link.

are you sure this is right? have you a working image to check if this is the right device for output?

Yes I tried LibreElec’s dev built and it does throw all the logs, yes console=ttyAML0 is right

you can check in running image which device in dts your console device is (register address). maybe there are serial devices in other order…same device is maybe ttyAML1 (i don’t know AML tty), for r2 i changed ttyS2 to ttyS0 in dtsi to be compatible with bpi images. and of course be sure you have serial driver builtin :slight_smile:

If libre elec compiled with ikconfig (modprobe config),you can export config (zcat /proc/config.gz) and use this to build your own config

1 Like

Good point. Thanks. I will try this but i’d assume LibreElec and Me (manjaro) kernel are both upstream kernels so should be any difference.

won’t hurt to look into it though. Thanks for the guidance.