Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2231603/?format=api
{ "id": 2231603, "url": "http://patchwork.ozlabs.org/api/patches/2231603/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/patch/20260430223319.2663939-2-lukas.schmid@netcube.li/", "project": { "id": 18, "url": "http://patchwork.ozlabs.org/api/projects/18/?format=api", "name": "U-Boot", "link_name": "uboot", "list_id": "u-boot.lists.denx.de", "list_email": "u-boot@lists.denx.de", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260430223319.2663939-2-lukas.schmid@netcube.li>", "list_archive_url": null, "date": "2026-04-30T22:33:00", "name": "[v2,1/6] sunxi: move SID MAC fallback from board env setup to EMAC read_rom_hwaddr", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "9f2a3f9426328918f4b27138e8ffd69b094eb7df", "submitter": { "id": 90004, "url": "http://patchwork.ozlabs.org/api/people/90004/?format=api", "name": "Lukas Schmid", "email": "lukas.schmid@netcube.li" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/uboot/patch/20260430223319.2663939-2-lukas.schmid@netcube.li/mbox/", "series": [ { "id": 502402, "url": "http://patchwork.ozlabs.org/api/series/502402/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/list/?series=502402", "date": "2026-04-30T22:32:59", "name": "sunxi: add NetCube Nagami support and T113 secure boot enablement", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/502402/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2231603/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2231603/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<u-boot-bounces@lists.denx.de>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=netcube.li header.i=@netcube.li header.a=rsa-sha256\n header.s=s1 header.b=sv6TL6/z;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de\n (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de;\n envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org)", "phobos.denx.de;\n dmarc=pass (p=none dis=none) header.from=netcube.li", "phobos.denx.de;\n spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de", "phobos.denx.de;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=netcube.li header.i=@netcube.li header.b=\"sv6TL6/z\";\n\tdkim-atps=neutral", "phobos.denx.de;\n dmarc=pass (p=none dis=none) header.from=netcube.li", "phobos.denx.de;\n spf=pass smtp.mailfrom=lukas.schmid@netcube.li" ], "Received": [ "from phobos.denx.de (phobos.denx.de\n [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g68916t2Wz1yJv\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 01 May 2026 08:33:57 +1000 (AEST)", "from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id 4079F841D7;\n\tFri, 1 May 2026 00:33:43 +0200 (CEST)", "by phobos.denx.de (Postfix, from userid 109)\n id 87A39803C6; Fri, 1 May 2026 00:33:42 +0200 (CEST)", "from mail.netcube.li (mail.netcube.li [173.249.15.149])\n (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))\n (No client certificate requested)\n by phobos.denx.de (Postfix) with ESMTPS id 511A2839D5\n for <u-boot@lists.denx.de>; Fri, 1 May 2026 00:33:40 +0200 (CEST)", "from lukas-hpz440workstation.lan.sk100508.local\n (193-80-178-216.hdsl.highway.telekom.at [193.80.178.216])\n by mail.netcube.li with ESMTPA ; Fri, 1 May 2026 00:33:40 +0200" ], "X-Spam-Checker-Version": "SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de", "X-Spam-Level": "", "X-Spam-Status": "No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,\n DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED,\n SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2", "dkim-signature": "v=1; a=rsa-sha256; d=netcube.li; s=s1;\n c=relaxed/relaxed; q=dns/txt;\n h=From:Subject:Date:Message-ID:To:CC:MIME-Version:Content-Transfer-Encoding:In-Reply-To:References;\n bh=y2DsxBoY9Lh4nA2+rQ/dIkM1CtHEkxCkxWpYN6t8LbY=;\n b=sv6TL6/zVPbcArv+qjUECOSOom65GmIFL/6p/b1ACnmhZwp/gEnE9i1RfxuyDy9PAbYQ4+wHK6hBewEmRcdzx6JV4QZWmsSW2d6rGA/DNzKRcI9v/ggko96gs+EHi/Ft2IiTnuuihE+BQprSj+PZN0rdgkjWAq3WyFHmgvQ9ZwU=", "From": "Lukas Schmid <lukas.schmid@netcube.li>", "To": "Andre Przywara <andre.przywara@arm.com>, Tom Rini <trini@konsulko.com>,\n Hans de Goede <hdegoede@redhat.com>,\n Jerome Forissier <jerome.forissier@arm.com>", "Cc": "Lukas Schmid <lukas.schmid@netcube.li>,\n\tu-boot@lists.denx.de", "Subject": "[PATCH v2 1/6] sunxi: move SID MAC fallback from board env setup to\n EMAC read_rom_hwaddr", "Date": "Fri, 1 May 2026 00:33:00 +0200", "Message-ID": "<20260430223319.2663939-2-lukas.schmid@netcube.li>", "X-Mailer": "git-send-email 2.47.3", "In-Reply-To": "<20260430223319.2663939-1-lukas.schmid@netcube.li>", "References": "<20260430223319.2663939-1-lukas.schmid@netcube.li>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-BeenThere": "u-boot@lists.denx.de", "X-Mailman-Version": "2.1.39", "Precedence": "list", "List-Id": "U-Boot discussion <u-boot.lists.denx.de>", "List-Unsubscribe": "<https://lists.denx.de/options/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>", "List-Archive": "<https://lists.denx.de/pipermail/u-boot/>", "List-Post": "<mailto:u-boot@lists.denx.de>", "List-Help": "<mailto:u-boot-request@lists.denx.de?subject=help>", "List-Subscribe": "<https://lists.denx.de/listinfo/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=subscribe>", "Errors-To": "u-boot-bounces@lists.denx.de", "Sender": "\"U-Boot\" <u-boot-bounces@lists.denx.de>", "X-Virus-Scanned": "clamav-milter 0.103.8 at phobos.denx.de", "X-Virus-Status": "Clean" }, "content": "sunxi currently seeds ethaddr/ethXaddr in setup_environment() from SID.\nThat happens before Ethernet probe, so even with a clean persisted\nenvironment we can populate env with a generated MAC and later get a\nmismatch warning when DM Ethernet reads a different MAC from DT/NVMEM.\n\nStop generating Ethernet MAC env variables in setup_environment() and\nprovide SID-derived fallback addresses through read_rom_hwaddr in the\nsunxi EMAC and designware eth drivers instead.\n\nAlso move the SID uniqueness/MAC derivation logic into shared sunxi arch\nhelpers so board code and drivers use one implementation and keep legacy\nalgorithm compatibility across SoCs.\n\nThis keeps the generic MAC source order (DT/NVMEM first, fallback second),\navoids board-level MAC policy special-casing, and prevents same-boot\nenv-vs-NVMEM mismatch warnings caused by early env seeding.\n\nSigned-off-by: Lukas Schmid <lukas.schmid@netcube.li>\n---\n arch/arm/include/asm/arch-sunxi/sys_proto.h | 6 ++\n arch/arm/mach-sunxi/cpu_info.c | 44 ++++++++++++++\n board/sunxi/board.c | 64 +--------------------\n drivers/net/designware.c | 20 +++++++\n drivers/net/sun8i_emac.c | 15 +++++\n drivers/net/sunxi_emac.c | 15 +++++\n 6 files changed, 102 insertions(+), 62 deletions(-)", "diff": "diff --git a/arch/arm/include/asm/arch-sunxi/sys_proto.h b/arch/arm/include/asm/arch-sunxi/sys_proto.h\nindex 92c7721a530..6f70753e948 100644\n--- a/arch/arm/include/asm/arch-sunxi/sys_proto.h\n+++ b/arch/arm/include/asm/arch-sunxi/sys_proto.h\n@@ -12,6 +12,12 @@\n \n void sdelay(unsigned long);\n \n+/* Read SID and apply legacy/newer-SoC normalization for uniqueness. */\n+bool sunxi_get_unique_sid(unsigned int *sid);\n+\n+/* Build legacy-compatible SID-derived locally administered MAC address. */\n+bool sunxi_get_sid_mac_addr(int index, u8 mac[6]);\n+\n /* return_to_fel() - Return to BROM from SPL\n *\n * This returns back into the BROM after U-Boot SPL has performed its initial\ndiff --git a/arch/arm/mach-sunxi/cpu_info.c b/arch/arm/mach-sunxi/cpu_info.c\nindex c3a51d9956e..d804307e280 100644\n--- a/arch/arm/mach-sunxi/cpu_info.c\n+++ b/arch/arm/mach-sunxi/cpu_info.c\n@@ -9,8 +9,10 @@\n #include <asm/io.h>\n #include <asm/arch/cpu.h>\n #include <asm/arch/clock.h>\n+#include <asm/arch/sys_proto.h>\n #include <axp_pmic.h>\n #include <errno.h>\n+#include <u-boot/crc.h>\n \n #ifdef CONFIG_MACH_SUN6I\n int sunxi_get_ss_bonding_id(void)\n@@ -175,3 +177,45 @@ int sunxi_get_sid(unsigned int *sid)\n \treturn -ENODEV;\n #endif\n }\n+\n+bool sunxi_get_unique_sid(unsigned int *sid)\n+{\n+\tif (sunxi_get_sid(sid) != 0)\n+\t\treturn false;\n+\n+\tif (!sid[0])\n+\t\treturn false;\n+\n+\t/*\n+\t * On newer SoCs use a CRC over SID words 1..3 for better uniqueness,\n+\t * while keeping the long-standing algorithm on older SoCs.\n+\t */\n+#if !defined(CONFIG_MACH_SUN4I) && !defined(CONFIG_MACH_SUN5I) && \\\n+\t!defined(CONFIG_MACH_SUN6I) && !defined(CONFIG_MACH_SUN7I) && \\\n+\t!defined(CONFIG_MACH_SUN8I_A23) && !defined(CONFIG_MACH_SUN8I_A33)\n+\tsid[3] = crc32(0, (unsigned char *)&sid[1], 12);\n+#endif\n+\n+\t/* Ensure the NIC-specific bytes are not all 0. */\n+\tif ((sid[3] & 0xffffff) == 0)\n+\t\tsid[3] |= 0x800000;\n+\n+\treturn true;\n+}\n+\n+bool sunxi_get_sid_mac_addr(int index, u8 mac[6])\n+{\n+\tunsigned int sid[4];\n+\n+\tif (!sunxi_get_unique_sid(sid))\n+\t\treturn false;\n+\n+\tmac[0] = ((index & 0xf) << 4) | 0x02;\n+\tmac[1] = (sid[0] >> 0) & 0xff;\n+\tmac[2] = (sid[3] >> 24) & 0xff;\n+\tmac[3] = (sid[3] >> 16) & 0xff;\n+\tmac[4] = (sid[3] >> 8) & 0xff;\n+\tmac[5] = (sid[3] >> 0) & 0xff;\n+\n+\treturn true;\n+}\ndiff --git a/board/sunxi/board.c b/board/sunxi/board.c\nindex d7722d1858a..4a7a3f0e08d 100644\n--- a/board/sunxi/board.c\n+++ b/board/sunxi/board.c\n@@ -41,7 +41,6 @@\n #include <asm/gpio.h>\n #include <sunxi_gpio.h>\n #include <asm/io.h>\n-#include <u-boot/crc.h>\n #include <env_internal.h>\n #include <linux/libfdt.h>\n #include <fdt_support.h>\n@@ -748,38 +747,6 @@ static void parse_spl_header(const uint32_t spl_addr)\n \tenv_set_hex(\"fel_scriptaddr\", spl->fel_script_address);\n }\n \n-static bool get_unique_sid(unsigned int *sid)\n-{\n-\tif (sunxi_get_sid(sid) != 0)\n-\t\treturn false;\n-\n-\tif (!sid[0])\n-\t\treturn false;\n-\n-\t/*\n-\t * The single words 1 - 3 of the SID have quite a few bits\n-\t * which are the same on many models, so we take a crc32\n-\t * of all 3 words, to get a more unique value.\n-\t *\n-\t * Note we only do this on newer SoCs as we cannot change\n-\t * the algorithm on older SoCs since those have been using\n-\t * fixed mac-addresses based on only using word 3 for a\n-\t * long time and changing a fixed mac-address with an\n-\t * u-boot update is not good.\n-\t */\n-#if !defined(CONFIG_MACH_SUN4I) && !defined(CONFIG_MACH_SUN5I) && \\\n- !defined(CONFIG_MACH_SUN6I) && !defined(CONFIG_MACH_SUN7I) && \\\n- !defined(CONFIG_MACH_SUN8I_A23) && !defined(CONFIG_MACH_SUN8I_A33)\n-\tsid[3] = crc32(0, (unsigned char *)&sid[1], 12);\n-#endif\n-\n-\t/* Ensure the NIC specific bytes of the mac are not all 0 */\n-\tif ((sid[3] & 0xffffff) == 0)\n-\t\tsid[3] |= 0x800000;\n-\n-\treturn true;\n-}\n-\n /*\n * Note this function gets called multiple times.\n * It must not make any changes to env variables which already exist.\n@@ -788,37 +755,10 @@ static void setup_environment(const void *fdt)\n {\n \tchar serial_string[17] = { 0 };\n \tunsigned int sid[4];\n-\tuint8_t mac_addr[6];\n-\tchar ethaddr[16];\n-\tint i;\n \n-\tif (!get_unique_sid(sid))\n+\tif (!sunxi_get_unique_sid(sid))\n \t\treturn;\n \n-\tfor (i = 0; i < 4; i++) {\n-\t\tsprintf(ethaddr, \"ethernet%d\", i);\n-\t\tif (!fdt_get_alias(fdt, ethaddr))\n-\t\t\tcontinue;\n-\n-\t\tif (i == 0)\n-\t\t\tstrcpy(ethaddr, \"ethaddr\");\n-\t\telse\n-\t\t\tsprintf(ethaddr, \"eth%daddr\", i);\n-\n-\t\tif (env_get(ethaddr))\n-\t\t\tcontinue;\n-\n-\t\t/* Non OUI / registered MAC address */\n-\t\tmac_addr[0] = (i << 4) | 0x02;\n-\t\tmac_addr[1] = (sid[0] >> 0) & 0xff;\n-\t\tmac_addr[2] = (sid[3] >> 24) & 0xff;\n-\t\tmac_addr[3] = (sid[3] >> 16) & 0xff;\n-\t\tmac_addr[4] = (sid[3] >> 8) & 0xff;\n-\t\tmac_addr[5] = (sid[3] >> 0) & 0xff;\n-\n-\t\teth_env_set_enetaddr(ethaddr, mac_addr);\n-\t}\n-\n \tif (!env_get(\"serial#\")) {\n \t\tsnprintf(serial_string, sizeof(serial_string),\n \t\t\t\"%08x%08x\", sid[0], sid[3]);\n@@ -892,7 +832,7 @@ static void bluetooth_dt_fixup(void *blob)\n \t\tfor (i = 0; i < ETH_ALEN; ++i)\n \t\t\tbdaddr[i] = tmp[ETH_ALEN - i - 1];\n \t} else {\n-\t\tif (!get_unique_sid(sid))\n+\t\tif (!sunxi_get_unique_sid(sid))\n \t\t\treturn;\n \n \t\tbdaddr[0] = ((sid[3] >> 0) & 0xff) ^ 1;\ndiff --git a/drivers/net/designware.c b/drivers/net/designware.c\nindex 6ed9c6d538a..3d8e13031af 100644\n--- a/drivers/net/designware.c\n+++ b/drivers/net/designware.c\n@@ -37,6 +37,8 @@\n #include <asm/arch/gmac.h>\n #endif\n \n+bool sunxi_get_sid_mac_addr(int index, u8 mac[6]);\n+\n static int dw_mdio_read(struct mii_dev *bus, int addr, int devad, int reg)\n {\n \tstruct dw_eth_dev *priv = dev_get_priv((struct udevice *)bus->priv);\n@@ -842,6 +844,23 @@ int designware_eth_write_hwaddr(struct udevice *dev)\n \treturn _dw_write_hwaddr(priv, pdata->enetaddr);\n }\n \n+static int designware_eth_read_rom_hwaddr(struct udevice *dev)\n+{\n+\tstruct eth_pdata *pdata = dev_get_plat(dev);\n+\tu8 mac[ARP_HLEN];\n+\n+\tif (IS_ENABLED(CONFIG_ARCH_SUNXI)) {\n+\t\tif (!sunxi_get_sid_mac_addr(dev_seq(dev), mac))\n+\t\t\treturn -ENODEV;\n+\n+\t\tmemcpy(pdata->enetaddr, mac, ARP_HLEN);\n+\n+\t\treturn 0;\n+\t}\n+\n+\treturn -ENOSYS;\n+}\n+\n static int designware_eth_bind(struct udevice *dev)\n {\n \tif (IS_ENABLED(CONFIG_PCI)) {\n@@ -1018,6 +1037,7 @@ const struct eth_ops designware_eth_ops = {\n \t.free_pkt\t\t= designware_eth_free_pkt,\n \t.stop\t\t\t= designware_eth_stop,\n \t.write_hwaddr\t\t= designware_eth_write_hwaddr,\n+\t.read_rom_hwaddr\t= designware_eth_read_rom_hwaddr,\n };\n \n int designware_eth_of_to_plat(struct udevice *dev)\ndiff --git a/drivers/net/sun8i_emac.c b/drivers/net/sun8i_emac.c\nindex 41c52f56d7a..a267b6cd7f5 100644\n--- a/drivers/net/sun8i_emac.c\n+++ b/drivers/net/sun8i_emac.c\n@@ -13,6 +13,7 @@\n #include <cpu_func.h>\n #include <log.h>\n #include <asm/cache.h>\n+#include <asm/arch/sys_proto.h>\n #include <asm/global_data.h>\n #include <asm/gpio.h>\n #include <asm/io.h>\n@@ -259,6 +260,19 @@ static int sun8i_eth_write_hwaddr(struct udevice *dev)\n \treturn 0;\n }\n \n+static int sun8i_eth_read_rom_hwaddr(struct udevice *dev)\n+{\n+\tstruct eth_pdata *pdata = dev_get_plat(dev);\n+\tu8 mac[ARP_HLEN];\n+\n+\tif (!sunxi_get_sid_mac_addr(dev_seq(dev), mac))\n+\t\treturn -ENODEV;\n+\n+\tmemcpy(pdata->enetaddr, mac, ARP_HLEN);\n+\n+\treturn 0;\n+}\n+\n static void sun8i_adjust_link(struct emac_eth_dev *priv,\n \t\t\t struct phy_device *phydev)\n {\n@@ -715,6 +729,7 @@ static int sun8i_emac_eth_probe(struct udevice *dev)\n \n static const struct eth_ops sun8i_emac_eth_ops = {\n \t.start = sun8i_emac_eth_start,\n+\t.read_rom_hwaddr\t= sun8i_eth_read_rom_hwaddr,\n \t.write_hwaddr = sun8i_eth_write_hwaddr,\n \t.send = sun8i_emac_eth_send,\n \t.recv = sun8i_emac_eth_recv,\ndiff --git a/drivers/net/sunxi_emac.c b/drivers/net/sunxi_emac.c\nindex 3dee849c97e..f45a0790a40 100644\n--- a/drivers/net/sunxi_emac.c\n+++ b/drivers/net/sunxi_emac.c\n@@ -15,6 +15,7 @@\n #include <miiphy.h>\n #include <net.h>\n #include <asm/io.h>\n+#include <asm/arch/sys_proto.h>\n #include <asm/arch/clock.h>\n #include <power/regulator.h>\n \n@@ -539,6 +540,19 @@ static int sunxi_emac_eth_send(struct udevice *dev, void *packet, int length)\n \treturn _sunxi_emac_eth_send(priv, packet, length);\n }\n \n+static int sunxi_emac_read_rom_hwaddr(struct udevice *dev)\n+{\n+\tstruct eth_pdata *pdata = dev_get_plat(dev);\n+\tu8 mac[ARP_HLEN];\n+\n+\tif (!sunxi_get_sid_mac_addr(dev_seq(dev), mac))\n+\t\treturn -ENODEV;\n+\n+\tmemcpy(pdata->enetaddr, mac, ARP_HLEN);\n+\n+\treturn 0;\n+}\n+\n static int sunxi_emac_eth_recv(struct udevice *dev, int flags, uchar **packetp)\n {\n \tstruct emac_eth_dev *priv = dev_get_priv(dev);\n@@ -581,6 +595,7 @@ static int sunxi_emac_eth_probe(struct udevice *dev)\n \n static const struct eth_ops sunxi_emac_eth_ops = {\n \t.start\t\t\t= sunxi_emac_eth_start,\n+\t.read_rom_hwaddr\t= sunxi_emac_read_rom_hwaddr,\n \t.send\t\t\t= sunxi_emac_eth_send,\n \t.recv\t\t\t= sunxi_emac_eth_recv,\n \t.stop\t\t\t= sunxi_emac_eth_stop,\n", "prefixes": [ "v2", "1/6" ] }