Files
SDK_SG200x_V2/u-boot-2021.10/cmd/cvi_sd_update.c
carbon 0545e9dc6d init version 2024-05-07
commit d1edce71135cc6d98c0a4b5729774542b676e769
Author: sophgo-forum-service <forum_service@sophgo.com>
Date:   Fri Mar 15 16:07:33 2024 +0800

    [fix] recommend using ssh method to clone repo.
    [fix] fix sensor driver repo branch name.
2024-05-07 19:36:36 +08:00

69 lines
1.7 KiB
C

#include <stdlib.h>
#include <common.h>
#include <config.h>
#include <command.h>
#include <cvsnfc.h>
#define BIT_WRITE_FIP_BIN BIT(0)
#define BIT_WRITE_ROM_PATCH BIT(1)
#define BIT_WRITE_BLD BIT(2)
#define COMPARE_STRING_LEN 6
//------------------------------------------------------------------------------
// data type definitions: typedef, struct or class
//------------------------------------------------------------------------------
#define PTR_INC(base, offset) (void *)((uint8_t *)(base) + (offset))
static int do_cvi_sd_update(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[])
{
char *addr;
uint32_t component = 0;
if (argc != 4) {
printf("Usage:\n%s\n", cmdtp->usage);
return 1;
}
addr = (char *)simple_strtol(argv[1], NULL, 16);
if (!addr) {
printf("Usage:\n%s\n", cmdtp->usage);
return 1;
}
printf("addr %p\n", addr);
if (!strncmp(argv[3], "fip", COMPARE_STRING_LEN)) {
printf("fip.bin\n");
component |= BIT_WRITE_FIP_BIN;
} else if (!strncmp(argv[3], "patch", COMPARE_STRING_LEN)) {
printf("patch\n");
component |= BIT_WRITE_ROM_PATCH;
} else if (!strncmp(argv[3], "all", COMPARE_STRING_LEN)) {
printf("all\n");
component |= BIT_WRITE_FIP_BIN | BIT_WRITE_ROM_PATCH | BIT_WRITE_BLD;
} else {
printf("Usage:\n%s\n", cmdtp->usage);
return 1;
}
if (!strncmp(argv[2], "spinand", COMPARE_STRING_LEN)) {
do_cvi_update_spinand(component, addr);
} else {
printf("Usage:\n%s\n", cmdtp->usage);
return 1;
}
return 0;
}
U_BOOT_CMD(cvi_sd_update, 4, 0, do_cvi_sd_update,
"cvi_sd_update - write images to SPI NAND\n",
"cvi_sd_update addr dev_type img_type - Print a report\n"
"addr : data memory address\n"
"dev_type : spinand\n"
"img_type : fip/patch/all\n"
);