From: Florent Kermarrec Date: Sat, 27 Jul 2019 18:27:53 +0000 (+0200) Subject: soc: generate git header and show migen/litex git sha1 in bios X-Git-Tag: 24jan2021_ls180~1076 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=25ca0a8b71648c0152a2dbca0aeaf729abd9290f;p=litex.git soc: generate git header and show migen/litex git sha1 in bios --- diff --git a/litex/soc/integration/builder.py b/litex/soc/integration/builder.py index 2a645be3..81c66b7d 100755 --- a/litex/soc/integration/builder.py +++ b/litex/soc/integration/builder.py @@ -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"): diff --git a/litex/soc/integration/cpu_interface.py b/litex/soc/integration/cpu_interface.py index c1acd144..067e1d47 100644 --- a/litex/soc/integration/cpu_interface.py +++ b/litex/soc/integration/cpu_interface.py @@ -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 diff --git a/litex/soc/software/bios/main.c b/litex/soc/software/bios/main.c index 95b439cb..a93b4e13 100644 --- a/litex/soc/software/bios/main.c +++ b/litex/soc/software/bios/main.c @@ -26,6 +26,7 @@ #include #include +#include #ifdef CSR_ETHMAC_BASE #include @@ -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__