Files
luban-lite-t3e-pro/application/baremetal/helloworld/cmd/reset.c

54 lines
1.1 KiB
C
Raw Normal View History

2023-11-09 20:19:51 +08:00
/*
2023-08-30 16:21:18 +08:00
* Copyright (c) 2023, Artinchip Technology Co., Ltd
*
* SPDX-License-Identifier: Apache-2.0
*
* Wu Dehuang <dehuang.wu@artinchip.com>
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <console.h>
#include <aic_core.h>
#include <aic_common.h>
#include <aic_errno.h>
#include <aic_hal.h>
#include <hal_rtc.h>
#include <wdt.h>
static int do_reset_boot(int argc, char *argv[])
{
2024-01-27 08:47:24 +08:00
#ifdef AIC_WDT_DRV
2023-08-30 16:21:18 +08:00
wdt_init();
2024-06-04 19:00:30 +08:00
printf("Restarting system ...\n");
2024-01-27 08:47:24 +08:00
#endif
2023-11-09 20:19:51 +08:00
#ifdef AIC_WRI_DRV
2023-08-30 16:21:18 +08:00
aic_set_reboot_reason(REBOOT_REASON_CMD_REBOOT);
2023-11-09 20:19:51 +08:00
#endif
2024-01-27 08:47:24 +08:00
#ifdef AIC_WDT_DRV
2023-08-30 16:21:18 +08:00
wdt_expire_now();
2024-04-03 16:40:57 +08:00
while(1) {};
2024-01-27 08:47:24 +08:00
#endif
2023-08-30 16:21:18 +08:00
return 0;
}
CONSOLE_CMD(reset, do_reset_boot, "Reboot device.");
CONSOLE_CMD(reboot, do_reset_boot, "Reboot device.");
static int cmd_aicupg(int argc, char **argv)
{
2023-11-09 20:19:51 +08:00
#ifdef AIC_WRI_DRV
2024-06-04 19:00:30 +08:00
if ((argc == 2) && !strcmp(argv[1], "gotobl"))
aic_set_reboot_reason(REBOOT_REASON_BL_UPGRADE);
else
aic_set_reboot_reason(REBOOT_REASON_UPGRADE);
2023-11-09 20:19:51 +08:00
#endif
2023-08-30 16:21:18 +08:00
do_reset_boot(0, NULL);
return 0;
}
CONSOLE_CMD(aicupg, cmd_aicupg, "Reboot to the upgrade mode.");