This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM4372: MMC device access in U-boot

Part Number: AM4372

Hi Sitara support Team,

My customer is facing not to detect MMC device in u-boot with QSPI boot.

Here is the boot log.
***************************************************************
U-Boot 2019.01-g65a9755cd1-dirty (Dec 10 2019 - 10:12:16 +0900)

CPU : AM437X-GP rev 1.2
Model: TI AM437x SK EVM
DRAM: 1 GiB
Board : A32EXS AM4372
U-Boot: Custom ver. 0.9.0
MMC:
Loading Environment from SPI Flash... SF: Detected mt25ql512 with page size 256 Bytes, erase size 4 KiB, total 64 MiB
OK
SF: Detected mt25ql512 with page size 256 Bytes, erase size 4 KiB, total 64 MiB
Net: eth0: ethernet@4a100000
Hit any key to stop autoboot: 0
=>
=>
=> mmc rescan
No MMC device available
=>
***************************************************************

Their files; am437x-sk-evm.dts, am4372.dtsi, ATT99172.config
SDK info; Linux SDK v6.0

If these lines are in am437x-sk-evm.dts file, QSPI boot is failed.

/*-----------------------------------*/
/* &mmc1 {
/* status = "okay";
/* pinctrl-names = "default";
/* pinctrl-0 = <&mmc1_pins>;
/*
/* vmmc-supply = <&dcdc4>;
/* bus-width = <4>;
/* };
/*-----------------------------------*/

Question
How can it access MMC device via u-boot?

