#1034651 installation-reports: Somewhat successful installation on Radxa ROCK 4C+ (RK3399-T)

#1034651#5
Date:
2023-04-20 20:58:08 UTC
From:
To:
Boot method: microSD card with netboot SD-card-image built from firmware.rock-pi-4-rk3399.img.gz and partition.img.gz
Image version: https://deb.debian.org/debian/dists/testing/main/installer-arm64/current/images/netboot/SD-card-images/firmware.rock-pi-4-rk3399.img.gz and https://deb.debian.org/debian/dists/testing/main/installer-arm64/current/images/netboot/SD-card-images/partition.img.gz, dated from 2023-03-31T21:11:00
Date: ~2023-04-20T20:00:00

Machine: OKdo ROCK 4C+ powered by Radxa, a single board ARM64 computer based on RK3399-T
Partitions:
  # fdisk -l /dev/mmcblk0
  Disk /dev/mmcblk0: 29.72 GiB, 31914983424 bytes, 62333952 sectors
  Units: sectors of 1 * 512 = 512 bytes
  Sector size (logical/physical): 512 bytes / 512 bytes
  I/O size (minimum/optimal): 512 bytes / 512 bytes
  Disklabel type: gpt
  Disk identifier: 12808202-944C-4D0B-A0BE-15B1F343F7C8

  Device            Start      End  Sectors  Size Type
  /dev/mmcblk0p1     2048   999423   997376  487M Linux filesystem
  /dev/mmcblk0p2   999424 60332031 59332608 28.3G Linux filesystem
  /dev/mmcblk0p3 60332032 62332927  2000896  977M Linux swap


Base System Installation Checklist:
[O] = OK, [E] = Error (please elaborate below), [ ] = didn't try it

Initial boot:           [O]
Detect network card:    [O]
Configure network:      [O]
Detect media:           [O]
Load installer modules: [O]
Clock/timezone setup:   [O]
User/password setup:    [O]
Detect hard drives:     [O]
Partition hard drives:  [O]
Install base system:    [O]
Install tasks:          [O]
Install boot loader:    [E]
Overall install:        [O]

Comments/Problems:

Installation was done over the serial console - iirc, using a USB keyboard and
screen plugged into the HDMI output didn't work, I think I only saw some output
from u-boot and maybe the kernel, but nothing from the installer. I think I
also saw that the board was detected as "Radxa ROCK Pi 4B" (and thus the
corresponding DTB got used which got also installed and linked in /boot).

The installation process was smooth, I don't remember any error messages or
warnings. I used the automatic partitioning with the whole disk. However, when
rebooting, I just got the following:

  U-Boot TPL 2023.01+dfsg-2 (Jan 18 2023 - 01:57:16)
  lpddr4_set_rate: change freq to 400MHz 0, 1
  Channel 0: LPDDR4, 400MHz
  BW=32 Col=10 Bk=8 CS0 Row=16/15 CS=1 Die BW=16 Size=2048MB
  Channel 1: LPDDR4, 400MHz
  BW=32 Col=10 Bk=8 CS0 Row=16/15 CS=1 Die BW=16 Size=2048MB
  256B stride
  lpddr4_set_rate: change freq to 800MHz 1, 0
  Trying to boot from BOOTROM
  Returning to boot ROM...

  U-Boot SPL 2023.01+dfsg-2 (Jan 18 2023 - 01:57:16 +0000)
  Trying to boot from MMC1
  mmc_load_image_raw_sector: mmc block read error
  Trying to boot from MMC2
  Card did not respond to voltage select! : -110
  spl: mmc init failed with error: -95
  Trying to boot from MMC1
  mmc_load_image_raw_sector: mmc block read error
  SPL: failed to boot from all boot devices
  ### ERROR ### Please RESET the board ###

I'm not sure what went wrong here, but unplugging and plugging it in again
didn't change anything. After putting the microSD card in another machine,
bind-mounting /dev, mounting the root file system, installing the (not yet
installed) u-boot-rockchip package after chrooting into the root file system
and running

  TARGET=/usr/lib/u-boot/rock-pi-4-rk3399 u-boot-install-rockchip /dev/mmcblk0

it successfully booted. So I guess that when using the whole disk, u-boot
doesn't get installed correctly or fully - or at all.

Before I arrived at the above solution, I made several other installation
attempts. In a (rare ;)) successful attempt, I didn't use the whole disk and
chose to manually partition it instead. I also reused the original but enlarged
partition where the installer resided as /boot and added new partitions for the
root file system and swap. That way, the system successfully booted immediately
after the installation. In that case, I assume it was just using the u-boot
that came with the installer image since the partition table wasn't recreated
during the installation - but I'm just guessing here.

Now that it booted, I still didn't get a lot of output on the attached screen,
iirc, it was only output from u-boot. Similarly on the serial console - there, I
only got output from u-boot and various error or warning messages from the
kernel, but no login prompt. I think the reason for this is that the wrong DTB
gets used. I don't remember all the details how I worked around that, but at
least part of the solution was adding

  Machine: Radxa ROCK 4C+
  Kernel-Flavors: arm64
  DTB-Id: rockchip/rk3399-rock-4c-plus.dtb
  Boot-Script-Path: /boot/boot.scr
  U-Boot-Script-Name: bootscr.uboot-generic
  Required-Packages: u-boot-tools

to /etc/flash-kernel/db,

  setenv fdtfile rockchip/rk3399-rock-4c-plus.dtb

to e.g. /etc/flash-kernel/ubootenv.d/rock4cplus and maybe

  Radxa ROCK 4C+

to /etc/flash-kernel/machine and running flash-kernel. After a subsequent
reboot, many of the errors from the kernel were gone, I got a login prompt on
the serial console and was also able to login using a USB keyboard and the
screen attached via HDMI.

According to its output, u-boot itself still uses the DTB for a "Radxa ROCK Pi
4B" I think, but by setting fdtfile to the correct DTB for the board as above,
the kernel boots using the correct one.

I haven't checked if all the hardware actually works, but ethernet, bluetooth,
USB and HDMI seem to. WiFi didn't when I quickly tried to use it, but that's
probably caused by missing firmware (I did install some firmware packages, but
the kernel still complained that it can't load some iirc .txt file - which
would be part of the raspi-firmware package, but I didn't try to install that).

Unfortunately, I don't know why the board is mis-detected as "Radxa ROCK Pi
4B", which is at least part of some problems I guess, but I also know pretty
much nothing about u-boot, ARM, DTBs, etc. ;). But I think that this might at
least in part be caused by u-boot not currently supporting the "Radxa ROCK 4C+"
- I didn't find any reference to it in the u-boot source code but a patch which
would add that support [1].

I hope the above is useful for somebody. I certainly find it great that it is
possible to get a stock Debian running on this board, even though it's not as
easy yet as I was hoping when I bought the board ;).

Cheers,
Manfred

[1] https://lore.kernel.org/all/20221019073755.100576-1-naoki@radxa.com/