[BPI-R3 Mini] How to make sure if it's booting from NAND or eMMC?

Hello everyone. I just got my new BPI-R3 Mini. The stock firmware that came with it seems to be working fine, but I would like to install the official OpenWrt on eMMC.

Since this router doesn’t accept SD Card, and I don’t have a UART debug cable, I am a little concerned of bricking it. I just wanted to make sure that I am booting from NAND, so that I can update eMMC successfully. How can I make sure that I am booting from NAND?

The reason I am questioning this, is because the boot switch says one thing, but commands like df or lsblk says otherwise.

For example, when the boot switch is set to eMMC, I get the following outputs from df and lsblk.

root@OpenWrt:~# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                43.8M     43.8M         0 100% /rom
tmpfs                   997.0M      3.4M    993.7M   0% /tmp
/dev/mtdblock10         980.3M      5.8M    974.5M   1% /overlay
overlayfs:/overlay      980.3M      5.8M    974.5M   1% /
tmpfs                   512.0K         0    512.0K   0% /dev
root@OpenWrt:~# lsblk
NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
mtdblock0     31:0    0   128M  0 disk 
mtdblock1     31:1    0     1M  1 disk 
mtdblock2     31:2    0   512K  0 disk 
mtdblock3     31:3    0     2M  0 disk 
mtdblock4     31:4    0     2M  0 disk 
mtdblock5     31:5    0   4.5M  1 disk 
mtdblock6     31:6    0     2M  0 disk 
mtdblock7     31:7    0     2M  1 disk 
mtdblock8     31:8    0    32M  0 disk 
mtdblock9     31:9    0     1G  0 disk /rom
mtdblock10    31:10   0 980.3M  0 disk /overlay
mtdblock11    31:11   0     2G  0 disk 
mtdblock12    31:12   0   4.2G  0 disk 
mmcblk0      179:0    0   7.3G  0 disk 
├─mmcblk0p1  179:1    0    17K  0 part 
├─mmcblk0p2  179:2    0   512K  0 part 
├─mmcblk0p3  179:3    0     2M  0 part 
├─mmcblk0p4  179:4    0     2M  0 part 
├─mmcblk0p5  179:5    0    32M  0 part 
└─mmcblk0p6  179:6    0   256M  0 part 
mmcblk0boot0 179:8    0     4M  1 disk 
mmcblk0boot1 179:16   0     4M  1 disk 

Isn’t MTD related to NAND storage? Why are they being mounted when the boot switch is set to eMMC?

Likewise, if I set the boot switch to NAND, seems that it’s mounting the eMMC storage, as can be seen below:

root@OpenWrt:~# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                44.0M     44.0M         0 100% /rom
tmpfs                   997.0M      2.8M    994.2M   0% /tmp
/dev/ubi0_2               9.1M    624.0K      8.0M   7% /overlay
overlayfs:/overlay        9.1M    624.0K      8.0M   7% /
tmpfs                   512.0K         0    512.0K   0% /dev
/dev/mmcblk0p6           43.8M     43.8M         0 100% /mnt/mmcblk0p6
root@OpenWrt:~# lsblk
NAME         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
mtdblock0     31:0    0  128M  0 disk 
mtdblock1     31:1    0    1M  1 disk 
mtdblock2     31:2    0  512K  0 disk 
mtdblock3     31:3    0    2M  0 disk 
mtdblock4     31:4    0    2M  0 disk 
mtdblock5     31:5    0   64M  0 disk 
mmcblk0      179:0    0  7.3G  0 disk 
├─mmcblk0p1  179:1    0   17K  0 part 
├─mmcblk0p2  179:2    0  512K  0 part 
├─mmcblk0p3  179:3    0    2M  0 part 
├─mmcblk0p4  179:4    0    2M  0 part 
├─mmcblk0p5  179:5    0   32M  0 part 
└─mmcblk0p6  179:6    0  256M  0 part /mnt/mmcblk0p6
mmcblk0boot0 179:8    0    4M  1 disk 
mmcblk0boot1 179:16   0    4M  1 disk 
ubiblock0_1  254:0    0 43.8M  0 disk /rom

Can someone share some light on this matter?

Thanks in advance!

do you have automount package?

Dont be concerned, its hard to brick: even if you write garbage to both eMMC and NAND, you can still use the mtk_uartboot method to bootstrap some minimal environment to re-flash them. Also the USB-C port has a built-in UART serial console, so you can power it from your PC while accessing the console.

Its correct: mmcblk* related to eMMC, and mtd* related to NAND. What is the output of the mount command? Also, there is a register called EC which has value 2000 if the switch is at the eMMC and 1000 if at the NAND position. Maybe someone know how to read that register value from Linux.

Daniel posted patches for uboot so you see full register and calculation to use from linux.

