BPI-R3 Mini NAND Restore

Are there any chance to restore original firmware to NAND? For the moment I do have working system on emmc and heve issues with OS on NAND.

# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00200000 00020000 "bl2"
mtd1: 07e00000 00020000 "ubi"
# cat /proc/partitions
major minor  #blocks  name
  31        0       2048 mtdblock0
  31        1     129024 mtdblock1
 179        0    7634944 mmcblk0
 179        1        512 mmcblk0p1
 179        2       2048 mmcblk0p2
 179        3       4096 mmcblk0p3
 179        4      32768 mmcblk0p4
 179        5     307200 mmcblk0p5
 259        0       4079 mmcblk0p128
 179        8       4096 mmcblk0boot0
 179       16       4096 mmcblk0boot1
 259        1       8444 fit0
 259        2     291252 fitrw
 254        0      44764 ubiblock0_1

Official manual is telling us that we can use single image to restore NANS content

mtd erase /dev/mtd0
dd if=mtk-bpi-r3mini-NAND-20230719-single-image.bin of=/dev/mtdblock0

but the problem is that /dev/mtdblock0 is RO. Only using USB2TTL nand cam be resorted?

1 Like

Why not install up2date openwrt on nand?

What is that? Im not a big expert in OpenWrt and have a huge gap in knowledge … I just need somehow to have working OS that can start from Nand.

I thought emmc uboot has nand install commands,but it does not seems to

But you can try to do like it is defined in nand environment

https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=package/boot/uboot-mediatek/patches/442-add-bpi-r3-mini.patch;h=5409f7fa0de71ed406727c1d53cc5a1e733afdeb;hb=HEAD#l456

I’m no expert in openwrt too…but if there is a newer system i do not want to install an older one :stuck_out_tongue:

Were able to reinstall to NAND. Here is what I did to do that

#
insmod mtd-rw.ko i_want_a_brick=1

#
mtd erase bl2 && mtd write openwrt-mediatek-filogic-bananapi_bpi-r3-mini-snand-preloader.bin bl2

#
umount /mnt/ubi0* 2> /dev/null
ubidetach -p /dev/mtd1 2> /dev/null
mtd erase ubi

#
ubiformat -y /dev/mtd1
ubiattach -p /dev/mtd1

#
ubimkvol /dev/ubi0 -n 0 -N ubootenv -s 128KiB
ubimkvol /dev/ubi0 -n 1 -N ubootenv2 -s 128KiB

# Install uboot
volsize=$(wc -c < openwrt-mediatek-filogic-bananapi_bpi-r3-mini-snand-bl31-uboot.fip)
ubimkvol /dev/ubi0 -N fip -n 2 -s $volsize -t static && \
ubiupdatevol /dev/ubi0_2 openwrt-mediatek-filogic-bananapi_bpi-r3-mini-snand-bl31-uboot.fip

# Install en8811h-fw
cat /lib/firmware/airoha/EthMD32.dm.bin /lib/firmware/airoha/EthMD32.DSP.bin > ./en8811h-fw.bin
volsize=$(wc -c < openwrt-mediatek-filogic-bananapi_bpi-r3-mini-snand-bl31-uboot.fip)
ubimkvol /dev/ubi0 -N en8811h-fw -n 3 -s $volsize -t static && \
ubiupdatevol /dev/ubi0_3 /tmp/en8811h-fw.bin

# Install recovery
volsize=$(wc -c < openwrt-mediatek-filogic-bananapi_bpi-r3-mini-initramfs-recovery.itb)
ubimkvol /dev/ubi0 -n 4 -N recovery -s $volsize && \
ubiupdatevol /dev/ubi0_4 openwrt-mediatek-filogic-bananapi_bpi-r3-mini-initramfs-recovery.itb

# Install system
volsize=$(wc -c < openwrt-mediatek-filogic-bananapi_bpi-r3-mini-squashfs-sysupgrade.itb)
ubimkvol /dev/ubi0 -n 5 -N fit -s $volsize && \
ubiupdatevol /dev/ubi0_5 openwrt-mediatek-filogic-bananapi_bpi-r3-mini-squashfs-sysupgrade.itb

# Create rootfs_data partition
ubimkvol /dev/ubi0 -n 6 -N rootfs_data -m

Have you used UART-USB in your solution to this problem?

Nope. I did this from emmc OS as it was alive