summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorEvan Lojewski <github@meklort.com>2020-09-26 13:16:01 -0600
committerGitHub <noreply@github.com>2020-09-26 13:16:01 -0600
commit19fc2074766a894727dcbf26ca9cfbe3ad3ffe7f (patch)
treeeb97893312874e288cf026e0fc66dbbbbbb3a616 /utils
parent548c7ba4e77b3625e58defcccd3bfce0dc47193e (diff)
downloadbcm5719-ortega-19fc2074766a894727dcbf26ca9cfbe3ad3ffe7f.tar.gz
bcm5719-ortega-19fc2074766a894727dcbf26ca9cfbe3ad3ffe7f.zip
stage1: Add a fixed-location version string and version number. (#118)
Similar to the proprietary firmware, add a version string pointer 8 bytes into the firmware image. Unlike the proprietary firmware, the version number is also stored 12 bytes into the firmware image. This closes GH-114
Diffstat (limited to 'utils')
-rw-r--r--utils/bcmflash/main.cpp38
1 files changed, 37 insertions, 1 deletions
diff --git a/utils/bcmflash/main.cpp b/utils/bcmflash/main.cpp
index ef50427..2cfac87 100644
--- a/utils/bcmflash/main.cpp
+++ b/utils/bcmflash/main.cpp
@@ -298,9 +298,27 @@ int main(int argc, char const *argv[])
uint32_t crc_word = stage1_length / 4;
uint32_t expected_crc = be32toh(~NVRam_crc(stage1, stage1_length, 0xffffffff));
+ uint32_t phys_addr = be32toh(nvram.contents.header.bootstrapPhysAddr);
+ uint32_t ver_addr = be32toh(stage1_wd[2]) - phys_addr;
+ const char *stage1_ver = NULL;
+ uint32_t stage1_version_num = be32toh(stage1_wd[3]);
+ uint8_t stage1_version_major = stage1_version_num >> 24;
+ uint8_t stage1_version_minor = stage1_version_num >> 16 & 0xff;
+ uint16_t stage1_version_patch = stage1_version_num & 0xffff;
+
+ if (ver_addr < stage1_length)
+ {
+ stage1_ver = (char *)&stage1[ver_addr];
+ }
+ else
+ {
+ stage1_ver = "Unknown";
+ }
+
printf("=== stage1 ===\n");
+ printf("Version: %s (version %d.%d.%d)\n", stage1_ver, stage1_version_major, stage1_version_minor, stage1_version_patch);
printf("Magic: 0x%08X\n", be32toh(nvram.contents.header.magic));
- printf("Bootstrap Phys Addr: 0x%08X\n", be32toh(nvram.contents.header.bootstrapPhysAddr));
+ printf("Bootstrap Phys Addr: 0x%08X\n", phys_addr);
printf("Length (bytes): 0x%08zX\n", stage1_length);
printf("Offset: 0x%08lX\n", ((stage1_wd - nvram.words) * 4));
printf("Calculated CRC: 0x%08X\n", expected_crc);
@@ -363,6 +381,24 @@ int main(int argc, char const *argv[])
printf("New CRC: 0x%08X\n", new_crc);
printf("New Length (bytes): 0x%08X\n", new_stage1_length);
+ // Determine new version
+ stage1_version_num = be32toh(stage1_wd[3]);
+ stage1_version_major = stage1_version_num >> 24;
+ stage1_version_minor = stage1_version_num >> 16 & 0xff;
+ stage1_version_patch = stage1_version_num & 0xffff;
+ phys_addr = be32toh(nvram.contents.header.bootstrapPhysAddr);
+ ver_addr = be32toh(stage1_wd[2]) - phys_addr;
+ stage1_ver = NULL;
+ if (ver_addr < stage1_length)
+ {
+ stage1_ver = (char *)&stage1[ver_addr];
+ }
+ else
+ {
+ stage1_ver = "Unknown";
+ }
+ printf("New Version: %s (version %d.%d.%d)\n", stage1_ver, stage1_version_major, stage1_version_minor, stage1_version_patch);
+
// Update the CRC in the file copy.
stage1_wd[crc_word] = htobe32(new_crc);
OpenPOWER on IntegriCloud