Re: [PATCH 14/14] Add support for Archos G9 tablet

2012-10-22 Thread Jan Weitzel
Am Sonntag, den 21.10.2012, 03:00 +0200 schrieb vj:
 On Fri, Oct 19, 2012 at 1:10 PM, Jan Weitzel j.weit...@phytec.de wrote:
  diff --git a/arch/arm/boards/archosg9/lowlevel.c 
  b/arch/arm/boards/archosg9/lowlevel.c
  new file mode 100644
  index 000..fa5be1d
  --- /dev/null
  +++ b/arch/arm/boards/archosg9/lowlevel.c
  @@ -0,0 +1,79 @@
  +/*
  + * This program is free software; you can redistribute it and/or
  + * modify it under the terms of the GNU General Public License as
  + * published by the Free Software Foundation; either version 2 of
  + * the License, or (at your option) any later version.
  + *
  + * This program is distributed in the hope that it will be useful,
  + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  + * GNU General Public License for more details.
  + */
  +
  +#include common.h
  +#include io.h
  +#include init.h
  +#include mach/omap4-mux.h
  +#include mach/omap4-silicon.h
  +#include mach/omap4-clock.h
  +#include mach/syslib.h
  +#include asm/barebox-arm.h
  +#include asm/barebox-arm-head.h
  +#include mux.h
  +
  +#define TPS62361_VSEL0_GPIO7
  +
  +static const struct ddr_regs ddr_regs_400_mhz_2cs = {
  + .tim1 = 0x10EB0662,
  + .tim2 = 0x20370DD2,
  + .tim3 = 0x00B1C33F,
  + .phy_ctrl_1   = 0x849FF408,
  + .ref_ctrl = 0x0618,
  + .config_init  = 0x8EB9,
  + .config_final = 0x80001AB9,
  + .zq_config= 0xD00B3215,
  + .mr1  = 0x83,
  + .mr2  = 0x4
  +};
  +
  +static noinline void archosg9_init_lowlevel(void)
  +{
  + struct dpll_param core = OMAP4_CORE_DPLL_PARAM_19M2_DDR400;
  + struct dpll_param mpu = OMAP4_MPU_DPLL_PARAM_19M2_MPU600;
  This if OPP100 for 4430, for 4460 OPP100 defines 700MHz.
  + struct dpll_param iva = OMAP4_IVA_DPLL_PARAM_19M2;
  + struct dpll_param per = OMAP4_PER_DPLL_PARAM_19M2;
  + struct dpll_param abe = OMAP4_ABE_DPLL_PARAM_19M2;
  + struct dpll_param usb = OMAP4_USB_DPLL_PARAM_19M2;
  +
  + writel(CM_SYS_CLKSEL_19M2, CM_SYS_CLKSEL);
  +
  + /* Configure all DPLL's at 100% OPP */
  + omap4_configure_mpu_dpll(mpu);
  + omap4_configure_iva_dpll(iva);
  + omap4_configure_per_dpll(per);
  + omap4_configure_abe_dpll(abe);
  + omap4_configure_usb_dpll(usb);
  +
  + /* Enable all clocks */
  + omap4_enable_all_clocks();
  +
  + set_muxconf_regs();
  +
  + omap4_ddr_init(ddr_regs_400_mhz_2cs, core);
  +
  + /* Set VCORE1 = 1.3 V, VCORE2 = VCORE3 = 1.21V */
  + omap4_scale_vcores(TPS62361_VSEL0_GPIO);
  According to TIs DM the sequence for going into a higher OPP is to first
  raise the voltage. I saw this is also wrong on pandaboard.
  They also say rise core freq before mpu freq so the order should be
  omap4_scale_vcores
  omap4_ddr_init
  omap4_configure_mpu_dpll
 
  I'll fix and test the order on PCM049
 
  Jan
 
 The only way I could make it work on archosG9 is with this order:
   set_muxconf_regs();
   writel(CM_SYS_CLKSEL_19M2, CM_SYS_CLKSEL);
   omap4_enable_all_clocks();
   omap4_scale_vcores(TPS62361_VSEL0_GPIO);
   omap4_ddr_init(ddr_regs_400_mhz_2cs, core);
   omap4_configure_mpu_dpll(mpu);
   ...
I think you need al least omap4_enable_gpio1_wup_clocks for using 
TPS62361_VSEL0_GPIO.

Jan
 Is this correct? That is, enable_all_clocks can be done before scale_vcores?
 It will depend on the default clock frequencies, I think.
 
 Vicente



___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 0/8] improve nandtest command

2012-10-22 Thread Alexander Aring
Small Summary:
- The old nandtest do a ecc statistic per eraseblock, it's better to
  do this per page. I don't know how this works with subpages.

- Add a progressbar instead of prints of current flash offset.

- Rename command argument 'passes' to 'iterations', which makes more
  sense.

- use builtin function 'get_random_bytes' to generate random buffer.

- use loff_t instead of off_t. To handle flash 4GB.

- add another constraints check for writesize.

Alexander Aring (8):
  nandtest: stat ecc per page not per eraseblock
  nandtest: add progressbar instead of offset print
  nandtest: rename command argument p to i
  nandtest: change flash length variable type
  nandtest: use get_random_bytes instead of for loop
  nandtest: clean up code
  nandtest: use loff_t instead off_t
  nandtest: add another constraints check

 commands/nandtest.c | 190 
 1 file changed, 103 insertions(+), 87 deletions(-)

-- 
1.7.12.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 1/8] nandtest: stat ecc per page not per eraseblock

2012-10-22 Thread Alexander Aring
Collect ecc statistics per page not per eraseblock.

Signed-off-by: Alexander Aring alex.ar...@gmail.com
---
 commands/nandtest.c | 70 +
 1 file changed, 39 insertions(+), 31 deletions(-)

diff --git a/commands/nandtest.c b/commands/nandtest.c
index d683b24..cdb837f 100644
--- a/commands/nandtest.c
+++ b/commands/nandtest.c
@@ -96,7 +96,8 @@ static ssize_t pwrite(int fd, const void *buf, size_t count, 
off_t offset)
 static int erase_and_write(off_t ofs, unsigned char *data, unsigned char *rbuf)
 {
struct erase_info_user er;
-   int i, ret;
+   unsigned int i;
+   int ret;
 
printf(\r0x%08x: erasing... , (unsigned)(ofs + memregion.offset));
 
@@ -111,43 +112,50 @@ static int erase_and_write(off_t ofs, unsigned char 
*data, unsigned char *rbuf)
return ret;
}
 
-   printf(\r0x%08x: writing..., (unsigned)(ofs + memregion.offset));
+   for (i = 0; i  meminfo.erasesize;
+   i += meminfo.writesize) {
+   printf(\r0x%08x: writing..., (unsigned)
+   (ofs + i + memregion.offset));
 
-   /* Write data to given offset */
-   pwrite(fd, data, meminfo.erasesize, ofs);
+   /* Write data to given offset */
+   pwrite(fd, data + i, meminfo.writesize, ofs + i);
 
-   printf(\r0x%08x: reading..., (unsigned)(ofs + memregion.offset));
+   printf(\r0x%08x: reading..., (unsigned)
+   (ofs + i + memregion.offset));
 
-   /* Read data from offset */
-   pread(fd, rbuf, meminfo.erasesize, ofs);
+   /* Read data from offset */
+   pread(fd, rbuf + i, meminfo.writesize, ofs + i);
 
-   ret = ioctl(fd, ECCGETSTATS, newstats);
-   if (ret  0) {
-   perror(ECCGETSTATS);
-   return ret;
-   }
+   ret = ioctl(fd, ECCGETSTATS, newstats);
+   if (ret  0) {
+   perror(ECCGETSTATS);
+   return ret;
+   }
 
-   if (newstats.corrected  oldstats.corrected) {
-   printf(\n %d bit(s) ECC corrected at 0x%08x\n,
-   newstats.corrected - oldstats.corrected,
-   (unsigned)(ofs + memregion.offset));
-   if ((newstats.corrected-oldstats.corrected) = MAX_ECC_BITS) {
-   /* Increment ECC stats that are over MAX_ECC_BITS */
-   ecc_stats_over++;
-   } else {
-   /* Increment ECC stat value */
-   ecc_stats[(newstats.corrected-oldstats.corrected)-1]++;
+   if (newstats.corrected  oldstats.corrected) {
+   printf(\n %d bit(s) ECC corrected at page 0x%08x\n,
+   newstats.corrected - oldstats.corrected,
+   (unsigned)(ofs + memregion.offset + i));
+   if ((newstats.corrected-oldstats.corrected) =
+   MAX_ECC_BITS) {
+   /* Increment ECC stats that
+* are over MAX_ECC_BITS */
+   ecc_stats_over++;
+   } else {
+   /* Increment ECC stat value */
+   ecc_stats[(newstats.corrected-
+   oldstats.corrected)-1]++;
+   }
+   /* Set oldstats to newstats */
+   oldstats.corrected = newstats.corrected;
+   }
+   if (newstats.failed  oldstats.failed) {
+   printf(\nECC failed at page 0x%08x\n,
+   (unsigned)(ofs + memregion.offset + i));
+   oldstats.failed = newstats.failed;
+   ecc_failed_cnt++;
}
-   /* Set oldstats to newstats */
-   oldstats.corrected = newstats.corrected;
-   }
-   if (newstats.failed  oldstats.failed) {
-   printf(\nECC failed at 0x%08x\n,
-   (unsigned)(ofs + memregion.offset));
-   oldstats.failed = newstats.failed;
-   ecc_failed_cnt++;
}
-
printf(\r0x%08x: checking..., (unsigned)(ofs + memregion.offset));
 
/* Compared written data with read data.
-- 
1.7.12.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 3/8] nandtest: rename command argument p to i

2012-10-22 Thread Alexander Aring
Rename command argument p for 'passes' to 'i' iteration.

Signed-off-by: Alexander Aring alex.ar...@gmail.com
---
 commands/nandtest.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/commands/nandtest.c b/commands/nandtest.c
index f614cd5..656fb65 100644
--- a/commands/nandtest.c
+++ b/commands/nandtest.c
@@ -198,7 +198,7 @@ static int do_nandtest(int argc, char *argv[])
int opt, length = -1, do_nandtest_dev = -1;
off_t flash_offset = 0;
off_t test_ofs;
-   unsigned int nr_passes = 1, pass;
+   unsigned int nr_iterations = 1, iter;
int i;
int ret = -1;
unsigned char *wbuf, *rbuf;
@@ -210,7 +210,7 @@ static int do_nandtest(int argc, char *argv[])
 
memset(ecc_stats, 0, MAX_ECC_BITS);
 
-   while ((opt = getopt(argc, argv, ms:p:o:l:t))  0) {
+   while ((opt = getopt(argc, argv, ms:i:o:l:t))  0) {
switch (opt) {
case 'm':
markbad = 1;
@@ -218,8 +218,8 @@ static int do_nandtest(int argc, char *argv[])
case 's':
seed = simple_strtoul(optarg, NULL, 0);
break;
-   case 'p':
-   nr_passes = simple_strtoul(optarg, NULL, 0);
+   case 'i':
+   nr_iterations = simple_strtoul(optarg, NULL, 0);
break;
case 'o':
flash_offset = simple_strtoul(optarg, NULL, 0);
@@ -310,7 +310,7 @@ static int do_nandtest(int argc, char *argv[])
}
rbuf = wbuf + meminfo.erasesize;
 
-   for (pass = 0; pass  nr_passes; pass++) {
+   for (iter = 0; iter  nr_iterations; iter++) {
init_progression_bar(length);
for (test_ofs = flash_offset;
test_ofs  flash_offset+length;
@@ -338,10 +338,10 @@ static int do_nandtest(int argc, char *argv[])
goto err2;
}
show_progress(test_ofs);
-   printf(\nFinished pass %d successfully\n, pass+1);
+   printf(\nFinished pass %d successfully\n, iter+1);
}
 
-   print_stats(nr_passes, length);
+   print_stats(nr_iterations, length);
 
ret = close(fd);
if (ret  0) {
@@ -366,7 +366,7 @@ static const __maybe_unused char cmd_nandtest_help[] =
  -t,  Really do a nandtest on device.\n
  -m,  Mark blocks bad if they appear so.\n
  -s   seed, Supply random seed.\n
- -p   passes, Number of passes.\n
+ -i   iterations, Number of iterations.\n
  -o   offset, Start offset on flash.\n
  -l   length, Length of flash to test.\n;
 
-- 
1.7.12.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 2/8] nandtest: add progressbar instead of offset print

2012-10-22 Thread Alexander Aring
Add progressbar and remove other outputs of current flash offset.

Signed-off-by: Alexander Aring alex.ar...@gmail.com
---
 commands/nandtest.c | 42 +-
 1 file changed, 25 insertions(+), 17 deletions(-)

diff --git a/commands/nandtest.c b/commands/nandtest.c
index cdb837f..f614cd5 100644
--- a/commands/nandtest.c
+++ b/commands/nandtest.c
@@ -21,6 +21,7 @@
 #include linux/mtd/mtd-abi.h
 #include fcntl.h
 #include stdlib.h
+#include progress.h
 
 /* Max ECC Bits that can be corrected */
 #define MAX_ECC_BITS 8
@@ -64,7 +65,8 @@ static ssize_t pread(int fd, void *buf, size_t count, off_t 
offset)
 /*
  * Implementation of pwrite with lseek and write.
  */
-static ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset)
+static ssize_t pwrite(int fd, const void *buf,
+   size_t count, off_t offset, off_t length)
 {
int ret;
 
@@ -77,9 +79,11 @@ static ssize_t pwrite(int fd, const void *buf, size_t count, 
off_t offset)
if (ret  0) {
perror(write);
if (markbad) {
-   printf(Mark block bad at 0x%08x\n,
+   printf(\nMark block bad at 0x%08x\n,
(unsigned)(offset + memregion.offset));
ioctl(fd, MEMSETBADBLOCK, offset);
+   init_progression_bar(length);
+   show_progress(offset);
}
}
 
@@ -92,21 +96,21 @@ static ssize_t pwrite(int fd, const void *buf, size_t 
count, off_t offset)
  * Param ofs: offset on flash_device.
  * Param data: data to write on flash.
  * Param rbuf: pointer to allocated buffer to copy readed data.
+ * Param length: length of testing area
  */
-static int erase_and_write(off_t ofs, unsigned char *data, unsigned char *rbuf)
+static int erase_and_write(off_t ofs, unsigned char *data,
+   unsigned char *rbuf, off_t length)
 {
struct erase_info_user er;
unsigned int i;
int ret;
 
-   printf(\r0x%08x: erasing... , (unsigned)(ofs + memregion.offset));
-
er.start = ofs;
er.length = meminfo.erasesize;
 
ret = erase(fd, er.length, er.start);
if (ret  0) {
-   perror(erase);
+   perror(\nerase);
printf(Could't not erase flash at 0x%08x length 0x%08x.\n,
   er.start, er.length);
return ret;
@@ -114,21 +118,16 @@ static int erase_and_write(off_t ofs, unsigned char 
*data, unsigned char *rbuf)
 
for (i = 0; i  meminfo.erasesize;
i += meminfo.writesize) {
-   printf(\r0x%08x: writing..., (unsigned)
-   (ofs + i + memregion.offset));
-
/* Write data to given offset */
-   pwrite(fd, data + i, meminfo.writesize, ofs + i);
-
-   printf(\r0x%08x: reading..., (unsigned)
-   (ofs + i + memregion.offset));
+   pwrite(fd, data + i, meminfo.writesize,
+   ofs + i, length);
 
/* Read data from offset */
pread(fd, rbuf + i, meminfo.writesize, ofs + i);
 
ret = ioctl(fd, ECCGETSTATS, newstats);
if (ret  0) {
-   perror(ECCGETSTATS);
+   perror(\nECCGETSTATS);
return ret;
}
 
@@ -136,6 +135,8 @@ static int erase_and_write(off_t ofs, unsigned char *data, 
unsigned char *rbuf)
printf(\n %d bit(s) ECC corrected at page 0x%08x\n,
newstats.corrected - oldstats.corrected,
(unsigned)(ofs + memregion.offset + i));
+   init_progression_bar(length);
+   show_progress(ofs);
if ((newstats.corrected-oldstats.corrected) =
MAX_ECC_BITS) {
/* Increment ECC stats that
@@ -152,11 +153,12 @@ static int erase_and_write(off_t ofs, unsigned char 
*data, unsigned char *rbuf)
if (newstats.failed  oldstats.failed) {
printf(\nECC failed at page 0x%08x\n,
(unsigned)(ofs + memregion.offset + i));
+   init_progression_bar(length);
+   show_progress(ofs);
oldstats.failed = newstats.failed;
ecc_failed_cnt++;
}
}
-   printf(\r0x%08x: checking..., (unsigned)(ofs + memregion.offset));
 
/* Compared written data with read data.
 * If data is not identical, display a detailed
@@ -309,27 +311,33 @@ static int do_nandtest(int argc, char *argv[])
rbuf = wbuf + meminfo.erasesize;
 
for (pass = 0; pass  nr_passes; pass++) {
+   

[PATCH 6/8] nandtest: clean up code

2012-10-22 Thread Alexander Aring
Clean up code:

- change 'i+i' to 'i + i'.
- change counter variable to unsigned int.
- use spaces instead of tabs in help text.
- remove __test_ofs variable.

Signed-off-by: Alexander Aring alex.ar...@gmail.com
---
 commands/nandtest.c | 34 --
 1 file changed, 16 insertions(+), 18 deletions(-)

diff --git a/commands/nandtest.c b/commands/nandtest.c
index cdf9c31..ead728b 100644
--- a/commands/nandtest.c
+++ b/commands/nandtest.c
@@ -144,8 +144,8 @@ static int erase_and_write(off_t ofs, unsigned char *data,
ecc_stats_over++;
} else {
/* Increment ECC stat value */
-   ecc_stats[(newstats.corrected-
-   oldstats.corrected)-1]++;
+   ecc_stats[(newstats.corrected -
+   oldstats.corrected) - 1]++;
}
/* Set oldstats to newstats */
oldstats.corrected = newstats.corrected;
@@ -179,13 +179,13 @@ static int erase_and_write(off_t ofs, unsigned char *data,
 /* Print stats of nandtest. */
 static void print_stats(int nr_passes, int length)
 {
-   int i;
+   unsigned int i;
printf( Summary \n);
printf(Tested blocks   : %d\n, (length/meminfo.erasesize)
* nr_passes);
 
for (i = 0; i  MAX_ECC_BITS; i++)
-   printf(ECC %d bit error(s) : %d\n, i+1, ecc_stats[i]);
+   printf(ECC %d bit error(s) : %d\n, i + 1, ecc_stats[i]);
 
printf(ECC %d bit error(s): %d\n, MAX_ECC_BITS, ecc_stats_over);
printf(ECC corrections failed  : %d\n, ecc_failed_cnt);
@@ -195,10 +195,9 @@ static void print_stats(int nr_passes, int length)
 /* Main program. */
 static int do_nandtest(int argc, char *argv[])
 {
-   int opt, do_nandtest_dev = -1;
+   int opt, do_nandtest_dev = -1, ret = -1;
off_t flash_offset = 0, test_ofs, length = 0;
unsigned int nr_iterations = 1, iter;
-   int ret = -1;
unsigned char *wbuf, *rbuf;
 
ecc_failed_cnt = 0;
@@ -276,10 +275,10 @@ static int do_nandtest(int argc, char *argv[])
}
 
printf(Flash offset: 0x%08x\n,
-   (unsigned)(flash_offset+memregion.offset));
+   (unsigned)(flash_offset + memregion.offset));
printf(Length: 0x%08x\n, (unsigned)length);
printf(End address: 0x%08x\n,
-   (unsigned)(flash_offset+length+memregion.offset));
+   (unsigned)(flash_offset + length + memregion.offset));
printf(Erasesize: 0x%08x\n, (unsigned)(meminfo.erasesize));
printf(Starting nandtest...\n);
 
@@ -311,14 +310,13 @@ static int do_nandtest(int argc, char *argv[])
for (iter = 0; iter  nr_iterations; iter++) {
init_progression_bar(length);
for (test_ofs = flash_offset;
-   test_ofs  flash_offset+length;
+   test_ofs  flash_offset + length;
test_ofs += meminfo.erasesize) {
-   loff_t __test_ofs = test_ofs;
show_progress(test_ofs);
srand(seed);
seed = rand();
 
-   if (ioctl(fd, MEMGETBADBLOCK, __test_ofs)) {
+   if (ioctl(fd, MEMGETBADBLOCK, test_ofs)) {
printf(\nBad block at 0x%08x\n,
(unsigned)(test_ofs +
memregion.offset));
@@ -334,7 +332,7 @@ static int do_nandtest(int argc, char *argv[])
goto err2;
}
show_progress(test_ofs);
-   printf(\nFinished pass %d successfully\n, iter+1);
+   printf(\nFinished pass %d successfully\n, iter + 1);
}
 
print_stats(nr_iterations, length);
@@ -359,12 +357,12 @@ err:
 /* String for usage of nandtest */
 static const __maybe_unused char cmd_nandtest_help[] =
 Usage: nandtest [OPTION] device\n
- -t,  Really do a nandtest on device.\n
- -m,  Mark blocks bad if they appear so.\n
- -s   seed, Supply random seed.\n
- -i   iterations, Number of iterations.\n
- -o   offset, Start offset on flash.\n
- -l   length, Length of flash to test.\n;
+ -t,  Really do a nandtest on device.\n
+ -m,  Mark blocks bad if they appear so.\n
+ -s   seed, Supply random seed.\n
+ -i   iterations, Number of iterations.\n
+ -o   offset, Start offset on flash.\n
+ -l   length, Length of 

[PATCH 5/8] nandtest: use get_random_bytes instead of for loop

2012-10-22 Thread Alexander Aring
Use already builtin get_random_bytes instead of for loop.

Signed-off-by: Alexander Aring alex.ar...@gmail.com
---
 commands/nandtest.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/commands/nandtest.c b/commands/nandtest.c
index e25f062..cdf9c31 100644
--- a/commands/nandtest.c
+++ b/commands/nandtest.c
@@ -198,7 +198,6 @@ static int do_nandtest(int argc, char *argv[])
int opt, do_nandtest_dev = -1;
off_t flash_offset = 0, test_ofs, length = 0;
unsigned int nr_iterations = 1, iter;
-   int i;
int ret = -1;
unsigned char *wbuf, *rbuf;
 
@@ -328,9 +327,7 @@ static int do_nandtest(int argc, char *argv[])
continue;
}
 
-   for (i = 0; i  meminfo.erasesize; i++)
-   wbuf[i] = rand();
-
+   get_random_bytes(wbuf, meminfo.erasesize);
ret = erase_and_write(test_ofs, wbuf,
rbuf, length);
if (ret  0)
-- 
1.7.12.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 1/3] command: introduce abi version

2012-10-22 Thread Jean-Christophe PLAGNIOL-VILLARD
This will allow to detect incompatibility between the env abi and the current
barebox one

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 common/command.c  |2 ++
 include/command.h |1 +
 include/command_abi.h |   12 
 3 files changed, 15 insertions(+)
 create mode 100644 include/command_abi.h

diff --git a/common/command.c b/common/command.c
index 873b3ff..c80538c 100644
--- a/common/command.c
+++ b/common/command.c
@@ -154,6 +154,8 @@ static int init_command_list(void)
 {
struct command *cmdtp;
 
+   export_env_ull(command_abi_version, COMMAND_ABI_VERSION);
+
for (cmdtp = __barebox_cmd_start;
cmdtp != __barebox_cmd_end;
cmdtp++)
diff --git a/include/command.h b/include/command.h
index ffc722c..c49a014 100644
--- a/include/command.h
+++ b/include/command.h
@@ -25,6 +25,7 @@
 
 #include linux/list.h
 #include linux/stringify.h
+#include command_abi.h
 
 #ifndef NULL
 #define NULL   0
diff --git a/include/command_abi.h b/include/command_abi.h
new file mode 100644
index 000..264c003
--- /dev/null
+++ b/include/command_abi.h
@@ -0,0 +1,12 @@
+/*
+ * (C) Copyright 2012 Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
+ *
+ * Under GPL v2
+ */
+
+#ifndef __COMMAND_ABI_H__
+#define __COMMAND_ABI_H__
+
+#define COMMAND_ABI_VERSION0
+
+#endif /* __COMMAND_ABI_H__ */
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 2/3] envfs: add command_abi_version support

2012-10-22 Thread Jean-Christophe PLAGNIOL-VILLARD
allow to store the command abi version
This will allow to detect incompatibility

Increase envfs minor to 1

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagn...@jcrosoft.com
---
 commands/loadenv.c|   11 ++-
 common/environment.c  |7 ++-
 common/startup.c  |4 ++--
 include/envfs.h   |4 ++--
 include/environment.h |   13 -
 scripts/bareboxenv.c  |9 -
 6 files changed, 40 insertions(+), 8 deletions(-)

diff --git a/commands/loadenv.c b/commands/loadenv.c
index 5bf1740..c52ee4b 100644
--- a/commands/loadenv.c
+++ b/commands/loadenv.c
@@ -26,6 +26,9 @@
 
 static int do_loadenv(int argc, char *argv[])
 {
+   int ret;
+   uint16_t command_abi_version;
+
char *filename, *dirname;
 
if (argc  3)
@@ -37,7 +40,13 @@ static int do_loadenv(int argc, char *argv[])
else
filename = argv[1];
printf(loading environment from %s\n, filename);
-   return envfs_load(filename, dirname);
+   ret = envfs_load(filename, dirname, command_abi_version);
+
+   if (command_abi_version  COMMAND_ABI_VERSION)
+   pr_warn(environment command_abi_verison (%u)  current version 
(%u)\n,
+   command_abi_version, COMMAND_ABI_VERSION);
+
+   return ret;
 }
 
 BAREBOX_CMD_HELP_START(loadenv)
diff --git a/common/environment.c b/common/environment.c
index 69c4c0a..e0207e9 100644
--- a/common/environment.c
+++ b/common/environment.c
@@ -162,6 +162,7 @@ int envfs_save(char *filename, char *dirname)
 
super = (struct envfs_super *)buf;
super-magic = ENVFS_32(ENVFS_MAGIC);
+   super-command_abi_version = ENVFS_16(COMMAND_ABI_VERSION);
super-major = ENVFS_MAJOR;
super-minor = ENVFS_MINOR;
super-size = ENVFS_32(size);
@@ -206,7 +207,7 @@ EXPORT_SYMBOL(envfs_save);
  * Note: This function will also be used on the host! See note in the header
  * of this file.
  */
-int envfs_load(char *filename, char *dir)
+int envfs_load(char *filename, char *dir, uint16_t *command_abi_version)
 {
struct envfs_super super;
void *buf = NULL, *buf_free = NULL;
@@ -235,6 +236,7 @@ int envfs_load(char *filename, char *dir)
goto out;
}
 
+
if ( ENVFS_32(super.magic) != ENVFS_MAGIC) {
printf(envfs: wrong magic on %s\n, filename);
ret = -EIO;
@@ -248,6 +250,9 @@ int envfs_load(char *filename, char *dir)
goto out;
}
 
+   if (command_abi_version)
+   *command_abi_version = ENVFS_16(super.command_abi_version);
+
size = ENVFS_32(super.size);
buf = xmalloc(size);
buf_free = buf;
diff --git a/common/startup.c b/common/startup.c
index 78926c9..affb5a9 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -106,12 +106,12 @@ void start_barebox (void)
debug(initcalls done\n);
 
 #ifdef CONFIG_ENV_HANDLING
-   if (envfs_load(default_environment_path, /env)) {
+   if (envfs_load(default_environment_path, /env, NULL)) {
 #ifdef CONFIG_DEFAULT_ENVIRONMENT
printf(no valid environment found on %s. 
Using default environment\n,
default_environment_path);
-   envfs_load(/dev/defaultenv, /env);
+   envfs_load(/dev/defaultenv, /env, NULL);
 #endif
}
 #endif
diff --git a/include/envfs.h b/include/envfs.h
index 3d14fcb..6503d22 100644
--- a/include/envfs.h
+++ b/include/envfs.h
@@ -6,7 +6,7 @@
 #endif
 
 #define ENVFS_MAJOR1
-#define ENVFS_MINOR0
+#define ENVFS_MINOR1
 
 #define ENVFS_MAGIC0x798fba79  /* some random number */
 #define ENVFS_INODE_MAGIC  0x67a8c78d
@@ -40,7 +40,7 @@ struct envfs_super {
uint32_t size;  /* size of data */
uint8_t major;  /* major */
uint8_t minor;  /* minor */
-   uint16_t future;/* reserved for future use */
+   uint16_t command_abi_version;   /* command abi version */
uint32_t flags; /* feature flags */
uint32_t sb_crc;/* crc for the superblock */
 };
diff --git a/include/environment.h b/include/environment.h
index 95e75e7..64de26f 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -74,8 +74,19 @@ int env_push_context(void);
 /* defaults to /dev/env0 */
 extern char *default_environment_path;
 
-int envfs_load(char *filename, char *dirname);
+#ifdef CONFIG_ENV_HANDLING
+int envfs_load(char *filename, char *dir, uint16_t *command_abi_version);
 int envfs_save(char *filename, char *dirname);
+#else
+static inline int envfs_load(char *filename, char *dir, uint16_t 
*command_abi_version)
+{
+   return -EINVAL;
+}
+static inline int envfs_save(char *filename, char *dirname)
+{
+   return -EINVAL;
+}
+#endif
 
 int export(const char *);
 
diff --git a/scripts/bareboxenv.c 

[PATCH] common: Makefile: 'cd' command could lead to broken default_env.h

2012-10-22 Thread Wolfram Sang
Depending on the user's settings (CDPATH), 'cd' may print out the
directory which was changed to. This causes broken barebox_default_env.h
to be generated. Ignore the cd printout.

Signed-off-by: Wolfram Sang w.s...@pengutronix.de
---
 common/Makefile |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/Makefile b/common/Makefile
index 132bd06..f2c8a2e 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -99,7 +99,7 @@ $(obj)/barebox_default_env.lzo: $(obj)/barebox_default_env 
FORCE
$(call if_changed,lzo)
 
 quiet_cmd_env_h = ENVH$@
-cmd_env_h = cat $ | (cd $(obj)  $(objtree)/scripts/bin2c 
default_environment)  $@; \
+cmd_env_h = cat $ | (cd $(obj)  /dev/null  $(objtree)/scripts/bin2c 
default_environment)  $@; \
echo const int default_environment_uncompress_size=`stat -c%s 
$(obj)/barebox_default_env`;  $@
 
 $(obj)/barebox_default_env.h: 
$(obj)/barebox_default_env$(barebox_default_env_comp) FORCE
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] mtd: ubi: cdev: fix build warning for 64-bit

2012-10-22 Thread Wolfram Sang
Got this when compiling sandbox on a 64-bit system:

drivers/mtd/ubi/cdev.c: In function ‘ubi_volume_cdev_read’:
drivers/mtd/ubi/cdev.c:26:2: warning: format ‘%d’ expects argument of type 
‘int’, but argument 3 has type ‘size_t’ [-Wformat]

Signed-off-by: Wolfram Sang w.s...@pengutronix.de
---
 drivers/mtd/ubi/cdev.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c
index 93c3491..4bc4a99 100644
--- a/drivers/mtd/ubi/cdev.c
+++ b/drivers/mtd/ubi/cdev.c
@@ -23,7 +23,7 @@ static ssize_t ubi_volume_cdev_read(struct cdev *cdev, void 
*buf, size_t size,
loff_t offp = offset;
int usable_leb_size = vol-usable_leb_size;
 
-   printf(%s: %d @ 0x%08llx\n, __func__, size, offset);
+   printf(%s: %zd @ 0x%08llx\n, __func__, size, offset);
 
len = size  usable_leb_size ? usable_leb_size : size;
 
-- 
1.7.10.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox