int_32 Shell_bootloader_go_image(int_32 argc, char_ptr argv[] ) { /* Body */ boolean print_usage, shorthelp = FALSE; int_32 return_code = SHELL_EXIT_SUCCESS; print_usage = Shell_check_help_request(argc, argv, &shorthelp ); if (!print_usage) { _autoboot_cmd = AUTOBOOT_DISABLE; _image_index = _io_atoi(argv[1]); if(_bootloader_check_image(FALSE,_image_index)) { printf("\nStarting application at image:%d\n",_image_index); _mqx_exit(0); } else { printf("\nError no image found !\n"); } } if (print_usage) { if (shorthelp) { printf("%s [<index>] \n", argv[0]); } else { printf("Usage: %s [<index>] \n", argv[0]); printf(" <index> = image index in memory table \n"); } } }
int_32 Shell_bootloader_del_image(int_32 argc, char_ptr argv[] ) { /* Body */ boolean print_usage, shorthelp = FALSE; int_32 return_code = SHELL_EXIT_SUCCESS; uint_32 index, block, result; print_usage = Shell_check_help_request(argc, argv, &shorthelp ); if (!print_usage) { if ((argc < 2) || (argc >= 3)) { printf("Error, invalid number of parameters\n"); return_code = SHELL_EXIT_ERROR; print_usage=TRUE; } else { index = _io_atoi(argv[1]); _bootloader_del_image(index); } } if (print_usage) { if (shorthelp) { printf("%s <index> \n", argv[0]); } else { printf("Usage: %s <index> \n", argv[0]); printf(" <index> = index of image to delete\n"); } } }
int_32 Shell_bootloader_set_timeout(int_32 argc, char_ptr argv[] ) { /* Body */ boolean print_usage, shorthelp = FALSE; int_32 return_code = SHELL_EXIT_SUCCESS; int_32 index,timeout; print_usage = Shell_check_help_request(argc, argv, &shorthelp ); if (!print_usage) { if (argc != 3) { printf("Error, invalid number of parameters\n"); return_code = SHELL_EXIT_ERROR; print_usage=TRUE; } else { index = _io_atoi( argv[1]); timeout = _io_atoi( argv[2]); if (MQX_OK ==_bootloader_set_timeout(index,timeout)){ printf ("Set image %d autoboot timeout in %d seconds success\n",index,timeout); } else{ printf ("Set default error\n "); } } } if (print_usage) { if (shorthelp) { printf("%s <index> <timeout>\n", argv[0]); } else { printf("Usage: %s <index> <timeout> \n", argv[0]); printf(" <index> = Image index to set autoboot timeout\n"); printf(" <timeout> = Timeout value in second\n"); } } } /* Endbody */
int_32 Shell_bootloader_store_image(int_32 argc, char_ptr argv[] ) { /* Body */ boolean print_usage, shorthelp = FALSE; int_32 return_code = SHELL_EXIT_SUCCESS; uint_32 addr, size, result; uchar buffer[] = {1,2,3,4,5,6,7,8,9,0}; print_usage = Shell_check_help_request(argc, argv, &shorthelp ); if (!print_usage) { if (argc!=2) { printf("Error, invalid number of parameters\n"); return_code = SHELL_EXIT_ERROR; print_usage=TRUE; } else { addr = _io_atoi(argv[1]); size = _io_atoi(argv[2]); _bootloader_store_image(addr, size, buffer,(uchar_ptr)"default"); } } if (print_usage) { if (shorthelp) { printf("%s <add> <size> \n", argv[0]); } else { printf("Usage: %s <add> <size>\n", argv[0]); printf(" <add> = addrees begin to store"); printf(" <size>= size image to store "); } } }
int_32 Shell_erase(int_32 argc, char_ptr argv[] ) { /* Body */ boolean print_usage, shorthelp = FALSE; int_32 return_code = SHELL_EXIT_SUCCESS; uint_32 block; MQX_FILE_PTR fd; char_ptr abs_path; boolean cache_enabled=TRUE; SHELL_CONTEXT_PTR shell_ptr = Shell_get_context( argv ); char buf[SHELL_BLOCK_SIZE]; MQX_FILE_PTR nandflash_hdl; print_usage = Shell_check_help_request(argc, argv, &shorthelp ); if (!print_usage) { nandflash_hdl = fopen("nandflash:", NULL); if ((argc < 2) || (argc >= 3)) { printf("Error, invalid number of parameters\n"); return_code = SHELL_EXIT_ERROR; print_usage=TRUE; } block = _io_atoi( argv[1]); if(MQX_OK != ioctl(nandflash_hdl, NANDFLASH_IOCTL_ERASE_BLOCK, (void*)block)) printf("\n\nErasing block %d failed.",block); else printf("\n\nErasing block %d passed.\n",block); } if (print_usage) { if (shorthelp) { printf("%s <block>\n", argv[0]); } else { printf("Usage: %s <block> ", argv[0]); printf(" <block> = number of block to erase\n"); } } } /* Endbody */
int_32 Shell_bootloader_set_default(int_32 argc, char_ptr argv[] ) { /* Body */ boolean print_usage, shorthelp = FALSE; int_32 return_code = SHELL_EXIT_SUCCESS; int_8 index; print_usage = Shell_check_help_request(argc, argv, &shorthelp ); if (!print_usage) { if (argc != 2) { printf("Error, invalid number of parameters\n"); return_code = SHELL_EXIT_ERROR; print_usage=TRUE; } else { index = _io_atoi( argv[1]); if (MQX_OK ==_bootloader_set_default(index)){ printf ("Set image %d as default boot image success\n",index); } else{ printf ("Set default error\n "); } } } if (print_usage) { if (shorthelp) { printf("%s [<index>]", argv[0]); } else { printf("Usage: %s ", argv[0]); printf(" <%s> Image index to boot\n",argv[0]); } } } /* Endbody */