Uboot on pi4: couldn't find a valid ZFS label

Hi all,

Yesterday I finally decided to see if I could migrate my Raspberry Pi 4 off BTRFS onto ZFS. I’m using NixOS which has good support for ZFS.

I would ideally like to be able to use uboot to boot directly from ZFS (like one can do with grub). It seems like this might be possible, as uboot has a CONFIG_CMD_ZFS flag.

I’ve compiled a u-boot with this flag, and I can confirm that with it I have access to commands like zfsls and zfsload that are not present in the uboot shell otherwise, but it doesn’t seem to be actually reading the partition; whenever I run e.g. zfsls usb 0:2 (with 2 being my boot partition, uncompressed, and created with compatibility=grub2), I get an error about "couldn't find a valid ZFS label".

I’ve tried various permutations such as zfsls usb 0:2 / or zfsls usb 0:2 rpool/nixos/root (as well as 0:1, 0:3, etc.) but all produce the same error.

Are there any uboot experts here that have suggestions for how to get this working?

For additional context, I was able to get a successful boot by putting the initrd and such on the Pi’s FAT partition, but I’d much rather have it on a ZFS partition where it can benefit from ZFS superpowers. After some fiddling, I was able to get uboot to boot directly from a BTRFS subvolume (https://github.com/n8henrie/nixos-btrfs-pi) by compiling uboot with CONFIG_CMD_BTRFS, so I’m hopeful this might be possible with ZFS as well.

Thanks in advance for any suggestions!