BPI-R3 如何支持Nand下可以使用TF卡

使用目前的固件或者openwrt下载23.05固件,均无法在Nand启动的OpenWRT下使用TF卡,
如何配置和操作才能使用TF卡?

默认Nor和Nand启动后, 唯一的MMC控制器接到EMMC。需要改DTS。

&mmc0 {
        pinctrl-names = "default", "state_uhs";
        pinctrl-0 = <&mmc0_pins_default>;
        pinctrl-1 = <&mmc0_pins_uhs>;
        bus-width = <8>;
        max-frequency = <200000000>;
        cap-mmc-highspeed;
        mmc-hs200-1_8v;
        mmc-hs400-1_8v;
        hs400-ds-delay = <0x14014>;
        vmmc-supply = <&reg_3p3v>;
        vqmmc-supply = <&reg_1p8v>;
        non-removable;
        no-sd;
        no-sdio;
        status = "okay";
};

上面字段改成如下就可以了

&mmc0 {
        pinctrl-names = "default", "state_uhs";
        pinctrl-0 = <&mmc0_pins_default>;
        pinctrl-1 = <&mmc0_pins_uhs>;
        bus-width = <4>;
        max-frequency = <52000000>;
        cap-sd-highspeed;
	r_smpl = <1>;
        vmmc-supply = <&reg_3p3v>;
        vqmmc-supply = <&reg_3p3v>;
        status = "okay";
};

谢谢回复,但在V21.02.3 版本中,编译过程中会有依赖错误,修改之后生成的SD镜像,启动时也会报很多jffs的错误,无法使用

[ 243.981732] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x25c90000: 0x6538 instead
[ 243.991190] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x25c90004: 0x3231 instead
[ 244.000648] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x25c90008: 0x6332 instead

0x3d301018: 0xed4c instead
[ 971.501933] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x3d301038: 0x624f instead
[ 971.512024] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x3d301ffc: 0xd54e instead
[ 971.521484] jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x3d302000: 0x41c0 instead

使用 OpenWRT V23.05: (git.openwrt.org Git - openwrt/openwrt.git/summary) 编译生成的SD镜像,
启动没有遇到错误,但是修改
./target/linux/mediatek/files-5.15/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts
中的 &mmc0字段无效,

请问在 OpenWRT V23.05下要如何修改dts?

SD卡启动会报jffs2错误,这个建议先将sd卡进行低格再烧录。

用SD Formatter格式化之后,启动有改善,大概需要3分钟

[ 41.628714] mt7530 mdio-bus:1f lan1: Link is Up - 1Gbps/Full - flow control rx/tx
[ 41.636218] br-lan: port 1(lan1) entered blocking state
[ 41.641436] br-lan: port 1(lan1) entered forwarding state
[ 181.442523] jffs2: Cowardly refusing to erase blocks on filesystem with no valid JFFS2 nodes
[ 181.450952] jffs2: empty_blocks 0, bad_blocks 0, c->nr_blocks 16022

不过生成的固件里面没有这种文件 mtk-bpi-r3-NAND-WAN1-SFP1-20220619-single-image.bin
要怎么配置才能生成NAND的bin文件?

test@vu-1:/mnt/owrt/openwrt$ ls -lh bin/targets/mediatek/filogic/
total 42M
-rw-r–r-- 1 test test 168 Jun 12 02:32 config.buildinfo
-rw-r–r-- 1 test test 268 Jun 12 02:32 feeds.buildinfo
-rw-r–r-- 1 test test 1.1M Jun 12 02:33 openwrt-mediatek-filogic-bananapi_bpi-r3-emmc-bl31-uboot.fip
-rw-r–r-- 1 test test 197K Jun 12 02:33 openwrt-mediatek-filogic-bananapi_bpi-r3-emmc-preloader.bin
-rw-r–r-- 1 test test 8.1M Jun 12 02:33 openwrt-mediatek-filogic-bananapi_bpi-r3-initramfs-recovery.itb
-rw-r–r-- 1 test test 4.2K Jun 12 02:34 openwrt-mediatek-filogic-bananapi_bpi-r3.manifest
-rw-r–r-- 1 test test 407K Jun 12 02:33 openwrt-mediatek-filogic-bananapi_bpi-r3-nor-bl31-uboot.fip
-rw-r–r-- 1 test test 198K Jun 12 02:33 openwrt-mediatek-filogic-bananapi_bpi-r3-nor-preloader.bin
-rw-r–r-- 1 test test 21M Jun 12 02:34 openwrt-mediatek-filogic-bananapi_bpi-r3-sdcard.img.gz
-rw-r–r-- 1 test test 1.1M Jun 12 02:33 openwrt-mediatek-filogic-bananapi_bpi-r3-snand-bl31-uboot.fip
-rw-r–r-- 1 test test 201K Jun 12 02:33 openwrt-mediatek-filogic-bananapi_bpi-r3-snand-preloader.bin
-rw-r–r-- 1 test test 11M Jun 12 02:33 openwrt-mediatek-filogic-bananapi_bpi-r3-squashfs-sysupgrade.itb
drwxr-xr-x 2 test test 12K Jun 12 02:34 packages
-rw-r–r-- 1 test test 3.3K Jun 12 02:34 profiles.json
-rw-r–r-- 1 test test 1.6K Jun 12 02:34 sha256sums
-rw-r–r-- 1 test test 18 Jun 12 02:32 version.buildinfo

你把SD.img、snand-bl31-uboot.fip和snand-preloader.bin都烧录到nand。

上面的内容复制错了,是这样的

test@vu-1:/mnt/r3/BPI-R3-OPENWRT-V21.02.3$ ls bin/targets/mediatek/mt7986/ -lh |grep SFP
-rw-r–r-- 1 test test 24M Jun 11 09:10 openwrt-mediatek-mt7986-BPI-R3-EMMC-WAN1-SFP1-initramfs-kernel.bin
-rw-r–r-- 1 test test 27M Jun 11 09:10 openwrt-mediatek-mt7986-BPI-R3-EMMC-WAN1-SFP1-squashfs-sysupgrade.bin
-rw-r–r-- 1 test test 24M Jun 11 09:11 openwrt-mediatek-mt7986-BPI-R3-NAND-WAN1-SFP1-initramfs-kernel.bin
-rw-r–r-- 1 test test 29M Jun 11 09:10 openwrt-mediatek-mt7986-BPI-R3-NAND-WAN1-SFP1-squashfs-factory.bin
-rw-r–r-- 1 test test 27M Jun 11 09:10 openwrt-mediatek-mt7986-BPI-R3-NAND-WAN1-SFP1-squashfs-sysupgrade.bin
-rw-r–r-- 1 test test 24M Jun 11 09:10 openwrt-mediatek-mt7986-BPI-R3-NOR-WAN1-SFP1-initramfs-kernel.bin
-rw-r–r-- 1 test test 27M Jun 11 09:10 openwrt-mediatek-mt7986-BPI-R3-NOR-WAN1-SFP1-squashfs-sysupgrade.bin
-rw-r–r-- 1 test test 24M Jun 11 09:14 openwrt-mediatek-mt7986-BPI-R3-SD-WAN1-SFP1-initramfs-kernel.bin
-rw-r–r-- 1 test test 27M Jun 11 09:14 openwrt-mediatek-mt7986-BPI-R3-SD-WAN1-SFP1-squashfs-sysupgrade.bin

只需要写入openwrt-mediatek-mt7986-BPI-R3-NAND-WAN1-SFP1-initramfs-kernel.bin 这个吗,直接写入会无法启动

不是这些文件, Image文件在build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7986/下的*.img文件

如果你们希望做nand的Image,还需要一个工具来做nand Image

确实需要做NAND image,因为要用SD卡,
需要用什么工具,怎么做image?

使用sysupgrade 方式升级当前系统:(mtk-bpi-r3-NAND-WAN1-SFP1-20220928-single-image.bin)。

  • 使用NAND文件升级失败

root@OpenWrt:/mnt/sda1/BPI# sysupgrade openwrt-mediatek-mt7986-BPI-R3-NAND-WAN1-
SFP1-squashfs-sysupgrade.bin
Wed Jun 12 09:40:27 UTC 2024 upgrade: Image not in /tmp, copying…
Invalid image type.
Image check failed.

  • 使用NOR可以升级

root@OpenWrt:/mnt/sda1/BPI# sysupgrade openwrt-mediatek-mt7986-BPI-R3-NOR-WAN1-S
FP1-squashfs-sysupgrade.bin
Wed Jun 12 09:44:25 UTC 2024 upgrade: Image not in /tmp, copying…
Wed Jun 12 09:44:26 UTC 2024 upgrade: Saving config files…
Wed Jun 12 09:44:26 UTC 2024 upgrade: Commencing upgrade. Closing all shell sessions.
Watchdog handover: fd=3
-watchdog -
killall: telnetd: no process killed
Wed Jun 12 09:44:26 UTC 2024 upgrade: Sending TERM to remaining processes … ubusd urngd fwdd logd rpcd netifd odhcpd uhttpd blockd wapp wapp wapp dnsmasq ntpd crond
Wed Jun 12 09:44:29 UTC 2024 upgrade: Sending KILL to remaining processes …
[ 560.382409] sh (7608): drop_caches: 3
Wed Jun 12 09:44:30 UTC 2024 upgrade: Switching to ramdisk…
[ 561.444674] [EXFAT] trying to unmount…
[ 561.448645] [EXFAT] unmounted successfully
[ 561.473577] UBIFS (ubi0:2): background thread “ubifs_bgt0_2” stops
[ 561.485707] UBIFS (ubi0:2): un-mount UBI device 0
Wed Jun 12 09:44:31 UTC 2024 upgrade: Performing system upgrade…
[ 561.509972] sh (7608): drop_caches: 3
Could not open mtd device: firmw[ 561.517577] reboot: Restarting system

但是启动之后,SD卡仍然不能使用

目前sysupgrade 不支持, 需要客户自已做二次开发

那相对简单的还是做Nand single Image了,这个需要怎制作?

single_img_wrapper-spim-nand.tgz (434.9 KB)
single_img_wrapper-spim-nor.tgz (294.6 KB)

用附件的工具。

./mk_image.sh -p mt7986a -d spim-nand -b bl2.img -f fip.bin -k openwrt-mediatek-mt7986-BPI-R3-NAND-WAN1-SFP1-squashfs-factory.bin

./mk_image.sh -p mt7986a -d spim-nor -b bl2.img -f fip.bin -k openwrt-mediatek-mt7986-BPI-R3-NOR-WAN1-SFP1-initramfs-kernel.bin

SD卡可以在Nand下用了,显示为 /dev/mmcblk0

不过有新问题,这个SD卡比较特殊,挂载之后只显示一个uupd.bin,
厂家说可能需要重新上电,不过热插拔会出问题,
咱们这个emmc 用sd卡之后支持热插拔吗?

emmc不能用sd卡