Installing a Debian image built with debian-image-builder to the NanoPi R5S

2022/12/05

Tags: linux nanopi

Returning the device to factory condition

First I overwrote the contents of my eMMC back to FriendlyWRT as the device ships with, to recreate the initial state the device ships in. For that I used one of the eflasher images from https://drive.google.com/drive/folders/1AN6tYCWZAXjJY3oFXO_hVc5WGRvgStov. I used the rk3568-eflasher-friendlywrt-22.03-docker-20220919.img image, it seems like a later version of that is now available.

Removed the SD card and verified that FriendlyWRT booted correctly

Powered off.

Then I attempted to boot a Debian image written to an SD card, created by this builder tool, just to verify that it doesn’t work. Holding the mask button, powering on and releasing after 3 seconds, this fails due to the U-Boot on the eMMC being a vintage 2017.09 version: Tail of the serial console output:

U-Boot SPL 2022.07 (Oct 04 2022 - 10:18:08 -0400)
Trying to boot from MMC2
spl: mmc init failed with error: -110
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 then reinserted the SD card with the FriendlyWRT eflasher (this will boot automatically without holding down the mask button when FriendlyWRT is on the eMMC) and powered on. I then switched to a virtual console (ctrl - alt - f2) and logged in with the credentials root / fa

From here I executed dd if=/dev/zero of=/dev/mmcblk2 bs=8M count=1

I then removed the SD card and powered off / on. As expected, with no SD card the device will not boot as there is no U-Boot on the eMMC.

I then reinserted the debian-image-builder SD card, and powered on without holding down the mask button

Interestingly this results in U-Boot SPL 2022.07 off the SD card trying to boot into the eMMC with U-Boot 2017.09

U-Boot SPL 2022.07 (Oct 04 2022 - 10:18:08 -0400)
Trying to boot from MMC2
INFO:    Preloader serial: 2
NOTICE:  BL31: v2.3():v2.3-181-gc9a647cae:cl
NOTICE:  BL31: Built : 10:55:41, Oct 18 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= 1560MHz
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
WARNING: No OPTEE provided by BL2 boot loader, Booting device without OPTEE initialization. SMC`s destined for OPTEE will return SMC_UNK
ERROR:   Error initializing runtime service opt

U-Boot 2017.09-g8c91d15ff7-dirty # (Sep 18 2022 - 19:04:00 +0800)

Board: NanoPi R5S
PreSerial: 2, raw, 0xfe660000
DRAM:  4 GiB
Sysmem: init
Relocation Offset: ed34a000
Relocation Offset: ed34a000
Relocation fdt: eb9fa320 - eb9fecc8
CR: M/C/I
Using default environment

dwmmc@fe2b0000: 1, dwmmc@fe2c0000: 2, sdhci@fe310000: 0
switch to partitions #0, OK
mmc1 is current device
Boot from SDcard
Bootdev: mmc 1
MMC1: Legacy, 52Mhz
PartType: EFI
DM: v1
No misc partition
boot mode: None
FIT: No boot partition
No resource partition
Failed to get rk3568-nanopi5-rev01.dtb
No resource partition
Failed to load DTB, ret=-19
No find valid DTB, ret=-22
Failed to get kernel dtb, ret=-22
io-domain: OK
Failed to get scmi clk dev
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 780000 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
vdd_usbc 5255 mV

Net:   No ethernet found.
Hit key to stop autoboot('CTRL+C'):  0 
## Booting FIT Image FIT: No boot partition
FIT: No fit blob
FIT: No FIT image
Could not find misc partition
ANDROID: reboot reason: "(none)"
optee check api revision fail: -1.0
optee api revision is too low
### ERROR ### Please RESET the board ###

Installing Debian to the eMMC

Mount the “FriendlyArm” partition and copy over the debian-image-builder image (decompressed) Press ctrl-alt-f2 to switch to a virtual console log in with root / fa dd if=/mnt/sdcard/rk3568-nanopi-r5s-debian-bullseye-5.19.12-arm64-2022-10-04.img of=/dev/mmcblk2 bs=1M status=progress

Download a FriendlyWRT eflasher image from https://drive.google.com/drive/folders/1AN6tYCWZAXjJY3oFXO_hVc5WGRvgStov. I used the rk3568-eflasher-friendlywrt-22.03-docker-20220919.img image, it seems like a later version of that is now available. Any of the images would work, but this has a nice large exFAT partition with lots of free space, so makes it easy.

Write this to an SD card

Mount the exFAT partition named FriendlyARM on the SD and copy over your debian-image-builder image e.g. rk3568-nanopi-r5s-debian-bullseye-5.19.12-arm64-2022-10-04.img (ensure this in uncompressed). There should be enough space on the partition without deleting anything.

Insert the SD card in the nanopi and power on, it should boot from the SD card without holding down the mask button if you have FriendlyWRT on the eMMC. If not, or you’ve wiped the boot on the eMMC, hold down the mask button for 3 seconds.

Once you see the “Welcome to NanoPi-R5S” GUI, press ctrl-alt-f2 to switch to a virtual console log in with username: root / password: fa

Write Debian to the eMMC dd if=/mnt/sdcard/rk3568-nanopi-r5s-debian-bullseye-5.19.12-arm64-2022-10-04.img of=/dev/mmcblk2 bs=1M status=progress

Remove the SD card and power off / on

It should boot into Debian and you can log in with npi/npi on the prebuilt images (this is no longer the case)

Errors in U-Boot

=> mmc info
Device: mmc@fe310000
Manufacturer ID: 15
OEM: 0
Name: AJTD4R 
Bus Speed: 200000000
Mode: HS200 (200MHz)
Rd Block Len: 512
MMC version 5.1
High Capacity: Yes
Capacity: 14.6 GiB
Bus Width: 8-bit
Erase Group Size: 512 KiB
HC WP Group Size: 8 MiB
User Capacity: 14.6 GiB WRREL
Boot Capacity: 4 MiB ENH
RPMB Capacity: 4 MiB ENH
Boot area 0 is not write protected
Boot area 1 is not write protected
=> mmc list
mmc@fe2b0000: 1
mmc@fe310000: 0 (eMMC)
=> mmc rescan
\ 
=> 
Card did not respond to voltage select! : -110
=> mmc list
mmc@fe2b0000: 1
mmc@fe310000: 0
=> mmc info
Card did not respond to voltage select! : -110
=> mmc dev 0 
Card did not respond to voltage select! : -110
=> mmc dev mmc@fe310000
Card did not respond to voltage select! : -110
=> mmc rescan HS200
Card did not respond to voltage select! : -110
=> mmc rescan 10   
Card did not respond to voltage select! : -110
=> mmc rescan 9 
Card did not respond to voltage select! : -110
=> 
Card did not respond to voltage select! : -110
=> mmc dev 1
Card did not respond to voltage select! : -110
=> mmc info
Card did not respond to voltage select! : -110
=> mmc rescan
Card did not respond to voltage select! : -110