summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorTom Rini <[email protected]>2025-08-25 13:28:49 -0600
committerTom Rini <[email protected]>2025-08-25 13:28:49 -0600
commitfceb37d802b65beb4713f17e9167e7ecc4dbbe67 (patch)
treeec0390afd09a92d03b571927ad675a7e18f59311 /cmd
parent91595c96a53360dce696c2da694b1983c91d64f6 (diff)
parentdca578a9c9decb85271665de8086b8f41731d388 (diff)
Merge tag 'v2025.10-rc3' into next
Prepare v2025.10-rc3
Diffstat (limited to 'cmd')
-rw-r--r--cmd/Kconfig2
-rw-r--r--cmd/lwip/dns.c108
-rw-r--r--cmd/lwip/ping.c1
-rw-r--r--cmd/lwip/sntp.c1
-rw-r--r--cmd/mtd.c15
-rw-r--r--cmd/nand.c56
6 files changed, 44 insertions, 139 deletions
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 1a7dba2a27d..29de857ba7c 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -2117,7 +2117,7 @@ config CMD_DHCP
config CMD_DNS
bool "dns"
- select PROT_DNS_LWIP if NET_LWIP
+ select DNS
help
Lookup the IP of a hostname
diff --git a/cmd/lwip/dns.c b/cmd/lwip/dns.c
index b5fccc7433e..3eb698b3f82 100644
--- a/cmd/lwip/dns.c
+++ b/cmd/lwip/dns.c
@@ -2,115 +2,7 @@
/* Copyright (C) 2024 Linaro Ltd. */
#include <command.h>
-#include <console.h>
-#include <env.h>
-#include <lwip/dns.h>
-#include <lwip/timeouts.h>
#include <net.h>
-#include <time.h>
U_BOOT_CMD(dns, 3, 1, do_dns, "lookup the IP of a hostname",
"hostname [envvar]");
-
-#define DNS_RESEND_MS 1000
-#define DNS_TIMEOUT_MS 10000
-
-struct dns_cb_arg {
- ip_addr_t host_ipaddr;
- const char *var;
- bool done;
-};
-
-static void do_dns_tmr(void *arg)
-{
- dns_tmr();
-}
-
-static void dns_cb(const char *name, const ip_addr_t *ipaddr, void *arg)
-{
- struct dns_cb_arg *dns_cb_arg = arg;
- char *ipstr = ip4addr_ntoa(ipaddr);
-
- dns_cb_arg->done = true;
-
- if (!ipaddr) {
- printf("DNS: host not found\n");
- dns_cb_arg->host_ipaddr.addr = 0;
- return;
- }
-
- dns_cb_arg->host_ipaddr.addr = ipaddr->addr;
-
- if (dns_cb_arg->var)
- env_set(dns_cb_arg->var, ipstr);
-}
-
-static int dns_loop(struct udevice *udev, const char *name, const char *var)
-{
- struct dns_cb_arg dns_cb_arg = { };
- struct netif *netif;
- ip_addr_t ipaddr;
- ulong start;
- int ret;
-
- dns_cb_arg.var = var;
-
- netif = net_lwip_new_netif(udev);
- if (!netif)
- return CMD_RET_FAILURE;
-
- if (net_lwip_dns_init()) {
- net_lwip_remove_netif(netif);
- return CMD_RET_FAILURE;
- }
-
- dns_cb_arg.done = false;
-
- ret = dns_gethostbyname(name, &ipaddr, dns_cb, &dns_cb_arg);
-
- if (ret == ERR_OK) {
- dns_cb(name, &ipaddr, &dns_cb_arg);
- } else if (ret == ERR_INPROGRESS) {
- start = get_timer(0);
- sys_timeout(DNS_RESEND_MS, do_dns_tmr, NULL);
- do {
- net_lwip_rx(udev, netif);
- if (dns_cb_arg.done)
- break;
- if (ctrlc()) {
- printf("\nAbort\n");
- break;
- }
- } while (get_timer(start) < DNS_TIMEOUT_MS);
- sys_untimeout(do_dns_tmr, NULL);
- }
-
- net_lwip_remove_netif(netif);
-
- if (dns_cb_arg.done && dns_cb_arg.host_ipaddr.addr != 0) {
- if (!var)
- printf("%s\n", ipaddr_ntoa(&ipaddr));
- return CMD_RET_SUCCESS;
- }
-
- return CMD_RET_FAILURE;
-}
-
-int do_dns(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
-{
- char *name;
- char *var = NULL;
-
- if (argc == 1 || argc > 3)
- return CMD_RET_USAGE;
-
- name = argv[1];
-
- if (argc == 3)
- var = argv[2];
-
- if (net_lwip_eth_start() < 0)
- return CMD_RET_FAILURE;
-
- return dns_loop(eth_get_dev(), name, var);
-}
diff --git a/cmd/lwip/ping.c b/cmd/lwip/ping.c
index 87f8e958e48..6d090fc530d 100644
--- a/cmd/lwip/ping.c
+++ b/cmd/lwip/ping.c
@@ -170,6 +170,7 @@ int do_ping(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
if (net_lwip_dns_resolve(argv[1], &addr))
return CMD_RET_USAGE;
+ net_try_count = 1;
restart:
if (net_lwip_eth_start() < 0 || ping_loop(eth_get_dev(), &addr) < 0) {
if (net_start_again() == 0)
diff --git a/cmd/lwip/sntp.c b/cmd/lwip/sntp.c
index ae02bb11040..608345c873b 100644
--- a/cmd/lwip/sntp.c
+++ b/cmd/lwip/sntp.c
@@ -79,7 +79,6 @@ static int sntp_loop(struct udevice *udev, ip_addr_t *srvip)
sys_timeout(SNTP_TIMEOUT, no_response, NULL);
while (sntp_state == NOT_DONE) {
net_lwip_rx(udev, netif);
- sys_check_timeouts();
if (ctrlc()) {
printf("\nAbort\n");
sntp_state = ABORTED;
diff --git a/cmd/mtd.c b/cmd/mtd.c
index c25997cfb24..2520b89eed2 100644
--- a/cmd/mtd.c
+++ b/cmd/mtd.c
@@ -17,6 +17,7 @@
#include <malloc.h>
#include <mapmem.h>
#include <mtd.h>
+#include <time.h>
#include <dm/devres.h>
#include <linux/err.h>
@@ -466,8 +467,9 @@ static int mtd_special_write_oob(struct mtd_info *mtd, u64 off,
static int do_mtd_io(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
- bool dump, read, raw, woob, write_empty_pages, has_pages = false;
+ bool dump, read, raw, woob, benchmark, write_empty_pages, has_pages = false;
u64 start_off, off, len, remaining, default_len;
+ unsigned long bench_start, bench_end;
struct mtd_oob_ops io_op = {};
uint user_addr = 0, npages;
const char *cmd = argv[0];
@@ -490,6 +492,7 @@ static int do_mtd_io(struct cmd_tbl *cmdtp, int flag, int argc,
read = dump || !strncmp(cmd, "read", 4);
raw = strstr(cmd, ".raw");
woob = strstr(cmd, ".oob");
+ benchmark = strstr(cmd, ".benchmark");
write_empty_pages = !has_pages || strstr(cmd, ".dontskipff");
argc -= 2;
@@ -559,6 +562,9 @@ static int do_mtd_io(struct cmd_tbl *cmdtp, int flag, int argc,
led_activity_blink();
+ if (benchmark)
+ bench_start = timer_get_us();
+
/* Loop over the pages to do the actual read/write */
while (remaining) {
/* Skip the block if it is bad */
@@ -586,6 +592,13 @@ static int do_mtd_io(struct cmd_tbl *cmdtp, int flag, int argc,
io_op.oobbuf += io_op.oobretlen;
}
+ if (benchmark && bench_start) {
+ bench_end = timer_get_us();
+ printf("%s speed: %lukiB/s\n",
+ read ? "Read" : "Write",
+ ((io_op.len * 1000000) / (bench_end - bench_start)) / 1024);
+ }
+
led_activity_off();
if (!ret && dump)
diff --git a/cmd/nand.c b/cmd/nand.c
index 2f785deeb7f..b5678b0a008 100644
--- a/cmd/nand.c
+++ b/cmd/nand.c
@@ -37,6 +37,7 @@
#include <asm/byteorder.h>
#include <jffs2/jffs2.h>
#include <nand.h>
+#include <display_options.h>
#include "legacy-mtd-utils.h"
@@ -159,7 +160,7 @@ free_memory:
}
static int nand_dump(struct mtd_info *mtd, ulong off, int only_oob,
- int repeat)
+ int ecc, int repeat)
{
int i;
u_char *datbuf, *oobbuf, *p;
@@ -191,39 +192,30 @@ static int nand_dump(struct mtd_info *mtd, ulong off, int only_oob,
ops.oobbuf = oobbuf;
ops.len = mtd->writesize;
ops.ooblen = mtd->oobsize;
- ops.mode = MTD_OPS_RAW;
+ if (ecc)
+ ops.mode = MTD_OPS_PLACE_OOB;
+ else
+ ops.mode = MTD_OPS_RAW;
i = mtd_read_oob(mtd, addr, &ops);
if (i < 0) {
- printf("Error (%d) reading page %08lx\n", i, off);
+ printf("Error reading page at offset %08lx, %d %s\n",
+ off, i, i == -EUCLEAN ? "correctable" :
+ "uncorrectable, dumping raw data");
ret = 1;
- goto free_all;
}
- printf("Page %08lx dump:\n", off);
+ printf("\nPage at offset %08lx dump:\n", off);
if (!only_oob) {
- i = mtd->writesize >> 4;
+ i = mtd->writesize;
p = datbuf;
-
- while (i--) {
- printf("\t%02x %02x %02x %02x %02x %02x %02x %02x"
- " %02x %02x %02x %02x %02x %02x %02x %02x\n",
- p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7],
- p[8], p[9], p[10], p[11], p[12], p[13], p[14],
- p[15]);
- p += 16;
- }
+ print_buffer(off, p, 1, i, 16);
}
- puts("OOB:\n");
- i = mtd->oobsize >> 3;
+ puts("\nOOB:\n");
+ i = mtd->oobsize;
p = oobbuf;
- while (i--) {
- printf("\t%02x %02x %02x %02x %02x %02x %02x %02x\n",
- p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);
- p += 8;
- }
+ print_buffer(0, p, 1, i, 8);
-free_all:
free(oobbuf);
free_dat:
free(datbuf);
@@ -412,7 +404,7 @@ int do_nand_env_oob(struct cmd_tbl *cmdtp, int argc, char *const argv[])
}
ops.datbuf = NULL;
- ops.mode = MTD_OOB_AUTO;
+ ops.mode = MTD_OPS_AUTO_OOB;
ops.ooboffs = 0;
ops.ooblen = ENV_OFFSET_SIZE;
ops.oobbuf = (void *) oob_buf;
@@ -708,11 +700,19 @@ static int do_nand(struct cmd_tbl *cmdtp, int flag, int argc,
}
if (strncmp(cmd, "dump", 4) == 0) {
+ int only_oob, ecc;
+
if (argc < 3)
goto usage;
+ only_oob = !strcmp(&cmd[4], ".oob") || !strcmp(&cmd[4], ".ecc.oob") ||
+ !strcmp(&cmd[4], ".oob.ecc");
+
+ ecc = !strcmp(&cmd[4], ".ecc") || !strcmp(&cmd[4], ".ecc.oob") ||
+ !strcmp(&cmd[4], ".oob.ecc");
+
off = (int)hextoul(argv[2], NULL);
- ret = nand_dump(mtd, off, !strcmp(&cmd[4], ".oob"), repeat);
+ ret = nand_dump(mtd, off, only_oob, ecc, repeat);
return ret == 0 ? 1 : 0;
}
@@ -1026,8 +1026,8 @@ U_BOOT_LONGHELP(nand,
"nand write - addr off|partition size\n"
" read/write 'size' bytes starting at offset 'off'\n"
" to/from memory address 'addr', skipping bad blocks.\n"
- "nand read.raw - addr off|partition [count]\n"
- "nand write.raw[.noverify] - addr off|partition [count]\n"
+ "nand read.raw - addr off|partition [pages]\n"
+ "nand write.raw[.noverify] - addr off|partition [pages]\n"
" Use read.raw/write.raw to avoid ECC and access the flash as-is.\n"
#ifdef CONFIG_CMD_NAND_TRIMFFS
"nand write.trimffs - addr off|partition size\n"
@@ -1042,7 +1042,7 @@ U_BOOT_LONGHELP(nand,
"nand erase.part [clean] partition - erase entire mtd partition'\n"
"nand erase.chip [clean] - erase entire chip'\n"
"nand bad - show bad blocks\n"
- "nand dump[.oob] off - dump page\n"
+ "nand dump[.oob][.ecc] off - dump raw (default) or ecc corrected page at offset\n"
#ifdef CONFIG_CMD_NAND_WATCH
"nand watch <off> <size> - check an area for bitflips\n"
"nand watch.part <part> - check a partition for bitflips\n"