+++ /dev/null
-#ifndef __VERSION_H
-#define __VERSION_H
-
-#define VERSION "2.0"
-
-#endif /* __VERSION_H */
-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)
]
--- /dev/null
+import subprocess
+
+def get_id():
+ output = subprocess.check_output(["git", "rev-parse", "HEAD"]).decode("ascii")
+ return int(output[:8], 16)
#include <system.h>
#include <id.h>
#include <irq.h>
-#include <version.h>
#include <crc.h>
#include <hw/csr.h>
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)
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();
}
}
-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];
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();
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)
#
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
#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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <version.h>
#include <id.h>
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);
}
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
#
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"))
-Subproject commit 4c0f6c51253b4482fe7685e77d4d5549207a098c
+Subproject commit 90651f0dcb02565bd69c634f4a811e94671d21ef