ericwoud
(Eric W.)
September 26, 2025, 9:42am
63
This is defined in the devicetree of the system that is booting. Not sure if this is the same on the openwrt version you want to use.
Also in this devicetree, this partition is set as read-only. You’ll need to remove this from the dts, or write to the partition from U-Boot
Also, if you want to write to mtd on linux, the dts may be missing properties to nand, which I don’t know if @frank-w added that to the dts in the Ubuntu image you are using. See:
I haven’t really used nand before, so I thought, give it a try, writing to nand from linux.
[root@bpir3 ~]# cat /boot/dtbos/nand-enable.dts
/dts-v1/;
/plugin/;
&spi0 {
#address-cells = <1>;
#size-cells = <0>;
spi_nand: flash@0 {
compatible = "spi-nand";
reg = <0>;
spi-max-frequency = <10000000>;
spi-tx-buswidth = <4>;
spi-rx-buswidth = <4>;
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
partition@0…
frank-w
(Frank W.)
September 26, 2025, 10:29am
64
For R3 i have not added mtd partitions afaik
ericwoud
(Eric W.)
September 26, 2025, 10:35am
65
Here you have the partitions.
/* SPDX-License-Identifier: (GPL-2.0-only OR MIT) */
/*
* Authors: Daniel Golle <[email protected] >
* Frank Wunderlich <[email protected] >
*/
/dts-v1/;
/plugin/;
/ {
compatible = "bananapi,bpi-r3", "mediatek,mt7986a";
};
&{/soc/spi@1100a000} {
#address-cells = <1>;
#size-cells = <0>;
spi_nand: flash@0 {
compatible = "spi-nand";
reg = <0>;
This file has been truncated. show original
Including the read-only property.
Edit:
In some cases I saw you also added the ubi-volumes to the dts(o). That I believe is abundant, as the setup of the ubi-volumes is already stored on the ubi-partition. Also defining them in the dts(o) would be the second definition of the ubi-volumes and, when not corresponding, may lead to errors.
brucerry
(bruce)
September 26, 2025, 11:26am
66
The desired Openwrt devicetree partition is different to that of my NAND partition. It should be the same as the Openwrt NOR:
root@OpenWrt:/# cat proc/mtd
dev: size erasesize name
mtd0: 00040000 00010000 "BL2"
mtd1: 00010000 00010000 "u-boot-env"
mtd2: 000b0000 00010000 "Factory"
mtd3: 00080000 00010000 "FIP"
mtd4: 00e00000 00010000 "firmware"
root@OpenWrt:/#
Previously, I flashed Openwrt single-image to the NOR /dev/mtdblock0
which should be referring to the “BL2”, right?
Do you have experience on flashing Openwrt images to NAND from u-boot?
ericwoud
(Eric W.)
September 26, 2025, 11:40am
67
No I try to always use linux
brucerry
(bruce)
September 26, 2025, 11:58am
68
I have just re-flashed the entire NAND with Openwrt single image from u-boot. It does work.
BPI-R3> run useusb
USB is stopped. Please issue 'usb start' first.
starting USB...
xhci-mtk xhci@11200000: hcd: 0x0000000011200000, ippc: 0x0000000011203e00
xhci-mtk xhci@11200000: ports disabled mask: u3p-0x0, u2p-0x0
xhci-mtk xhci@11200000: u2p:2, u3p:1
Register 300010f NbrPorts 3
Starting the controller
USB XHCI 1.10
Bus xhci@11200000: 3 USB Device(s) found
scanning usb for storage devices... 1 Storage Device(s) found
System Volume Information/
200072 bl2_emmc.img
17408 gpt_emmc_100m6g.img
16546559 rootfs_arm64.cpio.zst
27956672 mtk-bpi-r3-NOR-WAN1-RJ45-20220720-single-image.bin
69584284 mtk-bpi-r3-EMMC-WAN1-RJ45-20220720-single-image.img
38666240 mtk-bpi-r3-NAND-WAN1-RJ45-20220720-single-image.bin
9699328 openwrt-mediatek-filogic-bananapi_bpi-r3-initramfs-recovery.itb
9518220 bpi-r3.itb
99280305 bpi-r3_6.12.47-main.tar.gz
7865152 bpi-r3_emmc.img.gz
200793 bpi-r3_emmc_bl2.img
280749 bpi-r3_emmc_fip.bin
727753804 bpi-r3_noble_6.12.47-main_sdmmc.img.gz
209616 bpi-r3_spim-nand_bl2.img
279581 bpi-r3_spim-nand_fip.bin
WAP7633/
15 file(s), 2 dir(s)
BPI-R3> mtd list
jedec_spi_nor spi_nor@0: unrecognized JEDEC id bytes: ff, ef, aa
List of MTD devices:
* spi-nand0
- device: spi_nand@1
- parent: spi@1100a000
- driver: spi_nand
- path: /spi@1100a000/spi_nand@1
- type: NAND flash
- block size: 0x20000 bytes
- min I/O: 0x800 bytes
- OOB size: 64 bytes
- OOB available: 24 bytes
- 0x000000000000-0x000008000000 : "spi-nand0"
- 0x000000000000-0x000000080000 : "bl2"
- 0x000000080000-0x000000380000 : "factory"
- 0x000000380000-0x000000580000 : "fip"
- 0x000000580000-0x000008000000 : "ubi"
BPI-R3> mtd erase spi-nand0
jedec_spi_nor spi_nor@0: unrecognized JEDEC id bytes: ff, ef, aa
Erasing 0x00000000 ... 0x07ffffff (1024 eraseblock(s))
BPI-R3> fatload usb 0:1 $loadaddr mtk-bpi-r3-NAND-WAN1-RJ45-20220720-single-image.bin
38666240 bytes read in 2766 ms (13.3 MiB/s)
BPI-R3> mtd write spi-nand0 $loadaddr 0x0 0x8000000
jedec_spi_nor spi_nor@0: unrecognized JEDEC id bytes: ff, ef, aa
Writing 134217728 byte(s) (65536 page(s)) at offset 0x00000000
BPI-R3>