summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--stage1/CMakeLists.txt4
-rw-r--r--stage1/crt.s53
-rw-r--r--stage1/main.c6
-rw-r--r--utils/bcmflash/main.cpp38
4 files changed, 98 insertions, 3 deletions
diff --git a/stage1/CMakeLists.txt b/stage1/CMakeLists.txt
index 75b8e9d..13a2bf2 100644
--- a/stage1/CMakeLists.txt
+++ b/stage1/CMakeLists.txt
@@ -52,6 +52,10 @@ mips_add_executable(${PROJECT_NAME}
main.c
crt.s)
mips_linker_script(${PROJECT_NAME} ${LINKER_SCRIPT})
+target_link_libraries(${PROJECT_NAME}
+ --defsym=VERSION_MAJOR=${VERSION_MAJOR}
+ --defsym=VERSION_MINOR=${VERSION_MINOR}
+ --defsym=VERSION_PATCH=${VERSION_PATCH})
target_link_libraries(${PROJECT_NAME} NVRam-mips MII-mips APE-mips printf-mips)
target_link_libraries(${PROJECT_NAME} bcm5719)
diff --git a/stage1/crt.s b/stage1/crt.s
index aa9b621..5d1143a 100644
--- a/stage1/crt.s
+++ b/stage1/crt.s
@@ -1,9 +1,60 @@
-
+////////////////////////////////////////////////////////////////////////////////
+///
+/// @file stage1/crt.s
+///
+/// @project
+///
+/// @brief stage1 startup code
+///
+////////////////////////////////////////////////////////////////////////////////
+///
+////////////////////////////////////////////////////////////////////////////////
+///
+/// @copyright Copyright (c) 2018-2020, Evan Lojewski
+/// @cond
+///
+/// All rights reserved.
+///
+/// Redistribution and use in source and binary forms, with or without
+/// modification, are permitted provided that the following conditions are met:
+/// 1. Redistributions of source code must retain the above copyright notice,
+/// this list of conditions and the following disclaimer.
+/// 2. Redistributions in binary form must reproduce the above copyright notice,
+/// this list of conditions and the following disclaimer in the documentation
+/// and/or other materials provided with the distribution.
+/// 3. Neither the name of the copyright holder nor the
+/// names of its contributors may be used to endorse or promote products
+/// derived from this software without specific prior written permission.
+///
+////////////////////////////////////////////////////////////////////////////////
+///
+/// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+/// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+/// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+/// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+/// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+/// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+/// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+/// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+/// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+/// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+/// POSSIBILITY OF SUCH DAMAGE.
+/// @endcond
+////////////////////////////////////////////////////////////////////////////////
.section .init
.global __start
.align 4
__start:
+ j _main
+ // NOP is automatically added by llvm
+
+_version_ptr:
+ .word gStage1Version
+_version_data:
+ .word (VERSION_MAJOR << 24) | (VERSION_MINOR << 16) | VERSION_PATCH
+
+_main:
la $sp, _estack
j main
.size __start, . - __start
diff --git a/stage1/main.c b/stage1/main.c
index c24aa07..5788ca9 100644
--- a/stage1/main.c
+++ b/stage1/main.c
@@ -66,6 +66,8 @@
#include <bcm5719_GEN.h>
#include <bcm5719_SHM.h>
+const char gStage1Version[] = "stage1-" STRINGIFY(VERSION_MAJOR) "." STRINGIFY(VERSION_MINOR) "." STRINGIFY(VERSION_PATCH);
+
NVRAMContents_t gNVMContents;
void __attribute__((noinline)) reportStatus(uint32_t code, uint8_t step)
@@ -139,7 +141,9 @@ int main()
if (0 == DEVICE.Status.bits.FunctionNumber)
{
- em100_puts("RX Firmware v" STRINGIFY(VERSION_MAJOR) "." STRINGIFY(VERSION_MINOR) "." STRINGIFY(VERSION_PATCH) "\n");
+ em100_puts("RX Firmware ");
+ em100_puts(gStage1Version);
+ em100_puts("\n");
}
#if !CXX_SIMULATOR
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