build icon indicating copy to clipboard operation
build copied to clipboard

Enable BTRFS support in uBoot for Helios64

Open iav opened this issue 1 month ago β€’ 1 comments

I tried enabling BTRFS support in uBoot v2022.07 for Helios64. As was recently done for several other devices, but with a more recent version of uBoot.

All I did was add CONFIG_CMD_BTRFS=y to the uBoot .config file.

However, an image with such uBoot is not loaded, even if it is on ext4.

The simplest conclusion from this is "enabling BTRFS support in this version of uBoot breaks it completely, so just don't do it." However, maybe someone more familiar with uBoot knows that something else is wrong, and this can be fixed very simply? Posting this PR as a question.

Here is the boot log from this image

DDR Version 1.25 20210517
In
channel 0
CS = 0
MR0=0x18
MR4=0x1
MR5=0x1
MR8=0x10
MR12=0x72
MR14=0x72
MR18=0x0
MR19=0x0
MR24=0x8
MR25=0x0
channel 1
CS = 0
MR0=0x18
MR4=0x1
MR5=0x1
MR8=0x10
MR12=0x72
MR14=0x72
MR18=0x0
MR19=0x0
MR24=0x8
MR25=0x0
channel 0 training pass!
channel 1 training pass!
change freq to 416MHz 0,1
Channel 0: LPDDR4,416MHz
Bus Width=32 Col=10 Bank=8 Row=16 CS=1 Die Bus-Width=16 Size=2048MB
Channel 1: LPDDR4,416MHz
Bus Width=32 Col=10 Bank=8 Row=16 CS=1 Die Bus-Width=16 Size=2048MB
256B stride
channel 0
CS = 0
MR0=0x18
MR4=0x1
MR5=0x1
MR8=0x10
MR12=0x72
MR14=0x72
MR18=0x0
MR19=0x0
MR24=0x8
MR25=0x0
channel 1
CS = 0
MR0=0x18
MR4=0x1
MR5=0x1
MR8=0x10
MR12=0x72
MR14=0x72
MR18=0x0
MR19=0x0
MR24=0x8
MR25=0x0
channel 0 training pass!
channel 1 training pass!
channel 0, cs 0, advanced training done
channel 1, cs 0, advanced training done
change freq to 856MHz 1,0
ch 0 ddrconfig = 0x101, ddrsize = 0x40
ch 1 ddrconfig = 0x101, ddrsize = 0x40
pmugrf_os_reg[2] = 0x32C1F2C1, stride = 0xD
ddr_set_rate to 328MHZ
ddr_set_rate to 666MHZ
ddr_set_rate to 928MHZ
channel 0, cs 0, advanced training done
channel 1, cs 0, advanced training done
ddr_set_rate to 416MHZ, ctl_index 0
ddr_set_rate to 856MHZ, ctl_index 1
support 416 856 328 666 928 MHz, current 856MHz
OUT

U-Boot SPL 2022.07_armbian-2022.07-Se092-P3fcd-Hee64-V0d63-Bbf55-R448a (Dec 10 2025 - 01:57:34 +0000)
Trying to boot from MMC1
NOTICE:  BL31: v2.13.0(release):armbian
NOTICE:  BL31: Built : 18:55:15, Oct 27 2025
INFO:    GICv3 with legacy support detected.
INFO:    ARM GICv3 driver initialized in EL3
INFO:    Maximum SPI INTID supported: 287
INFO:    plat_rockchip_pmu_init(1624): pd status 3e
INFO:    BL31: Initializing runtime services
INFO:    BL31: Preparing for EL3 exit to normal world
INFO:    Entry point address = 0x200000
INFO:    SPSR = 0x3c9


U-Boot 2022.07_armbian-2022.07-Se092-P3fcd-Hee64-V0d63-Bbf55-R448a (Dec 10 2025 - 01:57:34 +0000)

SoC: Rockchip rk3399
Reset cause: POR
DRAM:  initcall sequence 00000000002a8900 failed at call 00000000002037e0 (err=-19)
### ERROR ### Please RESET the board ###

iav avatar Dec 10 '25 04:12 iav

[!IMPORTANT]

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The PR refactors Helios64 board U-Boot Btrfs support handling by removing btrfs from the ROOTFS_TYPE conditional and introducing a dedicated pre-config function that explicitly enables CONFIG_CMD_BTRFS in the U-Boot configuration file.

Changes

Cohort / File(s) Summary
Helios64 board configuration
config/boards/helios64.conf
Modified ROOTFS_TYPE conditional to exclude btrfs (narrowing condition to f2fs, nilfs2, nfs, xfs); added new pre_config_uboot_target__helios64_patch_enable_btrfs() function to insert/update CONFIG_CMD_BTRFS=y in U-Boot configs and output unified diff of changes

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Single configuration file modification with straightforward conditional removal
  • New function follows clear, predictable pattern for board-specific U-Boot configuration
  • Changes are self-contained and have minimal risk surface

Possibly related PRs

  • armbian/build#9010: Implements enabling U-Boot Btrfs support on another Helios board variant with similar CONFIG_CMD_BTRFS configuration logic.
  • armbian/build#8946: Modifies helios64.conf to adjust btrfs handling in boot and U-Boot configuration workflows.
  • armbian/build#8880: Adds board-specific CONFIG_CMD_BTRFS enabling with informational alerts in the U-Boot configuration workflow.

Suggested reviewers

  • igorpecovnik
  • prahal
  • rpardini

Poem

🐰 A filesystem tale for Helios so fair,
Btrfs moved from rootfs care,
Now CONFIG_CMD sings its own song,
Pre-config hops along,
U-Boot tuning, steady and square! 🎯

Pre-merge checks and finishing touches

βœ… Passed checks (3 passed)
Check name Status Explanation
Description Check βœ… Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check βœ… Passed The title 'Enable BTRFS support in uBoot for Helios64' accurately describes the main change: adding CONFIG_CMD_BTRFS=y configuration to U-Boot for the Helios64 board.
Docstring Coverage βœ… Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Dec 10 '25 04:12 coderabbitai[bot]

@coderabbitai review

iav avatar Dec 10 '25 15:12 iav

βœ… Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

coderabbitai[bot] avatar Dec 10 '25 15:12 coderabbitai[bot]

