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.

[参考译文] TMDS64EVM:从 R5 SBL 引导 Linux 和裸机-身份验证失败

Guru**** 2482225 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1448810/tmds64evm-boot-linux-and-baremetal-from-r5-sbl---authentication-failed

器件型号:TMDS64EVM

工具与软件:

我尝试实现的是从定制 R5 SBL 引导 Linux 和裸机应用程序。 引导加载程序从 OSPI Flash 加载、而 Linux appimage 也位于 ospi 闪存中。  

Linux 系统本身位于 SD 卡上。 直接从 SD 卡引导可以正常工作。  

R5 SBL 和 Linux appimage 使用 SYSFW 的版本10.1.7 (Fiery Fox)。

所以我的问题是、如果 R5内核(裸机应用程序启动)的自复位在 A53启动后立即发生、我在 Linux 方面运行下面的问题:

NOTICE:  BL31: v2.10.9(release):lts-v2.10.9
NOTICE:  BL31: Built : 10:13:43, Dec  6 2024

U-Boot SPL 2024.04-00015-g1f034d8945 (Dec 09 2024 - 09:16:08 +0100)
SYSFW ABI: 4.0 (firmware rev 0x000a '10.1.7--v10.01.07 (Fiery Fox)')
Trying to boot from MMC2
ti_sci system-controller@44043000: Message not acknowledged
Authentication failed!
### ERROR ### Please RESET the board ###

但是、如果在 A35启动和 R5复位之间有一段时间进行了传递(aprox.2-3)、那么 u-boot 能够进行身份验证并加载 Linux 内核。

我不确定是什么原因导致了这个问题。 对我来说、R5自复位似乎有一些问题。

我还尝试从裸机应用程序中删除所有内容、但我同时(true)循环、以验证初始化不是问题。

如果有人能给我一个提示、这可能是个问题、那就更好了。

谢谢!  

