Skip to content

Commit f39d5cd

Browse files
committed
helios64: u-boot: cherry-pick fdt_fixup_ethernet logs and fileenv cmd
Pull two generic v2026.04 patches that helios64 currently misses because BOOTPATCHDIR points at the self-contained board_helios64 subdirectory and does not inherit from patch/u-boot/v2026.04/. - 1001-fdt_fixup_ethernet-add-logs.patch: diagnostic log_info() calls in boot/fdt_support.c and boot/image-fdt.c. helios64 hits this path via its gmac ethernet fixups. - cmd-fileenv-read-string-from-file-into-env.patch: adds the 'fileenv' command. Enable CONFIG_CMD_FILEENV in helios64.conf alongside, matching the convention of odroidm1 / khadas-vim3 / odroidm1s which bring in the patch and enable the option in the same commit. The command is purely additive — it does not affect armbianEnv.txt or the existing env mechanics, only adds a new CLI command to read a file into env. Other parent-level patches (rk3288 VOP, rk3588 I2S MCLK, DW-HDMI disable) are SoC-specific or require config options helios64 does not enable, so they are not pulled in.
1 parent 0d03946 commit f39d5cd

3 files changed

Lines changed: 291 additions & 0 deletions

File tree

config/boards/helios64.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ if [[ "$ROOTFS_TYPE" =~ f2fs|nilfs2|nfs|xfs ]]; then
2525
BOOTPART_REQUIRED=${BOOTPART_REQUIRED:-yes}
2626
fi
2727

