summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/Kconfig9
-rw-r--r--cmd/Makefile2
-rw-r--r--cmd/bdinfo.c355
-rw-r--r--cmd/blob.c2
-rw-r--r--cmd/bootefi.c32
-rw-r--r--cmd/booti.c161
-rw-r--r--cmd/bootm.c250
-rw-r--r--cmd/bootz.c106
-rw-r--r--cmd/fastboot/Kconfig60
-rw-r--r--cmd/fdt.c26
-rw-r--r--cmd/gpt.c4
-rw-r--r--cmd/i2c.c2
-rw-r--r--cmd/lzmadec.c5
-rw-r--r--cmd/misc.c21
-rw-r--r--cmd/mtdparts.c96
-rw-r--r--cmd/nand.c15
-rw-r--r--cmd/sf.c2
-rw-r--r--cmd/usb_mass_storage.c4
18 files changed, 643 insertions, 509 deletions
diff --git a/cmd/Kconfig b/cmd/Kconfig
index d69b817c827..d28da54ed65 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -114,6 +114,8 @@ config AUTOBOOT_STOP_STR_SHA256
endmenu
+source "cmd/fastboot/Kconfig"
+
comment "Commands"
menu "Info commands"
@@ -165,6 +167,13 @@ config CMD_BOOTZ
help
Boot the Linux zImage
+config CMD_BOOTI
+ bool "booti"
+ depends on ARM64
+ default y
+ help
+ Boot an AArch64 Linux Kernel image from memory.
+
config CMD_BOOTEFI
bool "bootefi"
depends on EFI_LOADER
diff --git a/cmd/Makefile b/cmd/Makefile
index a1731be7012..a1ecf73ef31 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -26,6 +26,8 @@ obj-$(CONFIG_CMD_BOOTEFI) += bootefi.o
obj-$(CONFIG_CMD_BOOTMENU) += bootmenu.o
obj-$(CONFIG_CMD_BOOTLDR) += bootldr.o
obj-$(CONFIG_CMD_BOOTSTAGE) += bootstage.o
+obj-$(CONFIG_CMD_BOOTZ) += bootz.o
+obj-$(CONFIG_CMD_BOOTI) += booti.o
obj-$(CONFIG_CMD_CACHE) += cache.o
obj-$(CONFIG_CMD_CBFS) += cbfs.o
obj-$(CONFIG_CMD_CLK) += clk.o
diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c
index 1c4bed96b5b..ae3027a297b 100644
--- a/cmd/bdinfo.c
+++ b/cmd/bdinfo.c
@@ -69,6 +69,105 @@ static void print_mhz(const char *name, unsigned long hz)
printf("%-12s= %6s MHz\n", name, strmhz(buf, hz));
}
+
+static inline void print_bi_boot_params(const bd_t *bd)
+{
+ print_num("boot_params", (ulong)bd->bi_boot_params);
+}
+
+static inline void print_bi_mem(const bd_t *bd)
+{
+#if defined(CONFIG_SH)
+ print_num("mem start ", (ulong)bd->bi_memstart);
+ print_lnum("mem size ", (u64)bd->bi_memsize);
+#elif defined(CONFIG_ARC)
+ print_num("mem start", (ulong)bd->bi_memstart);
+ print_lnum("mem size", (u64)bd->bi_memsize);
+#elif defined(CONFIG_AVR32)
+ print_num("memstart", (ulong)bd->bi_dram[0].start);
+ print_lnum("memsize", (u64)bd->bi_dram[0].size);
+#else
+ print_num("memstart", (ulong)bd->bi_memstart);
+ print_lnum("memsize", (u64)bd->bi_memsize);
+#endif
+}
+
+static inline void print_bi_dram(const bd_t *bd)
+{
+#ifdef CONFIG_NR_DRAM_BANKS
+ int i;
+
+ for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
+ if (bd->bi_dram[i].size) {
+ print_num("DRAM bank", i);
+ print_num("-> start", bd->bi_dram[i].start);
+ print_num("-> size", bd->bi_dram[i].size);
+ }
+ }
+#endif
+}
+
+static inline void print_bi_flash(const bd_t *bd)
+{
+#if defined(CONFIG_MICROBLAZE) || defined(CONFIG_SH)
+ print_num("flash start ", (ulong)bd->bi_flashstart);
+ print_num("flash size ", (ulong)bd->bi_flashsize);
+ print_num("flash offset ", (ulong)bd->bi_flashoffset);
+
+#elif defined(CONFIG_NIOS2) || defined(CONFIG_OPENRISC)
+ print_num("flash start", (ulong)bd->bi_flashstart);
+ print_num("flash size", (ulong)bd->bi_flashsize);
+ print_num("flash offset", (ulong)bd->bi_flashoffset);
+#else
+ print_num("flashstart", (ulong)bd->bi_flashstart);
+ print_num("flashsize", (ulong)bd->bi_flashsize);
+ print_num("flashoffset", (ulong)bd->bi_flashoffset);
+#endif
+}
+
+static inline void print_eth_ip_addr(void)
+{
+#if defined(CONFIG_CMD_NET)
+ print_eth(0);
+#if defined(CONFIG_HAS_ETH1)
+ print_eth(1);
+#endif
+#if defined(CONFIG_HAS_ETH2)
+ print_eth(2);
+#endif
+#if defined(CONFIG_HAS_ETH3)
+ print_eth(3);
+#endif
+#if defined(CONFIG_HAS_ETH4)
+ print_eth(4);
+#endif
+#if defined(CONFIG_HAS_ETH5)
+ print_eth(5);
+#endif
+ printf("IP addr = %s\n", getenv("ipaddr"));
+#endif
+}
+
+static inline void print_baudrate(void)
+{
+#if defined(CONFIG_PPC)
+ printf("baudrate = %6u bps\n", gd->baudrate);
+#elif defined(CONFIG_SPARC)
+ printf("baudrate = %6u bps\n", gd->baudrate);
+#else
+ printf("baudrate = %u bps\n", gd->baudrate);
+#endif
+}
+
+static inline void print_std_bdinfo(const bd_t *bd)
+{
+ print_bi_boot_params(bd);
+ print_bi_mem(bd);
+ print_bi_flash(bd);
+ print_eth_ip_addr();
+ print_baudrate();
+}
+
#if defined(CONFIG_PPC)
void __weak board_detail(void)
{
@@ -82,11 +181,8 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
#ifdef DEBUG
print_num("bd address", (ulong)bd);
#endif
- print_num("memstart", bd->bi_memstart);
- print_lnum("memsize", bd->bi_memsize);
- print_num("flashstart", bd->bi_flashstart);
- print_num("flashsize", bd->bi_flashsize);
- print_num("flashoffset", bd->bi_flashoffset);
+ print_bi_mem(bd);
+ print_bi_flash(bd);
print_num("sramstart", bd->bi_sramstart);
print_num("sramsize", bd->bi_sramsize);
#if defined(CONFIG_5xx) || defined(CONFIG_8xx) || \
@@ -129,25 +225,8 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
#endif
#endif
- print_eth(0);
-#if defined(CONFIG_HAS_ETH1)
- print_eth(1);
-#endif
-#if defined(CONFIG_HAS_ETH2)
- print_eth(2);
-#endif
-#if defined(CONFIG_HAS_ETH3)
- print_eth(3);
-#endif
-#if defined(CONFIG_HAS_ETH4)
- print_eth(4);
-#endif
-#if defined(CONFIG_HAS_ETH5)
- print_eth(5);
-#endif
-
- printf("IP addr = %s\n", getenv("ipaddr"));
- printf("baudrate = %6u bps\n", gd->baudrate);
+ print_eth_ip_addr();
+ print_baudrate();
print_num("relocaddr", gd->relocaddr);
board_detail();
return 0;
@@ -157,30 +236,18 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
- int i;
bd_t *bd = gd->bd;
- for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
- print_num("DRAM bank", i);
- print_num("-> start", bd->bi_dram[i].start);
- print_num("-> size", bd->bi_dram[i].size);
- }
-
- print_num("flash start", (ulong)bd->bi_flashstart);
- print_num("flash size", (ulong)bd->bi_flashsize);
- print_num("flash offset", (ulong)bd->bi_flashoffset);
+ print_bi_dram(bd);
+ print_bi_flash(bd);
#if defined(CONFIG_SYS_SRAM_BASE)
print_num ("sram start", (ulong)bd->bi_sramstart);
print_num ("sram size", (ulong)bd->bi_sramsize);
#endif
-#if defined(CONFIG_CMD_NET)
- print_eth(0);
- printf("ip_addr = %s\n", getenv("ipaddr"));
-#endif
-
- printf("baudrate = %u bps\n", gd->baudrate);
+ print_eth_ip_addr();
+ print_baudrate();
return 0;
}
@@ -190,17 +257,9 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
bd_t *bd = gd->bd;
- int i;
- for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
- print_num("DRAM bank", i);
- print_num("-> start", bd->bi_dram[i].start);
- print_num("-> size", bd->bi_dram[i].size);
- }
-
- print_num("flash start ", (ulong)bd->bi_flashstart);
- print_num("flash size ", (ulong)bd->bi_flashsize);
- print_num("flash offset ", (ulong)bd->bi_flashoffset);
+ print_bi_dram(bd);
+ print_bi_flash(bd);
#if defined(CONFIG_SYS_SRAM_BASE)
print_num("sram start ", (ulong)bd->bi_sramstart);
print_num("sram size ", (ulong)bd->bi_sramsize);
@@ -208,7 +267,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
#if defined(CONFIG_CMD_NET) && !defined(CONFIG_DM_ETH)
print_eths();
#endif
- printf("baudrate = %u bps\n", gd->baudrate);
+ print_baudrate();
print_num("relocaddr", gd->relocaddr);
print_num("reloc off", gd->reloc_off);
print_num("fdt_blob", (ulong)gd->fdt_blob);
@@ -243,11 +302,8 @@ int do_bdinfo(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
printf("CONFIG_SYS_GBL_DATA_OFFSET = 0x%x (%d)\n", CONFIG_SYS_GBL_DATA_OFFSET,
GENERATED_GBL_DATA_SIZE);
-#if defined(CONFIG_CMD_NET)
- print_eth(0);
- printf("ip_addr = %s\n", getenv("ipaddr"));
-#endif
- printf("baudrate = %6u bps\n", gd->baudrate);
+ print_eth_ip_addr();
+ print_baudrate();
return 0;
}
@@ -257,11 +313,8 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
bd_t *bd = gd->bd;
- print_num("memstart", (ulong)bd->bi_memstart);
- print_lnum("memsize", (u64)bd->bi_memsize);
- print_num("flashstart", (ulong)bd->bi_flashstart);
- print_num("flashsize", (ulong)bd->bi_flashsize);
- print_num("flashoffset", (ulong)bd->bi_flashoffset);
+ print_bi_mem(bd);
+ print_bi_flash(bd);
#if defined(CONFIG_SYS_INIT_RAM_ADDR)
print_num("sramstart", (ulong)bd->bi_sramstart);
print_num("sramsize", (ulong)bd->bi_sramsize);
@@ -279,21 +332,8 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
print_mhz("inpfreq", bd->bi_inpfreq);
print_mhz("vcofreq", bd->bi_vcofreq);
#endif
-#if defined(CONFIG_CMD_NET)
- print_eth(0);
-#if defined(CONFIG_HAS_ETH1)
- print_eth(1);
-#endif
-#if defined(CONFIG_HAS_ETH2)
- print_eth(2);
-#endif
-#if defined(CONFIG_HAS_ETH3)
- print_eth(3);
-#endif
-
- printf("ip_addr = %s\n", getenv("ipaddr"));
-#endif
- printf("baudrate = %u bps\n", gd->baudrate);
+ print_eth_ip_addr();
+ print_baudrate();
return 0;
}
@@ -311,16 +351,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
print_mhz("CCLK", bd->bi_cclk);
print_mhz("SCLK", bd->bi_sclk);
- print_num("boot_params", (ulong)bd->bi_boot_params);
- print_num("memstart", (ulong)bd->bi_memstart);
- print_lnum("memsize", (u64)bd->bi_memsize);
- print_num("flashstart", (ulong)bd->bi_flashstart);
- print_num("flashsize", (ulong)bd->bi_flashsize);
- print_num("flashoffset", (ulong)bd->bi_flashoffset);
-
- print_eth(0);
- printf("ip_addr = %s\n", getenv("ipaddr"));
- printf("baudrate = %u bps\n", gd->baudrate);
+ print_std_bdinfo(bd);
return 0;
}
@@ -329,18 +360,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
- bd_t *bd = gd->bd;
-
- print_num("boot_params", (ulong)bd->bi_boot_params);
- print_num("memstart", (ulong)bd->bi_memstart);
- print_lnum("memsize", (u64)bd->bi_memsize);
- print_num("flashstart", (ulong)bd->bi_flashstart);
- print_num("flashsize", (ulong)bd->bi_flashsize);
- print_num("flashoffset", (ulong)bd->bi_flashoffset);
-
- print_eth(0);
- printf("ip_addr = %s\n", getenv("ipaddr"));
- printf("baudrate = %u bps\n", gd->baudrate);
+ print_std_bdinfo(gd->bd);
print_num("relocaddr", gd->relocaddr);
print_num("reloc off", gd->reloc_off);
@@ -351,19 +371,7 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
- bd_t *bd = gd->bd;
-
- print_num("boot_params", (ulong)bd->bi_boot_params);
- print_num("memstart", (ulong)bd->bi_dram[0].start);
- print_lnum("memsize", (u64)bd->bi_dram[0].size);
- print_num("flashstart", (ulong)bd->bi_flashstart);
- print_num("flashsize", (ulong)bd->bi_flashsize);
- print_num("flashoffset", (ulong)bd->bi_flashoffset);
-
- print_eth(0);
- printf("ip_addr = %s\n", getenv("ipaddr"));
- printf("baudrate = %u bps\n", gd->baudrate);
-
+ print_std_bdinfo(gd->bd);
return 0;
}
@@ -372,28 +380,22 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
static int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc,
char * const argv[])
{
- int i;
bd_t *bd = gd->bd;
print_num("arch_number", bd->bi_arch_number);
- print_num("boot_params", (ulong)bd->bi_boot_params);
-
- for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
- print_num("DRAM bank", i);
- print_num("-> start", bd->bi_dram[i].start);
- print_num("-> size", bd->bi_dram[i].size);
- }
+ print_bi_boot_params(bd);
+ print_bi_dram(bd);
#ifdef CONFIG_SYS_MEM_RESERVE_SECURE
- if (gd->secure_ram & MEM_RESERVE_SECURE_SECURED) {
+ if (gd->arch.secure_ram & MEM_RESERVE_SECURE_SECURED) {
print_num("Secure ram",
- gd->secure_ram & MEM_RESERVE_SECURE_ADDR_MASK);
+ gd->arch.secure_ram & MEM_RESERVE_SECURE_ADDR_MASK);
}
#endif
#if defined(CONFIG_CMD_NET) && !defined(CONFIG_DM_ETH)
print_eths();
#endif
- printf("baudrate = %u bps\n", gd->baudrate);
+ print_baudrate();
#if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
print_num("TLB addr", gd->arch.tlb_addr);
#endif
@@ -416,6 +418,11 @@ static int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc,
#ifdef CONFIG_BOARD_TYPES
printf("Board Type = %ld\n", gd->board_type);
#endif
+#ifdef CONFIG_SYS_MALLOC_F
+ printf("Early malloc usage: %lx / %x\n", gd->malloc_ptr,
+ CONFIG_SYS_MALLOC_F_LEN);
+#endif
+
return 0;
}
@@ -424,17 +431,11 @@ static int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc,
int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
bd_t *bd = gd->bd;
- print_num("mem start ", (ulong)bd->bi_memstart);
- print_lnum("mem size ", (u64)bd->bi_memsize);
- print_num("flash start ", (ulong)bd->bi_flashstart);
- print_num("flash size ", (ulong)bd->bi_flashsize);
- print_num("flash offset ", (ulong)bd->bi_flashoffset);
-#if defined(CONFIG_CMD_NET)
- print_eth(0);
- printf("ip_addr = %s\n", getenv("ipaddr"));
-#endif
- printf("baudrate = %u bps\n", gd->baudrate);
+ print_bi_mem(bd);
+ print_bi_flash(bd);
+ print_eth_ip_addr();
+ print_baudrate();
return 0;
}
@@ -442,33 +443,17 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
- int i;
bd_t *bd = gd->bd;
- print_num("boot_params", (ulong)bd->bi_boot_params);
- print_num("bi_memstart", bd->bi_memstart);
- print_num("bi_memsize", bd->bi_memsize);
- print_num("bi_flashstart", bd->bi_flashstart);
- print_num("bi_flashsize", bd->bi_flashsize);
- print_num("bi_flashoffset", bd->bi_flashoffset);
- print_num("bi_sramstart", bd->bi_sramstart);
- print_num("bi_sramsize", bd->bi_sramsize);
- print_num("bi_bootflags", bd->bi_bootflags);
- print_mhz("cpufreq", bd->bi_intfreq);
- print_mhz("busfreq", bd->bi_busfreq);
+ print_bi_boot_params(bd);
- for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
- print_num("DRAM bank", i);
- print_num("-> start", bd->bi_dram[i].start);
- print_num("-> size", bd->bi_dram[i].size);
- }
+ print_bi_dram(bd);
#if defined(CONFIG_CMD_NET)
- print_eth(0);
- printf("ip_addr = %s\n", getenv("ipaddr"));
+ print_eth_ip_addr();
print_mhz("ethspeed", bd->bi_ethspeed);
#endif
- printf("baudrate = %u bps\n", gd->baudrate);
+ print_baudrate();
return 0;
}
@@ -477,21 +462,12 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
- int i;
bd_t *bd = gd->bd;
- print_num("boot_params", (ulong)bd->bi_boot_params);
+ print_bi_boot_params(bd);
+ print_bi_dram(bd);
+ print_eth_ip_addr();
- for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
- print_num("DRAM bank", i);
- print_num("-> start", bd->bi_dram[i].start);
- print_num("-> size", bd->bi_dram[i].size);
- }
-
-#if defined(CONFIG_CMD_NET)
- print_eth(0);
- printf("ip_addr = %s\n", getenv("ipaddr"));
-#endif
#if defined(CONFIG_LCD) || defined(CONFIG_VIDEO)
print_num("FB base ", gd->fb_base);
#endif
@@ -502,23 +478,13 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
- int i;
bd_t *bd = gd->bd;
print_num("arch_number", bd->bi_arch_number);
- print_num("boot_params", (ulong)bd->bi_boot_params);
-
- for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
- print_num("DRAM bank", i);
- print_num("-> start", bd->bi_dram[i].start);
- print_num("-> size", bd->bi_dram[i].size);
- }
-
-#if defined(CONFIG_CMD_NET)
- print_eth(0);
- printf("ip_addr = %s\n", getenv("ipaddr"));
-#endif
- printf("baudrate = %u bps\n", gd->baudrate);
+ print_bi_boot_params(bd);
+ print_bi_dram(bd);
+ print_eth_ip_addr();
+ print_baudrate();
return 0;
}
@@ -529,18 +495,10 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
bd_t *bd = gd->bd;
- print_num("mem start", (ulong)bd->bi_memstart);
- print_lnum("mem size", (u64)bd->bi_memsize);
- print_num("flash start", (ulong)bd->bi_flashstart);
- print_num("flash size", (ulong)bd->bi_flashsize);
- print_num("flash offset", (ulong)bd->bi_flashoffset);
-
-#if defined(CONFIG_CMD_NET)
- print_eth(0);
- printf("ip_addr = %s\n", getenv("ipaddr"));
-#endif
-
- printf("baudrate = %u bps\n", gd->baudrate);
+ print_bi_mem(bd);
+ print_bi_flash(bd);
+ print_eth_ip_addr();
+ print_baudrate();
return 0;
}
@@ -551,15 +509,18 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
bd_t *bd = gd->bd;
- print_num("mem start", bd->bi_memstart);
- print_lnum("mem size", bd->bi_memsize);
+ print_bi_mem(bd);
+ print_eth_ip_addr();
+ print_baudrate();
-#if defined(CONFIG_CMD_NET)
- print_eth(0);
- printf("ip_addr = %s\n", getenv("ipaddr"));
-#endif
- printf("baudrate = %d bps\n", gd->baudrate);
+ return 0;
+}
+#elif defined(CONFIG_XTENSA)
+
+int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+ print_std_bdinfo(gd->bd);
return 0;
}
diff --git a/cmd/blob.c b/cmd/blob.c
index ac8b268e0b8..bdd4cfda0b3 100644
--- a/cmd/blob.c
+++ b/cmd/blob.c
@@ -54,7 +54,7 @@ __weak int blob_encap(u8 *key_mod, u8 *src, u8 *dst, u32 len)
*/
static int do_blob(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
{
- uint32_t key_addr, src_addr, dst_addr, len;
+ ulong key_addr, src_addr, dst_addr, len;
uint8_t *km_ptr, *src_ptr, *dst_ptr;
int enc, ret = 0;
diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 011f62c5b1c..21fe42c2cb8 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -8,6 +8,7 @@
#include <common.h>
#include <command.h>
+#include <dm/device.h>
#include <efi_loader.h>
#include <errno.h>
#include <libfdt.h>
@@ -225,7 +226,7 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
int r = 0;
if (argc < 2)
- return 1;
+ return CMD_RET_USAGE;
saddr = argv[1];
addr = simple_strtoul(saddr, NULL, 16);
@@ -265,18 +266,30 @@ void efi_set_bootdev(const char *dev, const char *devnr, const char *path)
char devname[32] = { 0 }; /* dp->str is u16[32] long */
char *colon;
- /* Assemble the condensed device name we use in efi_disk.c */
- snprintf(devname, sizeof(devname), "%s%s", dev, devnr);
+#if defined(CONFIG_BLK) || defined(CONFIG_ISO_PARTITION)
+ desc = blk_get_dev(dev, simple_strtol(devnr, NULL, 10));
+#endif
+
+#ifdef CONFIG_BLK
+ if (desc) {
+ snprintf(devname, sizeof(devname), "%s", desc->bdev->name);
+ } else
+#endif
+
+ {
+ /* Assemble the condensed device name we use in efi_disk.c */
+ snprintf(devname, sizeof(devname), "%s%s", dev, devnr);
+ }
+
colon = strchr(devname, ':');
#ifdef CONFIG_ISO_PARTITION
/* For ISOs we create partition block devices */
- desc = blk_get_dev(dev, simple_strtol(devnr, NULL, 10));
if (desc && (desc->type != DEV_TYPE_UNKNOWN) &&
(desc->part_type == PART_TYPE_ISO)) {
if (!colon)
- snprintf(devname, sizeof(devname), "%s%s:1", dev,
- devnr);
+ snprintf(devname, sizeof(devname), "%s:1", devname);
+
colon = NULL;
}
#endif
@@ -290,6 +303,11 @@ void efi_set_bootdev(const char *dev, const char *devnr, const char *path)
/* Patch bootefi_image_path to the target file path */
memset(bootefi_image_path[0].str, 0, sizeof(bootefi_image_path[0].str));
- snprintf(devname, sizeof(devname), "%s", path);
+ if (strcmp(dev, "Net")) {
+ /* Add leading / to fs paths, because they're absolute */
+ snprintf(devname, sizeof(devname), "/%s", path);
+ } else {
+ snprintf(devname, sizeof(devname), "%s", path);
+ }
ascii2unicode(bootefi_image_path[0].str, devname);
}
diff --git a/cmd/booti.c b/cmd/booti.c
new file mode 100644
index 00000000000..6c1c998a568
--- /dev/null
+++ b/cmd/booti.c
@@ -0,0 +1,161 @@
+/*
+ * (C) Copyright 2000-2009
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+#include <bootm.h>
+#include <command.h>
+#include <image.h>
+#include <lmb.h>
+#include <mapmem.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/* See Documentation/arm64/booting.txt in the Linux kernel */
+struct Image_header {
+ uint32_t code0; /* Executable code */
+ uint32_t code1; /* Executable code */
+ uint64_t text_offset; /* Image load offset, LE */
+ uint64_t image_size; /* Effective Image size, LE */
+ uint64_t res1; /* reserved */
+ uint64_t res2; /* reserved */
+ uint64_t res3; /* reserved */
+ uint64_t res4; /* reserved */
+ uint32_t magic; /* Magic number */
+ uint32_t res5;
+};
+
+#define LINUX_ARM64_IMAGE_MAGIC 0x644d5241
+
+static int booti_setup(bootm_headers_t *images)
+{
+ struct Image_header *ih;
+ uint64_t dst;
+ uint64_t image_size;
+
+ ih = (struct Image_header *)map_sysmem(images->ep, 0);
+
+ if (ih->magic != le32_to_cpu(LINUX_ARM64_IMAGE_MAGIC)) {
+ puts("Bad Linux ARM64 Image magic!\n");
+ return 1;
+ }
+
+ if (ih->image_size == 0) {
+ puts("Image lacks image_size field, assuming 16MiB\n");
+ image_size = 16 << 20;
+ } else {
+ image_size = le64_to_cpu(ih->image_size);
+ }
+
+ /*
+ * If we are not at the correct run-time location, set the new
+ * correct location and then move the image there.
+ */
+ dst = gd->bd->bi_dram[0].start + le64_to_cpu(ih->text_offset);
+
+ unmap_sysmem(ih);
+
+ if (images->ep != dst) {
+ void *src;
+
+ debug("Moving Image from 0x%lx to 0x%llx\n", images->ep, dst);
+
+ src = (void *)images->ep;
+ images->ep = dst;
+ memmove((void *)dst, src, image_size);
+ }
+
+ return 0;
+}
+
+/*
+ * Image booting support
+ */
+static int booti_start(cmd_tbl_t *cmdtp, int flag, int argc,
+ char * const argv[], bootm_headers_t *images)
+{
+ int ret;
+ struct Image_header *ih;
+
+ ret = do_bootm_states(cmdtp, flag, argc, argv, BOOTM_STATE_START,
+ images, 1);
+
+ /* Setup Linux kernel Image entry point */
+ if (!argc) {
+ images->ep = load_addr;
+ debug("* kernel: default image load address = 0x%08lx\n",
+ load_addr);
+ } else {
+ images->ep = simple_strtoul(argv[0], NULL, 16);
+ debug("* kernel: cmdline image address = 0x%08lx\n",
+ images->ep);
+ }
+
+ ret = booti_setup(images);
+ if (ret != 0)
+ return 1;
+
+ ih = (struct Image_header *)map_sysmem(images->ep, 0);
+
+ lmb_reserve(&images->lmb, images->ep, le32_to_cpu(ih->image_size));
+
+ unmap_sysmem(ih);
+
+ /*
+ * Handle the BOOTM_STATE_FINDOTHER state ourselves as we do not
+ * have a header that provide this informaiton.
+ */
+ if (bootm_find_images(flag, argc, argv))
+ return 1;
+
+ return 0;
+}
+
+int do_booti(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+ int ret;
+
+ /* Consume 'booti' */
+ argc--; argv++;
+
+ if (booti_start(cmdtp, flag, argc, argv, &images))
+ return 1;
+
+ /*
+ * We are doing the BOOTM_STATE_LOADOS state ourselves, so must
+ * disable interrupts ourselves
+ */
+ bootm_disable_interrupts();
+
+ images.os.os = IH_OS_LINUX;
+ ret = do_bootm_states(cmdtp, flag, argc, argv,
+ BOOTM_STATE_OS_PREP | BOOTM_STATE_OS_FAKE_GO |
+ BOOTM_STATE_OS_GO,
+ &images, 1);
+
+ return ret;
+}
+
+#ifdef CONFIG_SYS_LONGHELP
+static char booti_help_text[] =
+ "[addr [initrd[:size]] [fdt]]\n"
+ " - boot arm64 Linux Image stored in memory\n"
+ "\tThe argument 'initrd' is optional and specifies the address\n"
+ "\tof an initrd in memory. The optional parameter ':size' allows\n"
+ "\tspecifying the size of a RAW initrd.\n"
+#if defined(CONFIG_OF_LIBFDT)
+ "\tSince booting a Linux kernel requires a flat device-tree, a\n"
+ "\tthird argument providing the address of the device-tree blob\n"
+ "\tis required. To boot a kernel with a device-tree blob but\n"
+ "\twithout an initrd image, use a '-' for the initrd argument.\n"
+#endif
+ "";
+#endif
+
+U_BOOT_CMD(
+ booti, CONFIG_SYS_MAXARGS, 1, do_booti,
+ "boot arm64 Linux Image image from memory", booti_help_text
+);
diff --git a/cmd/bootm.c b/cmd/bootm.c
index 16fdea5507b..e02a1c54b70 100644
--- a/cmd/bootm.c
+++ b/cmd/bootm.c
@@ -14,12 +14,9 @@
#include <environment.h>
#include <errno.h>
#include <image.h>
-#include <lmb.h>
#include <malloc.h>
-#include <mapmem.h>
#include <nand.h>
#include <asm/byteorder.h>
-#include <linux/compiler.h>
#include <linux/ctype.h>
#include <linux/err.h>
#include <u-boot/zlib.h>
@@ -40,8 +37,6 @@ extern flash_info_t flash_info[]; /* info for FLASH chips */
static int do_imls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
#endif
-bootm_headers_t images; /* pointers to os/initrd/fdt images */
-
/* we overload the cmd field with our state machine info instead of a
* function pointer */
static cmd_tbl_t cmd_bootm_sub[] = {
@@ -540,248 +535,3 @@ U_BOOT_CMD(
" boundaries in nor/nand flash."
);
#endif
-
-#ifdef CONFIG_CMD_BOOTZ
-
-int __weak bootz_setup(ulong image, ulong *start, ulong *end)
-{
- /* Please define bootz_setup() for your platform */
-
- puts("Your platform's zImage format isn't supported yet!\n");
- return -1;
-}
-
-/*
- * zImage booting support
- */
-static int bootz_start(cmd_tbl_t *cmdtp, int flag, int argc,
- char * const argv[], bootm_headers_t *images)
-{
- int ret;
- ulong zi_start, zi_end;
-
- ret = do_bootm_states(cmdtp, flag, argc, argv, BOOTM_STATE_START,
- images, 1);
-
- /* Setup Linux kernel zImage entry point */
- if (!argc) {
- images->ep = load_addr;
- debug("* kernel: default image load address = 0x%08lx\n",
- load_addr);
- } else {
- images->ep = simple_strtoul(argv[0], NULL, 16);
- debug("* kernel: cmdline image address = 0x%08lx\n",
- images->ep);
- }
-
- ret = bootz_setup(images->ep, &zi_start, &zi_end);
- if (ret != 0)
- return 1;
-
- lmb_reserve(&images->lmb, images->ep, zi_end - zi_start);
-
- /*
- * Handle the BOOTM_STATE_FINDOTHER state ourselves as we do not
- * have a header that provide this informaiton.
- */
- if (bootm_find_images(flag, argc, argv))
- return 1;
-
- return 0;
-}
-
-int do_bootz(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
-{
- int ret;
-
- /* Consume 'bootz' */
- argc--; argv++;
-
- if (bootz_start(cmdtp, flag, argc, argv, &images))
- return 1;
-
- /*
- * We are doing the BOOTM_STATE_LOADOS state ourselves, so must
- * disable interrupts ourselves
- */
- bootm_disable_interrupts();
-
- images.os.os = IH_OS_LINUX;
- ret = do_bootm_states(cmdtp, flag, argc, argv,
- BOOTM_STATE_OS_PREP | BOOTM_STATE_OS_FAKE_GO |
- BOOTM_STATE_OS_GO,
- &images, 1);
-
- return ret;
-}
-
-#ifdef CONFIG_SYS_LONGHELP
-static char bootz_help_text[] =
- "[addr [initrd[:size]] [fdt]]\n"
- " - boot Linux zImage stored in memory\n"
- "\tThe argument 'initrd' is optional and specifies the address\n"
- "\tof the initrd in memory. The optional argument ':size' allows\n"
- "\tspecifying the size of RAW initrd.\n"
-#if defined(CONFIG_OF_LIBFDT)
- "\tWhen booting a Linux kernel which requires a flat device-tree\n"
- "\ta third argument is required which is the address of the\n"
- "\tdevice-tree blob. To boot that kernel without an initrd image,\n"
- "\tuse a '-' for the second argument. If you do not pass a third\n"
- "\ta bd_info struct will be passed instead\n"
-#endif
- "";
-#endif
-
-U_BOOT_CMD(
- bootz, CONFIG_SYS_MAXARGS, 1, do_bootz,
- "boot Linux zImage image from memory", bootz_help_text
-);
-#endif /* CONFIG_CMD_BOOTZ */
-
-#ifdef CONFIG_CMD_BOOTI
-/* See Documentation/arm64/booting.txt in the Linux kernel */
-struct Image_header {
- uint32_t code0; /* Executable code */
- uint32_t code1; /* Executable code */
- uint64_t text_offset; /* Image load offset, LE */
- uint64_t image_size; /* Effective Image size, LE */
- uint64_t res1; /* reserved */
- uint64_t res2; /* reserved */
- uint64_t res3; /* reserved */
- uint64_t res4; /* reserved */
- uint32_t magic; /* Magic number */
- uint32_t res5;
-};
-
-#define LINUX_ARM64_IMAGE_MAGIC 0x644d5241
-
-static int booti_setup(bootm_headers_t *images)
-{
- struct Image_header *ih;
- uint64_t dst;
- uint64_t image_size;
-
- ih = (struct Image_header *)map_sysmem(images->ep, 0);
-
- if (ih->magic != le32_to_cpu(LINUX_ARM64_IMAGE_MAGIC)) {
- puts("Bad Linux ARM64 Image magic!\n");
- return 1;
- }
-
- if (ih->image_size == 0) {
- puts("Image lacks image_size field, assuming 16MiB\n");
- image_size = 16 << 20;
- } else {
- image_size = le64_to_cpu(ih->image_size);
- }
-
- /*
- * If we are not at the correct run-time location, set the new
- * correct location and then move the image there.
- */
- dst = gd->bd->bi_dram[0].start + le64_to_cpu(ih->text_offset);
-
- unmap_sysmem(ih);
-
- if (images->ep != dst) {
- void *src;
-
- debug("Moving Image from 0x%lx to 0x%llx\n", images->ep, dst);
-
- src = (void *)images->ep;
- images->ep = dst;
- memmove((void *)dst, src, image_size);
- }
-
- return 0;
-}
-
-/*
- * Image booting support
- */
-static int booti_start(cmd_tbl_t *cmdtp, int flag, int argc,
- char * const argv[], bootm_headers_t *images)
-{
- int ret;
- struct Image_header *ih;
-
- ret = do_bootm_states(cmdtp, flag, argc, argv, BOOTM_STATE_START,
- images, 1);
-
- /* Setup Linux kernel Image entry point */
- if (!argc) {
- images->ep = load_addr;
- debug("* kernel: default image load address = 0x%08lx\n",
- load_addr);
- } else {
- images->ep = simple_strtoul(argv[0], NULL, 16);
- debug("* kernel: cmdline image address = 0x%08lx\n",
- images->ep);
- }
-
- ret = booti_setup(images);
- if (ret != 0)
- return 1;
-
- ih = (struct Image_header *)map_sysmem(images->ep, 0);
-
- lmb_reserve(&images->lmb, images->ep, le32_to_cpu(ih->image_size));
-
- unmap_sysmem(ih);
-
- /*
- * Handle the BOOTM_STATE_FINDOTHER state ourselves as we do not
- * have a header that provide this informaiton.
- */
- if (bootm_find_images(flag, argc, argv))
- return 1;
-
- return 0;
-}
-
-int do_booti(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
-{
- int ret;
-
- /* Consume 'booti' */
- argc--; argv++;
-
- if (booti_start(cmdtp, flag, argc, argv, &images))
- return 1;
-
- /*
- * We are doing the BOOTM_STATE_LOADOS state ourselves, so must
- * disable interrupts ourselves
- */
- bootm_disable_interrupts();
-
- images.os.os = IH_OS_LINUX;
- ret = do_bootm_states(cmdtp, flag, argc, argv,
- BOOTM_STATE_OS_PREP | BOOTM_STATE_OS_FAKE_GO |
- BOOTM_STATE_OS_GO,
- &images, 1);
-
- return ret;
-}
-
-#ifdef CONFIG_SYS_LONGHELP
-static char booti_help_text[] =
- "[addr [initrd[:size]] [fdt]]\n"
- " - boot arm64 Linux Image stored in memory\n"
- "\tThe argument 'initrd' is optional and specifies the address\n"
- "\tof an initrd in memory. The optional parameter ':size' allows\n"
- "\tspecifying the size of a RAW initrd.\n"
-#if defined(CONFIG_OF_LIBFDT)
- "\tSince booting a Linux kernel requires a flat device-tree, a\n"
- "\tthird argument providing the address of the device-tree blob\n"
- "\tis required. To boot a kernel with a device-tree blob but\n"
- "\twithout an initrd image, use a '-' for the initrd argument.\n"
-#endif
- "";
-#endif
-
-U_BOOT_CMD(
- booti, CONFIG_SYS_MAXARGS, 1, do_booti,
- "boot arm64 Linux Image image from memory", booti_help_text
-);
-#endif /* CONFIG_CMD_BOOTI */
diff --git a/cmd/bootz.c b/cmd/bootz.c
new file mode 100644
index 00000000000..9648fe9948d
--- /dev/null
+++ b/cmd/bootz.c
@@ -0,0 +1,106 @@
+/*
+ * (C) Copyright 2000-2009
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+#include <bootm.h>
+#include <command.h>
+#include <lmb.h>
+#include <linux/compiler.h>
+
+int __weak bootz_setup(ulong image, ulong *start, ulong *end)
+{
+ /* Please define bootz_setup() for your platform */
+
+ puts("Your platform's zImage format isn't supported yet!\n");
+ return -1;
+}
+
+/*
+ * zImage booting support
+ */
+static int bootz_start(cmd_tbl_t *cmdtp, int flag, int argc,
+ char * const argv[], bootm_headers_t *images)
+{
+ int ret;
+ ulong zi_start, zi_end;
+
+ ret = do_bootm_states(cmdtp, flag, argc, argv, BOOTM_STATE_START,
+ images, 1);
+
+ /* Setup Linux kernel zImage entry point */
+ if (!argc) {
+ images->ep = load_addr;
+ debug("* kernel: default image load address = 0x%08lx\n",
+ load_addr);
+ } else {
+ images->ep = simple_strtoul(argv[0], NULL, 16);
+ debug("* kernel: cmdline image address = 0x%08lx\n",
+ images->ep);
+ }
+
+ ret = bootz_setup(images->ep, &zi_start, &zi_end);
+ if (ret != 0)
+ return 1;
+
+ lmb_reserve(&images->lmb, images->ep, zi_end - zi_start);
+
+ /*
+ * Handle the BOOTM_STATE_FINDOTHER state ourselves as we do not
+ * have a header that provide this informaiton.
+ */
+ if (bootm_find_images(flag, argc, argv))
+ return 1;
+
+ return 0;
+}
+
+int do_bootz(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+ int ret;
+
+ /* Consume 'bootz' */
+ argc--; argv++;
+
+ if (bootz_start(cmdtp, flag, argc, argv, &images))
+ return 1;
+
+ /*
+ * We are doing the BOOTM_STATE_LOADOS state ourselves, so must
+ * disable interrupts ourselves
+ */
+ bootm_disable_interrupts();
+
+ images.os.os = IH_OS_LINUX;
+ ret = do_bootm_states(cmdtp, flag, argc, argv,
+ BOOTM_STATE_OS_PREP | BOOTM_STATE_OS_FAKE_GO |
+ BOOTM_STATE_OS_GO,
+ &images, 1);
+
+ return ret;
+}
+
+#ifdef CONFIG_SYS_LONGHELP
+static char bootz_help_text[] =
+ "[addr [initrd[:size]] [fdt]]\n"
+ " - boot Linux zImage stored in memory\n"
+ "\tThe argument 'initrd' is optional and specifies the address\n"
+ "\tof the initrd in memory. The optional argument ':size' allows\n"
+ "\tspecifying the size of RAW initrd.\n"
+#if defined(CONFIG_OF_LIBFDT)
+ "\tWhen booting a Linux kernel which requires a flat device-tree\n"
+ "\ta third argument is required which is the address of the\n"
+ "\tdevice-tree blob. To boot that kernel without an initrd image,\n"
+ "\tuse a '-' for the second argument. If you do not pass a third\n"
+ "\ta bd_info struct will be passed instead\n"
+#endif
+ "";
+#endif
+
+U_BOOT_CMD(
+ bootz, CONFIG_SYS_MAXARGS, 1, do_bootz,
+ "boot Linux zImage image from memory", bootz_help_text
+);
diff --git a/cmd/fastboot/Kconfig b/cmd/fastboot/Kconfig
new file mode 100644
index 00000000000..a93d1c09e71
--- /dev/null
+++ b/cmd/fastboot/Kconfig
@@ -0,0 +1,60 @@
+comment "FASTBOOT"
+
+config FASTBOOT
+ bool ""
+
+menu "Fastboot support"
+ depends on FASTBOOT
+
+config USB_FUNCTION_FASTBOOT
+ bool "Enable USB fastboot gadget"
+ help
+ This enables the USB part of the fastboot gadget.
+
+config CMD_FASTBOOT
+ bool "Enable FASTBOOT command"
+ help
+ This enables the command "fastboot" which enables the Android
+ fastboot mode for the platform's USB device. Fastboot is a USB
+ protocol for downloading images, flashing and device control
+ used on Android devices.
+
+config ANDROID_BOOT_IMAGE
+ bool "Enable support for Android Boot Images"
+ help
+ This enables support for booting images which use the Android
+ image format header.
+
+if USB_FUNCTION_FASTBOOT
+
+config FASTBOOT_BUF_ADDR
+ hex "Define FASTBOOT buffer address"
+ help
+ The fastboot protocol requires a large memory buffer for
+ downloads. Define this to the starting RAM address to use for
+ downloaded images.
+
+config FASTBOOT_BUF_SIZE
+ hex "Define FASTBOOT buffer size"
+ help
+ The fastboot protocol requires a large memory buffer for
+ downloads. This buffer should be as large as possible for a
+ platform. Define this to the size available RAM for fastboot.
+
+config FASTBOOT_FLASH
+ bool "Enable FASTBOOT FLASH command"
+ help
+ The fastboot protocol includes a "flash" command for writing
+ the downloaded image to a non-volatile storage device. Define
+ this to enable the "fastboot flash" command.
+
+config FASTBOOT_FLASH_MMC_DEV
+ int "Define FASTBOOT MMC FLASH default device"
+ help
+ The fastboot "flash" command requires additional information
+ regarding the non-volatile storage device. Define this to
+ the eMMC device that fastboot should use to store the image.
+
+endif # USB_FUNCTION_FASTBOOT
+
+endmenu
diff --git a/cmd/fdt.c b/cmd/fdt.c
index 898217ffe5f..58af7727ba0 100644
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -87,7 +87,7 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
/*
* Set the address of the fdt
*/
- if (argv[1][0] == 'a') {
+ if (strncmp(argv[1], "ad", 2) == 0) {
unsigned long addr;
int control = 0;
struct fdt_header *blob;
@@ -639,6 +639,27 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
#endif
}
+#ifdef CONFIG_OF_LIBFDT_OVERLAY
+ /* apply an overlay */
+ else if (strncmp(argv[1], "ap", 2) == 0) {
+ unsigned long addr;
+ struct fdt_header *blob;
+
+ if (argc != 3)
+ return CMD_RET_USAGE;
+
+ if (!working_fdt)
+ return CMD_RET_FAILURE;
+
+ addr = simple_strtoul(argv[2], NULL, 16);
+ blob = map_sysmem(addr, 0);
+ if (!fdt_valid(&blob))
+ return CMD_RET_FAILURE;
+
+ if (fdt_overlay_apply(working_fdt, blob))
+ return CMD_RET_FAILURE;
+ }
+#endif
/* resize the fdt */
else if (strncmp(argv[1], "re", 2) == 0) {
fdt_shrink_to_minimum(working_fdt);
@@ -1025,6 +1046,9 @@ static int fdt_print(const char *pathp, char *prop, int depth)
#ifdef CONFIG_SYS_LONGHELP
static char fdt_help_text[] =
"addr [-c] <addr> [<length>] - Set the [control] fdt location to <addr>\n"
+#ifdef CONFIG_OF_LIBFDT_OVERLAY
+ "fdt apply <addr> - Apply overlay to the DT\n"
+#endif
#ifdef CONFIG_OF_BOARD_SETUP
"fdt boardsetup - Do board-specific set up\n"
#endif
diff --git a/cmd/gpt.c b/cmd/gpt.c
index 3d9706b679c..897596a969f 100644
--- a/cmd/gpt.c
+++ b/cmd/gpt.c
@@ -298,8 +298,8 @@ static int set_gpt_info(struct blk_desc *dev_desc,
if (extract_env(val, &p))
p = val;
if ((strcmp(p, "-") == 0)) {
- /* remove first usable lba and last block */
- parts[i].size = dev_desc->lba - 34 - 1 - offset;
+ /* Let part efi module to auto extend the size */
+ parts[i].size = 0;
} else {
size_ll = ustrtoull(p, &p, 0);
parts[i].size = lldiv(size_ll, dev_desc->blksz);
diff --git a/cmd/i2c.c b/cmd/i2c.c
index 18ce789d7ed..473153fbd47 100644
--- a/cmd/i2c.c
+++ b/cmd/i2c.c
@@ -178,7 +178,7 @@ static int i2c_get_cur_bus_chip(uint chip_addr, struct udevice **devp)
* i2c_init_board() - Board-specific I2C bus init
*
* This function is the default no-op implementation of I2C bus
- * initialization. This function can be overriden by board-specific
+ * initialization. This function can be overridden by board-specific
* implementation if needed.
*/
__weak
diff --git a/cmd/lzmadec.c b/cmd/lzmadec.c
index 1ad9ed6ce96..c78df825e84 100644
--- a/cmd/lzmadec.c
+++ b/cmd/lzmadec.c
@@ -20,7 +20,7 @@
static int do_lzmadec(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
{
unsigned long src, dst;
- unsigned long src_len = ~0UL, dst_len = ~0UL;
+ SizeT src_len = ~0UL, dst_len = ~0UL;
int ret;
switch (argc) {
@@ -40,7 +40,8 @@ static int do_lzmadec(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
if (ret != SZ_OK)
return 1;
- printf("Uncompressed size: %ld = 0x%lX\n", src_len, src_len);
+ printf("Uncompressed size: %ld = %#lX\n", (ulong)src_len,
+ (ulong)src_len);
setenv_hex("filesize", src_len);
return 0;
diff --git a/cmd/misc.c b/cmd/misc.c
index 39d86835cff..efcbb90d18d 100644
--- a/cmd/misc.c
+++ b/cmd/misc.c
@@ -15,13 +15,31 @@
static int do_sleep(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
ulong start = get_timer(0);
+ ulong mdelay = 0;
ulong delay;
+ char *frpart;
if (argc != 2)
return CMD_RET_USAGE;
delay = simple_strtoul(argv[1], NULL, 10) * CONFIG_SYS_HZ;
+ frpart = strchr(argv[1], '.');
+
+ if (frpart) {
+ uint mult = CONFIG_SYS_HZ / 10;
+ for (frpart++; *frpart != '\0' && mult > 0; frpart++) {
+ if (*frpart < '0' || *frpart > '9') {
+ mdelay = 0;
+ break;
+ }
+ mdelay += (*frpart - '0') * mult;
+ mult /= 10;
+ }
+ }
+
+ delay += mdelay;
+
while (get_timer(start) < delay) {
if (ctrlc())
return (-1);
@@ -36,7 +54,8 @@ U_BOOT_CMD(
sleep , 2, 1, do_sleep,
"delay execution for some time",
"N\n"
- " - delay execution for N seconds (N is _decimal_ !!!)"
+ " - delay execution for N seconds (N is _decimal_ and can be\n"
+ " fractional)"
);
#ifdef CONFIG_CMD_TIMER
diff --git a/cmd/mtdparts.c b/cmd/mtdparts.c
index 44b2c3a5a9f..b9b160dc1e2 100644
--- a/cmd/mtdparts.c
+++ b/cmd/mtdparts.c
@@ -109,17 +109,17 @@ DECLARE_GLOBAL_DATA_PTR;
#define MTD_WRITEABLE_CMD 1
/* default values for mtdids and mtdparts variables */
-#if defined(MTDIDS_DEFAULT)
-static const char *const mtdids_default = MTDIDS_DEFAULT;
-#else
-static const char *const mtdids_default = NULL;
+#if !defined(MTDIDS_DEFAULT)
+#define MTDIDS_DEFAULT NULL
#endif
-
-#if defined(MTDPARTS_DEFAULT)
-static const char *const mtdparts_default = MTDPARTS_DEFAULT;
-#else
-static const char *const mtdparts_default = NULL;
+#if !defined(MTDPARTS_DEFAULT)
+#define MTDPARTS_DEFAULT NULL
+#endif
+#if defined(CONFIG_SYS_MTDPARTS_RUNTIME)
+extern void board_mtdparts_default(const char **mtdids, const char **mtdparts);
#endif
+static const char *mtdids_default = MTDIDS_DEFAULT;
+static const char *mtdparts_default = MTDPARTS_DEFAULT;
/* copies of last seen 'mtdids', 'mtdparts' and 'partition' env variables */
#define MTDIDS_MAXLEN 128
@@ -142,6 +142,8 @@ static struct list_head devices;
struct mtd_device *current_mtd_dev = NULL;
u8 current_mtd_partnum = 0;
+u8 use_defaults;
+
static struct part_info* mtd_part_info(struct mtd_device *dev, unsigned int part_num);
/* command line only routines */
@@ -1491,7 +1493,7 @@ static int spread_partitions(void)
part = list_entry(pentry, struct part_info, link);
debug("spread_partitions: device = %s%d, partition %d ="
- " (%s) 0x%08x@0x%08x\n",
+ " (%s) 0x%08llx@0x%08llx\n",
MTD_DEV_TYPE(dev->id->type), dev->id->num,
part_num, part->name, part->size,
part->offset);
@@ -1516,6 +1518,23 @@ static int spread_partitions(void)
#endif /* CONFIG_CMD_MTDPARTS_SPREAD */
/**
+ * The mtdparts variable tends to be long. If we need to access it
+ * before the env is relocated, then we need to use our own stack
+ * buffer. gd->env_buf will be too small.
+ *
+ * @param buf temporary buffer pointer MTDPARTS_MAXLEN long
+ * @return mtdparts variable string, NULL if not found
+ */
+static const char *getenv_mtdparts(char *buf)
+{
+ if (gd->flags & GD_FLG_ENV_READY)
+ return getenv("mtdparts");
+ if (getenv_f("mtdparts", buf, MTDPARTS_MAXLEN) != -1)
+ return buf;
+ return NULL;
+}
+
+/**
* Accept character string describing mtd partitions and call device_parse()
* for each entry. Add created devices to the global devices list.
*
@@ -1524,7 +1543,7 @@ static int spread_partitions(void)
*/
static int parse_mtdparts(const char *const mtdparts)
{
- const char *p = mtdparts;
+ const char *p;
struct mtd_device *dev;
int err = 1;
char tmp_parts[MTDPARTS_MAXLEN];
@@ -1538,12 +1557,9 @@ static int parse_mtdparts(const char *const mtdparts)
}
/* re-read 'mtdparts' variable, mtd_devices_init may be updating env */
- if (gd->flags & GD_FLG_ENV_READY) {
- p = getenv("mtdparts");
- } else {
- p = tmp_parts;
- getenv_f("mtdparts", tmp_parts, MTDPARTS_MAXLEN);
- }
+ p = getenv_mtdparts(tmp_parts);
+ if (!p)
+ p = mtdparts;
if (strncmp(p, "mtdparts=", 9) != 0) {
printf("mtdparts variable doesn't start with 'mtdparts='\n");
@@ -1551,7 +1567,7 @@ static int parse_mtdparts(const char *const mtdparts)
}
p += 9;
- while (p && (*p != '\0')) {
+ while (*p != '\0') {
err = 1;
if ((device_parse(p, &p, &dev) != 0) || (!dev))
break;
@@ -1569,12 +1585,10 @@ static int parse_mtdparts(const char *const mtdparts)
list_add_tail(&dev->link, &devices);
err = 0;
}
- if (err == 1) {
+ if (err == 1)
device_delall(&devices);
- return 1;
- }
- return 0;
+ return err;
}
/**
@@ -1688,6 +1702,7 @@ static int parse_mtdids(const char *const ids)
return 0;
}
+
/**
* Parse and initialize global mtdids mapping and create global
* device/partition list.
@@ -1710,22 +1725,16 @@ int mtdparts_init(void)
memset(last_ids, 0, MTDIDS_MAXLEN);
memset(last_parts, 0, MTDPARTS_MAXLEN);
memset(last_partition, 0, PARTITION_MAXLEN);
+#if defined(CONFIG_SYS_MTDPARTS_RUNTIME)
+ board_mtdparts_default(&mtdids_default, &mtdparts_default);
+#endif
+ use_defaults = 1;
initialized = 1;
}
/* get variables */
ids = getenv("mtdids");
- /*
- * The mtdparts variable tends to be long. If we need to access it
- * before the env is relocated, then we need to use our own stack
- * buffer. gd->env_buf will be too small.
- */
- if (gd->flags & GD_FLG_ENV_READY) {
- parts = getenv("mtdparts");
- } else {
- parts = tmp_parts;
- getenv_f("mtdparts", tmp_parts, MTDPARTS_MAXLEN);
- }
+ parts = getenv_mtdparts(tmp_parts);
current_partition = getenv("partition");
/* save it for later parsing, cannot rely on current partition pointer
@@ -1758,10 +1767,16 @@ int mtdparts_init(void)
return 1;
}
- /* do no try to use defaults when mtdparts variable is not defined,
- * just check the length */
- if (!parts)
- printf("mtdparts variable not set, see 'help mtdparts'\n");
+ /* use defaults when mtdparts variable is not defined
+ * once mtdparts is saved environment, drop use_defaults flag */
+ if (!parts) {
+ if (mtdparts_default && use_defaults) {
+ parts = mtdparts_default;
+ if (setenv("mtdparts", (char *)parts) == 0)
+ use_defaults = 0;
+ } else
+ printf("mtdparts variable not set, see 'help mtdparts'\n");
+ }
if (parts && (strlen(parts) > MTDPARTS_MAXLEN - 1)) {
printf("mtdparts too long (> %d)\n", MTDPARTS_MAXLEN);
@@ -1933,9 +1948,10 @@ static int do_mtdparts(cmd_tbl_t *cmdtp, int flag, int argc,
{
if (argc == 2) {
if (strcmp(argv[1], "default") == 0) {
- setenv("mtdids", (char *)mtdids_default);
- setenv("mtdparts", (char *)mtdparts_default);
+ setenv("mtdids", NULL);
+ setenv("mtdparts", NULL);
setenv("partition", NULL);
+ use_defaults = 1;
mtdparts_init();
return 0;
@@ -2009,7 +2025,7 @@ static int do_mtdparts(cmd_tbl_t *cmdtp, int flag, int argc,
if (!strcmp(&argv[1][3], ".spread")) {
spread_partition(mtd, p, &next_offset);
- debug("increased %s to %d bytes\n", p->name, p->size);
+ debug("increased %s to %llu bytes\n", p->name, p->size);
}
#endif
diff --git a/cmd/nand.c b/cmd/nand.c
index ffdeea41a5a..e10349ac2be 100644
--- a/cmd/nand.c
+++ b/cmd/nand.c
@@ -306,7 +306,7 @@ static void nand_print_and_set_info(int idx)
}
static int raw_access(struct mtd_info *mtd, ulong addr, loff_t off,
- ulong count, int read)
+ ulong count, int read, int no_verify)
{
int ret = 0;
@@ -324,7 +324,7 @@ static int raw_access(struct mtd_info *mtd, ulong addr, loff_t off,
ret = mtd_read_oob(mtd, off, &ops);
} else {
ret = mtd_write_oob(mtd, off, &ops);
- if (!ret)
+ if (!ret && !no_verify)
ret = nand_verify_page_oob(mtd, &ops, off);
}
@@ -546,6 +546,7 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
ulong pagecount = 1;
int read;
int raw = 0;
+ int no_verify = 0;
if (argc < 4)
goto usage;
@@ -557,9 +558,12 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
s = strchr(cmd, '.');
- if (s && !strcmp(s, ".raw")) {
+ if (s && !strncmp(s, ".raw", 4)) {
raw = 1;
+ if (!strcmp(s, ".raw.noverify"))
+ no_verify = 1;
+
if (mtd_arg_off(argv[3], &dev, &off, &size, &maxsize,
MTD_DEV_TYPE_NAND,
nand_info[dev]->size))
@@ -633,7 +637,8 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
else
ret = mtd_write_oob(mtd, off, &ops);
} else if (raw) {
- ret = raw_access(mtd, addr, off, pagecount, read);
+ ret = raw_access(mtd, addr, off, pagecount, read,
+ no_verify);
} else {
printf("Unknown nand command suffix '%s'.\n", s);
return 1;
@@ -786,7 +791,7 @@ static char nand_help_text[] =
" 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 - addr off|partition [count]\n"
+ "nand write.raw[.noverify] - addr off|partition [count]\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"
diff --git a/cmd/sf.c b/cmd/sf.c
index 42862d9d921..286906c3a15 100644
--- a/cmd/sf.c
+++ b/cmd/sf.c
@@ -88,6 +88,8 @@ static int do_spi_flash_probe(int argc, char * const argv[])
#ifdef CONFIG_DM_SPI_FLASH
struct udevice *new, *bus_dev;
int ret;
+ /* In DM mode defaults will be taken from DT */
+ speed = 0, mode = 0;
#else
struct spi_flash *new;
#endif
diff --git a/cmd/usb_mass_storage.c b/cmd/usb_mass_storage.c
index b05913ac344..86398fc24e8 100644
--- a/cmd/usb_mass_storage.c
+++ b/cmd/usb_mass_storage.c
@@ -22,7 +22,7 @@ static int ums_read_sector(struct ums *ums_dev,
struct blk_desc *block_dev = &ums_dev->block_dev;
lbaint_t blkstart = start + ums_dev->start_sector;
- return block_dev->block_read(block_dev, blkstart, blkcnt, buf);
+ return blk_dread(block_dev, blkstart, blkcnt, buf);
}
static int ums_write_sector(struct ums *ums_dev,
@@ -31,7 +31,7 @@ static int ums_write_sector(struct ums *ums_dev,
struct blk_desc *block_dev = &ums_dev->block_dev;
lbaint_t blkstart = start + ums_dev->start_sector;
- return block_dev->block_write(block_dev, blkstart, blkcnt, buf);
+ return blk_dwrite(block_dev, blkstart, blkcnt, buf);
}
static struct ums *ums;