frank-w
(Frank W.)
May 24, 2026, 6:15am
41
How exactly do you apply the overlay without recompiling the fit/itb? Is it exactly the overlay i’ve posted above?
or do you manually modify dt and use different adresse by hacking into the bootm-chain (like described here )?
fdt set /chosen u-boot,bootconf $bootconf#$bootconf_emmc#$bootconf_extra
only with the reg entry instead of choosen node
Yes first boot has the errors in uboot as initialization of ubi is done in linux later and only next bootup is clean.
The 2m missing are for the bl2 partition,so ubi is 2m less than nand size.
And yes,please make issue on openwrt and link to here for solution…maybe there is another way
I needed to keep it simple so I recompiled everything, not following @czo ’s suggestion.
I made your update to build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_filogic/linux-6.18.28/arch/arm64/boot/dts/mediatek/mt7988a-bananapi-bpi-r4.dtsi
… changing [email protected] = <0x200000 0xfe00000>.
Afterwards I flashed the sdcard with the new openwrt-mediatek-filogic-bananapi_bpi-r4-sdcard_8g.img and took it from there.
I hope that answers your question.
frank-w
(Frank W.)
May 24, 2026, 2:48pm
43
ok, but this is only temporary quick&dirty change…when you do a clean build this gets lost…
so now we know that it fixes the issue you have and we need to think about it how to make it right. I try to make a PR with the overlay, but i’m no expert with the openwrt build-system.
added the overlay here:
can you test it please?
you can apply the overlay by setting bootconf_extra=mt7988a-bananapi-bpi-r4-nand in uboot environment
Please erase your nand before and then bootup sd with the overlay active
Happy to test it. I don’t know how though.
I’ve cloned your repo. I see the bootconf_extra parameter in /package/boot/uboot-mediatek/patches/450-add-bpi-r4.patch do I just set that? or is it a command I need to run?
frank-w
(Frank W.)
May 25, 2026, 7:37am
45
either
setenv bootconf_extra mt7988a-bananapi-bpi-r4-nand
saveenv
Or using fw_setenv in linux
You can also patch the env file in source,but you have to use the right file (sdmmc) or all.
As it happens my system doesn’t have setenv or fw_setenv. NOTE these aren’t advertised in the apt repositories. Consequently I just did export bootconf_extra=mt7988a-bananapi-bpi-r4-nand.
Your repo compiled but I couldn’t see anything about the patch in,
$ make -j1 V=s > makedump && grep -E "bpi-r4-nand" makedump
Anyhow, it doesn’t look like your build worked,
root@OpenWrt:~# dmesg
[ 1.153758] spi-nand spi0.0: Winbond SPI NAND was found.
[ 1.159073] spi-nand spi0.0: 256 MiB, block size: 128 KiB, page size: 2048, OOB size: 128
[ 1.173815] OF: Bad cell count for /soc/spi@11007000/spi_nand@0/partitions
[ 1.180686] OF: Bad cell count for /soc/spi@11007000/spi_nand@0/partitions
[ 2.140401] OF: Bad cell count for /soc/spi@11007000/spi_nand@0/partitions
[ 2.153269] OF: Bad cell count for /soc/spi@11007000/spi_nand@0/partitions
.
.
.
[ 1.286590] ubi0: default fastmap pool size: 50
[ 1.291118] ubi0: default fastmap WL pool size: 25
[ 1.295905] ubi0: attaching mtd1
[ 2.070253] ubi0: scanning is finished
[ 2.083305] ubi0: attached mtd1 (name "ubi", size 126 MiB)
[ 2.088802] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
[ 2.095667] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
[ 2.102442] ubi0: VID header offset: 2048 (aligned 2048), data offset: 4096
[ 2.109395] ubi0: good PEBs: 1008, bad PEBs: 0, corrupted PEBs: 0
[ 2.115478] ubi0: user volume: 7, internal volumes: 1, max. volumes count: 128
[ 2.122687] ubi0: max/mean erase counter: 2/1, WL threshold: 4096, image sequence number: 0
[ 2.131026] ubi0: available PEBs: 0, total reserved PEBs: 1008, PEBs reserved for bad PEB handling: 40
[ 2.140325] ubi0: background thread "ubi_bgt0d" started, PID 245
root@OpenWrt:~#
But I don’t think my testing skills are up to par.
Happy to take another run at it. If you have any other things you want to try let me know.
frank-w
(Frank W.)
May 25, 2026, 7:30pm
47
Setenv is uboot command,fw_setwnv is from openwrt linux.
You should see the dt overlays applied just before linux starts.
You could dump initramfs.itb with dumpinage -l which overlays are present
$ dumpimage -l bin/targets/mediatek/filogic/openwrt-mediatek-filogic-bananapi_bpi-r4-initramfs-recovery.itb
...
Configuration 5 (mt7988a-bananapi-bpi-r4-nand)
Description: OpenWrt bananapi_bpi-r4 overlay mt7988a-bananapi-bpi-r4-nand
Kernel: unavailable
FDT: fdt-mt7988a-bananapi-bpi-r4-nand
so overlay is there
if your itb also shows this and you have flashed the image, exit the bootmenu and run the setenv command and then the default menuentry (bootmenu shows the menu again). and then post full log as file
I was able to find uboot tools for my distro.
It looks like my compile is missing the crucial overlay.
$ dumpimage -l bin/targets/mediatek/filogic/openwrt-mediatek-filogic-bananapi_bpi-r4-8g-initramfs-recovery.itb
FIT description: ARM64 OpenWrt FIT (Flattened Image Tree)
Created: Tue Oct 21 16:46:13 2025
Image 0 (kernel-1)
Description: ARM64 OpenWrt Linux-6.6.110
Created: Tue Oct 21 16:46:13 2025
.
.
.
Image 5 (fdt-mt7988a-bananapi-bpi-r4-sd)
Description: ARM64 OpenWrt bananapi_bpi-r4-8g device tree overlay mt7988a-bananapi-bpi-r4-sd
Created: Tue Oct 21 16:46:13 2025
Type: Flat Device Tree
Compression: uncompressed
Data Size: 1474 Bytes = 1.44 KiB = 0.00 MiB
Architecture: AArch64
Hash algo: crc32
Hash value: 992dc95a
Hash algo: sha1
Hash value: d8c80e86d46ccac204bdcf81feb9ca2802402042
.
.
.
Configuration 0 (config-mt7988a-bananapi-bpi-r4)
Description: OpenWrt bananapi_bpi-r4-8g
Kernel: kernel-1
Init Ramdisk: initrd-1
FDT: fdt-1
Configuration 1 (mt7988a-bananapi-bpi-r4-emmc)
Description: OpenWrt bananapi_bpi-r4-8g overlay mt7988a-bananapi-bpi-r4-emmc
Kernel: unavailable
FDT: fdt-mt7988a-bananapi-bpi-r4-emmc
Configuration 2 (mt7988a-bananapi-bpi-r4-rtc)
Description: OpenWrt bananapi_bpi-r4-8g overlay mt7988a-bananapi-bpi-r4-rtc
Kernel: unavailable
FDT: fdt-mt7988a-bananapi-bpi-r4-rtc
Configuration 3 (mt7988a-bananapi-bpi-r4-sd)
Description: OpenWrt bananapi_bpi-r4-8g overlay mt7988a-bananapi-bpi-r4-sd
Kernel: unavailable
FDT: fdt-mt7988a-bananapi-bpi-r4-sd
Configuration 4 (mt7988a-bananapi-bpi-r4-wifi-mt7996a)
Description: OpenWrt bananapi_bpi-r4-8g overlay mt7988a-bananapi-bpi-r4-wifi-mt7996a
Kernel: unavailable
FDT: fdt-mt7988a-bananapi-bpi-r4-wifi-mt7996a
Also,
root@OpenWrt:~# dmesg | grep -E 'mtd|nand'
[ 1.170202] spi-nand spi0.0: Winbond SPI NAND was found.
[ 1.175542] spi-nand spi0.0: 256 MiB, block size: 128 KiB, page size: 2048, OOB size: 128
[ 1.556460] OF: Bad cell count for /soc/spi@11007000/spi_nand@0/partitions
[ 1.563336] OF: Bad cell count for /soc/spi@11007000/spi_nand@0/partitions
[ 1.678903] ubi0: attaching mtd1
[ 2.467256] ubi0: attached mtd1 (name "ubi", size 126 MiB)
[ 2.524347] OF: Bad cell count for /soc/spi@11007000/spi_nand@0/partitions
[ 2.537212] OF: Bad cell count for /soc/spi@11007000/spi_nand@0/partitions
Note, I didn’t get any of the original error messages when I booted for whatever reason.
I’m just figuring out what uboot is btw. I will need time to understand the commands I’m running.
frank-w
(Frank W.)
May 27, 2026, 6:37am
49
Are you sure you checked out my nand tree and cleaned the image before building? Look at buildzine of the files (itb when dumping it).
I did not checkout your nand tree.
Do you mean https://github.com/frank-w/u-boot ?
If yes, I cloned the above linked u-boot repo, ran make clean and updated the build.conf file,
$ cat build.conf
uploaduser=$USER
uploadserver=r2
uploaddir=/var/lib/tftp
#board=bpi-r2
#board=bpi-r64
#board=bpi-r2pro
#board=bpi-r3
#board=bpi-r3mini
board=bpi-r4
#board=bpi-r4lite
#board=bpi-r4pro
#device=emmc
device=spi-nand
#device=spi-nor
but ./build.sh fails early on at …
Address in memory to use by default (SYS_LOAD_ADDR) [] (NEW)
I ran menuconfig (without making any changes) just to generate a .config file.
The build still fails as above… all assuming I’m in the right place doing the right things.
That said, even after a successful build I’m not sure how to mix the “nand tree” with an openwrt build. Sorry, my compling knowledge is pretty basic. I want to test this but I’ll need some “hand holding” if you have the time.
frank-w
(Frank W.)
May 28, 2026, 1:28am
51
We are talking about openwrt…my uboot repo is standalone
Please clone my openwrt repo and switch to the bpi-r4-nand branch
Then make menuconfig,select board and your packages and then make to build
Thanks, I have it now.
before fw_setenv bootconf_extra mt7988a-bananapi-bpi-r4-nand
root@OpenWrt:~# dmesg | grep -E 'mtd|nand'
[ 1.180925] spi-nand spi0.0: Winbond SPI NAND was found.
[ 1.186269] spi-nand spi0.0: 256 MiB, block size: 128 KiB, page size: 2048, OOB size: 128
[ 1.294131] ubi0: attaching mtd1
[ 1.686520] ubi0: attached mtd1 (name "ubi", size 126 MiB)
[ 1.956502] FIT: flat_dt sub-image 0x00628000..0x00628112 "fdt-mt7988a-bananapi-bpi-r4-nand" (ARM64 OpenWrt bananapi_bpi-r4 device tree overlay mt7988a-bananapi-bpi-r4-nand)
after…
root@OpenWrt:~# dmesg | grep -E 'nand|mtd'
[ 1.180521] spi-nand spi0.0: Winbond SPI NAND was found.
[ 1.185864] spi-nand spi0.0: 256 MiB, block size: 128 KiB, page size: 2048, OOB size: 128
[ 1.362444] ubi0: attaching mtd1
[ 2.078494] ubi0: attached mtd1 (name "ubi", size 254 MiB)
[ 2.345772] FIT: flat_dt sub-image 0x00628000..0x00628112 "fdt-mt7988a-bananapi-bpi-r4-nand" (ARM64 OpenWrt bananapi_bpi-r4 device tree overlay mt7988a-bananapi-bpi-r4-nand)
That looks like good news to me
Note, there was a lot of missteps getting here. Just to be clear,
dumpimage -l openwrt-mediatek-filogic-bananapi_bpi-r4-initramfs-recovery.itb 22:47:10
FIT description: ARM64 OpenWrt FIT (Flattened Image Tree)
Created: Sun May 24 11:04:31 2026
Image 0 (kernel-1)
Description: ARM64 OpenWrt Linux-6.18.31
Created: Sun May 24 11:04:31 2026
.
.
.
Image 7 (fdt-mt7988a-bananapi-bpi-r4-nand)
Description: ARM64 OpenWrt bananapi_bpi-r4 device tree overlay mt7988a-bananapi-bpi-r4-nand
Created: Sun May 24 11:04:31 2026
Type: Flat Device Tree
Compression: uncompressed
Data Size: 275 Bytes = 0.27 KiB = 0.00 MiB
Architecture: AArch64
Hash algo: crc32
Hash value: 9fc80998
Hash algo: sha1
Hash value: eafc7c33f378a0770c9d7d6445619c9f7ac357dd
Default Configuration: 'config-mt7988a-bananapi-bpi-r4'
Opah!
Thanks for your help and patience.
1 Like
frank-w
(Frank W.)
May 31, 2026, 12:00pm
53
I’ve updated the branch to have the nand overlay set on 8g boards…maybe you can pull latest change and test again?
committed 11:28AM - 31 May 26 UTC
Updated boot commands to include RAM size check and set boot configuration for B… ananapi BPI-R4.
Btw. I’ve noticed that openwrt still uses older version of msize command with the multiplier param (g). I have to update it with newer version to keep compatibility of env when newer uboot is used (2026.04+)
Basicly replace existing patch
committed 09:15PM - 24 Jan 26 UTC
Add command which gets ramsize and write it to env variable.
Signed-off-by: Fra… nk Wunderlich <[email protected] >
Link: https://github.com/openwrt/openwrt/pull/21437
Signed-off-by: Hauke Mehrtens <[email protected] >
with this version:
https://patchwork.ozlabs.org/project/uboot/patch/[email protected] /
Happy to test the build.
You’ll have to walk me through it though. I barely made it through the last build test.
I see your bpi-r4-nand branch with the 4 commits.
No idea how I replace the ‘getting the size of ram’ patch with the ozlabs patch?
Looking at the diffs in https://patchwork.ozlabs.org/project/uboot/patch/[email protected] / … is this a copy/paste kind of operation?
frank-w
(Frank W.)
May 31, 2026, 7:25pm
55
I did already in the branch,but unable to test it currently.basicly i used the existing patchfile,and replaced content with the patch from patchwork
Then updated environment to drop size multiplier and compare to > 8000 instead of =8
root@OpenWrt:~# dmesg | grep -E 'mtd|nand'
[ 1.185206] spi-nand spi0.0: Winbond SPI NAND was found.
[ 1.190521] spi-nand spi0.0: 256 MiB, block size: 128 KiB, page size: 2048, OOB size: 128
[ 1.367078] ubi0: attaching mtd1
[ 2.021279] ubi0: attached mtd1 (name "ubi", size 254 MiB)
[ 2.295916] FIT: flat_dt sub-image 0x00628000..0x00628112 "fdt-mt7988a-bananapi-bpi-r4-nand" (ARM64 OpenWrt bananapi_bpi-r4 device tree overlay mt7988a-bananapi-bpi-r4-nand)
root@OpenWrt:~#
… seems like a win to me.
frank-w
(Frank W.)
June 1, 2026, 7:12am
57
Can you post uart output on which overlays are applied (uboot output after menu)?
btw. started pull-request
openwrt:main ← frank-w:bpi-r4-nand_2
opened 04:53PM - 01 Jun 26 UTC
- Updating the msize command for uboot to the upstream version (merged in 2026.0… 4),
- correct environment for bpi-r4 for the changes (size param dropped) and then
- add nand overlay for 8G BPI-R4 boards (they have 256MB instead of 128MB).