Alex

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Alex、

    您在这里使用的 SBL 是什么? 是 SBL_OSPI、SBL_OSPI_Linux 还是您定制的 SBL?

    谢谢!

    Prashant

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好 Prashant:

    定制 SBL 基于 SBL_OSPI、并通过 SBL_OSPI_Linux 中的 Linux 引导命令进行扩展。  

    这是我用于 Linux 启动的代码:

    #include "linuxboot.h"
    #include "bootConfig.h"
    #include <drivers/bootloader/soc/bootloader_soc.h>
    #include <drivers/pinmux.h>
    
    Bootloader_FlashArgs gBootloaderLinuxArgs = {
        .flashIndex = 0xFF,
        .curOffset = 0,
        .appImageOffset = 0x300000,
    };
    /* Workaround to initialize MMC SD Pinmux (Later will be done in SPL) */
    static Pinmux_PerCfg_t gPinMuxMMCSDCfg[] = {
        /* MyMMC11 -> MMC1_CMD -> J19 */
        { PIN_MMC1_CMD, PIN_MODE(0) | ((PIN_PULL_DIRECTION | PIN_INPUT_ENABLE) & (~PIN_PULL_DISABLE)) },
        /* MyMMC11 -> MMC1_CLK -> L20 */
        { PIN_MMC1_CLK, PIN_MODE(0) | ((PIN_PULL_DISABLE | PIN_INPUT_ENABLE) & (~PIN_PULL_DIRECTION)) },
        /* MyMMC11 -> MMC1_CLKLB */
        { PIN_MMC1_CLKLB, PIN_MODE(0) | ((PIN_PULL_DIRECTION | PIN_INPUT_ENABLE) & (~PIN_PULL_DISABLE)) },
        /* MyMMC11 -> MMC1_DAT0 -> K21 */
        { PIN_MMC1_DAT0, PIN_MODE(0) | ((PIN_PULL_DIRECTION | PIN_INPUT_ENABLE) & (~PIN_PULL_DISABLE)) },
        /* MyMMC11 -> MMC1_DAT1 -> L21 */
        { PIN_MMC1_DAT1, PIN_MODE(0) | ((PIN_PULL_DIRECTION | PIN_INPUT_ENABLE) & (~PIN_PULL_DISABLE)) },
        /* MyMMC11 -> MMC1_DAT2 -> K19 */
        { PIN_MMC1_DAT2, PIN_MODE(0) | ((PIN_PULL_DIRECTION | PIN_INPUT_ENABLE) & (~PIN_PULL_DISABLE)) },
        /* MyMMC11 -> MMC1_DAT3 -> K18 */
        { PIN_MMC1_DAT3, PIN_MODE(0) | ((PIN_PULL_DIRECTION | PIN_INPUT_ENABLE) & (~PIN_PULL_DISABLE)) },
        /* MyMMC11 -> MMC1_SDCD -> D19 */
        { PIN_MMC1_SDCD, PIN_MODE(0) | ((PIN_PULL_DIRECTION | PIN_INPUT_ENABLE) & (~PIN_PULL_DISABLE)) },
    
        { PINMUX_END, (uint32_t)PINMUX_END }
    };
    // uint8_t gScratchMemPtr[0xDA700];
    
    int32_t App_loadLinuxImages(Bootloader_Handle bootHandle, Bootloader_BootImageInfo* bootImageInfo )
    {
        int32_t status = SystemP_FAILURE;
    
        if (bootHandle != NULL)
        {
            status = Bootloader_parseAndLoadLinuxAppImage(bootHandle, bootImageInfo);
    
            if (status == SystemP_SUCCESS)
            {
                bootImageInfo->cpuInfo[CSL_CORE_ID_A53SS0_0].clkHz = Bootloader_socCpuGetClkDefault(CSL_CORE_ID_A53SS0_0);
                status = Bootloader_loadCpu(bootHandle, &(bootImageInfo->cpuInfo[CSL_CORE_ID_A53SS0_0]));
            }
        }
        return status;
    }
    
    int32_t App_runLinuxCpu(Bootloader_Handle bootHandle, Bootloader_BootImageInfo* bootImageInfo)
    {
        int32_t status = SystemP_FAILURE;
    
        /* Initialize GTC by enabling using Syscfg */
    
        /* Change the dev stat register to SD card bootmode so that SPL loads uBoot and linux kernel from SD card */
        SOC_setDevStat(SOC_BOOTMODE_MMCSD);
    
        /* Enable pinmux for MMCSD (Workaround as MMC SD pinmux is not initialized in A53 SPL) */
        Pinmux_config(gPinMuxMMCSDCfg, PINMUX_DOMAIN_ID_MAIN);
    
        /* Unlock all the control MMRs. Linux/U-boot expects all the MMRs to be unlocked */
        SOC_unlockAllMMR();
    
        status = Bootloader_runCpu(bootHandle, &(bootImageInfo->cpuInfo[CSL_CORE_ID_A53SS0_0]));
    
        return status;
    }
    void* operatingMode = NULL;
    
    Bootloader_Config bootConfigLinux = {
        .fxns = &gBootloaderFlashFxns,
        .args = &gBootloaderLinuxArgs,
        .bootMedia = BOOTLOADER_MEDIA_FLASH,
        .bootImageSize = 0,
        .coresPresentMap = 0,
        .scratchMemPtr = NULL, // gScratchMemPtr,
        .socCoreOpMode = (void*)&operatingMode,
        .isAppimageSigned = TRUE,
        .disableAppImageAuth = TRUE,
        .initICSSCores = TRUE,
    };
    Bootloader_Handle        gBootHandleLinux;
    Bootloader_BootImageInfo gBootImageInfoLinux;
    Bootloader_Params        gBootParamsLinux;
    
    
    void custom_linux_load(OSPI_Handle ospi_handle)
    {
        int status = 0;
    
    
        Bootloader_Params_init(&gBootParamsLinux);
        Bootloader_BootImageInfo_init(&gBootImageInfoLinux);
    
    
        gBootHandleLinux = CustomBootloader_open(&bootConfigLinux, &gBootParamsLinux);
    
        if (gBootHandleLinux != NULL)
        {
            status = App_loadLinuxImages(gBootHandleLinux, &gBootImageInfoLinux, ospi_handle);
            if (status != SystemP_SUCCESS)
            {
                return;
            }
        }
        else
        {
        }
    }
    
    void custom_linux_start()
    {
        int status = App_runLinuxCpu(gBootHandleLinux, &gBootImageInfoLinux);
    
    }
    

    它位于单独的源文件和自定义 SBL 中,我只需要调用 custom_linux_load ()和 custom_linux_start ()。  

    此致

    Alex

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    在 U-boot 中进行一些研究后、我发现 在尝试验证映像时、arch/arm/mach-k3/security.c 文件中的 uboot 失败。  

    ret = proc_ops->proc_auth_boot_image(ti_sci, &image_addr, &image_size);
    失败的调用。  
    我不知道为什么重新启动 R5内核会阻止 uboot 验证映像
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Alex、

    自定义 SBL 基于 SBL_OSPI

    这就是这个问题的原因。

    `Bootloader_socCpuResetReleaseSelf`函数作为自复位序列的一部分请求 SYSFW 以进行安全性切换。

    github.com/.../bootloader_soc.c

    如果成功、SYSFW 将放弃所有安全服务、包括 PROC_AUTH_BOOT 消息。 这将导致对任何安全服务请求的 SYSFW NACK。

    此问题有两种解决方案:

    -在`Bootloader_socCpuResetReleaseSelf`函数内注释` Bootloader_socSecHandoverage `函数调用。

    或者

    -使用以下补丁修改安全电路板配置以完全禁用安全切换功能。

    diff --git a/source/drivers/sciclient/sciclient_default_boardcfg/am64x/sciclient_defaultBoardcfg_security.c b/source/drivers/sciclient/sciclient_default_boardcfg/am64x/sciclient_defaultBoardcfg_security.c
    index b37b1aa4..e5d5af3b 100755
    --- a/source/drivers/sciclient/sciclient_default_boardcfg/am64x/sciclient_defaultBoardcfg_security.c
    +++ b/source/drivers/sciclient/sciclient_default_boardcfg/am64x/sciclient_defaultBoardcfg_security.c
    @@ -257,8 +257,8 @@ __attribute__(( aligned(128), section(".boardcfg_data") )) =
                 .magic = TISCI_BOARDCFG_SEC_HANDOVER_CFG_MAGIC_NUM,
                 .size = sizeof(struct tisci_boardcfg_sec_handover),
             },
    -        .handover_msg_sender = TISCI_HOST_ID_MAIN_0_R5_0,
    -        .handover_to_host_id = TISCI_HOST_ID_MAIN_0_R5_0,
    +        .handover_msg_sender = 0,
    +        .handover_to_host_id = 0,
             .rsvd = {0, 0, 0, 0},
         },
     
    

    --------------------------------------------------------

    请注意、SBL_OSPI_Linux 不存在此问题、因为此 SBL 使用不同的电路板配置、其中默认情况下禁用安全切换功能、而正常的 SBL 除外。

    --- ./source/drivers/sciclient/sciclient_default_boardcfg/am64x/sciclient_defaultBoardcfg_security.c	2024-12-10 11:24:53.171438359 +0530
    +++ ./source/drivers/sciclient/sciclient_default_boardcfg/am64x/sciclient_defaultBoardcfg_security_linux.c	2024-08-04 07:20:17.000000000 +0530
    ...
    @@ -258,10 +126,7 @@
                 .size = sizeof(struct tisci_boardcfg_sec_handover),
             },
    -        .handover_msg_sender = TISCI_HOST_ID_MAIN_0_R5_0,
    -        .handover_to_host_id = TISCI_HOST_ID_MAIN_0_R5_0,
    -        .rsvd = {0, 0, 0, 0},
    +		.handover_msg_sender = 0,
    +		.handover_to_host_id = 0,
    +		.rsvd = {0,0,0,0},
         },
    -
     };
    -
    -
    

    好的、另一个解决方案是仅在 SBL 中使用 Linux 板配置。

    --- ./examples/drivers/boot/sbl_ospi/am64x-evm/r5fss0-0_nortos/ti-arm-clang/makefile	2024-12-04 13:07:12.639416480 +0530
    +++ ./examples/drivers/boot/sbl_ospi_linux/am64x-evm/r5fss0-0_nortos/ti-arm-clang/makefile	2024-09-19 15:32:14.737729016 +0530
    ...
    @@ -255,7 +255,7 @@
     SYSFW_PATH=$(MCU_PLUS_SDK_PATH)/source/drivers/sciclient/soc/am64x_am243x
     SYSFW_LOAD_ADDR=0x44000
     BOARDCFG_LOAD_ADDR=0x7B000
    -BOARDCFG_BLOB=$(MCU_PLUS_SDK_PATH)/source/drivers/sciclient/sciclient_default_boardcfg/am64x/boardcfg_blob.bin
    +BOARDCFG_BLOB=$(MCU_PLUS_SDK_PATH)/source/drivers/sciclient/sciclient_default_boardcfg/am64x/boardcfg_blob_linux.bin
     
     
     SBL_RUN_ADDRESS=0x70000000
    ...

    此致、

    Prashant