Uboot install conflict in rock5c image

rock5c板子刷了rock-5c_bookworm_kde_b1.output镜像,

参考 U-boot 开发 | Radxa Docs
#./bsp --no-prepare-source u-boot rk2410 rock-5c -r 999
#sudo dpkg -i u-boot-rk2410_2017.09-999_arm64.deb
错误信息

dpkg: regarding u-boot-rk2410_2017.09-888_arm64.deb containing u-boot-rk2410: u-boot-rk2410 conflicts with u-boot-rk3588 u-boot-rknext provides u-boot-rk3588 and is present and installed.

dpkg: error processing archive u-boot-rk2410_2017.09-888_arm64.deb (–install): conflicting packages - not installing u-boot-rk2410

请问怎么解决,谢谢。

系统启动后的信息,内核显示rk2312 ,不是基线rk2410

rock@rock-5c:~$ uname -a
Linux rock-5c 6.1.43-12-rk2312 #64ff16134 SMP Thu Jun 27 07:32:21 UTC 2024 aarch64 GNU/Linux

Hi,

有解决方案吗,这个应该是个基础的开发环境问题,过了这么长时间都没人回复,太影响口碑了

你好,

这个错误不是 U-Boot 本身的问题,只是 Debian 软件包冲突。

原因

  • 旧镜像 rock-5c_bookworm_kde_b1 里预装的是 u-boot-rknext,它同时 provides 虚拟包 u-boot-rk3588。

  • 新的 u-boot-rk2410 在 bsp 里声明了替换 rk3588(u-boot/rk2410/fork.conf 中的 BSP_REPLACES=("rk3588")),所以与 u-boot-rk3588 冲突。

  • dpkg -i 不会自动卸载冲突的包,所以直接报错退出。

解决方法

用 apt 代替 dpkg -i 来安装本地 deb。apt 会自动卸载 u-boot-rknext,并同时升级元包 u-boot-rock-5c:

sudo apt install ./u-boot-rk2410_2017.09-999_arm64.deb

不要先用 dpkg -r u-boot-rknext 卸载:元包 u-boot-rock-5c 依赖 u-boot-rknext,dpkg 会报 “dependency problems - not removing”。

另外,如果不需要修改 U-Boot 源码,其实不用自己编译。u-boot-rk2410 已经在 Radxa 的 apt 源里了:

sudo apt update
sudo apt install u-boot-rk2410

顺便说明为什么旧镜像执行 apt upgrade 之后仍然是 rknext:切换到 rk2410 需要卸载 u-boot-rknext,所以 apt upgrade 会把 u-boot-rock-5c 列为 “kept back”。用 apt full-upgrade 才会切换。

注意:

  1. 卸载 u-boot-rknext 只会删除 /usr/lib/u-boot/... 下的文件,已经写在存储设备开头的 U-Boot 不会被动,所以不会因此无法启动。

  2. 安装 deb 并不会自动刷写 U-Boot(这个包没有 postinst 脚本)。需要再执行 sudo rsetup → System → Bootloader Management → Update Bootloader 才会真正写入。菜单名以 rsetup 0.4.27 为准,旧版本可能略有不同。

  3. ROCK 5C 没有 SPI flash,U-Boot 写在 SD 卡 / eMMC 的开头。如果自己编译的 U-Boot 起不来,只能在别的电脑上重新烧录镜像恢复,建议先备份。

  4. 你编译时用的是 -r 999,但报错信息里是 2017.09-888,请确认安装的是刚编译出来的那个 deb。

关于内核显示 rk2312

U-Boot 和内核是两个独立的包,换成 rk2410 的 U-Boot 之后 uname 仍然会是 rk2312。 我自己的 ROCK 5C 上 U-Boot 一直是 u-boot-rknext 2017.09-32,内核是 6.1.84-8-rk2410,运行正常。 所以如果目的是基于 rk2410 基线开发,不一定需要更换 U-Boot:只升级内核,或者直接烧录带 rk2410 内核的新版官方镜像会更简单。

希望对你有帮助。

—

Hi,

This isn’t a problem with U-Boot itself — it’s just a Debian package conflict.

Cause

  • The older image rock-5c_bookworm_kde_b1 ships with u-boot-rknext, which also provides the virtual package u-boot-rk3588.

  • The newer u-boot-rk2410 is declared in the bsp as replacing rk3588 (BSP_REPLACES=("rk3588") in u-boot/rk2410/fork.conf), so it conflicts with u-boot-rk3588.

  • dpkg -i never removes a conflicting package by itself, so it just stops with that error.

Fix

Install the local deb with apt instead of dpkg -i. apt removes u-boot-rknext for you and upgrades the meta package u-boot-rock-5c at the same time:

sudo apt install ./u-boot-rk2410_2017.09-999_arm64.deb

Don’t try to remove it first with dpkg -r u-boot-rknext: the meta package u-boot-rock-5c depends on u-boot-rknext, so dpkg refuses with “dependency problems - not removing”.

Also, unless you need to modify the U-Boot source, you don’t have to build it yourself. u-boot-rk2410 is already in Radxa’s apt repository:

sudo apt update
sudo apt install u-boot-rk2410

This is also why the old image stays on rknext after apt upgrade: switching to rk2410 requires removing u-boot-rknext, so apt upgrade keeps u-boot-rock-5c back. apt full-upgrade will do the switch.

Notes:

  1. Removing u-boot-rknext only deletes the files under /usr/lib/u-boot/.... The U-Boot already written at the start of your boot media is left untouched, so this step alone won’t make the board unbootable.

  2. Installing the deb does not flash U-Boot (the package has no postinst script). To actually write it, run sudo rsetup → System → Bootloader Management → Update Bootloader. These menu names are from rsetup 0.4.27; older versions may differ slightly.

  3. The ROCK 5C has no SPI flash, so U-Boot lives at the start of the SD card / eMMC. If your self-built U-Boot doesn’t boot, the only way back is to re-flash the image from another PC, so make a backup first.

  4. You built with -r 999, but the error message shows 2017.09-888. Please make sure you’re installing the deb you just built.

About the kernel showing rk2312

U-Boot and the kernel are separate packages, so uname will still show rk2312 after you switch U-Boot to rk2410. On my own ROCK 5C, U-Boot is still u-boot-rknext 2017.09-32 and the kernel is 6.1.84-8-rk2410, and it runs fine. So if your goal is to work on the rk2410 baseline, you don’t necessarily need to replace U-Boot: just upgrade the kernel, or flash a newer official image that already ships the rk2410 kernel.

Hope this helps.

谢谢答复。目前需要修改u-boot,代码是https://github.com/radxa-repo/bsp.git,编译命令 ./bsp --no-prepare-source u-boot rk2410 rock-5c,有说明办法可以安装到板子上的emmc分区,并让系统启动后可以加载这个自己编译的u-boot.itb呢,试过dd命令,启动后还是老的rknext.

.已经解决了 /dev/mmcblk0 代表emmc模组,sd卡没有试过是否可行。

sudo dd if=idbloader.img of=/dev/mmcblk0 bs=512 seek=64 conv=notrunc,fsync

sudo dd if=u-boot.itb of=/dev/mmcblk0 bs=512 seek=16384 conv=notrunc,fsync

sudo sync

解决了就好!补充几点,供以后搜到这个帖子的人参考。

为什么之前 dd 了还是 rknext

我看了官方 u-boot-rk2410(2017.09-66)里 rock-5c 的 idbloader.img,SPL 设备树里的启动顺序是:

u-boot,spl-boot-order = mmc@fe2c0000 (SD) → SPI → mmc@fe2e0000 (eMMC)

