[PATCH] cmd: bdinfo: Fix showing correct IP address based on current device

Michal Simek michal.simek at amd.com
Tue Jul 29 09:12:54 CEST 2025


Use the same logic as is used for MAC address where bdi shows mac address
for current device where index (idx) is used to point to correct IP address
which is read and show.

Signed-off-by: Michal Simek <michal.simek at amd.com>
---

 cmd/bdinfo.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c
index ae9e1923eacf..20c8c97f0cd1 100644
--- a/cmd/bdinfo.c
+++ b/cmd/bdinfo.c
@@ -46,6 +46,7 @@ void bdinfo_print_num_ll(const char *name, unsigned long long value)
 static void print_eth(void)
 {
 	const int idx = eth_get_dev_index();
+	char ipstr[] = "ipaddr\0\0";
 	uchar enetaddr[6];
 	char name[10];
 	int ret;
@@ -62,7 +63,11 @@ static void print_eth(void)
 		printf("%-12s= (not set)\n", name);
 	else
 		printf("%-12s= %pM\n", name, enetaddr);
-	printf("IP addr     = %s\n", env_get("ipaddr"));
+
+	if (idx > 0)
+		sprintf(ipstr, "ipaddr%d", idx);
+
+	printf("IP addr     = %s\n", env_get(ipstr));
 }
 
 void bdinfo_print_mhz(const char *name, unsigned long hz)
-- 
2.43.0

base-commit: 6f13cf94e46d7e0543bb44ed5528846cb966876a
branch: mbv-upstream-qemu


More information about the U-Boot mailing list