Skip to content
Snippets Groups Projects
Commit 8edffecd authored by Ronny Nilsson's avatar Ronny Nilsson
Browse files

- Add read only mode for pureUBI, where we only print the sequence number.

- No need for specifying a UBI volume for the sequence number. The program scans them all automatically.
parent b6f00b82
Branches
No related tags found
No related merge requests found
......@@ -376,8 +376,11 @@ generate_image(const char *in_file, char *sequence_number)
int inFd, res;
long offset;
if(!in_file)
exit(1);
if(!in_file) {
if (verbose) printf("Assuming Broadcom pureUBI (without check).\n");
if(gen_image_ubi(sequence_number)) exit(1);
return 0;
}
inFd = open(in_file, O_RDONLY);
if(inFd == -1) {
......@@ -428,7 +431,7 @@ generate_image(const char *in_file, char *sequence_number)
if (verbose) printf("Image is of UBI METADATA.\n");
free(buf);
close(inFd);
if(gen_image_ubi(in_file, sequence_number)) exit(1);
if(gen_image_ubi(sequence_number)) exit(1);
return 0;
}
}
......@@ -810,8 +813,10 @@ static void usage(void)
"---- generic options ----\n"
" -V verbose mode\n"
"\n"
"Example: To set a new sequence number on a file\n"
" brcm_fw_tool -s 002 update firmware_in firmware_out\n"
"Example: To set a new sequence number on a JFFS2 file\n"
" brcm_fw_tool -s 002 update firmware_in\n"
" To set a new sequence number in a pureUBI system\n"
" brcm_fw_tool update\n"
" To check the signature, returns 0 on succes, 1 on fail\n"
" brcm_fw_tool check firmware_in\n"
" To return the chip id from the firmware signature\n"
......@@ -965,15 +970,12 @@ int main (int argc, char **argv)
argc -= optind;
argv += optind;
if (argc < 1)
usage();
if (verbose) fprintf(stderr, "Verbose mode active\n");
if ((strcmp(argv[0], "check") == 0) && (argc == 2)) {
cmd = CMD_SIGNATURE_CHECK;
in_file = argv[1];
} else if ((strcmp(argv[0], "update") == 0) && (argc == 2)) {
} else if ((strcmp(argv[0], "update") == 0) && (argc >= 1)) {
cmd = CMD_GENERATE_UPDATE_IMAGE;
in_file = argv[1];
} else if ((strcmp(argv[0], "write") == 0) && (argc == 2)) {
......
......
......@@ -710,7 +710,7 @@ static int meta_generate_blob(const char *tmpPath, int seqNo)
// We want at least two active at all times (for being able
// to select booting previous or latest). For a short period
// of time we also need a third for ensuring atomicity.
static int meta_manage_vols(void)
static int meta_manage_vols(int readonly)
{
int highSeqNo, highMeta, i, newMeta, delMeta, wrapSeqNo;
struct metaInfo_t *tmpMeta;
......@@ -742,6 +742,11 @@ static int meta_manage_vols(void)
}
}
if(readonly) {
printf("%d\n", highSeqNo);
return 0;
}
// Decide which old meta volume to erase and which to create fresh.
switch(metaInfos[highMeta].volInfo.vol_id) {
case METAVOLID0:
......@@ -802,12 +807,13 @@ static int meta_manage_vols(void)
//-------------------------------------------------------------
// main() of Broadcom "METADATA" UBI volume management.
int gen_image_ubi(const char *in_file, char *sequence_number)
int gen_image_ubi(char *sequence_number)
{
int res, i;
int res, i, readonly;
// Init
res = 0;
readonly = 0;
for(i = 0; i < MAX_METAS; i++) {
metaInfos[i].found = 0;
......@@ -821,19 +827,15 @@ int gen_image_ubi(const char *in_file, char *sequence_number)
if(!tmpMetaBlob) return -1;
tmpMetaBlob = strdup(tmpMetaBlob);
/*if(sequence_number && strncmp(sequence_number, "-1", 3) == 0) {
seqNo = meta_find_seqno(in_file, sequence_number);
if (verbose) printf("Sequence number ");
printf("%d\n", seqNo);
}*/
readonly = (sequence_number && strncmp(sequence_number, "-1", 3) == 0);
if(!res) res = ubi_probe();
if(!res) res = meta_find_all();
if(!res) res = meta_manage_vols();
if(!res) res = meta_manage_vols(readonly);
// Possibly erase the temporary file.
if(tmpMetaBlob) {
unlink(tmpMetaBlob);
if(!readonly) unlink(tmpMetaBlob);
free(tmpMetaBlob);
tmpMetaBlob = NULL;
}
......
......
......@@ -17,6 +17,6 @@ extern char ubiStr1[];
//-------------------------------------------------------------
int gen_image_ubi(const char *in_file, char *sequence_number);
int gen_image_ubi(char *sequence_number);
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment