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.

SK-AM62: Booting from eMMC in backup boot mode fails

Part Number: SK-AM62

Booting from eMMC in backup boot mode fails on AM62 Starter Kit:

When I select an invalid primary boot mode and MMCSD as backup boot with port=0, fs, I get the following error:

Fullscreen
1
2
3
4
5
6
7
8
9
10
U-Boot SPL 2023.04-dirty (Mar 28 2024 - 16:34:41 +0100)
SYSFW ABI: 3.1 (firmware rev 0x0008 '8.6.4--v08.06.04 (Chill Capybar')
SPL initial stack usage: 13440 bytes
Trying to boot from MMC1
mmc_load_image_raw_sector: mmc block read error
** Partition 1 not valid on device 0 **
spl_register_fat_device: fat register err - -1
spl_load_image_fat: error reading image tispl.bin, err - -1
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


Interesting observations:
1) Booting from eMMC in primary boot mode works. I'm using MMCSD with port=0, fs mode. This boots fine. Just backup boot mode with the same options does not work.
2) When I delete the `tispl.bin` from the eMMC I get:

Fullscreen
1
2
3
4
5
6
7
U-Boot SPL 2023.04-dirty (Mar 28 2024 - 16:34:41 +0100)
SYSFW ABI: 3.1 (firmware rev 0x0008 '8.6.4--v08.06.04 (Chill Capybar')
SPL initial stack usage: 13440 bytes
Trying to boot from MMC1
spl_load_image_fat: error reading image tispl.bin, err - -2
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Any idea what I'm doing wrong? Or is this a known bug?

Edit: I'm building my u-boot from ti-u-boot 09.02.00.009. I followed the steps here: https://software-dl.ti.com/processor-sdk-linux-rt/esd/AM62X/latest/exports/docs/linux/Foundational_Components/U-Boot/UG-General-Info.html (except I used the ti-u-boot repo, though the same happens with upstream u-boot).

Edit2: Since the TRM says the eMMC is only accessed in 1-bit mode I tried to change the sdhci/bus-width to <0x01>, assuming that maybe the eMMC is set up differently by ROM code in backup boot mode, but that didn't help either. Also observation 2 suggests that the SPL can see the content on the eMMC, just loading the image fails for some reason.

  • Hi Gero,

    The shared logs suggests you are using U-Boot from PSDK v8.6 however your edit says v9.2. Can you please clarify the exact version you are using and share the corresponding logs?

    If it helps, I have verified the eMMC backup boot with PSDK v9.1

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    U-Boot SPL 2023.04-gafcd134e-dirty (Mar 29 2024 - 13:18:12 +0530)
    SYSFW ABI: 3.1 (firmware rev 0x0009 '9.1.8--v09.01.08 (Kool Koala)')
    SPL initial stack usage: 13384 bytes
    am625_init: spl_boot_device: devstat = 0x1473 bootmedia = 0x9 bootindex = 1
    Trying to boot from MMC1
    spl: mmc boot mode: fs
    am625_init: spl_boot_device: devstat = 0x1473 bootmedia = 0x9 bootindex = 1
    Authentication passed
    am625_init: spl_boot_device: devstat = 0x1473 bootmedia = 0x9 bootindex = 1
    Authentication passed
    am625_init: spl_boot_device: devstat = 0x1473 bootmedia = 0x9 bootindex = 1
    Authentication passed
    am625_init: spl_boot_device: devstat = 0x1473 bootmedia = 0x9 bootindex = 1
    Authentication passed
    am625_init: spl_boot_device: devstat = 0x1473 bootmedia = 0x9 bootindex = 1
    Authentication passed
    Starting ATF on ARM64 core...
    NOTICE: BL31: v2.9(release):v2.9.0-614-gd7a7135d32-dirty
    NOTICE: BL31: Built : 09:34:15, Aug 24 2023
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Regards,

    Prashant

  • Hi Prashant,

    Thank you for your help. I used sysfw 8.6.4 by accident, I rebuild everything with sysfw 9.2.7 but I still get the same error message:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    U-Boot SPL 2023.04 (Apr 02 2024 - 14:24:17 +0200)
    SYSFW ABI: 3.1 (firmware rev 0x0009 '9.2.7--v09.02.07 (Kool Koala)')
    SPL initial stack usage: 13440 bytes
    Trying to boot from MMC1
    mmc_load_image_raw_sector: mmc block read error
    ** Partition 1 not valid on device 0 **
    spl_register_fat_device: fat register err - -1
    spl_load_image_fat: error reading image tispl.bin, err - -1
    SPL: failed to boot from all boot devices
    ### ERROR ### Please RESET the board ###
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Just to clarify, I'm not building with yocto, just the individual components themselves. Here's what I'm doing to follow along:

    Setup:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    # Clone all repos
    git clone https://git.ti.com/git/ti-u-boot/ti-u-boot.git
    git clone https://git.ti.com/git/processor-firmware/ti-linux-firmware.git
    git clone https://git.ti.com/git/optee/ti-optee-os.git
    git clone https://git.ti.com/git/atf/arm-trusted-firmware.git
    # Checkout all repos to 09.02.00.009
    for dir in *; do
    cd $dir
    git checkout 09.02.00.009
    cd ..
    done
    # Verify
    for dir in *; do
    echo $dir:
    cd $dir
    git tag --points-at HEAD | grep ^[0-9]
    cd ..
    done
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Build:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    # Setup build
    export CC32=arm-linux-gnueabihf-
    export CC64=aarch64-linux-gnu-
    export LNX_FW_PATH=$PWD/ti-linux-firmware
    export TFA_PATH=$PWD/arm-trusted-firmware
    export OPTEE_PATH=$PWD/ti-optee-os
    export UBOOT_CFG_CORTEXR=am62x_evm_r5_defconfig
    export UBOOT_CFG_CORTEXA=am62x_evm_a53_defconfig
    export TFA_BOARD=lite
    unset TFA_EXTRA_ARGS
    export OPTEE_PLATFORM=k3-am62x
    export OPTEE_EXTRA_ARGS="CFG_WITH_SOFTWARE_PRNG=y"
    # Build TF-A
    cd arm-trusted-firmware
    make CROSS_COMPILE=$CC64 ARCH=aarch64 PLAT=k3 SPD=opteed $TFA_EXTRA_ARGS TARGET_BOARD=$TFA_BOARD
    # Build optee
    cd ../ti-optee-os
    make CROSS_COMPILE=$CC32 CROSS_COMPILE64=$CC64 CFG_ARM64_core=y $OPTEE_EXTRA_ARGS PLATFORM=$OPTEE_PLATFORM
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Flash:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    # I boot the board using sdcard into A53 u-boot, switches for SK E3:
    # 01101000 11000010 (port=1, fs, primary=mmcsd, backup=mmcsd)
    # then, in u-boot I flash the image onto the eMMC using DFU (I added DFU to u-boot on sd-card):
    => setenv dfu_alt_info 'uda part 0 1; tiboot3.bin fat 0 1; tispl.bin fat 0 1'
    => dfu 0 mmc 0
    # Host:
    dfu-util --alt tiboot3.bin --download tiboot3-am62x-gp-evm.bin
    dfu-util --alt tispl.bin --download tispl.bin
    # Switch off board, set switches to boot from emmc UDA (primary):
    # 00101000 11000010 (port=0, fs, primary=mmcsd, backup=mmcsd)
    # and test if the board comes up:
    # It boots R5 SPL, loads tispl and starts ATF and OP-TEE then boots A53 SPL,
    # there it hangs because there's no u-boot.img on the eMMC (expected).
    # Switch off board, set switches to boot from emmc UDA (backup):
    # 00101000 11010010 (port=0, fs, primary=eMMC, backup=mmcsd)
    # I'm using eMMC mode as primary, but there's no image on hardware partition
    # boot0, so backup boot will be used (I tested that boot0 is empty).
    # Power on board and observe:
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Oh, I think I just found the issue: If I use I2C as primary boot (nothing connected), then backup boot with MMCSD and port=0 (eMMC) works!

    So the bug is: When using primary boot mode eMMC, then using backup boot mode MMCSD with port=0 (eMMC) does not work.

    Any idea how to solve this? Or is this a hardware limitation? (Couldn't find it in the Errata.)

  • Hi Gero,

    Oh, I think I just found the issue: If I use I2C as primary boot (nothing connected), then backup boot with MMCSD and port=0 (eMMC) works!

    I was going to suggest the same. If you see in my working logs, the primary boot media is SPI and backup media is eMMC. I guess if I do the same boot switches configuration as yours, I would also see the issue.

    Let me know dig through the code and see what's going on.

    Regards,

    Prashant

  • Hi Prashant,

    Let me know dig through the code and see what's going on.

    Sounds great, thank you! Let me know if I can support you in any way to figure this one out.

    Best,
    Gero

  • Hi Gero,

    I indeed see the same issue with the bootmode pins => B0-B7: 11010010, B8-B15: 00101000.

    For eMMC/SD boot, this is the function call that decides from where to boot the `tispl.bin` & `u-boot.img`: https://git.ti.com/cgit/ti-u-boot/ti-u-boot/tree/common/spl/spl_mmc.c?h=09.02.00.009&id=f9b966c674731a1a29a20a8e143c61d4e046f13c#n441

    and this is the corresponding function definition for AM62x: https://git.ti.com/cgit/ti-u-boot/ti-u-boot/tree/arch/arm/mach-k3/am625_init.c?h=09.02.00.009&id=f9b966c674731a1a29a20a8e143c61d4e046f13c#n230

    The `spl_mmc_boot_mode` implementation doesn't take into consideration the backup boot and so explains why there is an issue with eMMC UDA backup boot when primary boot is eMMC alternate. In this case, it will return MMCSD_MODE_EMMCBOOT based on the primary boot eMMC alternate.

    This will make the `spl_mmc_load` function to boot `tispl.bin` and `u-boot.img` from the enabled boot partition in the EXTCSD eMMC register. If it is configured to Boot0 partition (mmc partconf 0 1 1 1) then it will try both RAW and FAT load. The FAT load will definitely fail while the RAW load will fail if there is no image present.

    A possible fix for this can be the following:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    diff --git a/arch/arm/mach-k3/am625_init.c b/arch/arm/mach-k3/am625_init.c
    index ccbfad29..48a5f8d8 100644
    --- a/arch/arm/mach-k3/am625_init.c
    +++ b/arch/arm/mach-k3/am625_init.c
    @@ -229,6 +229,15 @@ void board_init_f(ulong dummy)
    u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)
    {
    + /**
    + * Bootindex is already initialized at this point
    + * bootindex = 0 => Primary boot
    + * bootindex = 1 => Backup boot
    + */
    + if(bootindex == 1) {
    + return MMCSD_MODE_FS;
    + }
    +
    u32 devstat = readl(CTRLMMR_MAIN_DEVSTAT);
    u32 bootmode = (devstat & MAIN_DEVSTAT_PRIMARY_BOOTMODE_MASK) >>
    MAIN_DEVSTAT_PRIMARY_BOOTMODE_SHIFT;
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    I will discuss this internally and decide if this is indeed a bug in which case I will file a ticket and let the dev team take the best course of action.

    Regards,

    Prashant

  • Prashant, you are a hero! This fixed the issue!

    I would be great if this fix could be included upstream. Until then I will use this patch.

    Thank you very much for the detailed explanation and the solution! Great TI support!