Source code for the u-boot SPI build

@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:

1 Like

Very thanks !!! I waited :), nvme drivers are included in the kernel and STORAGE can now be located on nvme

/dev/mmcblk1p6          511.7M    158.4M    353.3M  31% /flash
/dev/nvme0n1p9            4.7G     16.0M      4.5G   0% /storage

As far as I can see, your launch is not completely with NVMe ?

my SSD not boot trough spi :frowning:
https://forum.radxa.com/t/fixing-u-boot-to-support-boot-from-nvmes/2076/9?u=rua1

Можете показать лог UART при использовании моего u-boot-spi с подключенным модулем NVMe ?

ок … у меня много символов на 1500000 теряется, могу тормознуть , перейти на 115200 , тогда все выводится

Очень странно, на этой скорости на RK вообще не должно ни чего в лог попадать …

good news :slight_smile:

https://forum.armbian.com/topic/12162-single-armbian-image-for-rk-aml-aw/?do=findComment&comment=96341

Если не вывелось В каком месте это должно быть и что там должно быть? я несколько раз подергаю может и вылезет

Summary
CPUId = 0x0
ChipType = 0x10, Spi_ChipId = b4016
SpiBootInit:0
mmc0:cmd5,32
SdmmcInit=0 0
BootCapSize=0
UserCapSize=15193MB
FwPartOffset=2000 , 0
StorageInit ok = 188403
SecureMode = 0
SecureInit reGPT  signature is wrong
LoadTruLoadTrust Addr:0x1c00
LoadTrust Addr:0x2000
No find bl30.bin
No find bl32.bin
Load uboot, ReadLba = 1000
hdr 00000000031912Load OK, addr=0x200000, size=0xb15d8
RunBL31 0x10000
NOTICE:  BL31: v1.3(debug):0e7a845
NOTICE:  BL31: Built : 16:13:46, Apr 17 2019
NOTICE:  BL31: Rockchip release version: v1.1
INFO:    GICv3 wiINFO:    Using opteed sec cpu_cotus 3e
INFO:    BL31: Initializing runtime services
WARNING: NSMC_UNK
ERROR:   Error initializing runtime service opteed_fast


U-Boot 2017.09 (Feb 06 2020 - 17:07:41 +0300)

Model: Rock3.9 GiB
Sysmem: init
Relocation Offset is: f7d0d000
I2c speed: 400000Hz
PMIC:  RK808 
vdd-center init 950000 uV
MMC:   dwmmc@fe320000: 1, sdhci@fe330000: 0
Using default environment

In:    serial@ff1a0000
Out:   serial@ff1a0000
Err:   serial@ff399 Evaluation Board
CLK: (uboot. arml: enter 816000 KHz, init z, init 24000 KHz, kernel 0N/A)
  aplll 816000 KHz
  apllb 24000 KHz
  dpll 800000 KHz
  cplpclk_perihp 33333 KHz
  aclk_perilp0 266666 KHz
  hclk_perilp0 88888 KHz
  pclk_perilp0 44444eth0: ethernet@fe300000
Hit key to stop autoboot('CTRL+C'):  0 
starting USB...
USB0:   USB EHCI 1.00
USB1:   USB OHCI 1.0
USB2:   USB EHCI 1.00
USB3:   USB OHCI 1.0
USB4:   Register 2000140 NbrPorts 2
Starting the controller
USB XHCI 1Register 2000140 NbrPorts 2
Starting the controller
USB XHCI 11 USB Device(s) found
scanning bus 1 for devices... 1 USB Device(s) found
scanning bus 2 for devices... 1 USB Device(s) found
scanning bus 3 for devices... 1 USB Device(s) found
scanning bus 4 for devices... 1 USB Device(s) found
scanning bus 5 for devices... 1 USB Device(s) found
       scanning usb for storage devices..switch to partitions #0, OK
mmc1 is current device
Scanning mmc 1:b...
Found /extlinux/extlinux.conf
Retrieving file: /extlinux/extlin797 bytes read in 9 ms (85.9 KiB/s)
select kernel
1:      kernel-4.4.154-104-rockchip-g3037f71a0de71:     kernel-4.4.154-104-rockchip-g3037f71a0de7
Retrieving file: /19494920 bytes read in 877 ms (21.2 MiB/s)
append: earlyprintk nk=0 rw init=/sbin/init rootfstype=ext4 rootwait root=/dev/nvme0n1p5
Retrieving file: /dtbs/4.494293 bytes read in 83 ms (1.1 MiB/s)
## Flattened Device Tree  blob at 0x8300000
   Loading Device Tree to 00000000ebeda000, end 00000000ebef4054Adding bank: 0x00200000 - 0xf8000000 (size: 0xf7e00000)
Total: 11960.576 ms

Starting kernel ...

Это не мой последний u-boot-spi :slight_smile:
Мой даёт такой вывод

U-Boot 2017.09-00010-g18c70dba63-dirty (Feb 25 2020 - 12:23:09 +0300)

Model: Radxa ROCK Pi 4
PreSerial: 2
DRAM: 2 GiB
Relocation Offset is: 7dbd5000
Sysmem: init
I2c speed: 400000Hz
PMIC: RK808
vdd_center 900000 uV
vdd_cpu_l 800000 uV
vdd-log init 950000 uV
MMC: dwmmc@fe320000: 1, sdhci@fe330000: 0
Using default environment

ага sd забыл вынуть … вынул … и оно увиделось :))))))

