【简介】
从S32K388 的以下框图中可知,S32K388 有4个核心组成,CM7_0 和 CM7_1 默认为lockstep配置,CM7_2 为固定lockstep核心不可拆开使用,在此贴中(【S32K3学习整理】Lockstep和Decoupled 模式)已经将CM7_0 和CM7_1 配置为Decoupled 模式。

在之前的贴子中介绍过Boot core 启动其他核心的过程(【S32K3XX】MCME 启动 CORE1),启动过程可以查看此贴,在此就不再重复赘述了,添加如下代码启动其他核心。
void Mcme_Start_Core(uint8_t core,uint32_t startAddrCore)
{
if(core == 1)
{
IP_MC_ME->PRTN0_CORE1_ADDR = startAddrCore;
IP_MC_ME->PRTN0_CORE1_PCONF = 0x00000001;
IP_MC_ME->PRTN0_CORE1_PUPD = 0x00000001;
IP_MC_ME->CTL_KEY = 0x5AF0U;
IP_MC_ME->CTL_KEY = 0xA50FU;
while((IP_MC_ME->PRTN0_CORE1_STAT&0x0001) != 1);
}
else if(core == 2)
{
IP_MC_ME->PRTN0_CORE3_ADDR = startAddrCore;
IP_MC_ME->PRTN0_CORE3_PCONF = 0x00000001;
IP_MC_ME->PRTN0_CORE3_PUPD = 0x00000001;
IP_MC_ME->CTL_KEY = 0x5AF0U;
IP_MC_ME->CTL_KEY = 0xA50FU;
while((IP_MC_ME->PRTN0_CORE3_STAT&0x0001) != 1);
}
else if(core == 3)
{
IP_MC_ME->PRTN0_CORE4_ADDR = startAddrCore;
IP_MC_ME->PRTN0_CORE4_PCONF = 0x00000001;
IP_MC_ME->PRTN0_CORE4_PUPD = 0x00000001;
IP_MC_ME->CTL_KEY = 0x5AF0U;
IP_MC_ME->CTL_KEY = 0xA50FU;
while((IP_MC_ME->PRTN0_CORE4_STAT&0x0001) != 1);
}
else
{
/* Invalid core number */
}
}
/********************************************************************************************************
* Shell command define *
*******************************************************************************************************/
#if (CFG_OS_TYPE == OS_TYPE_FREERTOS)
/* FreeRtos include file */
#include "FreeRTOS.h"
#include "task.h"
#endif
unsigned int kickcore(char argc, char **argv)
{
if(argc == 3)
{
uint8_t core = (uint8_t)atoi(argv[1]);
uint32_t startAddr = (uint32_t)atohex(argv[2]);
Mcme_Start_Core(core, startAddr);
#if (CFG_OS_TYPE == OS_TYPE_FREERTOS)
vTaskDelay(1000);
#endif
}
return 0;
} 本地编译好其他三个核心的镜像分别位于0x600000/0x800000/0xa00000的地址,每个核心运行如下的测试代码输出自身的CORE ID信息。
/*==================================================================================================
* Project : RTD AUTOSAR 4.9
* Platform : CORTEXM
* Peripheral : S32K3XX
* Dependencies : none
*
* Autosar Version : 4.9.0
* Autosar Revision : ASR_REL_4_9_REV_0000
* Autosar Conf.Variant :
* SW Version : 7.0.1
* Build Version : S32K3_RTD_7_0_1_D2602_ASR_REL_4_9_REV_0000_20260206
*
* Copyright 2020 - 2026 NXP
*
* NXP Confidential and Proprietary. This software is owned or controlled by NXP and may only be
* used strictly in accordance with the applicable license terms. By expressly
* accepting such terms or by downloading, installing, activating and/or otherwise
* using the software, you are agreeing that you have read, and that you agree to
* comply with and are bound by, such license terms. If you do not agree to be
* bound by the applicable license terms, then you may not retain, install,
* activate or otherwise use the software.
==================================================================================================*/
/**
* @file main.c
*
* @addtogroup main_module main module documentation
* @{
*/
#ifdef __cplusplus
extern "C"{
#endif
/* Including necessary configuration files. */
#include "printf.h"
#include "Mcal.h"
volatile int exit_code = 0;
/* User includes */
/*!
\brief The main function for the project.
\details The startup initialization sequence is the following:
* - startup asm routine
* - main()
*/
extern uint8 Sys_GetCoreID(void);
int main(void)
{
/* Write your code here */
PRINTF("I AM Core%d\r\n",Sys_GetCoreID());
for(;;)
{
if(exit_code != 0)
{
break;
}
}
return exit_code;
}
#ifdef __cplusplus
}
#endif
/** @} */本地通过core0 去启动其他三个核心,其他核运行成功按照预期的打印输出各自的CORE ID信息。

我要赚赏金