Here is a modified version based on his patches:

SPYFF,

I did not know the USB-C port has a built-in UART serial console. That is EXCELLENT and so much easier than opening the case and connecting a UART adapter to the GND/TX/RX pins.

Thanks!

Eric

I have stock firmware, with no user installed package. But it doesn’t seem to be installed:

root@OpenWrt:~# opkg list-installed | grep mount
block-mount - 2021-01-04-c53b1882-1
libmount1 - 2.36.1-2
root@OpenWrt:~#

Thanks a lot for the USB-C tip. I have never found any information about this on the router’s Getting Started page, nor on the forum. According to the boot log it seems to be working as expected.

When boot switch is set to eMMC:

F0: 102B 0000
FA: 1040 0000
FA: 1040 0000 [0200]
F9: 103F 0000
F3: 1006 0033 [0200]
F3: 4001 00E0 [0200]
F3: 0000 0000
V0: 0000 0000 [0001]
00: 0000 0000
BP: 2400 0041 [0000]
G0: 1190 0000
EC: 0000 0000 [2000]
T0: 0000 021E [010F]
Jump to BL

NOTICE:  BL2: v2.6(release):
NOTICE:  BL2: Built : 20:16:38, May  7 2023
NOTICE:  WDT: disabled
NOTICE:  CPU: MT7986 (2000MHz)
NOTICE:  EMI: Using DDR4 settings
NOTICE:  EMI: Detected DRAM size: 2048MB
NOTICE:  EMI: complex R/W mem test passed
NOTICE:  BL2: Booting BL31
NOTICE:  BL31: v2.6(release):
NOTICE:  BL31: Built : 20:16:42, May  7 2023


U-Boot 2022.04-rc3 (Mar 24 2023 - 22:47:35 +0800)

CPU:   MediaTek MT7986
Model: mt7986-rfb
DRAM:  2 GiB
Core:  39 devices, 12 uclasses, devicetree: embed
MMC:   mmc@11230000: 0
Loading Environment from MMC... *** Warning - bad CRC, using default environment

In:    serial@11002000
Out:   serial@11002000
Err:   serial@11002000
Net:
Warning: ethernet@15100000 (eth0) using random MAC address - fa:5e:f1:f3:18:d8
eth0: ethernet@15100000

When boot switch is set to NAND:

F0: 102B 0000
FA: 1040 0000
FA: 1040 0000 [0200]
F9: 0000 0000
V0: 0000 0000 [0001]
00: 0000 0000
BP: 2400 0041 [0000]
G0: 1190 0000
EC: 0000 0000 [1000]
T0: 0000 021E [010F]
Jump to BL

NOTICE:  BL2: v2.6(release):
NOTICE:  BL2: Built : 20:18:14, May  7 2023
NOTICE:  WDT: disabled
NOTICE:  CPU: MT7986 (2000MHz)
NOTICE:  EMI: Using DDR4 settings
NOTICE:  EMI: Detected DRAM size: 2048MB
NOTICE:  EMI: complex R/W mem test passed
NOTICE:  SPI_NAND parses attributes from parameter page.
NOTICE:  SPI_NAND Detected ID 0xef
NOTICE:  Page size 2048, Block size 131072, size 134217728
NOTICE:  Initializing NMBM ...
NOTICE:  Signature found at block 1023 [0x07fe0000]
NOTICE:  First info table with writecount 0 found in block 960
NOTICE:  Second info table with writecount 0 found in block 963
NOTICE:  NMBM has been successfully attached in read-only mode
NOTICE:  BL2: Booting BL31
NOTICE:  BL31: v2.6(release):
NOTICE:  BL31: Built : 20:18:17, May  7 2023


U-Boot 2022.04-rc3 (Mar 24 2023 - 22:39:19 +0800)

CPU:   MediaTek MT7986
Model: mt7986-rfb
DRAM:  2 GiB
Core:  42 devices, 15 uclasses, devicetree: embed

Initializing NMBM ...
spi-nand: spi_nand spi_nand@1: Winbond SPI NAND was found.
spi-nand: spi_nand spi_nand@1: 128 MiB, block size: 128 KiB, page size: 2048, OOB size: 64
Could not find a valid device for nmbm0
Signature found at block 1023 [0x07fe0000]
First info table with writecount 0 found in block 960
Second info table with writecount 0 found in block 963
NMBM has been successfully attached

MMC:   mmc@11230000: 0
Loading Environment from MTD... *** Warning - bad CRC, using default environment

In:    serial@11002000
Out:   serial@11002000
Err:   serial@11002000
Net:
Warning: ethernet@15100000 (eth0) using random MAC address - a2:a1:bd:f6:d7:0a
eth0: ethernet@15100000

I will try to install the official OpenWrt on eMMC now.

Best regards.

1 Like