All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mattijs Korpershoek <mkorpershoek@baylibre.com>
To: Neil Armstrong <narmstrong@baylibre.com>
Cc: u-boot-amlogic@groups.io, u-boot@lists.denx.de,
	Mattijs Korpershoek <mkorpershoek@baylibre.com>
Subject: [PATCH] board: amlogic: vim3: configure serial# from ethaddr
Date: Wed, 19 Jan 2022 15:24:00 +0100	[thread overview]
Message-ID: <20220119142400.127342-1-mkorpershoek@baylibre.com> (raw)

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>
---
 board/amlogic/vim3/vim3.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/board/amlogic/vim3/vim3.c b/board/amlogic/vim3/vim3.c
index 5d9ac6458d68..fcd60ab1e058 100644
--- a/board/amlogic/vim3/vim3.c
+++ b/board/amlogic/vim3/vim3.c
@@ -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;
 }
-- 
2.32.0


             reply	other threads:[~2022-01-19 14:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-19 14:24 Mattijs Korpershoek [this message]
2022-01-19 14:43 ` [PATCH] board: amlogic: vim3: configure serial# from ethaddr Neil Armstrong
2022-01-19 14:47 ` Neil Armstrong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220119142400.127342-1-mkorpershoek@baylibre.com \
    --to=mkorpershoek@baylibre.com \
    --cc=narmstrong@baylibre.com \
    --cc=u-boot-amlogic@groups.io \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.