Source code for the u-boot SPI build

Where can I get the source code for the u-boot SPI build (Rock Pi 4B) ? Is it freely available or is it private information ?

Is it it?

ROCK Pi 4 SPI+NVME boot u-boot source code:

3 Likes

Hi

@jack @Lili

Can Radxa check to incorporate u-boot/ u-boot SPI changes to boot from USB first?
Please check with balbes-150 since he mentioned it to help boot from USB then micro-sd card easily to try different Linux OS’s easily from USB.

Another post of his for booting Linux from USB.

Sure, let’s do that :slight_smile:

That would be great.
Please also test if Android firmware is run from a micro-sd card or emmc and if you also connect a USB drive with Linux or Android on that is boots first from this USB device from any of the 4 USB ports if possible.
Then I can also try to add it to my firmware.

I already added that u-boot change to my Android firmware u-boot but still couldn’t boot from any USB device with Linux/Android also inserted first. I haven’t changed anything for SPI u-boot and only used it as I received it.

It would be great since lots of people have USB flash drives around and not always a card reader, so it will be more convenient to try different OS’s easily :slight_smile:

Hi, @mo123

I am afraid we will have to test that after the Chinese New Year holidays. Everywhere is closing down here now. Happy Chinese New Year!

1 Like

Happy holiday…

Now radxa uboot does not load boot partitions with boot.scr and does not found files on usb

Log
U-Boot 2017.09-2686-g18c70dba63 (Dec 31 2019 - 12:34:04 +000sting-2-136
...
mmc1 is current device
Scanning mmc 1:7...        <###############SLAX###############
Found U-Boot script /boot.scr
reading /boot.scr
1393 bytes read in 3 ms (453.1 KiB/s)
## Executing script at 00500000
Unknown command 'itest.b' - try 'help'
Unknown command 'itest.b' - try 'help'
libfdt fdt_check_header(): FDT_ERR_BADMAGIC
No FDT memory address configured. Please configure
the FDT address via "fdt addr <address>" command.
Aborng!
Bad Linux ARM64 Image magic!
SCRIPT FAILED: continuing...
Scanning mmc 1:b...   <#########ARMBIAN############
Found U-Boot script /boot.scr
reading /boot.scr
2940 bytes read in 3 ms (957 KiB/s)
## Executing script at 00500000
Boot script loaded from mmc 1
libfdt fdt_check_header(): FDT_ERR_BADMAGIC
No FDT memory address configured. Please configure
the FDT address via "fdt addr <address>" command.
Aborting!
Bad Linux ARM64 Image magic!
SCRIPT FAILED: continuing...
switch to partitions #0, OK

mmc0(part 0) is current device
Failed to mount ext2 filesystem...
** Unrecognized filesystem type **

starting USB...
USB0:   USB EHCI 1.00
USB1:   USB OHCI 1.0
USB2:   failed to get usb phy
Port not available.
USB3:   failed to get usb phy
Port not available.
USB4:   Can't get the usbphy register address
probe failed, error -6
USB5:   Can't get the usbphy registobe failed, error -6
scanning bus 0 for devices... 1 USB Device(s) found
scanning bus 1 for devices... 1 USB Device(s) found
       scanning usb for storage devices..
Device 0: unknown device
ethernet@fe300000 Waiting for PHY auto negotiation to complete. done <#############BOOTFROMNET################

About multiboot:
Now I use mutiboot with changing boot flag on mmcblk0 partitions. The rootfs partitions are located on nvme . This works on boot patitions with extlinux.conf

Partitions
parted /dev/mmcblk0 p
Number  Start   End     Size    File system  Name      Flags
 1      32,8kB  4129kB  4096kB
 2      8389kB  12,6MB  4194kB
 3      12,6MB  16,8MB  4194kB
 4      16,8MB  134MB   117MB   fat16        none      msftdata
 5      134MB   252MB   117MB   fat16        xubuntu   msftdata
 6      252MB   789MB   537MB   fat16        libre     msftdata
 7      789MB   1325MB  537MB   fat16        slax      boot, esp
 8      1325MB  1862MB  537MB   fat16        ARMB54    msftdata
 9      1862MB  2399MB  537MB   fat16                  msftdata
10      2399MB  13,1GB  10,7GB  ext4         ubuntu
11      13,1GB  13,4GB  268MB   fat16        bootmint  boot, esp
12      13,4GB  13,5GB  117MB   fat16        BootMain  boot, esp
13      13,5GB  15,9GB  2409MB  fat32        BAKU      msftdata

To change boot partition, I use ‘parted toogle N boot’ where N is partition number where the flag changes.
I would really like if there are no boot flags on mmcblk0, then the android booted with mmcblk1.
To raxda: Is it possible to make such uboot?

I sent the patch to GIT, you can build file the uboot-trust-spi.img for SPI with this patch ?
I would like to check it through the installation from the script
/usr/local/sbin/rockpi4b_upgrade_bootloader.sh

1 Like

@jack Question. I built a new u-boot from the SPI branch (with a patch). It works well when used on an SD card. But I have doubts that the assembled version will work from SPI (it may require a special build\keys\paramters for SPI). If I write it in SPI, is there a way to later replace this u-boot in SPI (if it is incorrect and does not work) ? I. e. if i’m write a wrong u-boot to SPI, are there any steps (techniques) that will allow i’m to start the system from the SD card and replace\erase the wrong u-boot in SPI ?

You can use the SPI recovery trick in the FAQs here: https://wiki.radxa.com/Rockpi4/dev/spi-install

1 Like

I put together a version of u-boot for SPI enables start with the USB. Installation in SPI passed without problems, but I see a USB processing error when working. It is possible that the current DTB (which is used in the build) or the sources have an error when working with USB.

starting USB…
USB0: USB EHCI 1.00
USB1: USB OHCI 1.0
USB2: failed to get usb phy
Port not available.
USB3: failed to get usb phy
Port not available.
USB4: Can’t get the usbphy register address
probe failed, error -6
USB5: Can’t get the usbphy register address
probe failed, error -6
scanning bus 0 for devices… 1 USB Device(s) found
scanning bus 1 for devices… 1 USB Device(s) found
scanning usb for storage devices… 0 Storage Device(s) found

Device 0: unknown device
switch to partitions #0, OK
mmc1 is current device
Scanning mmc 1:1…
Found U-Boot script /boot.scr
reading /boot.scr

When using u-boot-2020, USB works fine. Is it possible to update the source code for building the SPI version to version 2020 ?

Hit any key to stop autoboot: 0
starting USB…
Bus usb@fe380000: USB EHCI 1.00
Bus usb@fe3c0000: USB EHCI 1.00
Bus dwc3: Register 2000140 NbrPorts 2
Starting the controller
USB XHCI 1.10
Bus dwc3: Register 2000140 NbrPorts 2
Starting the controller
USB XHCI 1.10
scanning bus usb@fe380000 for devices… 1 USB Device(s) found
scanning bus usb@fe3c0000 for devices… 1 USB Device(s) found
scanning bus dwc3 for devices… 1 USB Device(s) found
scanning bus dwc3 for devices… 1 USB Device(s) found
scanning usb for storage devices… 0 Storage Device(s) found

Device 0: unknown device
switch to partitions #0, OK
mmc1 is current device
Scanning mmc 1:1…

1 Like

Found the reason, the patch will be ready next week

2 Likes

Test version of u-boot for installation in SPI with support for starting from USB. I checked it on my model. u-boot sees all devices (USB SD eMMC NVMe) and polls them sequentially for startup. The only problem is that I can’t check for a full run with NVMe yet, u-boot sees NVMe and can read small files from It, but when I try to read the kernel, I get a read error indicating the cluster. I think this is the problem of my NVMe (for the test, I connected the simplest NVMe module). But there may not be enough additional settings in the DTB (I don’t have time to check with another module yet). Start with the rest of the media works without problems.

2 Likes

Took a simple NVME (Orico), recorded an image of Armbian and it … normally starts with NVMe. I tried to write the same image on a Samsung EVO970, the system does not start … I don’t understand why one model works and the other doesn’t. And the most amazing thing is that it is run using a script that is designed to work with SD \ USB. Here is the output from the working run.

Device 0: RKPARM: Invalid parameter part table
Vendor: 0x126f Rev: S0614B0G Prod: AA000000000000000090
Type: Hard Disk
Capacity: 122104.3 MB = 119.2 GB (250069680 x 512)
… is now current device
Scanning nvme 0:1…
Found U-Boot script /boot.scr
reading /boot.scr
912 bytes read in 0 ms

Executing script at 00500000

start mainline u-boot
reading uEnv.txt
1296 bytes read in 1 ms (1.2 MiB/s)

Error: “mac” not defined

Error: “eth_mac” not defined

reading /zImage
27517440 bytes read in 65 ms (403.7 MiB/s)
reading /uInitrd
11050287 bytes read in 27 ms (390.3 MiB/s)
reading /dtb/rockchip/rk3399-rock-pi-4.dtb
54559 bytes read in 3 ms (17.3 MiB/s)

Loading init Ramdisk from Legacy Image at 0a200000 …

Image Name: uInitrd
Image Type: AArch64 Linux RAMDisk Image (gzip compressed)
Data Size: 11050223 Bytes = 10.5 MiB
Load Address: 00000000
Entry Point: 00000000
Verifying Checksum … OK

Flattened Device Tree blob at 08300000

Booting using the fdt blob at 0x8300000
Loading Ramdisk to 71330000, end 71db9cef … OK
Loading Device Tree to 000000007131f000, end 000000007132f51e … OK
Adding bank: 0x00200000 - 0x80000000 (size: 0x7fe00000)
Total: 13738.336 ms

Starting kernel …

[ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd034]
[ 0.000000] Linux version 5.5.1-rk3399-tv (root@vbox) (gcc version 8.3.0 (GNU Toolchain for the A-profile Architecture 8.3-2019.03 (arm-rel-8.36))) #trunk SMP PREEMPT Mon Feb 24 20:23:07 MSK 2020
[ 0.000000] Machine model: Radxa ROCK Pi 4
[ 0.000000] earlycon: uart8250 at MMIO32 0x00000000ff1a0000 (options ‘’)
[ 0.000000] printk: bootconsole [uart8250] enabled
[ 0.000000] efi: Getting EFI parameters from FDT:
[ 0.000000] efi: UEFI not found.
[ 0.000000] cma: Reserved 384 MiB at 0x0000000059000000
[ 0.000000] psci: probing for conduit method from DT.
[ 0.000000] psci: PSCIv1.0 detected in firmware.
[ 0.000000] psci: Using standard PSCI v0.2 function IDs
[ 0.000000] psci: MIGRATE_INFO_TYPE not supported.
[ 0.000000] psci: SMC Calling Convention v1.0
[ 0.000000] percpu: Embedded 22 pages/cpu s50840 r8192 d31080 u90112
[ 0.000000] Detected VIPT I-cache on CPU0
[ 0.000000] CPU features: detected: ARM erratum 845719
[ 0.000000] CPU features: detected: GIC system register CPU interface
[ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 515592
[ 0.000000] Kernel command line: root=LABEL=ROOTFS rootflags=data=writeback rw console=uart8250,mmio32,0xff1a0000 console=tty0 no_console_suspend consoleblank=0 fsck.fix=yes fsck.repair=yes net.ifnames=0
[ 0.000000] Dentry cache hash table entries: 262144 (order: 9, 2097152 bytes, linear)
[ 0.000000] Inode-cache hash table entries: 131072 (order: 8, 1048576 bytes, linear)
[ 0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[ 0.000000] software IO TLB: mapped [mem 0x3bfff000-0x3ffff000] (64MB)
[ 0.000000] Memory: 1556504K/2095104K available (15356K kernel code, 1464K rwdata, 6404K rodata, 3584K init, 932K bss, 145384K reserved, 393216K cma-reserved)
[ 0.000000] random: get_random_u64 called from cache_random_seq_create+0x7c/0x150 with crng_init=0

This is a conclusion from Sansung

Device 0: RKPARM: Invalid parameter part table
Vendor: 0x144d Rev: 2B2QEXE7 Prod: S465NB0KA03274D
Type: Hard Disk
Capacity: 238475.1 MB = 232.8 GB (488397168 x 512)
… is now current device
Scanning nvme 0:1…
Found U-Boot script /boot.scr
reading /boot.scr
912 bytes read in 1 ms (890.6 KiB/s)

Executing script at 00500000

start mainline u-boot
reading uEnv.txt
1296 bytes read in 2 ms (632.8 KiB/s)

Error: “mac” not defined

Error: “eth_mac” not defined

reading /zImage
ERROR: status = 2013, phase = 1, head = 0
Error reading cluster
** Unable to read file /zImage **
reading uEnv.txt
1296 bytes read in 2 ms (632.8 KiB/s)

Error: “mac” not defined

Error: “eth_mac” not defined

reading /zImage
ERROR: status = 2013, phase = 1, head = 0
Error reading cluster
** Unable to read file /zImage **
reading uEnv.txt
1296 bytes read in 1 ms (1.2 MiB/s)

Error: “mac” not defined

Error: “eth_mac” not defined

reading /zImage
ERROR: status = 2013, phase = 1, head = 0
Error reading cluster
** Unable to read file /zImage **
reading uEnv.txt
1296 bytes read in 1 ms (1.2 MiB/s)

Error: “mac” not defined

Error: “eth_mac” not defined

reading /zImage
ERROR: status = 2013, phase = 1, head = 0
Error reading cluster
** Unable to read file /zImage **
reading uEnv.txt
1296 bytes read in 1 ms (1.2 MiB/s)

Error: “mac” not defined

Error: “eth_mac” not defined

reading /zImage
ERROR: status = 2013, phase = 1, head = 0
Error reading cluster
** Unable to read file /zImage **
reading uEnv.txt
1296 bytes read in 1 ms (1.2 MiB/s)

Libreelec startup log. (the behavior is similar, one module works , the second gives an error reading data from it). Perhaps the cable that connects the expansion card is to blame. It would be interesting to check the direct connection of the module without the expansion card (I can’t check it, to disable it, will have to disassemble the radiator and the entire structure, which I have already Packed tightly). I would appreciate it if anyone has the opportunity to test the NVMe when directly connected to the connector (without the connection Board and its cable). I have already encountered on RK3399 that SD cards do not work very well, if you use an extension cable, perhaps the same situation here.

Device 0: RKPARM: Invalid parameter part table
Vendor: 0x126f Rev: S0614B0G Prod: AA000000000000000090
Type: Hard Disk
Capacity: 122104.3 MB = 119.2 GB (250069680 x 512)
… is now current device
Scanning nvme 0:1…
Found U-Boot script /boot.scr
reading /boot.scr
818 bytes read in 1 ms (798.8 KiB/s)

Executing script at 00500000

start mainline u-boot
reading uEnv.txt
137 bytes read in 1 ms (133.8 KiB/s)

Error: “mac” not defined

Error: “eth_mac” not defined

reading /KERNEL
30476296 bytes read in 63 ms (461.3 MiB/s)
reading /dtb/rockchip/img
54431 bytes read in 4 ms (13 MiB/s)

Flattened Device Tree blob at 08300000

Booting using the fdt blob at 0x8300000
Loading Device Tree to 0000000071daa000, end 0000000071dba49e … OK
Adding bank: 0x00200000 - 0x80000000 (size: 0x7fe00000)
Total: 8124.816 ms

Starting kernel …

Checked the latest version of Libreelec (20200228-aarch64) with NVMe with the new u-boot in SPI. I wrote the image to the NVMe module and configured the dtb. Everything works, the system automatically starts completely with NVMe. I liked the speed of work (installing add-ons takes a few seconds). When connect a USB media with Armbian, Armbian starts automatically, do not need to switch or change anything in the main system settings on NVMe.
But the main mode I will have is Armbian on NVMe, and the LE system will start from USB. :slight_smile: