Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CM3 does not boot #10

Open
Tidone opened this issue Sep 14, 2022 · 21 comments
Open

CM3 does not boot #10

Tidone opened this issue Sep 14, 2022 · 21 comments

Comments

@Tidone
Copy link

Tidone commented Sep 14, 2022

I'm using a Radxa CM3 module on a Raspberry Pi CM4 IO Board.
I built the image as described, and flashed it onto the internal eMMC.
The board starts U-Boot SPL, but then hangs after verifying the checksums:

[Skip DDR Initialization Block]

U-Boot SPL board init
U-Boot SPL 2017.09 (Sep 13 2022 - 17:35:53)
unknown raw ID phN
unrecognized JEDEC id bytes: 00, 00, 00
TryMMC error: The cmd index is 1, ret is -110
Card did not respond to voltage select!
mmc_init: -95, time 10
spl: mmc init faileerror: -95
Trying to boot from MMC1
## Verified-boot: 0
## Checking uboot 0x00a00000 ... sha256(87fbe2d509...) + OK
## Checking fdt 0x00b2e3e8 ... sha256(2154df9e4a...) + OK
## Checking optee 0x08400000 ... sha256(b8cddafab0...) + OK

I also tried to write the image onto an sdcard, but that didn't work as well (maybe a different dtbo is needed). Even if it worked on an external sdcard, I would like it to boot from the internal eMMC.

@flatmax
Copy link
Owner

flatmax commented Sep 14, 2022

I haven't tested using the Raspberry Pi's CM4 IO board, however, you could try this ...

For UBoot ...
Have you tried to find the correct config file ? radxa-cm3-rpi-cm4-io-rk3566_defconfig at this point in the buildroot config file.
This should also select the correct devicetree for uboot.

For Linux ...
The device tree you should be using is "rk3566-radxa-cm3-rpi-cm4-io.dts". For that reason, try to change the config file's device tree like so :

BR2_LINUX_KERNEL_INTREE_DTS_NAME="rockchip/rk3566-radxa-cm3-rpi-cm4-io"

@Tidone
Copy link
Author

Tidone commented Sep 15, 2022

Same result, the board hangs after checking optee.
I also changed the root device in boot.cmd and updated the fdtfile in vars.txt, but the result is the same.

By the way, when booting the standard debian image the bootloader checks a few more partitions:

[SNIP]
U-Boot SPL board init
U-Boot SPL 2017.09-ga65d0aec67 #stephen (Aug 25 2022 - 00:10:5unknown raw ID phN
unrecognized JEDEC id bytes: 00, 00, 00
Try boot from MMC2
MMC error: The cmd index is 1, ret is -110
Card did not respond to voltage select!
mmc_init: -95, time 10
spl: mmc init faileror: -95
Trying to boot from MMC1
## Verified-boot: 0
## Checking atf-1 0x00040000 ... sha256(fe4f274c06...) + OK
## Checking uboot 0x00a00000 ... sha256(37d023461e...) + OK
## Checking fdt 0x00b2f8c8 ... sha256(2154df9e4a...) + OK
## Checking atf-2 0x00068000 ... sha256(8d44036095...) + OK
## Checking atf-3 0xfdcd0000 ... sha256(e410275b51...) + OK
## Checking atf-4 0xfdcc9000 ... sha256(990c53fc01...) + OK
## Checking atf-5 0x00066000 ... sha256(315a4195a9...) + OK
Jumping to U-Boot(0x00a00000) via ATotal: 213.498 ms

INFO:    Preloader serial: 2
[SNIP]

Are they important for the boot process?

@flatmax
Copy link
Owner

flatmax commented Sep 15, 2022 via email

@Tidone
Copy link
Author

Tidone commented Sep 15, 2022

Yes, I deleted the output and buildroot.dl folders and cleaned both repos to make sure everything is rebuilt.

As another test I built everything on a Raspberry Pi 4 (that took a few hours...) from clean repos and now the CM3 hangs even earlier:

U-Boot SPL board init
U-Boot SPL 2017.09 (Sep 15 2022 - 23:07:27)
unknown raw ID phN
unrecognized JEDEC id bytes: 00, 00, 00
Try to boot from MMC2
MMC error: The cmd index is 1, ret is -110
Card did not respond to voltage select!
mmc_init: -c init failed with error: -95
Trying to boot from MMC1
## Verified-boot: 0
## Checking uboot 0x00a00000 ... sha256(b66ec6262a...) + OK
## Checking fdt 0x00b264b8 ... sha256(1f255aabe0...) + OK

Now it doesn't even get to the optee check.

When I have time I'll build a debian image from the debos-radxa repo and compare the outputs. Maybe I can spot some important differences.

@flatmax
Copy link
Owner

flatmax commented Sep 15, 2022

ok - do you have a CM3 IO board to do a sanity check on with the original repo ?

@Tidone
Copy link
Author

Tidone commented Sep 15, 2022

Unfortunately no. But I don't really think that the board makes such a huge difference.
I can flash the provided debian and ubuntu images and they boot just fine even with the default cm3-io overlays.

Could you build the image and provide the sdcard.img so I can test that one?

@Tidone
Copy link
Author

Tidone commented Sep 20, 2022

I could get my hands on a Rock 3A board, and that one doesn't boot either (with the respective rock3a configuration):

U-Boot SPL board init
U-Boot SPL 2017.09 (Sep 20 2022 - 18:02:40)
unknown raw ID phN
unrecognized JEDEC id bytes: 00, 00, 00
Trying to boot from MMC2
## Verified-boot: 0
## Checking uboot 0x00a00000 ... sha256+ OK
## Checking fdt 0x00b23280 ... sha256+ OK
## Checking optee 0x08400000 ... sha256+ OK

I'm currently settung up a fresh VM to make sure I don't have any bugs in my buildsystem, but I don't think that's the issue because I already built the image on my Raspberry 4 with the same result.

By the way, my build system looks like this:
Folders buildroot (on tag 2022.05), buildroot.dl and buildroot.rockchip.ext (on master)
I'm executing the following commands in the buildroot folder:

source ../buildroot.rockchip.ext/setup.rock3a.sh .
make rkbin
make
OF=/dev/sdb; rootDrive=`mount | grep " / " | grep $OF`; if [ -z $rootDrive ]; then sudo umount $OF[123456789]; sudo dd if=output/images/sdcard.img of=$OF bs=10M; else echo you are trying to overwrite your root drive; fi

That should be the correct way to build the image, right?

@flatmax
Copy link
Owner

flatmax commented Sep 20, 2022

That looks correct.
Normally for me I source with the full path to the build directory. But if your system is building then that shouldn't matter.
What host system kicks off buildroot ?

@Tidone
Copy link
Author

Tidone commented Sep 20, 2022

I'm using Ubuntu 22.04 with latest updates.
I can compile buildroot images for the rpi4 and bbb without problems, it's just the rockchip systems that won't boot.
I will try to compile the image in docker, and if that doesn't I honestly don't know what could be wrong.

I also found another buildroot repo for the cm3 (the firefly repo, if you know about it), but I don't really want to use that one because it uses it's own forks of u-boot and linux, and it comes with a huge amount of user apps for video and audio.

@flatmax
Copy link
Owner

flatmax commented Sep 21, 2022

IT should be building properly. Now how about your SDCard, have you only been using the one card ? Are you sure that card is writing as expected ?

@Tidone
Copy link
Author

Tidone commented Sep 21, 2022

I've tried running the image on 3 different SDCards on the Rock3, and the eMMC on the CM3.

I've also tried building the image with this Dockerfile:
Dockerfile.txt
prepare_buildroot.sh.txt
(I had to add the .txt extension to make github happy.)

Could you try building the system yourself using this Dockerfile?
I use a fresh buildroot repo in the container to make sure there are no artifacts from previous builds.
That means you have to mount a local directory when running the container and copy the sdcard.img at the end of the build. You can execute prepare_buildroot.sh to clone and checkout all repos.

I also built the official debian image with the debos-radxa repo, and that one works without problems.

Could you also make sure you have no local changes you haven't checked in?

@flatmax
Copy link
Owner

flatmax commented Sep 22, 2022

I just did a complete rebuild for the cm3 module on the cm3 io board. I started with make distclean then the "source" command and then make. It works as expected (see my boot log below).

I would recommend getting a cm3 io board and testing with that first. This initial io board test will confirm that there is nothing strange going on in your system build nor writing to sdcard. After that you can build and run on other boards. I took this approach before manufacturing and running on my own cm3 carrier board.

U-Boot SPL board init
U-Boot SPL 2017.09 (Sep 21 2022 - 15:53:06)
unknown raw ID phN
unrecognized JEDEC id bytes: 00, 00, 00
Trying to boot from MMC2
## Verified-boot: 0
## Checking atf-1 0x00040000 ... sha256(569842593f...) + OK
## Checking uboot 0x00a00000 ... sha256(de5a01817a...) + OK
## Checking fdt 0x00b2e3f0 ... sha256(2154df9e4a...) + OK
## Checking atf-2 0xfdcc9000 ... sha256(71fe14fa9d...) + OK
## Checking atf-3 0xfdcd0000 ... sha256(a5730ca9cc...) + OK
## Checking optee 0x08400000 ... sha256(b8cddafab0...) + OK
Jumping to U-Boot(0x00a00000) via ARM Trusted Firmware(0x00040000)
Total: 270.278 ms

INFO:    Preloader serial: 2
NOTICE:  BL31: v2.3():v2.3-135-gcda1658bc-dirty:xsf
NOTICE:  BL31: Built : 14:19:26, Jun  1 2021
INFO:    GICv3 without legacy support detected.
INFO:    ARM GICv3 driver initialized in EL3
INFO:    pmu v1 is valid
INFO:    dfs DDR fsp_param[0].freq_mhz= 1056MHz
INFO:    dfs DDR fsp_param[1].freq_mhz= 324MHz
INFO:    dfs DDR fsp_param[2].freq_mhz= 528MHz
INFO:    dfs DDR fsp_param[3].freq_mhz= 780MHz
INFO:    Using opteed sec cpu_context!
INFO:    boot cpu mask: 0
INFO:    BL31: Initializing runtime services
INFO:    BL31: Initializing BL32
I/TC: 
I/TC: Start rockchip platform init
I/TC: Rockchip release version: 1.0
I/TC: OP-TEE version: 3.6.0-307-g0b06ae94 #1 Fri May  7 01:52:27 UTC 2021 aarch64
I/TC: Initialized
INFO:    BL31: Preparing for EL3 exit to normal world
INFO:    Entry point address = 0xa00000
INFO:    SPSR = 0x3c9


U-Boot 2017.09 (Sep 21 2022 - 15:53:06 +1000)

Model: Radxa CM3 IO
PreSerial: 2, raw, 0xfe660000
DRAM:  2 GiB
Sysmem: init
Relocation Offset: 7d34a000
Relocation fdt: 7b9f90c0 - 7b9fecd0
CR: M/C/I
Using default environment

failed to find reset-gpios property
no mmc device at slot 1
dwmmc@fe2b0000: 1 (SD), dwmmc@fe2c0000: 2, sdhci@fe310000: 0
Bootdev(atags): mmc 1
MMC1: Legacy, 52Mhz
PartType: EFI
No misc partition
boot mode: None
FIT: No fdt blob
No resource partition
No resource partition
Failed to load DTB, ret=-19
Failed to get kernel dtb, ret=-19
io-domain: OK
Model: Radxa CM3 IO
rockchip_set_serialno: could not find efuse/otp device
CLK: (sync kernel. arm: enter 816000 KHz, init 816000 KHz, kernel 0N/A)
  apll 816000 KHz
  dpll 528000 KHz
  gpll 1188000 KHz
  cpll 1000000 KHz
  npll 24000 KHz
  vpll 24000 KHz
  hpll 24000 KHz
  ppll 200000 KHz
  armclk 816000 KHz
  aclk_bus 150000 KHz
  pclk_bus 50000 KHz
  aclk_top_high 300000 KHz
  aclk_top_low 200000 KHz
  hclk_top 150000 KHz
  pclk_top 50000 KHz
  aclk_perimid 300000 KHz
  hclk_perimid 150000 KHz
  pclk_pmu 100000 KHz
No misc partition
Net:   No ethernet found.
Hit key to stop autoboot('CTRL+C'):  0 
failed to find reset-gpios property

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
1113 bytes read in 2 ms (543 KiB/s)
## Executing script at 00c00000
loading boot vars
reading vars.txt
78 bytes read in 1 ms (76.2 KiB/s)
setting boot args
reading rockchip/rk3566-radxa-cm3-io.dtb
155033 bytes read in 17 ms (8.7 MiB/s)
reading Image
20944904 bytes read in 1739 ms (11.5 MiB/s)
loading overlay rk3568-fiq-debugger-uart2m0
reading rockchip/overlays/rk3568-fiq-debugger-uart2m0.dtbo
513 bytes read in 4 ms (125 KiB/s)
Applying kernel provided DT overlay rk3568-fiq-debugger-uart2m0.dtbo
booting linux ...
Fdt Ramdisk skip relocation
No misc partition
## Flattened Device Tree blob at 0x0a100000
   Booting using the fdt blob at 0x0a100000
   reserving fdt memory region: addr=a100000 size=8c000
  'reserved-memory' ramoops@110000: addr=110000 size=f0000
   Using Device Tree in place at 000000000a100000, end 000000000a18efff
Adding bank: 0x00200000 - 0x08400000 (size: 0x08200000)
Adding bank: 0x09400000 - 0x80000000 (size: 0x76c00000)
Total: 2245.276 ms

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0000000000 [0x412fd050]
[    0.000000] Linux version 4.19.193 (flatmax@dev) (gcc version 10.3.0 (Buildroot 2022.05-dirty), GNU ld (GNU Binutils) 2.37) #1 SMP Wed Sep 21 15:49:27 AEST 2022

@Tidone
Copy link
Author

Tidone commented Sep 24, 2022

I found the problem: You are using an old version of the rkbin repo, which NEEDS PYTHON2!

I think you should either specify that python2 needs to be installed, or update the rkbin (and u-boot) repos to a later version.

Here are the relevant lines of the build log without python2 installed:

2022-09-24T20:16:14 /home/pi/repos/Rockchip/buildroot/output/host/bin/aarch64-buildroot-linux-uclibc-gcc
2022-09-24T20:16:14 SEC=1
2022-09-24T20:16:14 /usr/bin/env: »python2“: no such file or directory
2022-09-24T20:16:14 ls: Can't access 'bl31_0x*.bin': no such file or directory
2022-09-24T20:16:14 pack u-boot.itb okay! Input: /home/pi/repos/Rockchip/buildroot/output/build/rkbin-7d631e0d5b2d373b54d4533580d08fb9bd2eaad4/RKTRUST/RK3568TRUST.ini
2022-09-24T20:16:14 
2022-09-24T20:16:14 FIT description: FIT Image with ATF/OP-TEE/U-Boot
2022-09-24T20:16:14 Created:         Sat Sep 24 20:16:14 2022
2022-09-24T20:16:14 Image 0 (uboot)
2022-09-24T20:16:14 Description:  U-Boot(64-bit)
2022-09-24T20:16:14 Created:      Sat Sep 24 20:16:14 2022
2022-09-24T20:16:14 Type:         Standalone Program
2022-09-24T20:16:14 Compression:  uncompressed
2022-09-24T20:16:14 Data Size:    1237992 Bytes = 1208.98 KiB = 1.18 MiB
2022-09-24T20:16:14 Architecture: AArch64
2022-09-24T20:16:14 Load Address: 0x00a00000
2022-09-24T20:16:14 Entry Point:  unavailable
2022-09-24T20:16:14 Hash algo:    sha256
2022-09-24T20:16:14 Hash value:   72f82820d01d1337edb6b309645d600dafc43beb8b95a0af25c540b63c903b2e
2022-09-24T20:16:14 Image 1 (optee)
2022-09-24T20:16:14 Description:  OP-TEE
2022-09-24T20:16:14 Created:      Sat Sep 24 20:16:14 2022
2022-09-24T20:16:14 Type:         Firmware
2022-09-24T20:16:14 Compression:  uncompressed
2022-09-24T20:16:14 Data Size:    439184 Bytes = 428.89 KiB = 0.42 MiB
2022-09-24T20:16:14 Architecture: AArch64
2022-09-24T20:16:14 Load Address: 0x08400000
2022-09-24T20:16:14 Hash algo:    sha256
2022-09-24T20:16:14 Hash value:   b8cddafab0c4e20b23a2eec4c41bdb252325b69333c07f2d5a1744280468c850
2022-09-24T20:16:14 Image 2 (fdt)
2022-09-24T20:16:14 Description:  U-Boot dtb
2022-09-24T20:16:14 Created:      Sat Sep 24 20:16:14 2022
2022-09-24T20:16:14 Type:         Flat Device Tree
2022-09-24T20:16:14 Compression:  uncompressed
2022-09-24T20:16:14 Data Size:    14290 Bytes = 13.96 KiB = 0.01 MiB
2022-09-24T20:16:14 Architecture: AArch64
2022-09-24T20:16:14 Hash algo:    sha256
2022-09-24T20:16:14 Hash value:   2154df9e4ad3e777a219301ce4814189784e8fe28ca1866e15fc1b460888cf13
2022-09-24T20:16:14 Default Configuration: 'conf'
2022-09-24T20:16:14 Configuration 0 (conf)
2022-09-24T20:16:14 Description:  rk3566-radxa-cm3-io
2022-09-24T20:16:14 Kernel:       unavailable
2022-09-24T20:16:14 Firmware:     atf-1
2022-09-24T20:16:14 FDT:          fdt
2022-09-24T20:16:14 Loadables:    uboot
2022-09-24T20:16:14 optee
2022-09-24T20:16:14 /home/pi/repos/Rockchip/buildroot/output/host/bin/aarch64-buildroot-linux-uclibc-gcc
2022-09-24T20:16:14 pack loader ok.(rk356x_spl_loader_v1.08.111.bin)(0.02)
2022-09-24T20:16:14 pack loader okay! Input: /home/pi/repos/Rockchip/buildroot/output/build/rkbin-7d631e0d5b2d373b54d4533580d08fb9bd2eaad4/RKBOOT/RK3568MINIALL.ini
2022-09-24T20:16:14 /home/pi/repos/Rockchip/buildroot/output/build/uboot-19cefea3b8a7e22fa29b39367b04a8ab90c5c765
2022-09-24T20:16:14 
2022-09-24T20:16:14 Image(no-signed, version=0):  uboot.img (FIT with uboot, trust...) is ready
2022-09-24T20:16:14 Image(no-signed):  rk356x_spl_loader_v1.08.111.bin (with spl, ddr, usbplug) is ready

And here's the log with python2 installed:

2022-09-24T20:38:18 /home/pi/repos/Rockchip/buildroot/output/host/bin/aarch64-buildroot-linux-uclibc-gcc
2022-09-24T20:38:18 SEC=1
2022-09-24T20:38:18 pack u-boot.itb okay! Input: /home/pi/repos/Rockchip/buildroot/output/build/rkbin-7d631e0d5b2d373b54d4533580d08fb9bd2eaad4/RKTRUST/RK3568TRUST.ini
2022-09-24T20:38:18 
2022-09-24T20:38:19 FIT description: FIT Image with ATF/OP-TEE/U-Boot
2022-09-24T20:38:19 Created:         Sat Sep 24 20:38:19 2022
2022-09-24T20:38:19 Image 0 (uboot)
2022-09-24T20:38:19 Description:  U-Boot(64-bit)
2022-09-24T20:38:19 Created:      Sat Sep 24 20:38:19 2022
2022-09-24T20:38:19 Type:         Standalone Program
2022-09-24T20:38:19 Compression:  uncompressed
2022-09-24T20:38:19 Data Size:    1237992 Bytes = 1208.98 KiB = 1.18 MiB
2022-09-24T20:38:19 Architecture: AArch64
2022-09-24T20:38:19 Load Address: 0x00a00000
2022-09-24T20:38:19 Entry Point:  unavailable
2022-09-24T20:38:19 Hash algo:    sha256
2022-09-24T20:38:19 Hash value:   e716abb471894c1eff12936fefa583aa43770d5f71cb604e0856175a9025036f
2022-09-24T20:38:19 Image 1 (atf-1)
2022-09-24T20:38:19 Description:  ARM Trusted Firmware
2022-09-24T20:38:19 Created:      Sat Sep 24 20:38:19 2022
2022-09-24T20:38:19 Type:         Firmware
2022-09-24T20:38:19 Compression:  uncompressed
2022-09-24T20:38:19 Data Size:    165047 Bytes = 161.18 KiB = 0.16 MiB
2022-09-24T20:38:19 Architecture: AArch64
2022-09-24T20:38:19 Load Address: 0x00040000
2022-09-24T20:38:19 Hash algo:    sha256
2022-09-24T20:38:19 Hash value:   569842593f5f627fc18aa8a73032efc228965ec28d3894f0d0967d9416d969a9
2022-09-24T20:38:19 Image 2 (atf-2)
2022-09-24T20:38:19 Description:  ARM Trusted Firmware
2022-09-24T20:38:19 Created:      Sat Sep 24 20:38:19 2022
2022-09-24T20:38:19 Type:         Firmware
2022-09-24T20:38:19 Compression:  uncompressed
2022-09-24T20:38:19 Data Size:    8192 Bytes = 8.00 KiB = 0.01 MiB
2022-09-24T20:38:19 Architecture: AArch64
2022-09-24T20:38:19 Load Address: 0xfdcc9000
2022-09-24T20:38:19 Hash algo:    sha256
2022-09-24T20:38:19 Hash value:   71fe14fa9d86ec19bf85de83c01b83fc0677989b17a4571d7bb6781eb2f4b7ed
2022-09-24T20:38:19 Image 3 (atf-3)
2022-09-24T20:38:19 Description:  ARM Trusted Firmware
2022-09-24T20:38:19 Created:      Sat Sep 24 20:38:19 2022
2022-09-24T20:38:19 Type:         Firmware
2022-09-24T20:38:19 Compression:  uncompressed
2022-09-24T20:38:19 Data Size:    7360 Bytes = 7.19 KiB = 0.01 MiB
2022-09-24T20:38:19 Architecture: AArch64
2022-09-24T20:38:19 Load Address: 0xfdcd0000
2022-09-24T20:38:19 Hash algo:    sha256
2022-09-24T20:38:19 Hash value:   a5730ca9ccd2e1e1a084de2f3412f6774d6ce770bd9ae0fedaad92ed6aacd730
2022-09-24T20:38:19 Image 4 (optee)
2022-09-24T20:38:19 Description:  OP-TEE
2022-09-24T20:38:19 Created:      Sat Sep 24 20:38:19 2022
2022-09-24T20:38:19 Type:         Firmware
2022-09-24T20:38:19 Compression:  uncompressed
2022-09-24T20:38:19 Data Size:    439184 Bytes = 428.89 KiB = 0.42 MiB
2022-09-24T20:38:19 Architecture: AArch64
2022-09-24T20:38:19 Load Address: 0x08400000
2022-09-24T20:38:19 Hash algo:    sha256
2022-09-24T20:38:19 Hash value:   b8cddafab0c4e20b23a2eec4c41bdb252325b69333c07f2d5a1744280468c850
2022-09-24T20:38:19 Image 5 (fdt)
2022-09-24T20:38:19 Description:  U-Boot dtb
2022-09-24T20:38:19 Created:      Sat Sep 24 20:38:19 2022
2022-09-24T20:38:19 Type:         Flat Device Tree
2022-09-24T20:38:19 Compression:  uncompressed
2022-09-24T20:38:19 Data Size:    14290 Bytes = 13.96 KiB = 0.01 MiB
2022-09-24T20:38:19 Architecture: AArch64
2022-09-24T20:38:19 Hash algo:    sha256
2022-09-24T20:38:19 Hash value:   2154df9e4ad3e777a219301ce4814189784e8fe28ca1866e15fc1b460888cf13
2022-09-24T20:38:19 Default Configuration: 'conf'
2022-09-24T20:38:19 Configuration 0 (conf)
2022-09-24T20:38:19 Description:  rk3566-radxa-cm3-io
2022-09-24T20:38:19 Kernel:       unavailable
2022-09-24T20:38:19 Firmware:     atf-1
2022-09-24T20:38:19 FDT:          fdt
2022-09-24T20:38:19 Loadables:    uboot
2022-09-24T20:38:19 atf-2
2022-09-24T20:38:19 atf-3
2022-09-24T20:38:19 optee
2022-09-24T20:38:19 /home/pi/repos/Rockchip/buildroot/output/host/bin/aarch64-buildroot-linux-uclibc-gcc
2022-09-24T20:38:19 pack loader ok.(rk356x_spl_loader_v1.08.111.bin)(0.02)
2022-09-24T20:38:19 pack loader okay! Input: /home/pi/repos/Rockchip/buildroot/output/build/rkbin-7d631e0d5b2d373b54d4533580d08fb9bd2eaad4/RKBOOT/RK3568MINIALL.ini
2022-09-24T20:38:19 /home/pi/repos/Rockchip/buildroot/output/build/uboot-19cefea3b8a7e22fa29b39367b04a8ab90c5c765
2022-09-24T20:38:19 
2022-09-24T20:38:19 Image(no-signed, version=0):  uboot.img (FIT with uboot, trust...) is ready
2022-09-24T20:38:19 Image(no-signed):  rk356x_spl_loader_v1.08.111.bin (with spl, ddr, usbplug) is ready

As you can see, without python2 the bootloader image is invalid because the atf sections are missing. That's why my cm3 would always hang when trying to validate the atf sections.

@CaptChrisD
Copy link

@Tidone It looks like you may have gotten this to work. Could you provide more details? I am also working on batting the CM3 on a CM4 IO board but am stuck. I have a CM3 with eMMC so I am writing the output image to the eMMC with rkdeveloptool. I know the CM3 is working correctly on the IO board with an image installed on the eMMC by using the precompiled images from Radxa.

Here is a Gist showing what setup I am doing before running make. Everything seems to compile correctly -- no noticeable errors in the compile output -- but then when running I get the following:

[SNIP]
U-Boot SPL board init
U-Boot SPL 2017.09 (Dec 18 2022 - 15:13:28)
unknown raw ID phN
unrecognized JEDEC id bytes: 00, 00, 00
Trying to boot from MMC2
MMC error: The cmd index is 1, ret is -110
Card did not respond to voltage select!
mmc_init: -95, time 10
spl: mmc init failed with error: -95
Trying to boot from MMC1
## Verified-boot: 0
## Checking uboot 0x00a00000 ... sha256(48bc9eadf8...) + OK
## Checking fdt 0x00b26718 ... sha256(eb4a666b09...) + OK

I am building on a parallels VM running Ubuntu 22.04 on a Mac M1. I have also installed python2 based on your comment above. Is that all you did?

parallels@ubuntu-linux-22-04-desktop:~$ python2 -V
Python 2.7.18

I don't have a CM3 IO board and have tried to order one but can't get it for more then a month...

I have been at this for a couple of days now on and off with no success. Thank you in advance for any help.

@Tidone
Copy link
Author

Tidone commented Dec 19, 2022

Yes, I got it to work on the CM4 IO board. You don't really need a CM3 IO board because your CM3 gets stuck before it uses any hardware specific parts.
Also, there are no significant differences between the CM3 IO and the CM4 IO if you use the eMMC. Any image compiled for one board should work on the other as well.

According to your uboot log you definitely still have compile errors.
A stuck U-Boot SPL means that the image is invalid and some secure sections are missing.
Maybe your build system still can't find python2?

I checked your environment and have a few comments:

  1. You can call utils/brmake instead of make to compile the buildroot image.
    • This will automatically create a build log (br.log) in the buildroot folder and trim the terminal output.
    • This command will also use all available cores to speed up compilation.
    • You have to install expect (sudo apt install expect) for that to work
  2. You have to adapt a few files in the buildroot.rockchip.ext folder to make sure U-Boot uses the eMMC:
    • board/RK3566.cm3/boot.cmd: setenv devnum 0 and setenv bootargs "root=/dev/mmcblk0p2 earlyprintk console=ttyS2,1500000n8 rw rootwait"
    • board/RK3566.cm3/vars.txt: fdtfile=rockchip/rk3566-radxa-cm3-rpi-cm4-io.dtb
    • This is not relevant to your error right now because your CM3 doesn't even get that far.
  3. You can copy this patch to buildroot.rockchip.ext/patches.cm3/uboot/ to remove the python2 dependency and use python3 instead.

I could create a working image with your setup and these changes. (Check this Gist for my relevant logs.)

You can check the FIT description section at the end of your build log to make sure the generated image is valid:

  • If only 3 image sections are printed (count the number of Hash values) you have an invalid image which won't boot
    • You can check a few lines above the FIT description. Most common errors will be printed there, like python2 not found and/or bl31 not found
  • If you have 6 image sections the image should work.

@CaptChrisD
Copy link

CaptChrisD commented Dec 20, 2022

@Tidone Thank your for your quick reply and detailed info. Unfortunately I am still stuck but have had some findings. I have updated my gist with my patches, setup script and br.log output

I am hopeful since you can make a build but seems we need to find the difference in our two setups.

I am still only getting to

U-Boot SPL board init
U-Boot SPL 2017.09 (Dec 19 2022 - 17:17:55)
unknown raw ID phN
unrecognized JEDEC id bytes: 00, 00, 00
Trying to boot from MMC2
MMC error: The cmd index is 1, ret is -110
Card did not respond to voltage select!
mmc_init: -95, time 9
spl: mmc init failed with error: -95
Trying to boot from MMC1
## Verified-boot: 0
## Checking uboot 0x00a00000 ... sha256(bdd9a39b13...) + OK
## Checking fdt 0x00b25ff0 ... sha256(eb4a666b09...) + OK

I have noticed two differences. Your output has a line TryC2 and also spl: mmc init failed with error: -95 of mine is replaced with spl: mmc init failed with ering to boot from MMC1 in yours.

I believe this may be due to the error I found in the br.log output

2022-12-19T17:17:59 /home/parallels/cm4-io/buildroot/output/build/uboot-26d3b6963ed2d2215348f1baba8b9646ed3dc6ea/scripts/loader.sh: line 40: ./tools/boot_merger: cannot execute binary file: Exec format error
2022-12-19T17:17:59 cp: cannot stat '/home/parallels/cm4-io/buildroot/output/build/uboot-26d3b6963ed2d2215348f1baba8b9646ed3dc6ea/uboot.img': No such file or directory

This is right after the FIT description section you mentioned reviewing -- which I do have 6 image sections.

It looks like this should read

2022-12-19T19:26:10 pack loader ok.(rk356x_spl_loader_v1.08.111.bin)(0.02)
2022-12-19T19:26:10 pack loader okay! Input: /home/pi/repos/Rockchip/testtest/cm4-io/buildroot/output/images/rkbin/RKBOOT/RK3568MINIALL.ini
2022-12-19T19:26:10 /home/pi/repos/Rockchip/testtest/cm4-io/buildroot/output/build/uboot-26d3b6963ed2d2215348f1baba8b9646ed3dc6ea
2022-12-19T19:26:10 
2022-12-19T19:26:10 Image(no-signed, version=0):  uboot.img (FIT with uboot, trust...) is ready
2022-12-19T19:26:10 Image(no-signed):  rk356x_spl_loader_v1.08.111.bin (with spl, ddr, usbplug) is ready
2022-12-19T19:26:10 pack uboot.img okay! Input: /home/pi/repos/Rockchip/testtest/cm4-io/buildroot/output/images/rkbin/RKTRUST/RK3568TRUST.ini
2022-12-19T19:26:10 
2022-12-19T19:26:10 Platform RK3568 is build OK, with exist .config
2022-12-19T19:26:10 Mo 19 Dez 2022 19:26:10 CET

I did try to change my build and before doing utils/brmake I tried to do a make rkbin and then utils/brmake. I have the same error even when explicitly building rkbin first.

Any ideas are greatly appreciated!

PS. I don't think this matters yet but I am pushing the the eMMC by doing the following

rkdeveloptool db rk356x_spl_loader_ddr1056_v1.06.110.bin
rkdeveloptool/rkdeveloptool wl 0 sdcard.img

@CaptChrisD
Copy link

CaptChrisD commented Dec 20, 2022

I have been digging some more and also found

2022-12-19T17:02:11 FileNotFoundError: [Errno 2] No such file or directory: '../rkbin-7d631e0d5b2d373b54d4533580d08fb9bd2eaad4/bin/rk35/rk3568_bl31_v1.24.elf'
2022-12-19T17:02:11 CHK     include/generated/generic-asm-offsets.h
2022-12-19T17:02:11 CHK     include/generated/asm-offsets.h
2022-12-19T17:02:11 ls: cannot access 'bl31_0x*.bin': No such file or directory

I checked out https://github.com/rockchip-linux/rkbin at that commit and the path does appear to be correct... maybe the defconfig or something else... still digging

Not sure exactly where in the dir structure the BR2_TARGET_UBOOT_CUSTOM_MAKEOPTS is used but the file is at least in the filesystem...

parallels@ubuntu-linux-22-04-desktop:~/cm4-io/buildroot/output/build/uboot-26d3b6963ed2d2215348f1baba8b9646ed3dc6ea$ ls -la ../rkbin-7d631e0d5b2d373b54d4533580d08fb9bd2eaad4/bin/rk35/rk3568_bl31_v1.24.elf
-rwxr-xr-x 1 parallels parallels 270224 May 31  2021 ../rkbin-7d631e0d5b2d373b54d4533580d08fb9bd2eaad4/bin/rk35/rk3568_bl31_v1.24.elf

@Tidone
Copy link
Author

Tidone commented Dec 20, 2022

The main problem is that we are relying on binary blobs in rkbin, which are compiled for x86-64.

All your build errors can be traced back to the build system trying to execute rkbin/tools/boot_merger, which fails because you are compiling on a Mac M1 (ARM64) system.

Unfortunately you also can't use the boot_merger in u-boot because the rkbin one has some device specific patches (and we don't have the sources for that).

You could try to use qemu to execute the offending scripts (maybe build inside docker and use multiarch/qemu-user-static?).

I also have a heavily modified version of this repo which uses newer versions of u-boot and Linux.
That one should not rely on rkbin, but I have to test this. Unfortunately my only ARM build system is a Raspi 4 which takes a while to compile buildroot.
I will test everything, clean up my repo and publish it later.

EDIT: I just published my heavily modified fork of this repo (https://github.com/Tidone/buildroot.cm3). My fork will build an image for the CM3-CM4IO with the latest mainline Linux Kernel 6.1 and U-Boot v2022.04.
It does not depend on any binary blobs and should also work on the Mac M1.

@CaptChrisD
Copy link

Thank you so much for your reply and fork. I will give it a go later today.

I am actually working on bringing the CM3 up as a Nerves supported board. So all of your help is greatly appreciated and hopefully will be realized by many

@Tidone
Copy link
Author

Tidone commented Dec 20, 2022

@CaptChrisD Seriously? I actually already created a Nerves System (https://github.com/sportalliance/nerves_system_radxa_cm3).

It uses a really minimal set of hardware features because we use it for some of our companie's products, but one can fork it and adapt the dtb to enable additional features.

@CaptChrisD
Copy link

Wow... that would have saved a lot of time. So cool.

I have brought up the board with your buildroot.cm3 repo as well as the nerves system. As well as with the nerves system. I am just going to start working through getting the device tree switched out to support the cm4-io board. If I bump into troubles I will ping you over in that repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants