soc: generate git header and show migen/litex git sha1 in bios
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Sat, 27 Jul 2019 18:27:53 +0000 (20:27 +0200)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Sat, 27 Jul 2019 18:27:53 +0000 (20:27 +0200)
litex/soc/integration/builder.py
litex/soc/integration/cpu_interface.py
litex/soc/software/bios/main.c

index 2a645be3e5fa51ed90a4c3d4752d9c34d8e342a4..81c66b7db14afc6f1feeb9c14954e67a3ce20e6e 100755 (executable)
@@ -103,20 +103,22 @@ class Builder:
         write_to_file(
             os.path.join(generated_dir, "variables.mak"),
             "".join(variables_contents))
-
         write_to_file(
             os.path.join(generated_dir, "output_format.ld"),
             cpu_interface.get_linker_output_format(self.soc.cpu))
         write_to_file(
             os.path.join(generated_dir, "regions.ld"),
             cpu_interface.get_linker_regions(memory_regions))
-
         write_to_file(
             os.path.join(generated_dir, "mem.h"),
             cpu_interface.get_mem_header(memory_regions, flash_boot_address, shadow_base))
         write_to_file(
             os.path.join(generated_dir, "csr.h"),
             cpu_interface.get_csr_header(csr_regions, constants))
+        write_to_file(
+            os.path.join(generated_dir, "git.h"),
+            cpu_interface.get_git_header()
+        )
 
         if isinstance(self.soc, soc_sdram.SoCSDRAM):
             if hasattr(self.soc, "sdram"):
index c1acd144128183184d2e1f298466aa04f0d93b63..067e1d47c8245fe726c77366d0bb5434cb5a169e 100644 (file)
@@ -217,3 +217,12 @@ def get_csr_csv(csr_regions=None, constants=None, memory_regions=None):
             r += "memory_region,{},0x{:08x},{:d},\n".format(name.lower(), origin, length)
 
     return r
+
+def get_git_header():
+    from litex.build.tools import get_migen_git_revision, get_litex_git_revision
+    r = generated_banner("//")
+    r += "#ifndef __GENERATED_GIT_H\n#define __GENERATED_GIT_H\n\n"
+    r += "#define MIGEN_GIT_SHA1 \"{}\"\n".format(get_migen_git_revision())
+    r += "#define LITEX_GIT_SHA1 \"{}\"\n".format(get_litex_git_revision())
+    r += "#endif\n"
+    return r
index 95b439cb293c11d5ad58b99399f24de536006e32..a93b4e132a3a13bd897bc4f2c766fc99fb601a54 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <generated/csr.h>
 #include <generated/mem.h>
+#include <generated/git.h>
 
 #ifdef CSR_ETHMAC_BASE
 #include <net/microudp.h>
@@ -465,7 +466,9 @@ int main(int i, char **c)
        printf(" BIOS built on "__DATE__" "__TIME__"\n");
        crcbios();
        printf("\n");
-
+       printf(" Migen git sha1: "MIGEN_GIT_SHA1"\n");
+       printf(" LiteX git sha1: "LITEX_GIT_SHA1"\n");
+       printf("\n");
        printf("--============ \e[1mSoC info\e[0m ================--\n");
        printf("\e[1mCPU\e[0m:       ");
 #ifdef __lm32__