-
Notifications
You must be signed in to change notification settings - Fork 336
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lk2nd: Add version module for VCS tag reporting
Signed-off-by: Nikita Travkin <[email protected]>
- Loading branch information
Showing
5 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#ifndef LK2ND_VERSION_H | ||
#define LK2ND_VERSION_H | ||
|
||
extern const char* LK2ND_VERSION; | ||
|
||
#endif /* LK2ND_VERSION_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
LOCAL_DIR := $(GET_LOCAL_DIR) | ||
|
||
OBJS += \ | ||
$(LOCAL_DIR)/version.o \ | ||
|
||
# Generate the version tag from VCS | ||
|
||
LK2ND_VERSION := $(shell $(LK_TOP_DIR)/lk2nd/scripts/describe-version.sh) | ||
VERSION_FILE := $(BUILDDIR)/$(LOCAL_DIR)/tag.c | ||
|
||
FORCE: | ||
|
||
$(VERSION_FILE): FORCE | ||
@$(MKDIR) | ||
@echo "const char* LK2ND_VERSION = \"$(LK2ND_VERSION)\";" > $@.tmp | ||
@if ! cmp -s $@.tmp $@; then \ | ||
echo generating $@ for lk2nd $(LK2ND_VERSION); \ | ||
mv $@.tmp $@; \ | ||
fi | ||
|
||
OBJS += \ | ||
$(LOCAL_DIR)/tag.o \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
/* Copyright (c) 2023, Nikita Travkin <[email protected]> */ | ||
|
||
#include <boot.h> | ||
#include <libfdt.h> | ||
#include <fastboot.h> | ||
|
||
#include <lk2nd/version.h> | ||
|
||
/* | ||
* version.c - Pass lk2nd build information to the OS. | ||
* | ||
* Per DT spec /chosen is used for various firmware | ||
* parameters so we place our version here in case OS wants | ||
* to use these to i.e. OTA update the lk2nd. | ||
*/ | ||
|
||
#define xstr(s) str(s) | ||
#define str(s) #s | ||
|
||
static int lk2nd_version_dt_update(void *dtb, const char *cmdline, | ||
enum boot_type boot_type) | ||
{ | ||
int ret, offset; | ||
|
||
if (boot_type & (BOOT_DOWNSTREAM | BOOT_LK2ND)) | ||
return 0; | ||
|
||
offset = fdt_path_offset(dtb, "/chosen"); | ||
if (offset < 0) | ||
return 0; | ||
|
||
ret = fdt_setprop_string(dtb, offset, "lk2nd,project", xstr(BOARD)); | ||
if (ret < 0) | ||
return 0; | ||
|
||
ret = fdt_setprop_string(dtb, offset, "lk2nd,version", LK2ND_VERSION); | ||
if (ret < 0) | ||
return 0; | ||
|
||
return 0; | ||
} | ||
DEV_TREE_UPDATE(lk2nd_version_dt_update); | ||
|
||
static void lk2nd_version_publish(void) | ||
{ | ||
fastboot_publish("lk2nd:version", LK2ND_VERSION); | ||
} | ||
FASTBOOT_INIT(lk2nd_version_publish); |