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

sysupgrade: inform brcm_fw_tool which flash bank we are currently running on.

This will make brcm_fw_tool to force writing pureUBI into same flash bank
again and again even if invoked multiple times. This might happen if the
post-rootfs-fixup fails and the user retries again.
parent d68e4ba9
No related branches found
No related tags found
No related merge requests found
...@@ -783,6 +783,7 @@ static void usage(void) ...@@ -783,6 +783,7 @@ static void usage(void)
"Following options are available:\n" "Following options are available:\n"
" -s <sequencenumber> set new sequence number in output image\n" " -s <sequencenumber> set new sequence number in output image\n"
" [000-999] or -1 to just read current value\n" " [000-999] or -1 to just read current value\n"
" or [0-1] for pureUBI to force flash bank.\n"
" -d <mtddevice> mtd device to compare input file against\n" " -d <mtddevice> mtd device to compare input file against\n"
" -b return block size from signature check\n" " -b return block size from signature check\n"
" -t return flash type from signature check\n" " -t return flash type from signature check\n"
...@@ -821,7 +822,7 @@ static void usage(void) ...@@ -821,7 +822,7 @@ static void usage(void)
"Example: To set a new sequence number on a JFFS2 file\n" "Example: To set a new sequence number on a JFFS2 file\n"
" brcm_fw_tool -s 002 update firmware_in\n" " brcm_fw_tool -s 002 update firmware_in\n"
" To set a new sequence number in a pureUBI system\n" " To set a new sequence number in a pureUBI system\n"
" brcm_fw_tool update\n" " brcm_fw_tool -s <next bank> update\n"
" To check the signature, returns 0 on succes, 1 on fail\n" " To check the signature, returns 0 on succes, 1 on fail\n"
" brcm_fw_tool check firmware_in\n" " brcm_fw_tool check firmware_in\n"
" To return the chip id from the firmware signature\n" " To return the chip id from the firmware signature\n"
......
...@@ -750,7 +750,7 @@ static int meta_generate_blob(const char *tmpPath, int seqNo) ...@@ -750,7 +750,7 @@ static int meta_generate_blob(const char *tmpPath, int seqNo)
// We want at least two active at all times (for being able // We want at least two active at all times (for being able
// to select booting previous or latest). For a short period // to select booting previous or latest). For a short period
// of time we also need a third for ensuring atomicity. // of time we also need a third for ensuring atomicity.
static int meta_manage_vols(int readonly) static int meta_manage_vols(int readonly, int forcedBank)
{ {
int highSeqNo, highMeta, i, newMeta, delMeta, wrapSeqNo, newBank, res; int highSeqNo, highMeta, i, newMeta, delMeta, wrapSeqNo, newBank, res;
struct metaInfo_t *tmpMeta; struct metaInfo_t *tmpMeta;
...@@ -759,7 +759,6 @@ static int meta_manage_vols(int readonly) ...@@ -759,7 +759,6 @@ static int meta_manage_vols(int readonly)
highSeqNo = -1; highSeqNo = -1;
highMeta = 0; highMeta = 0;
wrapSeqNo = -1; wrapSeqNo = -1;
newBank = -1;
res = 0; res = 0;
// What is the highest metadata sequence number? // What is the highest metadata sequence number?
...@@ -790,8 +789,17 @@ static int meta_manage_vols(int readonly) ...@@ -790,8 +789,17 @@ static int meta_manage_vols(int readonly)
return 0; return 0;
} }
// Decide which old meta volume to erase and which to create fresh. // Has the user forced a specific flash bank for writing?
switch(metaInfos[highMeta].volInfo.vol_id) { if(forcedBank == 0) {
forcedBank = METAVOLID2;
}
else if(forcedBank == 1) {
forcedBank = METAVOLID0;
}
/* Decide which old meta volume to erase and which to create fresh.
* Either of: "next subsequent" or "user forced". */
switch(forcedBank >= 0 ? forcedBank : metaInfos[highMeta].volInfo.vol_id) {
case METAINVALID: case METAINVALID:
case METAVOLID0: case METAVOLID0:
case METAVOLID1: case METAVOLID1:
...@@ -865,11 +873,12 @@ static int meta_manage_vols(int readonly) ...@@ -865,11 +873,12 @@ static int meta_manage_vols(int readonly)
// main() of Broadcom "METADATA" UBI volume management. // main() of Broadcom "METADATA" UBI volume management.
int gen_image_ubi(char *sequence_number) int gen_image_ubi(char *sequence_number)
{ {
int res, i, readonly; int res, i, readonly, forcedBank;
// Init // Init
res = 0; res = 0;
readonly = 0; readonly = 0;
forcedBank = -1;
for(i = 0; i < MAX_METAS; i++) { for(i = 0; i < MAX_METAS; i++) {
metaInfos[i].found = 0; metaInfos[i].found = 0;
...@@ -883,11 +892,27 @@ int gen_image_ubi(char *sequence_number) ...@@ -883,11 +892,27 @@ int gen_image_ubi(char *sequence_number)
if(!tmpMetaBlob) return -1; if(!tmpMetaBlob) return -1;
tmpMetaBlob = strdup(tmpMetaBlob); tmpMetaBlob = strdup(tmpMetaBlob);
readonly = (sequence_number && strncmp(sequence_number, "-1", 3) == 0); if(sequence_number) {
i = strtol(sequence_number, NULL, 10);
switch(i) {
case -1: // Query only.
readonly = 1;
break;
case 0:
case 1: // User has forced writing to a specific flash bank.
forcedBank = i;
break;
default:
fprintf(stderr, "Incorrect flash bank %s!\n", sequence_number);
return -1;
}
}
if(!res) res = ubi_probe(); if(!res) res = ubi_probe();
if(!res) res = meta_find_all(); if(!res) res = meta_find_all();
if(!res) res = meta_manage_vols(readonly); if(!res) res = meta_manage_vols(readonly, forcedBank);
// Possibly erase the temporary file. // Possibly erase the temporary file.
if(tmpMetaBlob) { if(tmpMetaBlob) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment