User Tools

Site Tools


bpi_r3_mini:nand

刷写OpenWrt到NAND Flash

1. 所需材料

  1. 杜邦线(用于连接UART)
  2. USB TTL
  3. U盘(FAT32)

2. 解锁mtd

从eMMC启动路由器

2.1 原厂系统

原厂系统为OpenWrt 21, 不支持mt7986, 无法在线安装kmod-mtd-rw, 需要上传mtd-rw-a53-5.4.ko/tmp目录

cp /tmp/mtd-rw-a53-5.4.ko /lib/modules/5.4.171/
insmod mtd-rw-a53-5.4.ko i_want_a_brick=y

2.2 openwrt系统

需要可访问外网

opkg install kmod-mtd-rw
insmod mtd-rw.ko i_want_a_brick=y
modprobe mtd-rw i_want_a_brick=y

3. 刷写NAND Flash

3.1 擦除flash

mtd erase /dev/mtd0

3.2 刷入preloader和uboot

snand-preloaderbl31-uboot上传到/tmp目录

(原厂系统与OpenWrt分区名称大小写不同, 擦除时需要区分大小写)

3.2.1 原厂系统

mtd erase BL2
RRE_LOAD=$(ls /tmp/|grep 'snand-preloader')
mtd write /tmp/${RRE_LOAD} BL2

mtd erase FIP
UBOOT=$(ls /tmp/|grep 'snand-bl31-uboot')
mtd write /tmp/${UBOOT} FIP

3.2.2 openwrt系统

mtd erase bl2
RRE_LOAD=$(ls /tmp/|grep 'snand-preloader')
mtd write /tmp/${RRE_LOAD} bl2

mtd erase fip
UBOOT=$(ls /tmp/|grep 'snand-bl31-uboot')
mtd write /tmp/${UBOOT} fip

4. 重启进入恢复模式刷机

openwrt-mediatek-filogic-bananapi_bpi-r3-mini-squashfs-sysupgrade.itb复制到U盘openwrt文件夹内

重启路由器, 启动时选择0. U-Boot console, 执行下面的操作

        ( ( ( OpenWrt ) ) )  [eMMC]       U-Boot 2023.07.02-OpenWrt-r23630-842932a63d (Nov 14 2023 - 13:38:11 +0000)

      1. Run default boot command.
      2. Boot system via TFTP.
      3. Boot production system from eMMC.
      4. Boot recovery system from eMMC.
      5. Load production system via TFTP then write to eMMC.
      6. Load recovery system via TFTP then write to eMMC.
      7. Load BL31+U-Boot FIP via TFTP then write to eMMC.
      8. Load BL2 preloader via TFTP then write to eMMC.
      9. Reboot.
      a. Reset all settings to factory defaults.
      0. U-Boot console


  Press UP/DOWN to move, ENTER to select, ESC to quit

MT7986> usb start
starting USB...
Bus xhci@11200000: 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
scanning bus xhci@11200000 for devices... 2 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
MT7986> fatload usb 0:1 0x46000000 openwrt/openwrt-mediatek-filogic-bananapi_bpi-r3-mini-initramfs-recovery.itb
40960000 bytes read in 889 ms (43.9 MiB/s)
MT7986> bootm

路由器会启动进入恢复模式, 浏览器打开172.16.0.1, 选择squashfs-sysupgrade进行刷机

5. 创建ubootenv分区

重启后执行下面命令

umount /mnt/ubi0*
ubidetach -p /dev/mtd4
ubiformat -y /dev/mtd4
ubiattach -p /dev/mtd4

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

刷入recovery(可选, 每次开机自动进入recovery, 慎重)

ubimkvol /dev/ubi0 -n 2 -N recovery -s 40MiB
RECOVERY=$(ls /tmp/|grep recovery)
ubiupdatevol /dev/ubi0_2 /tmp/${RECOVERY}

6. 参考文献

bpi_r3_mini/nand.txt · Last modified: 2024/01/15 15:11 by sandro

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki