tools: rockchip: boot/trust_merger: add "--prepath" support

Add prefix path of binary path.

Change-Id: I576b9fa40f88a1ee0701f1ff776d25d4e3ed747b
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
This commit is contained in:
Joseph Chen 2019-05-23 18:19:46 +08:00
parent ab64d6564f
commit e311da2458
4 changed files with 20 additions and 0 deletions

View File

@ -21,6 +21,7 @@ bool gDebug =
options gOpts; options gOpts;
char gLegacyPath[MAX_LINE_LEN] = { 0 }; char gLegacyPath[MAX_LINE_LEN] = { 0 };
char gNewPath[MAX_LINE_LEN] = { 0 }; char gNewPath[MAX_LINE_LEN] = { 0 };
static char *gPrePath;
char gSubfix[MAX_LINE_LEN] = OUT_SUBFIX; char gSubfix[MAX_LINE_LEN] = OUT_SUBFIX;
char gEat[MAX_LINE_LEN]; char gEat[MAX_LINE_LEN];
char *gConfigPath; char *gConfigPath;
@ -148,6 +149,10 @@ static inline void fixPath(char *path)
strcpy(path, gNewPath); strcpy(path, gNewPath);
strcat(path, tmp); strcat(path, tmp);
} }
} else if (gPrePath) {
strcpy(tmp, path);
strcpy(path, gPrePath);
strcat(path, tmp);
} }
} }
@ -976,6 +981,7 @@ static void printHelp(void)
printf("\t" OPT_VERSION "\t\tDisplay version information.\n"); printf("\t" OPT_VERSION "\t\tDisplay version information.\n");
printf("\t" OPT_SUBFIX "\t\tSpec subfix.\n"); printf("\t" OPT_SUBFIX "\t\tSpec subfix.\n");
printf("\t" OPT_REPLACE "\t\tReplace some part of binary path.\n"); printf("\t" OPT_REPLACE "\t\tReplace some part of binary path.\n");
printf("\t" OPT_PREPATH "\t\tAdd prefix path of binary path.\n");
printf("\t" OPT_SIZE printf("\t" OPT_SIZE
"\t\tImage size.\"--size [image KB size]\", must be 512KB aligned\n"); "\t\tImage size.\"--size [image KB size]\", must be 512KB aligned\n");
printf("Usage2: boot_merger [options] [parameter]\n"); printf("Usage2: boot_merger [options] [parameter]\n");
@ -1021,6 +1027,9 @@ int main(int argc, char **argv)
snprintf(gLegacyPath, sizeof(gLegacyPath), "%s", argv[i]); snprintf(gLegacyPath, sizeof(gLegacyPath), "%s", argv[i]);
i++; i++;
snprintf(gNewPath, sizeof(gNewPath), "%s", argv[i]); snprintf(gNewPath, sizeof(gNewPath), "%s", argv[i]);
} else if (!strcmp(OPT_PREPATH, argv[i])) {
i++;
gPrePath = argv[i];
} else if (!strcmp(OPT_SIZE, argv[i])) { } else if (!strcmp(OPT_SIZE, argv[i])) {
g_merge_max_size = strtoul(argv[++i], NULL, 10); g_merge_max_size = strtoul(argv[++i], NULL, 10);
if (g_merge_max_size % 512) { if (g_merge_max_size % 512) {

View File

@ -186,6 +186,7 @@ typedef struct {
#define OPT_UNPACK "--unpack" #define OPT_UNPACK "--unpack"
#define OPT_SUBFIX "--subfix" #define OPT_SUBFIX "--subfix"
#define OPT_REPLACE "--replace" #define OPT_REPLACE "--replace"
#define OPT_PREPATH "--prepath"
#define OPT_SIZE "--size" #define OPT_SIZE "--size"
#define OPT_CHIP "-c" #define OPT_CHIP "-c"

View File

@ -51,6 +51,7 @@ static uint8_t gBuf[BL3X_FILESIZE_MAX];
static bool gSubfix; static bool gSubfix;
static char *gLegacyPath; static char *gLegacyPath;
static char *gNewPath; static char *gNewPath;
static char *gPrePath;
static uint8_t gRSAmode = RSA_SEL_2048; static uint8_t gRSAmode = RSA_SEL_2048;
static uint8_t gSHAmode = SHA_SEL_256; static uint8_t gSHAmode = SHA_SEL_256;
static bool gIgnoreBL32; static bool gIgnoreBL32;
@ -109,6 +110,10 @@ static inline void fixPath(char *path)
strcpy(path, gNewPath); strcpy(path, gNewPath);
strcat(path, tmp); strcat(path, tmp);
} }
} else if (gPrePath) {
strcpy(tmp, path);
strcpy(path, gPrePath);
strcat(path, tmp);
} }
} }
@ -833,6 +838,7 @@ static void printHelp(void)
printf("\t" OPT_VERSION "\t\tDisplay version information.\n"); printf("\t" OPT_VERSION "\t\tDisplay version information.\n");
printf("\t" OPT_SUBFIX "\t\tSpec subfix.\n"); printf("\t" OPT_SUBFIX "\t\tSpec subfix.\n");
printf("\t" OPT_REPLACE "\t\tReplace some part of binary path.\n"); printf("\t" OPT_REPLACE "\t\tReplace some part of binary path.\n");
printf("\t" OPT_PREPATH "\t\tAdd prefix path of binary path.\n");
printf("\t" OPT_RSA "\t\t\tRSA mode.\"--rsa [mode]\", [mode] can be: " printf("\t" OPT_RSA "\t\t\tRSA mode.\"--rsa [mode]\", [mode] can be: "
"0(none), 1(1024), 2(2048), 3(2048 pss).\n"); "0(none), 1(1024), 2(2048), 3(2048 pss).\n");
printf("\t" OPT_SHA printf("\t" OPT_SHA
@ -870,6 +876,9 @@ int main(int argc, char **argv)
gLegacyPath = argv[i]; gLegacyPath = argv[i];
i++; i++;
gNewPath = argv[i]; gNewPath = argv[i];
} else if (!strcmp(OPT_PREPATH, argv[i])) {
i++;
gPrePath = argv[i];
} else if (!strcmp(OPT_RSA, argv[i])) { } else if (!strcmp(OPT_RSA, argv[i])) {
i++; i++;
if (!is_digit(*(argv[i]))) { if (!is_digit(*(argv[i]))) {

View File

@ -44,6 +44,7 @@
#define OPT_UNPACK "--unpack" #define OPT_UNPACK "--unpack"
#define OPT_SUBFIX "--subfix" #define OPT_SUBFIX "--subfix"
#define OPT_REPLACE "--replace" #define OPT_REPLACE "--replace"
#define OPT_PREPATH "--prepath"
#define OPT_RSA "--rsa" #define OPT_RSA "--rsa"
#define OPT_SHA "--sha" #define OPT_SHA "--sha"
#define OPT_SIZE "--size" #define OPT_SIZE "--size"