R3 mini can not boot from nand

Hello, everyone, my R3 mini can’t be started from nand. Now emmc have the offcial openwrt, I want to burn a new frimware to nand, but when I try to run

mtd erase /dev/mtd

and then show

Could not open /dev/mtd device: device 0

It seems that I can’t do anything about nand. Is there any way to solve it?

NAND is read-only you need to enable read-write first:

opkg install kmod-mtd-rw
insmod mtd-rw.ko i_want_a_brick=1

And now the commands for NAND formatting and flashing like

mtd write /tmp/openwrt-*-bananapi_bpi-r3-mini-snand-preloader.bin /dev/mtd0
ubidetach -m 1
ubiformat /dev/mtd1
ubiattach -m 1
volsize=$(wc -c < /tmp/openwrt-*-bananapi_bpi-r3-mini-snand-bl31-uboot.fip)
ubimkvol /dev/ubi0 -N fip -n 0 -s $volsize -t static
ubiupdatevol /dev/ubi0_0 /tmp/openwrt-*-bananapi_bpi-r3-mini-snand-bl31-uboot.fip

cd /lib/firmware/airoha
cat EthMD32.dm.bin EthMD32.DSP.bin > /tmp/en8811h-fw.bin
ubimkvol /dev/ubi0 -N en8811h-firmware -n 1 -s 147456 -t static
ubiupdatevol /dev/ubi0_1 /tmp/en8811h-fw.bin

ubimkvol /dev/ubi0 -n 2 -N ubootenv -s 126976
ubimkvol /dev/ubi0 -n 3 -N ubootenv2 -s 126976
volsize=$(wc -c < /tmp/openwrt-*-bananapi_bpi-r3-mini-initramfs-recovery.itb)
ubimkvol /dev/ubi0 -n 4 -N recovery -s $volsize
ubiupdatevol /dev/ubi0_4 /tmp/openwrt-*-bananapi_bpi-r3-mini-initramfs-recovery.itb
volsize=$(wc -c < /tmp/openwrt-*-bananapi_bpi-r3-mini-squashfs-sysupgrade.itb)
ubimkvol /dev/ubi0 -n 5 -N fit -s $volsize
ubiupdatevol /dev/ubi0_5 /tmp/openwrt-*-bananapi_bpi-r3-mini-squashfs-sysupgrade.itb
ubimkvol /dev/ubi0 -n 6 -N rootfs_data -m

Obviously the place where you put your firmware files might be different (e.g. not /tmp)