28+
function post_config_uboot_target__helios64_enable_fileenv() {
29+
display_alert "u-boot for ${BOARD}" "enable CONFIG_CMD_FILEENV" "info"
30+
run_host_command_logged scripts/config --enable CONFIG_CMD_FILEENV # added via cmd-fileenv-read-string-from-file-into-env.patch
31+
}
32+
2833
function post_family_tweaks__helios64_enable_heartbeat() {
2934
display_alert "$BOARD" "Installing board tweaks" "info"
3035

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Ricardo Pardini <ricardo@pardini.net>
3+
Date: Mon, 12 Jan 2026 18:26:25 +0100
4+
Subject: fdt_fixup_ethernet: add logs
5+
6+
---
7+
boot/fdt_support.c | 56 +++++++---
8+
boot/image-fdt.c | 18 +++
9+
2 files changed, 59 insertions(+), 15 deletions(-)
10+
11+
diff --git a/boot/fdt_support.c b/boot/fdt_support.c
12+
index 111111111111..222222222222 100644
13+
--- a/boot/fdt_support.c
14+
+++ b/boot/fdt_support.c
15+
@@ -632,27 +632,31 @@ int fdt_fixup_memory(void *blob, u64 start, u64 size)
16+
17+
void fdt_fixup_ethernet(void *fdt)
18+
{
19+
+ log_info("[fdt_fixup_ethernet] called\n");
20+
int i = 0, j, prop;
21+
char *tmp, *end;
22+
char mac[16];
23+
const char *path;
24+
unsigned char mac_addr[ARP_HLEN];
25+
int offset;
26+
+ int total_aliases = 0, total_attempted = 0, total_skipped = 0, total_patched = 0;
27+
#ifdef FDT_SEQ_MACADDR_FROM_ENV
28+
int nodeoff;
29+
const struct fdt_property *fdt_prop;
30+
#endif
31+
32+
- if (fdt_path_offset(fdt, "/aliases") < 0)
33+
+ int aliases_off = fdt_path_offset(fdt, "/aliases");
34+
+ if (aliases_off < 0) {
35+
+ log_info("[fdt_fixup_ethernet] /aliases node not found\n");
36+
return;
37+
+ }
38+
39+
/* Cycle through all aliases */
40+
for (prop = 0; ; prop++) {
41+
const char *name;
42+
43+
/* FDT might have been edited, recompute the offset */
44+
- offset = fdt_first_property_offset(fdt,
45+
- fdt_path_offset(fdt, "/aliases"));
46+
+ offset = fdt_first_property_offset(fdt, aliases_off);
47+
/* Select property number 'prop' */
48+
for (j = 0; j < prop; j++)
49+
offset = fdt_next_property_offset(fdt, offset);
50+
@@ -660,7 +664,10 @@ void fdt_fixup_ethernet(void *fdt)
51+
if (offset < 0)
52+
break;
53+
54+
+ total_aliases++;
55+
path = fdt_getprop_by_offset(fdt, offset, &name, NULL);
56+
+ log_info("[fdt_fixup_ethernet] alias #%d: name='%s', path='%s'\n", prop, name, path ? path : "<null>");
57+
+
58+
if (!strncmp(name, "ethernet", 8)) {
59+
/* Treat plain "ethernet" same as "ethernet0". */
60+
if (!strcmp(name, "ethernet")
61+
@@ -679,33 +686,52 @@ void fdt_fixup_ethernet(void *fdt)
62+
else
63+
sprintf(mac, "eth%daddr", i);
64+
} else {
65+
+ log_info("[fdt_fixup_ethernet] Skipping alias '%s' (invalid index)\n", name);
66+
+ total_skipped++;
67+
continue;
68+
}
69+
#ifdef FDT_SEQ_MACADDR_FROM_ENV
70+
nodeoff = fdt_path_offset(fdt, path);
71+
- fdt_prop = fdt_get_property(fdt, nodeoff, "status",
72+
- NULL);
73+
- if (fdt_prop && !strcmp(fdt_prop->data, "disabled"))
74+
+ fdt_prop = fdt_get_property(fdt, nodeoff, "status", NULL);
75+
+ if (fdt_prop && !strcmp(fdt_prop->data, "disabled")) {
76+
+ log_info("[fdt_fixup_ethernet] Node '%s' is disabled, skipping\n", path);
77+
+ total_skipped++;
78+
continue;
79+
+ }
80+
i++;
81+
#endif
82+
+ total_attempted++;
83+
tmp = env_get(mac);
84+
- if (!tmp)
85+
+ log_info("[fdt_fixup_ethernet] env var for alias '%s' is '%s', value='%s'\n", name, mac, tmp ? tmp : "<not set>");
86+
+ if (!tmp) {
87+
+ log_info("[fdt_fixup_ethernet] env var '%s' not set, skipping\n", mac);
88+
+ total_skipped++;
89+
continue;
90+
-
91+
+ }
92+
+ int nodeoff = fdt_path_offset(fdt, path);
93+
+ if (nodeoff < 0) {
94+
+ log_info("[fdt_fixup_ethernet] Node path '%s' not found, skipping\n", path);
95+
+ total_skipped++;
96+
+ continue;
97+
+ }
98+
+ const struct fdt_property *status_prop = fdt_get_property(fdt, nodeoff, "status", NULL);
99+
+ if (status_prop && strcmp((const char *)status_prop->data, "okay")) {
100+
+ log_info("[fdt_fixup_ethernet] Node '%s' status is '%s', skipping\n", path, (const char *)status_prop->data);
101+
+ total_skipped++;
102+
+ continue;
103+
+ }
104+
for (j = 0; j < 6; j++) {
105+
- mac_addr[j] = tmp ?
106+
- hextoul(tmp, &end) : 0;
107+
+ mac_addr[j] = tmp ? hextoul(tmp, &end) : 0;
108+
if (tmp)
109+
tmp = (*end) ? end + 1 : end;
110+
}
111+
-
112+
- do_fixup_by_path(fdt, path, "mac-address",
113+
- &mac_addr, 6, 0);
114+
- do_fixup_by_path(fdt, path, "local-mac-address",
115+
- &mac_addr, 6, 1);
116+
+ log_info("[fdt_fixup_ethernet] Patching node '%s' (offset %d) with MAC %02x:%02x:%02x:%02x:%02x:%02x\n", path, nodeoff, mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]);
117+
+ do_fixup_by_path(fdt, path, "mac-address", &mac_addr, 6, 0);
118+
+ do_fixup_by_path(fdt, path, "local-mac-address", &mac_addr, 6, 1);
119+
+ total_patched++;
120+
}
121+
}
122+
+ log_info("[fdt_fixup_ethernet] SUMMARY: aliases found=%d, attempted=%d, skipped=%d, patched=%d\n", total_aliases, total_attempted, total_skipped, total_patched);
123+
}
124+
125+
int fdt_record_loadable(void *blob, u32 index, const char *name,
126+
diff --git a/boot/image-fdt.c b/boot/image-fdt.c
127+
index 111111111111..222222222222 100644
128+
--- a/boot/image-fdt.c
129+
+++ b/boot/image-fdt.c
130+
@@ -1,3 +1,4 @@
131+
+#warning "Building image-fdt.c: fdt fixup call chain instrumented for MAC debugging."
132+
// SPDX-License-Identifier: GPL-2.0+
133+
/*
134+
* Copyright (c) 2013, Google Inc.
135+
@@ -586,11 +587,25 @@ __weak int ft_verify_fdt(void *fdt)
136+
137+
__weak int arch_fixup_fdt(void *blob)
138+
{
139+
+ log_info("[arch_fixup_fdt] called (weak stub)\n");
140+
+ return 0;
141+
+}
142+
+
143+
+__weak int ft_board_setup(void *blob, struct bd_info *bd)
144+
+{
145+
+ log_info("[ft_board_setup] called (weak stub)\n");
146+
+ return 0;
147+
+}
148+
+
149+
+__weak int ft_system_setup(void *blob, struct bd_info *bd)
150+
+{
151+
+ log_info("[ft_system_setup] called (weak stub)\n");
152+
return 0;
153+
}
154+
155+
int image_setup_libfdt(struct bootm_headers *images, void *blob, bool lmb)
156+
{
157+
+ log_info("[image_setup_libfdt] called\n");
158+
ulong *initrd_start = &images->initrd_start;
159+
ulong *initrd_end = &images->initrd_end;
160+
bool skip_board_fixup = false;
161+
@@ -638,6 +653,7 @@ int image_setup_libfdt(struct bootm_headers *images, void *blob, bool lmb)
162+
strlen(images->fit_uname_cfg) + 1, 1);
163+
164+
/* Update ethernet nodes */
165+
+ log_info("[image_setup_libfdt] calling fdt_fixup_ethernet\n");
166+
fdt_fixup_ethernet(blob);
167+
#if IS_ENABLED(CONFIG_CMD_PSTORE)
168+
/* Append PStore configuration */
169+
@@ -651,6 +667,7 @@ int image_setup_libfdt(struct bootm_headers *images, void *blob, bool lmb)
170+
}
171+
172+
if (IS_ENABLED(CONFIG_OF_BOARD_SETUP) && !skip_board_fixup) {
173+
+ log_info("[image_setup_libfdt] calling ft_board_setup\n");
174+
fdt_ret = ft_board_setup(blob, gd->bd);
175+
if (fdt_ret) {
176+
printf("ERROR: board-specific fdt fixup failed: %s\n",
177+
@@ -659,6 +676,7 @@ int image_setup_libfdt(struct bootm_headers *images, void *blob, bool lmb)
178+
}
179+
}
180+
if (IS_ENABLED(CONFIG_OF_SYSTEM_SETUP)) {
181+
+ log_info("[image_setup_libfdt] calling ft_system_setup\n");
182+
fdt_ret = ft_system_setup(blob, gd->bd);
183+
if (fdt_ret) {
184+
printf("ERROR: system-specific fdt fixup failed: %s\n",
185+
--
186+
Armbian
187+
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Ricardo Pardini <ricardo@pardini.net>
3+
Date: Fri, 31 Jan 2025 15:52:03 +0100
4+
Subject: cmd: fileenv: read string from file into env
5+
6+
- rpardini: adapted from vendor/legacy patch from 2018
7+
8+
Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch>
9+
Signed-off-by: Stefan Agner <stefan@agner.ch>
10+
Signed-off-by: Ricardo Pardini <ricardo@pardini.net>
11+
---
12+
cmd/Kconfig | 5 +
13+
cmd/Makefile | 1 +
14+
cmd/fileenv.c | 46 ++++++++++
15+
3 files changed, 52 insertions(+)
16+
17+
diff --git a/cmd/Kconfig b/cmd/Kconfig
18+
index 111111111111..222222222222 100644
19+
--- a/cmd/Kconfig
20+
+++ b/cmd/Kconfig
21+
@@ -1927,6 +1927,11 @@ config CMD_XXD
22+
help
23+
Print file as hexdump to standard output
24+
25+
+config CMD_FILEENV
26+
+ bool "fileenv"
27+
+ help
28+
+ Read a file into memory and store it to env.
29+
+
30+
endmenu
31+
32+
if NET || NET_LWIP
33+
diff --git a/cmd/Makefile b/cmd/Makefile
34+
index 111111111111..222222222222 100644
35+
--- a/cmd/Makefile
36+
+++ b/cmd/Makefile
37+
@@ -176,6 +176,7 @@ obj-$(CONFIG_CMD_SHA1SUM) += sha1sum.o
38+
obj-$(CONFIG_CMD_SEAMA) += seama.o
39+
obj-$(CONFIG_CMD_SETEXPR) += setexpr.o
40+
obj-$(CONFIG_CMD_SETEXPR_FMT) += printf.o
41+
+obj-$(CONFIG_CMD_FILEENV) += fileenv.o
42+
obj-$(CONFIG_CMD_SPI) += spi.o
43+
obj-$(CONFIG_CMD_STRINGS) += strings.o
44+
obj-$(CONFIG_CMD_SM3SUM) += sm3sum.o
45+
diff --git a/cmd/fileenv.c b/cmd/fileenv.c
46+
new file mode 100644
47+
index 000000000000..111111111111
48+
--- /dev/null
49+
+++ b/cmd/fileenv.c
50+
@@ -0,0 +1,46 @@
51+
+#include <config.h>
52+
+#include <command.h>
53+
+#include <fs.h>
54+
+#include <linux/ctype.h>
55+
+#include <vsprintf.h>
56+
+#include "env.h"
57+
+static char *fs_argv[5];
58+
+
59+
+int do_fileenv(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[])
60+
+{
61+
+ if (argc < 6)
62+
+ return CMD_RET_USAGE;
63+
+
64+
+ fs_argv[0] = "fatload";
65+
+ fs_argv[1] = argv[1];
66+
+ fs_argv[2] = argv[2];
67+
+ fs_argv[3] = argv[3];
68+
+ fs_argv[4] = argv[4];
69+
+
70+
+ if (do_fat_fsload(cmdtp, 0, 5, fs_argv) != 0)
71+
+ return 1;
72+
+
73+
+ char *addr = (char *)simple_strtoul(argv[3], NULL, 16);
74+
+ size_t size = env_get_hex("filesize", 0);
75+
+
76+
+ // Prepare string
77+
+ addr[size] = 0x00;
78+
+ char *s = addr;
79+
+ while(*s != 0x00) {
80+
+ if (isprint(*s)) {
81+
+ s++;
82+
+ }
83+
+ else {
84+
+ *s = 0x00;
85+
+ }
86+
+ }
87+
+
88+
+ return env_set(argv[5], addr);
89+
+}
90+
+
91+
+U_BOOT_CMD(
92+
+ fileenv, 6, 0, do_fileenv,
93+
+ "Read file and store it into env.",
94+
+ "<interface> <dev:part> <addr> <filename> <envname>\n"
95+
+ " - Read file from fat32 and store it as env."
96+
+);
97+
--
98+
Armbian
99+

0 commit comments

Comments
 (0)