BPI-R3 fw_setenv can't write fw_env to flash

Does anyone have a working fw_env.conf file for the BPI-R3 (or know what’s going on)? My existing file currently has:

# MTD device name   Device offset   Env. size   Flash sector size  Number of sectors
/dev/mmcblk0p2      0x300000        0x80000

and I am using it with uboot 2024.01 and uboot-tools 2024.01. It works well enough for fw_printenv however if I try to modify the environment I get a write error:

$ fw_setenv test123 asd
Seek error on /dev/mmcblk0p2: Invalid argument
Error: can't write fw_env to flash

Haven’t tried fw_{set,print}env from U-Boot 2014.01 yet, but I can tell you that what is included with U-Boot 2023.07.02 does work fine.

And just to be sure regarding fw_printenv seemingly working fine: Can you double check please that what it displays is really the content of your env and not a default it spits out in case it cannot access it?

Thanks Daniel. Yes, the fw_printenv does work as expected i.e. prints the correct data. I only recently moved to the 2024.01, but was having the same issue on the 2023.10. I am using @frank-w git branch (GitHub - frank-w/u-boot: U-Boot-Bootloader for BananaPI-R2/R64/R2Pro/R3). Are you using some other repo? If yes, maybe you can share that such that I can look for relevant patches.

It is possible that it needs some config option i have not set

Your file-header says mtd device and mmcblk0p2 isn’t a mtd device. On r3 only nand and nor have mtd devices,mmc (emmc+sd) have a gpt.

My uboot is designed to be extended by uEnv.txt on bpi-boot partition.