summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/board_f.c2
-rw-r--r--common/cmd_dfu.c6
-rw-r--r--common/cmd_fastboot.c4
-rw-r--r--common/cmd_hash.c28
-rw-r--r--common/fb_mmc.c26
-rw-r--r--common/hash.c6
6 files changed, 47 insertions, 25 deletions
diff --git a/common/board_f.c b/common/board_f.c
index 98c9c728ce..cfd77f8653 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -813,7 +813,9 @@ static init_fnc_t init_sequence_f[] = {
#endif
setup_mon_len,
setup_fdt,
+#ifdef CONFIG_TRACE
trace_early_init,
+#endif
initf_malloc,
#if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)
/* TODO: can this go into arch_cpu_init()? */
diff --git a/common/cmd_dfu.c b/common/cmd_dfu.c
index 9e020b40be..e975abebc9 100644
--- a/common/cmd_dfu.c
+++ b/common/cmd_dfu.c
@@ -38,10 +38,10 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
int controller_index = simple_strtoul(usb_controller, NULL, 0);
board_usb_init(controller_index, USB_INIT_DEVICE);
- dfu_clear_detach();
+ g_dnl_clear_detach();
g_dnl_register("usb_dnl_dfu");
while (1) {
- if (dfu_detach()) {
+ if (g_dnl_detach()) {
/*
* Check if USB bus reset is performed after detach,
* which indicates that -R switch has been passed to
@@ -74,7 +74,7 @@ done:
if (dfu_reset)
run_command("reset", 0);
- dfu_clear_detach();
+ g_dnl_clear_detach();
return ret;
}
diff --git a/common/cmd_fastboot.c b/common/cmd_fastboot.c
index 909616dcb7..b72f4f310d 100644
--- a/common/cmd_fastboot.c
+++ b/common/cmd_fastboot.c
@@ -15,17 +15,21 @@ static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
{
int ret;
+ g_dnl_clear_detach();
ret = g_dnl_register("usb_dnl_fastboot");
if (ret)
return ret;
while (1) {
+ if (g_dnl_detach())
+ break;
if (ctrlc())
break;
usb_gadget_handle_interrupts();
}
g_dnl_unregister();
+ g_dnl_clear_detach();
return CMD_RET_SUCCESS;
}
diff --git a/common/cmd_hash.c b/common/cmd_hash.c
index 90facbbe1a..704d21ec6d 100644
--- a/common/cmd_hash.c
+++ b/common/cmd_hash.c
@@ -18,9 +18,9 @@
static int do_hash(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
char *s;
-#ifdef CONFIG_HASH_VERIFY
int flags = HASH_FLAG_ENV;
+#ifdef CONFIG_HASH_VERIFY
if (argc < 4)
return CMD_RET_USAGE;
if (!strcmp(argv[1], "-v")) {
@@ -28,8 +28,6 @@ static int do_hash(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
argc--;
argv++;
}
-#else
- const int flags = HASH_FLAG_ENV;
#endif
/* Move forward to 'algorithm' parameter */
argc--;
@@ -40,19 +38,19 @@ static int do_hash(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
}
#ifdef CONFIG_HASH_VERIFY
-U_BOOT_CMD(
- hash, 6, 1, do_hash,
- "compute hash message digest",
- "algorithm address count [[*]sum_dest]\n"
- " - compute message digest [save to env var / *address]\n"
- "hash -v algorithm address count [*]sum\n"
- " - verify hash of memory area with env var / *address"
-);
+#define HARGS 6
#else
+#define HARGS 5
+#endif
+
U_BOOT_CMD(
- hash, 5, 1, do_hash,
- "compute message digest",
- "algorithm address count [[*]sum_dest]\n"
+ hash, HARGS, 1, do_hash,
+ "compute hash message digest",
+ "algorithm address count [[*]hash_dest]\n"
" - compute message digest [save to env var / *address]"
-);
+#ifdef CONFIG_HASH_VERIFY
+ "\nhash -v algorithm address count [*]hash\n"
+ " - verify message digest of memory area to immediate value, \n"
+ " env var or *address"
#endif
+);
diff --git a/common/fb_mmc.c b/common/fb_mmc.c
index fb06d8a557..6ea3938d83 100644
--- a/common/fb_mmc.c
+++ b/common/fb_mmc.c
@@ -4,12 +4,17 @@
* SPDX-License-Identifier: GPL-2.0+
*/
+#include <config.h>
#include <common.h>
#include <fb_mmc.h>
#include <part.h>
#include <aboot.h>
#include <sparse_format.h>
+#ifndef CONFIG_FASTBOOT_GPT_NAME
+#define CONFIG_FASTBOOT_GPT_NAME GPT_ENTRY_NAME
+#endif
+
/* The 64 defined bytes plus the '\0' */
#define RESPONSE_LEN (64 + 1)
@@ -62,7 +67,6 @@ static void write_raw_image(block_dev_desc_t *dev_desc, disk_partition_t *info,
void fb_mmc_flash_write(const char *cmd, void *download_buffer,
unsigned int download_bytes, char *response)
{
- int ret;
block_dev_desc_t *dev_desc;
disk_partition_t info;
@@ -76,8 +80,24 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer,
return;
}
- ret = get_partition_info_efi_by_name(dev_desc, cmd, &info);
- if (ret) {
+ if (strcmp(cmd, CONFIG_FASTBOOT_GPT_NAME) == 0) {
+ printf("%s: updating MBR, Primary and Backup GPT(s)\n",
+ __func__);
+ if (is_valid_gpt_buf(dev_desc, download_buffer)) {
+ printf("%s: invalid GPT - refusing to write to flash\n",
+ __func__);
+ fastboot_fail("invalid GPT partition");
+ return;
+ }
+ if (write_mbr_and_gpt_partitions(dev_desc, download_buffer)) {
+ printf("%s: writing GPT partitions failed\n", __func__);
+ fastboot_fail("writing GPT partitions failed");
+ return;
+ }
+ printf("........ success\n");
+ fastboot_okay("");
+ return;
+ } else if (get_partition_info_efi_by_name(dev_desc, cmd, &info)) {
error("cannot find partition: '%s'\n", cmd);
fastboot_fail("cannot find partition");
return;
diff --git a/common/hash.c b/common/hash.c
index 12d67594ab..aceabc5cad 100644
--- a/common/hash.c
+++ b/common/hash.c
@@ -256,7 +256,7 @@ static int parse_verify_sum(struct hash_algo *algo, char *verify_str,
env_var = 1;
}
- if (env_var) {
+ if (!env_var) {
ulong addr;
void *buf;
@@ -347,7 +347,7 @@ int hash_command(const char *algo_name, int flags, cmd_tbl_t *cmdtp, int flag,
{
ulong addr, len;
- if (argc < 2)
+ if ((argc < 2) || ((flags & HASH_FLAG_VERIFY) && (argc < 3)))
return CMD_RET_USAGE;
addr = simple_strtoul(*argv++, NULL, 16);
@@ -380,8 +380,6 @@ int hash_command(const char *algo_name, int flags, cmd_tbl_t *cmdtp, int flag,
#else
if (0) {
#endif
- if (!argc)
- return CMD_RET_USAGE;
if (parse_verify_sum(algo, *argv, vsum,
flags & HASH_FLAG_ENV)) {
printf("ERROR: %s does not contain a valid "
OpenPOWER on IntegriCloud