cdsteinkuehler / br2rauc

Buildroot + RAUC
Other
51 stars 18 forks source link

Setting up br2rauc for USB/NVMe boot #12

Closed minecraft2048 closed 1 year ago

minecraft2048 commented 2 years ago

I'm currently developing a CM4 carrier board that will boot from PCIe NVMe SSD instead of eMMC/SD card. For now I use a NVMe USB reader, which works with the official image. When I try to use br2rauc to make image, and flash it to the SSD, it got stuck in a boot loop, complaining about Bad Linux ARM64 Image magic!:

RPi: BOOTLOADER release VERSION:507b2360 DATE: 2022/04/26 TIME: 11:24:28 BOOTMODE: 0x00000006 part: 0 BUILD_TIMESTAMP=1650968668 0xa9dfd335 0x00b03140 0x00069bf1
PM_RSTS: 0x00000020
part 00000000 reset_info 00000000
uSD voltage 3.3V
Initialising SDRAM 'Samsung' 16Gb x1 total-size: 16 Gbit 3200
DDR 3200 0 0 16 152

Boot mode: SD (01) order f2564
SD HOST: 250000000 CTL0: 0x00000000 BUS: 200000 Hz actual: 200000 HZ div: 1250 (625) status: 0x1fff0000 delay: 540
SD HOST: 250000000 CTL0: 0x00000f00 BUS: 200000 Hz actual: 200000 HZ div: 1250 (625) status: 0x1fff0000 delay: 540
EMMC
SD retry 1 oc 0
SD HOST: 250000000 CTL0: 0x00000000 BUS: 200000 Hz actual: 200000 HZ div: 1250 (625) status: 0x1fff0000 delay: 540
OCR c0ff8080 [0]
CID: 00150100424a5444345203712cba8d68
SD HOST: 250000000 CTL0: 0x00000f04 BUS: 25000000 Hz actual: 25000000 HZ div: 10 (5) status: 0x1fff0000 delay: 4
SD HOST: 250000000 CTL0: 0x00000f04 BUS: 50000000 Hz actual: 41666666 HZ div: 6 (3) status: 0x1fff0000 delay: 2
MBR: 0x00000000,       0 type: 0x00
MBR: 0x00000000,       0 type: 0x00
MBR: 0x00000000,       0 type: 0x00
MBR: 0x00000000,       0 type: 0x00
Trying partition: 0
Trying partition: 0
Retry SD 1
SD HOST: 250000000 CTL0: 0x00000000 BUS: 200000 Hz actual: 200000 HZ div: 1250 (625) status: 0x1fff0000 delay: 540
SD HOST: 250000000 CTL0: 0x00000f00 BUS: 200000 Hz actual: 200000 HZ div: 1250 (625) status: 0x1fff0000 delay: 540
EMMC
SD retry 1 oc 0
SD HOST: 250000000 CTL0: 0x00000000 BUS: 200000 Hz actual: 200000 HZ div: 1250 (625) status: 0x1fff0000 delay: 540
OCR c0ff8080 [0]
CID: 00150100424a5444345203712cba8d68
SD HOST: 250000000 CTL0: 0x00000f04 BUS: 25000000 Hz actual: 25000000 HZ div: 10 (5) status: 0x1fff0000 delay: 4
SD HOST: 250000000 CTL0: 0x00000f04 BUS: 50000000 Hz actual: 41666666 HZ div: 6 (3) status: 0x1fff0000 delay: 2
MBR: 0x00000000,       0 type: 0x00
MBR: 0x00000000,       0 type: 0x00
MBR: 0x00000000,       0 type: 0x00
MBR: 0x00000000,       0 type: 0x00
Trying partition: 0
Trying partition: 0
Boot mode: USB-MSD (04) order f256
PCIe timeout: 0x0000008f
USB xHC init failed
Boot mode: NVME (06) order f25
PCIe timeout: 0x0000008f
Failed to open device: 'nvme'
Retry NVME 1
PCIe timeout: 0x0000008f
Failed to open device: 'nvme'
Boot mode: BCM-USB-MSD (05) order f2
XHCI-STOP
xHC ver: 272 HCS: 01000140 0c0000f1 07ff000a HCC: 0220fe65
xHC ports 1 slots 64 intrs 1
USB2[1] 000206e1 connected
USB2[1] 00200e03 connected enabled
USB2 root HUB port 1 init
DEV [01:00] 2.00 000000:01 class 9 VID 1a40 PID 0101
HUB init [01:00] 2.00 000000:01
HUB [01:00] 2.00 000000:01 init port 3 speed 3
DEV [02:01] 2.16 000003:01 class 0 VID 0bda PID 9210
MSD device [02:01] 2.16 000003:01 conf 0 iface 0 ep 81#512 02#512
MSD [02:01] 2.16 000003:01 register MSD
MSD [02:01] 2.16 000003:01 LUN 0
MSD INQUIRY [02:01] 2.16 000003:01
MSD [02:01] 2.16 000003:01 lun 0 block-count 976773168 block-size 512
MBR: 0x00002000,  524288 type: 0x0c
MBR: 0x00102000,  524288 type: 0x83
MBR: 0x00182000,  262144 type: 0x83
MBR: 0x001c2000, 5529603 type: 0x0f
Trying partition: 0
type: 16 lba: 8192 oem: 'mkfs.fat' volume: '  V       ^ '
rsc 8 fat-sectors 256 c-count 65467 c-size 8
root dir cluster 1 sectors 32 entries 512
FAT16 clusters 65467
Trying partition: 0
type: 16 lba: 8192 oem: 'mkfs.fat' volume: '  V       ^ '
rsc 8 fat-sectors 256 c-count 65467 c-size 8
root dir cluster 1 sectors 32 entries 512
FAT16 clusters 65467
Read config.txt bytes     2820 hnd 0x10
gpio_cmd: '4=ip,pu' pins: 4-4 drive: -1 fsel: 0 term: 2
Read start4.elf bytes  2240608 hnd 0x13
Read fixup4.dat bytes     5354 hnd 0x11
Firmware: bd34f55ef7b01b0a367f131060b561a2a58b80bb Jan 17 2022 19:20:34
0x00b03140 0x00000000 0x00000fff
MEM GPU: 76 ARM: 947 TOTAL: 1023
Starting start4.elf @ 0xfeb00200 partition 0
+

