From ce2f5800177c36451da44345f7ab408df240ff82 Mon Sep 17 00:00:00 2001 From: Joe Hershberger Date: Mon, 15 Oct 2012 15:29:24 +0000 Subject: tools/env: Fix variable delete operation Fix crash introduced by a073d63a36524453a817ab029fad5b188f46127e when attempting to delete a variable. Signed-off-by: Joe Hershberger --- tools/env/fw_env.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c index ab8c15d..97328bb 100644 --- a/tools/env/fw_env.c +++ b/tools/env/fw_env.c @@ -494,6 +494,8 @@ int fw_setenv(int argc, char *argv[]) char *val = argv[i]; size_t val_len = strlen(val); + if (value) + value[len - 1] = ' '; value = realloc(value, len + val_len + 1); if (!value) { fprintf(stderr, @@ -504,9 +506,8 @@ int fw_setenv(int argc, char *argv[]) memcpy(value + len, val, val_len); len += val_len; - value[len++] = ' '; + value[len++] = '\0'; } - value[len - 1] = '\0'; fw_env_write(name, value); -- cgit v1.1 From 74620e1c94565b835c7b6eb34db9b67bfc898bc4 Mon Sep 17 00:00:00 2001 From: Joe Hershberger Date: Mon, 15 Oct 2012 15:29:25 +0000 Subject: tools/env: Improve debug prints Provide more information when using redundant environments Consistently print debug info to stderr Signed-off-by: Joe Hershberger --- tools/env/fw_env.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'tools') diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c index 97328bb..32e853a 100644 --- a/tools/env/fw_env.c +++ b/tools/env/fw_env.c @@ -739,8 +739,8 @@ static int flash_read_buf (int dev, int fd, void *buf, size_t count, return -1; } #ifdef DEBUG - fprintf (stderr, "Read 0x%x bytes at 0x%llx\n", - rc, blockstart + block_seek); + fprintf(stderr, "Read 0x%x bytes at 0x%llx on %s\n", + rc, blockstart + block_seek, DEVNAME(dev)); #endif processed += readlen; readlen = min (blocklen, count - processed); @@ -819,6 +819,18 @@ static int flash_write_buf (int dev, int fd, void *buf, size_t count, if (write_total != rc) return -1; +#ifdef DEBUG + fprintf(stderr, "Preserving data "); + if (block_seek != 0) + fprintf(stderr, "0x%x - 0x%lx", 0, block_seek - 1); + if (block_seek + count != write_total) { + if (block_seek != 0) + fprintf(stderr, " and "); + fprintf(stderr, "0x%lx - 0x%x", + block_seek + count, write_total - 1); + } + fprintf(stderr, "\n"); +#endif /* Overwrite the old environment */ memcpy (data + block_seek, buf, count); } else { @@ -877,7 +889,8 @@ static int flash_write_buf (int dev, int fd, void *buf, size_t count, } #ifdef DEBUG - printf ("Write 0x%x bytes at 0x%llx\n", erasesize, blockstart); + fprintf(stderr, "Write 0x%x bytes at 0x%llx\n", erasesize, + blockstart); #endif if (write (fd, data + processed, erasesize) != erasesize) { fprintf (stderr, "Write error on %s: %s\n", @@ -944,7 +957,7 @@ static int flash_write (int fd_current, int fd_target, int dev_target) } #ifdef DEBUG - printf ("Writing new environment at 0x%lx on %s\n", + fprintf(stderr, "Writing new environment at 0x%lx on %s\n", DEVOFFSET (dev_target), DEVNAME (dev_target)); #endif rc = flash_write_buf(dev_target, fd_target, environment.image, @@ -958,7 +971,8 @@ static int flash_write (int fd_current, int fd_target, int dev_target) off_t offset = DEVOFFSET (dev_current) + offsetof (struct env_image_redundant, flags); #ifdef DEBUG - printf ("Setting obsolete flag in environment at 0x%lx on %s\n", + fprintf(stderr, + "Setting obsolete flag in environment at 0x%lx on %s\n", DEVOFFSET (dev_current), DEVNAME (dev_current)); #endif flash_flag_obsolete (dev_current, fd_current, offset); @@ -1225,6 +1239,9 @@ int fw_env_open(void) /* Other pointers are already set */ free (addr1); } +#ifdef DEBUG + fprintf(stderr, "Selected env in %s\n", DEVNAME(dev_current)); +#endif } return 0; } -- cgit v1.1 From ddd8418f7f390a39d460e6ab98e8e668f0cf617c Mon Sep 17 00:00:00 2001 From: Joe Hershberger Date: Fri, 12 Oct 2012 08:48:51 +0000 Subject: env: cosmetic: Consilidate the default env definition There used to be a huge structure duplicated 3 times in the source. Signed-off-by: Joe Hershberger Signed-off-by: Tom Rini --- tools/env/fw_env.c | 98 ++---------------------------------------------------- 1 file changed, 2 insertions(+), 96 deletions(-) (limited to 'tools') diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c index 32e853a..9b023e8 100644 --- a/tools/env/fw_env.c +++ b/tools/env/fw_env.c @@ -119,102 +119,8 @@ static unsigned char active_flag = 1; /* obsolete_flag must be 0 to efficiently set it on NOR flash without erasing */ static unsigned char obsolete_flag = 0; - -static char default_environment[] = { -#if defined(CONFIG_BOOTARGS) - "bootargs=" CONFIG_BOOTARGS "\0" -#endif -#if defined(CONFIG_BOOTCOMMAND) - "bootcmd=" CONFIG_BOOTCOMMAND "\0" -#endif -#if defined(CONFIG_RAMBOOTCOMMAND) - "ramboot=" CONFIG_RAMBOOTCOMMAND "\0" -#endif -#if defined(CONFIG_NFSBOOTCOMMAND) - "nfsboot=" CONFIG_NFSBOOTCOMMAND "\0" -#endif -#if defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY >= 0) - "bootdelay=" __stringify(CONFIG_BOOTDELAY) "\0" -#endif -#if defined(CONFIG_BAUDRATE) && (CONFIG_BAUDRATE >= 0) - "baudrate=" __stringify(CONFIG_BAUDRATE) "\0" -#endif -#ifdef CONFIG_LOADS_ECHO - "loads_echo=" __stringify(CONFIG_LOADS_ECHO) "\0" -#endif -#ifdef CONFIG_ETHADDR - "ethaddr=" __stringify(CONFIG_ETHADDR) "\0" -#endif -#ifdef CONFIG_ETH1ADDR - "eth1addr=" __stringify(CONFIG_ETH1ADDR) "\0" -#endif -#ifdef CONFIG_ETH2ADDR - "eth2addr=" __stringify(CONFIG_ETH2ADDR) "\0" -#endif -#ifdef CONFIG_ETH3ADDR - "eth3addr=" __stringify(CONFIG_ETH3ADDR) "\0" -#endif -#ifdef CONFIG_ETH4ADDR - "eth4addr=" __stringify(CONFIG_ETH4ADDR) "\0" -#endif -#ifdef CONFIG_ETH5ADDR - "eth5addr=" __stringify(CONFIG_ETH5ADDR) "\0" -#endif -#ifdef CONFIG_ETHPRIME - "ethprime=" CONFIG_ETHPRIME "\0" -#endif -#ifdef CONFIG_IPADDR - "ipaddr=" __stringify(CONFIG_IPADDR) "\0" -#endif -#ifdef CONFIG_SERVERIP - "serverip=" __stringify(CONFIG_SERVERIP) "\0" -#endif -#ifdef CONFIG_SYS_AUTOLOAD - "autoload=" CONFIG_SYS_AUTOLOAD "\0" -#endif -#ifdef CONFIG_ROOTPATH - "rootpath=" CONFIG_ROOTPATH "\0" -#endif -#ifdef CONFIG_GATEWAYIP - "gatewayip=" __stringify(CONFIG_GATEWAYIP) "\0" -#endif -#ifdef CONFIG_NETMASK - "netmask=" __stringify(CONFIG_NETMASK) "\0" -#endif -#ifdef CONFIG_HOSTNAME - "hostname=" __stringify(CONFIG_HOSTNAME) "\0" -#endif -#ifdef CONFIG_BOOTFILE - "bootfile=" CONFIG_BOOTFILE "\0" -#endif -#ifdef CONFIG_LOADADDR - "loadaddr=" __stringify(CONFIG_LOADADDR) "\0" -#endif -#ifdef CONFIG_PREBOOT - "preboot=" CONFIG_PREBOOT "\0" -#endif -#ifdef CONFIG_CLOCKS_IN_MHZ - "clocks_in_mhz=" "1" "\0" -#endif -#if defined(CONFIG_PCI_BOOTDELAY) && (CONFIG_PCI_BOOTDELAY > 0) - "pcidelay=" __stringify(CONFIG_PCI_BOOTDELAY) "\0" -#endif -#ifdef CONFIG_ENV_VARS_UBOOT_CONFIG - "arch=" CONFIG_SYS_ARCH "\0" - "cpu=" CONFIG_SYS_CPU "\0" - "board=" CONFIG_SYS_BOARD "\0" -#ifdef CONFIG_SYS_VENDOR - "vendor=" CONFIG_SYS_VENDOR "\0" -#endif -#ifdef CONFIG_SYS_SOC - "soc=" CONFIG_SYS_SOC "\0" -#endif -#endif -#ifdef CONFIG_EXTRA_ENV_SETTINGS - CONFIG_EXTRA_ENV_SETTINGS -#endif - "\0" /* Termimate struct environment data with 2 NULs */ -}; +#define DEFAULT_ENV_INSTANCE_STATIC +#include static int flash_io (int mode); static char *envmatch (char * s1, char * s2); -- cgit v1.1 From 7f14f30a6d6c80f9fbe3fd8d5b0c294575e3094e Mon Sep 17 00:00:00 2001 From: Albert ARIBAUD Date: Mon, 15 Oct 2012 09:55:50 +0000 Subject: patman: force git log commands to not use color Colored logs confuse patman when analyzing logs. Add --no-color option in git log commands in case the default config has color. Signed-off-by: Albert ARIBAUD Acked-by: Simon Glass Signed-off-by: Tom Rini --- tools/patman/gitutil.py | 2 +- tools/patman/patchstream.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/patman/gitutil.py b/tools/patman/gitutil.py index 59eca99..72d37a0 100644 --- a/tools/patman/gitutil.py +++ b/tools/patman/gitutil.py @@ -38,7 +38,7 @@ def CountCommitsToBranch(): Return: Number of patches that exist on top of the branch """ - pipe = [['git', 'log', '--oneline', '@{upstream}..'], + pipe = [['git', 'log', '--no-color', '--oneline', '@{upstream}..'], ['wc', '-l']] stdout = command.RunPipe(pipe, capture=True, oneline=True) patch_count = int(stdout) diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py index 0503bac..ad280cc 100644 --- a/tools/patman/patchstream.py +++ b/tools/patman/patchstream.py @@ -344,7 +344,8 @@ def GetMetaData(start, count): start: Commit to start from: 0=HEAD, 1=next one, etc. count: Number of commits to list """ - pipe = [['git', 'log', '--reverse', 'HEAD~%d' % start, '-n%d' % count]] + pipe = [['git', 'log', '--no-color', '--reverse', 'HEAD~%d' % start, + '-n%d' % count]] stdout = command.RunPipe(pipe, capture=True) series = Series() ps = PatchStream(series, is_log=True) -- cgit v1.1 From 79b9ebb7007cd99409ff506c1bf57b2ab0975243 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Tue, 16 Oct 2012 13:06:06 +0000 Subject: omapimage: Add support for byteswapped SPI images Add MLO.byteswap as a target to spl/Makefile and un-guard the first MLO rule so we don't have to duplicate it. Signed-off-by: Tom Rini --- tools/omapimage.c | 83 +++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 65 insertions(+), 18 deletions(-) (limited to 'tools') diff --git a/tools/omapimage.c b/tools/omapimage.c index 5e739ac..d242cca 100644 --- a/tools/omapimage.c +++ b/tools/omapimage.c @@ -42,6 +42,18 @@ #define OMAP_GP_HDR_SIZE (sizeof(struct gp_header)) #define OMAP_FILE_HDR_SIZE (OMAP_CH_HDR_SIZE+OMAP_GP_HDR_SIZE) +static int do_swap32 = 0; + +static uint32_t omapimage_swap32(uint32_t data) +{ + uint32_t result = 0; + result = (data & 0xFF000000) >> 24; + result |= (data & 0x00FF0000) >> 8; + result |= (data & 0x0000FF00) << 8; + result |= (data & 0x000000FF) << 24; + return result; +} + static uint8_t omapimage_header[OMAP_FILE_HDR_SIZE]; static int omapimage_check_image_types(uint8_t type) @@ -80,12 +92,17 @@ static int omapimage_verify_header(unsigned char *ptr, int image_size, { struct ch_toc *toc = (struct ch_toc *)ptr; struct gp_header *gph = (struct gp_header *)(ptr+OMAP_CH_HDR_SIZE); - uint32_t offset, size; + uint32_t offset, size, gph_size, gph_load_addr; while (toc->section_offset != 0xffffffff && toc->section_size != 0xffffffff) { - offset = toc->section_offset; - size = toc->section_size; + if (do_swap32) { + offset = omapimage_swap32(toc->section_offset); + size = omapimage_swap32(toc->section_size); + } else { + offset = toc->section_offset; + size = toc->section_size; + } if (!offset || !size) return -1; if (offset >= OMAP_CH_HDR_SIZE || @@ -93,9 +110,18 @@ static int omapimage_verify_header(unsigned char *ptr, int image_size, return -1; toc++; } - if (!valid_gph_size(gph->size)) + + if (do_swap32) { + gph_size = omapimage_swap32(gph->size); + gph_load_addr = omapimage_swap32(gph->load_addr); + } else { + gph_size = gph->size; + gph_load_addr = gph->load_addr; + } + + if (!valid_gph_size(gph_size)) return -1; - if (!valid_gph_load_addr(gph->load_addr)) + if (!valid_gph_load_addr(gph_load_addr)) return -1; return 0; @@ -128,12 +154,17 @@ static void omapimage_print_header(const void *ptr) const struct ch_toc *toc = (struct ch_toc *)ptr; const struct gp_header *gph = (struct gp_header *)(ptr+OMAP_CH_HDR_SIZE); - uint32_t offset, size; + uint32_t offset, size, gph_size, gph_load_addr; while (toc->section_offset != 0xffffffff && toc->section_size != 0xffffffff) { - offset = toc->section_offset; - size = toc->section_size; + if (do_swap32) { + offset = omapimage_swap32(toc->section_offset); + size = omapimage_swap32(toc->section_size); + } else { + offset = toc->section_offset; + size = toc->section_size; + } if (offset >= OMAP_CH_HDR_SIZE || offset+size >= OMAP_CH_HDR_SIZE) @@ -148,22 +179,26 @@ static void omapimage_print_header(const void *ptr) toc++; } - if (!valid_gph_size(gph->size)) { - fprintf(stderr, - "Error: invalid image size %x\n", - gph->size); + if (do_swap32) { + gph_size = omapimage_swap32(gph->size); + gph_load_addr = omapimage_swap32(gph->load_addr); + } else { + gph_size = gph->size; + gph_load_addr = gph->load_addr; + } + + if (!valid_gph_size(gph_size)) { + fprintf(stderr, "Error: invalid image size %x\n", gph_size); exit(EXIT_FAILURE); } - if (!valid_gph_load_addr(gph->load_addr)) { - fprintf(stderr, - "Error: invalid image load address %x\n", - gph->size); + if (!valid_gph_load_addr(gph_load_addr)) { + fprintf(stderr, "Error: invalid image load address %x\n", + gph_load_addr); exit(EXIT_FAILURE); } - printf("GP Header: Size %x LoadAddr %x\n", - gph->size, gph->load_addr); + printf("GP Header: Size %x LoadAddr %x\n", gph_size, gph_load_addr); } static int toc_offset(void *hdr, void *member) @@ -194,6 +229,18 @@ static void omapimage_set_header(void *ptr, struct stat *sbuf, int ifd, gph->size = sbuf->st_size - OMAP_FILE_HDR_SIZE; gph->load_addr = params->addr; + + if (strncmp(params->imagename, "byteswap", 8) == 0) { + do_swap32 = 1; + int swapped = 0; + uint32_t *data = (uint32_t *)ptr; + + while (swapped <= (sbuf->st_size / sizeof(uint32_t))) { + *data = omapimage_swap32(*data); + swapped++; + data++; + } + } } int omapimage_check_params(struct mkimage_params *params) -- cgit v1.1 From 619dd5de69bc506e4f4607aa1e698b2fd61b99fe Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 2 Nov 2012 06:38:43 +0000 Subject: patman: Add additional tags to ignore The BRANCH= tag can be used to indicate the destination branch for a commit. Ignore this tag. Also ignore the gerrit 'Commit-Ready:' tag. Signed-off-by: Simon Glass --- tools/patman/patchstream.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py index ad280cc..f7ee75a 100644 --- a/tools/patman/patchstream.py +++ b/tools/patman/patchstream.py @@ -30,8 +30,8 @@ import gitutil from series import Series # Tags that we detect and remove -re_remove = re.compile('^BUG=|^TEST=|^Change-Id:|^Review URL:' - '|Reviewed-on:|Reviewed-by:') +re_remove = re.compile('^BUG=|^TEST=|^BRANCH=|^Change-Id:|^Review URL:' + '|Reviewed-on:|Reviewed-by:|Commit-Ready:') # Lines which are allowed after a TEST= line re_allowed_after_test = re.compile('^Signed-off-by:') -- cgit v1.1