[BPI-R4] U-boot on NAND but activating eMMC instead SD

Hi all,

I have a short question regarding BPI-R4 boot from NAND. I was able to built my own custom BL2 AT-F and FIP U-boot but regarding what kind of DTB I’m choosing for U-boot, eMMC is not able to be initialized.

Normally I tried to set “mt7988-rfb” DTB for U-boot to be able to use eMMC instead SD slot, but each time I’m booting with DIP switch in position AB = 01 I’m getting this error:

EasyOS(BPi-R4)> mmc info
Card did not respond to voltage select! : -110
mmc_init: -95, time 16

There is a restriction when using SPI NAND that MUX for SD/eMMC is not switched to eMMC?

Looking into the DTS sources for mt7988-rfb.dts:

        mmc0_pins_default: mmc0default {
                mux {
                        function = "flash";
                        groups =  "emmc_51";
                };

                conf-cmd-dat {
                        pins = "EMMC_DATA_0", "EMMC_DATA_1", "EMMC_DATA_2",
                               "EMMC_DATA_3", "EMMC_DATA_4", "EMMC_DATA_5",
                               "EMMC_DATA_6", "EMMC_DATA_7", "EMMC_CMD";
                        input-enable;
                };

                conf-clk {
                        pins = "EMMC_CK";
                };

                conf-dsl {
                        pins = "EMMC_DSL";
                };

                conf-rst {
                        pins = "EMMC_RSTB";
                };
        };

and mt7988-sd-rfb.dts:

        mmc1_pins_default: mmc1default {
                mux {
                        function = "flash";
                        groups =  "emmc_45";
                };

                conf-cmd-dat {
                        pins = "SPI2_CSB", "SPI2_MISO", "SPI2_MOSI",
                               "SPI2_CLK", "SPI2_HOLD";
                        input-enable;
                        drive-strength = <MTK_DRIVE_4mA>;
                };

                conf-clk {
                        pins = "SPI2_WP";
                        drive-strength = <MTK_DRIVE_4mA>;
                };
        };

I’m seeing that mux part configuration that sounds like it must switch between eMMC and SD slot. De-compiling the u-boot.dtb after build shows me clearly this:

               mmc0default {
                        phandle = <0x0e>;

                        mux {
                                function = "flash";
                                groups = "emmc_51";
                        };

                        conf-cmd-dat {
                                pins = "EMMC_DATA_0\0EMMC_DATA_1\0EMMC_DATA_2\0EMMC_DATA_3\0EMMC_DATA_4\0EMMC_DATA_5\0EMMC_DATA_6\0EMMC_DATA_7\0EMMC_CMD";
                                input-enable;
                        };

                        conf-clk {
                                pins = "EMMC_CK";
                        };

                        conf-dsl {
                                pins = "EMMC_DSL";
                        };

                        conf-rst {
                                pins = "EMMC_RSTB";
                        };
                };
        };
..
        mmc@11230000 {
                compatible = "mediatek,mt7988-mmc\0mediatek,mt7986-mmc";
                reg = <0x00 0x11230000 0x00 0x1000>;
                interrupts = <0x00 0x8f 0x04>;
                clocks = <0x08 0x3f 0x08 0x40 0x08 0x41 0x08 0x42>;
                clock-names = "source\0hclk\0source_cg\0axi_cg";
                status = "okay";
                pinctrl-names = "default";
                pinctrl-0 = <0x0e>;
                max-frequency = <0x3197500>;
                bus-width = <0x08>;
                cap-mmc-highspeed;
                cap-mmc-hw-reset;
                vmmc-supply = <0x0f>;
                vqmmc-supply = <0x10>;
                non-removable;
                phandle = <0x30>;
        };
..
        regulator-3p3v {
                compatible = "regulator-fixed";
                regulator-name = "fixed-3.3V";
                regulator-min-microvolt = <0x325aa0>;
                regulator-max-microvolt = <0x325aa0>;
                regulator-boot-on;
                regulator-always-on;
                phandle = <0x0f>;
        };

        regulator-1p8v {
                compatible = "regulator-fixed";
                regulator-name = "fixed-1.8V";
                regulator-min-microvolt = <0x1b7740>;
                regulator-max-microvolt = <0x1b7740>;
                regulator-boot-on;
                regulator-always-on;
                phandle = <0x10>;
        };

