Skip to content

Commit

Permalink
lk2nd: serialno: Pass lk2nd version to the OS
Browse files Browse the repository at this point in the history
  • Loading branch information
TravMurav committed Aug 29, 2023
1 parent c31d8d1 commit b8aeac4
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions lk2nd/serialno/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ MODULES += lib/libfdt
OBJS += \
$(LOCAL_DIR)/mac.o \
$(LOCAL_DIR)/serialno.o \
$(LOCAL_DIR)/version.o \
42 changes: 42 additions & 0 deletions lk2nd/serialno/version.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// SPDX-License-Identifier: BSD-3-Clause
/* Copyright (c) 2023, Nikita Travkin <[email protected]> */

#include <boot.h>
#include <libfdt.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", xstr(LK2ND_VERSION));
if (ret < 0)
return 0;

return 0;
}
DEV_TREE_UPDATE(lk2nd_version_dt_update);

0 comments on commit b8aeac4

Please sign in to comment.