Summary
=> setenv baudrate 115200
## Switch baudrate to 115200 bps and press ENTER ...
=> nvme scan
=> nvme info  
Device 0: Vendor: 0x1987 Rev: ECFM12.2 Prod: LSL78256A95EF02545  
            Type: Hard Disk
            Capacity: 244198.3 MB = 238.4 GB (500118192 x 512)
=> nvme part

Partition Map for NVMe device 0  --   Partition Type: EFI

Part    Start LBA       End LBA         Name
        Attributes
        Type GUID
        Partition GUID
  1     0x00000040      0x00001f7f      "loader1"
        attrs:  0x0000000000000000
        type:   0fc63daf-8483-4772-8e79-3d69d8477de4
        guid:   4c98c92e-398a-4fb8-afd1-1529095b79b8
  2     0x00004000      0x00005fff      "loader2"
        attrs:  0x0000000000000000
        type:   0fc63daf-8483-4772-8e79-3d69d8477de4
        guid:   c8bdd4f5-12d8-42b8-8f69-147391c0438a
  3     0x00006000      0x00007fff      "trust"
        attrs:  0x0000000000000000
        t72699c7
        guid:   bbf86b96-61b3-446d-a789-bed7e5b85490
  5     0x00108000      0x03bc7fde      "mate"
        attrs:  0x0000000000000000
        type:   0fc63daf-8483-4772-8e79-3d69d8477de4
        guid:   ec15ec14-1781-45fe-9328-8012d52b4b54
  6     0x03bc8000      0x063c7fff      "xubuntu"
        attrs:  0x0000000000000000
        type:   0fc63daf-8483-4772-8e79-3d69d8477de4
        guid:   4640415b-956d-4627-84e9-f5e7cf630be0
  7     0x063c8000      0x08113fff      "none"
        attrs:  0x0000000000000000
        type:   0fc63daf-8483-4772-8e79-3d69d8477de4
        guid:   0328f464-d501-4d8d-8f61-f51822ae6fca
  8     0x08114000      0x14463fff      "data63daf-8483-4772-8e79-3d69d8477de4
        guid:   5d925b1c-5d31-4c15-a03f-d81bf324e09a
 10     0x14e28000      0x16b73fff      "slak"
        attrs:  0x0000000000000000
        type:   0fc63daf-8483-4772-8e79-3d69d8477de4
        guid:   ed75ee03-149a-4cf2-bf88-d1c37b79895e
 11     0x16b74000      0x188bffff      "armbian54"
        attrs:  0x0000000000000000
        type:   0fc63daf-8483-4772-8e79-3d69d8477de4
        guid:   5e6dfaa8-f304-4646-91f3-bdf5dcb7b99f
 12     0x188c0000      0x19cbffff      ""
        attrs:  0x0000000000000000
        type:   0fc63daf-8483-4772-8e79-3d69d8477de4
        guid:   ac160133-43ad-4726-8c5b-ae233e8d235c
 13     0x19cc0000      0x1a4bffff      ""
        attrs:  0

Partition Map for NVMe device 0  --   Partition Type: EFI

Part    Start LBA       End LBA         Name
        Attributes
        Type GUID
        Partition GUID
  1     0x00000040      0x00001f7f      "loader1"
        attrs:  0x0000000000000000
        type:   0fc63daf-8483-4772-8e79-3d69d8477de4
        guid:   4c98c92e-398a-4fb8-afd1-1529095b79b8
  2     0x00004000      0x00005fff      "loader2"
        attrs:  0x0000000000000000
        type:   0fc63daf-8483-4772-8e79-3d69d8477de4
        guid:   c8bdd4f5-12d8-42b8-8f69-147391c0438a
  3     0x00006000      0x00007fff      "trust"
        attrs:  0x0000000000000000
        type:   0fc63daf-8483-4772-8e79-3d69d8477de4
        guid:   8e58643e-760f-  0x03bc7fde      "mate"
        attrs:  0x0000000000000000
        type:   0fc63daf-8483-4772-8e79-3d69d8477de4
        guid:   ec15ec14-1781-45fe-9328-8012d52b4b54
  6     0x03bc8000      0x063c7fff      "xubuntu"
        attrs:  0x0000000000000000
        type:   0fc63daf-8483-4772-8e79-3d69d8477de4
        guid:   4640415b-956d-4627-84e9-f5e7cf630be0
  7     0x063c8000      0x08113fff      "none"
        attrs:  0x0000000000000000
        type:   0fc63daf-8483-4772-8e79-3d69d8477de4
        guid:   0328f464-d501-4d8d-8f61-f51822ae6fca
  8     0x08114000      0x14463fff      "data"
        attrs:  0x0000000000000000
        type:   0fc63daf-8483-4772-8e79-3d69d8477de4
        guid:   f4484f08-192f-4caa-97d1-70efafd1db95
  9     0x14464000      0x14e27fff      "libre"
        attrs:  af-8483-4772-8e79-3d69d8477de4
        guid:   ed75ee03-149a-4cf2-bf88-d1c37b79895e
 11     0x16b74000      0x188bffff      "armbian54"
        attrs:  0x0000000000000000
        type:   0fc63daf-8483-4772-8e79-3d69d8477de4
        guid:   5e6dfaa8-f304-4646-91f3-bdf5dcb7b99f
 12     0x188c0000      0x19cbffff      ""
        attrs:  0x0000000000000000
        type:   0fc63daf-8483-4772-8e79-3d69d8477de4
        guid:   ac160133-43ad-4726-8c5b-ae233e8d235c
 13     0x19cc0000      0x1a4bffff      ""
        attrs:  0x0000000000000000
        type:   0657fd6d-a4ab-43c4-84e5-0933c84b4f4f
        guid:   3e3dec41-e471-49f2-b655-98670394ee75
=>