diff options
| author | Tom Rini <[email protected]> | 2024-10-07 09:06:49 -0600 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2024-10-07 09:06:49 -0600 |
| commit | c530f6079c70219e01022142b404bf8a6b572366 (patch) | |
| tree | 7696586afaf4c0ae8a94ef811abd7d4a2276eb64 /cmd | |
| parent | f919c3a889f0ec7d63a48b5d0ed064386b0980bd (diff) | |
| parent | 28dc47038edc4e93f32d75a357131bcf01a18d85 (diff) | |
Merge branch 'next'
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/Kconfig | 32 | ||||
| -rw-r--r-- | cmd/Makefile | 1 | ||||
| -rw-r--r-- | cmd/bdinfo.c | 7 | ||||
| -rw-r--r-- | cmd/bind.c | 46 | ||||
| -rw-r--r-- | cmd/booti.c | 4 | ||||
| -rw-r--r-- | cmd/bootz.c | 2 | ||||
| -rw-r--r-- | cmd/date.c | 32 | ||||
| -rw-r--r-- | cmd/efi.c | 2 | ||||
| -rw-r--r-- | cmd/efi_common.c | 2 | ||||
| -rw-r--r-- | cmd/elf.c | 2 | ||||
| -rw-r--r-- | cmd/flash.c | 2 | ||||
| -rw-r--r-- | cmd/gpt.c | 2 | ||||
| -rw-r--r-- | cmd/i2c.c | 23 | ||||
| -rw-r--r-- | cmd/led.c | 2 | ||||
| -rw-r--r-- | cmd/load.c | 7 | ||||
| -rw-r--r-- | cmd/mem.c | 26 | ||||
| -rw-r--r-- | cmd/mmc.c | 71 | ||||
| -rw-r--r-- | cmd/mvebu/bubt.c | 4 | ||||
| -rw-r--r-- | cmd/nvedit_efi.c | 2 | ||||
| -rw-r--r-- | cmd/read.c | 10 | ||||
| -rw-r--r-- | cmd/sb.c | 6 | ||||
| -rw-r--r-- | cmd/sf.c | 8 | ||||
| -rw-r--r-- | cmd/upl.c | 118 | ||||
| -rw-r--r-- | cmd/usb.c | 20 | ||||
| -rw-r--r-- | cmd/x86/hob.c | 2 |
25 files changed, 260 insertions, 173 deletions
diff --git a/cmd/Kconfig b/cmd/Kconfig index 978f44eda42..d50f6396fc7 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -388,6 +388,13 @@ config CMD_SEAMA help Support reading NAND Seattle Image (SEAMA) images. +config CMD_UPL + bool "upl - Universal Payload Specification" + help + Provides commands to deal with UPL payloads and handoff information. + U-Boot supports generating and accepting handoff information. The + mkimage tool will eventually support creating payloads. + config CMD_VBE bool "vbe - Verified Boot for Embedded" depends on BOOTMETH_VBE @@ -1399,6 +1406,15 @@ config CMD_MMC_SWRITE Enable support for the "mmc swrite" command to write Android sparse images to eMMC. +config MMC_SPEED_MODE_SET + bool "set speed mode using mmc command" + help + Enable setting speed mode using mmc rescan and mmc dev commands. + The speed mode is provided as the last argument in these commands + and is indicated using the index from enum bus_mode in + include/mmc.h. A speed mode can be set only if it has already + been enabled in the device tree. + endif config CMD_CLONE @@ -1487,6 +1503,7 @@ config USE_ONENAND_BOARD_INIT config CMD_OSD bool "osd" + depends on OSD help Enable the 'osd' command which allows to query information from and write text data to a on-screen display (OSD) device; a virtual device @@ -1668,9 +1685,8 @@ config CMD_ROCKUSB config CMD_USB_MASS_STORAGE bool "UMS usb mass storage" - depends on USB_GADGET_DOWNLOAD + depends on BLK && USB_GADGET_DOWNLOAD select USB_FUNCTION_MASS_STORAGE - depends on BLK && USB_GADGET help Enables the command "ums" and the USB mass storage support to the export a block device: U-Boot, the USB device, acts as a simple @@ -2003,6 +2019,7 @@ config SYS_DISABLE_AUTOLOAD config CMD_WGET bool "wget" select PROT_TCP + default y if SANDBOX help wget is a simple command to download kernel, or other files, from a http server over TCP. @@ -2091,6 +2108,7 @@ config CMD_ETHSW config CMD_PXE bool "pxe" select PXE_UTILS + imply CMD_TFTPBOOT help Boot image via network using PXE protocol @@ -2963,16 +2981,6 @@ config CMD_UBIFS help UBIFS is a file system for flash devices which works on top of UBI. -config MMC_SPEED_MODE_SET - bool "set speed mode using mmc command" - depends on CMD_MMC - help - Enable setting speed mode using mmc rescan and mmc dev commands. - The speed mode is provided as the last argument in these commands - and is indicated using the index from enum bus_mode in - include/mmc.h. A speed mode can be set only if it has already - been enabled in the device tree. - config CMD_MESON bool "Amlogic Meson commands" depends on ARCH_MESON diff --git a/cmd/Makefile b/cmd/Makefile index 87133cc27a8..91227f1249c 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -189,6 +189,7 @@ obj-$(CONFIG_CMD_UBIFS) += ubifs.o obj-$(CONFIG_CMD_UNIVERSE) += universe.o obj-$(CONFIG_CMD_UNLZ4) += unlz4.o obj-$(CONFIG_CMD_UNZIP) += unzip.o +obj-$(CONFIG_CMD_UPL) += upl.o obj-$(CONFIG_CMD_VIRTIO) += virtio.o obj-$(CONFIG_CMD_WDT) += wdt.o obj-$(CONFIG_CMD_LZMADEC) += lzmadec.o diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c index 437ac4e8630..f6e534dd5bb 100644 --- a/cmd/bdinfo.c +++ b/cmd/bdinfo.c @@ -154,18 +154,13 @@ static int bdinfo_print_all(struct bd_info *bd) if (IS_ENABLED(CONFIG_CMD_NET)) print_eth(); bdinfo_print_num_l("fdt_blob", (ulong)map_to_sysmem(gd->fdt_blob)); - bdinfo_print_num_l("new_fdt", (ulong)map_to_sysmem(gd->new_fdt)); - bdinfo_print_num_l("fdt_size", (ulong)gd->fdt_size); if (IS_ENABLED(CONFIG_VIDEO)) show_video_info(); #if CONFIG_IS_ENABLED(MULTI_DTB_FIT) bdinfo_print_num_l("multi_dtb_fit", (ulong)gd->multi_dtb_fit); #endif if (IS_ENABLED(CONFIG_LMB) && gd->fdt_blob) { - struct lmb lmb; - - lmb_init_and_reserve(&lmb, gd->bd, (void *)gd->fdt_blob); - lmb_dump_all_force(&lmb); + lmb_dump_all_force(); if (IS_ENABLED(CONFIG_OF_REAL)) printf("devicetree = %s\n", fdtdec_get_srcname()); } diff --git a/cmd/bind.c b/cmd/bind.c index 3a59eefd5c5..c0d31f5eb16 100644 --- a/cmd/bind.c +++ b/cmd/bind.c @@ -10,8 +10,8 @@ #include <dm/root.h> #include <dm/uclass-internal.h> -static int bind_by_class_index(const char *uclass, int index, - const char *drv_name) +static int bind_by_class_seq(const char *uclass, int seq, + const char *drv_name) { static enum uclass_id uclass_id; struct udevice *dev; @@ -31,9 +31,9 @@ static int bind_by_class_index(const char *uclass, int index, return -EINVAL; } - ret = uclass_find_device(uclass_id, index, &parent); + ret = uclass_find_device_by_seq(uclass_id, seq, &parent); if (!parent || ret) { - printf("Cannot find device %d of class %s\n", index, uclass); + printf("Cannot find device %d of class %s\n", seq, uclass); return ret; } @@ -47,7 +47,7 @@ static int bind_by_class_index(const char *uclass, int index, return 0; } -static int find_dev(const char *uclass, int index, struct udevice **devp) +static int find_dev(const char *uclass, int seq, struct udevice **devp) { static enum uclass_id uclass_id; int rc; @@ -58,21 +58,21 @@ static int find_dev(const char *uclass, int index, struct udevice **devp) return -EINVAL; } - rc = uclass_find_device(uclass_id, index, devp); + rc = uclass_find_device_by_seq(uclass_id, seq, devp); if (!*devp || rc) { - printf("Cannot find device %d of class %s\n", index, uclass); + printf("Cannot find device %d of class %s\n", seq, uclass); return rc; } return 0; } -static int unbind_by_class_index(const char *uclass, int index) +static int unbind_by_class_seq(const char *uclass, int seq) { int ret; struct udevice *dev; - ret = find_dev(uclass, index, &dev); + ret = find_dev(uclass, seq, &dev); if (ret) return ret; @@ -91,8 +91,8 @@ static int unbind_by_class_index(const char *uclass, int index) return 0; } -static int unbind_child_by_class_index(const char *uclass, int index, - const char *drv_name) +static int unbind_child_by_class_seq(const char *uclass, int seq, + const char *drv_name) { struct udevice *parent; int ret; @@ -104,7 +104,7 @@ static int unbind_child_by_class_index(const char *uclass, int index, return -ENOENT; } - ret = find_dev(uclass, index, &parent); + ret = find_dev(uclass, seq, &parent); if (ret) return ret; @@ -217,19 +217,19 @@ static int do_bind_unbind(struct cmd_tbl *cmdtp, int flag, int argc, return CMD_RET_USAGE; ret = unbind_by_node_path(argv[1]); } else if (!by_node && bind) { - int index = (argc > 2) ? dectoul(argv[2], NULL) : 0; + int seq = (argc > 2) ? dectoul(argv[2], NULL) : 0; if (argc != 4) return CMD_RET_USAGE; - ret = bind_by_class_index(argv[1], index, argv[3]); + ret = bind_by_class_seq(argv[1], seq, argv[3]); } else if (!by_node && !bind) { - int index = (argc > 2) ? dectoul(argv[2], NULL) : 0; + int seq = (argc > 2) ? dectoul(argv[2], NULL) : 0; if (argc == 3) - ret = unbind_by_class_index(argv[1], index); + ret = unbind_by_class_seq(argv[1], seq); else if (argc == 4) - ret = unbind_child_by_class_index(argv[1], index, - argv[3]); + ret = unbind_child_by_class_seq(argv[1], seq, + argv[3]); else return CMD_RET_USAGE; } @@ -244,17 +244,17 @@ U_BOOT_CMD( bind, 4, 0, do_bind_unbind, "Bind a device to a driver", "<node path> <driver>\n" - "bind <class> <index> <driver>\n" + "bind <class> <seq> <driver>\n" "Use 'dm tree' to list all devices registered in the driver model,\n" - "their path, class, index and current driver.\n" + "their path, class, sequence and current driver.\n" ); U_BOOT_CMD( unbind, 4, 0, do_bind_unbind, "Unbind a device from a driver", "<node path>\n" - "unbind <class> <index>\n" - "unbind <class> <index> <driver>\n" + "unbind <class> <seq>\n" + "unbind <class> <seq> <driver>\n" "Use 'dm tree' to list all devices registered in the driver model,\n" - "their path, class, index and current driver.\n" + "their path, class, sequence and current driver.\n" ); diff --git a/cmd/booti.c b/cmd/booti.c index 62b19e83436..43e79e87201 100644 --- a/cmd/booti.c +++ b/cmd/booti.c @@ -78,7 +78,7 @@ static int booti_start(struct bootm_info *bmi) /* Handle BOOTM_STATE_LOADOS */ if (relocated_addr != ld) { - printf("Moving Image from 0x%lx to 0x%lx, end=%lx\n", ld, + printf("Moving Image from 0x%lx to 0x%lx, end=0x%lx\n", ld, relocated_addr, relocated_addr + image_size); memmove((void *)relocated_addr, (void *)ld, image_size); } @@ -87,7 +87,7 @@ static int booti_start(struct bootm_info *bmi) images->os.start = relocated_addr; images->os.end = relocated_addr + image_size; - lmb_reserve(&images->lmb, images->ep, le32_to_cpu(image_size)); + lmb_reserve(images->ep, le32_to_cpu(image_size)); /* * Handle the BOOTM_STATE_FINDOTHER state ourselves as we do not diff --git a/cmd/bootz.c b/cmd/bootz.c index 55837a7599b..787203f5bd7 100644 --- a/cmd/bootz.c +++ b/cmd/bootz.c @@ -56,7 +56,7 @@ static int bootz_start(struct cmd_tbl *cmdtp, int flag, int argc, if (ret != 0) return 1; - lmb_reserve(&images->lmb, images->ep, zi_end - zi_start); + lmb_reserve(images->ep, zi_end - zi_start); /* * Handle the BOOTM_STATE_FINDOTHER state ourselves as we do not diff --git a/cmd/date.c b/cmd/date.c index 755adec1e71..8614f022761 100644 --- a/cmd/date.c +++ b/cmd/date.c @@ -31,7 +31,6 @@ static int do_date(struct cmd_tbl *cmdtp, int flag, int argc, int old_bus __maybe_unused; /* switch to correct I2C bus */ -#ifdef CONFIG_DM_RTC struct udevice *dev; rcode = uclass_get_device_by_seq(UCLASS_RTC, 0, &dev); @@ -42,35 +41,19 @@ static int do_date(struct cmd_tbl *cmdtp, int flag, int argc, return CMD_RET_FAILURE; } } -#elif CONFIG_IS_ENABLED(SYS_I2C_LEGACY) - old_bus = i2c_get_bus_num(); - i2c_set_bus_num(CFG_SYS_RTC_BUS_NUM); -#else - old_bus = I2C_GET_BUS(); - I2C_SET_BUS(CFG_SYS_RTC_BUS_NUM); -#endif switch (argc) { case 2: /* set date & time */ if (strcmp(argv[1],"reset") == 0) { puts ("Reset RTC...\n"); -#ifdef CONFIG_DM_RTC rcode = dm_rtc_reset(dev); if (!rcode) rcode = dm_rtc_set(dev, &default_tm); -#else - rtc_reset(); - rcode = rtc_set(&default_tm); -#endif if (rcode) puts("## Failed to set date after RTC reset\n"); } else { /* initialize tm with current time */ -#ifdef CONFIG_DM_RTC rcode = dm_rtc_get(dev, &tm); -#else - rcode = rtc_get(&tm); -#endif if (!rcode) { /* insert new date & time */ if (mk_date(argv[1], &tm) != 0) { @@ -78,11 +61,7 @@ static int do_date(struct cmd_tbl *cmdtp, int flag, int argc, break; } /* and write to RTC */ -#ifdef CONFIG_DM_RTC rcode = dm_rtc_set(dev, &tm); -#else - rcode = rtc_set(&tm); -#endif if (rcode) { printf("## Set date failed: err=%d\n", rcode); @@ -93,11 +72,7 @@ static int do_date(struct cmd_tbl *cmdtp, int flag, int argc, } fallthrough; case 1: /* get date & time */ -#ifdef CONFIG_DM_RTC rcode = dm_rtc_get(dev, &tm); -#else - rcode = rtc_get(&tm); -#endif if (rcode) { puts("## Get date failed\n"); break; @@ -114,13 +89,6 @@ static int do_date(struct cmd_tbl *cmdtp, int flag, int argc, rcode = CMD_RET_USAGE; } - /* switch back to original I2C bus */ -#if CONFIG_IS_ENABLED(SYS_I2C_LEGACY) - i2c_set_bus_num(old_bus); -#elif !defined(CONFIG_DM_RTC) - I2C_SET_BUS(old_bus); -#endif - return rcode ? CMD_RET_FAILURE : 0; } diff --git a/cmd/efi.c b/cmd/efi.c index 6bed2d743ba..687ccb52042 100644 --- a/cmd/efi.c +++ b/cmd/efi.c @@ -11,7 +11,7 @@ #include <log.h> #include <malloc.h> #include <sort.h> -#include <uuid.h> +#include <u-boot/uuid.h> #include <asm/global_data.h> DECLARE_GLOBAL_DATA_PTR; diff --git a/cmd/efi_common.c b/cmd/efi_common.c index c46764e6eea..d2f2b59e9e3 100644 --- a/cmd/efi_common.c +++ b/cmd/efi_common.c @@ -8,7 +8,7 @@ #include <efi.h> #include <efi_api.h> -#include <uuid.h> +#include <u-boot/uuid.h> void efi_show_tables(struct efi_system_table *systab) { diff --git a/cmd/elf.c b/cmd/elf.c index 673c6c30511..f07e344a596 100644 --- a/cmd/elf.c +++ b/cmd/elf.c @@ -70,7 +70,7 @@ int do_bootelf(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) fdt_set_totalsize((void *)fdt_addr, fdt_totalsize(fdt_addr) + CONFIG_SYS_FDT_PAD); - if (image_setup_libfdt(&img, (void *)fdt_addr, NULL)) + if (image_setup_libfdt(&img, (void *)fdt_addr, false)) return 1; } #endif diff --git a/cmd/flash.c b/cmd/flash.c index de0e04f09cf..fd660ec477c 100644 --- a/cmd/flash.c +++ b/cmd/flash.c @@ -10,7 +10,7 @@ #include <command.h> #include <log.h> #include <vsprintf.h> -#include <uuid.h> +#include <u-boot/uuid.h> #if defined(CONFIG_CMD_MTDPARTS) #include <jffs2/jffs2.h> diff --git a/cmd/gpt.c b/cmd/gpt.c index 86b7701886a..27aea2df197 100644 --- a/cmd/gpt.c +++ b/cmd/gpt.c @@ -19,7 +19,7 @@ #include <part_efi.h> #include <part.h> #include <exports.h> -#include <uuid.h> +#include <u-boot/uuid.h> #include <linux/ctype.h> #include <div64.h> #include <memalign.h> diff --git a/cmd/i2c.c b/cmd/i2c.c index 7dac0a9fb6c..7246c4fa3e7 100644 --- a/cmd/i2c.c +++ b/cmd/i2c.c @@ -1698,18 +1698,6 @@ static int do_i2c_show_bus(struct cmd_tbl *cmdtp, int flag, int argc, for (i = 0; i < CFG_SYS_NUM_I2C_BUSES; i++) { printf("Bus %d:\t%s", i, I2C_ADAP_NR(i)->name); -#ifndef CFG_SYS_I2C_DIRECT_BUS - int j; - - for (j = 0; j < CFG_SYS_I2C_MAX_HOPS; j++) { - if (i2c_bus[i].next_hop[j].chip == 0) - break; - printf("->%s@0x%2x:%d", - i2c_bus[i].next_hop[j].mux.name, - i2c_bus[i].next_hop[j].chip, - i2c_bus[i].next_hop[j].channel); - } -#endif printf("\n"); } #endif @@ -1734,17 +1722,6 @@ static int do_i2c_show_bus(struct cmd_tbl *cmdtp, int flag, int argc, return -1; } printf("Bus %d:\t%s", i, I2C_ADAP_NR(i)->name); -#ifndef CFG_SYS_I2C_DIRECT_BUS - int j; - for (j = 0; j < CFG_SYS_I2C_MAX_HOPS; j++) { - if (i2c_bus[i].next_hop[j].chip == 0) - break; - printf("->%s@0x%2x:%d", - i2c_bus[i].next_hop[j].mux.name, - i2c_bus[i].next_hop[j].chip, - i2c_bus[i].next_hop[j].channel); - } -#endif printf("\n"); #endif } diff --git a/cmd/led.c b/cmd/led.c index 2f786f34c67..91fb856ee59 100644 --- a/cmd/led.c +++ b/cmd/led.c @@ -118,7 +118,7 @@ int do_led(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) return 0; } -#ifdef CONFIG_LED_BLINK +#if defined(CONFIG_LED_BLINK) || defined(CONFIG_LED_SW_BLINK) #define BLINK "|blink [blink-freq in ms]" #else #define BLINK "" diff --git a/cmd/load.c b/cmd/load.c index d773a25d70c..20d802502ae 100644 --- a/cmd/load.c +++ b/cmd/load.c @@ -141,7 +141,6 @@ static int do_load_serial(struct cmd_tbl *cmdtp, int flag, int argc, static ulong load_serial(long offset) { - struct lmb lmb; char record[SREC_MAXRECLEN + 1]; /* buffer for one S-Record */ char binbuf[SREC_MAXBINLEN]; /* buffer for binary data */ int binlen; /* no. of data bytes in S-Rec. */ @@ -154,8 +153,6 @@ static ulong load_serial(long offset) int line_count = 0; long ret; - lmb_init_and_reserve(&lmb, gd->bd, (void *)gd->fdt_blob); - while (read_record(record, SREC_MAXRECLEN + 1) >= 0) { type = srec_decode(record, &binlen, &addr, binbuf); @@ -182,7 +179,7 @@ static ulong load_serial(long offset) { void *dst; - ret = lmb_reserve(&lmb, store_addr, binlen); + ret = lmb_reserve(store_addr, binlen); if (ret) { printf("\nCannot overwrite reserved area (%08lx..%08lx)\n", store_addr, store_addr + binlen); @@ -191,7 +188,7 @@ static ulong load_serial(long offset) dst = map_sysmem(store_addr, binlen); memcpy(dst, binbuf, binlen); unmap_sysmem(dst); - lmb_free(&lmb, store_addr, binlen); + lmb_free(store_addr, binlen); } if ((store_addr) < start_addr) start_addr = store_addr; diff --git a/cmd/mem.c b/cmd/mem.c index 274348068c2..4d6fde28531 100644 --- a/cmd/mem.c +++ b/cmd/mem.c @@ -245,7 +245,7 @@ static int do_mem_cmp(struct cmd_tbl *cmdtp, int flag, int argc, int size; int rcode = 0; const char *type; - const void *buf1, *buf2, *base; + const void *buf1, *buf2, *base, *ptr1, *ptr2; ulong word1, word2; /* 64-bit if MEM_SUPPORT_64BIT_DATA */ if (argc != 4) @@ -270,22 +270,22 @@ static int do_mem_cmp(struct cmd_tbl *cmdtp, int flag, int argc, bytes = size * count; base = buf1 = map_sysmem(addr1, bytes); buf2 = map_sysmem(addr2, bytes); - for (ngood = 0; ngood < count; ++ngood) { + for (ngood = 0, ptr1 = buf1, ptr2 = buf2; ngood < count; ++ngood) { if (size == 4) { - word1 = *(u32 *)buf1; - word2 = *(u32 *)buf2; + word1 = *(u32 *)ptr1; + word2 = *(u32 *)ptr2; } else if (MEM_SUPPORT_64BIT_DATA && size == 8) { - word1 = *(ulong *)buf1; - word2 = *(ulong *)buf2; + word1 = *(ulong *)ptr1; + word2 = *(ulong *)ptr2; } else if (size == 2) { - word1 = *(u16 *)buf1; - word2 = *(u16 *)buf2; + word1 = *(u16 *)ptr1; + word2 = *(u16 *)ptr2; } else { - word1 = *(u8 *)buf1; - word2 = *(u8 *)buf2; + word1 = *(u8 *)ptr1; + word2 = *(u8 *)ptr2; } if (word1 != word2) { - ulong offset = buf1 - base; + ulong offset = ptr1 - base; printf("%s at 0x%08lx (%#0*lx) != %s at 0x%08lx (%#0*lx)\n", type, (ulong)(addr1 + offset), size, word1, type, (ulong)(addr2 + offset), size, word2); @@ -293,8 +293,8 @@ static int do_mem_cmp(struct cmd_tbl *cmdtp, int flag, int argc, break; } - buf1 += size; - buf2 += size; + ptr1 += size; + ptr2 += size; /* reset watchdog from time to time */ if ((ngood % (64 << 10)) == 0) diff --git a/cmd/mmc.c b/cmd/mmc.c index 7244a90f4dc..fe7899ec793 100644 --- a/cmd/mmc.c +++ b/cmd/mmc.c @@ -8,12 +8,14 @@ #include <command.h> #include <console.h> #include <display_options.h> +#include <mapmem.h> #include <memalign.h> #include <mmc.h> #include <part.h> #include <sparse_format.h> #include <image-sparse.h> #include <vsprintf.h> +#include <linux/ctype.h> static int curr_device = -1; @@ -238,7 +240,7 @@ static int do_mmcrpmb_read(struct cmd_tbl *cmdtp, int flag, if (argc == 5) key_addr = (void *)hextoul(argv[4], NULL); - printf("\nMMC RPMB read: dev # %d, block # %d, count %d ... ", + printf("MMC RPMB read: dev # %d, block # %d, count %d ... ", curr_device, blk, cnt); n = mmc_rpmb_read(mmc, addr, blk, cnt, key_addr); @@ -265,7 +267,7 @@ static int do_mmcrpmb_write(struct cmd_tbl *cmdtp, int flag, cnt = hextoul(argv[3], NULL); key_addr = (void *)hextoul(argv[4], NULL); - printf("\nMMC RPMB write: dev # %d, block # %d, count %d ... ", + printf("MMC RPMB write: dev # %d, block # %d, count %d ... ", curr_device, blk, cnt); n = mmc_rpmb_write(mmc, addr, blk, cnt, key_addr); @@ -349,12 +351,12 @@ static int do_mmc_read(struct cmd_tbl *cmdtp, int flag, { struct mmc *mmc; u32 blk, cnt, n; - void *addr; + void *ptr; if (argc != 4) return CMD_RET_USAGE; - addr = (void *)hextoul(argv[1], NULL); + ptr = map_sysmem(hextoul(argv[1], NULL), 0); blk = hextoul(argv[2], NULL); cnt = hextoul(argv[3], NULL); @@ -362,11 +364,12 @@ static int do_mmc_read(struct cmd_tbl *cmdtp, int flag, if (!mmc) return CMD_RET_FAILURE; - printf("\nMMC read: dev # %d, block # %d, count %d ... ", + printf("MMC read: dev # %d, block # %d, count %d ... ", curr_device, blk, cnt); - n = blk_dread(mmc_get_blk_desc(mmc), blk, cnt, addr); + n = blk_dread(mmc_get_blk_desc(mmc), blk, cnt, ptr); printf("%d blocks read: %s\n", n, (n == cnt) ? "OK" : "ERROR"); + unmap_sysmem(ptr); return (n == cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE; } @@ -411,7 +414,7 @@ static int do_mmc_sparse_write(struct cmd_tbl *cmdtp, int flag, if (!mmc) return CMD_RET_FAILURE; - printf("\nMMC Sparse write: dev # %d, block # %d ... ", + printf("MMC Sparse write: dev # %d, block # %d ... ", curr_device, blk); if (mmc_getwp(mmc) == 1) { @@ -442,12 +445,12 @@ static int do_mmc_write(struct cmd_tbl *cmdtp, int flag, { struct mmc *mmc; u32 blk, cnt, n; - void *addr; + void *ptr; if (argc != 4) return CMD_RET_USAGE; - addr = (void *)hextoul(argv[1], NULL); + ptr = map_sysmem(hextoul(argv[1], NULL), 0); blk = hextoul(argv[2], NULL); cnt = hextoul(argv[3], NULL); @@ -455,15 +458,16 @@ static int do_mmc_write(struct cmd_tbl *cmdtp, int flag, if (!mmc) return CMD_RET_FAILURE; - printf("\nMMC write: dev # %d, block # %d, count %d ... ", + printf("MMC write: dev # %d, block # %d, count %d ... ", curr_device, blk, cnt); if (mmc_getwp(mmc) == 1) { printf("Error: card is write protected!\n"); return CMD_RET_FAILURE; } - n = blk_dwrite(mmc_get_blk_desc(mmc), blk, cnt, addr); + n = blk_dwrite(mmc_get_blk_desc(mmc), blk, cnt, ptr); printf("%d blocks written: %s\n", n, (n == cnt) ? "OK" : "ERROR"); + unmap_sysmem(ptr); return (n == cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE; } @@ -472,19 +476,27 @@ static int do_mmc_erase(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { struct mmc *mmc; + struct disk_partition info; u32 blk, cnt, n; - if (argc != 3) + if (argc < 2 || argc > 3) return CMD_RET_USAGE; - blk = hextoul(argv[1], NULL); - cnt = hextoul(argv[2], NULL); - mmc = init_mmc_device(curr_device, false); if (!mmc) return CMD_RET_FAILURE; - printf("\nMMC erase: dev # %d, block # %d, count %d ... ", + if (argc == 3) { + blk = hextoul(argv[1], NULL); + cnt = hextoul(argv[2], NULL); + } else if (part_get_info_by_name(mmc_get_blk_desc(mmc), argv[1], &info) >= 0) { + blk = info.start; + cnt = info.size; + } else { + return CMD_RET_FAILURE; + } + + printf("MMC erase: dev # %d, block # %d, count %d ... ", curr_device, blk, cnt); if (mmc_getwp(mmc) == 1) { @@ -918,8 +930,9 @@ static int mmc_partconf_print(struct mmc *mmc, const char *varname) printf("EXT_CSD[179], PARTITION_CONFIG:\n" "BOOT_ACK: 0x%x\n" - "BOOT_PARTITION_ENABLE: 0x%x\n" - "PARTITION_ACCESS: 0x%x\n", ack, part, access); + "BOOT_PARTITION_ENABLE: 0x%x (%s)\n" + "PARTITION_ACCESS: 0x%x (%s)\n", ack, part, emmc_boot_part_names[part], + access, emmc_hwpart_names[access]); return CMD_RET_SUCCESS; } @@ -948,9 +961,26 @@ static int do_mmc_partconf(struct cmd_tbl *cmdtp, int flag, if (argc == 2 || argc == 3) return mmc_partconf_print(mmc, cmd_arg2(argc, argv)); + /* BOOT_ACK */ ack = dectoul(argv[2], NULL); - part_num = dectoul(argv[3], NULL); - access = dectoul(argv[4], NULL); + /* BOOT_PARTITION_ENABLE */ + if (!isdigit(*argv[3])) { + for (part_num = ARRAY_SIZE(emmc_boot_part_names) - 1; part_num > 0; part_num--) { + if (!strcmp(argv[3], emmc_boot_part_names[part_num])) + break; + } + } else { + part_num = dectoul(argv[3], NULL); + } + /* PARTITION_ACCESS */ + if (!isdigit(*argv[4])) { + for (access = ARRAY_SIZE(emmc_hwpart_names) - 1; access > 0; access--) { + if (!strcmp(argv[4], emmc_hwpart_names[access])) + break; + } + } else { + access = dectoul(argv[4], NULL); + } /* acknowledge to be sent during boot operation */ ret = mmc_set_part_conf(mmc, ack, part_num, access); @@ -1271,6 +1301,7 @@ U_BOOT_CMD( "mmc swrite addr blk#\n" #endif "mmc erase blk# cnt\n" + "mmc erase partname\n" "mmc rescan [mode]\n" "mmc part - lists available partition on current mmc device\n" "mmc dev [dev] [part] [mode] - show or set current mmc device [partition] and set mode\n" diff --git a/cmd/mvebu/bubt.c b/cmd/mvebu/bubt.c index e3f21dd0d81..5e4ffc40d72 100644 --- a/cmd/mvebu/bubt.c +++ b/cmd/mvebu/bubt.c @@ -223,8 +223,8 @@ static int mmc_burn_image(size_t image_size) #endif part = EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config); - if (part == 7) - part = 0; + if (part == EMMC_BOOT_PART_USER) + part = EMMC_HWPART_DEFAULT; #ifdef CONFIG_BLK err = blk_dselect_hwpart(blk_desc, part); diff --git a/cmd/nvedit_efi.c b/cmd/nvedit_efi.c index 64ae2ad2ce2..32b7d049074 100644 --- a/cmd/nvedit_efi.c +++ b/cmd/nvedit_efi.c @@ -15,7 +15,7 @@ #include <malloc.h> #include <mapmem.h> #include <rtc.h> -#include <uuid.h> +#include <u-boot/uuid.h> #include <linux/kernel.h> /* diff --git a/cmd/read.c b/cmd/read.c index af54bd17654..8e21f004423 100644 --- a/cmd/read.c +++ b/cmd/read.c @@ -20,7 +20,7 @@ do_rw(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) struct disk_partition part_info; ulong offset, limit; uint blk, cnt, res; - void *addr; + void *ptr; int part; if (argc != 6) { @@ -33,7 +33,7 @@ do_rw(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) if (part < 0) return 1; - addr = map_sysmem(hextoul(argv[3], NULL), 0); + ptr = map_sysmem(hextoul(argv[3], NULL), 0); blk = hextoul(argv[4], NULL); cnt = hextoul(argv[5], NULL); @@ -48,13 +48,15 @@ do_rw(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) if (cnt + blk > limit) { printf("%s out of range\n", cmdtp->name); + unmap_sysmem(ptr); return 1; } if (IS_ENABLED(CONFIG_CMD_WRITE) && !strcmp(cmdtp->name, "write")) - res = blk_dwrite(dev_desc, offset + blk, cnt, addr); + res = blk_dwrite(dev_desc, offset + blk, cnt, ptr); else - res = blk_dread(dev_desc, offset + blk, cnt, addr); + res = blk_dread(dev_desc, offset + blk, cnt, ptr); + unmap_sysmem(ptr); if (res != cnt) { printf("%s error\n", cmdtp->name); @@ -14,8 +14,10 @@ static int do_sb_handoff(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { #if CONFIG_IS_ENABLED(HANDOFF) - if (gd->spl_handoff) - printf("SPL handoff magic %lx\n", gd->spl_handoff->arch.magic); + struct spl_handoff *handoff = handoff_get(); + + if (handoff) + printf("SPL handoff magic %lx\n", handoff->arch.magic); else printf("SPL handoff info not received\n"); @@ -10,6 +10,7 @@ #include <div64.h> #include <dm.h> #include <log.h> +#include <lmb.h> #include <malloc.h> #include <mapmem.h> #include <spi.h> @@ -317,6 +318,13 @@ static int do_spi_flash_read_write(int argc, char *const argv[]) strncmp(argv[0], "write", 5) == 0) { int read; + if (CONFIG_IS_ENABLED(LMB)) { + if (lmb_read_check(addr, len)) { + printf("ERROR: trying to overwrite reserved memory...\n"); + return CMD_RET_FAILURE; + } + } + read = strncmp(argv[0], "read", 4) == 0; if (read) ret = spi_flash_read(flash, offset, len, buf); diff --git a/cmd/upl.c b/cmd/upl.c new file mode 100644 index 00000000000..c9745886507 --- /dev/null +++ b/cmd/upl.c @@ -0,0 +1,118 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Commands for UPL handoff generation + * + * Copyright 2024 Google LLC + * Written by Simon Glass <[email protected]> + */ + +#define LOG_CATEGORY UCLASS_BOOTSTD + +#include <abuf.h> +#include <alist.h> +#include <command.h> +#include <display_options.h> +#include <mapmem.h> +#include <string.h> +#include <upl.h> +#include <dm/ofnode.h> +#include <test/ut.h> + +DECLARE_GLOBAL_DATA_PTR; + +static int do_upl_info(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + const struct upl *upl = gd_upl(); + + printf("UPL state: %sactive\n", upl ? "" : "in"); + if (!upl) + return 0; + if (argc > 1 && !strcmp("-v", argv[1])) { + int i; + + printf("fit %lx\n", upl->fit); + printf("conf_offset %x\n", upl->conf_offset); + for (i = 0; i < upl->image.count; i++) { + const struct upl_image *img = + alist_get(&upl->image, i, struct upl_image); + + printf("image %d: load %lx size %lx offset %x: %s\n", i, + img->load, img->size, img->offset, + img->description); + } + } + + return 0; +} + +static int do_upl_write(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct upl s_upl, *upl = &s_upl; + struct unit_test_state uts; + struct abuf buf; + oftree tree; + ulong addr; + int ret; + + upl_get_test_data(&uts, upl); + + log_debug("Writing UPL\n"); + ret = upl_create_handoff_tree(upl, &tree); + if (ret) { + log_err("Failed to write (err=%dE)\n", ret); + return CMD_RET_FAILURE; + } + + log_debug("Flattening\n"); + ret = oftree_to_fdt(tree, &buf); + if (ret) { + log_err("Failed to write (err=%dE)\n", ret); + return CMD_RET_FAILURE; + } + addr = map_to_sysmem(abuf_data(&buf)); + printf("UPL handoff written to %lx size %lx\n", addr, abuf_size(&buf)); + if (env_set_hex("upladdr", addr) || + env_set_hex("uplsize", abuf_size(&buf))) { + printf("Cannot set env var\n"); + return CMD_RET_FAILURE; + } + + log_debug("done\n"); + + return 0; +} + +static int do_upl_read(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct upl s_upl, *upl = &s_upl; + oftree tree; + ulong addr; + int ret; + + if (argc < 1) + return CMD_RET_USAGE; + addr = hextoul(argv[1], NULL); + + printf("Reading UPL at %lx\n", addr); + tree = oftree_from_fdt(map_sysmem(addr, 0)); + ret = upl_read_handoff(upl, tree); + if (ret) { + log_err("Failed to read (err=%dE)\n", ret); + return CMD_RET_FAILURE; + } + + return 0; +} + +U_BOOT_LONGHELP(upl, + "info [-v] - Check UPL status\n" + "upl read <addr> - Read handoff information\n" + "upl write - Write handoff information"); + +U_BOOT_CMD_WITH_SUBCMDS(upl, "Universal Payload support", upl_help_text, + U_BOOT_SUBCMD_MKENT(info, 2, 1, do_upl_info), + U_BOOT_SUBCMD_MKENT(read, 2, 1, do_upl_read), + U_BOOT_SUBCMD_MKENT(write, 1, 1, do_upl_write)); diff --git a/cmd/usb.c b/cmd/usb.c index 16c081bf128..13a2996c1f0 100644 --- a/cmd/usb.c +++ b/cmd/usb.c @@ -560,17 +560,6 @@ static int do_usbboot(struct cmd_tbl *cmdtp, int flag, int argc, } #endif /* CONFIG_USB_STORAGE */ -static int do_usb_stop_keyboard(int force) -{ -#if !defined CONFIG_DM_USB && defined CONFIG_USB_KEYBOARD - if (usb_kbd_deregister(force) != 0) { - printf("USB not stopped: usbkbd still using USB\n"); - return 1; - } -#endif - return 0; -} - static void do_usb_start(void) { bootstage_mark_name(BOOTSTAGE_ID_USB_START, "usb_start"); @@ -583,11 +572,6 @@ static void do_usb_start(void) /* try to recognize storage devices immediately */ usb_stor_curr_dev = usb_stor_scan(1); # endif -#ifndef CONFIG_DM_USB -# ifdef CONFIG_USB_KEYBOARD - drv_usb_kbd_init(); -# endif -#endif /* !CONFIG_DM_USB */ } #ifdef CONFIG_DM_USB @@ -633,8 +617,6 @@ static int do_usb(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) if (strncmp(argv[1], "reset", 5) == 0) { printf("resetting USB...\n"); - if (do_usb_stop_keyboard(1) != 0) - return 1; usb_stop(); do_usb_start(); return 0; @@ -642,8 +624,6 @@ static int do_usb(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) if (strncmp(argv[1], "stop", 4) == 0) { if (argc != 2) console_assign(stdin, "serial"); - if (do_usb_stop_keyboard(0) != 0) - return 1; printf("stopping USB..\n"); usb_stop(); return 0; diff --git a/cmd/x86/hob.c b/cmd/x86/hob.c index 2dd30808bd1..d3713cef331 100644 --- a/cmd/x86/hob.c +++ b/cmd/x86/hob.c @@ -5,7 +5,7 @@ #include <command.h> #include <efi.h> -#include <uuid.h> +#include <u-boot/uuid.h> #include <asm/global_data.h> #include <asm/hob.h> #include <asm/fsp/fsp_hob.h> |
