mirror of
https://github.com/xboot/xrock.git
synced 2024-11-23 01:44:46 +08:00
[xrock]add upgrade command
This commit is contained in:
parent
583fe4a9ee
commit
8040e9050d
@ -57,6 +57,7 @@ For 32-bits windows, you can using `i686-w64-mingw32-` instead of `x86_64-w64-mi
|
||||
usage:
|
||||
xrock maskrom <ddr> <usbplug> [--rc4-off] - Initial chip using ddr and usbplug in maskrom mode
|
||||
xrock download <loader> - Initial chip using loader in maskrom mode
|
||||
xrock upgrade <loader> - Upgrade loader to flash in loader mode
|
||||
xrock ready - Show chip ready or not
|
||||
xrock version - Show chip version
|
||||
xrock capability - Show capability information
|
||||
|
63
main.c
63
main.c
@ -22,6 +22,7 @@ static void usage(void)
|
||||
printf("usage:\r\n");
|
||||
printf(" xrock maskrom <ddr> <usbplug> [--rc4-off] - Initial chip using ddr and usbplug in maskrom mode\r\n");
|
||||
printf(" xrock download <loader> - Initial chip using loader in maskrom mode\r\n");
|
||||
printf(" xrock upgrade <loader> - Upgrade loader to flash in loader mode\r\n");
|
||||
printf(" xrock ready - Show chip ready or not\r\n");
|
||||
printf(" xrock version - Show chip version\r\n");
|
||||
printf(" xrock capability - Show capability information\r\n");
|
||||
@ -149,6 +150,68 @@ int main(int argc, char * argv[])
|
||||
else
|
||||
usage();
|
||||
}
|
||||
else if(!strcmp(argv[1], "upgrade"))
|
||||
{
|
||||
argc -= 2;
|
||||
argv += 2;
|
||||
if(argc == 1)
|
||||
{
|
||||
struct rkloader_ctx_t * lctx = rkloader_ctx_alloc(argv[0]);
|
||||
if(lctx)
|
||||
{
|
||||
uint32_t sec = 64;
|
||||
enum storage_type_t type = rock_storage_read(&ctx);
|
||||
switch(type)
|
||||
{
|
||||
case STORAGE_TYPE_FLASH:
|
||||
sec = 64;
|
||||
break;
|
||||
case STORAGE_TYPE_EMMC:
|
||||
sec = 64;
|
||||
break;
|
||||
case STORAGE_TYPE_SD:
|
||||
sec = 64;
|
||||
break;
|
||||
case STORAGE_TYPE_SD1:
|
||||
sec = 64;
|
||||
break;
|
||||
case STORAGE_TYPE_SPINOR:
|
||||
sec = 128;
|
||||
break;
|
||||
case STORAGE_TYPE_SPINAND:
|
||||
sec = 512;
|
||||
break;
|
||||
case STORAGE_TYPE_RAM:
|
||||
sec = 64;
|
||||
break;
|
||||
case STORAGE_TYPE_USB:
|
||||
sec = 64;
|
||||
break;
|
||||
case STORAGE_TYPE_SATA:
|
||||
sec = 64;
|
||||
break;
|
||||
case STORAGE_TYPE_PCIE:
|
||||
sec = 64;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
struct flash_info_t info;
|
||||
if(rock_flash_detect(&ctx, &info))
|
||||
{
|
||||
if(!rock_flash_write_lba_progress(&ctx, sec, lctx->idblen / 512, lctx->idbbuf))
|
||||
printf("Failed to write flash\r\n");
|
||||
}
|
||||
else
|
||||
printf("Failed to detect flash\r\n");
|
||||
rkloader_ctx_free(lctx);
|
||||
}
|
||||
else
|
||||
printf("ERROR: Not a valid loader '%s'\r\n", argv[0]);
|
||||
}
|
||||
else
|
||||
usage();
|
||||
}
|
||||
else if(!strcmp(argv[1], "ready"))
|
||||
{
|
||||
argc -= 2;
|
||||
|
Loading…
Reference in New Issue
Block a user