Re: [U-Boot] [PATCH v5] palmtreo680: add utility that writes u-boot to flash

2013-04-26 Thread Smithlife

Dies ist, was ich interessiert bin in.Welcome mich contace.



___
Diablo 3 Gold http://www.mmobf.com/  ; Aion Kinah
http://www.mmobf.com/aion-kinah-566/  ; Diablo 3 Gold Kaufen
http://www.mmobf.com/  ; GW2 Gold http://www.mmobf.com/Guild-Wars-2/  




--
View this message in context: 
http://u-boot.10912.n7.nabble.com/PATCH-v5-palmtreo680-add-utility-that-writes-u-boot-to-flash-tp152882p153395.html
Sent from the U-Boot mailing list archive at Nabble.com.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v5] palmtreo680: add utility that writes u-boot to flash

2013-04-20 Thread Marek Vasut
Dear Mike Dunn,

 This adds a userspace linux utility that writes the u-boot image to an mtd
 partition on the docg4 nand flash.
 
 A special utility is required to do this because u-boot is partially loaded
 by an initial program loader (IPL) that is permanently programmed to the
 boot region of the flash.  This IPL expects the image to be written in a
 unique format. The characteristics of this format can be summarized as
 follows: - Flash blocks to be loaded must have a magic number in the oob
 bytes of the first page of the block.
   - Each page must be written redundantly in the subsequent page.
   - The integrated flash controller's reliable mode is used, requiring
 that alternate 2k regions (4 pages) are skipped when writing.
 For these reasons, a u-boot image can not be written using nandwrite from
 mtd-utils.

I fixed the calloc() semantics and applied, thanks. Please repost whatever is 
still missing in u-boot-pxa/master and I'll then roll pullRQ for mainline.

Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v5] palmtreo680: add utility that writes u-boot to flash

2013-04-20 Thread Mike Dunn
On 04/20/2013 03:25 AM, Marek Vasut wrote:
 Dear Mike Dunn,

[...]

 
 I fixed the calloc() semantics and applied, thanks. Please repost whatever is 
 still missing in u-boot-pxa/master and I'll then roll pullRQ for mainline.

Thanks Marek.  Now I see your point regarding calloc() semantics.  Only

arm: bootm: call udc_disable() before booting linux

is not in your tree; I think you were worried about testing on musb boards.
I'll repost, but no reason to take a risk; I hope to get a patch for the Linux
udc driver upstream soon.

Thanks,
Mike
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v5] palmtreo680: add utility that writes u-boot to flash

2013-04-20 Thread Marek Vasut
Dear Mike Dunn,

 On 04/20/2013 03:25 AM, Marek Vasut wrote:
  Dear Mike Dunn,
 
 [...]
 
  I fixed the calloc() semantics and applied, thanks. Please repost
  whatever is still missing in u-boot-pxa/master and I'll then roll pullRQ
  for mainline.
 
 Thanks Marek.  Now I see your point regarding calloc() semantics.  Only
 
 arm: bootm: call udc_disable() before booting linux
 
 is not in your tree; I think you were worried about testing on musb boards.
 I'll repost, but no reason to take a risk; I hope to get a patch for the
 Linux udc driver upstream soon.

Ah yes, sorry about that. I wonder if Tom tested it or maybe Albert.

Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v5] palmtreo680: add utility that writes u-boot to flash

2013-04-20 Thread Mike Dunn
On 04/20/2013 03:25 AM, Marek Vasut wrote:
 Dear Mike Dunn,
 
 
 I fixed the calloc() semantics and applied, thanks. Please repost whatever is 
 still missing in u-boot-pxa/master and I'll then roll pullRQ for mainline.


Oops, the board support patch is not in your tree either.  Will repost.

Thanks,
Mike
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v5] palmtreo680: add utility that writes u-boot to flash

2013-04-20 Thread Marek Vasut
Dear Mike Dunn,

 On 04/20/2013 03:25 AM, Marek Vasut wrote:
  Dear Mike Dunn,
  
  
  I fixed the calloc() semantics and applied, thanks. Please repost
  whatever is still missing in u-boot-pxa/master and I'll then roll pullRQ
  for mainline.
 
 Oops, the board support patch is not in your tree either.  Will repost.

Did I not ramble about it? Check that first please, I'm not sure now ;-)

Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v5] palmtreo680: add utility that writes u-boot to flash

2013-04-20 Thread Mike Dunn
On 04/20/2013 11:01 AM, Marek Vasut wrote:
 Dear Mike Dunn,
 
 On 04/20/2013 03:25 AM, Marek Vasut wrote:
 Dear Mike Dunn,


 I fixed the calloc() semantics and applied, thanks. Please repost
 whatever is still missing in u-boot-pxa/master and I'll then roll pullRQ
 for mainline.

 Oops, the board support patch is not in your tree either.  Will repost.
 
 Did I not ramble about it? Check that first please, I'm not sure now ;-)
 


Yes, we went back-and-forth about it, and the latest version was v4.  But I need
to rework it because the spl build now fails due to a recent change to
arch/arm/cpu/pxa/start.S in commit 7086e91b0e9930139e703c8f9f857b52baf2bef4

  arm: relocate_code(): Use __image_copy_end for end of relocation

I was using my own linker script for the spl, which does not define the
__image_copy_end symbol that is now referenced in start.S.  I don't exactly
remember why I felt the need to avoid using the script in
arch/arm/cpu/u-boot-spl.lds, except that I didn't like all the sections created
by the --ffunction-sections and --fdata-sections compiler flags and wanted them
combined with a '*' wildcard.  But I removed my linker script and the
CONFIG_SPL_LDSCRIPT line from my config file and it is testing fine.  So I will
have to post a v5 of the patch.

Thanks again Marek,
Mike
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v5] palmtreo680: add utility that writes u-boot to flash

2013-04-19 Thread Mike Dunn
This adds a userspace linux utility that writes the u-boot image to an mtd
partition on the docg4 nand flash.

A special utility is required to do this because u-boot is partially loaded by
an initial program loader (IPL) that is permanently programmed to the boot
region of the flash.  This IPL expects the image to be written in a unique
format. The characteristics of this format can be summarized as follows:
  - Flash blocks to be loaded must have a magic number in the oob bytes of the
first page of the block.
  - Each page must be written redundantly in the subsequent page.
  - The integrated flash controller's reliable mode is used, requiring that
alternate 2k regions (4 pages) are skipped when writing.
For these reasons, a u-boot image can not be written using nandwrite from
mtd-utils.

Signed-off-by: Mike Dunn miked...@newsguy.com
---
Changelog:
  v5: on error, return sensible code from errno.h
  v4:
- use return instead of exit
- use calloc() instead of malloc()
- remove call to read() from within while loop test 
  v3: new patch; split off from patch 7 in v2 of patchset

 tools/palmtreo680/flash_u-boot.c |  177 ++
 1 files changed, 177 insertions(+), 0 deletions(-)
 create mode 100644 tools/palmtreo680/flash_u-boot.c

diff --git a/tools/palmtreo680/flash_u-boot.c b/tools/palmtreo680/flash_u-boot.c
new file mode 100644
index 000..3d8296f
--- /dev/null
+++ b/tools/palmtreo680/flash_u-boot.c
@@ -0,0 +1,177 @@
+/*
+ * Copyright (C) 2013 Mike Dunn miked...@newsguy.com
+ *
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ *
+ *
+ * This is a userspace Linux utility that, when run on the Treo 680, will
+ * program u-boot to flash.  The docg4 driver *must* be loaded with the
+ * reliable_mode and ignore_badblocks parameters enabled:
+ *
+ *modprobe docg4 ignore_badblocks=1 reliable_mode=1
+ *
+ * This utility writes the concatenated spl + u-boot image to the start of the
+ * mtd device in the format expected by the IPL/SPL.  The image file and mtd
+ * device node are passed to the utility as arguments.  The blocks must have
+ * been erased beforehand.
+ *
+ * When you compile this, note that it links to libmtd from mtd-utils, so 
ensure
+ * that your include and lib paths include this.
+ */
+
+#include stdio.h
+#include stdlib.h
+#include sys/stat.h
+#include fcntl.h
+#include string.h
+#include sys/types.h
+#include unistd.h
+#include errno.h
+#include mtd/mtd-user.h
+#include libmtd.h
+
+#define RELIABLE_BLOCKSIZE  0x1 /* block capacity in reliable mode */
+#define STANDARD_BLOCKSIZE  0x4 /* block capacity in normal mode */
+#define PAGESIZE 512
+#define PAGES_PER_BLOCK 512
+#define OOBSIZE 7  /* available to user (16 total) */
+
+uint8_t ff_oob[OOBSIZE] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+
+/* this is the magic number the IPL looks for (ASCII BIPO) */
+uint8_t page0_oob[OOBSIZE] = {'B', 'I', 'P', 'O', 0xff, 0xff, 0xff};
+
+int main(int argc, char * const argv[])
+{
+   int devfd, datafd, num_blocks, block;
+   off_t file_size;
+   libmtd_t mtd_desc;
+   struct mtd_dev_info devinfo;
+   uint8_t *blockbuf;
+   char response[8];
+
+   if (argc != 3) {
+   printf(usage: %s image file mtd dev node\n, argv[0]);
+   return -EINVAL;
+   }
+
+   mtd_desc = libmtd_open();
+   if (mtd_desc == NULL) {
+   int errsv = errno;
+   fprintf(stderr, can't initialize libmtd\n);
+   return -errsv;
+   }
+
+   /* open the spl image file and mtd device */
+   datafd = open(argv[1], O_RDONLY);
+   if (datafd == -1) {
+   int errsv = errno;
+   perror(argv[1]);
+   return -errsv;
+   }
+   devfd = open(argv[2], O_WRONLY);
+   if (devfd == -1) {
+   int errsv = errno;
+   perror(argv[2]);
+   return -errsv;
+   }
+   if (mtd_get_dev_info(mtd_desc, argv[2], devinfo)  0) {
+   int errsv = errno;
+   perror(argv[2]);
+   return -errsv;
+   }
+
+   /* determine the number of blocks needed by the image */
+   file_size = lseek(datafd, 0, SEEK_END);
+   if (file_size == (off_t)-1) {
+   int errsv = errno;
+   perror(lseek);
+   return -errsv;
+   }
+   num_blocks = (file_size + RELIABLE_BLOCKSIZE - 1) / RELIABLE_BLOCKSIZE;
+   file_size = lseek(datafd, 0, SEEK_SET);
+   if (file_size == (off_t)-1) {
+   int errsv = errno;
+   perror(lseek);
+   return -errsv;
+   }
+   printf(The mtd partition contains %d blocks\n, devinfo.eb_cnt);
+   printf(U-boot will occupy %d blocks\n, num_blocks);
+   if (num_blocks  devinfo.eb_cnt) {
+   fprintf(stderr, Insufficient blocks