【简介】
在之前的贴子中(【S32K3XX】HSE固件安装配置说明)介绍过HSE固件的安装过程,如果运行过程中异常的触发固件被擦除就需要通过MU 来进行固件的安装。
HSE 固件的安装HSE 的开发RM文档中有对应的而流程图我们按照对应的流程图实现即可完成HSE 的MU 安装,以下是对应的流程图和对应的步骤说明。


按照上述流程编写如下代码实现通过MU 完成固件的安装。
/*==================================================================================================
* LOCAL VARIABLES
*================================================================================================*/
static int32_t hse_install_status __attribute__((section(".standby_data")));
void hse_full_memory_install_mu(void)
{
/* 1. Write 0xA5 on register DCMRWP1 (0x402AC400, [24:31 bits]) followed by functional reset. This will
set Bit 1 in HSE GPR (0x4039C028) indicating SBAF has activated MU0 for installation */
if(!(hse_install_status >= 0x5a6bc7d0 && hse_install_status <= 0x5a6bc7d7))
{
REG_WRITE32(0x402AC400,(REG_READ32(0x402AC400) & 0x00FFFFFF) | (0x00000000));
REG_WRITE32(0x402AC400,(REG_READ32(0x402AC400) & 0x00FFFFFF) | (0xA5000000));
hse_install_status = 0x5a6bc7d0;
PRINTF("STEP1 : activate MU0 for installation.\r\n");
Power_Ip_MC_ME_SocTriggerResetEvent( POWER_IP_FUNC_RESET_MODE );
}
/* 2. If SBAF sends '0xFF00F00F' response on MU Rx register (0x4038c280) (that means new HSE
firmware installation is required) then go to next step.*/
if(hse_install_status == 0x5a6bc7d0)
{
PRINTF("Wait for SBAF sends '0xFF00F00F' response on MU Rx register (0x4038c280).\r\n");
while(REG_READ32(0x4038c280) != 0xFF00F00F);
hse_install_status = 0x5a6bc7d1;
PRINTF("STEP2 : Wait for SBAF sends '0xFF00F00F' response on MU Rx register (0x4038c280).\r\n");
}
/* 3. App Core to respond by writing value ‘0xF0F00F0F’ on MU Tx register (0x4038c200) to confirm
installation within 80 seconds. Go to next Step. */
if(hse_install_status == 0x5a6bc7d1)
{
PRINTF("Write value 0xF0F00F0F on MU Tx register (0x4038c200) to confirm installation.\r\n");
REG_WRITE32(0x4038c200, 0xF0F00F0F);
hse_install_status = 0x5a6bc7d2;
}
/* 4. SBAF sends ‘0xDADABABA’ on MU Rx register (0x4038c280). Go to next Step */
if(hse_install_status == 0x5a6bc7d2)
{
PRINTF("Wait for SBAF sends '0xDADABABA' response on MU Rx register (0x4038c280).\r\n");
while(REG_READ32(0x4038c280) != 0xDADABABA);
hse_install_status = 0x5a6bc7d3;
PRINTF("STEP4 : Wait for SBAF sends '0xDADABABA' response on MU Rx register (0x4038c280).\r\n");
}
/*App core responds by writing Pink Image Location on MU Tx register (0x4038c200) within 60 seconds. Go to next Step.
Steps for Active-Passive Block Partition Switching*/
if(hse_install_status == 0x5a6bc7d3)
{
PRINTF("Write Pink Image Location on MU Tx register (0x4038c200).\r\n");
REG_WRITE32(0x4038c200, 0x004DE000UL);
hse_install_status = 0x5a6bc7d4;
}
/*6. If SBAF sends '0xDACACADA' response on MU Rx register (0x4038c280) to indicate success and
go to next Step.*/
if(hse_install_status == 0x5a6bc7d4)
{
PRINTF("Wait for SBAF sends '0xDACACADA' response on MU Rx register (0x4038c280).\r\n");
while(REG_READ32(0x4038c280) != 0xDACACADA);
hse_install_status = 0x5a6bc7d5;
PRINTF("HSE FW Install Success.\r\n");
Power_Ip_MC_ME_SocTriggerResetEvent( POWER_IP_FUNC_RESET_MODE );
}
/* 8. App core must wait for Bit 0 in GPR to set (that means SBAF has completed and booted new HSE
Firmware). If the bit is NOT SET even after approximately 1 second, either you can retry again from
beginning or contact NXP */
if(hse_install_status == 0x5a6bc7d5)
{
PRINTF("Wait for Bit 0 in GPR to set (that means SBAF has completed and booted new HSE Firmware).\r\n");
while((REG_READ32(0x4039C028) & 0x1) == 0);
PRINTF("HSE FW Install Completed and Booted.\r\n");
while (1);
}
}
我要赚赏金
