Skip to contentSkip to conversation

board: amlogic: vim3: configure serial# from ethaddr

PATCH In review Mattijs Korpershoek 2 participants 3 messages Jan 19, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 board: amlogic: vim3: configure serial# from ethaddr

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

---
 board/amlogic/vim3/vim3.c | 9 +++++++++
 1 file changed, 9 insertions(+)
board/amlogic/vim3/vim3.c +9 -0
index 5d9ac6458d68..fcd60ab1e058 100644
@@ -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)) {
@@ -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;
 }
Signature · 1 line
2.32.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 29 lines · Mattijs Korpershoek

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

---
 board/amlogic/vim3/vim3.c | 9 +++++++++
 1 file changed, 9 insertions(+)
board/amlogic/vim3/vim3.c +1 -0
index 5d9ac6458d68..fcd60ab1e058 100644
@@ -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)) {
@@ -177,5 +178,13 @@ int misc_init_r(void)
 		eth_env_get_enetaddr("ethaddr", mac_addr);
 	}
 

board/amlogic/vim3/vim3.c int misc_init_r(void) · line 190

Quoted 10 lines
board/amlogic/vim3/vim3.c +8 -0
+	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;
 }
#2 lore raw
In reply to Mattijs Korpershoek

Hi,

Quoted 9 lines · Mattijs Korpershoek

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

[...]

Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-amlogic (u-boot-amlogic)

[1/1] board: amlogic: vim3: configure serial# from ethaddr

      https://source.denx.de/u-boot/custodians/u-boot-amlogic/-/commit/522c51839a6f31d66054c44aeffda00888e731ad
Signature · 1 line
Neil