From: Michal Simek Date: Thu, 21 Jul 2022 14:19:17 +0000 (+0200) Subject: xilinx: Wire uuid reading from FRU X-Git-Url: http://git.dujemihanovic.xyz/img/%7B%7B%20%28.OutputFormats.Get?a=commitdiff_plain;h=ee5a4b87a1a57607db28fafa2692dabf92c64570;p=u-boot.git xilinx: Wire uuid reading from FRU 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 Link: https://lore.kernel.org/r/1dfa4b4220a508abc05351da2119880811b77612.1658413156.git.michal.simek@amd.com --- diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c index 5f2afb9def..b0c11aaa42 100644 --- a/board/xilinx/common/board.c +++ b/board/xilinx/common/board.c @@ -23,6 +23,7 @@ #include #include #include +#include #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;