Skip to content

Commit

Permalink
soc: generate git header and show migen/litex git sha1 in bios
Browse files Browse the repository at this point in the history
  • Loading branch information
enjoy-digital committed Jul 27, 2019
1 parent ae00482 commit 25ca0a8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
6 changes: 4 additions & 2 deletions litex/soc/integration/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,22 @@ def define(k, v):
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"):
Expand Down
9 changes: 9 additions & 0 deletions litex/soc/integration/cpu_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 4 additions & 1 deletion litex/soc/software/bios/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include <generated/csr.h>
#include <generated/mem.h>
#include <generated/git.h>

#ifdef CSR_ETHMAC_BASE
#include <net/microudp.h>
Expand Down Expand Up @@ -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__
Expand Down

0 comments on commit 25ca0a8

Please sign in to comment.