summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/env/fw_env.c130
-rw-r--r--tools/omapimage.c83
-rw-r--r--tools/patman/gitutil.py2
-rw-r--r--tools/patman/patchstream.py3
4 files changed, 95 insertions, 123 deletions
diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index ab8c15d..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 <env_default.h>
static int flash_io (int mode);
static char *envmatch (char * s1, char * s2);
@@ -494,6 +400,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 +412,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);
@@ -738,8 +645,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);
@@ -818,6 +725,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 {
@@ -876,7 +795,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",
@@ -943,7 +863,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,
@@ -957,7 +877,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);
@@ -1224,6 +1145,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;
}
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)
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)