From 78398652723b6fe743751ffb19d8256b7e3e0a4e Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 21 Oct 2021 21:08:52 -0600 Subject: bootm: Tidy up use of autostart env var This has different semantics in different places. Go with the bootm method and put it in a common function so that the behaviour is consistent in U-Boot. Update the docs. To be clear, this changes the way that 'bootelf' and standalone boot work. Before, if autostart was set to "fred" or "YES", for example, they would consider that a "yes". This may change behaviour for some boards, but the only in-tree boards which mention autostart use "no" to disable it, which will still work. Signed-off-by: Simon Glass Suggested-by: Wolfgang Denk --- cmd/bootm.c | 4 +--- cmd/elf.c | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) (limited to 'cmd') diff --git a/cmd/bootm.c b/cmd/bootm.c index 92468d09a1f..b82a872a86c 100644 --- a/cmd/bootm.c +++ b/cmd/bootm.c @@ -140,9 +140,7 @@ int do_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) int bootm_maybe_autostart(struct cmd_tbl *cmdtp, const char *cmd) { - const char *ep = env_get("autostart"); - - if (ep && !strcmp(ep, "yes")) { + if (env_get_autostart()) { char *local_args[2]; local_args[0] = (char *)cmd; local_args[1] = NULL; diff --git a/cmd/elf.c b/cmd/elf.c index d75b21461c2..2b33c50bd02 100644 --- a/cmd/elf.c +++ b/cmd/elf.c @@ -41,7 +41,6 @@ int do_bootelf(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) unsigned long addr; /* Address of the ELF image */ unsigned long rc; /* Return value from user code */ char *sload = NULL; - const char *ep = env_get("autostart"); int rcode = 0; /* Consume 'bootelf' */ @@ -69,7 +68,7 @@ int do_bootelf(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) else addr = load_elf_image_shdr(addr); - if (ep && !strcmp(ep, "no")) + if (!env_get_autostart()) return rcode; printf("## Starting application at 0x%08lx ...\n", addr); -- cgit v1.2.3 From ad4e0100541eb8a19de00f56bda10be576a7cde6 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 19 Sep 2021 15:49:33 -0600 Subject: sf: Use const for the stage name This is not updated at runtime so should be marked const. Update the code accordingly. Signed-off-by: Simon Glass Reviewed-by: Jagan Teki Reviewed-by: Heinrich Schuchardt --- cmd/sf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/sf.c b/cmd/sf.c index eac27ed2d77..15361a4bddf 100644 --- a/cmd/sf.c +++ b/cmd/sf.c @@ -394,7 +394,7 @@ enum { STAGE_COUNT, }; -static char *stage_name[STAGE_COUNT] = { +static const char *stage_name[STAGE_COUNT] = { "erase", "check", "write", -- cgit v1.2.3 From 3512e1570d4376a4581575546cee7b5d3af54370 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 19 Sep 2021 15:49:34 -0600 Subject: sf: Tidy up code to avoid #ifdef Update this code to use IS_ENABLED() instead. Signed-off-by: Simon Glass Reviewed-by: Pratyush Yadav Reviewed-by: Jagan Teki --- cmd/sf.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'cmd') diff --git a/cmd/sf.c b/cmd/sf.c index 15361a4bddf..72246d912fe 100644 --- a/cmd/sf.c +++ b/cmd/sf.c @@ -384,7 +384,6 @@ static int do_spi_protect(int argc, char *const argv[]) return ret == 0 ? 0 : 1; } -#ifdef CONFIG_CMD_SF_TEST enum { STAGE_ERASE, STAGE_CHECK, @@ -548,7 +547,6 @@ static int do_spi_flash_test(int argc, char *const argv[]) return 0; } -#endif /* CONFIG_CMD_SF_TEST */ static int do_spi_flash(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) @@ -582,10 +580,8 @@ static int do_spi_flash(struct cmd_tbl *cmdtp, int flag, int argc, ret = do_spi_flash_erase(argc, argv); else if (strcmp(cmd, "protect") == 0) ret = do_spi_protect(argc, argv); -#ifdef CONFIG_CMD_SF_TEST - else if (!strcmp(cmd, "test")) + else if (IS_ENABLED(CONFIG_CMD_SF_TEST) && !strcmp(cmd, "test")) ret = do_spi_flash_test(argc, argv); -#endif else ret = -1; @@ -597,16 +593,8 @@ usage: return CMD_RET_USAGE; } -#ifdef CONFIG_CMD_SF_TEST -#define SF_TEST_HELP "\nsf test offset len " \ - "- run a very basic destructive test" -#else -#define SF_TEST_HELP -#endif - -U_BOOT_CMD( - sf, 5, 1, do_spi_flash, - "SPI flash sub-system", +#ifdef CONFIG_SYS_LONGHELP +static const char long_help[] = "probe [[bus:]cs] [hz] [mode] - init flash device on given SPI bus\n" " and chip select\n" "sf read addr offset|partition len - read `len' bytes starting at\n" @@ -622,6 +610,14 @@ U_BOOT_CMD( " at `addr' to flash at `offset'\n" " or to start of mtd `partition'\n" "sf protect lock/unlock sector len - protect/unprotect 'len' bytes starting\n" - " at address 'sector'\n" - SF_TEST_HELP + " at address 'sector'" +#ifdef CONFIG_CMD_SF_TEST + "\nsf test offset len - run a very basic destructive test" +#endif +#endif /* CONFIG_SYS_LONGHELP */ + ; + +U_BOOT_CMD( + sf, 5, 1, do_spi_flash, + "SPI flash sub-system", long_help ); -- cgit v1.2.3 From 362a79f3e8582138545d408a56d4accf35e894b3 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 23 Oct 2021 17:26:01 -0600 Subject: mbr: Correct verification check At present this command considers the partitions to be identical if the start and size are smaller than expected. It should check that they are the same. Fix this and tidy up the code style a little. Signed-off-by: Simon Glass Acked-by: Ilias Apalodimas --- cmd/mbr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'cmd') diff --git a/cmd/mbr.c b/cmd/mbr.c index e7e22980969..c269833eb82 100644 --- a/cmd/mbr.c +++ b/cmd/mbr.c @@ -244,12 +244,12 @@ static int do_verify_mbr(struct blk_desc *dev, const char *str) for (i = 0; i < count; i++) { struct disk_partition p; - if (part_get_info(dev, i+1, &p)) + if (part_get_info(dev, i + 1, &p)) goto fail; - if ((partitions[i].size && p.size < partitions[i].size) || - (partitions[i].start && p.start < partitions[i].start) || - (p.sys_ind != partitions[i].sys_ind)) + if ((partitions[i].size && p.size != partitions[i].size) || + (partitions[i].start && p.start != partitions[i].start) || + p.sys_ind != partitions[i].sys_ind) goto fail; } ret = 0; -- cgit v1.2.3 From 89050244c40e79fc24b24ee84e4e668a6dfc336d Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 24 Nov 2021 09:26:39 -0700 Subject: trace: sandbox: Use only the Kconfig options At present there are Kconfig options for tracing, but sandbox uses plain #defines to set them. Correct this and make the tracing command default to enabled so that this is not needed. Signed-off-by: Simon Glass --- cmd/Kconfig | 2 ++ 1 file changed, 2 insertions(+) (limited to 'cmd') diff --git a/cmd/Kconfig b/cmd/Kconfig index 5b30b13e438..fd8f0227c89 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -2350,6 +2350,8 @@ config CMD_LOG config CMD_TRACE bool "trace - Support tracing of function calls and timing" + depends on TRACE + default y help Enables a command to control using of function tracing within U-Boot. This allows recording of call traces including timing -- cgit v1.2.3 From 32c8566f138d4685c60c83fa89cf4bb0b7b00e79 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 24 Nov 2021 09:26:40 -0700 Subject: sandbox: Drop CONFIG_HOST_MAX_DEVICES This can go in the related header file. Drop the CONFIG option. Signed-off-by: Simon Glass Reviewed-by: Heinrich Schuchardt --- cmd/host.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/host.c b/cmd/host.c index 2e998abbcdc..f0d989ac0f9 100644 --- a/cmd/host.c +++ b/cmd/host.c @@ -78,7 +78,7 @@ static int do_host_info(struct cmd_tbl *cmdtp, int flag, int argc, if (argc < 1 || argc > 2) return CMD_RET_USAGE; int min_dev = 0; - int max_dev = CONFIG_HOST_MAX_DEVICES - 1; + int max_dev = SANDBOX_HOST_MAX_DEVICES - 1; if (argc >= 2) { char *ep; char *dev_str = argv[1]; -- cgit v1.2.3 From ff66e7bb73233a4decfcdb66b7a858399dbccf50 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 16 Dec 2021 20:59:34 -0700 Subject: fdt: Report the devicetree source It can be confusing to figure out where the devicetree came from. It seems important enough to warrant a message during boot. Add information about the number of devices and uclasses too since it is helpful to have some idea what is going on with driver model. Report the devicetree source in bdinfo too. This looks something like this, with > marking the new line. U-Boot 2021.10-00190 (Oct 30 2021 - 09:01:29 -0600) DRAM: 128 MiB > Core: 42 devices, 11 uclasses, devicetree: passage Flash: 64 MiB Signed-off-by: Simon Glass --- cmd/bdinfo.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'cmd') diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c index bf63cc6d649..c56b3f4f6ec 100644 --- a/cmd/bdinfo.c +++ b/cmd/bdinfo.c @@ -128,6 +128,8 @@ int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) lmb_init_and_reserve(&lmb, gd->bd, (void *)gd->fdt_blob); lmb_dump_all_force(&lmb); + if (IS_ENABLED(CONFIG_OF_REAL)) + printf("devicetree = %s\n", fdtdec_get_srcname()); } arch_print_bdinfo(); -- cgit v1.2.3 From 6cdc8be7c5f2a79db8f0791a76c83d46c9aa7591 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 19 Nov 2021 13:23:52 -0700 Subject: sandbox: Enable support for the gzip command This does not work with sandbox at present. Fix it up to use map_sysmem() to convert an address to a pointer. Signed-off-by: Simon Glass --- cmd/unzip.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/unzip.c b/cmd/unzip.c index 3d1f5f3ac10..bc6cee06043 100644 --- a/cmd/unzip.c +++ b/cmd/unzip.c @@ -8,6 +8,7 @@ #include #include #include +#include #include static int do_unzip(struct cmd_tbl *cmdtp, int flag, int argc, @@ -28,7 +29,8 @@ static int do_unzip(struct cmd_tbl *cmdtp, int flag, int argc, return CMD_RET_USAGE; } - if (gunzip((void *) dst, dst_len, (void *) src, &src_len) != 0) + if (gunzip(map_sysmem(dst, dst_len), dst_len, map_sysmem(src, 0), + &src_len) != 0) return 1; printf("Uncompressed size: %lu = 0x%lX\n", src_len, src_len); -- cgit v1.2.3 From 7e6a6fd82140dd4136b5a98e459b384f910ccd74 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Sat, 11 Dec 2021 14:55:48 -0500 Subject: Convert CONFIG_ENV_SPI_BUS et al to Kconfig This converts the following to Kconfig: CONFIG_ENV_SPI_BUS CONFIG_ENV_SPI_CS CONFIG_ENV_SPI_MAX_HZ CONFIG_ENV_SPI_MODE As part of this, we use Kconfig to provide the defaults now that were done in include/spi_flash.h. We also in some cases change from using CONFIG_ENV_SPI_FOO to CONFIG_SF_DEFAULT_FOO as those were the values in use anyhow as ENV was not enabled. Signed-off-by: Tom Rini --- cmd/mvebu/bubt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cmd') diff --git a/cmd/mvebu/bubt.c b/cmd/mvebu/bubt.c index a7f3ff3c6fc..1362c03bcee 100644 --- a/cmd/mvebu/bubt.c +++ b/cmd/mvebu/bubt.c @@ -271,8 +271,8 @@ static int spi_burn_image(size_t image_size) u32 erase_bytes; /* Probe the SPI bus to get the flash device */ - flash = spi_flash_probe(CONFIG_ENV_SPI_BUS, - CONFIG_ENV_SPI_CS, + flash = spi_flash_probe(CONFIG_SF_DEFAULT_BUS, + CONFIG_SF_DEFAULT_CS, CONFIG_SF_DEFAULT_SPEED, CONFIG_SF_DEFAULT_MODE); if (!flash) { -- cgit v1.2.3 From ff27af1244113a8cd27624430799d58e3ce5898b Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Sun, 12 Dec 2021 22:12:29 -0500 Subject: Convert CONFIG_SYS_MEMTEST_START et al to Kconfig This converts the following to Kconfig: CONFIG_SYS_MEMTEST_START CONFIG_SYS_MEMTEST_END This is removing unused defines and correcting the default value to be 0x0 as we are a hex symbol. Signed-off-by: Tom Rini --- cmd/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/Kconfig b/cmd/Kconfig index fd8f0227c89..7747ab50a04 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -741,7 +741,7 @@ endif config SYS_MEMTEST_START hex "default start address for mtest" - default 0 + default 0x0 help This is the default start address for mtest for simple read/write test. If no arguments are given to mtest, default address is used -- cgit v1.2.3 From 968c6210e6bc4c76edeeacc16f02aef2a14dd96f Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Fri, 17 Dec 2021 18:08:47 -0500 Subject: Convert CONFIG_JFFS2_DEV et al to Kconfig This converts the following to Kconfig: CONFIG_JFFS2_DEV CONFIG_JFFS2_LZO CONFIG_JFFS2_NAND CONFIG_JFFS2_PART_OFFSET CONFIG_JFFS2_PART_SIZE Signed-off-by: Tom Rini --- cmd/Kconfig | 21 +++++++++++++++++++++ cmd/jffs2.c | 12 ------------ 2 files changed, 21 insertions(+), 12 deletions(-) (limited to 'cmd') diff --git a/cmd/Kconfig b/cmd/Kconfig index 7747ab50a04..ef82f794b55 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -2219,6 +2219,27 @@ config CMD_JFFS2 provide the ability to load files, list directories and obtain filesystem information. +config JFFS2_DEV + string "Default device for JFFS2" + depends on CMD_JFFS2 + default "nor0" + help + The default device to use with the jffs2 command. + +config JFFS2_PART_OFFSET + hex "Default offset within flash to locate the JFFS2 image" + depends on CMD_JFFS2 + default 0x0 + help + The default offset within flash to locate the JFFS2 image. + +config JFFS2_PART_SIZE + hex "Default size of JFFS2 partition" + depends on CMD_JFFS2 + default 0xFFFFFFFF + help + The default size of the JFFS2 partition + config CMD_MTDPARTS bool "MTD partition support" depends on MTD diff --git a/cmd/jffs2.c b/cmd/jffs2.c index 63bd55263a2..6f15b57b6a1 100644 --- a/cmd/jffs2.c +++ b/cmd/jffs2.c @@ -360,11 +360,7 @@ int mtdparts_init(void) /* id */ id->mtd_id = "single part"; -#if defined(CONFIG_JFFS2_DEV) dev_name = CONFIG_JFFS2_DEV; -#else - dev_name = "nor0"; -#endif if ((mtd_id_parse(dev_name, NULL, &id->type, &id->num) != 0) || (mtd_device_validate(id->type, id->num, &size) != 0)) { @@ -382,17 +378,9 @@ int mtdparts_init(void) part->name = "static"; part->auto_name = 0; -#if defined(CONFIG_JFFS2_PART_SIZE) part->size = CONFIG_JFFS2_PART_SIZE; -#else - part->size = SIZE_REMAINING; -#endif -#if defined(CONFIG_JFFS2_PART_OFFSET) part->offset = CONFIG_JFFS2_PART_OFFSET; -#else - part->offset = 0x00000000; -#endif part->dev = current_mtd_dev; INIT_LIST_HEAD(&part->link); -- cgit v1.2.3