Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Orange Pi 5 - bootloader / kernel update
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo on ARM
View previous topic :: View next topic  
Author Message
Gladdle
Guru
Guru


Joined: 27 Jul 2008
Posts: 313
Location: Cleebronn, Germany

PostPosted: Thu Dec 28, 2023 9:33 pm    Post subject: Orange Pi 5 - bootloader / kernel update Reply with quote

I am sorry to ask stupid questions again, but i didn't understand the boot sequence for the Orange pi 5, also there are different bootloader.
I have watched a few youtube chanels, some tutorials. So what i know is that the Orange Pi 5 uses a Rockchip 3588. The developer got some "special" kernel builds, in my case it's a "5.10.110-3+" kernel - even there, not all the funtions (like USB or the NVMe) work propper. Thanks to Collabora there are drivers for the "Rockchip 3588" since the Version 6.3 in the official linux tree. So i try to update, install the gentoo-sources and genkernel. I got a new kernel (v6.6.7). The directory /boot/ contains this files:
Code:
drwxr-xr-x  3 root root 4.0K Apr 21  2023 dtbs
drwxr-xr-x  2 root root 4.0K Apr 11  2023 extlinux
-rwxr-xr-x  1 root root  34M Apr 20  2023 Image
-rwxr-xr-x  1 root root 286K Apr 19  2023 idbloader.img
-rwxr-xr-x  1 root root  279 Nov 30 19:01 info.txt
-rwxr-xr-x  1 root root 7.3M Apr 21  2023 initramfs-linux.img
-rwxr-xr-x  1 root root 1.1M Apr 19  2023 logo.bmp
-rwxr-xr-x  1 root root  16M Apr 19  2023 rkspi_loader.img
-rwxr-xr-x  1 root root  16M Apr 19  2023 rkspi_loader_sata.img
-rwxr-xr-x  1 root root 1.6M Apr 19  2023 u-boot.itb

And after the update (i mean the self made kernel) there are 3 more files:
Code:
-rwxr-xr-x  1 root root 4.3M Dec 19 12:59 System.map-6.6.7-gentoo-arm64
-rwxr-xr-x  1 root root 9.4M Dec 19 13:56 initramfs-6.6.7-gentoo-arm64.img
-rwxr-xr-x  1 root root  28M Dec 19 12:59 vmlinuz-6.6.7-gentoo-arm64

But i don't know how to update the bootloader, can't find anything bout this topic. Is there a software from the Orange Pi manufacturer (official Google Drive from the manufacturer for the OPi5)? it seems like some "u-boot" stuff, but i don't know how to update that bootloader, it's still booting the old kernel. I found something on reddit: "Upstream U-Boot support for OrangePi 5/5B/5+", but i can't understand all of that (english is not my native language, specially not the technical one), have i to install that u-boot version from github? I'm very happy if someone can help me, maybe with some useful links or a small tutorial. If i get some good hints i'm pretty sure i can solve that and post the solution here.
Back to top
View user's profile Send private message
pingtoo
Veteran
Veteran


Joined: 10 Sep 2021
Posts: 1339
Location: Richmond Hill, Canada

PostPosted: Thu Dec 28, 2023 10:16 pm    Post subject: Reply with quote

Gladdle,

Do you have serial console setup for OPI5? I mean a usb to ttl serial cable from you other PC to OPI5?

Without it could be difficult to make change in u-boot.

I would not recommend you change u-boot or kernel if you are not familiar with embedded device would because there is quick a bit of stuff you need to know before you can run mainstream linux/u-boot.

See rockchip wiki about [url=]rockchip boot sequence[/url].

You may be able to make change in extlinux/extlinux.conf to switch kernel, however I doubt the new kernel you build will boot, It is possible that u-boot is currently programmed to expecting a u-boot specific format kernel image file in order for it to load.

BTW, in your previous post about USB not working, I have point out the button USB port of OPI5 is usb 2. so it is possible you used a incomparable cable therefor it is not working.
Back to top
View user's profile Send private message
Gladdle
Guru
Guru