And soon as I’m inserting the SD card in slot is shows me the external card:

> mmc info
Card did not respond to voltage select! : -110
mmc_init: -95, time 17
EasyOS(BPi-R4)> mmc info
Device: mmc@11230000
Manufacturer ID: 3
OEM: 5344
Name: SC32G 
Bus Speed: 25000000
Mode: MMC legacy
Rd Block Len: 512
SD version 3.0
High Capacity: Yes
Capacity: 29.7 GiB
Bus Width: 4-bit
Erase Group Size: 512 Bytes

Is something that I’m missing out here?

Thank you in advance.

Boot from nand has emmc active in hardware not sdcard,so your nand uboot needs the non-sd dts as emmc has completely different settings (not only pinmux,also regulators and other settings like speed,removalble flag,…).

Are you sure uboot uses right dts? Afair there were 2 dts settings in config.

I found the issue. The problem was when I tested the new U-boot it wasn’t flashed in FIP partition.

In NAND I still got the old FIP that was using SDMMC. Then, before writing the new FIP, I wanted to test it by loading in RAM the new u-boot.bin and the use go to run the new one. So the board booted initially booted the old FIP with SDMMC DTB and then I used go to run the new U-boot.

Seems that in this case, even the u-boot.bin contains the correct DTB, doesn’t apply it correctly for eMMC/SDMMC.

After I write the FIP partition in NAND, reset U-boot now I got the eMMC:

EasyOS(BPi-R4)> version 
U-Boot 2025.01-rc3-EasyOS-eMMC-gacab6e78aca7-dirty (Dec 14 2024 - 17:12:40 +0100)

EasyOS(BPi-R4)> mmc info
Device: mmc@11230000
Manufacturer ID: 15
OEM: 0
Name: 8GTF4R 
Bus Speed: 52000000
Mode: MMC High Speed (52MHz)
Rd Block Len: 512
MMC version 5.1
High Capacity: Yes
Capacity: 7.3 GiB
Bus Width: 8-bit
Erase Group Size: 512 KiB
HC WP Group Size: 8 MiB
User Capacity: 7.3 GiB WRREL
Boot Capacity: 4 MiB ENH
RPMB Capacity: 512 KiB ENH
Boot area 0 is not write protected
Boot area 1 is not write protected

Do you have an explanation for this behavior?

Fip partition is only used on mmc…spi use fixed locations or ubi in openwrt uboot.

When booting from nand the nand-fip should have emmc dts. Which uboot code and defconfig do you use for nand?

My NAND has 2 partitions: BL2 starts from 0x0 with 2MB size and the next one FIP partition with a size of 2MB:

+------------+-----------+-----------+-----------+
| Partition  | Offset    | End       | Size      |
+------------+-----------+-----------+-----------+
| BL2        | 0x0       | 0x1FFFFF  | 0x200000  |
|*FIP        | 0x200000  | 0x3FFFFF  | 0x200000  |
| u-boot-env | 0x400000  | 0x43FFFF  | 0x40000   |
| UBI        | 0x440000  | 0x7FFFFFF | 0x7BC0000 |
+------------+-----------+-----------+-----------+
INFO: FIP_BASE address 0x200000 doesn't match with FIP partition start 0x100000
INFO: Overwriting FIP_BASE with address 0x200000. Otherwise BL2 will not find FIP!

As you can see I write my script to verify the FIP partition offset. In case is not correct one (by default for MT7988 is 0x580000 and in my script I set an offset of 0x100000) the script is autocorrecting the FIP offset for AT-F.

But before testing the new FIP U-boot with eMMC, in NAND I had FIP U-Boot with SDMMC DTB.

By default board was booting FIP U-boot with SDMMC. Then I was loading via TFTP the new U-boot eMMC binary which contains the eMMC DTB. But even the new U-boot was running successfully with go command, it didn’t initialize the eMMC and still tried to initialize the SDMMC.

As soon as I write FIP image of U-boot eMMC in NAND and reboot the board, the U-boot initialize the eMMC instead SDMMC.

Why the new u-boot.bin didn’t initialize eMMC if was running via go from a previous U-boot with SDMMC DTB boot, I have no clue.

So all working now with emmc dts on nand?

I guess some driver (pinctrl,clk,…) does not reset the specific device

1 Like

Possible. But is a good exercise for others in case they step into a same issue.