[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

Hey All!
First time poster on these forums, and first time user of a bpi device.

Just got the BPI r3mini, and I tried to re-flash it with mainland openwrt… but things went sideways… =/

I started with to do a tftp boot through u-boot first, loading the mainland initramfs.itb into ram of the device, and started it. Every works dandy, installed luci and other packages to check that it worked, which it seemed to do… I did this while still being in the emmc mode… which I have later seen I should not have done… =/ I know rtfm… which i though I did, but clearly not good enough…

then googled around a bit, and then did the u-boot “load single file” with tftp and flashed with the sysupgrade-squashfs.itb file, which also seemed to go dandy.

Then I ran the reset command, and when it tried to boot after the flash, it did not start, due to the new bootloader cant find the old image(since it was updated.

=/

This is what I get now when I look on the serial port when connecting the device to my pc with the usb-c cable that came with the package.

I saw that you SPYFF that I could use the mtk_uartboot to fix this(which I have tried with the usb-c cable but without success…)

This is what i get in the minicom terminal when I put power to the device, and I cant seem to find a way of using the mtk_uartboot application to get it on its feets again.

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 0219 [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 ERROR: BL2: Failed to load image id 3 (-2)

I presume that I seriously bricked the device, and I now have more electric garbage i can recycle… but you forum post gave me hope…

to use the mtk_uartboot, do I need the serial connection with the proper cable from the inside of the device, or can I use the mtk_uartboot with the usb-c cable?

Indeed, this one. Recommended is FT232, do not forget to set jumper to 3.3v. looking at the output, you already have it connected to the correct serial port.

which device have you tried booting above? i guess nand and it should scan ubi which does not happen…maybe openwrt packed the wrong bl2 for installing to nand?

ther error says that bl2 cannot find fip which should be in fip volume of ubi mtd partition

its in emmc mode right now… the switch is set closer to the M2 slot on the board it self. It was in this location when I ran the tftp single file load thing… I have tried to boot through the NAND mode, but I get the same result(more or less in the console)

Thanks, I have such a cable, but I don’t have the female connector on the cable(it’s been removed during another project… so I’m trying to find some female connectors to use instead.

It’s the r3mini so a proper usb-c cable should work for you. By proper I mean not a cheap one packaged for a phone or headset etc. instead a PD capable good quality one like 100w or 240w.

More important is the payload: specific u-boot binary needed, for ram boot, eMMC or nand binary will not work! Check Frank W wiki page for unbrick ram binaries.

Hello again!

Thank you all for the support. I managed to get it working again with the help of the usb2serial cable connected to the board itself. I did not manage to get it working with either of my usb-c cables with mtk_uartboot.

I have setup a small github repo where I have a guide on what I did and in which order - so that I know how to handle it in the future - im getting older and older, and im sort of an expert in forgetting the details after a while. :smiley:

magnuszetterberg/bpi-r3mini-unbrick-guide: Guide to unbrick the Banana-pie r3mini

1 Like

Thanks for writing it down and for the credits.

Added link to your readme in my wiki too. Maybe restore works in uboot too,but i guess restoring in openwrt itself like you did is easier.

Maybe you can mention that the ram binaries are created by github pipeline in my u-boot repo and accessible via releases. Just if somebody do not trust my binaries and/or wants the source :slight_smile:

You very welcome Frank! Thank you for the support once again.

Ill add your text to the readme.md file regarding the github pipeline in your u-boot repo and they are accessible via the ‘releases’ feature on github. =)

Ps your github repo with a link pointing to the releases page is added to the document. Ds