Загрузка данных
void Board_TestM7Update(void)
{
int32_t status;
uint32_t m7_cpu_id = 1U;
uint8_t *src_buffer = (uint8_t *)0x90400000; // U-Boot load address
uint8_t *dst_buffer = (uint8_t *)0x80000000; // M7
size_t copy_size = 1024 * 1024; // Test size 1Mb
printf("[BOARD_UPDATE] Start update M7...\n");
/* Step 1. Stop the M7 logical machine */
status = LMM_CpuStop(s_lm, m7_cpu_id);
if (status != SM_ERR_SUCCESS)
{
printf("[BOARD_UPDATE] Error stop M7: %d\n", status);
return;
}
printf("[BOARD_UPDATE] Logical machine M7 has been successfully stopped.\n");
/* Step 2. Securely copying data using M33 */
// Since we've already opened the XRDC permissions, the standard memcpy will work successfully.
printf("[BOARD_UPDATE] Copying data from 0x%08X to 0x%08X...\n", (uint32_t)src_buffer, (uint32_t)dst_buffer);
memcpy(dst_buffer, src_buffer, copy_size);
/* Step 3. Clear the M33 data cache (if the cache is enabled for DDR regions in the MPU) */
// Ensures that the data physically reaches the DDR bus
#if defined(__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U)
SCB_CleanDCache_by_Addr((uint32_t *)dst_buffer, copy_size);
#endif
printf("[BOARD_UPDATE] Copying completed successfully.\n");
/* Step 4. Restarting the M7 logical machine */
status = LMM_CpuStart(s_lm, m7_cpu_id);
if (status != SM_ERR_SUCCESS)
{
printf("[BOARD_UPDATE] M7 startup error: %d\n", status);
return;
}
printf("[BOARD_UPDATE] Logical machine M7 successfully launched with new code!\n");
}
int32_t MONITOR_Dispatch(char *line)
{
int32_t status = SM_ERR_SUCCESS;
int32_t argc = 0;
const char *argv[MAXARGS];
/* Add here. Don't forget the comma. */
static string const cmds[] =
{
"?",
"help",
"exit",
"quit",
"info",
"ele",
"v2x",
"err",
"btime",
"trdc.raw",
"trdc",
"reason",
"shutdown",
"reset",
"stage",
"suspend",
"wake",
"wdog",
"fault",
"lm",
"power.r",
"power.w",
"perf.r",
"perf.w",
"clock.reset",
"clock.r",
"clock.w",
"sensor.r",
"sensor.w",
"rst.r",
"rst.w",
"volt.r",
"volt.w",
"bb.r",
"bb.w",
"cpu.r",
"cpu.w",
"ctrl.r",
"ctrl.w",
"ctrl.action",
"ctrl.notify",
"extctrl.r",
"extctrl.w",
"md.b",
"md.w",
"md",
"mm.b",
"mm.w",
"mm",
"fuse.r",
"fuse.w",
"pmic.r",
"pmic.w",
"idle",
"assert",
"syslog",
"grp",
"ssm",
"custom",
"test",
"delay",
"ddr",
"gcov",
"start_a55",
"update_m7"
};
/* Parse Line */
MONITOR_ParseLine(line, &argc, argv);
/* Parse command */
if (argc != 0)
{
int32_t sub = MONITOR_FindN(cmds, (int32_t) ARRAY_SIZE(cmds),
argv[0]);
switch (sub)
{
case 0: /* ? */
case 1: /* help */
for (uint8_t idx = 0U; idx < ARRAY_SIZE(cmds); idx++)
{
printf(" %s\n", cmds[idx]);
}
break;
case 2: /* exit */
case 3: /* quit */
status = SM_ERR_LAST;
break;
case 4: /* info */
status = MONITOR_CmdInfo(argc - 1, &argv[1]);
break;
case 5: /* ele */
status = MONITOR_CmdEle(argc - 1, &argv[1]);
break;
#ifdef DEVICE_HAS_V2X
case 6: /* v2x */
status = MONITOR_CmdV2x(argc - 1, &argv[1]);
break;
#endif
....
case 63: /* start_a55 */
printf("%s(%d) START A55\n",__FUNCTION__,__LINE__);
LMM_Boot_core(2U); // 2U = LM2(AP)
break;
case 64: /*update_m7*/
printf("%s(%d) Update M7\n",__FUNCTION__,__LINE__);
Board_TestM7Update();
break;
default:
status = SM_ERR_NOT_FOUND;
break;
}
}
/* Return status */
return status;
}