Hmm. Helios64 is an anomaly. The upstream DT is incomplete (compared to Armbian/Kibol's patched) and u-boot for it was never submitted, and Kobol folded before anything got straightened out. There was some activity upstream you can see here https://github.com/torvalds/linux/commits/master/arch/arm64/boot/dts/rockchip/rk3399-kobol-helios64.dts

Your best chance here, I think, is to take the add-board-helios64.patch (which has all the .c/.h files, DT, and the defconfig) and try to adapt it to a more recent u-boot version, then bump it.

Alternatively: if fancy u-boot stuff (boot from pcie, net, usb) not strictly required for Helios64, maybe the recently introduced generic-rk3399_defconfig can be a replacement?

rpardini avatar Dec 10 '25 18:12 rpardini

I am not going to talk about the hardware side of things, @rpardini has already spoken to that and unlike me he is an expert there. But instead of reinventing the wheel may I attempt to get you interested to leverage the uboot-btrfs extension to actually enable the support in line with #9012, @iav ?

@djurny Do you have anything to add? You're the u-boot guy that I'm aware of and I know you also have and care about the Helios64.

leggewie avatar Dec 10 '25 19:12 leggewie

But instead of reinventing the wheel may I attempt to get you interested to leverage the uboot-btrfs extension to actually enable the support in line with #9012, @iav ?

In fact, that's exactly what I'm doing. However, "just turn on that extension" for Helios64 is not possible, because with its version of uBoot, this simply does not work. So in this PR, I do the same thing as your extension, just in the way that is suitable for uBoot v22.07. Unfortunately, as a result, I ended up with an unusable uBoot. Then I ask for help.

And now I will follow rpardinis's recommendations. In case of success I will report there :)

iav avatar Dec 10 '25 20:12 iav

Thank you, @iav

I am happy to augment the uboot-btrfs extension to cover your use case (support for earlier uboot versions). But I understand you first have to iron out the general issues with uboot and btrfs on the Helios64. Let's hope @djurny finds the time to look into it. I have the feeling he would have it up and running fairly quickly.

leggewie avatar Dec 11 '25 23:12 leggewie

Oh, my. There are changed APIs.

iav avatar Dec 12 '25 16:12 iav

@iav: any success with generic-rk3399_defconfig ? I heard good things recently (eMMC/SD boot working fine on an unrelated board).

rpardini avatar Dec 15 '25 20:12 rpardini

@iav: any success with generic-rk3399_defconfig ? I heard good things recently (eMMC/SD boot working fine on an unrelated board).

this hole very deep for me. some functions from helios64.c became private in uBoot, so I just turned off the part of the code where they were used. I borrowed function post_family_config__rk3566_box_demo_use_mainline_uboot () 'from config/boards/rk3566-box-demo.csc' and at the moment I stopped at an image build error if build without patches

[🐳|🌱] Preparing u-boot bootloader [ LOOP=/dev/loop0 - /armbian/output/debs/linux-u-boot-helios64-edge_26.02.0-trunk_arm64__2025.10-Se50b-P0eb7-H272d-Vef0d-Bbf55-R448a.deb ]
[🐳|🌱] Sourcing u-boot install functions [ /armbian/output/debs/linux-u-boot-helios64-edge_26.02.0-trunk_arm64__2025.10-Se50b-P0eb7-H272d-Vef0d-Bbf55-R448a.deb ]
[🐳|🌱] Writing u-boot bootloader [ /dev/loop0 ]
dd: failed to open '/armbian/.tmp/work-8f9f2c80-5786-45c5-b090-2099a2e2e342/uboot-write-5of0F/usr/lib/linux-u-boot-edge-helios64/u-boot-rockchip.bin': No such file or directory

If I use generic-rk3399_defconfig (have to copy into helios64-rk3399_defconfig to add CONFIG_OF_UPSTREAM=y) then building error are

 /usr/bin/aarch64-linux-gnu-ld: invalid length for memory region .sram
...
Writing u-boot bootloader [ /dev/loop0 ]
dd: failed to open '/armbian/.tmp/work-97af6db2-dbd2-48c8-8464-aa544832e3da/uboot-write-v6U4X/usr/lib/linux-u-boot-edge-helios64/u-boot-rockchip.bin': No such file or directory

there are a lot of changes in the process of making loader, and I haven't figured out how it should work at all.

current workset https://github.com/armbian/build/compare/main...iav:armbian:helios64_uboot_upgrade?expand=1

iav avatar Dec 15 '25 22:12 iav

Builded somethhing that booted up to uboot prompt. with generic-rk3399_defconfig β†’ helios64-rk3399_defconfig and

CONFIG_DEFAULT_DEVICE_TREE="rockchip/rk3399-kobol-helios64"
CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-generic.dtb"
CONFIG_OF_UPSTREAM=y
CONFIG_TPL=n
CONFIG_SPL=y
CONFIG_SPL_BINMAN=y

and upstream dtbs

ch 0 ddrconfig = 0x101, ddrsize = 0x40
ch 1 ddrconfig = 0x101, ddrsize = 0x40
pmugrf_os_reg[2] = 0x32C1F2C1, stride = 0xD
ddr_set_rate to 328MHZ
ddr_set_rate to 666MHZ
ddr_set_rate to 928MHZ
channel 0, cs 0, advanced training done
channel 1, cs 0, advanced training done
ddr_set_rate to 416MHZ, ctl_index 0
ddr_set_rate to 856MHZ, ctl_index 1
support 416 856 328 666 928 MHz, current 856MHz
OUT

U-Boot SPL 2026.01-rc4_armbian-2026.01-rc4-S0e0a-Pd56f-Hbed3-V7c2d-Bbf55-R448a (Dec 14 2025 - 22:54:04 +0000)
Trying to boot from MMC2
## Checking hash(es) for config config-1 ... OK
## Checking hash(es) for Image atf-1 ... sha256+ OK
## Checking hash(es) for Image u-boot ... sha256+ OK
## Checking hash(es) for Image fdt-1 ... sha256+ OK
## Checking hash(es) for Image atf-2 ... sha256+ OK
## Checking hash(es) for Image atf-3 ... sha256+ OK
ERROR:   not expected type found -1124772903431303728
DDR Version 1.25 20210517
In
channel 0
CS = 0
MR0=0x18
MR4=0x1
MR5=0x1
MR8=0x10
MR12=0x72
MR14=0x72
MR18=0x0
MR19=0x0
MR24=0x8
MR25=0x0
channel 1
CS = 0
MR0=0x18
MR4=0x1
MR5=0x1
MR8=0x10
MR12=0x72
MR14=0x72
MR18=0x0
MR19=0x0
MR24=0x8
MR25=0x0
channel 0 training pass!
channel 1 training pass!
change freq to 416MHz 0,1
Channel 0: LPDDR4,416MHz
Bus Width=32 Col=10 Bank=8 Row=16 CS=1 Die Bus-Width=16 Size=2048MB
Channel 1: LPDDR4,416MHz
Bus Width=32 Col=10 Bank=8 Row=16 CS=1 Die Bus-Width=16 Size=2048MB
256B stride
channel 0
CS = 0
MR0=0x18
MR4=0x1
MR5=0x1
MR8=0x10
MR12=0x72
MR14=0x72
MR18=0x0
MR19=0x0
MR24=0x8
MR25=0x0
channel 1
CS = 0
MR0=0x18
MR4=0x1
MR5=0x1
MR8=0x10
MR12=0x72
MR14=0x72
MR18=0x0
MR19=0x0
MR24=0x8
MR25=0x0
channel 0 training pass!
channel 1 training pass!
channel 0, cs 0, advanced training done
channel 1, cs 0, advanced training done
change freq to 856MHz 1,0
ch 0 ddrconfig = 0x101, ddrsize = 0x40
ch 1 ddrconfig = 0x101, ddrsize = 0x40
pmugrf_os_reg[2] = 0x32C1F2C1, stride = 0xD
ddr_set_rate to 328MHZ
ddr_set_rate to 666MHZ
ddr_set_rate to 928MHZ
channel 0, cs 0, advanced training done
channel 1, cs 0, advanced training done
ddr_set_rate to 416MHZ, ctl_index 0
ddr_set_rate to 856MHZ, ctl_index 1
support 416 856 328 666 928 MHz, current 856MHz
OUT

U-Boot SPL 2025.10_armbian-2025.10-Se50b-Pc6ec-H272d-Vd559-Bbf55-R448a (Dec 16 2025 - 05:26:36 +0000)
Trying to boot from MMC2
## Checking hash(es) for config config-1 ... OK
## Checking hash(es) for Image atf-1 ... sha256+ OK
## Checking hash(es) for Image u-boot ... sha256+ OK
## Checking hash(es) for Image fdt-1 ... sha256+ OK
## Checking hash(es) for Image atf-2 ... sha256+ OK
## Checking hash(es) for Image atf-3 ... sha256+ OK
NOTICE:  BL31: v1.3(release):845ee93
NOTICE:  BL31: Built : 15:51:11, Jul 22 2020
NOTICE:  BL31: Rockchip release version: v1.1
INFO:    GICv3 with legacy support detected. ARM GICV3 driver initialized in EL3
INFO:    Using opteed sec cpu_context!
INFO:    boot cpu mask: 0
INFO:    plat_rockchip_pmu_init(1196): pd status 3e
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 opteed_fast
INFO:    BL31: Preparing for EL3 exit to normal world
INFO:    Entry point address = 0x200000
INFO:    SPSR = 0x3c9
ns16550_serial serial@ff1a0000: pinctrl_select_state_full: uclass_get_device_by_phandle_id: err=-19


U-Boot 2025.10_armbian-2025.10-Se50b-Pc6ec-H272d-Vd559-Bbf55-R448a (Dec 16 2025 - 05:26:36 +0000)

Model: Kobol Helios64
DRAM:  4 GiB (total 3.9 GiB)
Core:  257 devices, 24 uclasses, devicetree: separate
Warning: Device tree includes old 'u-boot,dm-' tags: please fix by 2023.07!
MMC:   mmc@fe320000: 1, mmc@fe330000: 0
Loading Environment from nowhere... OK
In:    serial@ff1a0000
Out:   serial@ff1a0000
Err:   serial@ff1a0000
Hit any key to stop autoboot:  0
Scanning for bootflows in all bootdevs
Seq  Method       State   Uclass    Part  Name                      Filename
---  -----------  ------  --------  ----  ------------------------  ----------------
Scanning global bootmeth 'efi_mgr':
Cannot persist EFI variables without system partition
  0  efi_mgr      ready   (none)       0  <NULL>
** Booting bootflow '<NULL>' with efi_mgr
Loading Boot0000 'mmc 1' failed
Loading Boot0001 'mmc 0' failed
EFI boot manager: Cannot load any image
Boot failed (err=-14)
Scanning bootdev '[email protected]':
  1  script       ready   mmc          1  [email protected] /boot.scr
** Booting bootflow '[email protected]_1' with script
Boot script loaded from mmc 1:1
131 bytes read in 2 ms (63.5 KiB/s)
30074594 bytes read in 1272 ms (22.5 MiB/s)
43723264 bytes read in 1849 ms (22.6 MiB/s)
Failed to load '/dtb/rockchip/rk3399-generic.dtb'
libfdt fdt_check_header(): FDT_ERR_BADMAGIC
No FDT memory address configured. Please configure
the FDT address via "fdt addr <address>" command.
Aborting!
2825 bytes read in 7 ms (393.6 KiB/s)
Applying kernel provided DT fixup script (rockchip-fixup.scr)
## Executing script at 09000000
Trying kaslrseed command... Info: Unknown command can be safely ignored since kaslrseed does not apply to all boards.
Unknown command 'kaslrseed' - try 'help'
## Loading init Ramdisk from Legacy Image at 12180000 ...
   Image Name:   uInitrd
   Image Type:   AArch64 Linux RAMDisk Image (gzip compressed)
   Data Size:    30074530 Bytes = 28.7 MiB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK
ERROR: Did not find a cmdline Flattened Device Tree
Could not find a valid device tree
Boot failed (err=-14)
Scanning bootdev '[email protected]':
Unknown uclass 'nvme' in label
Unknown uclass 'scsi' in label
Unknown uclass 'pxe' in label
Unknown uclass 'dhcp' in label
No more bootdevs
---  -----------  ------  --------  ----  ------------------------  ----------------
(2 bootflows, 2 valid)
=>

iav avatar Dec 16 '25 06:12 iav