-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Expand file tree
/
Copy path1001-fdt_fixup_ethernet-add-logs.patch.disabled
More file actions
189 lines (176 loc) · 6.36 KB
/
1001-fdt_fixup_ethernet-add-logs.patch.disabled
File metadata and controls
189 lines (176 loc) · 6.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Ricardo Pardini <ricardo@pardini.net>
Date: Mon, 12 Jan 2026 18:26:25 +0100
Subject: fdt_fixup_ethernet: add logs
---
boot/fdt_support.c | 56 +++++++---
boot/image-fdt.c | 18 +++
2 files changed, 59 insertions(+), 15 deletions(-)
diff --git a/boot/fdt_support.c b/boot/fdt_support.c
index 111111111111..222222222222 100644
--- a/boot/fdt_support.c
+++ b/boot/fdt_support.c
@@ -632,27 +632,31 @@ int fdt_fixup_memory(void *blob, u64 start, u64 size)
void fdt_fixup_ethernet(void *fdt)
{
+ log_info("[fdt_fixup_ethernet] called\n");
int i = 0, j, prop;
char *tmp, *end;
char mac[16];
const char *path;
unsigned char mac_addr[ARP_HLEN];
int offset;
+ int total_aliases = 0, total_attempted = 0, total_skipped = 0, total_patched = 0;
#ifdef FDT_SEQ_MACADDR_FROM_ENV
int nodeoff;
const struct fdt_property *fdt_prop;
#endif
- if (fdt_path_offset(fdt, "/aliases") < 0)
+ int aliases_off = fdt_path_offset(fdt, "/aliases");
+ if (aliases_off < 0) {
+ log_info("[fdt_fixup_ethernet] /aliases node not found\n");
return;
+ }
/* Cycle through all aliases */
for (prop = 0; ; prop++) {
const char *name;
/* FDT might have been edited, recompute the offset */
- offset = fdt_first_property_offset(fdt,
- fdt_path_offset(fdt, "/aliases"));
+ offset = fdt_first_property_offset(fdt, aliases_off);
/* Select property number 'prop' */
for (j = 0; j < prop; j++)
offset = fdt_next_property_offset(fdt, offset);
@@ -660,7 +664,10 @@ void fdt_fixup_ethernet(void *fdt)
if (offset < 0)
break;
+ total_aliases++;
path = fdt_getprop_by_offset(fdt, offset, &name, NULL);
+ log_info("[fdt_fixup_ethernet] alias #%d: name='%s', path='%s'\n", prop, name, path ? path : "<null>");
+
if (!strncmp(name, "ethernet", 8)) {
/* Treat plain "ethernet" same as "ethernet0". */
if (!strcmp(name, "ethernet")
@@ -679,33 +686,54 @@ void fdt_fixup_ethernet(void *fdt)
else
sprintf(mac, "eth%daddr", i);
} else {
+ log_info("[fdt_fixup_ethernet] Skipping alias '%s' (invalid index)\n", name);
+ total_skipped++;
continue;
}
#ifdef FDT_SEQ_MACADDR_FROM_ENV
nodeoff = fdt_path_offset(fdt, path);
- fdt_prop = fdt_get_property(fdt, nodeoff, "status",
- NULL);
- if (fdt_prop && !strcmp(fdt_prop->data, "disabled"))
+ fdt_prop = fdt_get_property(fdt, nodeoff, "status", NULL);
+ if (fdt_prop && !strcmp(fdt_prop->data, "disabled")) {
+ log_info("[fdt_fixup_ethernet] Node '%s' is disabled, skipping\n", path);
+ total_skipped++;
continue;
+ }
i++;
#endif
+ total_attempted++;
tmp = env_get(mac);
- if (!tmp)
+ log_info("[fdt_fixup_ethernet] env var for alias '%s' is '%s', value='%s'\n", name, mac, tmp ? tmp : "<not set>");
+ if (!tmp) {
+ log_info("[fdt_fixup_ethernet] env var '%s' not set, skipping\n", mac);
+ total_skipped++;
continue;
-
+ }
+#ifndef FDT_SEQ_MACADDR_FROM_ENV
+ int nodeoff = fdt_path_offset(fdt, path);
+#endif
+ if (nodeoff < 0) {
+ log_info("[fdt_fixup_ethernet] Node path '%s' not found, skipping\n", path);
+ total_skipped++;
+ continue;
+ }
+ const struct fdt_property *status_prop = fdt_get_property(fdt, nodeoff, "status", NULL);
+ if (status_prop && strcmp((const char *)status_prop->data, "okay")) {
+ log_info("[fdt_fixup_ethernet] Node '%s' status is '%s', skipping\n", path, (const char *)status_prop->data);
+ total_skipped++;
+ continue;
+ }
for (j = 0; j < 6; j++) {
- mac_addr[j] = tmp ?
- hextoul(tmp, &end) : 0;
+ mac_addr[j] = tmp ? hextoul(tmp, &end) : 0;
if (tmp)
tmp = (*end) ? end + 1 : end;
}
-
- do_fixup_by_path(fdt, path, "mac-address",
- &mac_addr, 6, 0);
- do_fixup_by_path(fdt, path, "local-mac-address",
- &mac_addr, 6, 1);
+ 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]);
+ do_fixup_by_path(fdt, path, "mac-address", &mac_addr, 6, 0);
+ do_fixup_by_path(fdt, path, "local-mac-address", &mac_addr, 6, 1);
+ total_patched++;
}
}
+ log_info("[fdt_fixup_ethernet] SUMMARY: aliases found=%d, attempted=%d, skipped=%d, patched=%d\n", total_aliases, total_attempted, total_skipped, total_patched);
}
int fdt_record_loadable(void *blob, u32 index, const char *name,
diff --git a/boot/image-fdt.c b/boot/image-fdt.c
index 111111111111..222222222222 100644
--- a/boot/image-fdt.c
+++ b/boot/image-fdt.c
@@ -1,3 +1,4 @@
+#warning "Building image-fdt.c: fdt fixup call chain instrumented for MAC debugging."
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (c) 2013, Google Inc.
@@ -586,11 +587,25 @@ __weak int ft_verify_fdt(void *fdt)
__weak int arch_fixup_fdt(void *blob)
{
+ log_info("[arch_fixup_fdt] called (weak stub)\n");
+ return 0;
+}
+
+__weak int ft_board_setup(void *blob, struct bd_info *bd)
+{
+ log_info("[ft_board_setup] called (weak stub)\n");
+ return 0;
+}
+
+__weak int ft_system_setup(void *blob, struct bd_info *bd)
+{
+ log_info("[ft_system_setup] called (weak stub)\n");
return 0;
}
int image_setup_libfdt(struct bootm_headers *images, void *blob, bool lmb)
{
+ log_info("[image_setup_libfdt] called\n");
ulong *initrd_start = &images->initrd_start;
ulong *initrd_end = &images->initrd_end;
bool skip_board_fixup = false;
@@ -638,6 +653,7 @@ int image_setup_libfdt(struct bootm_headers *images, void *blob, bool lmb)
strlen(images->fit_uname_cfg) + 1, 1);
/* Update ethernet nodes */
+ log_info("[image_setup_libfdt] calling fdt_fixup_ethernet\n");
fdt_fixup_ethernet(blob);
#if IS_ENABLED(CONFIG_CMD_PSTORE)
/* Append PStore configuration */
@@ -651,6 +667,7 @@ int image_setup_libfdt(struct bootm_headers *images, void *blob, bool lmb)
}
if (IS_ENABLED(CONFIG_OF_BOARD_SETUP) && !skip_board_fixup) {
+ log_info("[image_setup_libfdt] calling ft_board_setup\n");
fdt_ret = ft_board_setup(blob, gd->bd);
if (fdt_ret) {
printf("ERROR: board-specific fdt fixup failed: %s\n",
@@ -659,6 +676,7 @@ int image_setup_libfdt(struct bootm_headers *images, void *blob, bool lmb)
}
}
if (IS_ENABLED(CONFIG_OF_SYSTEM_SETUP)) {
+ log_info("[image_setup_libfdt] calling ft_system_setup\n");
fdt_ret = ft_system_setup(blob, gd->bd);
if (fdt_ret) {
printf("ERROR: system-specific fdt fixup failed: %s\n",
--
Armbian