Загрузка данных
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 7: /* err */
status = MONITOR_CmdErr(argc - 1, &argv[1]);
break;
case 8: /* btime */
status = MONITOR_CmdBtime(argc - 1, &argv[1]);
break;
#ifdef DEVICE_HAS_TRDC
case 9: /* trdc.raw */
status = MONITOR_CmdTrdcRaw(argc - 1, &argv[1]);
break;
case 10: /* trdc */
status = MONITOR_CmdTrdc(argc - 1, &argv[1]);
break;
#endif
case 11: /* reset reason */
status = MONITOR_CmdReason(argc - 1, &argv[1]);
break;
case 12: /* shutdown */
status = MONITOR_CmdShutdown(argc - 1, &argv[1]);
break;
case 13: /* reset */
status = MONITOR_CmdReset(argc - 1, &argv[1]);
break;
case 14: /* stage */
status = MONITOR_CmdStage(argc - 1, &argv[1]);
break;
case 15: /* suspend */
status = MONITOR_CmdSuspend(argc - 1, &argv[1]);
break;
case 16: /* wake */
status = MONITOR_CmdWake(argc - 1, &argv[1]);
break;
#ifdef BOARD_HAS_WDOG
case 17: /* wdog */
status = MONITOR_CmdWdog(argc - 1, &argv[1]);
break;
#endif
case 18: /* fault */
status = MONITOR_CmdFault(argc - 1, &argv[1]);
break;
case 19: /* lm */
status = MONITOR_CmdLm(argc - 1, &argv[1]);
break;
case 20: /* power.r */
status = MONITOR_CmdPower(argc - 1, &argv[1], READ);
break;
case 21: /* power.w */
status = MONITOR_CmdPower(argc - 1, &argv[1], WRITE);
break;
case 22: /* perf.r */
status = MONITOR_CmdPerf(argc - 1, &argv[1], READ);
break;
case 23: /* perf.w */
status = MONITOR_CmdPerf(argc - 1, &argv[1], WRITE);
break;
case 24: /* clock.reset */
status = MONITOR_CmdClock(argc - 1, &argv[1], RESET);
break;
case 25: /* clock.r */
status = MONITOR_CmdClock(argc - 1, &argv[1], READ);
break;
case 26: /* clock.w */
status = MONITOR_CmdClock(argc - 1, &argv[1], WRITE);
break;
case 27: /* sensor.r */
status = MONITOR_CmdSensor(argc - 1, &argv[1], READ);
break;
case 28: /* sensor.w */
status = MONITOR_CmdSensor(argc - 1, &argv[1], WRITE);
break;
case 29: /* rst.r */
status = MONITOR_CmdRst(argc - 1, &argv[1], READ);
break;
case 30: /* rst.w */
status = MONITOR_CmdRst(argc - 1, &argv[1], WRITE);
break;
case 31: /* volt.r */
status = MONITOR_CmdVolt(argc - 1, &argv[1], READ);
break;
case 32: /* volt.w */
status = MONITOR_CmdVolt(argc - 1, &argv[1], WRITE);
break;
case 33: /* bb.r */
status = MONITOR_CmdBb(argc - 1, &argv[1], READ);
break;
case 34: /* bb.w */
status = MONITOR_CmdBb(argc - 1, &argv[1], WRITE);
break;
case 35: /* cpu.r */
status = MONITOR_CmdCpu(argc - 1, &argv[1], READ);
break;
case 36: /* cpu.w */
status = MONITOR_CmdCpu(argc - 1, &argv[1], WRITE);
break;
case 37: /* ctrl.r */
status = MONITOR_CmdCtrl(argc - 1, &argv[1], READ);
break;
case 38: /* ctrl.w */
status = MONITOR_CmdCtrl(argc - 1, &argv[1], WRITE);
break;
case 39: /* ctrl.action */
status = MONITOR_CmdCtrl(argc - 1, &argv[1], ACTION);
break;
case 40: /* ctrl.notify */
status = MONITOR_CmdCtrl(argc - 1, &argv[1], NOTIFY);
break;
case 41: /* extctrl.r */
status = MONITOR_CmdExtCtrl(argc - 1, &argv[1], READ);
break;
case 42: /* extctrl.w */
status = MONITOR_CmdExtCtrl(argc - 1, &argv[1], WRITE);
break;
case 43: /* md.b */
status = MONITOR_CmdMd(argc - 1, &argv[1], BYTE);
break;
case 44: /* md.w */
status = MONITOR_CmdMd(argc - 1, &argv[1], WORD);
break;
case 45: /* md.l */
status = MONITOR_CmdMd(argc - 1, &argv[1], LONG);
break;
case 46: /* mm.b */
status = MONITOR_CmdMm(argc - 1, &argv[1], BYTE);
break;
case 47: /* mm.w */
status = MONITOR_CmdMm(argc - 1, &argv[1], WORD);
break;
case 48: /* mm.l */
status = MONITOR_CmdMm(argc - 1, &argv[1], LONG);
break;
case 49: /* fuse.r */
status = MONITOR_CmdFuse(argc - 1, &argv[1], READ);
break;
case 50: /* fuse.w */
status = MONITOR_CmdFuse(argc - 1, &argv[1], WRITE);
break;
#ifdef BOARD_HAS_PMIC
case 51: /* pmic.r */
status = MONITOR_CmdPmic(argc - 1, &argv[1], READ);
break;
case 52: /* pmic.w */
status = MONITOR_CmdPmic(argc - 1, &argv[1], WRITE);
break;
#endif
case 53: /* idle */
status = MONITOR_CmdIdle(argc - 1, &argv[1]);
break;
case 54: /* assert */
status = MONITOR_CmdAssert(argc - 1, &argv[1]);
break;
case 55: /* syslog */
status = MONITOR_CmdSyslog(argc - 1, &argv[1]);
break;
case 56: /* group */
status = MONITOR_CmdGroup(argc - 1, &argv[1]);
break;
case 57: /* ssm */
status = MONITOR_CmdSsm(argc - 1, &argv[1]);
break;
case 58: /* custom */
status = MONITOR_CmdCustom(argc - 1, &argv[1]);
break;
case 59: /* test */
status = MONITOR_CmdTest(argc - 1, &argv[1]);
break;
case 60: /* delay */
status = MONITOR_CmdDelay(argc - 1, &argv[1]);
break;
case 61: /* ddr */
status = MONITOR_CmdDdr(argc - 1, &argv[1]);
break;
#if defined(GCOV) && !defined(SIMU)
case 62: /* gcov */
GCOV_InfoDump();
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;
}