blob: 0ab492bd3a90e298b520f169a644fd05c013d44b [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001#include <common.h>
2#include <command.h>
3#include <asr_flag.h>
4
5//#define CMD_ASR_FLAG_CFG_PROD
6
7int do_asr_flag (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
8{
9 u32 len;
10 int i;
11 u32 *ptr;
12 struct asr_firmware_flag *p_asr_flag = get_asr_flag();
13
14 if (strcmp (argv[1], "ota") == 0) {
15 p_asr_flag->upgrade_flag = 1;
16 p_asr_flag->upgrade_method = simple_strtoul(argv[2], NULL, 10);
17 p_asr_flag->fbf_flash_address = simple_strtoul(argv[3], NULL, 16);
18 p_asr_flag->fbf_file_size = simple_strtoul(argv[4], NULL, 16);
19 if (p_asr_flag->upgrade_method == 4 /*dfota/sdfota*/) {
20 p_asr_flag->dfota_n_of_images = 0xFFFFFFFF;
21 p_asr_flag->dfota_need_copy_only = 0;
22 p_asr_flag->dfota_conpy_len = 0;
23 memset(&p_asr_flag->SDfotaInfo, 0, sizeof(SDfotaState));
24 printf("dfota or sdfota triggered\n");
25 } else {
26 printf("fota triggered\n");
27 }
28 asr_flag_update();
29 return 0;
30 }
31
32 if (strcmp (argv[1], "nocp") == 0) {
33 p_asr_flag->nocp[0] = 0x50434F4E;
34 p_asr_flag->nocp[1] = simple_strtoul(argv[2], NULL, 10);
35 printf("set nocp mode as %d\n", p_asr_flag->nocp[1]);
36 asr_flag_update();
37 return 0;
38 }
39
40 if (strcmp (argv[1], "dump") == 0) {
41 len = (sizeof(struct asr_firmware_flag)) >> 2;
42 ptr = (u32 *)p_asr_flag;
43 printf("ASR Flag dump:\n");
44 for (i = 0; i < len; i++) {
45 printf("0x%08x ", ptr[i]);
46 if((i + 1)%4 == 0)
47 printf("\n");
48 }
49 printf("\n");
50 return 0;
51 }
52
53#ifdef CMD_ASR_FLAG_CFG_PROD
54 if(strcmp (argv[1], "prod") == 0) {
55 p_asr_flag->production_mode_flag = simple_strtoul(argv[2], NULL, 10);
56 printf("set production mode as %d\n", p_asr_flag->production_mode_flag);
57 printf("need to reboot to take affect\n");
58 asr_flag_update();
59 return 0;
60 }
61#endif
62
63 printf("run 'help asr_flag' to check usage\n");
64
65 return 0;
66}
67
68U_BOOT_CMD(
69 asr_flag, 5, 1, do_asr_flag,
70 "ASR flag modify command",
71 "ota <method> <fbf_addr> <fbf_len> - trigger an OTA process\n"
72 "asr_flag nocp <mode> - configure nocp mode\n"
73 #ifdef CMD_ASR_FLAG_CFG_PROD
74 "asr_flag prod <mode> - configure production mode\n"
75 #endif
76 "asr_flag dump - dump asr flag content\n"
77);