From e92b5d0ddfbe95b0d6bf5277f06d00b1acfa0b83 Mon Sep 17 00:00:00 2001 From: Mattijs Korpershoek Date: Fri, 22 Nov 2024 15:11:34 +0100 Subject: [PATCH 01/11] test: boot: Set DM|SCAN_FDT flags for bootmeth_{cros,android} We make fewer calls to dm_test_restore() since commit fbdac8155c89 ("test: Expand implementation of ut_list_has_dm_tests()") Because of this some valid test combinations are now broken: $ ./test/py/test.py --bd sandbox --build -k test_ut $ ./test/py/test.py --bd sandbox --build -k "bootflow_android or bootflow_cros" Shows: Expected ' 2 cros ready mmc 4 mmc5.bootdev.part_4 ', got ' 2 cros ready mmc 2 mmc5.bootdev.part_2 ' Here prep_mmc_bootdev() is called twice and it will bind bootmeth_cros twice. Since bootmeth_cros is bound twice, 'bootflow scan' will find 2x the expected bootflows. Before commit fbdac8155c89 ("test: Expand implementation of ut_list_has_dm_tests()") this did not happen because a cleanup was called each time. Add UTF_DM and UTF_SCAN_FDT flags to both tests to make sure that the bootmeths are unbound after the test finishes. Fixes: fbdac8155c89 ("test: Expand implementation of ut_list_has_dm_tests()") Signed-off-by: Mattijs Korpershoek --- test/boot/bootflow.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index 9397328609..da713d8ed7 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -1197,7 +1197,7 @@ static int bootflow_cros(struct unit_test_state *uts) return 0; } -BOOTSTD_TEST(bootflow_cros, UTF_CONSOLE); +BOOTSTD_TEST(bootflow_cros, UTF_CONSOLE | UTF_DM | UTF_SCAN_FDT); /* Test Android bootmeth */ static int bootflow_android(struct unit_test_state *uts) @@ -1220,7 +1220,7 @@ static int bootflow_android(struct unit_test_state *uts) return 0; } -BOOTSTD_TEST(bootflow_android, UTF_CONSOLE); +BOOTSTD_TEST(bootflow_android, UTF_CONSOLE | UTF_DM | UTF_SCAN_FDT); /* Test EFI bootmeth */ static int bootflow_efi(struct unit_test_state *uts) From 8c95d84b39fc0886a4417c5ddefc2ea05217c0ac Mon Sep 17 00:00:00 2001 From: Jerome Forissier Date: Fri, 22 Nov 2024 13:35:29 +0100 Subject: [PATCH 02/11] net: lwip: fix dhcp_loop() The local variables ipstr, maskstr and gwstr in static function dhcp_loop() cannot be pointers to read-only data, since they may be written to in case the device index is > 0. Therefore make them char arrays allocated on the stack. Reported-by: Ilias Apalodimas Signed-off-by: Jerome Forissier Reviewed-by: Ilias Apalodimas --- net/lwip/dhcp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/lwip/dhcp.c b/net/lwip/dhcp.c index 23b5622692..bfc72ca6c5 100644 --- a/net/lwip/dhcp.c +++ b/net/lwip/dhcp.c @@ -27,9 +27,9 @@ static void call_lwip_dhcp_fine_tmr(void *ctx) static int dhcp_loop(struct udevice *udev) { - char *ipstr = "ipaddr\0\0"; - char *maskstr = "netmask\0\0"; - char *gwstr = "gatewayip\0\0"; + char ipstr[] = "ipaddr\0\0"; + char maskstr[] = "netmask\0\0"; + char gwstr[] = "gatewayip\0\0"; unsigned long start; struct netif *netif; struct dhcp *dhcp; From c16fcbc14a7aca15ea6dd5d283506c08920486e0 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Tue, 19 Nov 2024 08:05:26 -0600 Subject: [PATCH 03/11] Revert "test: Update time tests to use unit-test asserts" While at the base level, this conversion looks equivalent, we now see both of these tests failing (due to exceeding their allowed margin for being too slow) in Azure with a very high frequency. This reverts commit 88db4fc5fec20429881896740df61d402b4b1f66. Signed-off-by: Tom Rini Tested-by: Andrew Goodbody Reviewed-by: Simon Glass --- test/lib/time.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/test/lib/time.c b/test/lib/time.c index b99e738c50..2095bef758 100644 --- a/test/lib/time.c +++ b/test/lib/time.c @@ -22,7 +22,11 @@ static int test_get_timer(struct unit_test_state *uts) next = get_timer(0); } while (start == next); - ut_asserteq(start + 1, next); + if (start + 1 != next) { + printf("%s: iter=%d, start=%lu, next=%lu, expected a difference of 1\n", + __func__, iter, start, next); + return -EINVAL; + } start++; } @@ -31,7 +35,11 @@ static int test_get_timer(struct unit_test_state *uts) * an extra millisecond may have passed. */ diff = get_timer(base); - ut_assert(diff == iter || diff == iter + 1); + if (diff != iter && diff != iter + 1) { + printf("%s: expected get_timer(base) to match elapsed time: diff=%lu, expected=%d\n", + __func__, diff, iter); + return -EINVAL; + } return 0; } @@ -49,8 +57,11 @@ static int test_timer_get_us(struct unit_test_state *uts) next = timer_get_us(); if (next != prev) { delta = next - prev; - ut_assert(delta >= 0); - if (delta) { + if (delta < 0) { + printf("%s: timer_get_us() went backwards from %lu to %lu\n", + __func__, prev, next); + return -EINVAL; + } else if (delta != 0) { if (delta < min) min = delta; prev = next; @@ -59,7 +70,11 @@ static int test_timer_get_us(struct unit_test_state *uts) } } - ut_asserteq(1, min); + if (min != 1) { + printf("%s: Minimum microsecond delta should be 1 but is %lu\n", + __func__, min); + return -EINVAL; + } return 0; } @@ -80,7 +95,8 @@ static int test_time_comparison(struct unit_test_state *uts) error = delta_us - 1000000; printf("%s: Microsecond time for 1 second: %lu, error = %ld\n", __func__, delta_us, error); - ut_assert(abs(error) <= 1000); + if (abs(error) > 1000) + return -EINVAL; return 0; } @@ -99,7 +115,8 @@ static int test_udelay(struct unit_test_state *uts) error = delta - 1000; printf("%s: Delay time for 1000 udelay(1000): %lu ms, error = %ld\n", __func__, delta, error); - ut_assert(abs(error) <= 100); + if (abs(error) > 100) + return -EINVAL; return 0; } From afa99e65b9b4a3ba47c8ef963083e7c0cae62367 Mon Sep 17 00:00:00 2001 From: Ben Horgan Date: Tue, 19 Nov 2024 17:25:58 +0000 Subject: [PATCH 04/11] board: armltd: Make myself maintainer for total compute The previous maintainer is no longer involved in total compute. Signed-off-by: Ben Horgan Reviewed-by: Peter Robinson Reviewed-by: Leo Yan --- board/armltd/total_compute/MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/board/armltd/total_compute/MAINTAINERS b/board/armltd/total_compute/MAINTAINERS index 3dc1cd188a..92486f4193 100644 --- a/board/armltd/total_compute/MAINTAINERS +++ b/board/armltd/total_compute/MAINTAINERS @@ -1,5 +1,5 @@ TOTAL_COMPUTE BOARD -M: Usama Arif +M: Ben Horgan S: Maintained F: board/armltd/total_compute/ F: include/configs/total_compute.h From dfe5f16a33453b742a66cabc8ea9a52a33279810 Mon Sep 17 00:00:00 2001 From: Udit Kumar Date: Tue, 19 Nov 2024 15:37:20 +0530 Subject: [PATCH 05/11] arm64: dts: ti: k3-j7200: Fix OSPI boot OSPI boot is broken due to missing bootph property in pin mux of OSPI. So add bootph to fix OSPI boot. Signed-off-by: Udit Kumar --- dts/upstream/src/arm64/ti/k3-j7200-som-p0.dtsi | 1 + 1 file changed, 1 insertion(+) diff --git a/dts/upstream/src/arm64/ti/k3-j7200-som-p0.dtsi b/dts/upstream/src/arm64/ti/k3-j7200-som-p0.dtsi index 21fe194a57..014cf1805f 100644 --- a/dts/upstream/src/arm64/ti/k3-j7200-som-p0.dtsi +++ b/dts/upstream/src/arm64/ti/k3-j7200-som-p0.dtsi @@ -124,6 +124,7 @@ }; mcu_fss0_ospi0_pins_default: mcu-fss0-ospi0-default-pins { + bootph-all; pinctrl-single,pins = < J721E_WKUP_IOPAD(0x0000, PIN_OUTPUT, 0) /* MCU_OSPI0_CLK */ J721E_WKUP_IOPAD(0x002c, PIN_OUTPUT, 0) /* MCU_OSPI0_CSn0 */ From 7d80e7368e1012355695e1fb580e5b20c8de03b9 Mon Sep 17 00:00:00 2001 From: Jerome Forissier Date: Mon, 18 Nov 2024 15:31:25 +0100 Subject: [PATCH 06/11] net: lwip: fix get_udev_ipv4_info() The local variables ipstr, maskstr and gwstr in static function get_udev_ipv4_info() cannot be pointers to read-only data, since they may be written to in case the device index is > 0. Therefore make them char arrays allocated on the stack. Reported-by: Ilias Apalodimas Reported-by: Adriano Cordova Link: https://lists.denx.de/pipermail/u-boot/2024-November/572066.html Signed-off-by: Jerome Forissier Reviewed-by: Ilias Apalodimas --- net/lwip/net-lwip.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/lwip/net-lwip.c b/net/lwip/net-lwip.c index 470217781a..b863047f59 100644 --- a/net/lwip/net-lwip.c +++ b/net/lwip/net-lwip.c @@ -91,9 +91,9 @@ struct netif *net_lwip_get_netif(void) static int get_udev_ipv4_info(struct udevice *dev, ip4_addr_t *ip, ip4_addr_t *mask, ip4_addr_t *gw) { - char *ipstr = "ipaddr\0\0"; - char *maskstr = "netmask\0\0"; - char *gwstr = "gatewayip\0\0"; + char ipstr[] = "ipaddr\0\0"; + char maskstr[] = "netmask\0\0"; + char gwstr[] = "gatewayip\0\0"; int idx = dev_seq(dev); char *env; From 572b5b0d5a04a255dea7b83d4edfdd71b886f229 Mon Sep 17 00:00:00 2001 From: Jerome Forissier Date: Thu, 14 Nov 2024 15:20:40 +0100 Subject: [PATCH 07/11] net: lwip: wget: update help string The lwIP version of wget also supports the legacy syntax. Document it in the help string. Signed-off-by: Jerome Forissier Reviewed-by: Ilias Apalodimas --- cmd/net-lwip.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/net-lwip.c b/cmd/net-lwip.c index 6f5fc74303..0fd446ecb2 100644 --- a/cmd/net-lwip.c +++ b/cmd/net-lwip.c @@ -27,6 +27,9 @@ U_BOOT_CMD(dns, 3, 1, do_dns, "lookup the IP of a hostname", #endif #if defined(CONFIG_CMD_WGET) -U_BOOT_CMD(wget, 3, 1, do_wget, "boot image via network using HTTP protocol", - "[loadAddress] URL"); +U_BOOT_CMD(wget, 3, 1, do_wget, + "boot image via network using HTTP/HTTPS protocol", + "[loadAddress] url\n" + "wget [loadAddress] [host:]path" +); #endif From 2cde2f4a0073ac1e4a528a1fab40e3d6c1f4bf29 Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Thu, 14 Nov 2024 16:29:15 +0200 Subject: [PATCH 08/11] net: lwip: provide entropy to MBed TLS in one go We currently provide entropy to mbedTLS using 8b chunks. Take into account the 'len' parameter passed by MBed TLS to the entropy gathering function instead. Note that the current code works because len is always 128 (defined at compile time), therefore mbedtls_hardware_poll() is called repeatedly and the buffer is filled correctly. But passing 'len' to dm_rng_read() is both better and simpler. Reviewed-by: Jerome Forissier Suggested-by: Simon Glass Signed-off-by: Ilias Apalodimas Reviewed-by: Simon Glass --- net/lwip/wget.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/net/lwip/wget.c b/net/lwip/wget.c index e85d57bc1d..062aa7c44f 100644 --- a/net/lwip/wget.c +++ b/net/lwip/wget.c @@ -42,7 +42,6 @@ int mbedtls_hardware_poll(void *data, unsigned char *output, size_t len, size_t *olen) { struct udevice *dev; - u64 rng = 0; int ret; *olen = 0; @@ -52,12 +51,11 @@ int mbedtls_hardware_poll(void *data, unsigned char *output, size_t len, log_err("Failed to get an rng: %d\n", ret); return ret; } - ret = dm_rng_read(dev, &rng, sizeof(rng)); + ret = dm_rng_read(dev, output, len); if (ret) return ret; - memcpy(output, &rng, len); - *olen = sizeof(rng); + *olen = len; return 0; } From 13e13f58671305ac20a889d7271d85cb7e27af78 Mon Sep 17 00:00:00 2001 From: Jerome Forissier Date: Thu, 14 Nov 2024 18:20:07 +0100 Subject: [PATCH 09/11] net: lwip: dhcp: support arguments for TFTP file download The dhcp command is supposed to have the following syntax as per "help dhcp": dhcp [loadAddress] [[hostIPaddr:]bootfilename] In other words, any arguments should be passed to an implicit tftpboot command after the DHCP exchange has occurred. Add the missing code to the lwIP version of do_dhcp(). Signed-off-by: Jerome Forissier --- net/lwip/dhcp.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/net/lwip/dhcp.c b/net/lwip/dhcp.c index bfc72ca6c5..9b882cf5b8 100644 --- a/net/lwip/dhcp.c +++ b/net/lwip/dhcp.c @@ -111,9 +111,21 @@ static int dhcp_loop(struct udevice *udev) int do_dhcp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { + int ret; + eth_set_current(); - return dhcp_loop(eth_get_dev()); + ret = dhcp_loop(eth_get_dev()); + if (ret) + return ret; + + if (argc > 1) { + struct cmd_tbl cmdtp = {}; + + return do_tftpb(&cmdtp, 0, argc, argv); + } + + return CMD_RET_SUCCESS; } int dhcp_run(ulong addr, const char *fname, bool autoload) From 544418999882487c25cc9529d0698f75d824bec0 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Wed, 13 Nov 2024 22:15:12 +0100 Subject: [PATCH 10/11] test: unit test for hextoull() Provide a unit test for the hextoull() function. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- test/lib/str.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/lib/str.c b/test/lib/str.c index 3cc9dfea6a..e62045318c 100644 --- a/test/lib/str.c +++ b/test/lib/str.c @@ -18,6 +18,8 @@ static const char str4[] = "1234567890123 I lost closer friends"; static const char str5[] = "0x9876543210the last time I was deloused"; static const char str6[] = "0778octal is seldom used"; static const char str7[] = "707it is a piece of computing history"; +static const char str8[] = "0x887e2561352d80fa"; +static const char str9[] = "614FF7EAA63009DA"; static int str_upper(struct unit_test_state *uts) { @@ -186,6 +188,22 @@ static int str_hextoul(struct unit_test_state *uts) } LIB_TEST(str_hextoul, 0); +static int str_hextoull(struct unit_test_state *uts) +{ + char *endp; + + /* Just a simple test, since we know this uses simple_strtoull() */ + ut_asserteq_64(0x887e2561352d80faULL, hextoull(str8, &endp)); + ut_asserteq_64(0x12, endp - str8); + ut_asserteq_64(0x614ff7eaa63009daULL, hextoull(str9, &endp)); + ut_asserteq_64(0x10, endp - str9); + ut_asserteq_64(0x887e2561352d80faULL, hextoull(str8, NULL)); + ut_asserteq_64(0x614ff7eaa63009daULL, hextoull(str9, NULL)); + + return 0; +} +LIB_TEST(str_hextoull, 0); + static int str_dectoul(struct unit_test_state *uts) { char *endp; From 0e3cd1313f031acd7e2e29b5742e625f842b52fa Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Mon, 11 Nov 2024 10:50:35 +0100 Subject: [PATCH 11/11] cmd: improve description of the cdp command Users might not know what 'CDP' refers to. Provide basic information. Signed-off-by: Heinrich Schuchardt --- cmd/Kconfig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/Kconfig b/cmd/Kconfig index b2d0348fe3..1d7ddb4ed3 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -2016,7 +2016,9 @@ config CMD_PING6 config CMD_CDP bool "cdp" help - Perform CDP network configuration + The cdp command is used to announce the U-Boot device in the network + and to retrieve configuration data including the VLAN id using the + proprietary Cisco Discovery Protocol (CDP). config CMD_SNTP bool "sntp"