NanoPC-T6 Image (Single Partition) Kernel Upgrade

Creating a bug report/issue

I have searched the existing open and closed issues

Required Information

  • DietPi version
G_DIETPI_VERSION_CORE=9
G_DIETPI_VERSION_SUB=3
G_DIETPI_VERSION_RC=0
G_GITBRANCH='master'
G_GITOWNER='MichaIng
  • Distro version | bookworm
  • Kernel version | uname --all
  • Architecture | Linux DietPi 5.10.160-legacy-rk35xx #1 SMP Fri Feb 2 07:51:33 UTC 2024 aarch64 GNU/Linux
  • SBC model | NanoPi 6 series (aarch64)
  • Power supply used | 12V/2A
  • SD card used | Sandisk Ultra 8GB

Steps to reproduce

I’m trying to replace the Kernel with my own build, which I did in the past when the partition layout was Android-like (separate boot/kernel partition to enclose the img files). I’m building my kernel as described on the NanoPC-T6 page (as I always did) with the 5.10.16 kernel branch. This actually gives me the same kernel version (legacy) as it is installed right now.

  1. I follow the steps in 12.4.2 Build kernel linux-v6.1.y to build the nanopi6-images and then I can flash the kernel.img and the boot.img to the Android layout - boot, works.
  2. Tried to update the uImage and other stuff on the boot directory on the single-partition layout - fails miserably, does not boot any more. I included the custom modules build, but not the dts (those I took from the legacy for now.
  3. Also tried to create bindeb-pkg to have debian packages (image,headers,libc) - no luck either.

Expected behaviour

  • I would expect that replacing the uInitrd-*, the vmlinuz-* and the System.map should actually do the trick, but does not.

Is there a known procedure to update the kernel for the NanoPC-T6 with the new single-partition layout?

Thx…

@MichaIng maybe you are able to assist

Ok, so here’s a (not so nice, but working) solution. All of that goes after building the nanopi6-images:

export KDIR=/home/dietpi/kernel-rockchip

# Config & Map
cp $KDIR/System.map /boot/System-5.10.160-custom
cp $KDIR/.config /boot/config-5.10.160-custom

# Image
cp $KDIR/arch/arm64/boot/Image /boot/vmlinuz-5.10.160-custom
rm /boot/Image && ln -s /boot/vmlinuz-5.10.160-custom /boot/Image

# Modules
cp -R $KDIR/out-modules/lib/modules/5.10.160-custom /lib/modules/

# DTB
mkdir -p /boot/dtb-5.10.160-custom/rockchip
cp $KDIR/arch/arm64/boot/dts/rockchip/*.dtb \
  /boot/dtb-5.10.160-custom/rockchip
rm /boot/dtb && ln -s /boot/dtb-5.10.160-custom /boot/dtb

# Initrd
mkinitramfs -o initrd.img-5.10.160-custom 5.10.160-custom

#uInitrd
mkimage -A arm64 -O linux -T ramdisk -C none -a 0 -e 0 -n uInitrd \
  -d /boot/initrd.img-5.10.160-custom /boot/uInitrd-5.10.160-custom
rm /boot/uInitrd && ln -s /boot/uInitrd-5.10.160-custom /boot/uInitrd

rebooted, works. Need to check if overlays of dtbs also works…

PS:
So this also does not work - there is something missing. For some reason if I just did a soft “reboot” it worked, but after pulling the plug and restarting it cold, it did not work again…

any hints?

So after diving a little deeper into this, I think that my kernel is actually not in the right format (why it booted before? - I don’t know).

Anyway, here’s the output that file tells me for the two kernels:

mine:

rockchip$ file arch/arm64/boot/uImage 
arch/arm64/boot/uImage: u-boot legacy uImage, , Linux/ARM 64-bit, OS Kernel Image (gzip), 34881544 bytes, Wed May  8 08:27:29 2024, Load Address: 0x00000000, Entry Point: 0x00000000, Header CRC: 0xB59BFE5F, Data CRC: 0x9ABADFC4

legacy:

rockchip$ file vmlinuz-5.10.160-legacy-rk35xx 
vmlinuz-5.10.160-legacy-rk35xx: MS-DOS executable PE32+ executable (EFI application) Aarch64 (stripped to external PDB), for MS Windows

Honestly, I don’t get it. Any ideas appreciated…

EDIT: Ah wait, for the single-partition layout? You do have an image with a single partition already, don’t you? Else uname -a should not contain 5.10.160-legacy-rk35xx, or am I missing something? Below works on an image with linux-image-legacy-rk35xx package on single-partition image. For migration on old older images with 8 partitions, I need time for testing.

Here is a simpler solution, as we have packages for Linux 6.1 already, which work well on Orange Pi 5, but needs testing on NanoPi T6, to be sure:

cd /tmp
wget https://dietpi.com/downloads/binaries/testing/linux-{image,dtb}-vendor-rk35xx.deb
dpkg -i linux-{image,dtb}-vendor-rk35xx.deb
reboot

Well, I’m booting off the SDCard right now with a single partition, yes, but I want to move to EMMC (single partition also) once I have a working version.

I don’t necessarily need a version 6 kernel, I need to patch the devicetree for some devices attached. That’s why I need to run through the steps all one by one…

Can you provide the instructions to build the debian packages?

We use the Armbian build system: DietPi/.github/workflows/armbian.yml at 03b8282751f6020a116809314868aa589b395b7b · MichaIng/DietPi · GitHub

Isn’t it possible to apply your device tree changes via overlay(s)? So it can survive kernel package upgrades.

If you find time to test the Linux 6.1 build, that would be great. I want to move all RK3588 boards to this version, but the NanoPC T6 is the only relevant board I have not here to test myself :slightly_smiling_face:.

That works without any issues on the NanoPC-T6, so you did a good job, as always :slight_smile:

 ─────────────────────────────────────────────────────
 DietPi v9.3.0 : 09:50 - Thu 05/09/24
 ─────────────────────────────────────────────────────
 - Device model : NanoPi 6 series (aarch64)
 - CPU temp : 31 °C / 87 °F : Cool runnings
 - LAN IP : 192.168.0.218 (eth1)
 - MOTD : Open Beta v9.4 | Please help testing our upcoming release:
          https://github.com/MichaIng/DietPi/issues/7060
 ─────────────────────────────────────────────────────

 DietPi Team     : https://github.com/MichaIng/DietPi#the-dietpi-project-team
 Patreon Legends : Chris Gelatt, ADSB.im
 Website         : https://dietpi.com/ | https://twitter.com/DietPi_
 Contribute      : https://dietpi.com/contribute.html
 Web Hosting by  : https://myvirtualserver.com

 dietpi-launcher : All the DietPi programs in one place
 dietpi-config   : Feature rich configuration tool for your device
 dietpi-software : Select optimised software for installation
 htop            : Resource monitor
 cpu             : Shows CPU information and stats

root@DietPi:~# uname -a
Linux DietPi 6.1.43-vendor-rk35xx #1 SMP Sat Apr 27 18:12:21 UTC 2024 aarch64 GNU/Linux
root@DietPi:~# 

Yes, Overlay is one part of the story. This is a pain by its own, so I usually just include particular dtsi files in the original dts files and it is included automatically.

The other issue is drivers. I need drivers for camera sensors, like OV4689 or OV9281, IMX214, IMX219 and so on… In the end I still need the entire kernel tree and then I can just resort to building the kernel myself.

PS:

So I tried to write an overlay, compile it within the armbian-kernel and copy it over to the board. Unfortunately it does not seem to get loaded (for whatever reason). I think I just have to put the name into the user_overlays= clause without the prefix, so rk3588-nanopi6-ov9281.dtbo becomes nanopi6-ov9281 but it does not get applied as it seems…

Those should all be present:
image
image
Ah, OV4689 is missing. It is present in the sources: linux-rockchip/drivers/media/i2c/ov4689.c at cdbd7566a3a017d407c8a9a9af176c7ca46c8c69 · armbian/linux-rockchip · GitHub
Hmm even enabled in the config: build/config/kernel/linux-rk35xx-vendor.config at 1ff445fa3dbac7555944f1e5d56b94e5b3b0b546 · armbian/build · GitHub
I even see it being compiled in our logs: Armbian · MichaIng/DietPi@406ddb3 · GitHub

… ah, CONFIG_VIDEO_OV4689=y, not CONFIG_VIDEO_OV4689=m, so it is builtin :slightly_smiling_face:. So all there, anything not working OOTB regarding those?

yes, I saw that everything should be there, thank you :wink:

My device tree overlay is simply not loaded, or it is loaded, but does not work which is more likely… I verified that the loading functionality through overlay-user actually works, so it has to do with my implementation.

I’ll probably try to just include the device tree like I did previously, and then gradually move to the overlay version.

One last question. The best way to move the 1-partition SD-card solution to the EMMC is simply to do a dd to a single partition on the EMMC, right? Again following merely this Blog, right?

Best is to flash a new image to the NVMe. Else yes, that blog post should work. Note that “partition” is not right here, since you dd the whole drive content, including partition table and all its partitions (which is a single only, yes. You dd /dev/mmcblk0 (the drive itself), not /dev/mmcblk0p1 (the first partition), which would not result in a bootable image.

ok, managed that… runs fine from EMMC…

just including the devicetree file in the dtb compilation works, but the overlay does not… tricky…

There is one more thing I noticed. The NanoPC-T6 has 2 Ethernet ports and usually the ETH1 is the working one… however, sometimes it seems the ports switch roles… then ETH2 works as if it was ETH1 with the same MAC address… that’s very weird… ever read something like that?

Same happens on Orange Pi 5 Plus. I’ll implement udev rules to hardcode the interface names, but I need some device identifier to match them. I’ll check back with the commands to list device identifiers, something with the udevadm tool.

ok, let me know if I can assist somehow…

Is there any easy way to check the messages when loading the device tree overlay? There is a serial interface on the Debug UART enabled which should show any error messages before booting, right?

respectively here:

Yes, attaching a USB-UART adapter and serial console should show bootloader/U-Boot logs, including failures up to the point where the kernel was loaded, and login prompt (on successful boot). Kernel logs themselves are done on HDMI (/dev/tty1) by default. One would need to switch the two console devices in /boot/dietpiEnv.txt kernel command-line arguments to have kernel and init/systemd logs as well on the serial console: the last console= argument is used for this.

Works nicely, but does not help in the end unfortunately. It seems I have to stick to the rockchip kernel for the time being. There is something weird happening to the mipi and rkisp stuff…

Tried asking for help on friendlyelec discord, but no luck so far…

overlay_6_1_50_armbian.log (107.5 KB)
overlay_5_1_160_rockchip.log (101.5 KB)

Thx so far…

Help with what? What is not working with Linux 6.1? Ethernet interface swap is still expected. I’ll implement a fix today for today’s DietPi update.

Well, it seems that the rkisp and mipi things are messed up in the 6.1 kernel. I can‘t really tell what is wrong… if you compare the two log files there are no errors in the 5.10 version, but in the 6 version it starts with the „subdev not found“ errors and in the end the rkisp mainpath does not give images… the rkaiq server also fails…

7.247712] rkisp_hw fdcb0000.rkisp: Missing rockchip,grf property
[ 7.249179] rkisp_hw fdcb0000.rkisp: max input:0x0@0fps
[ 7.250748] rkisp_hw fdcb0000.rkisp: no find phandle sram

And goes on when it comes to rkcif… actually I think that is the problem…

Ps: here is the overlay:

I thought the overlay method does not work in general? Did you check whether the overlay was actually applied or failed? In case of any overlay failure, our /boot/boot.scr applies again the default device tree.