也就是说,即使 SPL 是从 eMMC 加载的,只要插着带系统镜像的 SD 卡,SPL 也会优先加载 SD 卡上的 u-boot.itb。所以如果当时插着旧镜像的 SD 卡,或者 dd 写到了 SD 卡上,看到的就还是旧的 rknext。

先确认哪个设备是 eMMC

grep -H . /sys/block/mmcblk*/device/type    # MMC = eMMC,SD = SD 卡

确认写进去的确实是自己编译的版本

# SPL 的版本和编译时间(SD 卡也可以这样查,看看上面有没有旧的 loader)
sudo dd if=/dev/mmcblk0 bs=512 skip=64 count=1024 status=none | grep -a -o "U-Boot SPL [[:print:]]*"

# 逐字节比对
sudo cmp -n $(stat -c%s idbloader.img) idbloader.img /dev/mmcblk0 0 $((64*512))    && echo "idbloader OK"
sudo cmp -n $(stat -c%s u-boot.itb)    u-boot.itb    /dev/mmcblk0 0 $((16384*512)) && echo "u-boot.itb OK"

SD 卡

偏移完全相同(idbloader 在 sector 64,u-boot.itb 在 sector 16384),只要把 of= 换成 SD 卡的设备即可(用上面的命令确认,通常是 /dev/mmcblk1)。
官方包里的脚本做的也是同样的事,安装自己编译的 deb 之后可以直接用:

sudo /usr/lib/u-boot/rock-5c/setup.sh update_bootloader /dev/mmcblk0

变砖时怎么恢复(更正我上次的说法)

如果 eMMC 上自己编译的 SPL 起不来,BootROM 不一定会回退到 SD 卡。这时进 Maskrom 模式,用 rkdeveloptool 重新写入即可,不需要换板子。同一个 setup.sh 里也有 maskrom_update_bootloader、maskrom_erase_bootloader 这些函数可以参考。


Glad you got it working! A few notes for anyone who finds this thread later.

Why the earlier dd still booted rknext

I looked at the rock-5c idbloader.img in the official u-boot-rk2410 package (2017.09-66). The boot order in the SPL device tree is:

u-boot,spl-boot-order = mmc@fe2c0000 (SD) → SPI → mmc@fe2e0000 (eMMC)

So even when the SPL itself is loaded from eMMC, if an SD card with an OS image is inserted, the SPL loads u-boot.itb from the SD card first. If an SD card with the old image was in the slot, or the dd went to the SD card, you would still see the old rknext.

Check which device is the eMMC

grep -H . /sys/block/mmcblk*/device/type    # MMC = eMMC, SD = SD card

Check that what you wrote is really your own build

# SPL version and build time (also works on the SD card, to see if an old loader is there)
sudo dd if=/dev/mmcblk0 bs=512 skip=64 count=1024 status=none | grep -a -o "U-Boot SPL [[:print:]]*"

# byte-for-byte check
sudo cmp -n $(stat -c%s idbloader.img) idbloader.img /dev/mmcblk0 0 $((64*512))    && echo "idbloader OK"
sudo cmp -n $(stat -c%s u-boot.itb)    u-boot.itb    /dev/mmcblk0 0 $((16384*512)) && echo "u-boot.itb OK"

SD card

The offsets are the same (idbloader at sector 64, u-boot.itb at sector 16384). Just point of= at the SD card device instead (check it with the command above; usually /dev/mmcblk1).
The script in the official package does exactly the same thing, so after installing your own deb you can simply run:

sudo /usr/lib/u-boot/rock-5c/setup.sh update_bootloader /dev/mmcblk0

Recovering from a bad build (correcting what I said last time)

If a self-built SPL on the eMMC doesn’t boot, the BootROM won’t necessarily fall back to the SD card. In that case, enter Maskrom mode and rewrite it with rkdeveloptool; the board isn’t lost. The same setup.sh has maskrom_update_bootloader and maskrom_erase_bootloader functions you can use as a reference.