diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/cmd_elf.c | 6 | ||||
-rw-r--r-- | common/cmd_ide.c | 2 | ||||
-rw-r--r-- | common/cmd_mtdparts.c | 2 | ||||
-rw-r--r-- | common/cmd_net.c | 31 | ||||
-rw-r--r-- | common/cmd_nvedit.c | 32 | ||||
-rw-r--r-- | common/hush.c | 15 | ||||
-rw-r--r-- | common/update.c | 2 | ||||
-rw-r--r-- | common/usb.c | 21 | ||||
-rw-r--r-- | common/usb_storage.c | 33 |
9 files changed, 88 insertions, 56 deletions
diff --git a/common/cmd_elf.c b/common/cmd_elf.c index bf3261256f3..11ffc1b8aa7 100644 --- a/common/cmd_elf.c +++ b/common/cmd_elf.c @@ -133,10 +133,10 @@ int do_bootvx (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) /* Check to see if we need to tftp the image ourselves before starting */ if ((argc == 2) && (strcmp (argv[1], "tftp") == 0)) { - if (NetLoop (TFTP) <= 0) + if (NetLoop(TFTPGET) <= 0) return 1; - printf ("Automatic boot of VxWorks image at address 0x%08lx ... \n", - addr); + printf("Automatic boot of VxWorks image at address 0x%08lx " + "...\n", addr); } #endif diff --git a/common/cmd_ide.c b/common/cmd_ide.c index da5189c37e0..74e6504b2d8 100644 --- a/common/cmd_ide.c +++ b/common/cmd_ide.c @@ -1224,7 +1224,7 @@ ulong ide_read (int device, lbaint_t blknr, ulong blkcnt, void *buffer) lba48 = 1; } #endif - debug ("ide_read dev %d start %LX, blocks %lX buffer at %lX\n", + debug("ide_read dev %d start %lX, blocks %lX buffer at %lX\n", device, blknr, blkcnt, (ulong)buffer); ide_led (DEVICE_LED(device), 1); /* LED on */ diff --git a/common/cmd_mtdparts.c b/common/cmd_mtdparts.c index 2c2e4e09735..b7c833b1499 100644 --- a/common/cmd_mtdparts.c +++ b/common/cmd_mtdparts.c @@ -839,9 +839,7 @@ static int device_parse(const char *const mtd_dev, const char **ret, struct mtd_ const char *mtd_id; unsigned int mtd_id_len; const char *p; -#ifdef DEBUG const char *pend; -#endif LIST_HEAD(tmp_list); struct list_head *entry, *n; u16 num_parts; diff --git a/common/cmd_net.c b/common/cmd_net.c index 872f4a69c82..f89a24bfd4f 100644 --- a/common/cmd_net.c +++ b/common/cmd_net.c @@ -28,7 +28,7 @@ #include <command.h> #include <net.h> -static int netboot_common (proto_t, cmd_tbl_t *, int , char * const []); +static int netboot_common(enum proto_t, cmd_tbl_t *, int, char * const []); int do_bootp (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { @@ -43,7 +43,7 @@ U_BOOT_CMD( int do_tftpb (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { - return netboot_common (TFTP, cmdtp, argc, argv); + return netboot_common(TFTPGET, cmdtp, argc, argv); } U_BOOT_CMD( @@ -52,6 +52,22 @@ U_BOOT_CMD( "[loadAddress] [[hostIPaddr:]bootfilename]" ); +#ifdef CONFIG_CMD_TFTPPUT +int do_tftpput(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + int ret; + + ret = netboot_common(TFTPPUT, cmdtp, argc, argv); + return ret; +} + +U_BOOT_CMD( + tftpput, 4, 1, do_tftpput, + "TFTP put command, for uploading files to a server", + "Address Size [[hostIPaddr:]filename]" +); +#endif + #ifdef CONFIG_CMD_TFTPSRV static int do_tftpsrv(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) { @@ -167,8 +183,8 @@ static void netboot_update_env (void) #endif } -static int -netboot_common (proto_t proto, cmd_tbl_t *cmdtp, int argc, char * const argv[]) +static int netboot_common(enum proto_t proto, cmd_tbl_t *cmdtp, int argc, + char * const argv[]) { char *s; char *end; @@ -203,6 +219,13 @@ netboot_common (proto_t proto, cmd_tbl_t *cmdtp, int argc, char * const argv[]) break; +#ifdef CONFIG_CMD_TFTPPUT + case 4: + save_addr = strict_strtoul(argv[1], NULL, 16); + save_size = strict_strtoul(argv[2], NULL, 16); + copy_filename(BootFile, argv[3], sizeof(BootFile)); + break; +#endif default: show_boot_progress (-80); return cmd_usage(cmdtp); diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index fa99c44b010..396a17135eb 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -79,6 +79,8 @@ SPI_FLASH|MG_DISK|NVRAM|MMC} or CONFIG_ENV_IS_NOWHERE #define MAX_ENV_SIZE (1 << 20) /* 1 MiB */ ulong load_addr = CONFIG_SYS_LOAD_ADDR; /* Default Load Address */ +ulong save_addr; /* Default Save Address */ +ulong save_size; /* Default Save Size (in bytes) */ /* * Table with supported baudrates (defined in config_xyz.h) @@ -377,6 +379,36 @@ int setenv(const char *varname, const char *varvalue) return _do_env_set(0, 3, (char * const *)argv); } +/** + * Set an environment variable to an integer value + * + * @param varname Environmet variable to set + * @param value Value to set it to + * @return 0 if ok, 1 on error + */ +int setenv_ulong(const char *varname, ulong value) +{ + /* TODO: this should be unsigned */ + char *str = simple_itoa(value); + + return setenv(varname, str); +} + +/** + * Set an environment variable to an address in hex + * + * @param varname Environmet variable to set + * @param addr Value to set it to + * @return 0 if ok, 1 on error + */ +int setenv_addr(const char *varname, const void *addr) +{ + char str[17]; + + sprintf(str, "%x", (uintptr_t)addr); + return setenv(varname, str); +} + int do_env_set(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { if (argc < 2) diff --git a/common/hush.c b/common/hush.c index 940889b8986..2495a6d5927 100644 --- a/common/hush.c +++ b/common/hush.c @@ -17,7 +17,6 @@ * Erik W. Troan, which they placed in the public domain. I don't know * how much of the Johnson/Troan code has survived the repeated rewrites. * Other credits: - * simple_itoa() was lifted from boa-0.93.15 * b_addchr() derived from similar w_addchar function in glibc-2.2 * setup_redirect(), redirect_opt_num(), and big chunks of main() * and many builtins derived from contributions by Erik Andersen @@ -922,20 +921,6 @@ static int b_addqchr(o_string *o, int ch, int quote) return b_addchr(o, ch); } -/* belongs in utility.c */ -char *simple_itoa(unsigned int i) -{ - /* 21 digits plus null terminator, good for 64-bit or smaller ints */ - static char local[22]; - char *p = &local[21]; - *p-- = '\0'; - do { - *p-- = '0' + i % 10; - i /= 10; - } while (i > 0); - return p + 1; -} - #ifndef __U_BOOT__ static int b_adduint(o_string *o, unsigned int i) { diff --git a/common/update.c b/common/update.c index a19f136647d..5b1a064c29c 100644 --- a/common/update.c +++ b/common/update.c @@ -86,7 +86,7 @@ static int update_load(char *filename, ulong msec_max, int cnt_max, ulong addr) /* download the update file */ load_addr = addr; copy_filename(BootFile, filename, sizeof(BootFile)); - size = NetLoop(TFTP); + size = NetLoop(TFTPGET); if (size < 0) rv = 1; diff --git a/common/usb.c b/common/usb.c index 2cd50db9994..bed51165053 100644 --- a/common/usb.c +++ b/common/usb.c @@ -56,16 +56,16 @@ #endif #ifdef DEBUG -#define USB_DEBUG -#define USB_HUB_DEBUG -#endif - -#ifdef USB_DEBUG -#define USB_PRINTF(fmt, args...) printf(fmt , ##args) +#define USB_DEBUG 1 +#define USB_HUB_DEBUG 1 #else -#define USB_PRINTF(fmt, args...) +#define USB_DEBUG 0 +#define USB_HUB_DEBUG 0 #endif +#define USB_PRINTF(fmt, args...) debug_cond(USB_DEBUG, fmt, ##args) +#define USB_HUB_PRINTF(fmt, args...) debug_cond(USB_HUB_DEBUG, fmt, ##args) + #define USB_BUFSIZ 512 static struct usb_device usb_dev[USB_MAX_DEVICE]; @@ -968,13 +968,6 @@ void usb_scan_devices(void) * Probes device for being a hub and configurate it */ -#ifdef USB_HUB_DEBUG -#define USB_HUB_PRINTF(fmt, args...) printf(fmt , ##args) -#else -#define USB_HUB_PRINTF(fmt, args...) -#endif - - static struct usb_hub_device hub_dev[USB_MAX_HUB]; static int usb_hub_index; diff --git a/common/usb_storage.c b/common/usb_storage.c index 16667f39482..d9a2585d580 100644 --- a/common/usb_storage.c +++ b/common/usb_storage.c @@ -56,16 +56,17 @@ #include <part.h> #include <usb.h> -#undef USB_STOR_DEBUG #undef BBB_COMDAT_TRACE #undef BBB_XPORT_TRACE #ifdef USB_STOR_DEBUG -#define USB_STOR_PRINTF(fmt, args...) printf(fmt , ##args) +#define USB_BLK_DEBUG 1 #else -#define USB_STOR_PRINTF(fmt, args...) +#define USB_BLK_DEBUG 0 #endif +#define USB_STOR_PRINTF(fmt, args...) debug_cond(USB_BLK_DEBUG, fmt, ##args) + #include <scsi.h> /* direction table -- this indicates the direction of the data * transfer for each command code -- a 1 indicates input @@ -372,7 +373,7 @@ static int us_one_transfer(struct us_data *us, int pipe, char *buf, int length) usb_clear_halt(us->pusb_dev, pipe); us->pusb_dev->status = stat; if (this_xfer == partial) { - USB_STOR_PRINTF("bulk transferred with error %X, but data ok\n", us->pusb_dev->status); + USB_STOR_PRINTF("bulk transferred with error %lX, but data ok\n", us->pusb_dev->status); return 0; } else @@ -384,12 +385,12 @@ static int us_one_transfer(struct us_data *us, int pipe, char *buf, int length) } USB_STOR_PRINTF("bulk transferred with error"); if (this_xfer == partial) { - USB_STOR_PRINTF(" %d, but data ok\n", + USB_STOR_PRINTF(" %ld, but data ok\n", us->pusb_dev->status); return 0; } /* if our try counter reaches 0, bail out */ - USB_STOR_PRINTF(" %d, data %d\n", + USB_STOR_PRINTF(" %ld, data %d\n", us->pusb_dev->status, partial); if (!maxtry--) return result; @@ -437,19 +438,19 @@ static int usb_stor_BBB_reset(struct us_data *us) /* long wait for reset */ wait_ms(150); - USB_STOR_PRINTF("BBB_reset result %d: status %X reset\n", result, + USB_STOR_PRINTF("BBB_reset result %d: status %lX reset\n", result, us->pusb_dev->status); pipe = usb_rcvbulkpipe(us->pusb_dev, us->ep_in); result = usb_clear_halt(us->pusb_dev, pipe); /* long wait for reset */ wait_ms(150); - USB_STOR_PRINTF("BBB_reset result %d: status %X clearing IN endpoint\n", + USB_STOR_PRINTF("BBB_reset result %d: status %lX clearing IN endpoint\n", result, us->pusb_dev->status); /* long wait for reset */ pipe = usb_sndbulkpipe(us->pusb_dev, us->ep_out); result = usb_clear_halt(us->pusb_dev, pipe); wait_ms(150); - USB_STOR_PRINTF("BBB_reset result %d: status %X" + USB_STOR_PRINTF("BBB_reset result %d: status %lX" " clearing OUT endpoint\n", result, us->pusb_dev->status); USB_STOR_PRINTF("BBB_reset done\n"); @@ -477,7 +478,7 @@ static int usb_stor_CB_reset(struct us_data *us) /* long wait for reset */ wait_ms(1500); - USB_STOR_PRINTF("CB_reset result %d: status %X" + USB_STOR_PRINTF("CB_reset result %d: status %lX" " clearing endpoint halt\n", result, us->pusb_dev->status); usb_clear_halt(us->pusb_dev, usb_rcvbulkpipe(us->pusb_dev, us->ep_in)); @@ -568,7 +569,7 @@ int usb_stor_CB_comdat(ccb *srb, struct us_data *us) srb->cmd, srb->cmdlen, USB_CNTL_TIMEOUT * 5); USB_STOR_PRINTF("CB_transport: control msg returned %d," - " status %X\n", result, us->pusb_dev->status); + " status %lX\n", result, us->pusb_dev->status); /* check the return code for the command */ if (result < 0) { if (us->pusb_dev->status & USB_ST_STALLED) { @@ -580,7 +581,7 @@ int usb_stor_CB_comdat(ccb *srb, struct us_data *us) us->pusb_dev->status = status; } USB_STOR_PRINTF(" error during command %02X" - " Stat = %X\n", srb->cmd[0], + " Stat = %lX\n", srb->cmd[0], us->pusb_dev->status); return result; } @@ -777,7 +778,7 @@ again: usb_stor_BBB_reset(us); return USB_STOR_TRANSPORT_FAILED; } else if (data_actlen > srb->datalen) { - USB_STOR_PRINTF("transferred %dB instead of %dB\n", + USB_STOR_PRINTF("transferred %dB instead of %ldB\n", data_actlen, srb->datalen); return USB_STOR_TRANSPORT_FAILED; } else if (csw.bCSWStatus == CSWSTATUS_FAILED) { @@ -802,7 +803,7 @@ int usb_stor_CB_transport(ccb *srb, struct us_data *us) /* issue the command */ do_retry: result = usb_stor_CB_comdat(srb, us); - USB_STOR_PRINTF("command / Data returned %d, status %X\n", + USB_STOR_PRINTF("command / Data returned %d, status %lX\n", result, us->pusb_dev->status); /* if this is an CBI Protocol, get IRQ */ if (us->protocol == US_PR_CBI) { @@ -825,7 +826,7 @@ do_retry: /* do we have to issue an auto request? */ /* HERE we have to check the result */ if ((result < 0) && !(us->pusb_dev->status & USB_ST_STALLED)) { - USB_STOR_PRINTF("ERROR %X\n", us->pusb_dev->status); + USB_STOR_PRINTF("ERROR %lX\n", us->pusb_dev->status); us->transport_reset(us); return USB_STOR_TRANSPORT_ERROR; } @@ -852,7 +853,7 @@ do_retry: status = usb_stor_CBI_get_status(psrb, us); if ((result < 0) && !(us->pusb_dev->status & USB_ST_STALLED)) { - USB_STOR_PRINTF(" AUTO REQUEST ERROR %d\n", + USB_STOR_PRINTF(" AUTO REQUEST ERROR %ld\n", us->pusb_dev->status); return USB_STOR_TRANSPORT_ERROR; } |