MESS:00:00:06.055023:0: brfs: File read: /mfs/sd/config.txt
MESS:00:00:06.058728:0: brfs: File read: 2820 bytes
MESS:00:00:06.111577:0: HDMI0:EDID error reading EDID block 0 attempt 0
MESS:00:00:06.121089:0: HDMI0:EDID error reading EDID block 0 attempt 1
MESS:00:00:06.130603:0: HDMI0:EDID error reading EDID block 0 attempt 2
MESS:00:00:06.140110:0: HDMI0:EDID error reading EDID block 0 attempt 3
MESS:00:00:06.149624:0: HDMI0:EDID error reading EDID block 0 attempt 4
MESS:00:00:06.159133:0: HDMI0:EDID error reading EDID block 0 attempt 5
MESS:00:00:06.168647:0: HDMI0:EDID error reading EDID block 0 attempt 6
MESS:00:00:06.178154:0: HDMI0:EDID error reading EDID block 0 attempt 7
MESS:00:00:06.187668:0: HDMI0:EDID error reading EDID block 0 attempt 8
MESS:00:00:06.197178:0: HDMI0:EDID error reading EDID block 0 attempt 9
MESS:00:00:06.201683:0: HDMI0:EDID giving up on reading EDID block 0
MESS:00:00:06.227155:0: HDMI1:EDID error reading EDID block 0 attempt 0
MESS:00:00:06.236663:0: HDMI1:EDID error reading EDID block 0 attempt 1
MESS:00:00:06.246177:0: HDMI1:EDID error reading EDID block 0 attempt 2
MESS:00:00:06.255687:0: HDMI1:EDID error reading EDID block 0 attempt 3
MESS:00:00:06.265201:0: HDMI1:EDID error reading EDID block 0 attempt 4
MESS:00:00:06.274713:0: HDMI1:EDID error reading EDID block 0 attempt 5
MESS:00:00:06.284227:0: HDMI1:EDID error reading EDID block 0 attempt 6
MESS:00:00:06.293737:0: HDMI1:EDID error reading EDID block 0 attempt 7
MESS:00:00:06.303251:0: HDMI1:EDID error reading EDID block 0 attempt 8
MESS:00:00:06.312758:0: HDMI1:EDID error reading EDID block 0 attempt 9
MESS:00:00:06.317263:0: HDMI1:EDID giving up on reading EDID block 0
MESS:00:00:06.323052:0: brfs: File read: /mfs/sd/config.txt
MESS:00:00:06.328841:0: gpioman: gpioman_get_pin_num: pin DISPLAY_SDA not defined
MESS:00:00:06.334843:0: gpioman: gpioman_get_pin_num: pin LEDS_PWR_OK not defined
MESS:00:00:06.362879:0: gpioman: gpioman_get_pin_num: pin FLASH_0_ENABLE not defined
MESS:00:00:06.367516:0: gpioman: gpioman_get_pin_num: pin FLASH_0_INDICATOR not defined
MESS:00:00:06.375258:0: gpioman: gpioman_get_pin_num: pin FLASH_0_ENABLE not defined
MESS:00:00:06.382708:0: gpioman: gpioman_get_pin_num: pin FLASH_0_INDICATOR not defined
MESS:00:00:06.844869:0: gpioman: gpioman_get_pin_num: pin LEDS_PWR_OK not defined
MESS:00:00:06.850516:0: *** Restart logging
MESS:00:00:06.853159:0: brfs: File read: 2820 bytes
MESS:00:00:06.862880:0: hdmi: HDMI0:EDID error reading EDID block 0 attempt 0
MESS:00:00:06.872911:0: hdmi: HDMI0:EDID error reading EDID block 0 attempt 1
MESS:00:00:06.882949:0: hdmi: HDMI0:EDID error reading EDID block 0 attempt 2
MESS:00:00:06.892981:0: hdmi: HDMI0:EDID error reading EDID block 0 attempt 3
MESS:00:00:06.903018:0: hdmi: HDMI0:EDID error reading EDID block 0 attempt 4
MESS:00:00:06.913049:0: hdmi: HDMI0:EDID error reading EDID block 0 attempt 5
MESS:00:00:06.923087:0: hdmi: HDMI0:EDID error reading EDID block 0 attempt 6
MESS:00:00:06.933119:0: hdmi: HDMI0:EDID error reading EDID block 0 attempt 7
MESS:00:00:06.943157:0: hdmi: HDMI0:EDID error reading EDID block 0 attempt 8
MESS:00:00:06.953187:0: hdmi: HDMI0:EDID error reading EDID block 0 attempt 9
MESS:00:00:06.958216:0: hdmi: HDMI0:EDID giving up on reading EDID block 0
MESS:00:00:06.968840:0: hdmi: HDMI0:EDID error reading EDID block 0 attempt 0
MESS:00:00:06.978871:0: hdmi: HDMI0:EDID error reading EDID block 0 attempt 1
MESS:00:00:06.988909:0: hdmi: HDMI0:EDID error reading EDID block 0 attempt 2
MESS:00:00:06.998942:0: hdmi: HDMI0:EDID error reading EDID block 0 attempt 3
MESS:00:00:07.008980:0: hdmi: HDMI0:EDID error reading EDID block 0 attempt 4
MESS:00:00:07.019010:0: hdmi: HDMI0:EDID error reading EDID block 0 attempt 5
MESS:00:00:07.029048:0: hdmi: HDMI0:EDID error reading EDID block 0 attempt 6
MESS:00:00:07.039081:0: hdmi: HDMI0:EDID error reading EDID block 0 attempt 7
MESS:00:00:07.049119:0: hdmi: HDMI0:EDID error reading EDID block 0 attempt 8
MESS:00:00:07.059148:0: hdmi: HDMI0:EDID error reading EDID block 0 attempt 9
MESS:00:00:07.064177:0: hdmi: HDMI0:EDID giving up on reading EDID block 0
MESS:00:00:07.069776:0: hdmi: HDMI:hdmi_get_state is deprecated, use hdmi_get_display_state instead
MESS:00:00:07.083567:0: hdmi: HDMI1:EDID error reading EDID block 0 attempt 0
MESS:00:00:07.093606:0: hdmi: HDMI1:EDID error reading EDID block 0 attempt 1
MESS:00:00:07.103635:0: hdmi: HDMI1:EDID error reading EDID block 0 attempt 2
MESS:00:00:07.113672:0: hdmi: HDMI1:EDID error reading EDID block 0 attempt 3
MESS:00:00:07.123704:0: hdmi: HDMI1:EDID error reading EDID block 0 attempt 4
MESS:00:00:07.133742:0: hdmi: HDMI1:EDID error reading EDID block 0 attempt 5
MESS:00:00:07.143773:0: hdmi: HDMI1:EDID error reading EDID block 0 attempt 6
MESS:00:00:07.153810:0: hdmi: HDMI1:EDID error reading EDID block 0 attempt 7
MESS:00:00:07.163844:0: hdmi: HDMI1:EDID error reading EDID block 0 attempt 8
MESS:00:00:07.173882:0: hdmi: HDMI1:EDID error reading EDID block 0 attempt 9
MESS:00:00:07.178902:0: hdmi: HDMI1:EDID giving up on reading EDID block 0
MESS:00:00:07.189524:0: hdmi: HDMI1:EDID error reading EDID block 0 attempt 0
MESS:00:00:07.199562:0: hdmi: HDMI1:EDID error reading EDID block 0 attempt 1
MESS:00:00:07.209592:0: hdmi: HDMI1:EDID error reading EDID block 0 attempt 2
MESS:00:00:07.219630:0: hdmi: HDMI1:EDID error reading EDID block 0 attempt 3
MESS:00:00:07.229663:0: hdmi: HDMI1:EDID error reading EDID block 0 attempt 4
MESS:00:00:07.239701:0: hdmi: HDMI1:EDID error reading EDID block 0 attempt 5
MESS:00:00:07.249731:0: hdmi: HDMI1:EDID error reading EDID block 0 attempt 6
MESS:00:00:07.259768:0: hdmi: HDMI1:EDID error reading EDID block 0 attempt 7
MESS:00:00:07.269801:0: hdmi: HDMI1:EDID error reading EDID block 0 attempt 8
MESS:00:00:07.279839:0: hdmi: HDMI1:EDID error reading EDID block 0 attempt 9
MESS:00:00:07.284860:0: hdmi: HDMI1:EDID giving up on reading EDID block 0
MESS:00:00:07.290458:0: hdmi: HDMI:hdmi_get_state is deprecated, use hdmi_get_display_state instead
MESS:00:00:07.299223:0: HDMI0: hdmi_pixel_encoding: 300000000
MESS:00:00:07.304690:0: HDMI1: hdmi_pixel_encoding: 300000000
MESS:00:00:07.310640:0: gpioman: gpioman_get_pin_num: pin CAMERA_0_I2C_PORT not defined
MESS:00:00:07.322152:0: dtb_file 'bcm2711-rpi-cm4.dtb'
MESS:00:00:07.342714:0: brfs: File read: /mfs/sd/bcm2711-rpi-cm4.dtb
MESS:00:00:07.345961:0: Loading 'bcm2711-rpi-cm4.dtb' to 0x100 size 0xcc10
MESS:00:00:07.365630:0: brfs: File read: 52240 bytes
MESS:00:00:07.374917:0: brfs: File read: /mfs/sd/overlays/overlay_map.dtb
MESS:00:00:07.451469:0: brfs: File read: 1703 bytes
MESS:00:00:07.453926:0: brfs: File read: /mfs/sd/config.txt
MESS:00:00:07.459008:0: dtparam: audio=on
MESS:00:00:07.472870:0: brfs: File read: 2820 bytes
MESS:00:00:07.481671:0: brfs: File read: /mfs/sd/overlays/vc4-kms-v3d-pi4.dtbo
MESS:00:00:07.550871:0: Loaded overlay 'vc4-kms-v3d'
MESS:00:00:07.713342:0: brfs: File read: 3823 bytes
MESS:00:00:07.719547:0: brfs: File read: /mfs/sd/overlays/miniuart-bt.dtbo
MESS:00:00:07.743997:0: Loaded overlay 'miniuart-bt'
MESS:00:00:07.745942:0: dtparam: watchdog=true
MESS:00:00:07.828510:0: brfs: File read: 1819 bytes
MESS:00:00:07.830663:0: brfs: File read: /mfs/sd/cmdline.txt
MESS:00:00:07.835674:0: Read command line from file 'cmdline.txt':
MESS:00:00:07.841559:0: 'root=/dev/mmcblk0p2 rootwait console=tty1 console=ttyAMA0,115200 fw_dtb'
MESS:00:00:07.947131:0: brfs: File read: 72 bytes
MESS:00:00:07.982175:0: brfs: File read: /mfs/sd/u-boot.bin
MESS:00:00:07.984641:0: Loading 'u-boot.bin' to 0x80000 size 0x8f4c0
MESS:00:00:07.990730:0: Device tree loaded to 0x2eff2e00 (size 0xd17b)
MESS:00:00:07.998758:0: uart: Set PL011 baud rate to 103448.300000 Hz
MESS:00:00:08.006035:0: uart: Baud rate change done...
MESS:00:00:08.008057:0: uart: Baud rate change done...
MESS:00:00:08.014669:0: bfs_xhci_stop
MESS:00:00:08.016304:0: XHCI-STOP
MESS:00:00:08.019357:0: xHC ver: 272 HCS: 01000140 0c0000f1 07ff000a HCC: 0220fe65
MESS:00:00:08.026638:0: USBSTS 18

