[ion] Add software version, patch level and serial number

Change-Id: I011eeb2d8596f63e0c2fdedf353d544dc8a8a202
This commit is contained in:
Émilie Feral
2017-04-04 14:02:59 +02:00
parent c5df63a184
commit 7091b2ea35
6 changed files with 39 additions and 1 deletions

View File

@@ -1,5 +1,7 @@
include build/config.mak
VERSION ?= 1.0.0
ifndef USE_LIBA
$(error platform.mak should define USE_LIBA)
endif

View File

@@ -1,8 +1,18 @@
GIT := $(shell command -v git 2> /dev/null)
PATCH_LEVEL = NONE
ifdef GIT
PATCH_LEVEL = `git rev-parse HEAD`
endif
SFLAGS += -Iion/include -DKD_CONFIG_H=1
ion/src/shared/software_version.o: SFLAGS += -DPATCH_LEVEL=$(PATCH_LEVEL) -DVERSION=$(VERSION)
include ion/src/$(PLATFORM)/Makefile
objs += $(addprefix ion/src/shared/, \
events.o \
software_version.o \
)
tests += $(addprefix ion/test/,\

View File

@@ -27,6 +27,8 @@ void msleep(long ms);
void usleep(long us);
const char * serialNumber();
const char * softwareVersion();
const char * patchLevel();
/* CAUTION: This is a complete reset! */
void reset();

View File

@@ -74,7 +74,7 @@ const char * Ion::serialNumber() {
static char serialNumber[25] = {0};
if (serialNumber[0] == 0) {
uint8_t * rawUniqueID = (uint8_t *)0x1FFF7A10;
for (int i=0; i<24; i++) {
for (int i=0; i<12; i++) {
uint8_t d = *rawUniqueID++;
serialNumber[2*i] = hex(d & 0xF);
serialNumber[2*i+1] = hex(d >> 4);

View File

@@ -0,0 +1,20 @@
#include <ion.h>
#define STR_EXPAND(arg) #arg
#define STR(arg) STR_EXPAND(arg)
#ifndef PATCH_LEVEL
#error This file expects PATCH_LEVEL to be defined
#endif
const char * Ion::softwareVersion() {
return STR(VERSION);
}
const char * Ion::patchLevel() {
static char patchLevel[20] = {0};
if (patchLevel[0] == 0) {
strlcpy(patchLevel, STR(PATCH_LEVEL), 6+1);
}
return patchLevel;
}

View File

@@ -81,3 +81,7 @@ void Ion::msleep(long ms) {
}
}
}
const char * Ion::serialNumber() {
return "Simulator";
}