]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
xilinx: Wire uuid reading from FRU
authorMichal Simek <michal.simek@amd.com>
Thu, 21 Jul 2022 14:19:17 +0000 (16:19 +0200)
committerMichal Simek <michal.simek@amd.com>
Tue, 26 Jul 2022 06:25:16 +0000 (08:25 +0200)
UUID is already recorded when FRU is parsed but it is not copied to local
structures and exported to variable that's why simply add it.
Data is saved in binary format but there must be conversion to string for
exporting it to variable and string should be in uuid format too.

One way how to use it directly is to setup pxeuuid based on it. For
example via preboot with "setenv pxeuuid ${board_uuid}"

Signed-off-by: Michal Simek <michal.simek@amd.com>
Link: https://lore.kernel.org/r/1dfa4b4220a508abc05351da2119880811b77612.1658413156.git.michal.simek@amd.com
board/xilinx/common/board.c

index 5f2afb9def4eef68441198bfc161c4c6f52dae9d..b0c11aaa4256d610ea0f9790fad464717672edd5 100644 (file)
@@ -23,6 +23,7 @@
 #include <soc.h>
 #include <linux/ctype.h>
 #include <linux/kernel.h>
+#include <uuid.h>
 
 #include "fru.h"
 
@@ -86,6 +87,7 @@ int zynq_board_read_rom_ethaddr(unsigned char *ethaddr)
 #define EEPROM_HDR_SERIAL_LEN          20
 #define EEPROM_HDR_NO_OF_MAC_ADDR      4
 #define EEPROM_HDR_ETH_ALEN            ETH_ALEN
+#define EEPROM_HDR_UUID_LEN            16
 
 struct xilinx_board_description {
        u32 header;
@@ -94,6 +96,7 @@ struct xilinx_board_description {
        char revision[EEPROM_HDR_REV_LEN + 1];
        char serial[EEPROM_HDR_SERIAL_LEN + 1];
        u8 mac_addr[EEPROM_HDR_NO_OF_MAC_ADDR][EEPROM_HDR_ETH_ALEN + 1];
+       char uuid[EEPROM_HDR_UUID_LEN + 1];
 };
 
 static int highest_id = -1;
@@ -237,6 +240,8 @@ static int xilinx_read_eeprom_fru(struct udevice *dev, char *name,
        /* It is clear that FRU was captured and structures were filled */
        strncpy(desc->manufacturer, (char *)fru_data.brd.manufacturer_name,
                sizeof(desc->manufacturer));
+       strncpy(desc->uuid, (char *)fru_data.brd.uuid,
+               sizeof(desc->uuid));
        strncpy(desc->name, (char *)fru_data.brd.product_name,
                sizeof(desc->name));
        for (i = 0; i < sizeof(desc->name); i++) {
@@ -452,6 +457,19 @@ int board_late_init_xilinx(void)
                                ret |= env_set_by_index("serial", id,
                                                        desc->serial);
 
+                       if (desc->uuid[0]) {
+                               char uuid[UUID_STR_LEN + 1];
+                               char *t = desc->uuid;
+
+                               memset(uuid, 0, UUID_STR_LEN + 1);
+
+                               sprintf(uuid, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+                                       t[0], t[1], t[2], t[3], t[4], t[5],
+                                       t[6], t[7], t[8], t[9], t[10], t[11],
+                                       t[12], t[13], t[14], t[15]);
+                               ret |= env_set_by_index("uuid", id, uuid);
+                       }
+
                        if (!CONFIG_IS_ENABLED(NET))
                                continue;