TC3xx学习笔记-启动过程详解(二)

发布于:2025-06-16 ⋅ 阅读:(17) ⋅ 点赞:(0)

前言

上一篇介绍了TC3xx硬件firmware的启动过程,链接:TC3xx学习笔记-启动过程详解(一)
,本文接着基于英飞凌ILLD库介绍软件的启动过程

ILLD-StartupSW启动流程

整体启动流程如下图所示:
在这里插入图片描述
在这里插入图片描述
不同的复位方式所运行的启动模块不同,所花的时间也不一样,复位原因可以从RSTSTAT寄存器读取在这里插入图片描述
SW就是软件复位,PORST就是上电复位

Startup Software: Phase 1-Reset Evaluation

在这里插入图片描述

void __StartUpSoftware(void)
{
    /* Set the PSW to its reset value in case of a warm start,clear PSW.IS */
    Ifx_Ssw_MTCR(CPU_PSW, IFX_CFG_SSW_PSW_DEFAULT);
    Ifx_Ssw_MTCR(CPU_PCXI, IFX_CFG_SSW_PCXI_DEFAULT);
    Ifx_Ssw_MTCR(CPU_FCX, IFX_CFG_SSW_FCX_DEFAULT);

    /* This phase is executed only if last reset is not of type application reset */
    if (Ifx_Ssw_isApplicationReset() != 1)
    {
        Ifx_Ssw_jumpToFunction(__StartUpSoftware_Phase2);
    }
    else
    {
        Ifx_Ssw_jumpToFunction(__StartUpSoftware_Phase3ApplicationResetPath);
    }
}

设置PSW,PCXI,FCX寄存器为默认值,判断复位原因是否为Application复位,如果不是,则进入Phase2,否则进入Phase3ApplicationResetPath

Ifx_Ssw_isApplicationReset函数执行流程如下:
在这里插入图片描述

Startup Software: Phase 2-PMS, LBIST, MBIST Handling

在这里插入图片描述
›仅当上次复位为上电复位时,才执行此部分
在这一阶段的开始,电源的相关配置已经完成
›上次启动LBIST,导致电源热复位。这个阶段再次被执行。
›在LBIST错误的情况下触发回调应用程序
›CPU0 Stack和CSA触发MBIST (100MHz SPB)

static void __StartUpSoftware_Phase2(void)
{
    /* Power and EVRC configurations */
    IFX_CFG_SSW_CALLOUT_PMS_INIT();

    /* LBIST Tests and evaluation */
    IFX_CFG_SSW_CALLOUT_LBIST();

    /* MONBIST Tests and evaluation */
    IFX_CFG_SSW_CALLOUT_MONBIST();

    Ifx_Ssw_jumpToFunction(__StartUpSoftware_Phase3PowerOnResetPath);
}

实际是否执行BISI检测,需要对宏定义进行确认

Startup Software: Phase 3-Enabling Function Calls @ CPU0

在这里插入图片描述
›所有类型的重置都会执行此阶段
初始化CPU0 USTACK(用户栈指针)
-建立CPU0 CSA链表(上下文保存区)
—首次处理CPU0看门狗和Safety看门狗
;注意:
从这个时间点开始允许函数调用。但是Stack和CSA并没有经过完全的测试。
-还不能使用全局变量

static void __StartUpSoftware_Phase3PowerOnResetPath(void)
{
    IFX_SSW_INIT_CONTEXT();

    Ifx_Ssw_jumpToFunction(__StartUpSoftware_Phase4);
}

USTACK和CSA在IFX_SSW_INIT_CONTEXT进行初始化,实际并没有对看门狗处理

Startup Software: Phase 4-PLL and Clocks

在这里插入图片描述

static void __StartUpSoftware_Phase4(void)
{
    /* This is for ADAS chip, where clock is provided by MMIC chip. This has to be
     * implemented according the board.
     */
    IFX_CFG_SSW_CALLOUT_MMIC_CHECK();

    {
        /* Update safety and cpu watchdog reload value*/
        unsigned short cpuWdtPassword    = Ifx_Ssw_getCpuWatchdogPasswordInline(&MODULE_SCU.WDTCPU[0]);
        unsigned short safetyWdtPassword = Ifx_Ssw_getSafetyWatchdogPasswordInline();

        /* servicing watchdog timers */
        Ifx_Ssw_serviceCpuWatchdog(&MODULE_SCU.WDTCPU[0], cpuWdtPassword);
        Ifx_Ssw_serviceSafetyWatchdog(safetyWdtPassword);
    }

    /* Initialize the clock system */
    IFX_CFG_SSW_CALLOUT_PLL_INIT();

    /* MBIST Tests and evaluation */
    IFX_CFG_SSW_CALLOUT_MBIST();

    Ifx_Ssw_jumpToFunction(__StartUpSoftware_Phase5);
}

MMIC检测,PLL,MBIST目前都没有内容,该阶段实际只有看门狗处理

Startup Software: Phase 5-Multicore Startup

在这里插入图片描述

static void __StartUpSoftware_Phase5(void)
{
    /* SMU alarm handling */
    IFX_CFG_SSW_CALLOUT_SMU();

    Ifx_Ssw_jumpToFunction(__StartUpSoftware_Phase6);
}

实际代码中阶段5 SMU配置没有内容,也没有启动多核

Startup Software: Phase 6-C Initialization

在这里插入图片描述

static void __StartUpSoftware_Phase6(void)
{
    /* Start remaining cores as a daisy-chain */
#if (IFX_CFG_SSW_ENABLE_TRICORE1 != 0)
    Ifx_Ssw_startCore(&MODULE_CPU1, (unsigned int)__START(1));           /*The status returned by function call is ignored */
#endif /* #if (IFX_CFG_CPU_CSTART_ENABLE_TRICORE1 != 0)*/
#if (IFX_CFG_SSW_ENABLE_TRICORE1 == 0)
#if (IFX_CFG_SSW_ENABLE_TRICORE2 != 0)
    Ifx_Ssw_startCore(&MODULE_CPU2, (unsigned int)__START(2));           /*The status returned by function call is ignored */
#endif
#endif /* #if (IFX_CFG_SSW_ENABLE_TRICORE1 == 0) */

    Ifx_Ssw_jumpToFunction(__Core0_start);
}

这个阶段实际也没有使能cache,设置中断,初始化全局变量,这些操作在__Core0_start里进行,此处的启动从核也没有起作用,后面是通过OS来启动多核的。

总结

IFX中的启动流程,有很多都没有起作用,例如PLL,BISI,SMU,Cache等,在__Core0_start中还有一些初始化之后,才会跳转到main函数中,后面会继续介绍。


网站公告

今日签到

点亮在社区的每一天
去签到