Accessing U-Boot env from linux

As I’m using UART0 for a GPS receiver on visionfive2 I wanted to be able to change u-boot related settings from linux without using the serial.
This led me down a rabbit hole to get fw_printenv from the u-boot tools to work.

Before realizing that @strlcat already created a pull request i created my own patch for the jh7110.dtsi

--- arch/riscv/boot/dts/starfive/jh7110_orig.dtsi       2023-04-25 12:18:33.840079960 +0000
+++ arch/riscv/boot/dts/starfive/jh7110.dtsi    2023-04-25 12:21:37.123148082 +0000
@@ -372,13 +372,16 @@
                                        #size-cells = <1>;
                                        spl@0 {
-                                               reg = <0x0 0x40000>;
+                                               reg = <0x0 0x80000>;
+                                       };
+                                       uboot-env@f0000 {
+                                               reg = <0xf0000 0x10000>;
                                        uboot@100000 {
-                                               reg = <0x100000 0x300000>;
+                                               reg = <0x100000 0x400000>;
                                        data@f00000 {
-                                               reg = <0xf00000 0x100000>;
+                                               reg = <0x600000 0x1000000>;

slightly different namings and without the use of the full flash, but essentially the same just inserting siyes and offsets from Boot Address Allocation

Together with the correct /etc/fw_env.config:

# MTD device name       Device offset   Env. size       Flash sector size       Number of sectors
/dev/mtd1               0x0             0x10000

The uboot tools fw_printenv and fw_setenv just work (apt install libubootenv-tool) :partying_face:

Maybe i’m now brave enough to try moving the u-boot serial to uart3…


Deleted, I was the one not understanding/reading properly. Sorry…