summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/Kconfig31
-rw-r--r--cmd/fastboot.c91
-rw-r--r--cmd/fastboot/Kconfig134
-rw-r--r--cmd/fpga.c93
-rw-r--r--cmd/mmc.c14
5 files changed, 201 insertions, 162 deletions
diff --git a/cmd/Kconfig b/cmd/Kconfig
index d532c9fc41..e283cb9a8a 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
@@ -697,6 +707,13 @@ config CMD_FPGA_LOADP
Supports loading an FPGA device from a bitstream buffer containing
a partial bitstream.
+config CMD_FPGA_LOAD_SECURE
+ bool "fpga loads - loads secure bitstreams (Xilinx only)"
+ depends on CMD_FPGA
+ help
+ Enables the fpga loads command which is used to load secure
+ (authenticated or encrypted or both) bitstreams on to FPGA.
+
config CMD_FPGAD
bool "fpgad - dump FPGA registers"
help
@@ -823,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 a5ec5f46f6..557257aef8 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 0d2c2f131e..0000000000
--- 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/fpga.c b/cmd/fpga.c
index 14ad4e5266..74ae80c807 100644
--- a/cmd/fpga.c
+++ b/cmd/fpga.c
@@ -27,6 +27,7 @@ enum {
FPGA_LOADP,
FPGA_LOADBP,
FPGA_LOADFS,
+ FPGA_LOADS,
};
/* ------------------------------------------------------------------------- */
@@ -54,21 +55,55 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
fpga_fs_info fpga_fsinfo;
fpga_fsinfo.fstype = FS_TYPE_ANY;
#endif
+#if defined(CONFIG_CMD_FPGA_LOAD_SECURE)
+ struct fpga_secure_info fpga_sec_info;
+
+ memset(&fpga_sec_info, 0, sizeof(fpga_sec_info));
+#endif
if (devstr)
dev = (int) simple_strtoul(devstr, NULL, 16);
if (datastr)
fpga_data = (void *)simple_strtoul(datastr, NULL, 16);
- switch (argc) {
+ if (argc > 9 || argc < 2) {
+ debug("%s: Too many or too few args (%d)\n", __func__, argc);
+ return CMD_RET_USAGE;
+ }
+
+ op = (int)fpga_get_op(argv[1]);
+
+ switch (op) {
#if defined(CONFIG_CMD_FPGA_LOADFS)
- case 9:
+ case FPGA_LOADFS:
+ if (argc < 9)
+ return CMD_RET_USAGE;
fpga_fsinfo.blocksize = (unsigned int)
- simple_strtoul(argv[5], NULL, 16);
+ simple_strtoul(argv[5], NULL, 16);
fpga_fsinfo.interface = argv[6];
fpga_fsinfo.dev_part = argv[7];
fpga_fsinfo.filename = argv[8];
+ argc = 5;
+ break;
+#endif
+#if defined(CONFIG_CMD_FPGA_LOAD_SECURE)
+ case FPGA_LOADS:
+ if (argc < 7)
+ return CMD_RET_USAGE;
+ if (argc == 8)
+ fpga_sec_info.userkey_addr = (u8 *)(uintptr_t)
+ simple_strtoull(argv[7],
+ NULL, 16);
+ fpga_sec_info.encflag = (u8)simple_strtoul(argv[6], NULL, 16);
+ fpga_sec_info.authflag = (u8)simple_strtoul(argv[5], NULL, 16);
+ argc = 5;
+ break;
#endif
+ default:
+ break;
+ }
+
+ switch (argc) {
case 5: /* fpga <op> <dev> <data> <datasize> */
data_size = simple_strtoul(argv[4], NULL, 16);
@@ -117,15 +152,6 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
__func__, (ulong)fpga_data);
dev = FPGA_INVALID_DEVICE; /* reset device num */
}
-
- case 2: /* fpga <op> */
- op = (int)fpga_get_op(argv[1]);
- break;
-
- default:
- debug("%s: Too many or too few args (%d)\n", __func__, argc);
- op = FPGA_NONE; /* force usage display */
- break;
}
if (dev == FPGA_INVALID_DEVICE) {
@@ -143,6 +169,22 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
if (!fpga_fsinfo.interface || !fpga_fsinfo.dev_part ||
!fpga_fsinfo.filename)
wrong_parms = 1;
+ break;
+#endif
+#if defined(CONFIG_CMD_FPGA_LOAD_SECURE)
+ case FPGA_LOADS:
+ if (fpga_sec_info.authflag >= FPGA_NO_ENC_OR_NO_AUTH &&
+ fpga_sec_info.encflag >= FPGA_NO_ENC_OR_NO_AUTH) {
+ puts("ERR: use <fpga load> for NonSecure bitstream\n");
+ wrong_parms = 1;
+ }
+
+ if (fpga_sec_info.encflag == FPGA_ENC_USR_KEY &&
+ !fpga_sec_info.userkey_addr) {
+ wrong_parms = 1;
+ puts("ERR:User key not provided\n");
+ }
+ break;
#endif
case FPGA_LOAD:
case FPGA_LOADP:
@@ -199,6 +241,12 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
break;
#endif
+#if defined(CONFIG_CMD_FPGA_LOAD_SECURE)
+ case FPGA_LOADS:
+ rc = fpga_loads(dev, fpga_data, data_size, &fpga_sec_info);
+ break;
+#endif
+
#if defined(CONFIG_CMD_FPGA_LOADMK)
case FPGA_LOADMK:
switch (genimg_get_format(fpga_data)) {
@@ -332,6 +380,10 @@ static int fpga_get_op(char *opstr)
#endif
else if (!strcmp("dump", opstr))
op = FPGA_DUMP;
+#if defined(CONFIG_CMD_FPGA_LOAD_SECURE)
+ else if (!strcmp("loads", opstr))
+ op = FPGA_LOADS;
+#endif
if (op == FPGA_NONE)
printf("Unknown fpga operation \"%s\"\n", opstr);
@@ -339,7 +391,7 @@ static int fpga_get_op(char *opstr)
return op;
}
-#if defined(CONFIG_CMD_FPGA_LOADFS)
+#if defined(CONFIG_CMD_FPGA_LOADFS) || defined(CONFIG_CMD_FPGA_LOAD_SECURE)
U_BOOT_CMD(fpga, 9, 1, do_fpga,
#else
U_BOOT_CMD(fpga, 6, 1, do_fpga,
@@ -374,4 +426,19 @@ U_BOOT_CMD(fpga, 6, 1, do_fpga,
"\tsubimage unit name in the form of addr:<subimg_uname>"
#endif
#endif
+#if defined(CONFIG_CMD_FPGA_LOAD_SECURE)
+ "Load encrypted bitstream (Xilinx only)\n"
+ " loads [dev] [address] [size] [auth-OCM-0/DDR-1/noauth-2]\n"
+ " [enc-devkey(0)/userkey(1)/nenc(2) [Userkey address]\n"
+ "Loads the secure bistreams(authenticated/encrypted/both\n"
+ "authenticated and encrypted) of [size] from [address].\n"
+ "The auth-OCM/DDR flag specifies to perform authentication\n"
+ "in OCM or in DDR. 0 for OCM, 1 for DDR, 2 for no authentication.\n"
+ "The enc flag specifies which key to be used for decryption\n"
+ "0-device key, 1-user key, 2-no encryption.\n"
+ "The optional Userkey address specifies from which address key\n"
+ "has to be used for decryption if user key is selected.\n"
+ "NOTE: the sceure bitstream has to be created using xilinx\n"
+ "bootgen tool only.\n"
+#endif
);
diff --git a/cmd/mmc.c b/cmd/mmc.c
index a3357eff8f..c2ee2d9c0a 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"