Add version to firmware image
This commit is contained in:
parent
17cce5687f
commit
81ffcf5ae1
10
Makefile
10
Makefile
@ -5,11 +5,17 @@ $(info $(shell cd src/board && echo */*))
|
|||||||
$(error BOARD not set)
|
$(error BOARD not set)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# Calculate version
|
||||||
|
DATE=$(shell git show --format="%cd" --date="format:%Y-%m-%d" --no-patch)
|
||||||
|
REV=$(shell git describe --always --dirty)
|
||||||
|
VERSION=$(DATE)_$(REV)
|
||||||
|
|
||||||
# Set build directory
|
# Set build directory
|
||||||
BUILD=build/$(BOARD)
|
BUILD=build/$(BOARD)/$(VERSION)
|
||||||
|
|
||||||
# Default target - build the board's EC firmware
|
# Default target - build the board's EC firmware
|
||||||
all: $(BUILD)/ec.rom
|
all: $(BUILD)/ec.rom
|
||||||
|
$(info Built '$(VERSION)' for '$(BOARD)')
|
||||||
|
|
||||||
# Target to remove build artifacts
|
# Target to remove build artifacts
|
||||||
clean:
|
clean:
|
||||||
@ -19,7 +25,7 @@ clean:
|
|||||||
COMMON_DIR=src/common
|
COMMON_DIR=src/common
|
||||||
SRC=$(wildcard $(COMMON_DIR)/*.c)
|
SRC=$(wildcard $(COMMON_DIR)/*.c)
|
||||||
INCLUDE=$(wildcard $(COMMON_DIR)/include/common/*.h) $(COMMON_DIR)/common.mk
|
INCLUDE=$(wildcard $(COMMON_DIR)/include/common/*.h) $(COMMON_DIR)/common.mk
|
||||||
CFLAGS=-I$(COMMON_DIR)/include
|
CFLAGS=-I$(COMMON_DIR)/include -D__VERSION__=$(VERSION)
|
||||||
include $(COMMON_DIR)/common.mk
|
include $(COMMON_DIR)/common.mk
|
||||||
|
|
||||||
# Include the board's source
|
# Include the board's source
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include <board/smbus.h>
|
#include <board/smbus.h>
|
||||||
#include <common/debug.h>
|
#include <common/debug.h>
|
||||||
#include <common/macro.h>
|
#include <common/macro.h>
|
||||||
|
#include <common/version.h>
|
||||||
|
|
||||||
void external_0(void) __interrupt(0) {}
|
void external_0(void) __interrupt(0) {}
|
||||||
// timer_0 is in time.c
|
// timer_0 is in time.c
|
||||||
@ -91,7 +91,7 @@ void main(void) {
|
|||||||
gpio_set(&SMI_N, true);
|
gpio_set(&SMI_N, true);
|
||||||
gpio_set(&SWI_N, true);
|
gpio_set(&SWI_N, true);
|
||||||
|
|
||||||
INFO("Hello from System76 EC for %s!\n", xstr(__BOARD__));
|
INFO("System76 EC board '%s', version '%s'\n", board(), version());
|
||||||
|
|
||||||
for(main_cycle = 0; ; main_cycle++) {
|
for(main_cycle = 0; ; main_cycle++) {
|
||||||
// Handle power states
|
// Handle power states
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include <board/smbus.h>
|
#include <board/smbus.h>
|
||||||
#include <common/debug.h>
|
#include <common/debug.h>
|
||||||
#include <common/macro.h>
|
#include <common/macro.h>
|
||||||
|
#include <common/version.h>
|
||||||
|
|
||||||
void external_0(void) __interrupt(0) {}
|
void external_0(void) __interrupt(0) {}
|
||||||
// timer_0 is in time.c
|
// timer_0 is in time.c
|
||||||
@ -93,7 +93,7 @@ void main(void) {
|
|||||||
gpio_set(&SMI_N, true);
|
gpio_set(&SMI_N, true);
|
||||||
gpio_set(&SWI_N, true);
|
gpio_set(&SWI_N, true);
|
||||||
|
|
||||||
INFO("Hello from System76 EC for %s!\n", xstr(__BOARD__));
|
INFO("System76 EC board '%s', version '%s'\n", board(), version());
|
||||||
|
|
||||||
for(main_cycle = 0; ; main_cycle++) {
|
for(main_cycle = 0; ; main_cycle++) {
|
||||||
// Handle power states
|
// Handle power states
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#include <board/tcpm.h>
|
#include <board/tcpm.h>
|
||||||
#include <common/debug.h>
|
#include <common/debug.h>
|
||||||
#include <common/macro.h>
|
#include <common/macro.h>
|
||||||
|
#include <common/version.h>
|
||||||
|
|
||||||
void external_0(void) __interrupt(0) {}
|
void external_0(void) __interrupt(0) {}
|
||||||
// timer_0 is in time.c
|
// timer_0 is in time.c
|
||||||
@ -95,7 +95,7 @@ void main(void) {
|
|||||||
gpio_set(&SMI_N, true);
|
gpio_set(&SMI_N, true);
|
||||||
gpio_set(&SWI_N, true);
|
gpio_set(&SWI_N, true);
|
||||||
|
|
||||||
INFO("Hello from System76 EC for %s!\n", xstr(__BOARD__));
|
INFO("System76 EC board '%s', version '%s'\n", board(), version());
|
||||||
|
|
||||||
for(main_cycle = 0; ; main_cycle++) {
|
for(main_cycle = 0; ; main_cycle++) {
|
||||||
// Handle power states
|
// Handle power states
|
||||||
|
7
src/common/include/common/version.h
Normal file
7
src/common/include/common/version.h
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#ifndef _COMMON_VERSION_H
|
||||||
|
#define _COMMON_VERSION_H
|
||||||
|
|
||||||
|
const char * board();
|
||||||
|
const char * version();
|
||||||
|
|
||||||
|
#endif // _COMMON_VERSION_H
|
17
src/common/version.c
Normal file
17
src/common/version.c
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#include <common/macro.h>
|
||||||
|
|
||||||
|
static const char __code BOARD[] =
|
||||||
|
"76EC_BOARD="
|
||||||
|
xstr(__BOARD__);
|
||||||
|
|
||||||
|
static const char __code VERSION[] =
|
||||||
|
"76EC_VERSION="
|
||||||
|
xstr(__VERSION__);
|
||||||
|
|
||||||
|
const char * board() {
|
||||||
|
return &BOARD[11];
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * version() {
|
||||||
|
return &VERSION[13];
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user