aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/Kconfig24
-rw-r--r--cmd/fastboot.c91
-rw-r--r--cmd/fastboot/Kconfig134
-rw-r--r--cmd/mmc.c14
4 files changed, 114 insertions, 149 deletions
diff --git a/cmd/Kconfig b/cmd/Kconfig
index c4e831e..e283cb9 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -137,8 +137,6 @@ config AUTOBOOT_STOP_STR_SHA256
endmenu
-source "cmd/fastboot/Kconfig"
-
config BUILD_BIN2C
bool
@@ -228,7 +226,7 @@ config CMD_BOOTEFI
config CMD_BOOTEFI_HELLO_COMPILE
bool "Compile a standard EFI hello world binary for testing"
- depends on CMD_BOOTEFI && (ARM || X86)
+ depends on CMD_BOOTEFI && (ARM || X86 || RISCV)
default y
help
This compiles a standard EFI hello world application with U-Boot so
@@ -650,6 +648,18 @@ config CMD_DM
can be useful to see the state of driver model for debugging or
interest.
+config CMD_FASTBOOT
+ bool "fastboot - Android fastboot support"
+ depends on FASTBOOT
+ help
+ This enables the command "fastboot" which enables the Android
+ fastboot mode for the platform. Fastboot is a protocol for
+ downloading images, flashing and device control used on
+ Android devices. Fastboot requires either the network stack
+ enabled or support for acting as a USB device.
+
+ See doc/README.android-fastboot for more information.
+
config CMD_FDC
bool "fdcboot - Boot from floppy device"
help
@@ -830,6 +840,14 @@ config CMD_MMC_RPMB
Enable the commands for reading, writing and programming the
key for the Replay Protection Memory Block partition in eMMC.
+config CMD_MMC_SWRITE
+ bool "mmc swrite"
+ depends on CMD_MMC && MMC_WRITE
+ select IMAGE_SPARSE
+ help
+ Enable support for the "mmc swrite" command to write Android sparse
+ images to eMMC.
+
config CMD_NAND
bool "nand"
default y if NAND_SUNXI
diff --git a/cmd/fastboot.c b/cmd/fastboot.c
index a5ec5f4..557257a 100644
--- a/cmd/fastboot.c
+++ b/cmd/fastboot.c
@@ -10,10 +10,32 @@
#include <command.h>
#include <console.h>
#include <g_dnl.h>
+#include <fastboot.h>
+#include <net.h>
#include <usb.h>
-static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
+static int do_fastboot_udp(int argc, char *const argv[],
+ uintptr_t buf_addr, size_t buf_size)
{
+#if CONFIG_IS_ENABLED(UDP_FUNCTION_FASTBOOT)
+ int err = net_loop(FASTBOOT);
+
+ if (err < 0) {
+ printf("fastboot udp error: %d\n", err);
+ return CMD_RET_FAILURE;
+ }
+
+ return CMD_RET_SUCCESS;
+#else
+ pr_err("Fastboot UDP not enabled\n");
+ return CMD_RET_FAILURE;
+#endif
+}
+
+static int do_fastboot_usb(int argc, char *const argv[],
+ uintptr_t buf_addr, size_t buf_size)
+{
+#if CONFIG_IS_ENABLED(USB_FUNCTION_FASTBOOT)
int controller_index;
char *usb_controller;
int ret;
@@ -58,11 +80,70 @@ exit:
board_usb_cleanup(controller_index, USB_INIT_DEVICE);
return ret;
+#else
+ pr_err("Fastboot USB not enabled\n");
+ return CMD_RET_FAILURE;
+#endif
+}
+
+static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
+{
+ uintptr_t buf_addr = (uintptr_t)NULL;
+ size_t buf_size = 0;
+
+ if (argc < 2)
+ return CMD_RET_USAGE;
+
+ while (argc > 1 && **(argv + 1) == '-') {
+ char *arg = *++argv;
+
+ --argc;
+ while (*++arg) {
+ switch (*arg) {
+ case 'l':
+ if (--argc <= 0)
+ return CMD_RET_USAGE;
+ buf_addr = simple_strtoul(*++argv, NULL, 16);
+ goto NXTARG;
+
+ case 's':
+ if (--argc <= 0)
+ return CMD_RET_USAGE;
+ buf_size = simple_strtoul(*++argv, NULL, 16);
+ goto NXTARG;
+
+ default:
+ return CMD_RET_USAGE;
+ }
+ }
+NXTARG:
+ ;
+ }
+
+ fastboot_init((void *)buf_addr, buf_size);
+
+ if (!strcmp(argv[1], "udp"))
+ return do_fastboot_udp(argc, argv, buf_addr, buf_size);
+
+ if (!strcmp(argv[1], "usb")) {
+ argv++;
+ argc--;
+ }
+
+ return do_fastboot_usb(argc, argv, buf_addr, buf_size);
}
+#ifdef CONFIG_SYS_LONGHELP
+static char fastboot_help_text[] =
+ "[-l addr] [-s size] usb <controller> | udp\n"
+ "\taddr - address of buffer used during data transfers ("
+ __stringify(CONFIG_FASTBOOT_BUF_ADDR) ")\n"
+ "\tsize - size of buffer used during data transfers ("
+ __stringify(CONFIG_FASTBOOT_BUF_SIZE) ")"
+ ;
+#endif
+
U_BOOT_CMD(
- fastboot, 2, 1, do_fastboot,
- "use USB Fastboot protocol",
- "<USB_controller>\n"
- " - run as a fastboot usb device"
+ fastboot, CONFIG_SYS_MAXARGS, 1, do_fastboot,
+ "run as a fastboot usb or udp device", fastboot_help_text
);
diff --git a/cmd/fastboot/Kconfig b/cmd/fastboot/Kconfig
deleted file mode 100644
index 0d2c2f1..0000000
--- a/cmd/fastboot/Kconfig
+++ /dev/null
@@ -1,134 +0,0 @@
-comment "FASTBOOT"
-
-menuconfig FASTBOOT
- bool "Fastboot support"
- depends on USB_GADGET
- default y if ARCH_SUNXI && USB_MUSB_GADGET
-
-if FASTBOOT
-
-config USB_FUNCTION_FASTBOOT
- bool "Enable USB fastboot gadget"
- default y
- select USB_GADGET_DOWNLOAD
- imply ANDROID_BOOT_IMAGE
- imply CMD_FASTBOOT
- 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.
-
- See doc/README.android-fastboot for more information.
-
-if USB_FUNCTION_FASTBOOT
-
-config FASTBOOT_BUF_ADDR
- hex "Define FASTBOOT buffer address"
- default 0x82000000 if MX6SX || MX6SL || MX6UL || MX6SLL
- default 0x81000000 if ARCH_OMAP2PLUS
- default 0x42000000 if ARCH_SUNXI && !MACH_SUN9I
- default 0x22000000 if ARCH_SUNXI && MACH_SUN9I
- default 0x60800800 if ROCKCHIP_RK3036 || ROCKCHIP_RK3188 || \
- ROCKCHIP_RK322X
- default 0x800800 if ROCKCHIP_RK3288 || ROCKCHIP_RK3329 || \
- ROCKCHIP_RK3399
- default 0x280000 if ROCKCHIP_RK3368
- default 0x100000 if ARCH_ZYNQMP
- 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"
- default 0x8000000 if ARCH_ROCKCHIP
- default 0x6000000 if ARCH_ZYNQMP
- default 0x2000000 if ARCH_SUNXI
- default 0x7000000
- 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_USB_DEV
- int "USB controller number"
- default 0
- help
- Some boards have USB OTG controller other than 0. Define this
- option so it can be used in compiled environment (e.g. in
- CONFIG_BOOTCOMMAND).
-
-config FASTBOOT_FLASH
- bool "Enable FASTBOOT FLASH command"
- default y if ARCH_SUNXI
- 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.
-
-choice
- prompt "Flash provider for FASTBOOT"
- depends on FASTBOOT_FLASH
-
-config FASTBOOT_FLASH_MMC
- bool "FASTBOOT on MMC"
- depends on MMC
-
-config FASTBOOT_FLASH_NAND
- bool "FASTBOOT on NAND"
- depends on NAND
-
-endchoice
-
-config FASTBOOT_FLASH_MMC_DEV
- int "Define FASTBOOT MMC FLASH default device"
- depends on FASTBOOT_FLASH_MMC
- default 0 if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA = -1
- default 1 if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA != -1
- 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.
-
-config FASTBOOT_FLASH_NAND_DEV
- int "Define FASTBOOT NAND FLASH default device"
- depends on FASTBOOT_FLASH_NAND
- depends on CMD_MTDPARTS
- default 0 if ARCH_SUNXI && NAND_SUNXI
- help
- The fastboot "flash" command requires additional information
- regarding the non-volatile storage device. Define this to
- the NAND device that fastboot should use to store the image.
-
-config FASTBOOT_GPT_NAME
- string "Target name for updating GPT"
- depends on FASTBOOT_FLASH
- default "gpt"
- help
- The fastboot "flash" command supports writing the downloaded
- image to the Protective MBR and the Primary GUID Partition
- Table. (Additionally, this downloaded image is post-processed
- to generate and write the Backup GUID Partition Table.)
- This occurs when the specified "partition name" on the
- "fastboot flash" command line matches the value defined here.
- The default target name for updating GPT is "gpt".
-
-config FASTBOOT_MBR_NAME
- string "Target name for updating MBR"
- depends on FASTBOOT_FLASH
- default "mbr"
- help
- The fastboot "flash" command allows to write the downloaded image
- to the Master Boot Record. This occurs when the "partition name"
- specified on the "fastboot flash" command line matches the value
- defined here. The default target name for updating MBR is "mbr".
-
-endif # USB_FUNCTION_FASTBOOT
-
-endif # FASTBOOT
diff --git a/cmd/mmc.c b/cmd/mmc.c
index a3357ef..c2ee2d9 100644
--- a/cmd/mmc.c
+++ b/cmd/mmc.c
@@ -308,8 +308,7 @@ static int do_mmc_read(cmd_tbl_t *cmdtp, int flag,
return (n == cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE;
}
-#if CONFIG_IS_ENABLED(MMC_WRITE)
-#if defined(CONFIG_FASTBOOT_FLASH)
+#if CONFIG_IS_ENABLED(CMD_MMC_SWRITE)
static lbaint_t mmc_sparse_write(struct sparse_storage *info, lbaint_t blk,
lbaint_t blkcnt, const void *buffer)
{
@@ -367,13 +366,14 @@ static int do_mmc_sparse_write(cmd_tbl_t *cmdtp, int flag,
sparse.mssg = NULL;
sprintf(dest, "0x" LBAF, sparse.start * sparse.blksz);
- if (write_sparse_image(&sparse, dest, addr))
+ if (write_sparse_image(&sparse, dest, addr, NULL))
return CMD_RET_FAILURE;
else
return CMD_RET_SUCCESS;
}
#endif
+#if CONFIG_IS_ENABLED(MMC_WRITE)
static int do_mmc_write(cmd_tbl_t *cmdtp, int flag,
int argc, char * const argv[])
{
@@ -868,11 +868,11 @@ static cmd_tbl_t cmd_mmc[] = {
U_BOOT_CMD_MKENT(read, 4, 1, do_mmc_read, "", ""),
#if CONFIG_IS_ENABLED(MMC_WRITE)
U_BOOT_CMD_MKENT(write, 4, 0, do_mmc_write, "", ""),
-#if defined(CONFIG_FASTBOOT_FLASH)
- U_BOOT_CMD_MKENT(swrite, 3, 0, do_mmc_sparse_write, "", ""),
-#endif
U_BOOT_CMD_MKENT(erase, 3, 0, do_mmc_erase, "", ""),
#endif
+#if CONFIG_IS_ENABLED(CMD_MMC_SWRITE)
+ U_BOOT_CMD_MKENT(swrite, 3, 0, do_mmc_sparse_write, "", ""),
+#endif
U_BOOT_CMD_MKENT(rescan, 1, 1, do_mmc_rescan, "", ""),
U_BOOT_CMD_MKENT(part, 1, 1, do_mmc_part, "", ""),
U_BOOT_CMD_MKENT(dev, 3, 0, do_mmc_dev, "", ""),
@@ -927,7 +927,7 @@ U_BOOT_CMD(
"info - display info of the current MMC device\n"
"mmc read addr blk# cnt\n"
"mmc write addr blk# cnt\n"
-#if defined(CONFIG_FASTBOOT_FLASH)
+#if CONFIG_IS_ENABLED(CMD_MMC_SWRITE)
"mmc swrite addr blk#\n"
#endif
"mmc erase blk# cnt\n"