U-Boot 2022.01 (May 31 2022 - 09:50:01 +1000)

DRAM:  1.9 GiB
RPI Compute Module 4 (0xb03140)
MMC:   mmcnr@7e300000: 1, mmc@7e340000: 0
Loading Environment from MMC... OK
In:    serial
Out:   serial
Err:   serial
Net:   eth0: ethernet@7d580000
PCIe BRCM: link down
starting USB...
Bus xhci@7e9c0000: Register 1000140 NbrPorts 1
Starting the controller
USB XHCI 1.10
scanning bus xhci@7e9c0000 for devices... 3 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
Hit any key to stop autoboot:  0 
switch to partitions #0, OK
mmc0(part 0) is current device
** No partition table - mmc 0 **
Couldn't find partition mmc 0:1
Card did not respond to voltage select! : -110
MMC Device 2 not found
no mmc device at slot 2

Device 0: Vendor: Realtek  Rev: 1.00 Prod: RTL9210B-CG     
            Type: Hard Disk
            Capacity: 476940.0 MB = 465.7 GB (976773168 x 512)
... is now current device
Scanning usb 0:1...
Found U-Boot script /boot.scr
3993 bytes read in 1 ms (3.8 MiB/s)
## Executing script at 02400000
gpio: pin gpio4 (gpio 4) value is 1
Found valid slot B, 1 attempts remaining
Using firmware device-tree
Saving Environment to MMC... Writing to MMC(0)... OK
Loading kernel
** No partition table - mmc 0 **
Couldn't find partition mmc 0:6
Can't set block device
Starting kernel
Bad Linux ARM64 Image magic!
SCRIPT FAILED: continuing...
libfdt fdt_check_header(): FDT_ERR_BADMAGIC
Card did not respond to voltage select! : -110
Scanning disk mmcnr@7e300000.blk...
Disk mmcnr@7e300000.blk not ready
Scanning disk mmc@7e340000.blk...
Scanning disk usb_mass_storage.lun0...
Found 9 disks
No EFI system partition
BootOrder not defined
EFI boot manager: Cannot load any image
PCIe BRCM: link down
ethernet@7d580000 Waiting for PHY auto negotiation to complete.......
cdsteinkuehler commented 2 years ago

You are going to have to edit the U-Boot script and adjust it for your boot device (the default device is mmc, see the load_uenv, load_fdt, and load_kernel variables). To use PCIe you may also have to edit the U-Boot configuration and enable hardware support. The current U-Boot configuration should support USB mass-storage devices.

cdsteinkuehler commented 1 year ago

Given the number of changes required and the lack of support for RPi alternate boot methods in Buildroot, I currently have no plans to support anything other than the standard mmc / uSD boot. Feel free to send a pull request if you do get this working.