how does your dts/dtb look like? i’ve seen i upstreamed only the bl2 mtd partition to now break anything. But some of my trees defining the ubi-partition something like this:
partition@200000 {
label = "ubi";
reg = <0x200000 0x7e00000>;
compatible = "linux,ubi";
volumes {
ubi-volume-ubootenv {
volname = "ubootenv";
nvmem-layout {
compatible = "u-boot,env-redundant-bool-layout";
};
};
ubi-volume-ubootenv2 {
volname = "ubootenv2";
nvmem-layout {
compatible = "u-boot,env-redundant-bool-layout";
};
};
ubi_rootfs: ubi-volume-fit {
volname = "fit";
};
};
};
i guess if i only define the ubi-partition i can freely define the partitions inside it.
do you have enabled additional drivers?
i guess this
uninr=$(cat /proc/mtd | grep '"'ubi'"' | cut -d':' -f1 | tr -d [:alpha:])
ubiformat -y /dev/mtd${ubinr}
formats the complete mtd device, not only the ubi-partition, right? and so erases bl2…how to format only the ubi partition?
or is mtd0=bl2 and mtd1=ubi?
seems like this because i see this:
# hexdump -C /dev/mtd0 | less
00000000 53 50 49 4e 41 4e 44 21 01 00 00 00 10 00 00 00 |SPINAND!........|
# hexdump -C /dev/mtd1 | less
00000000 55 42 49 23 01 00 00 00 00 00 00 00 00 00 00 00 |UBI#............|
now i hang here:
# ubiattach -p /dev/mtd1
[ 847.732271] ubi0: attaching mtd1
[ 848.096639] ubi0: scanning is finished
[ 848.145172] ubi0: attached mtd1 (name "ubi", size 126 MiB)
[ 848.150673] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
[ 848.157590] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
[ 848.164377] ubi0: VID header offset: 2048 (aligned 2048), data offset: 4096
[ 848.171354] ubi0: good PEBs: 1008, bad PEBs: 0, corrupted PEBs: 0
[ 848.177446] ubi0: user volume: 0, internal volumes: 1, max. volumes count: 128
[ 848.184656] ubi0: max/mean erase counter: 0/0, WL threshold: 4096, image sequence number: 505724658
[ 848.193692] ubi0: available PEBs: 984, total reserved PEBs: 24, PEBs reserved for bad PEB handling: 20
[ 848.202996] ubi0: background thread "ubi_bgt0d" started, PID 3691
UBI device number 0, total 1008 LEBs (127991808 bytes, 122.0 MiB), available 984 LEBs (124944384 bytes, 119.1 MiB), LEB size 126976 bytes (124.0 KiB)
# ubidevice="$(basename /sys/class/mtd/mtd1/ubi*)"
root@bpi-r4-v11:~
# echo $ubidevice
ubi0
root@bpi-r4-v11:~
# i=0
# ubimkvol /dev/${ubidevice} -n $i -N fip -s 1MiB -t static
Volume ID 0, size 9 LEBs (1142784 bytes, 1.0 MiB), LEB size 126976 bytes (124.0 KiB), static, name "fip", alignment 1
now trying to flash the images, seems i cannot write directly to mtd0, but imho i set bl2 to readonly in dts
also cannot flash fip via dd to /dev/ubi0_0
root@bpi-r4-v11:~
# ubinfo /dev/ubi0 -N fip
Volume ID: 0 (on ubi0)
Type: static
Alignment: 1
Size: 9 LEBs (1142784 bytes, 1.0 MiB)
Data bytes: 0 bytes
State: OK
Name: fip
Character device major/minor: 242:1
root@bpi-r4-v11:~
# mkdir /tmp/mnt
root@bpi-r4-v11:~
# dd if=/mnt/2025.04/bpi-r4_spim-nand_ubi_fip.bin of=/dev/ubi0_0
dd: writing to '/dev/ubi0_0': Operation not permitted
1+0 records in
0+0 records out
0 bytes copied, 0.00206046 s, 0.0 kB/s
seems like you do this with ubiupdatevol
root@bpi-r4-v11:~
# ubiupdatevol /dev/ubi0_0 /mnt/2025.04/bpi-r4_spim-nand_ubi_fip.bin
runs without error…
wrote bl2 from uboot:
fatload usb 0:1 $loadaddr 2025.04/bpi-r4_spim-nand_ubi_bl2.img
BPI-R4> mtd erase spi-nand0 0x0 0x100000
Erasing 0x00000000 ... 0x000fffff (8 eraseblock(s))
BPI-R4> mtd write spi-nand0 $loadaddr 0x0 0x100000
Writing 1048576 byte(s) (512 page(s)) at offset 0x00000000
looks good so far
F0: 102B 0000
FA: 1042 0000
FA: 1042 0000 [0200]ove, ENTER to select, ESC to quit
F9: 0000 0000
V0: 0000 0000 [0001]
00: 0000 0000
BP: 0600 0041 [0000]
G0: 1190 0000
EC: 0000 0000 [1000]
MK: 0000 0000 [0000]
T0: 0000 01A8 [0101]
Jump to BL
NOTICE: BL2: v2.12.0(release):d50bccad1-bpi-r4-spim-nand
NOTICE: BL2: Built : 08:37:29, Jun 17 2025
NOTICE: WDT: Cold boot
NOTICE: WDT: disabled
NOTICE: CPU: MT7988
NOTICE: EMI: Using DDR unknown settings
NOTICE: EMI: Detected DRAM size: 4096 MB
NOTICE: EMI: complex R/W mem test passed
NOTICE: LVTS: Enable thermal HW reset
NOTICE: SPI_NAND parses attributes from parameter page.
NOTICE: SPI_NAND Detected ID 0xef
NOTICE: Page size 2048, Block size 131072, size 134217728
NOTICE: UBI: scanning [0x200000 - 0x8000000] ...
NOTICE: UBI: scanning is finished
NOTICE: UBI: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
NOTICE: UBI: VID header offset: 2048 (aligned 2048), data offset: 4096
NOTICE: UBI: Volume fip (Id #0) size is 309481 bytes
NOTICE: BL2: Booting BL31
NOTICE: BL31: v2.12.0(release):d50bccad1-bpi-r4-spim-nand
NOTICE: BL31: Built : 08:37:32, Jun 17 2025
U-Boot 2025.04-bpi-g1e7804aaf7e0-dirty (Jun 17 2025 - 08:36:53 +0000)
CPU: MediaTek MT7988
Model: mt7988-rfb
DRAM: 4 GiB
Core: 66 devices, 24 uclasses, devicetree: separate
MMC: mmc@11230000: 0
Loading Environment from nowhere... OK
In: serial@11000000
Out: serial@11000000
Err: serial@11000000
=> board_late_init...
bootmedia:spim-nand
Net: MediaTek MT7988 built-in switch
Warning: ethernet@15110100 (eth0) using random MAC address - 1e:97:0f:f0:b0:bf
eth0: ethernet@15110100
Hit any key to stop autoboot: 0