diff options
author | Frans Meulenbroeks <fransmeulenbroeks@gmail.com> | 2010-02-25 21:28:50 +0100 |
---|---|---|
committer | Frans Meulenbroeks <fransmeulenbroeks@gmail.com> | 2010-02-25 21:42:54 +0100 |
commit | 1ea726f64026f8974887950e4911d19da5f36f57 (patch) | |
tree | aafdd196e08a9a3ae4c2096427e09a3739a485d5 /recipes/u-boot/u-boot-git | |
parent | 6338989af8aed24ab9228c78e2f68a4e8290075c (diff) |
u-boot git: updated calamari SRCREV, add new functionality
Ths commit is for calamari (MPC8636DS) only.
It moves to the head of the mpc85xx git
I also added several patches.
These provide additional functionality w.r.t. expression handling,
As they are not calamari specific I've put them in the u-boot-git directory.
I did not want to apply them right away as I am not sure if they apply to all the various
SRCREVs that are build with this recipe and I did want to break someone else's u-boot.
The patches are also submitted upstream
Signed-off-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com>
Diffstat (limited to 'recipes/u-boot/u-boot-git')
8 files changed, 528 insertions, 0 deletions
diff --git a/recipes/u-boot/u-boot-git/0001-cmd_i2c.c-reduced-subaddress-length-to-3-bytes.patch b/recipes/u-boot/u-boot-git/0001-cmd_i2c.c-reduced-subaddress-length-to-3-bytes.patch new file mode 100644 index 0000000000..afaee11c5d --- /dev/null +++ b/recipes/u-boot/u-boot-git/0001-cmd_i2c.c-reduced-subaddress-length-to-3-bytes.patch @@ -0,0 +1,66 @@ +From 609d8536cd125793fe52b393e854dd7df238c954 Mon Sep 17 00:00:00 2001 +From: Frans Meulenbroeks <fransmeulenbroeks@gmail.com> +Date: Wed, 24 Feb 2010 09:23:00 +0100 +Subject: [PATCH 1/5] cmd_i2c.c: reduced subaddress length to 3 bytes + +according to some of the comments the subaddress length is 1 or 2, but we are being +prepared for the case it becomes 3. However the code also accepted 4. +This repairs this by changing the constand 4 to 3. + +Signed-off-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com> +--- + common/cmd_i2c.c | 10 +++++----- + 1 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c +index 62cbd33..7531702 100644 +--- a/common/cmd_i2c.c ++++ b/common/cmd_i2c.c +@@ -193,7 +193,7 @@ int do_i2c_md ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) + for (j = 0; j < 8; j++) { + if (argv[2][j] == '.') { + alen = argv[2][j+1] - '0'; +- if (alen > 4) { ++ if (alen > 3) { + cmd_usage(cmdtp); + return 1; + } +@@ -287,7 +287,7 @@ int do_i2c_mw ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) + for (j = 0; j < 8; j++) { + if (argv[2][j] == '.') { + alen = argv[2][j+1] - '0'; +- if (alen > 4) { ++ if (alen > 3) { + cmd_usage(cmdtp); + return 1; + } +@@ -361,7 +361,7 @@ int do_i2c_crc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) + for (j = 0; j < 8; j++) { + if (argv[2][j] == '.') { + alen = argv[2][j+1] - '0'; +- if (alen > 4) { ++ if (alen > 3) { + cmd_usage(cmdtp); + return 1; + } +@@ -451,7 +451,7 @@ mod_i2c_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char *argv[]) + for (j = 0; j < 8; j++) { + if (argv[2][j] == '.') { + alen = argv[2][j+1] - '0'; +- if (alen > 4) { ++ if (alen > 3) { + cmd_usage(cmdtp); + return 1; + } +@@ -607,7 +607,7 @@ int do_i2c_loop(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) + for (j = 0; j < 8; j++) { + if (argv[2][j] == '.') { + alen = argv[2][j+1] - '0'; +- if (alen > 4) { ++ if (alen > 3) { + cmd_usage(cmdtp); + return 1; + } +-- +1.7.0 + diff --git a/recipes/u-boot/u-boot-git/0002-cmd_bootm.c-made-subcommand-array-static.patch b/recipes/u-boot/u-boot-git/0002-cmd_bootm.c-made-subcommand-array-static.patch new file mode 100644 index 0000000000..9bf471e347 --- /dev/null +++ b/recipes/u-boot/u-boot-git/0002-cmd_bootm.c-made-subcommand-array-static.patch @@ -0,0 +1,26 @@ +From bdf849874fdb53e9b58adedec3bb54e19d06792c Mon Sep 17 00:00:00 2001 +From: Frans Meulenbroeks <fransmeulenbroeks@gmail.com> +Date: Wed, 24 Feb 2010 10:28:34 +0100 +Subject: [PATCH 2/5] cmd_bootm.c: made subcommand array static + +Signed-off-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com> +--- + common/cmd_bootm.c | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c +index 23ab0c4..827d542 100644 +--- a/common/cmd_bootm.c ++++ b/common/cmd_bootm.c +@@ -462,7 +462,7 @@ static int bootm_start_standalone(ulong iflag, int argc, char *argv[]) + + /* we overload the cmd field with our state machine info instead of a + * function pointer */ +-cmd_tbl_t cmd_bootm_sub[] = { ++static cmd_tbl_t cmd_bootm_sub[] = { + U_BOOT_CMD_MKENT(start, 0, 1, (void *)BOOTM_STATE_START, "", ""), + U_BOOT_CMD_MKENT(loados, 0, 1, (void *)BOOTM_STATE_LOADOS, "", ""), + #if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_SPARC) +-- +1.7.0 + diff --git a/recipes/u-boot/u-boot-git/0002-cmd_itest.c-fix-pointer-dereferencing.patch b/recipes/u-boot/u-boot-git/0002-cmd_itest.c-fix-pointer-dereferencing.patch new file mode 100644 index 0000000000..1b423b9195 --- /dev/null +++ b/recipes/u-boot/u-boot-git/0002-cmd_itest.c-fix-pointer-dereferencing.patch @@ -0,0 +1,40 @@ +Subject: [PATCH 2/2] cmd_itest.c: fix pointer dereferencing +Date: Mon, 22 Feb 2010 22:49:06 +0100 +Message-Id: <1266875346-17025-1-git-send-email-fransmeulenbroeks@gmail.com> +X-Mailer: git-send-email 1.6.4.2 + +fix pointer dereferencing +if the size is .b and .w an 8 or 16 bit access is done. + +Signed-off-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com> +--- + common/cmd_itest.c | 9 +++++++-- + 1 files changed, 7 insertions(+), 2 deletions(-) + +diff --git a/common/cmd_itest.c b/common/cmd_itest.c +index 5b301bf..58c5e7b 100644 +--- a/common/cmd_itest.c ++++ b/common/cmd_itest.c +@@ -66,12 +66,17 @@ op_tbl_t op_table [] = { + + static long evalexp(char *s, int w) + { +- long l, *p; ++ long l = 0; ++ long *p; + + /* if the parameter starts with a * then assume is a pointer to the value we want */ + if (s[0] == '*') { + p = (long *)simple_strtoul(&s[1], NULL, 16); +- l = *p; ++ switch (w) { ++ case 1: return((long)(*(unsigned char *)p)); ++ case 2: return((long)(*(unsigned short *)p)); ++ case 4: return(*p); ++ } + } else { + l = simple_strtoul(s, NULL, 16); + } +-- +1.6.4.2 + diff --git a/recipes/u-boot/u-boot-git/0003-cmd_i2c.c-reworked-subcommand-handling.patch b/recipes/u-boot/u-boot-git/0003-cmd_i2c.c-reworked-subcommand-handling.patch new file mode 100644 index 0000000000..d681bc2a98 --- /dev/null +++ b/recipes/u-boot/u-boot-git/0003-cmd_i2c.c-reworked-subcommand-handling.patch @@ -0,0 +1,109 @@ +From 75ed15eae925d6e9c8078c8fb013d344d7f3d50f Mon Sep 17 00:00:00 2001 +From: Frans Meulenbroeks <fransmeulenbroeks@gmail.com> +Date: Wed, 24 Feb 2010 12:24:34 +0100 +Subject: [PATCH 3/5] cmd_i2c.c: reworked subcommand handling + +Signed-off-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com> +--- + common/cmd_i2c.c | 77 +++++++++++++++++++++++++++++++---------------------- + 1 files changed, 45 insertions(+), 32 deletions(-) + +diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c +index 7531702..e54fc20 100644 +--- a/common/cmd_i2c.c ++++ b/common/cmd_i2c.c +@@ -1242,46 +1242,59 @@ int do_i2c_bus_speed(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) + return ret; + } + +-int do_i2c(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) ++int do_i2c_mm(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) + { +- /* Strip off leading 'i2c' command argument */ +- argc--; +- argv++; ++ return mod_i2c_mem (cmdtp, 1, flag, argc, argv); ++} ++ ++int do_i2c_nm(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) ++{ ++ return mod_i2c_mem (cmdtp, 0, flag, argc, argv); ++} + ++int do_i2c_reset(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) ++{ ++ i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); ++ return 0; ++} ++ ++static cmd_tbl_t cmd_i2c_sub[] = { + #if defined(CONFIG_I2C_MUX) +- if (!strncmp(argv[0], "bu", 2)) +- return do_i2c_add_bus(cmdtp, flag, argc, argv); ++ U_BOOT_CMD_MKENT(bus, 1, 1, do_i2c_add_bus, "", ""), + #endif /* CONFIG_I2C_MUX */ +- if (!strncmp(argv[0], "sp", 2)) +- return do_i2c_bus_speed(cmdtp, flag, argc, argv); ++ U_BOOT_CMD_MKENT(crc32, 3, 1, do_i2c_crc, "", ""), + #if defined(CONFIG_I2C_MULTI_BUS) +- if (!strncmp(argv[0], "de", 2)) +- return do_i2c_bus_num(cmdtp, flag, argc, argv); ++ U_BOOT_CMD_MKENT(dev, 1, 1, do_i2c_bus_num, "", ""), + #endif /* CONFIG_I2C_MULTI_BUS */ +- if (!strncmp(argv[0], "md", 2)) +- return do_i2c_md(cmdtp, flag, argc, argv); +- if (!strncmp(argv[0], "mm", 2)) +- return mod_i2c_mem (cmdtp, 1, flag, argc, argv); +- if (!strncmp(argv[0], "mw", 2)) +- return do_i2c_mw(cmdtp, flag, argc, argv); +- if (!strncmp(argv[0], "nm", 2)) +- return mod_i2c_mem (cmdtp, 0, flag, argc, argv); +- if (!strncmp(argv[0], "cr", 2)) +- return do_i2c_crc(cmdtp, flag, argc, argv); +- if (!strncmp(argv[0], "pr", 2)) +- return do_i2c_probe(cmdtp, flag, argc, argv); +- if (!strncmp(argv[0], "re", 2)) { +- i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); +- return 0; +- } +- if (!strncmp(argv[0], "lo", 2)) +- return do_i2c_loop(cmdtp, flag, argc, argv); ++ U_BOOT_CMD_MKENT(loop, 3, 1, do_i2c_loop, "", ""), ++ U_BOOT_CMD_MKENT(md, 3, 1, do_i2c_md, "", ""), ++ U_BOOT_CMD_MKENT(mm, 2, 1, do_i2c_mm, "", ""), ++ U_BOOT_CMD_MKENT(mw, 3, 1, do_i2c_mw, "", ""), ++ U_BOOT_CMD_MKENT(nm, 2, 1, do_i2c_nm, "", ""), ++ U_BOOT_CMD_MKENT(probe, 0, 1, do_i2c_probe, "", ""), ++ U_BOOT_CMD_MKENT(reset, 0, 1, do_i2c_reset, "", ""), + #if defined(CONFIG_CMD_SDRAM) +- if (!strncmp(argv[0], "sd", 2)) +- return do_sdram(cmdtp, flag, argc, argv); ++ U_BOOT_CMD_MKENT(sdram, 1, 1, do_i2c_sdram, "", ""), + #endif +- cmd_usage(cmdtp); +- return 0; ++ U_BOOT_CMD_MKENT(speed, 1, 1, do_i2c_bus_speed, "", ""), ++}; ++ ++int do_i2c(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) ++{ ++ cmd_tbl_t *c; ++ ++ /* Strip off leading 'i2c' command argument */ ++ argc--; ++ argv++; ++ ++ c = find_cmd_tbl(argv[0], &cmd_i2c_sub[0], ARRAY_SIZE(cmd_i2c_sub)); ++ ++ if (c) { ++ return c->cmd(cmdtp, flag, argc, argv); ++ } else { ++ cmd_usage(cmdtp); ++ return 1; ++ } + } + + /***************************************************/ +-- +1.7.0 + diff --git a/recipes/u-boot/u-boot-git/0004-cmd_i2c.c-sorted-commands-alphabetically.patch b/recipes/u-boot/u-boot-git/0004-cmd_i2c.c-sorted-commands-alphabetically.patch new file mode 100644 index 0000000000..b433d6a582 --- /dev/null +++ b/recipes/u-boot/u-boot-git/0004-cmd_i2c.c-sorted-commands-alphabetically.patch @@ -0,0 +1,48 @@ +From 5ed358a930d5bb79510dadf4e22b8ed9f972f454 Mon Sep 17 00:00:00 2001 +From: Frans Meulenbroeks <fransmeulenbroeks@gmail.com> +Date: Thu, 25 Feb 2010 09:58:24 +0100 +Subject: [PATCH 4/5] cmd_i2c.c: sorted commands alphabetically + +Signed-off-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com> +--- + common/cmd_i2c.c | 11 +++++------ + 1 files changed, 5 insertions(+), 6 deletions(-) + +diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c +index e54fc20..b51e3f4 100644 +--- a/common/cmd_i2c.c ++++ b/common/cmd_i2c.c +@@ -1302,25 +1302,24 @@ int do_i2c(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) + U_BOOT_CMD( + i2c, 6, 1, do_i2c, + "I2C sub-system", +- "speed [speed] - show or set I2C bus speed\n" + #if defined(CONFIG_I2C_MUX) +- "i2c bus [muxtype:muxaddr:muxchannel] - add a new bus reached over muxes\n" ++ "bus [muxtype:muxaddr:muxchannel] - add a new bus reached over muxes\ni2c " + #endif /* CONFIG_I2C_MUX */ ++ "crc32 chip address[.0, .1, .2] count - compute CRC32 checksum\n" + #if defined(CONFIG_I2C_MULTI_BUS) + "i2c dev [dev] - show or set current I2C bus\n" + #endif /* CONFIG_I2C_MULTI_BUS */ ++ "i2c loop chip address[.0, .1, .2] [# of objects] - looping read of device\n" + "i2c md chip address[.0, .1, .2] [# of objects] - read from I2C device\n" + "i2c mm chip address[.0, .1, .2] - write to I2C device (auto-incrementing)\n" + "i2c mw chip address[.0, .1, .2] value [count] - write to I2C device (fill)\n" + "i2c nm chip address[.0, .1, .2] - write to I2C device (constant address)\n" +- "i2c crc32 chip address[.0, .1, .2] count - compute CRC32 checksum\n" + "i2c probe - show devices on the I2C bus\n" + "i2c reset - re-init the I2C Controller\n" +- "i2c loop chip address[.0, .1, .2] [# of objects] - looping read of device" + #if defined(CONFIG_CMD_SDRAM) +- "\n" +- "i2c sdram chip - print SDRAM configuration information" ++ "i2c sdram chip - print SDRAM configuration information\n" + #endif ++ "i2c speed [speed] - show or set I2C bus speed" + ); + + #if defined(CONFIG_I2C_MUX) +-- +1.7.0 + diff --git a/recipes/u-boot/u-boot-git/0005-cmd_i2c.c-added-i2c-read-to-memory-function.patch b/recipes/u-boot/u-boot-git/0005-cmd_i2c.c-added-i2c-read-to-memory-function.patch new file mode 100644 index 0000000000..01d88548f5 --- /dev/null +++ b/recipes/u-boot/u-boot-git/0005-cmd_i2c.c-added-i2c-read-to-memory-function.patch @@ -0,0 +1,107 @@ +From cac3d6cd05cc89a4c1495f7198218ef2ae8088ec Mon Sep 17 00:00:00 2001 +From: Frans Meulenbroeks <fransmeulenbroeks@gmail.com> +Date: Thu, 25 Feb 2010 10:05:37 +0100 +Subject: [PATCH 5/5] cmd_i2c.c: added i2c read to memory function + +Signed-off-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com> +--- + common/cmd_i2c.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++- + 1 files changed, 60 insertions(+), 2 deletions(-) + +diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c +index b51e3f4..9e7143a 100644 +--- a/common/cmd_i2c.c ++++ b/common/cmd_i2c.c +@@ -154,6 +154,63 @@ int i2c_set_bus_speed(unsigned int) + */ + #define DISP_LINE_LEN 16 + ++/* ++ * Syntax: ++ * i2c read {i2c_chip} {devaddr}{.0, .1, .2} {len} {memaddr} ++ */ ++ ++int do_i2c_read ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) ++{ ++ u_char chip; ++ uint devaddr, alen, length; ++ u_char *memaddr; ++ int j; ++ ++ if (argc != 5) { ++ cmd_usage(cmdtp); ++ return 1; ++ } ++ ++ /* ++ * I2C chip address ++ */ ++ chip = simple_strtoul(argv[1], NULL, 16); ++ ++ /* ++ * I2C data address within the chip. This can be 1 or ++ * 2 bytes long. Some day it might be 3 bytes long :-). ++ */ ++ devaddr = simple_strtoul(argv[2], NULL, 16); ++ alen = 1; ++ for (j = 0; j < 8; j++) { ++ if (argv[2][j] == '.') { ++ alen = argv[2][j+1] - '0'; ++ if (alen > 3) { ++ cmd_usage(cmdtp); ++ return 1; ++ } ++ break; ++ } else if (argv[2][j] == '\0') ++ break; ++ } ++ ++ /* ++ * Length is the number of objects, not number of bytes. ++ */ ++ length = simple_strtoul(argv[3], NULL, 16); ++ ++ /* ++ * memaddr is the address where to store things in memory ++ */ ++ memaddr = (u_char *)simple_strtoul(argv[4], NULL, 16); ++ ++ if (i2c_read(chip, devaddr, alen, memaddr, length) != 0) { ++ puts ("Error reading the chip.\n"); ++ return 1; ++ } ++ return 0; ++} ++ + int do_i2c_md ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) + { + u_char chip; +@@ -1272,6 +1329,7 @@ static cmd_tbl_t cmd_i2c_sub[] = { + U_BOOT_CMD_MKENT(mw, 3, 1, do_i2c_mw, "", ""), + U_BOOT_CMD_MKENT(nm, 2, 1, do_i2c_nm, "", ""), + U_BOOT_CMD_MKENT(probe, 0, 1, do_i2c_probe, "", ""), ++ U_BOOT_CMD_MKENT(read, 5, 1, do_i2c_read, "", ""), + U_BOOT_CMD_MKENT(reset, 0, 1, do_i2c_reset, "", ""), + #if defined(CONFIG_CMD_SDRAM) + U_BOOT_CMD_MKENT(sdram, 1, 1, do_i2c_sdram, "", ""), +@@ -1315,6 +1373,7 @@ U_BOOT_CMD( + "i2c mw chip address[.0, .1, .2] value [count] - write to I2C device (fill)\n" + "i2c nm chip address[.0, .1, .2] - write to I2C device (constant address)\n" + "i2c probe - show devices on the I2C bus\n" ++ "i2c read chip address[.0, .1, .2] length memaddress - read to memory \n" + "i2c reset - re-init the I2C Controller\n" + #if defined(CONFIG_CMD_SDRAM) + "i2c sdram chip - print SDRAM configuration information\n" +@@ -1322,8 +1381,7 @@ U_BOOT_CMD( + "i2c speed [speed] - show or set I2C bus speed" + ); + +-#if defined(CONFIG_I2C_MUX) +- ++#if defined(CONFIG_I2C_MUX) + int i2c_mux_add_device(I2C_MUX_DEVICE *dev) + { + I2C_MUX_DEVICE *devtmp = i2c_mux_devices; +-- +1.7.0 + diff --git a/recipes/u-boot/u-boot-git/0006-cmd_itest.c-also-support-environment-variables-as-a.patch b/recipes/u-boot/u-boot-git/0006-cmd_itest.c-also-support-environment-variables-as-a.patch new file mode 100644 index 0000000000..fc77736f8a --- /dev/null +++ b/recipes/u-boot/u-boot-git/0006-cmd_itest.c-also-support-environment-variables-as-a.patch @@ -0,0 +1,39 @@ +From 11e8b9d3df819406049b36bed2f3fcf43ddd7f12 Mon Sep 17 00:00:00 2001 +From: Frans Meulenbroeks <fransmeulenbroeks@gmail.com> +Date: Wed, 24 Feb 2010 15:33:29 +0100 +Subject: [PATCH] cmd_itest.c: also support environment variables as arguments + +Signed-off-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com> +--- + common/cmd_itest.c | 8 ++++++++ + 1 files changed, 8 insertions(+), 0 deletions(-) + +diff --git a/common/cmd_itest.c b/common/cmd_itest.c +index 58c5e7b..78a4082 100644 +--- a/common/cmd_itest.c ++++ b/common/cmd_itest.c +@@ -69,6 +69,10 @@ static long evalexp(char *s, int w) + long l = 0; + long *p; + ++ /* if the parameter starts with a $ replace it with the environment value */ ++ if (s[0] == '$') { ++ s = getenv(&s[1]); ++ } + /* if the parameter starts with a * then assume is a pointer to the value we want */ + if (s[0] == '*') { + p = (long *)simple_strtoul(&s[1], NULL, 16); +@@ -86,6 +90,10 @@ static long evalexp(char *s, int w) + + static char * evalstr(char *s) + { ++ /* if the parameter starts with a $ replace it with the environment value */ ++ if (s[0] == '$') { ++ s = getenv(&s[1]); ++ } + /* if the parameter starts with a * then assume a string pointer else its a literal */ + if (s[0] == '*') { + return (char *)simple_strtoul(&s[1], NULL, 16); +-- +1.5.4.3 + diff --git a/recipes/u-boot/u-boot-git/0007-cmd_setexpr-allow-memory-addresses-and-env-vars-in-e.patch b/recipes/u-boot/u-boot-git/0007-cmd_setexpr-allow-memory-addresses-and-env-vars-in-e.patch new file mode 100644 index 0000000000..10fc4735a2 --- /dev/null +++ b/recipes/u-boot/u-boot-git/0007-cmd_setexpr-allow-memory-addresses-and-env-vars-in-e.patch @@ -0,0 +1,93 @@ +From 0d685fe90ab92ccb9f15b7d79b1063f5b79b2dd5 Mon Sep 17 00:00:00 2001 +From: Frans Meulenbroeks <fransmeulenbroeks@gmail.com> +Date: Thu, 25 Feb 2010 11:05:31 +0100 +Subject: [PATCH 7/7] cmd_setexpr: allow memory addresses and env vars in expressions + +This patch add functionality to use memory addresses and environment variables in +expressions. This increases the power of expressions substantially + +It adheres to the standard convemtions: memory addresses can be given in the format +*address (e.g. *1000), environment variables as $this_var. +environment variables are not processed recursively but can contain both constants +and memory addresses. + +Rationale for this change is that it allows masking off bits from a byte that is +obtained by reading data from e.g. i2c. + +Signed-off-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com> + +--- + +If recursive environment vars is desired: this can be added easily by changing the +if statement into a while statement. +I figured that would be somewhat over the top though (and, unless you take +special precautions you can run into an endless loop if an env var contains +its own name. +If it is desired, please let me know and I happily will add it. +--- + common/cmd_setexpr.c | 31 ++++++++++++++++++++++++++++--- + 1 files changed, 28 insertions(+), 3 deletions(-) + +diff --git a/common/cmd_setexpr.c b/common/cmd_setexpr.c +index f8b5d4d..a7c6f53 100644 +--- a/common/cmd_setexpr.c ++++ b/common/cmd_setexpr.c +@@ -28,10 +28,32 @@ + #include <config.h> + #include <command.h> + ++static ulong get_arg(char *s, int w) ++{ ++ ulong *p; ++ ++ /* if the parameter starts with a $ replace it with the environment value */ ++ if (s[0] == '$') { ++ s = getenv(&s[1]); ++ } ++ /* if the parameter starts with a * then assume is a pointer to the value we want */ ++ if (s[0] == '*') { ++ p = (ulong *)simple_strtoul(&s[1], NULL, 16); ++ switch (w) { ++ case 1: return((ulong)(*(uchar *)p)); ++ case 2: return((ulong)(*(ushort *)p)); ++ case 4: return(*p); ++ } ++ } else { ++ return simple_strtoul(s, NULL, 16); ++ } ++} ++ + int do_setexpr(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) + { + ulong a, b; + char buf[16]; ++ int w; + + /* Validate arguments */ + if ((argc != 5) || (strlen(argv[3]) != 1)) { +@@ -39,8 +61,10 @@ int do_setexpr(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) + return 1; + } + +- a = simple_strtoul(argv[2], NULL, 16); +- b = simple_strtoul(argv[4], NULL, 16); ++ w = cmd_get_data_size(argv[0], 4); ++ ++ a = get_arg(argv[2], w); ++ b = get_arg(argv[4], w); + + switch (argv[3][0]) { + case '|': sprintf(buf, "%lx", (a | b)); break; +@@ -64,7 +88,8 @@ int do_setexpr(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) + U_BOOT_CMD( + setexpr, 5, 0, do_setexpr, + "set environment variable as the result of eval expression", +- "name value1 <op> value2\n" ++ "[.b, .w, .l] name value1 <op> value2\n" + " - set environment variable 'name' to the result of the evaluated\n" + " express specified by <op>. <op> can be &, |, ^, +, -, *, /, %" ++ " size argument is only meaningful if value1 and/or value2 are memory addresses" + ); +-- +1.7.0 + |