Skip to content

Commit

Permalink
board: amlogic: vim3: configure serial# from ethaddr
Browse files Browse the repository at this point in the history
The Khadas VIM3 and VIM3L boards, which are supported in Android via
Yukawa [1] need a serial number for usb/fastboot enumeration.

Whenever the environment does not provide a serial#, use the eth mac
address as serial#.

[1] https://source.android.com/setup/build/devices#vim3_and_vim3l_boards

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Link: https://lore.kernel.org/r/20220119142400.127342-1-mkorpershoek@baylibre.com
  • Loading branch information
makohoek authored and superna9999 committed Jan 20, 2022
1 parent b749d5e commit 09c2deb
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions board/amlogic/vim3/vim3.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ int misc_init_r(void)
{
u8 mac_addr[MAC_ADDR_LEN];
char efuse_mac_addr[EFUSE_MAC_SIZE], tmp[3];
char serial_string[EFUSE_MAC_SIZE + 1];
ssize_t len;

if (!eth_env_get_enetaddr("ethaddr", mac_addr)) {
Expand All @@ -177,5 +178,13 @@ int misc_init_r(void)
eth_env_get_enetaddr("ethaddr", mac_addr);
}

if (!env_get("serial#")) {
eth_env_get_enetaddr("ethaddr", mac_addr);
sprintf(serial_string, "%02X%02X%02X%02X%02X%02X",
mac_addr[0], mac_addr[1], mac_addr[2],
mac_addr[3], mac_addr[4], mac_addr[5]);
env_set("serial#", serial_string);
}

return 0;
}

0 comments on commit 09c2deb

Please sign in to comment.