summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/cmd_bootm.c21
-rw-r--r--common/cmd_sf.c14
-rw-r--r--common/cmd_usb_mass_storage.c24
-rw-r--r--common/command.c4
-rw-r--r--common/env_callback.c9
-rw-r--r--common/env_flags.c8
-rw-r--r--common/image.c2
7 files changed, 63 insertions, 19 deletions
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 3f57659..a59ee95 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -82,6 +82,9 @@ static int do_imls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
static void fixup_silent_linux(void);
#endif
+static int do_bootm_standalone(int flag, int argc, char * const argv[],
+ bootm_headers_t *images);
+
static const void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc,
char * const argv[], bootm_headers_t *images,
ulong *os_data, ulong *os_len);
@@ -139,6 +142,7 @@ static boot_os_fn do_bootm_integrity;
#endif
static boot_os_fn *boot_os[] = {
+ [IH_OS_U_BOOT] = do_bootm_standalone,
#ifdef CONFIG_BOOTM_LINUX
[IH_OS_LINUX] = do_bootm_linux,
#endif
@@ -499,17 +503,18 @@ static int bootm_load_os(bootm_headers_t *images, unsigned long *load_end,
return 0;
}
-static int bootm_start_standalone(int argc, char * const argv[])
+static int do_bootm_standalone(int flag, int argc, char * const argv[],
+ bootm_headers_t *images)
{
char *s;
int (*appl)(int, char * const []);
/* Don't start if "autostart" is set to "no" */
if (((s = getenv("autostart")) != NULL) && (strcmp(s, "no") == 0)) {
- setenv_hex("filesize", images.os.image_len);
+ setenv_hex("filesize", images->os.image_len);
return 0;
}
- appl = (int (*)(int, char * const []))(ulong)ntohl(images.ep);
+ appl = (int (*)(int, char * const []))(ulong)ntohl(images->ep);
(*appl)(argc, argv);
return 0;
}
@@ -535,14 +540,12 @@ static cmd_tbl_t cmd_bootm_sub[] = {
static int boot_selected_os(int argc, char * const argv[], int state,
bootm_headers_t *images, boot_os_fn *boot_fn)
{
- if (images->os.type == IH_TYPE_STANDALONE) {
- /* This may return when 'autostart' is 'no' */
- bootm_start_standalone(argc, argv);
- return 0;
- }
arch_preboot_os();
boot_fn(state, argc, argv, images);
- if (state == BOOTM_STATE_OS_FAKE_GO) /* We expect to return */
+
+ /* Stand-alone may return when 'autostart' is 'no' */
+ if (images->os.type == IH_TYPE_STANDALONE ||
+ state == BOOTM_STATE_OS_FAKE_GO) /* We expect to return */
return 0;
bootstage_error(BOOTSTAGE_ID_BOOT_OS_RETURNED);
#ifdef DEBUG
diff --git a/common/cmd_sf.c b/common/cmd_sf.c
index 3994b06..b4ceb71 100644
--- a/common/cmd_sf.c
+++ b/common/cmd_sf.c
@@ -358,7 +358,8 @@ static void show_time(struct test_info *test, int stage)
int bps; /* Bits per second */
speed = (long long)test->bytes * 1000;
- do_div(speed, test->time_ms[stage] * 1024);
+ if (test->time_ms[stage])
+ do_div(speed, test->time_ms[stage] * 1024);
bps = speed * 8;
printf("%d %s: %d ticks, %d KiB/s %d.%03d Mbps\n", stage,
@@ -446,11 +447,13 @@ static int do_spi_flash_test(int argc, char * const argv[])
{
unsigned long offset;
unsigned long len;
- uint8_t *buf = (uint8_t *)CONFIG_SYS_TEXT_BASE;
+ uint8_t *buf, *from;
char *endp;
uint8_t *vbuf;
int ret;
+ if (argc < 3)
+ return -1;
offset = simple_strtoul(argv[1], &endp, 16);
if (*argv[1] == 0 || *endp != 0)
return -1;
@@ -460,17 +463,18 @@ static int do_spi_flash_test(int argc, char * const argv[])
vbuf = malloc(len);
if (!vbuf) {
- printf("Cannot allocate memory\n");
+ printf("Cannot allocate memory (%lu bytes)\n", len);
return 1;
}
buf = malloc(len);
if (!buf) {
free(vbuf);
- printf("Cannot allocate memory\n");
+ printf("Cannot allocate memory (%lu bytes)\n", len);
return 1;
}
- memcpy(buf, (char *)CONFIG_SYS_TEXT_BASE, len);
+ from = map_sysmem(CONFIG_SYS_TEXT_BASE, 0);
+ memcpy(buf, from, len);
ret = spi_flash_test(flash, buf, len, offset, vbuf);
free(vbuf);
free(buf);
diff --git a/common/cmd_usb_mass_storage.c b/common/cmd_usb_mass_storage.c
index 99487f4..5f557d5 100644
--- a/common/cmd_usb_mass_storage.c
+++ b/common/cmd_usb_mass_storage.c
@@ -42,6 +42,30 @@ int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag,
g_dnl_register("ums");
+ /* Timeout unit: seconds */
+ int cable_ready_timeout = UMS_CABLE_READY_TIMEOUT;
+
+ if (!usb_cable_connected()) {
+ puts("Please connect USB cable.\n");
+
+ while (!usb_cable_connected()) {
+ if (ctrlc()) {
+ puts("\rCTRL+C - Operation aborted.\n");
+ goto exit;
+ }
+ if (!cable_ready_timeout) {
+ puts("\rUSB cable not detected.\n" \
+ "Command exit.\n");
+ goto exit;
+ }
+
+ printf("\rAuto exit in: %.2d s.", cable_ready_timeout);
+ mdelay(1000);
+ cable_ready_timeout--;
+ }
+ puts("\r\n");
+ }
+
while (1) {
usb_gadget_handle_interrupts();
diff --git a/common/command.c b/common/command.c
index 625571d..597ab4c 100644
--- a/common/command.c
+++ b/common/command.c
@@ -184,10 +184,10 @@ static int complete_cmdv(int argc, char * const argv[], char last_char, int maxv
/* output full list of commands */
for (; cmdtp != cmdend; cmdtp++) {
if (n_found >= maxv - 2) {
- cmdv[n_found] = "...";
+ cmdv[n_found++] = "...";
break;
}
- cmdv[n_found] = cmdtp->name;
+ cmdv[n_found++] = cmdtp->name;
}
cmdv[n_found] = NULL;
return n_found;
diff --git a/common/env_callback.c b/common/env_callback.c
index 34bb58e..d03fa03 100644
--- a/common/env_callback.c
+++ b/common/env_callback.c
@@ -35,6 +35,9 @@ static struct env_clbk_tbl *find_env_callback(const char *name)
return NULL;
}
+static int first_call = 1;
+static const char *callback_list;
+
/*
* Look for a possible callback for a newly added variable
* This is called specifically when the variable did not exist in the hash
@@ -43,11 +46,15 @@ static struct env_clbk_tbl *find_env_callback(const char *name)
void env_callback_init(ENTRY *var_entry)
{
const char *var_name = var_entry->key;
- const char *callback_list = getenv(ENV_CALLBACK_VAR);
char callback_name[256] = "";
struct env_clbk_tbl *clbkp;
int ret = 1;
+ if (first_call) {
+ callback_list = getenv(ENV_CALLBACK_VAR);
+ first_call = 0;
+ }
+
/* look in the ".callbacks" var for a reference to this variable */
if (callback_list != NULL)
ret = env_attr_lookup(callback_list, var_name, callback_name);
diff --git a/common/env_flags.c b/common/env_flags.c
index e9b72e6..985f92e 100644
--- a/common/env_flags.c
+++ b/common/env_flags.c
@@ -395,6 +395,9 @@ static int env_parse_flags_to_bin(const char *flags)
return binflags;
}
+static int first_call = 1;
+static const char *flags_list;
+
/*
* Look for possible flags for a newly added variable
* This is called specifically when the variable did not exist in the hash
@@ -403,10 +406,13 @@ static int env_parse_flags_to_bin(const char *flags)
void env_flags_init(ENTRY *var_entry)
{
const char *var_name = var_entry->key;
- const char *flags_list = getenv(ENV_FLAGS_VAR);
char flags[ENV_FLAGS_ATTR_MAX_LEN + 1] = "";
int ret = 1;
+ if (first_call) {
+ flags_list = getenv(ENV_FLAGS_VAR);
+ first_call = 0;
+ }
/* look in the ".flags" and static for a reference to this variable */
ret = env_flags_lookup(flags_list, var_name, flags);
diff --git a/common/image.c b/common/image.c
index 4145354..ae95c3f 100644
--- a/common/image.c
+++ b/common/image.c
@@ -96,9 +96,9 @@ static const table_entry_t uimage_os[] = {
{ IH_OS_PLAN9, "plan9", "Plan 9", },
{ IH_OS_RTEMS, "rtems", "RTEMS", },
{ IH_OS_U_BOOT, "u-boot", "U-Boot", },
+ { IH_OS_VXWORKS, "vxworks", "VxWorks", },
#if defined(CONFIG_CMD_ELF) || defined(USE_HOSTCC)
{ IH_OS_QNX, "qnx", "QNX", },
- { IH_OS_VXWORKS, "vxworks", "VxWorks", },
#endif
#if defined(CONFIG_INTEGRITY) || defined(USE_HOSTCC)
{ IH_OS_INTEGRITY,"integrity", "INTEGRITY", },