sunxi: Add NetCube Systems Kumquat support and fix nvmem MAC handling
v2 cover sunxi: Add NetCube Systems Kumquat support and fix nvmem MAC handling
Changes in v2:
- Renamed the defconfig to match "maker-model" style
- Use the default env offset and size
- Disable redundant env to have U-Boot and env fit into first MB of SPI-Flash
- Remove unused config options (SPI_BOOT, CMD_RTC, SPI_FLASH_BAR,
USB_ETHER_...)
- Update mtdparts layout to reflect new environment layout
This series adds a defconfig for the NetCube Systems Kumquat and fixes and issue with setup_environment ignoring the mac-address loaded using nvmem-cells
Note: This series is based on U-Boot's next branch because it depends on the sun8i-v3s-netcube-kumquat.dts device tree, which was recently synced from upstream Linux and is not yet available in master.
---
Lukas Schmid (2):
sunxi: setup_environment: do not generate a MAC address when one is
set using nvmem-cells
configs: add support for NetCube Systems Kumquat
board/sunxi/board.c | 15 ++++++++++- configs/netcube_kumquat_defconfig | 45 +++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 configs/netcube_kumquat_defconfig
Signature · 1 line
2.39.5
PATCH v2 1/2 sunxi: setup_environment: do not generate a MAC address when one is set using nvmem-cells
Boards using MAC addresses stored in EEPROM via the device tree's nvmem-cells mechanism may already have a valid MAC loaded by the device model. However, setup_environment() currently ignores this and generates a fallback address from the SoC SID if no environment variable is set.
This leads to a mismatch warning during boot when the kernel or U-Boot detects the MAC from nvmem and compares it to the environment.
This patch checks whether the corresponding ethernet device node has a nvmem-cells property and skips generating a fallback MAC if it does, thus avoiding redundant or incorrect ethaddr setup.
This improves compatibility with nvmem-based MAC provisioning and aligns U-Boot behavior with Linux.
--- board/sunxi/board.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
board/sunxi/board.c +14 -1
@@ -774,10 +774,23 @@ static void setup_environment(const void *fdt)return ;for (i =0 ; i <4 ; i++) { +const char *alias; +int nodeoffset; +int len; +const fdt32_t *prop; +sprintf (ethaddr,"ethernet%d" , i); -if (!fdt_get_alias (fdt, ethaddr)) + alias =fdt_get_alias (fdt, ethaddr); +if (!alias)continue ; + nodeoffset =fdt_path_offset (fdt, alias); +if (nodeoffset >=0 ) { + prop =fdt_getprop (fdt, nodeoffset,"nvmem-cells" , &len); +if (prop && len >0 ) +continue ; + } +if (i ==0 )strcpy (ethaddr,"ethaddr" );else
Signature · 1 line
2.39.5
Re: [PATCH v2 1/2] sunxi: setup_environment: do not generate a MAC address when one is set using nvmem-cells
On Tue, 10 Jun 2025 07:38:54 +0200
Lukas Schmid <[email protected]> wrote:
Hi Lukas,
Quoted 6 lines
Boards using MAC addresses stored in EEPROM via the device tree's
nvmem-cellsmechanism may already have a valid MAC loaded by the device model. However,setup_environment()currently ignores this and generates a fallback address from the SoC SID if no environment variable is set.
Quoted 6 lines
This leads to a mismatch warning during boot when the kernel or U-Boot detects the MAC from nvmem and compares it to the environment.
This patch checks whether the corresponding ethernet device node has a
nvmem-cellsproperty and skips generating a fallback MAC if it does, thus avoiding redundant or incorrect ethaddr setup.
So while this seems like a pragmatic solution, I feel it's not the right one: This "peeking into the DT to skip something" sounds backwards. You have probably investigated this more thoroughly, but how does this work here? Did the generic code already parse the MAC address and put it somewhere, and our code here was about to overwrite it? Or will the generic code later fill the gap, if the sunxi code didn't set a MAC address based on the SID?
I feel like the sunxi code is to blame here for doing it at the wrong time or using its own method instead of coordinating with the generic code, so I'd rather fix this properly than papering over it here.
I will help you find a better solution, but if you can dump here what you learned, I'd be grateful, as I am too lazy atm to chase down the code ;-)
Cheers,
Andre
Quoted 37 lines
This improves compatibility with nvmem-based MAC provisioning and aligns U-Boot behavior with Linux.
Signed-off-by Lukas Schmid <[email protected]>--- board/sunxi/board.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)board/sunxi/board.c +14
-1@@ -774,10 +774,23 @@ static void setup_environment(const void *fdt)return ;for (i =0 ; i <4 ; i++) { +const char *alias; +int nodeoffset; +int len; +const fdt32_t *prop; +sprintf (ethaddr,"ethernet%d" , i); -if (!fdt_get_alias (fdt, ethaddr)) + alias =fdt_get_alias (fdt, ethaddr); +if (!alias)continue ; + nodeoffset =fdt_path_offset (fdt, alias); +if (nodeoffset >=0 ) { + prop =fdt_getprop (fdt, nodeoffset,"nvmem-cells" , &len); +if (prop && len >0 ) +continue ; + } +if (i ==0 )strcpy (ethaddr,"ethaddr" );else
Re: [PATCH v2 1/2] sunxi: setup_environment: do not generate a MAC address when one is set using nvmem-cells
14.01.2026 00:16:37 Andre Przywara <[email protected]>:
Quoted 2 lines
On Tue, 10 Jun 2025 07:38:54 +0200
Lukas Schmid <[email protected]> wrote:
Hi Andre,
Quoted 16 lines
Hi Lukas,
Quoted 6 lines
Boards using MAC addresses stored in EEPROM via the device tree's
nvmem-cellsmechanism may already have a valid MAC loaded by the device model. However,setup_environment()currently ignores this and generates a fallback address from the SoC SID if no environment variable is set.Quoted 6 lines
This leads to a mismatch warning during boot when the kernel or U-Boot detects the MAC from nvmem and compares it to the environment.
This patch checks whether the corresponding ethernet device node has a
nvmem-cellsproperty and skips generating a fallback MAC if it does, thus avoiding redundant or incorrect ethaddr setup.
Quoted 7 lines
So while this seems like a pragmatic solution, I feel it's not the right one: This "peeking into the DT to skip something" sounds backwards. You have probably investigated this more thoroughly, but how does this work here? Did the generic code already parse the MAC address and put it somewhere, and our code here was about to overwrite it? Or will the generic code later fill the gap, if the sunxi code didn't set a MAC address based on the SID?
At the time of running setup_environment is not yet set as a environment variable and U-Boot will also not try to set it later since sunxi already set one. I did not find a way in setup_env to check otherwise if there already is a valid Mac somewhere.
U-Boot does know however that there is a different mac intended for the interface as it throws a Mac address mismatch warning.
Quoted 49 lines
I feel like the sunxi code is to blame here for doing it at the wrong time or using its own method instead of coordinating with the generic code, so I'd rather fix this properly than papering over it here.
I will help you find a better solution, but if you can dump here what you learned, I'd be grateful, as I am too lazy atm to chase down the code ;-)
Cheers,
AndreQuoted 37 lines
This improves compatibility with nvmem-based MAC provisioning and aligns U-Boot behavior with Linux.
Signed-off-by Lukas Schmid <[email protected]>---
board/sunxi/board.c| 15 ++++++++++++++-1 file changed, 14 insertions(+), 1 deletion(-)board/sunxi/board.c +14
-1@@ -774,10 +774,23 @@ static void setup_environment(const void *fdt) return; for (i = 0; i < 4; i++) { + const char *alias; + int nodeoffset; + int len; + const fdt32_t *prop; + sprintf(ethaddr, "ethernet%d", i); - if (!fdt_get_alias(fdt, ethaddr)) + alias = fdt_get_alias(fdt, ethaddr); + if (!alias) continue; + nodeoffset = fdt_path_offset(fdt, alias); + if (nodeoffset >= 0) { + prop = fdt_getprop(fdt, nodeoffset, "nvmem-cells", &len); + if (prop && len > 0) + continue; + } + if (i == 0) strcpy(ethaddr, "ethaddr");else
PATCH v2 2/2 configs: add support for NetCube Systems Kumquat
In reply to Lukas SchmidNetCube Systems Kumquat is a board based on the Allwinner V3s SoC, including:
- 64MB DDR2 included in SoC
- 10/100 Mbps Ethernet
- USB-C DRD
- Audio Codec
- Isolated CAN-FD
- ESP32 over SDIO
- 8MB SPI-NOR Flash for bootloader
- I2C EEPROM for MAC addresses
- SDIO Connector for eMMC or SD-Card
- 8x 12/24V IOs, 4x normally open relays
- DS3232 RTC with Battery Backup
- QWIIC connectors for external I2C devices
--- configs/netcube_kumquat_defconfig | 45 +++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 configs/netcube_kumquat_defconfig
configs/netcube_kumquat_defconfig new file +45 -0
@@ -0,0 +1,45 @@ +CONFIG_ARM=y +CONFIG_ARCH_SUNXI=y +CONFIG_SF_DEFAULT_SPEED=40000000 +CONFIG_DEFAULT_DEVICE_TREE="allwinner/sun8i-v3s-netcube-kumquat" +CONFIG_SPL=y +CONFIG_MACH_SUN8I_V3S=y +CONFIG_DRAM_CLK=360 +CONFIG_SPL_SPI_SUNXI=y +# CONFIG_HAS_ARMV7_SECURE_BASE is not set +# CONFIG_TIMESTAMP is not set +CONFIG_BOOTDELAY=1 +CONFIG_PREBOOT="" +# CONFIG_SYS_DEVICE_NULLDEV is not set +CONFIG_SPL_MTD=y +CONFIG_SYS_PROMPT="Kumquat> " +CONFIG_CMD_EEPROM=y +CONFIG_CMD_I2C=y +CONFIG_CMD_MTD=y +CONFIG_MTDIDS_DEFAULT="nor0=firmware" +CONFIG_MTDPARTS_DEFAULT="mtdparts=firmware:960k(u-boot)ro,64k(u-boot-env),-(user)" +CONFIG_CMD_DIAG=y +CONFIG_OF_UPSTREAM=y +# CONFIG_ENV_IS_IN_FAT is not set +CONFIG_ENV_SPI_MAX_HZ=1000000 +CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y +CONFIG_USE_HOSTNAME=y +CONFIG_HOSTNAME="kumquat" +CONFIG_VERSION_VARIABLE=y +# CONFIG_USB_FUNCTION_FASTBOOT is not set +CONFIG_SYS_I2C_MVTWSI=y +CONFIG_MISC=y +CONFIG_NVMEM=y +CONFIG_I2C_EEPROM=y +CONFIG_SYS_I2C_EEPROM_ADDR=0x50 +CONFIG_MTD=y +CONFIG_SPI_FLASH_WINBOND=y +CONFIG_SPI_FLASH_MTD=y +CONFIG_SUN8I_EMAC=y +CONFIG_PHY_SUN4I_USB=y +CONFIG_DM_RTC=y +CONFIG_RTC_DS3232=y +CONFIG_SPI=y +CONFIG_USB_MUSB_HOST=y +CONFIG_USB_MUSB_GADGET=y +# CONFIG_USB_ETHER is not set
Signature · 1 line
2.39.5
Re: [PATCH v2 2/2] configs: add support for NetCube Systems Kumquat
On Tue, 10 Jun 2025 07:38:55 +0200
Lukas Schmid <[email protected]> wrote:
Hi Lukas,
Quoted 28 lines
NetCube Systems Kumquat is a board based on the Allwinner V3s SoC, including:
- 64MB DDR2 included in SoC
- 10/100 Mbps Ethernet
- USB-C DRD
- Audio Codec
- Isolated CAN-FD
- ESP32 over SDIO
- 8MB SPI-NOR Flash for bootloader
- I2C EEPROM for MAC addresses
- SDIO Connector for eMMC or SD-Card
- 8x 12/24V IOs, 4x normally open relays
- DS3232 RTC with Battery Backup
- QWIIC connectors for external I2C devicesSigned-off-by Lukas Schmid <[email protected]>--- configs/netcube_kumquat_defconfig | 45 +++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 configs/netcube_kumquat_defconfigconfigs/netcube_kumquat_defconfig new file +0
-0
configs/netcube_kumquat_defconfig line 7
Quoted 7 lines
configs/netcube_kumquat_defconfig new file +7
-0@@ -0,0 +1,45 @@ +CONFIG_ARM=y +CONFIG_ARCH_SUNXI=y +CONFIG_SF_DEFAULT_SPEED=40000000 +CONFIG_DEFAULT_DEVICE_TREE="allwinner/sun8i-v3s-netcube-kumquat" +CONFIG_SPL=y +CONFIG_MACH_SUN8I_V3S=y +CONFIG_DRAM_CLK=360
This line is redundant, since it's the default. I would be removed by a savedefconfig sync anyway.
Quoted 5 lines
configs/netcube_kumquat_defconfig new file +5
-0+CONFIG_SPL_SPI_SUNXI=y +# CONFIG_HAS_ARMV7_SECURE_BASE is not set +# CONFIG_TIMESTAMP is not set +CONFIG_BOOTDELAY=1 +CONFIG_PREBOOT=""
configs/netcube_kumquat_defconfig line 22
Quoted 10 lines
configs/netcube_kumquat_defconfig new file +10
-0+# CONFIG_SYS_DEVICE_NULLDEV is not set +CONFIG_SPL_MTD=y +CONFIG_SYS_PROMPT="Kumquat> " +CONFIG_CMD_EEPROM=y +CONFIG_CMD_I2C=y +CONFIG_CMD_MTD=y +CONFIG_MTDIDS_DEFAULT="nor0=firmware" +CONFIG_MTDPARTS_DEFAULT="mtdparts=firmware:960k(u-boot)ro,64k(u-boot-env),-(user)" +CONFIG_CMD_DIAG=y +CONFIG_OF_UPSTREAM=y
This one is now redundant as well, as all V3 devices are now using the DT rebasing repo DTs.
Since the rest looks fine, I just removed those lines and queued it for the next PR.
For the records:
Thanks,
Andre
Quoted 23 lines
configs/netcube_kumquat_defconfig new file +23
-0+# CONFIG_ENV_IS_IN_FAT is not set +CONFIG_ENV_SPI_MAX_HZ=1000000 +CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y +CONFIG_USE_HOSTNAME=y +CONFIG_HOSTNAME="kumquat" +CONFIG_VERSION_VARIABLE=y +# CONFIG_USB_FUNCTION_FASTBOOT is not set +CONFIG_SYS_I2C_MVTWSI=y +CONFIG_MISC=y +CONFIG_NVMEM=y +CONFIG_I2C_EEPROM=y +CONFIG_SYS_I2C_EEPROM_ADDR=0x50 +CONFIG_MTD=y +CONFIG_SPI_FLASH_WINBOND=y +CONFIG_SPI_FLASH_MTD=y +CONFIG_SUN8I_EMAC=y +CONFIG_PHY_SUN4I_USB=y +CONFIG_DM_RTC=y +CONFIG_RTC_DS3232=y +CONFIG_SPI=y +CONFIG_USB_MUSB_HOST=y +CONFIG_USB_MUSB_GADGET=y +# CONFIG_USB_ETHER is not set
Quoted 24 lines · On Dienstag, 10. Juni 2025 07:38:53 CEST Lukas Schmid wrote:
Changes in v2:
- Renamed the defconfig to match "maker-model" style
- Use the default env offset and size
- Disable redundant env to have U-Boot and env fit into first MB of SPI-Flash
- Remove unused config options (SPI_BOOT,CMD_RTC,SPI_FLASH_BAR,USB_ETHER_...)- Update mtdparts layout to reflect new environment layout
This series adds a defconfig for the NetCube Systems Kumquat and fixes and issue with
setup_environmentignoring the mac-address loaded using nvmem-cellsNote: This series is based on U-Boot's
nextbranch because it depends on thesun8i-v3s-netcube-kumquat.dtsdevice tree, which was recently synced from upstream Linux and is not yet available inmaster.Signed-off-by Lukas Schmid <[email protected]>---
Lukas Schmid (2):
sunxi:setup_environment: do not generate a MAC address when one is
set using nvmem-cells
configs: add support for NetCube Systems Kumquat
Quoted 4 lines
board/sunxi/board.c | 15 ++++++++++- configs/netcube_kumquat_defconfig | 45 +++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 configs/netcube_kumquat_defconfig
Hi Andre,
Just following up on this v2 series sent on June 10th. It's marked as "New" in Patchwork and assigned to you, so just checking if it's still on your radar.
Happy to address any further feedback if needed.
Thanks again for your time!
Best,
Lukas