Add support for printing version at runtime
authorJuan Castillo <juan.castillo@arm.com>
Mon, 30 Jun 2014 10:41:46 +0000 (11:41 +0100)
committerDan Handley <dan.handley@arm.com>
Fri, 25 Jul 2014 14:02:08 +0000 (15:02 +0100)
Print out Trusted Firmware version at runtime at each BL stage.
Message consists of TF version as defined statically in the Makefile
(e.g. v0.4), build mode (debug|release) and a customizable build
string:

  1. By defining BUILD_STRING in command line when building TF
  2. Default string is git commit ID
  3. Empty if git meta-data is not available

Fixes ARM-software/tf-issues#203

Change-Id: I5c5ba438f66ab68810427d76b49c5b9177a957d6

Makefile
bl1/bl1_main.c
bl2/bl2_main.c
bl31/bl31_main.c
bl32/tsp/tsp_main.c
include/common/bl_common.h

index 86a4878afd50bdd6ecaf10a3d37342f839d396c9..39496fb738835e3e47e3034d0ff45667a83f0cf8 100644 (file)
--- a/Makefile
+++ b/Makefile
 # POSSIBILITY OF SUCH DAMAGE.
 #
 
+#
+# Trusted Firmware Version
+#
+VERSION_MAJOR          := 0
+VERSION_MINOR          := 4
+
 #
 # Default values for build configurations
 #
@@ -76,6 +82,13 @@ else
        BUILD_TYPE      :=      release
 endif
 
+# Default build string (git branch and commit)
+ifeq (${BUILD_STRING},)
+       BUILD_STRING    :=      $(shell git log -n 1 --pretty=format:"%h")
+endif
+
+VERSION_STRING         :=      v${VERSION_MAJOR}.${VERSION_MINOR}(${BUILD_TYPE}):${BUILD_STRING}
+
 BL_COMMON_SOURCES      :=      common/bl_common.c                      \
                                common/debug.c                          \
                                common/tf_printf.c                      \
@@ -377,7 +390,8 @@ $(BUILD_DIR) :
 
 $(ELF) : $(OBJS) $(LINKERFILE)
        @echo "  LD      $$@"
-       @echo 'const char build_message[] = "Built : "__TIME__", "__DATE__;' | \
+       @echo 'const char build_message[] = "Built : "__TIME__", "__DATE__; \
+              const char version_string[] = "${VERSION_STRING}";' | \
                $$(CC) $$(CFLAGS) -xc - -o $(BUILD_DIR)/build_message.o
        $$(Q)$$(LD) -o $$@ $$(LDFLAGS) -Map=$(MAPFILE) --script $(LINKERFILE) \
                                        $(BUILD_DIR)/build_message.o $(OBJS)
index 47ca546d34da052520d9c4c7f01143502642c42d..c6f2caadf42372562b3730e1e5364d0ee1d0c860 100644 (file)
@@ -130,7 +130,8 @@ void bl1_main(void)
 
        /* Announce our arrival */
        tf_printf(FIRMWARE_WELCOME_STR);
-       tf_printf("%s\n\r", build_message);
+       tf_printf("%s\n", version_string);
+       tf_printf("%s\n", build_message);
 
        SET_PARAM_HEAD(&bl2_image_info, PARAM_IMAGE_BINARY, VERSION_1, 0);
        SET_PARAM_HEAD(&bl2_ep, PARAM_EP, VERSION_1, 0);
index 70b688a603305e7af7efa0ea8918b14ff08afe26..ca8384265ec8bce78f00bb88655e4bf3b9b4f74c 100644 (file)
@@ -195,7 +195,8 @@ void bl2_main(void)
        /* Perform platform setup in BL2 */
        bl2_platform_setup();
 
-       tf_printf("BL2 %s\n\r", build_message);
+       tf_printf("BL2 %s\n", version_string);
+       tf_printf("BL2 %s\n", build_message);
 
        /*
         * Load the subsequent bootloader images
index 031799ce2caaac4fae6efa6613c22d00174ad77e..861b3914c292164d143df9035dd91e1a11ed0246 100644 (file)
@@ -77,7 +77,8 @@ void bl31_main(void)
        /* Perform platform setup in BL1 */
        bl31_platform_setup();
 
-       tf_printf("BL31 %s\n\r", build_message);
+       tf_printf("BL31 %s\n", version_string);
+       tf_printf("BL31 %s\n", build_message);
 
        /* Initialise helper libraries */
        bl31_lib_init();
index 8844f41bb13b7a3794bf7d89e0fd353f82dc459f..b2850e9d44ecedac9a1e16d4ffc80730e63e5d6a 100644 (file)
@@ -120,7 +120,8 @@ uint64_t tsp_main(void)
        tsp_stats[linear_id].cpu_on_count++;
 
        spin_lock(&console_lock);
-       tf_printf("TSP %s\n\r", build_message);
+       tf_printf("TSP %s\n", version_string);
+       tf_printf("TSP %s\n", build_message);
        INFO("Total memory base : 0x%x\n", (unsigned long)BL32_TOTAL_BASE);
        INFO("Total memory size : 0x%x bytes\n",
                         (unsigned long)(BL32_TOTAL_LIMIT - BL32_TOTAL_BASE));
index 154c0f49d123a60a94a72dff1aeef3f4dc96d27a..e996fd6aa76274b4a63d111ca2bbb8a836899cca 100644 (file)
@@ -210,6 +210,7 @@ int load_image(meminfo_t *mem_layout,
               image_info_t *image_data,
               entry_point_info_t *entry_point_info);
 extern const char build_message[];
+extern const char version_string[];
 
 void reserve_mem(uint64_t *free_base, size_t *free_size,
                uint64_t addr, size_t size);