Joined: 27 Jul 2008
Posts: 313
Location: Cleebronn, Germany

PostPosted: Fri Dec 29, 2023 10:11 pm    Post subject: Reply with quote

pingtoo wrote:
Gladdle,

Do you have serial console setup for OPI5? I mean a usb to ttl serial cable from you other PC to OPI5?

Without it could be difficult to make change in u-boot.

I only want to install a new kernel, nothing else. And therefore i have access via keyboard and a monitor and also via ssh.

pingtoo wrote:
I would not recommend you change u-boot or kernel if you are not familiar with embedded device would because there is quick a bit of stuff you need to know before you can run mainstream linux/u-boot.

See rockchip wiki about [url=]rockchip boot sequence[/url].

I need a new kernel because some parts wont working. Nice link btw ;)

pingtoo wrote:
BTW, in your previous post about USB not working, I have point out the button USB port of OPI5 is usb 2. so it is possible you used a incomparable cable therefor it is not working.

I've updated my post, seems like i have to make some kernel updates to solve the problem, that's why this topic is created.

pingtoo wrote:
You may be able to make change in extlinux/extlinux.conf to switch kernel, however I doubt the new kernel you build will boot, It is possible that u-boot is currently programmed to expecting a u-boot specific format kernel image file in order for it to load.

THAT'S very useful, thanks a lot for this! My new kernel doesn't boot, the "orginal" one does, so i have to find a solution. Give me some time, i will test that in the next days!
Back to top
View user's profile Send private message
erg_samowzbudnik
Apprentice
Apprentice


Joined: 09 Sep 2011
Posts: 229
Location: European sticks

PostPosted: Thu Feb 22, 2024 12:43 pm    Post subject: Reply with quote

Hi. Don't want to create another thread, hope it's ok to continue this one as I've tried to do just that, boot mainline kernel on Orange Pi 5.

I started with a bootloader. From what NeddySeagoon said, there's more choice than just u-boot - but I chose u-boot. Do tell if it's easier with UEFI - or something else.

I wrote down what I did and how I failed hoping it'll help me understand what I did wrong.
It didn't. Hope youse can give a helping hand.

Preconditions:
- aarch64 crosscompiler set up

Hardware:
- Laptop x86_64, AMD
- SD card - I use 32GB class 10 SanDisk card
- USB-to-serial CH340
- Orange Pi 5


Procedure for creating Rockchip rk3588 u-boot image:

Create a directory for stuff:
Code:
mkdir rockchip && cd rockchip



Get u-boot and Rockchip binary blob from (git clone <repo>):
Code:
git clone https://gitlab.collabora.com/hardware-enablement/rockchip-3588/u-boot
git clone https://gitlab.collabora.com/hardware-enablement/rockchip-3588/rkbin.git
git clone https://gitlab.collabora.com/hardware-enablement/rockchip-3588/trusted-firmware-a


Now we have three subdirectories:
Code:

ls -1
rkbin
trusted-firmware-a
u-boot


Below step fails for me so I use provided rkbin/bin/rk35/rk3588_bl31_v1.27.elf:
Code:
cd trusted-firmware-a
make PLAT=rk3588 bl31
cd -


Build u-boot:
Code:
cd u-boot
export ROCKCHIP_TPL=../rkbin/bin/rk35/rk3588_ddr_lp4_2112MHz_lp5_2736MHz_v1.08.bin
export BL31=../rkbin/bin/rk35/rk3588_bl31_v1.27.elf
make ARCH=arm CROSS_COMPILE="aarch64-unknown-linux-gnu-" distclean
make ARCH=arm CROSS_COMPILE="aarch64-unknown-linux-gnu-" orangepi-5-rk3588s_defconfig
make ARCH=arm CROSS_COMPILE="aarch64-unknown-linux-gnu-"


Create image:
insert SD card, as root do:
Code:
dd if=idbloader.img of=/dev/mmcblkX seek=64
dd if=u-boot.itb of=/dev/mmcblkX seek=16384


Connect HDMI screen, connect USB-to-serial, start minicom:
Code:
minicom -b 1500000 -D /dev/ttyS0

(I start it on ttyS{0-4} as I'm not sure which one it is

Insert SD card to Pi, boot, see nothing.

What now?
Back to top
View user's profile Send private message
erg_samowzbudnik
Apprentice
Apprentice


Joined: 09 Sep 2011
Posts: 229
Location: European sticks

PostPosted: Thu Feb 22, 2024 5:03 pm    Post subject: Reply with quote

Turns out I was missing kernel module for that adapter :oops:

I have progress!

I just put the kernel I built on the boot partition, will need to massage that orange a bit.

I get that now from the serial (that's a tail):

Code:
USB XHCI 1.10
scanning bus usb@fc000000 for devices... 1 USB Device(s) found
scanning bus usb@fc800000 for devices... 1 USB Device(s) found
scanning bus usb@fc840000 for devices... 1 USB Device(s) found
scanning bus usb@fc880000 for devices... 1 USB Device(s) found
scanning bus usb@fc8c0000 for devices... 1 USB Device(s) found
scanning bus usb@fcd00000 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found

Device 0: unknown device
failed to find reset-gpios property
No ethernet found.
missing environment variable: pxeuuid
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/00000000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/0000000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/000000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/00000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/0000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/000
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/00
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/0
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/default-arm-rockchip
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/default-arm
No ethernet found.
missing environment variable: bootfile
Retrieving file: pxelinux.cfg/default
No ethernet found.
Config file not found
failed to find reset-gpios property
No ethernet found.
Could not get mtd 0
## Booting FIT Image FIT: No fit blob
FIT: No FIT image
Unknown command 'bootrkp' - try 'help'
opi#


Gotta get some food, it's going to be a long night :D
Back to top
View user's profile Send private message
erg_samowzbudnik
Apprentice
Apprentice


Joined: 09 Sep 2011
Posts: 229
Location: European sticks

PostPosted: Thu Mar 07, 2024 9:13 am    Post subject: Reply with quote

I have now flashed u-boot to SPI and it works.

Only my kernel still won't load:

Code:
Importing into environment ...
armbianEnv.txt imported into environment
14786786 bytes read in 1239 ms (11.4 MiB/s)
34134592 bytes read in 2855 ms (11.4 MiB/s)
249798 bytes read in 30 ms (7.9 MiB/s)
Working FDT set to 12000000
Failed to load '/dtb/rockchip/overlay/rockchip-rk3588-fixup.scr'
Unknown command 'kaslrseed' - try 'help'
Bad Linux ARM64 Image magic!
Boot failed (err=-14)


To generate my kernel I have used the orange pi 5 defconfig from Armbian.

Then I took this file:
Code:
file /usr/src/linux/arch/arm64/boot/Image
/usr/src/linux/arch/arm64/boot/Image: Linux kernel ARM64 boot executable Image, little-endian, 4K pages


Tried to boot it, fail.

Then I tried and run:
Code:
mkimage -A arm -O linux -T kernel -a 0x00080000 -e 0x00080000 -d Image uImage


The magic address in the above I am not sure about as I don't understand where it comes from. I have also tried without it, result is the same.

armbianEnv.txt content:

Code:
verbosity=1
bootlogo=false
overlay_prefix=rockchip-rk3588
fdtfile=rockchip/rk3588s-orangepi-5.dtb
rootdev=UUID=aa648621-8496-41a9-86a4-209afe528cfa
rootfstype=ext4
kernel=uImage


There is something not quite right with the kernel image format I suppose?
Or do I need rockchip-rk3588-fixup.scr ? I could not locate this file amongst u-boot provided files.

I also generated initrd but noticed u-boot doesn't try to use it. Armbian provided kernel boots without it as well.
Back to top
View user's profile Send private message
erg_samowzbudnik
Apprentice
Apprentice


Joined: 09 Sep 2011
Posts: 229
Location: European sticks

PostPosted: Thu Mar 07, 2024 1:08 pm    Post subject: Reply with quote

Got the board to start booting kernel with extlinux and Image.gz

Now it fails booting kernel with:
Code:
[    0.000000] GICv3: CPU0: using allocated LPI pending table @0x0000000100280000
[    0.000000] rcu: srcu_init: Setting srcu_struct sizes based on contention.
[    0.000000] rockchip_cpuclk_pre_rate_change: Invalid rate : 1100000000 for cpk
[    0.000000] clk: couldn't set armclk_l clk rate to 1100000000 (-16), current 0


Whole of booting progress:

Code:
Retrieving file: /dtb/rockchip/rk3588s-orangepi-5.dtb
   Uncompressing Kernel Image to 0
## Flattened Device Tree blob at 12000000
   Booting using the fdt blob at 0x12000000
Working FDT set to 12000000
ERROR: reserving fdt memory region failed (addr=0 size=0 flags=0)
ERROR: reserving fdt memory region failed (addr=0 size=0 flags=0)
   Loading Device Tree to 00000000ece5d000, end 00000000ece9cfc5 ... OK
Working FDT set to ece5d000

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0000000000 [0x412fd050]
[    0.000000] Linux version 6.6.13-gentoo (root@localhost) (gcc (Gentoo 13.2.1_4
[    0.000000] KASLR disabled due to lack of seed
[    0.000000] Machine model: Orange Pi 5
[    0.000000] earlycon: uart8250 at MMIO32 0x00000000feb50000 (options '')
[    0.000000] printk: bootconsole [uart8250] enabled
[    0.000000] efi: UEFI not found.
[    0.000000] OF: fdt: Reserved memory: failed to reserve memory for node 'drm-B
[    0.000000] OF: fdt: Reserved memory: failed to reserve memory for node 'drm-B
[    0.000000] OF: reserved mem: 0x0000000000110000..0x00000000001fffff (960 KiB0
[    0.000000] Reserved memory: created CMA memory pool at 0x0000000010000000, sB
[    0.000000] OF: reserved mem: initialized node cma, compatible id shared-dma-l
[    0.000000] OF: reserved mem: 0x0000000010000000..0x000000001fffffff (262144 a
[    0.000000] OF: reserved mem: 0x00000003fc000000..0x00000003fc4fffff (5120 Ki0
[    0.000000] OF: reserved mem: 0x00000003fff00000..0x00000003ffffffff (1024 Ki0
[    0.000000] Zone ranges:
[    0.000000]   DMA      [mem 0x0000000000200000-0x00000000ffffffff]
[    0.000000]   DMA32    empty
[    0.000000]   Normal   [mem 0x0000000100000000-0x00000003ffffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000200000-0x00000000efffffff]
[    0.000000]   node   0: [mem 0x0000000100000000-0x00000003fbffffff]
[    0.000000]   node   0: [mem 0x00000003fc000000-0x00000003fc4fffff]
[    0.000000]   node   0: [mem 0x00000003fc500000-0x00000003ffefffff]
[    0.000000]   node   0: [mem 0x00000003fff00000-0x00000003ffffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000200000-0x00000003ffffffff]
[    0.000000] On node 0, zone DMA: 512 pages in unavailable ranges
[    0.000000] psci: probing for conduit method from DT.
[    0.000000] psci: PSCIv1.1 detected in firmware.
[    0.000000] psci: Using standard PSCI v0.2 function IDs
[    0.000000] psci: MIGRATE_INFO_TYPE not supported.
[    0.000000] psci: SMC Calling Convention v1.2
[    0.000000] percpu: Embedded 31 pages/cpu s86840 r8192 d31944 u126976
[    0.000000] Detected VIPT I-cache on CPU0
[    0.000000] CPU features: detected: GIC system register CPU interface
[    0.000000] CPU features: detected: Virtualization Host Extensions
[    0.000000] CPU features: detected: Qualcomm erratum 1009, or ARM erratum 1289
[    0.000000] CPU features: detected: ARM errata 1165522, 1319367, or 1530923
[    0.000000] alternatives: applying boot alternatives
[    0.000000] Kernel command line: root=UUID=aa648621-8496-41a9-86a4-209afe528c7
[    0.000000] Dentry cache hash table entries: 2097152 (order: 12, 16777216 byt)
[    0.000000] Inode-cache hash table entries: 1048576 (order: 11, 8388608 bytes)
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 4063752
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] software IO TLB: area num 8.
[    0.000000] software IO TLB: mapped [mem 0x00000000e8e5d000-0x00000000ece5d00)
[    0.000000] Memory: 15826948K/16513024K available (16512K kernel code, 3318K )
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=8, Nodes=1
[    0.000000] ftrace: allocating 62838 entries in 246 pages
[    0.000000] ftrace: allocated 246 pages with 6 groups
[    0.000000] trace event string verifier disabled
[    0.000000] rcu: Hierarchical RCU implementation.
[    0.000000] rcu:     RCU event tracing is enabled.
[    0.000000]  Rude variant of Tasks RCU enabled.
[    0.000000]  Tracing variant of Tasks RCU enabled.
[    0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 30 jif.
[    0.000000] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
[    0.000000] GICv3: GIC: Using split EOI/Deactivate mode
[    0.000000] GICv3: 480 SPIs implemented
[    0.000000] GICv3: 0 Extended SPIs implemented
[    0.000000] Root IRQ handler: gic_handle_irq
[    0.000000] GICv3: GICv3 features: 16 PPIs
[    0.000000] GICv3: CPU0: found redistributor 0 region 0:0x00000000fe680000
[    0.000000] ITS [mem 0xfe640000-0xfe65ffff]
[    0.000000] GIC: enabling workaround for ITS: Rockchip erratum RK3588001
[    0.000000] ITS@0x00000000fe640000: allocated 8192 Devices @100220000 (indire)
[    0.000000] ITS@0x00000000fe640000: allocated 32768 Interrupt Collections @10)
[    0.000000] ITS: using cache flushing for cmd queue
[    0.000000] ITS [mem 0xfe660000-0xfe67ffff]
[    0.000000] GIC: enabling workaround for ITS: Rockchip erratum RK3588001
[    0.000000] ITS@0x00000000fe660000: allocated 8192 Devices @100250000 (indire)
[    0.000000] ITS@0x00000000fe660000: allocated 32768 Interrupt Collections @10)
[    0.000000] ITS: using cache flushing for cmd queue
[    0.000000] GICv3: using LPI property table @0x0000000100270000
[    0.000000] GIC: using cache flushing for LPI property table
[    0.000000] GICv3: CPU0: using allocated LPI pending table @0x0000000100280000
[    0.000000] rcu: srcu_init: Setting srcu_struct sizes based on contention.
[    0.000000] rockchip_cpuclk_pre_rate_change: Invalid rate : 1100000000 for cpk
[    0.000000] clk: couldn't set armclk_l clk rate to 1100000000 (-16), current 0
Back to top
View user's profile Send private message
erg_samowzbudnik
Apprentice
Apprentice


Joined: 09 Sep 2011
Posts: 229
Location: European sticks

PostPosted: Thu Mar 07, 2024 4:05 pm    Post subject: Reply with quote

It would seem I'm missing a clock driver.

Yet:

CONFIG_CLK_RK3588=y

Hmmm.
Back to top
View user's profile Send private message
erg_samowzbudnik
Apprentice
Apprentice


Joined: 09 Sep 2011
Posts: 229
Location: European sticks

PostPosted: Fri Mar 08, 2024 3:01 pm    Post subject: Reply with quote

Tried with kernel 6.7.9 , same problem.
Back to top
View user's profile Send private message
erg_samowzbudnik
Apprentice
Apprentice


Joined: 09 Sep 2011
Posts: 229
Location: European sticks

PostPosted: Wed Mar 20, 2024 11:47 am    Post subject: Reply with quote

It works now.
Not sure what kernel bits I was missing, got kernel config from:
https://github.com/sarnold/arm64-mainline-linux/releases/tag/6.7.6-arm64-r2

compiled and kernel booted up! But no ethernet ...
Looks like PHY got stuck.

Used mii-tool and ethtool to reset it, rebooted and ethernet works ever since.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo on ARM All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum