From: Sebastien Bourdeauducq Date: Sat, 9 Nov 2013 15:38:44 +0000 (+0100) Subject: use git commit id as version X-Git-Tag: 24jan2021_ls180~2825 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d7a4d8b66ea31fe366a38d22d7dcc7bb22b3f8fc;p=litex.git use git commit id as version --- diff --git a/common/version.h b/common/version.h deleted file mode 100644 index 68bd4c97..00000000 --- a/common/version.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef __VERSION_H -#define __VERSION_H - -#define VERSION "2.0" - -#endif /* __VERSION_H */ diff --git a/misoclib/identifier/__init__.py b/misoclib/identifier/__init__.py index ca792fd1..117219d1 100644 --- a/misoclib/identifier/__init__.py +++ b/misoclib/identifier/__init__.py @@ -1,29 +1,21 @@ -import re - from migen.fhdl.std import * from migen.bank.description import * -def encode_version(version): - match = re.match("(\d+)\.(\d+)(\.(\d+))?(rc(\d+))?", version, re.IGNORECASE) - r = (int(match.group(1)) << 12) | (int(match.group(2)) << 8) - subminor = match.group(4) - rc = match.group(6) - if subminor: - r |= int(subminor) << 4 - if rc: - r |= int(rc) - return r +from misoclib.identifier import git class Identifier(Module, AutoCSR): - def __init__(self, sysid, version, frequency): + def __init__(self, sysid, frequency, revision=None): self._r_sysid = CSRStatus(16) - self._r_version = CSRStatus(16) + self._r_revision = CSRStatus(32) self._r_frequency = CSRStatus(32) ### + if revision is None: + revision = git.get_id() + self.comb += [ self._r_sysid.status.eq(sysid), - self._r_version.status.eq(encode_version(version)), + self._r_revision.status.eq(revision), self._r_frequency.status.eq(frequency) ] diff --git a/misoclib/identifier/git.py b/misoclib/identifier/git.py new file mode 100644 index 00000000..19b902bd --- /dev/null +++ b/misoclib/identifier/git.py @@ -0,0 +1,5 @@ +import subprocess + +def get_id(): + output = subprocess.check_output(["git", "rev-parse", "HEAD"]).decode("ascii") + return int(output[:8], 16) diff --git a/software/bios/main.c b/software/bios/main.c index 50f4897e..97a0f82d 100644 --- a/software/bios/main.c +++ b/software/bios/main.c @@ -6,7 +6,6 @@ #include #include #include -#include #include #include @@ -319,7 +318,7 @@ static void help(void) puts("netboot - boot via TFTP"); puts("serialboot - boot via SFL"); puts("flashboot - boot from flash"); - puts("version - display version"); + puts("revision - display revision"); } static char *get_token(char **str) @@ -353,7 +352,7 @@ static void do_command(char *c) else if(strcmp(token, "serialboot") == 0) serialboot(); else if(strcmp(token, "netboot") == 0) netboot(); - else if(strcmp(token, "version") == 0) puts(VERSION); + else if(strcmp(token, "revision") == 0) printf("%08x\n", GIT_ID); else if(strcmp(token, "help") == 0) help(); @@ -401,14 +400,6 @@ static void crcbios(void) } } -static const char banner[] = - "\nMiSoC(tm) v"VERSION" BIOS http://www.milkymist.org\n" - "(c) Copyright 2007-2013 Sebastien Bourdeauducq\n" - "Built "__DATE__" "__TIME__"\n\n" - "This program is free software: you can redistribute it and/or modify\n" - "it under the terms of the GNU General Public License as published by\n" - "the Free Software Foundation, version 3 of the License."; - static void readstr(char *s, int size) { char c[2]; @@ -494,7 +485,9 @@ int main(int i, char **c) irq_setmask(0); irq_setie(1); uart_init(); - puts(banner); + puts("\nMiSoC BIOS http://www.milkymist.org\n" + "(c) Copyright 2007-2013 Sebastien Bourdeauducq"); + printf("Revision %08x built "__DATE__" "__TIME__"\n\n", GIT_ID); crcbios(); id_print(); ethreset(); diff --git a/software/common.mak b/software/common.mak index 825a88e5..0c8103de 100644 --- a/software/common.mak +++ b/software/common.mak @@ -18,6 +18,8 @@ LD_quiet = @echo " LD " $@ && $(TARGET_PREFIX)ld OBJCOPY_quiet = @echo " OBJCOPY " $@ && $(TARGET_PREFIX)objcopy RANLIB_quiet = @echo " RANLIB " $@ && $(TARGET_PREFIX)ranlib +GIT_ID:=$(shell echo -e "from misoclib.identifier.git import get_id\nprint(hex(get_id()), end='')" | python) + ifeq ($(V),1) CC = $(CC_normal) CX = $(CX_normal) @@ -40,7 +42,7 @@ endif # INCLUDES = -I$(MSCDIR)/software/include/base -I$(MSCDIR)/software/include -I$(MSCDIR)/common COMMONFLAGS = -O3 -mbarrel-shift-enabled -mmultiply-enabled -mdivide-enabled -msign-extend-enabled \ - -Wall -fno-builtin -nostdinc $(INCLUDES) + -Wall -fno-builtin -nostdinc -DGIT_ID=$(GIT_ID) $(INCLUDES) CFLAGS = $(COMMONFLAGS) -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes CXXFLAGS = $(COMMONFLAGS) -fno-exceptions -ffreestanding LDFLAGS = -nostdlib -nodefaultlibs diff --git a/software/include/base/id.h b/software/include/base/id.h index 19202c8b..89b540f6 100644 --- a/software/include/base/id.h +++ b/software/include/base/id.h @@ -6,9 +6,6 @@ extern "C" { #endif void get_sysid_formatted(char *sysid); -void get_soc_version(unsigned int *major, unsigned int *minor, unsigned int *subminor, unsigned int *rc); -void get_soc_version_formatted(char *version); - void id_print(void); #ifdef __cplusplus diff --git a/software/libbase/id.c b/software/libbase/id.c index 03382966..a0f92f53 100644 --- a/software/libbase/id.c +++ b/software/libbase/id.c @@ -2,7 +2,6 @@ #include #include #include -#include #include void get_sysid_formatted(char *sysid) @@ -12,36 +11,10 @@ void get_sysid_formatted(char *sysid) sysid[2] = 0; } -void get_soc_version(unsigned int *major, unsigned int *minor, unsigned int *subminor, unsigned int *rc) -{ - unsigned int id; - - id = identifier_version_read(); - *major = (id & 0xf000) >> 12; - *minor = (id & 0x0f00) >> 8; - *subminor = (id & 0x00f0) >> 4; - *rc = id & 0x000f; -} - -void get_soc_version_formatted(char *version) -{ - unsigned int major, minor, subminor, rc; - - get_soc_version(&major, &minor, &subminor, &rc); - - version += sprintf(version, "%u.%u", major, minor); - if(subminor != 0) - version += sprintf(version, ".%u", subminor); - if(rc != 0) - sprintf(version, "RC%u", rc); -} - void id_print(void) { - char soc_version[13]; char sysid[3]; - get_soc_version_formatted(soc_version); get_sysid_formatted(sysid); - printf("Running on MiSoC %s (sysid:%s) at %dMHz\n", soc_version, sysid, identifier_frequency_read()/1000000); + printf("Running on MiSoC rev. %08x (sysid:%s) at %dMHz\n", identifier_revision_read(), sysid, identifier_frequency_read()/1000000); } diff --git a/top.py b/top.py index 67022bef..f74d1bdc 100644 --- a/top.py +++ b/top.py @@ -11,8 +11,6 @@ from mibuild.generic_platform import ConstraintError from misoclib import mxcrg, lm32, norflash, uart, s6ddrphy, dfii, lasmicon, \ identifier, timer, minimac3, framebuffer, dvisampler, gpio, memtest -version = "2.0" - clk_freq = (83 + Fraction(1, 3))*1000000 sram_size = 4096 # in bytes l2_size = 8192 # in bytes @@ -156,7 +154,7 @@ class SoC(Module): # self.submodules.crg = mxcrg.MXCRG(MXClockPads(platform), clk_freq) self.submodules.uart = uart.UART(platform.request("serial"), clk_freq, baud=115200) - self.submodules.identifier = identifier.Identifier(0x4D31, version, int(clk_freq)) + self.submodules.identifier = identifier.Identifier(0x4D31, int(clk_freq)) self.submodules.timer0 = timer.Timer() if platform_name == "mixxeo": self.submodules.leds = gpio.GPIOOut(platform.request("user_led")) diff --git a/verilog/lm32/submodule b/verilog/lm32/submodule index 4c0f6c51..90651f0d 160000 --- a/verilog/lm32/submodule +++ b/verilog/lm32/submodule @@ -1 +1 @@ -Subproject commit 4c0f6c51253b4482fe7685e77d4d5549207a098c +Subproject commit 90651f0dcb02565bd69c634f4a811e94671d21ef