Best regards,
Kanae

  • Hi Kanae-san,

    Kanae said:
    => mmc rescan
    No MMC device available

    if you want to access a non-boot device in U-Boot you need to first initialize it, as by design U-Boot only initializes the actual boot media (known as "lazy initialization").

    This being said, when booting from xSPI, and wanting to access MMC, you would need to issue an mmc init command first. Try that, and then mmc info to see what was detected.

    Kanae said:
    If these lines are in am437x-sk-evm.dts file, QSPI boot is failed.

    I'm not sure I fully understand. Are you saying if you comment out these lines QSPI boot will not work at all? Can you share a boot log of this scenario?

    Also usually it's better to just set status="disabled" to make sure a device is really disabled independently of what else has been inherited from included device tree files, otherwise you could end up with an invalid configuration.

    Regards,
    Andreas

  • Hi Andreas,

    Thank you for your support!

    There is "mmc" command, but it seems not to support mmc init.
    Is it necessary to change the menuconfig, and so on?

    Here is the log executing "mmc init" command in u-boot.

    *****
    U-Boot 2019.01-g65a9755cd1-dirty (Dec 10 2019 - 10:12:16 +0900)

    CPU : AM437X-GP rev 1.2
    Model: TI AM437x SK EVM
    DRAM: 1 GiB
    Board : A32EXS AM4372
    U-Boot: Custom ver. 0.9.0
    MMC:
    Loading Environment from SPI Flash... SF: Detected mt25ql512 with page size 256 Bytes, erase size 4 KiB, total 64 MiB
    OK
    SF: Detected mt25ql512 with page size 256 Bytes, erase size 4 KiB, total 64 MiB
    Net: eth0: ethernet@4a100000
    Hit any key to stop autoboot: 0
    =>
    => mmc init
    mmc - MMC sub system

    Usage:
    mmc info - display info of the current MMC device
    mmc read addr blk# cnt
    mmc write addr blk# cnt
    mmc erase blk# cnt
    mmc rescan
    mmc part - lists available partition on current mmc device
    mmc dev [dev] [part] - show or set current mmc device [partition]
    mmc list - lists available devices
    mmc hwpartition [args...] - does hardware partitioning
    arguments (sizes in 512-byte blocks):
    [user [enh start cnt] [wrrel {on|off}]] - sets user data area attributes
    [gp1|gp2|gp3|gp4 cnt [enh] [wrrel {on|off}]] - general purpose partition
    [check|set|complete] - mode, complete set partitioning completed
    WARNING: Partitioning is a write-once setting once it is set to complete.
    Power cycling is required to initialize partitions after set to complete.
    mmc setdsr <value> - set DSR register value

    =>
    => mmc rescan
    No MMC device available
    => mmc info
    No MMC device available
    =>

    => mmc
    mmc mmcinfo

    *****

    Regarding "QSPI boot is failed", please forget about this,
    because it is unnecessary information.
    I am sorry to have confused you.

    Best regards,
    Kanae

  • Kanae-san,

    Kanae said:
    There is "mmc" command, but it seems not to support mmc init.
    Is it necessary to change the menuconfig, and so on?

    Oh yes this is an old command used to initialize the MMC sub-system, but this has been dropped from U-Boot sometime in 2016 and it is no longer needed. Instead, an "mmc rescan" does now do the initialization implicitly. Basically since you are on U-Boot 2019.01 this "init" command no longer applies, sorry for the confusion.

    I do not have an AM43xx board here with QSPI on it but I found an AM437x GP EVM that has NAND flash so I went ahead and programmed SPL (MLO) and U-Boot from the AM43xx Linux SDK into NAND, switched the boot mode setting to NAND-only SYSBOOT[4:0]==00110b, and was able to access an SD card on MMC0 without any issues after booting from NAND as shown in the below log:

    U-Boot SPL 2019.01-g029e4c009a (Oct 19 2019 - 23:19:05 +0000)
    Trying to boot from NAND
    SPL: Please implement spl_start_uboot() for your board
    SPL: Direct Linux boot not active!
    
    
    U-Boot 2019.01-g029e4c009a (Oct 19 2019 - 23:19:05 +0000)
    
    CPU  : AM437X-GP rev 1.2
    Model: TI AM437x GP EVM
    DRAM:  2 GiB
    PMIC:  TPS65218
    NAND:  512 MiB
    MMC:   OMAP SD/MMC: 0
    Loading Environment from FAT... *** Warning - bad CRC, using default environment
    
    Net:
    Warning: ethernet@4a100000 using MAC address from ROM
    eth0: ethernet@4a100000
    Hit any key to stop autoboot:  0
    => mmc rescan
    => mmc info
    Device: OMAP SD/MMC
    Manufacturer ID: 41
    OEM: 3432
    Name: SD32G 
    Bus Speed: 48000000
    Mode : SD High Speed (50MHz)
    Rd Block Len: 512
    SD version 3.0
    High Capacity: Yes
    Capacity: 29.1 GiB
    Bus Width: 4-bit
    Erase Group Size: 512 Bytes
    => fatls mmc 0
       139662   MLO
       726004   u-boot.img
          717   uEnv.txt
    
    3 file(s), 0 dir(s)

    I would not expect QSPI-based boot to be different from the point of being able to access MMCx after booting than above NAND-based boot, assuming the same code base / CONFIG options. At this point I would recommend using TI's AM437x GP EVM hardware design (http://www.ti.com/tool/TMDSEVM437X) plus the associated latest Linux SDK (http://www.ti.com/tool/PROCESSOR-SDK-AM437X) as a known-good reference and look for differences in what appears to be custom board and U-Boot firmware. I'd keep a particular eye on...

    1. the U-Boot DTS to make sure things like pinmux, regulators, clock sources etc. are setup correctly specifically for the MMCx modules. Again, use the AM437x GP EVM DTS files (arch/arm/dts/am437x-gp-evm.dts and arch/arm/dts/am437x-gp-evm-u-boot.dtsi) plus anything these files include as a "gold standard", and see if it can be made work.
    2. The defconfig used to build the project. The TI EVM uses configs/am43xx_evm_defconfig. What is the custom design based off? Compare and see if there might be CONFIG options missing. 

    One more thing you could do is turning on CONFIG_CMD_DM in U-Boot, and then printing out the entire driver model hierarchy using "dm tree" on the U-Boot console. This will tell you which drivers are there, and which ones got probed. For example try running this before and after "mmc rescan" and see if there is any change. 

    If this doesn't help then I'd suggest to try to port the current TI Linux SDK mentioned earlier to this custom board (assuming there is a custom board).

    Regards, Andreas

  • Hi Andreas,

    Thank you for your reply.
    Regarding the points that you'd keep a particular eye on...

    1. My customer did not check the AM437x GP EVM DTS files yet.
    However he uses the am437x-sk-evm.dts file without the following lines
    which are commented out.

    /*-----------------------------------*/
    /* &mmc1 {
    /* status = "okay";
    /* pinctrl-names = "default";
    /* pinctrl-0 = <&mmc1_pins>;
    /*
    /* vmmc-supply = <&dcdc4>;
    /* bus-width = <4>;
    /* };
    /*-----------------------------------*/

    And he compares the Control_module register at QSPI boot and at SD boot,
    there is no differences.

     Q1. Are there other registers for checck the setting?

    2. My customer uses the custom config file based on "am43xx evm_qsp boot_config".

     Q2. Can you agree that he thinks this config file be recognize SD card?

    Best regards,
    kanae

  • Kanae-san,

    I just verified successful operation with the actual TI AM437x SK EVM board in combination with the current AM437x Linux SDK v06.01.00.08.

    First, I built U-Boot using the am43xx_evm_qspiboot_defconfig from a clean U-Boot tree. No modifications were made and the SDK sources were used as-is.

    Then, I copied the generated u-boot.bin file to the mounted SD card for transfer to the AM437x SK board (while renaming the file for clarity)

    a0797059@jiji:/opt/procsdk-linux-am437x-evm-06.01.00.08/board-support/u-boot-2019.01+gitAUTOINC+029e4c009a-g029e4c009a (processor-sdk-local)
    $ cp u-boot.bin /media/a0797059/boot/u-boot-qspi.bin && sync

    Then, I booted the board from the SD card and programmed the QSPI image into the memory as follows

    => sf probe && sf erase 0 100000 && fatload mmc 0 80000000 u-boot-qspi.bin && sf write 80000000 0 ${filesize}                                       
    SF: Detected mx66l51235l with page size 256 Bytes, erase size 64 KiB, total 64 MiB                                                                  
    SF: 1048576 bytes @ 0x0 Erased: OK                                                                                                                  
    759144 bytes read in 43 ms (16.8 MiB/s)                                                                                                             
    device 0 offset 0x0, size 0xb9568                                                                                                                   
    SF: 759144 bytes @ 0x0 Written: OK                                                                                                                  
    =>

    Then I removed the SD card and power-cycled the board. It will take a while for QSPI boot to start due to the way the boot sequence is configured on the AM437x SK board, but eventually it will start as follows:

    U-Boot 2019.01-g15b9b87253 (Dec 20 2019 - 15:30:39 -0600)
    
    CPU  : AM437X-GP rev 1.2
    Model: TI AM437x SK EVM
    DRAM:  1 GiB
    PMIC:  TPS65218
    MMC:   OMAP SD/MMC: 0
    Loading Environment from SPI Flash... SF: Detected mx66l51235l with page size 256 Bytes, erase size 64 KiB, total 64 MiB
    *** Warning - bad CRC, using default environment
    
    Net:
    Warning: ethernet@4a100000 using MAC address from ROM
    eth0: ethernet@4a100000
    Hit any key to stop autoboot:  0

    Then, I inserted the SD card into the board, and was able to access it successfully:

    => mmc info
    Device: OMAP SD/MMC
    Manufacturer ID: 41
    OEM: 3432
    Name: SD32G
    Bus Speed: 48000000
    Mode : SD High Speed (50MHz)
    Rd Block Len: 512
    SD version 3.0
    High Capacity: Yes
    Capacity: 29.1 GiB
    Bus Width: 4-bit
    Erase Group Size: 512 Bytes
    => fatls mmc 0
       139662   MLO
       726004   u-boot.img
          717   uEnv.txt
       759128   u-boot-qspi.bin
                .Trash-14170/
    
    4 file(s), 1 dir(s)
    
    =>
    

    So what should be done here is going back to the original SDK v06.01.00.08 sources and the original SDK am43xx_evm_qspiboot_defconfig config and DTS file, making the absolute minimal changes as needed for the custom board to see if it can be made work. The above steps prove that this is a working reference solution, and the goal should be to re-create this and to understand/examine any differences in detail.

    If you go back to your original boot log you see the "MMC:   OMAP SD/MMC: 0" line is missing. This could be caused by either DTS, defconfig (pieces missing related to the driver or its dependencies), or some other issue with the code.

    I can further confirm that by removing the &mmc1 node from the DTS just as it was described in the initial post the SD card can no longer be accessed. Since this is the only MMC device exposed on the AM437x SK board it is expected behavior. Why was this node removed?

    Regards, Andreas