summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorEvan Lojewski <github@meklort.com>2020-03-01 22:14:00 -0700
committerGitHub <noreply@github.com>2020-03-01 22:14:00 -0700
commit4ac791b225dc148cda5b0fe519ceb438da79e0bd (patch)
tree95d77b97ac0a85577a08341622aa1b1bc731b645 /utils
parent4b06c31568b72192a51a8a61fd5045b588540042 (diff)
downloadbcm5719-ortega-4ac791b225dc148cda5b0fe519ceb438da79e0bd.tar.gz
bcm5719-ortega-4ac791b225dc148cda5b0fe519ceb438da79e0bd.zip
build: Add version information to output files. (#52)
Diffstat (limited to 'utils')
-rw-r--r--utils/ape2elf/main.cpp27
-rw-r--r--utils/apeconsole/main.cpp8
-rw-r--r--utils/bcmflash/main.cpp8
-rw-r--r--utils/bcmregtool/apeloader/CMakeLists.txt4
-rw-r--r--utils/bcmregtool/main.cpp8
-rw-r--r--utils/bin2c/CMakeLists.txt1
-rw-r--r--utils/bin2c/main.cpp10
-rw-r--r--utils/elf2ape/main.cpp14
8 files changed, 62 insertions, 18 deletions
diff --git a/utils/ape2elf/main.cpp b/utils/ape2elf/main.cpp
index 1fbb427..36e14db 100644
--- a/utils/ape2elf/main.cpp
+++ b/utils/ape2elf/main.cpp
@@ -10,7 +10,7 @@
///
////////////////////////////////////////////////////////////////////////////////
///
-/// @copyright Copyright (c) 2018, Evan Lojewski
+/// @copyright Copyright (c) 2018-2020, Evan Lojewski
/// @cond
///
/// All rights reserved.
@@ -48,10 +48,12 @@
#include <bcm5719_eeprom.h>
#include <elfio/elfio.hpp>
-#define ENTRYPOINT_SYMBOL "__start"
-#define VERSION_SYMBOL "VERSION"
-#define STACK_END_SYMBOL "_estack"
-#define THUMB_CODE_SYMBOL "$t"
+#define ENTRYPOINT_SYMBOL "__start"
+#define VERSION_MAJOR_SYMBOL "VERSION_MAJOR"
+#define VERSION_MINOR_SYMBOL "VERSION_MINOR"
+#define VERSION_PATCH_SYMBOL "VERSION_PATCH"
+#define STACK_END_SYMBOL "_estack"
+#define THUMB_CODE_SYMBOL "$t"
using namespace std;
using namespace ELFIO;
@@ -275,7 +277,13 @@ int main(int argc, char const *argv[])
// Add label name
Elf32_Word _start = stra.add_string(ENTRYPOINT_SYMBOL);
Elf32_Word _thumb = stra.add_string(THUMB_CODE_SYMBOL);
- Elf32_Word _version = stra.add_string(VERSION_SYMBOL);
+ Elf32_Word _version_major = stra.add_string(VERSION_MAJOR_SYMBOL);
+ Elf32_Word _version_minor = stra.add_string(VERSION_MINOR_SYMBOL);
+ Elf32_Word _version_patch = stra.add_string(VERSION_PATCH_SYMBOL);
+
+ uint8_t version_major = (ape.header.version >> 24) & 0xFF;
+ uint8_t version_minor = (ape.header.version >> 16) & 0xFF;
+ uint8_t version_patch = ape.header.version & 0xFFFF;
// Add symbol entry
syma.add_symbol(_start, ape.header.entrypoint, 0, STB_GLOBAL, STT_FUNC,
@@ -284,8 +292,13 @@ int main(int argc, char const *argv[])
syma.add_symbol(_thumb, ape.header.entrypoint & 0xfffffffe, 0,
STB_LOCAL, STT_OBJECT, 0, text_sec->get_index());
- syma.add_symbol(_version, ape.header.version, 0, STB_GLOBAL, STT_OBJECT,
+ syma.add_symbol(_version_major, version_major, 0, STB_GLOBAL, STT_OBJECT,
+ 0, text_sec->get_index());
+ syma.add_symbol(_version_minor, version_minor, 0, STB_GLOBAL, STT_OBJECT,
0, text_sec->get_index());
+ syma.add_symbol(_version_patch, version_patch, 0, STB_GLOBAL, STT_OBJECT,
+ 0, text_sec->get_index());
+
uint32_t *vectors = (uint32_t *)text_sec->get_data();
Elf32_Word index = stra.add_string(STACK_END_SYMBOL);
diff --git a/utils/apeconsole/main.cpp b/utils/apeconsole/main.cpp
index 0614bc7..d0d11bd 100644
--- a/utils/apeconsole/main.cpp
+++ b/utils/apeconsole/main.cpp
@@ -10,7 +10,7 @@
///
////////////////////////////////////////////////////////////////////////////////
///
-/// @copyright Copyright (c) 2018, Evan Lojewski
+/// @copyright Copyright (c) 2018-2020, Evan Lojewski
/// @cond
///
/// All rights reserved.
@@ -70,6 +70,8 @@
#include "../NVRam/bcm5719_NVM.h"
+#define VERSION_STRING STRINGIFY(VERSION_MAJOR) "." STRINGIFY(VERSION_MINOR) "." STRINGIFY(VERSION_PATCH)
+
using namespace std;
using namespace ELFIO;
using optparse::OptionParser;
@@ -82,7 +84,9 @@ using optparse::OptionParser;
int main(int argc, char const *argv[])
{
- OptionParser parser = OptionParser().description("BCM Register Utility");
+ OptionParser parser = OptionParser().description("BCM Console Utility v" VERSION_STRING);
+
+ parser.version(VERSION_STRING);
parser.add_option("-f", "--function")
.dest("function")
diff --git a/utils/bcmflash/main.cpp b/utils/bcmflash/main.cpp
index 3626753..553adfe 100644
--- a/utils/bcmflash/main.cpp
+++ b/utils/bcmflash/main.cpp
@@ -10,7 +10,7 @@
///
////////////////////////////////////////////////////////////////////////////////
///
-/// @copyright Copyright (c) 2018, Evan Lojewski
+/// @copyright Copyright (c) 2018-2020, Evan Lojewski
/// @cond
///
/// All rights reserved.
@@ -68,6 +68,8 @@
#include "../NVRam/bcm5719_NVM.h"
+#define VERSION_STRING STRINGIFY(VERSION_MAJOR) "." STRINGIFY(VERSION_MINOR) "." STRINGIFY(VERSION_PATCH)
+
using namespace std;
using optparse::OptionParser;
@@ -106,7 +108,9 @@ int main(int argc, char const *argv[])
uint8_t* stage1 = NULL;
uint32_t* stage1_wd = NULL;
- OptionParser parser = OptionParser().description("BCM Flash Utility");
+ OptionParser parser = OptionParser().description("BCM Flash Utility v" VERSION_STRING);
+
+ parser.version(VERSION_STRING);
parser.add_option("-t", "--target")
.choices({"hardware", "file"})
diff --git a/utils/bcmregtool/apeloader/CMakeLists.txt b/utils/bcmregtool/apeloader/CMakeLists.txt
index 80c8df8..1f8ce69 100644
--- a/utils/bcmregtool/apeloader/CMakeLists.txt
+++ b/utils/bcmregtool/apeloader/CMakeLists.txt
@@ -54,6 +54,10 @@ arm_linker_script(${PROJECT_NAME} ${LINKER_SCRIPT})
target_link_libraries(${PROJECT_NAME} APE-arm)
target_link_libraries(${PROJECT_NAME} bcm5719-arm)
+target_link_libraries(${PROJECT_NAME}
+ --defsym=VERSION_MAJOR=${VERSION_MAJOR}
+ --defsym=VERSION_MINOR=${VERSION_MINOR}
+ --defsym=VERSION_PATCH=${VERSION_PATCH})
target_compile_options(${PROJECT_NAME} PRIVATE -nodefaultlibs)
diff --git a/utils/bcmregtool/main.cpp b/utils/bcmregtool/main.cpp
index 7f8eb82..37d7c6a 100644
--- a/utils/bcmregtool/main.cpp
+++ b/utils/bcmregtool/main.cpp
@@ -10,7 +10,7 @@
///
////////////////////////////////////////////////////////////////////////////////
///
-/// @copyright Copyright (c) 2018, Evan Lojewski
+/// @copyright Copyright (c) 2018-2020, Evan Lojewski
/// @cond
///
/// All rights reserved.
@@ -78,6 +78,8 @@
#include "../NVRam/bcm5719_NVM.h"
+#define VERSION_STRING STRINGIFY(VERSION_MAJOR) "." STRINGIFY(VERSION_MINOR) "." STRINGIFY(VERSION_PATCH)
+
using namespace std;
using namespace ELFIO;
using optparse::OptionParser;
@@ -325,7 +327,9 @@ void step(void)
int main(int argc, char const *argv[])
{
- OptionParser parser = OptionParser().description("BCM Register Utility");
+ OptionParser parser = OptionParser().description("BCM Register Utility v" VERSION_STRING);
+
+ parser.version(VERSION_STRING);
parser.add_option("--elf")
.dest("debugfile")
diff --git a/utils/bin2c/CMakeLists.txt b/utils/bin2c/CMakeLists.txt
index e656fdd..c4f291b 100644
--- a/utils/bin2c/CMakeLists.txt
+++ b/utils/bin2c/CMakeLists.txt
@@ -51,5 +51,6 @@ set(SOURCES
simulator_add_executable(${PROJECT_NAME} ${SOURCES})
target_link_libraries(${PROJECT_NAME} PRIVATE OptParse)
+include_directories(${CMAKE_SOURCE_DIR}/include)
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION .)
diff --git a/utils/bin2c/main.cpp b/utils/bin2c/main.cpp
index c494421..a8da108 100644
--- a/utils/bin2c/main.cpp
+++ b/utils/bin2c/main.cpp
@@ -10,7 +10,7 @@
///
////////////////////////////////////////////////////////////////////////////////
///
-/// @copyright Copyright (c) 2019, Evan Lojewski
+/// @copyright Copyright (c) 2019-2020, Evan Lojewski
/// @cond
///
/// All rights reserved.
@@ -47,6 +47,10 @@
#include <cstring>
#include <fstream>
#include <iomanip>
+#include <types.h>
+
+#define VERSION_STRING STRINGIFY(VERSION_MAJOR) "." STRINGIFY(VERSION_MINOR) "." STRINGIFY(VERSION_PATCH)
+
using namespace std;
using optparse::OptionParser;
@@ -83,7 +87,9 @@ int main(int argc, char const *argv[])
{
ofstream outfile;
ifstream infile;
- OptionParser parser = OptionParser().description("Binary to C Header utility");
+ OptionParser parser = OptionParser().description("Binary to C Header utility v" VERSION_STRING);
+
+ parser.version(VERSION_STRING);
parser.add_option("-i", "--input")
.dest("input")
diff --git a/utils/elf2ape/main.cpp b/utils/elf2ape/main.cpp
index 6386437..57486f3 100644
--- a/utils/elf2ape/main.cpp
+++ b/utils/elf2ape/main.cpp
@@ -10,7 +10,7 @@
///
////////////////////////////////////////////////////////////////////////////////
///
-/// @copyright Copyright (c) 2018, Evan Lojewski
+/// @copyright Copyright (c) 2018-2020, Evan Lojewski
/// @cond
///
/// All rights reserved.
@@ -47,6 +47,9 @@
#include <OptionParser.h>
#include <bcm5719_eeprom.h>
#include <elfio/elfio.hpp>
+#include <types.h>
+
+#define VERSION_STRING STRINGIFY(VERSION_MAJOR) "." STRINGIFY(VERSION_MINOR) "." STRINGIFY(VERSION_PATCH)
using namespace ELFIO;
@@ -127,7 +130,9 @@ int main(int argc, char const *argv[])
APEHeader_t header;
} ape;
- OptionParser parser = OptionParser().description("BCM elf 2 APE Utility");
+ OptionParser parser = OptionParser().description("BCM ELF 2 APE Utility v" VERSION_STRING);
+
+ parser.version(VERSION_STRING);
parser.add_option("-i", "--input")
.dest("input")
@@ -275,7 +280,10 @@ int main(int argc, char const *argv[])
strncpy((char*)ape.header.name, name.c_str(), sizeof(ape.header.name));
}
- ape.header.version = get_symbol_value("VERSION", reader);
+ uint8_t version_major = get_symbol_value("VERSION_MAJOR", reader);
+ uint8_t version_minor = get_symbol_value("VERSION_MINOR", reader);
+ uint16_t version_patch = get_symbol_value("VERSION_PATCH", reader);
+ ape.header.version = version_major << 24 | version_minor << 16 | version_patch;
ape.header.entrypoint = get_symbol_value("__start", reader);
ape.header.unk1 = APE_HEADER_UNK1;
ape.header.words =
OpenPOWER on IntegriCloud