mirror of
https://github.com/enjoy-digital/litex.git
synced 2025-01-04 09:52:26 -05:00
use git commit id as version
This commit is contained in:
parent
0b881d934f
commit
d7a4d8b66e
9 changed files with 23 additions and 69 deletions
|
@ -1,6 +0,0 @@
|
|||
#ifndef __VERSION_H
|
||||
#define __VERSION_H
|
||||
|
||||
#define VERSION "2.0"
|
||||
|
||||
#endif /* __VERSION_H */
|
|
@ -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)
|
||||
]
|
||||
|
|
5
misoclib/identifier/git.py
Normal file
5
misoclib/identifier/git.py
Normal file
|
@ -0,0 +1,5 @@
|
|||
import subprocess
|
||||
|
||||
def get_id():
|
||||
output = subprocess.check_output(["git", "rev-parse", "HEAD"]).decode("ascii")
|
||||
return int(output[:8], 16)
|
|
@ -6,7 +6,6 @@
|
|||
#include <system.h>
|
||||
#include <id.h>
|
||||
#include <irq.h>
|
||||
#include <version.h>
|
||||
#include <crc.h>
|
||||
|
||||
#include <hw/csr.h>
|
||||
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <version.h>
|
||||
#include <id.h>
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
4
top.py
4
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"))
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 4c0f6c51253b4482fe7685e77d4d5549207a098c
|
||||
Subproject commit 90651f0dcb02565bd69c634f4a811e94671d21ef
|
Loading…
Reference in a new issue