All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/4][repost] tools: mkimage: Making genimg_print_size API global
@ 2009-08-24 17:33 Prafulla Wadaskar
  2009-08-24 17:33 ` [U-Boot] [PATCH 2/4][repost] tools: mkimage: Making table_entry code global Prafulla Wadaskar
  0 siblings, 1 reply; 16+ messages in thread
From: Prafulla Wadaskar @ 2009-08-24 17:33 UTC (permalink / raw)
  To: u-boot

Currently it is used by image.c only
This API can be used by additional mkimage types supports
for ex. kwbimage, to use it the API is made global

Signed-off-by: Prafulla Wadaskar <prafulla@marvell.com>
---
 common/image.c  |    3 +--
 include/image.h |    1 +
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/image.c b/common/image.c
index f3dd647..ca8205c 100644
--- a/common/image.c
+++ b/common/image.c
@@ -158,7 +158,6 @@ static table_entry_t uimage_comp[] = {
 
 uint32_t crc32 (uint32_t, const unsigned char *, uint);
 uint32_t crc32_wd (uint32_t, const unsigned char *, uint, uint);
-static void genimg_print_size (uint32_t size);
 #if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) || defined(USE_HOSTCC)
 static void genimg_print_time (time_t timestamp);
 #endif
@@ -473,7 +472,7 @@ void memmove_wd (void *to, void *from, size_t len, ulong chunksz)
 }
 #endif /* !USE_HOSTCC */
 
-static void genimg_print_size (uint32_t size)
+void genimg_print_size (uint32_t size)
 {
 #ifndef USE_HOSTCC
 	printf ("%d Bytes = ", size);
diff --git a/include/image.h b/include/image.h
index a62669f..4a7bf78 100644
--- a/include/image.h
+++ b/include/image.h
@@ -292,6 +292,7 @@ int genimg_get_os_id (const char *name);
 int genimg_get_arch_id (const char *name);
 int genimg_get_type_id (const char *name);
 int genimg_get_comp_id (const char *name);
+void genimg_print_size (uint32_t size);
 
 #ifndef USE_HOSTCC
 /* Image format types, returned by _get_format() routine */
-- 
1.5.3.3

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH 2/4][repost] tools: mkimage: Making table_entry code global
  2009-08-24 17:33 [U-Boot] [PATCH 1/4][repost] tools: mkimage: Making genimg_print_size API global Prafulla Wadaskar
@ 2009-08-24 17:33 ` Prafulla Wadaskar
  2009-08-24 17:33   ` [U-Boot] [PATCH 3/4][repost] Kirkwood: Sheevaplug: kwimage configuration Prafulla Wadaskar
  0 siblings, 1 reply; 16+ messages in thread
From: Prafulla Wadaskar @ 2009-08-24 17:33 UTC (permalink / raw)
  To: u-boot

1. get_table_entry_id API made global
2. get_table_entry_name API made global
3. struct table_entry moved to image.h

Currently it is used by image.c only
These APIs are very usefull and can be used by other part of code

This patch makes these APIs and struct global

Signed-off-by: Prafulla Wadaskar <prafulla@marvell.com>
---
 common/image.c  |   10 ++--------
 include/image.h |   26 ++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/common/image.c b/common/image.c
index ca8205c..e8ecfa5 100644
--- a/common/image.c
+++ b/common/image.c
@@ -74,12 +74,6 @@ static const image_header_t* image_get_ramdisk (ulong rd_addr, uint8_t arch,
 #include <image.h>
 #endif /* !USE_HOSTCC*/
 
-typedef struct table_entry {
-	int	id;		/* as defined in image.h	*/
-	char	*sname;		/* short (input) name		*/
-	char	*lname;		/* long (output) name		*/
-} table_entry_t;
-
 static table_entry_t uimage_arch[] = {
 	{	IH_ARCH_INVALID,	NULL,		"Invalid ARCH",	},
 	{	IH_ARCH_ALPHA,		"alpha",	"Alpha",	},
@@ -514,7 +508,7 @@ static void genimg_print_time (time_t timestamp)
  *     long entry name if translation succeeds
  *     msg otherwise
  */
-static char *get_table_entry_name (table_entry_t *table, char *msg, int id)
+char *get_table_entry_name (table_entry_t *table, char *msg, int id)
 {
 	for (; table->id >= 0; ++table) {
 		if (table->id == id)
@@ -561,7 +555,7 @@ const char *genimg_get_comp_name (uint8_t comp)
  *     entry id if translation succeeds
  *     -1 otherwise
  */
-static int get_table_entry_id (table_entry_t *table,
+int get_table_entry_id (table_entry_t *table,
 		const char *table_name, const char *name)
 {
 	table_entry_t *t;
diff --git a/include/image.h b/include/image.h
index 4a7bf78..58f13f9 100644
--- a/include/image.h
+++ b/include/image.h
@@ -284,6 +284,32 @@ typedef struct bootm_headers {
 #define uimage_to_cpu(x)		be32_to_cpu(x)
 #define cpu_to_uimage(x)		cpu_to_be32(x)
 
+/*
+ * Translation table for entries of a specific type
+ * This structue is used by the global functions get_table_entry_id,
+ * get_table_entry_name and these functions and this structure can also be
+ * referred by other part of code
+ */
+typedef struct table_entry {
+	int	id;
+	char	*sname;		/* name used to find table entry */
+	char	*lname;		/* name used to print for messages */
+} table_entry_t;
+
+/*
+ * get_table_entry_id() will go over translation table trying to find
+ * entry that matches given short name. If matching entry is found,
+ * its id returned to the caller.
+ */
+int get_table_entry_id (table_entry_t *table,
+		const char *table_name, const char *name);
+/*
+ * get_table_entry_name() will go over translation table trying to find
+ * entry that matches given id. If matching entry is found, its long
+ * name is returned to the caller.
+ */
+char *get_table_entry_name (table_entry_t *table, char *msg, int id);
+
 const char *genimg_get_os_name (uint8_t os);
 const char *genimg_get_arch_name (uint8_t arch);
 const char *genimg_get_type_name (uint8_t type);
-- 
1.5.3.3

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH 3/4][repost] Kirkwood: Sheevaplug: kwimage configuration
  2009-08-24 17:33 ` [U-Boot] [PATCH 2/4][repost] tools: mkimage: Making table_entry code global Prafulla Wadaskar
@ 2009-08-24 17:33   ` Prafulla Wadaskar
  2009-08-24 17:33     ` [U-Boot] [PATCH v3 4/4] tools: mkimage: Add: Kirkwood Boot Image support (kwbimage) Prafulla Wadaskar
  0 siblings, 1 reply; 16+ messages in thread
From: Prafulla Wadaskar @ 2009-08-24 17:33 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Prafulla Wadaskar <prafulla@marvell.com>
---
 board/Marvell/sheevaplug/config.mk    |    3 +
 board/Marvell/sheevaplug/kwbimage.cfg |  162 +++++++++++++++++++++++++++++++++
 2 files changed, 165 insertions(+), 0 deletions(-)
 create mode 100644 board/Marvell/sheevaplug/kwbimage.cfg

diff --git a/board/Marvell/sheevaplug/config.mk b/board/Marvell/sheevaplug/config.mk
index a4ea769..2bd9f79 100644
--- a/board/Marvell/sheevaplug/config.mk
+++ b/board/Marvell/sheevaplug/config.mk
@@ -23,3 +23,6 @@
 #
 
 TEXT_BASE = 0x00600000
+
+# Kirkwood Boot Image configuration file
+KWD_CONFIG = $(SRCTREE)/board/$(BOARDDIR)/kwbimage.cfg
diff --git a/board/Marvell/sheevaplug/kwbimage.cfg b/board/Marvell/sheevaplug/kwbimage.cfg
new file mode 100644
index 0000000..6c47d62
--- /dev/null
+++ b/board/Marvell/sheevaplug/kwbimage.cfg
@@ -0,0 +1,162 @@
+#
+# (C) Copyright 2009
+# Marvell Semiconductor <www.marvell.com>
+# Written-by: Prafulla Wadaskar <prafulla@marvell.com>
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# 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.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301 USA
+#
+# Refer docs/README.kwimage for more details about how-to configure
+# and create kirkwood boot image
+#
+
+# Boot Media configurations
+BOOT_FROM	nand
+NAND_ECC_MODE	default
+NAND_PAGE_SIZE	0x0800
+
+# SOC registers configuration using bootrom header extension
+# Maximum KWBIMAGE_MAX_CONFIG configurations allowed
+
+# Configure RGMII-0 interface pad voltage to 1.8V
+DATA 0xFFD100e0 0x1b1b1b9b
+
+#Dram initalization for SINGLE x16 CL=5 @ 400MHz
+DATA 0xFFD01400 0x43000c30	# DDR Configuration register
+# bit13-0:  0xc30 (3120 DDR2 clks refresh rate)
+# bit23-14: zero
+# bit24: 1= enable exit self refresh mode on DDR access
+# bit25: 1 required
+# bit29-26: zero
+# bit31-30: 01
+
+DATA 0xFFD01404 0x37543000	# DDR Controller Control Low
+# bit 4:    0=addr/cmd in smame cycle
+# bit 5:    0=clk is driven during self refresh, we don't care for APX
+# bit 6:    0=use recommended falling edge of clk for addr/cmd
+# bit14:    0=input buffer always powered up
+# bit18:    1=cpu lock transaction enabled
+# bit23-20: 5=recommended value for CL=5 and STARTBURST_DEL disabled bit31=0
+# bit27-24: 7= CL+2, STARTBURST sample stages, for freqs 400MHz, unbuffered DIMM
+# bit30-28: 3 required
+# bit31:    0=no additional STARTBURST delay
+
+DATA 0xFFD01408 0x22125451	# DDR Timing (Low) (active cycles value +1)
+# bit3-0:   TRAS lsbs
+# bit7-4:   TRCD
+# bit11- 8: TRP
+# bit15-12: TWR
+# bit19-16: TWTR
+# bit20:    TRAS msb
+# bit23-21: 0x0
+# bit27-24: TRRD
+# bit31-28: TRTP
+
+DATA 0xFFD0140C 0x00000a33	#  DDR Timing (High)
+# bit6-0:   TRFC
+# bit8-7:   TR2R
+# bit10-9:  TR2W
+# bit12-11: TW2W
+# bit31-13: zero required
+
+DATA 0xFFD01410 0x00000099	#  DDR Address Control
+# bit1-0:   01, Cs0width=x16
+# bit3-2:   10, Cs0size=512Mb
+# bit5-4:   01, Cs1width=x16
+# bit7-6:   10, Cs1size=512Mb
+# bit9-8:   00, Cs2width=nonexistent
+# bit11-10: 00, Cs2size =nonexistent
+# bit13-12: 00, Cs3width=nonexistent
+# bit15-14: 00, Cs3size =nonexistent
+# bit16:    0,  Cs0AddrSel
+# bit17:    0,  Cs1AddrSel
+# bit18:    0,  Cs2AddrSel
+# bit19:    0,  Cs3AddrSel
+# bit31-20: 0 required
+
+DATA 0xFFD01414 0x00000000	#  DDR Open Pages Control
+# bit0:    0,  OpenPage enabled
+# bit31-1: 0 required
+
+DATA 0xFFD01418 0x00000000	#  DDR Operation
+# bit3-0:   0x0, DDR cmd
+# bit31-4:  0 required
+
+DATA 0xFFD0141C 0x00000C52	#  DDR Mode
+# bit2-0:   2, BurstLen=2 required
+# bit3:     0, BurstType=0 required
+# bit6-4:   4, CL=5
+# bit7:     0, TestMode=0 normal
+# bit8:     0, DLL reset=0 normal
+# bit11-9:  6, auto-precharge write recovery ????????????
+# bit12:    0, PD must be zero
+# bit31-13: 0 required
+
+DATA 0xFFD01420 0x00000040	#  DDR Extended Mode
+# bit0:    0,  DDR DLL enabled
+# bit1:    0,  DDR drive strenght normal
+# bit2:    0,  DDR ODT control lsd (disabled)
+# bit5-3:  000, required
+# bit6:    1,  DDR ODT control msb, (disabled)
+# bit9-7:  000, required
+# bit10:   0,  differential DQS enabled
+# bit11:   0, required
+# bit12:   0, DDR output buffer enabled
+# bit31-13: 0 required
+
+DATA 0xFFD01424 0x0000F17F	#  DDR Controller Control High
+# bit2-0:  111, required
+# bit3  :  1  , MBUS Burst Chop disabled
+# bit6-4:  111, required
+# bit7  :  0
+# bit8  :  1  , add writepath sample stage, must be 1 for DDR freq >= 300MHz
+# bit9  :  0  , no half clock cycle addition to dataout
+# bit10 :  0  , 1/4 clock cycle skew enabled for addr/ctl signals
+# bit11 :  0  , 1/4 clock cycle skew disabled for write mesh
+# bit15-12: 1111 required
+# bit31-16: 0    required
+
+DATA 0xFFD01428 0x00085520	# DDR2 ODT Read Timing (default values)
+DATA 0xFFD0147C 0x00008552	# DDR2 ODT Write Timing (default values)
+
+DATA 0xFFD01500 0x00000000	# CS[0]n Base address to 0x0
+DATA 0xFFD01504 0x0FFFFFF1	# CS[0]n Size
+# bit0:    1,  Window enabled
+# bit1:    0,  Write Protect disabled
+# bit3-2:  00, CS0 hit selected
+# bit23-4: ones, required
+# bit31-24: 0x0F, Size (i.e. 256MB)
+
+DATA 0xFFD01508 0x10000000	# CS[1]n Base address to 256Mb
+DATA 0xFFD0150C 0x0FFFFFF5	# CS[1]n Size 256Mb Window enabled for CS1
+
+DATA 0xFFD01514 0x00000000	# CS[2]n Size, window disabled
+DATA 0xFFD0151C 0x00000000	# CS[3]n Size, window disabled
+
+DATA 0xFFD01494 0x00030000	#  DDR ODT Control (Low)
+DATA 0xFFD01498 0x00000000	#  DDR ODT Control (High)
+# bit1-0:  00, ODT0 controlled by ODT Control (low) register above
+# bit3-2:  01, ODT1 active NEVER!
+# bit31-4: zero, required
+
+DATA 0xFFD0149C 0x0000E803	# CPU ODT Control
+DATA 0xFFD01480 0x00000001	# DDR Initialization Control
+#bit0=1, enable DDR init upon this register write
+
+# End of Header extension
+DATA 0x0 0x0
-- 
1.5.3.3

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH v3 4/4] tools: mkimage: Add: Kirkwood Boot Image support (kwbimage)
  2009-08-24 17:33   ` [U-Boot] [PATCH 3/4][repost] Kirkwood: Sheevaplug: kwimage configuration Prafulla Wadaskar
@ 2009-08-24 17:33     ` Prafulla Wadaskar
  2009-09-01 17:15       ` Prafulla Wadaskar
  2009-09-03 12:00       ` Simon Kagstrom
  0 siblings, 2 replies; 16+ messages in thread
From: Prafulla Wadaskar @ 2009-08-24 17:33 UTC (permalink / raw)
  To: u-boot

This patch adds type kwbimabe support for new mkimage core
For more details refer docs/README.kwbimage

This patch is tested with Sheevaplug board

Signed-off-by: Prafulla Wadaskar <prafulla@marvell.com>
---
Change log:
v2: updated as per review comments for v1
added len checks in checksum functions
added printable strings for each valid table entry
use of sccanf not changed since it offers return value for failure

v3: resolved merge issues on mkimage branch

 Makefile            |    5 +
 common/image.c      |    1 +
 doc/README.kwbimage |   93 ++++++++++++
 include/image.h     |    1 +
 tools/Makefile      |    4 +
 tools/kwbimage.c    |  402 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/kwbimage.h    |  106 ++++++++++++++
 tools/mkimage.c     |    2 +
 8 files changed, 614 insertions(+), 0 deletions(-)
 create mode 100644 doc/README.kwbimage
 create mode 100644 tools/kwbimage.c
 create mode 100644 tools/kwbimage.h

diff --git a/Makefile b/Makefile
index 02393b6..fcf7404 100644
--- a/Makefile
+++ b/Makefile
@@ -322,6 +322,10 @@ $(obj)u-boot.img:	$(obj)u-boot.bin
 			sed -e 's/"[	 ]*$$/ for $(BOARD) board"/') \
 		-d $< $@
 
+$(obj)u-boot.kwb:       $(obj)u-boot.bin
+		$(obj)tools/mkimage -n $(KWD_CONFIG) -T kwbimage \
+		-a $(TEXT_BASE) -e $(TEXT_BASE) -d $< $@
+
 $(obj)u-boot.sha1:	$(obj)u-boot.bin
 		$(obj)tools/ubsha1 $(obj)u-boot.bin
 
@@ -3701,6 +3705,7 @@ clobber:	clean
 	@rm -f $(OBJS) $(obj)*.bak $(obj)ctags $(obj)etags $(obj)TAGS \
 		$(obj)cscope.* $(obj)*.*~
 	@rm -f $(obj)u-boot $(obj)u-boot.map $(obj)u-boot.hex $(ALL)
+	@rm -f $(obj)u-boot.kwb
 	@rm -f $(obj)tools/{env/crc32.c,inca-swap-bytes}
 	@rm -f $(obj)cpu/mpc824x/bedbug_603e.c
 	@rm -f $(obj)include/asm/proc $(obj)include/asm/arch $(obj)include/asm
diff --git a/common/image.c b/common/image.c
index f3dd647..370acd0 100644
--- a/common/image.c
+++ b/common/image.c
@@ -145,6 +145,7 @@ static table_entry_t uimage_type[] = {
 	{	IH_TYPE_SCRIPT,     "script",	  "Script",		},
 	{	IH_TYPE_STANDALONE, "standalone", "Standalone Program", },
 	{	IH_TYPE_FLATDT,     "flat_dt",    "Flat Device Tree",	},
+	{	IH_TYPE_KWBIMAGE,   "kwbimage",   "Kirkwood Boot Image",},
 	{	-1,		    "",		  "",			},
 };
 
diff --git a/doc/README.kwbimage b/doc/README.kwbimage
new file mode 100644
index 0000000..2a5b3b3
--- /dev/null
+++ b/doc/README.kwbimage
@@ -0,0 +1,93 @@
+---------------------------------------------
+Kirkwood Boot Image generation using mkimage
+---------------------------------------------
+
+This document describes the U-Boot feature as it
+is implemented for the Kirkwood family of SoCs.
+
+The Kirkwood SoC's can boot directly from NAND FLASH,
+SPI FLASH, SATA etc. using its internal bootRom support.
+
+for more details refer section 24.2 of Kirkwood functional specifications.
+ref: www.marvell.com/products/embedded.../kirkwood/index.jsp
+
+Command syntax:
+--------------
+./tools/mkimage -l <kwboot_file>
+		to list the kwb image file details
+
+./tools/mkimage -n <board specific configuration file> \
+                -T kwbimage -a <start address> -e <execution address> \
+		-d <input_raw_binary> <output_kwboot_file>
+
+for ex.
+./tools/mkimage -n ./board/Marvell/openrd_base/kwbimage.cfg \
+                -T kwbimage -a 0x00600000 -e 0x00600000 \
+		-d u-boot.bin u-boot.kwb
+
+kwimage support available with mkimage utility will generate kirkwood boot
+image that can be flashed on the board NAND/SPI flash
+
+Board specific configuration file specifications:
+------------------------------------------------
+1. This file must present in the $(BOARDDIR) and the name should be
+	kwbimage.cfg (since this is used in Makefile)
+2. This file can have empty lines and lines starting with "#" as first
+	character to put comments
+3. This file can have configuration command lines as mentioned below,
+	any other information in this file is treated as invalid.
+
+Configuration command line syntax:
+---------------------------------
+1. Each command line is must have two strings, first one command or address
+	and second one data string
+2. Following are the valid command strings and associated data strings:-
+	Command string		data string
+	--------------		-----------
+	BOOT_FROM		nand/spi/sata
+	NAND_ECC_MODE		default/rs/hamming/disabled
+	NAND_PAGE_SIZE		any uint16_t hex value
+	SATA_PIO_MODE		any uint32_t hex value
+	DDR_INIT_DELAY		any uint32_t hex value
+	DATA			regaddr and regdara hex value
+	you can have maximum 55 such register programming commands
+
+3. All commands are optional to program
+
+Typical example of kwimage.cfg file:
+-----------------------------------
+
+# Boot Media configurations
+BOOT_FROM	nand
+NAND_ECC_MODE	default
+NAND_PAGE_SIZE	0x0800
+
+# Configure RGMII-0 interface pad voltage to 1.8V
+DATA 0xFFD100e0 0x1b1b1b9b
+# DRAM Configuration
+DATA 0xFFD01400 0x43000c30
+DATA 0xFFD01404 0x37543000
+DATA 0xFFD01408 0x22125451
+DATA 0xFFD0140C 0x00000a33
+DATA 0xFFD01410 0x000000cc
+DATA 0xFFD01414 0x00000000
+DATA 0xFFD01418 0x00000000
+DATA 0xFFD0141C 0x00000C52
+DATA 0xFFD01420 0x00000040
+DATA 0xFFD01424 0x0000F17F
+DATA 0xFFD01428 0x00085520
+DATA 0xFFD0147C 0x00008552
+DATA 0xFFD01504 0x0FFFFFF1
+DATA 0xFFD01508 0x10000000
+DATA 0xFFD0150C 0x0FFFFFF5
+DATA 0xFFD01514 0x00000000
+DATA 0xFFD0151C 0x00000000
+DATA 0xFFD01494 0x00030000
+DATA 0xFFD01498 0x00000000
+DATA 0xFFD0149C 0x0000E803
+DATA 0xFFD01480 0x00000001
+# End of Header extension
+DATA 0x0 0x0
+
+------------------------------------------------
+Author: Prafulla Wadaskar <prafulla@marvell.com>
diff --git a/include/image.h b/include/image.h
index a62669f..50237b4 100644
--- a/include/image.h
+++ b/include/image.h
@@ -155,6 +155,7 @@
 #define IH_TYPE_SCRIPT		6	/* Script file			*/
 #define IH_TYPE_FILESYSTEM	7	/* Filesystem Image (any type)	*/
 #define IH_TYPE_FLATDT		8	/* Binary Flat Device Tree Blob	*/
+#define IH_TYPE_KWBIMAGE	9	/* Kirkwood Boot Image		*/
 
 /*
  * Compression Types
diff --git a/tools/Makefile b/tools/Makefile
index 858b0e8..56551f7 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -187,6 +187,7 @@ $(obj)mkimage$(SFX):	$(obj)crc32.o \
 			$(obj)default_image.o \
 			$(obj)fit_image.o \
 			$(obj)image.o \
+			$(obj)kwbimage.o \
 			$(obj)md5.o \
 			$(obj)mkimage.o \
 			$(obj)os_support.o \
@@ -216,6 +217,9 @@ $(obj)fit_image.o: $(SRCTREE)/tools/fit_image.c
 $(obj)image.o: $(SRCTREE)/common/image.c
 	$(CC) -g $(FIT_CFLAGS) -c -o $@ $<
 
+$(obj)kwbimage.o: $(SRCTREE)/tools/kwbimage.c
+	$(CC) -g $(FIT_CFLAGS) -c -o $@ $<
+
 $(obj)mkimage.o: $(SRCTREE)/tools/mkimage.c
 	$(CC) -g $(FIT_CFLAGS) -c -o $@ $<
 
diff --git a/tools/kwbimage.c b/tools/kwbimage.c
new file mode 100644
index 0000000..7250fc9
--- /dev/null
+++ b/tools/kwbimage.c
@@ -0,0 +1,402 @@
+/*
+ * (C) Copyright 2008
+ * Marvell Semiconductor <www.marvell.com>
+ * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include "mkimage.h"
+#include <image.h>
+#include "kwbimage.h"
+
+/*
+ * Supported commands for configuration file
+ */
+static table_entry_t kwbimage_cmds[] = {
+	{CMD_BOOT_FROM,		"BOOT_FROM",		"boot comand",	},
+	{CMD_NAND_ECC_MODE,	"NAND_ECC_MODE",	"NAND mode",	},
+	{CMD_NAND_PAGE_SIZE,	"NAND_PAGE_SIZE",	"NAND size",	},
+	{CMD_SATA_PIO_MODE,	"SATA_PIO_MODE",	"SATA mode",	},
+	{CMD_DDR_INIT_DELAY,	"DDR_INIT_DELAY",	"DDR init dly",	},
+	{CMD_DATA,		"DATA",			"Reg Write Data", },
+	{CMD_INVALID,		"",			"",	},
+};
+
+/*
+ * Supported Boot options for configuration file
+ */
+static table_entry_t kwbimage_bootops[] = {
+	{IBR_HDR_SPI_ID,	"spi",		"SPI Flash",	},
+	{IBR_HDR_NAND_ID,	"nand",		"NAND Flash",	},
+	{IBR_HDR_SATA_ID,	"sata",		"Sata port",	},
+	{IBR_HDR_PEX_ID,	"pex",		"PCIe port",	},
+	{IBR_HDR_UART_ID,	"uart",		"Serial port",	},
+	{-1,			"",		"Invalid",	},
+};
+
+/*
+ * Supported NAND ecc options configuration file
+ */
+static table_entry_t kwbimage_eccmodes[] = {
+	{IBR_HDR_ECC_DEFAULT,		"default",	"Default mode",	},
+	{IBR_HDR_ECC_FORCED_HAMMING,	"hamming",	"Hamming mode",	},
+	{IBR_HDR_ECC_FORCED_RS,		"rs",		"RS mode",	},
+	{IBR_HDR_ECC_DISABLED,		"disabled",	"ECC Disabled",	},
+	{-1,				"",		"",	},
+};
+
+static struct kwb_header kwbimage_header;
+static int datacmd_cnt = 0;
+static char * fname = "Unknown";
+static int lineno = -1;
+
+/*
+ * Report Error if xflag is set in addition to default
+ */
+static int kwbimage_check_params (struct mkimage_params *params)
+{
+	if (!strlen (params->imagename)) {
+		printf ("Error:%s - Configuration file not specified, "
+			"it is needed for kwbimage generation\n",
+			params->cmdname);
+		return CFG_INVALID;
+	}
+	return	((params->dflag && (params->fflag || params->lflag)) ||
+		(params->fflag && (params->dflag || params->lflag)) ||
+		(params->lflag && (params->dflag || params->fflag)) ||
+		(params->xflag) || !(strlen (params->imagename)));
+}
+
+static uint32_t check_get_hexval (char *token)
+{
+	uint32_t hexval;
+
+	if (!sscanf (token, "%x", &hexval)) {
+		printf ("Error:%s[%d] - Invalid hex data(%s)\n", fname,
+			lineno, token);
+		exit (EXIT_FAILURE);
+	}
+	return hexval;
+}
+
+/*
+ * Generates 8 bit checksum
+ */
+static uint8_t kwbimage_checksum8 (void *start, uint32_t len, uint8_t csum)
+{
+	register uint8_t sum = csum;
+	volatile uint8_t *p = (volatile uint8_t *)start;
+
+	/* check len and return zero checksum if invalid */
+	if (!len)
+		return 0;
+
+	do {
+		sum += *p;
+		p++;
+	} while (--len);
+	return (sum);
+}
+
+/*
+ * Generates 32 bit checksum
+ */
+static uint32_t kwbimage_checksum32 (uint32_t *start, uint32_t len, uint32_t csum)
+{
+	register uint32_t sum = csum;
+	volatile uint32_t *p = start;
+
+	/* check len and return zero checksum if invalid */
+	if (!len)
+		return 0;
+
+	if (len % sizeof(uint32_t)) {
+		printf ("Error:%s[%d] - lenght is not in multiple of %d\n",
+			__FUNCTION__, len, sizeof(uint32_t));
+		return 0;
+	}
+
+	do {
+		sum += *p;
+		p++;
+		len -= sizeof(uint32_t);
+	} while (len > 0);
+	return (sum);
+}
+
+static void kwbimage_check_cfgdata (char *token, enum kwbimage_cmd cmdsw,
+					struct kwb_header *kwbhdr)
+{
+	bhr_t *mhdr = &kwbhdr->kwb_hdr;
+	extbhr_t *exthdr = &kwbhdr->kwb_exthdr;
+	int i;
+
+	switch (cmdsw) {
+	case CMD_BOOT_FROM:
+		i = get_table_entry_id (kwbimage_bootops,
+				"Kwbimage boot option", token);
+
+		if (i < 0)
+			goto INVL_DATA;
+
+		mhdr->blockid = i;
+		printf ("Preparing kirkwood boot image to boot "
+			"from %s\n", token);
+		break;
+	case CMD_NAND_ECC_MODE:
+		i = get_table_entry_id (kwbimage_eccmodes,
+			"NAND ecc mode", token);
+
+		if (i < 0)
+			goto INVL_DATA;
+
+		mhdr->nandeccmode = i;
+		printf ("Nand ECC mode = %s\n", token);
+		break;
+	case CMD_NAND_PAGE_SIZE:
+		mhdr->nandpagesize =
+			(uint16_t) check_get_hexval (token);
+		printf ("Nand page size = 0x%x\n", mhdr->nandpagesize);
+		break;
+	case CMD_SATA_PIO_MODE:
+		mhdr->satapiomode =
+			(uint8_t) check_get_hexval (token);
+		printf ("Sata PIO mode = 0x%x\n",
+				mhdr->satapiomode);
+		break;
+	case CMD_DDR_INIT_DELAY:
+		mhdr->ddrinitdelay =
+			(uint16_t) check_get_hexval (token);
+		printf ("DDR init delay = %d msec\n", mhdr->ddrinitdelay);
+		break;
+	case CMD_DATA:
+		exthdr->rcfg[datacmd_cnt].raddr =
+			check_get_hexval (token);
+
+		break;
+	case CMD_INVALID:
+		goto INVL_DATA;
+	default:
+		goto INVL_DATA;
+	}
+	return;
+
+INVL_DATA:
+	printf ("Error:%s[%d] - Invalid data\n", fname, lineno);
+	exit (EXIT_FAILURE);
+}
+
+/*
+ * this function sets the kwbimage header by-
+ * 	1. Abstracting input command line arguments data
+ *	2. parses the kwbimage configuration file and update extebded header data
+ *	3. calculates header, extended header and image checksums
+ */
+static void kwdimage_set_ext_header (struct kwb_header *kwbhdr, char* name) {
+	bhr_t *mhdr = &kwbhdr->kwb_hdr;
+	extbhr_t *exthdr = &kwbhdr->kwb_exthdr;
+	FILE *fd = NULL;
+	int j;
+	char *line = NULL;
+	char * token, *saveptr1, *saveptr2;
+	size_t len = 0;
+	enum kwbimage_cmd cmd;
+
+	fname = name;
+	/* set dram register offset */
+	exthdr->dramregsoffs = (uint32_t)&exthdr->rcfg - (uint32_t)mhdr;
+
+	if ((fd = fopen (name, "r")) == 0) {
+		printf ("Error:%s - Can't open\n", fname);
+		exit (EXIT_FAILURE);
+	}
+
+	/* Simple kwimage.cfg file parser */
+	lineno=0;
+	while ((getline (&line, &len, fd)) > 0) {
+		lineno++;
+		token = strtok_r (line, "\r\n", &saveptr1);
+		/* drop all lines with zero tokens (= empty lines) */
+		if (token == NULL)
+			continue;
+
+		for (j = 0, cmd = CMD_INVALID, line = token; ; line = NULL) {
+			token = strtok_r (line, " \t", &saveptr2);
+			if (token == NULL)
+			break;
+			/* Drop all text starting with '#' as comments */
+			if (token[0] == '#')
+				break;
+
+			/* Process rest as valid config command line */
+			switch (j) {
+			case CFG_COMMAND:
+				cmd = get_table_entry_id (kwbimage_cmds,
+						"Kwbimage command", token);
+
+				if (cmd == CMD_INVALID)
+					goto INVL_CMD;
+				break;
+
+			case CFG_DATA0:
+				kwbimage_check_cfgdata (token, cmd, kwbhdr);
+				break;
+
+			case CFG_DATA1:
+				if (cmd != CMD_DATA)
+					goto INVL_CMD;
+
+				exthdr->rcfg[datacmd_cnt].rdata =
+						check_get_hexval (token);
+
+				if (datacmd_cnt > KWBIMAGE_MAX_CONFIG ) {
+					printf ("Error:%s[%d] - Found more "
+						"than max(%d) allowed "
+						"data configurations\n",
+						fname, lineno,
+						KWBIMAGE_MAX_CONFIG);
+				exit (EXIT_FAILURE);
+				} else
+					datacmd_cnt++;
+				break;
+
+			default:
+				goto INVL_CMD;
+			}
+			j++;
+		}
+	}
+	if (line)
+		free (line);
+
+	fclose (fd);
+	return;
+
+/*
+ * Invalid Command error reporring
+ *
+ * command CMD_DATA needs three strings on a line
+ * whereas other commands need only two.
+ *
+ * if more than two/three (as per command type) are observed,
+ * then error will be reported
+ */
+INVL_CMD:
+	printf ("Error:%s[%d] - Invalid command\n", fname, lineno);
+	exit (EXIT_FAILURE);
+}
+
+static void kwbimage_set_header (void *ptr, struct stat *sbuf, int ifd,
+				struct mkimage_params *params)
+{
+	struct kwb_header *hdr = (struct kwb_header *)ptr;
+	bhr_t *mhdr = &hdr->kwb_hdr;
+	extbhr_t *exthdr = &hdr->kwb_exthdr;
+	uint32_t checksum;
+	int size;
+
+	/* Build and add image checksum header */
+	checksum = kwbimage_checksum32 ((uint32_t *)ptr, sbuf->st_size, 0);
+
+	size = write (ifd, &checksum, sizeof(uint32_t));
+	if (size != sizeof(uint32_t)) {
+		printf ("Error:%s - Checksum write %d bytes %s\n",
+			params->cmdname, size, params->imagefile);
+		exit (EXIT_FAILURE);
+	}
+
+	sbuf->st_size += sizeof(uint32_t);
+
+	mhdr->blocksize = sbuf->st_size - sizeof(struct kwb_header);
+	mhdr->srcaddr = sizeof(struct kwb_header);
+	mhdr->destaddr= params->addr;
+	mhdr->execaddr =params->ep;
+	mhdr->ext = 0x1; /* header extension appended */
+
+	kwdimage_set_ext_header (hdr, params->imagename);
+	/* calculate checksums */
+	mhdr->checkSum = kwbimage_checksum8 ((void *)mhdr, sizeof(bhr_t), 0);
+	exthdr->checkSum = kwbimage_checksum8 ((void *)exthdr,
+						sizeof(extbhr_t), 0);
+}
+
+static int kwbimage_verify_header (unsigned char *ptr, int image_size,
+			struct mkimage_params *params)
+{
+	struct kwb_header *hdr = (struct kwb_header *)ptr;
+	bhr_t *mhdr = &hdr->kwb_hdr;
+	extbhr_t *exthdr = &hdr->kwb_exthdr;
+	uint8_t calc_hdrcsum;
+	uint8_t calc_exthdrcsum;
+
+	calc_hdrcsum = kwbimage_checksum8 ((void *)mhdr,
+			sizeof(bhr_t) - sizeof(uint8_t), 0);
+	if (calc_hdrcsum != mhdr->checkSum)
+		return -FDT_ERR_BADSTRUCTURE;	/* mhdr csum not matched */
+
+	calc_exthdrcsum = kwbimage_checksum8 ((void *)exthdr,
+			sizeof(extbhr_t) - sizeof(uint8_t), 0);
+	if (calc_hdrcsum != mhdr->checkSum)
+		return -FDT_ERR_BADSTRUCTURE; /* exthdr csum not matched */
+
+	return 0;
+}
+
+static void kwbimage_print_header (void *ptr)
+{
+	struct kwb_header *hdr = (struct kwb_header *) ptr;
+	bhr_t *mhdr = &hdr->kwb_hdr;
+	char *name = get_table_entry_name (kwbimage_bootops,
+				"Kwbimage boot option",
+				(int) mhdr->blockid);
+
+	printf ("Image Type:   Kirkwood Boot from %s Image\n", name);
+	printf ("Data Size:    ");
+	genimg_print_size (mhdr->blocksize - sizeof(uint32_t));
+	printf ("Load Address: %08x\n", mhdr->destaddr);
+	printf ("Entry Point:  %08x\n", mhdr->execaddr);
+}
+
+static int kwbimage_check_image_types (uint8_t type)
+{
+	if (type == IH_TYPE_KWBIMAGE)
+		return EXIT_SUCCESS;
+	else
+		return EXIT_FAILURE;
+}
+
+/*
+ * kwbimage type parameters definition
+ */
+static struct image_type_params kwbimage_params = {
+	.name = "Kirkwood Boot Image support",
+	.header_size = sizeof(struct kwb_header),
+	.hdr = (void*)&kwbimage_header,
+	.check_image_type = kwbimage_check_image_types,
+	.verify_header = kwbimage_verify_header,
+	.print_header = kwbimage_print_header,
+	.set_header = kwbimage_set_header,
+	.check_params = kwbimage_check_params,
+};
+
+void init_kwb_image_type (void)
+{
+	mkimage_register (&kwbimage_params);
+}
diff --git a/tools/kwbimage.h b/tools/kwbimage.h
new file mode 100644
index 0000000..3d3d5e9
--- /dev/null
+++ b/tools/kwbimage.h
@@ -0,0 +1,106 @@
+/*
+ * (C) Copyright 2008
+ * Marvell Semiconductor <www.marvell.com>
+ * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef _KWBIMAGE_H_
+#define _KWBIMAGE_H_
+
+#include <stdint.h>
+
+#define KWBIMAGE_MAX_CONFIG	((0x1dc - 0x20)/sizeof(struct reg_config))
+#define MAX_TEMPBUF_LEN		32
+
+/* NAND ECC Mode */
+#define IBR_HDR_ECC_DEFAULT		0x00
+#define IBR_HDR_ECC_FORCED_HAMMING	0x01
+#define IBR_HDR_ECC_FORCED_RS  		0x02
+#define IBR_HDR_ECC_DISABLED  		0x03
+
+/* Boot Type - block ID */
+#define IBR_HDR_I2C_ID			0x4D
+#define IBR_HDR_SPI_ID			0x5A
+#define IBR_HDR_NAND_ID			0x8B
+#define IBR_HDR_SATA_ID			0x78
+#define IBR_HDR_PEX_ID			0x9C
+#define IBR_HDR_UART_ID			0x69
+#define IBR_DEF_ATTRIB	 		0x00
+
+enum kwbimage_cmd {
+	CMD_INVALID,
+	CMD_BOOT_FROM,
+	CMD_NAND_ECC_MODE,
+	CMD_NAND_PAGE_SIZE,
+	CMD_SATA_PIO_MODE,
+	CMD_DDR_INIT_DELAY,
+	CMD_DATA
+};
+
+enum kwbimage_cmd_types {
+	CFG_INVALID = -1,
+	CFG_COMMAND,
+	CFG_DATA0,
+	CFG_DATA1
+};
+
+/* typedefs */
+typedef struct bhr_t {
+	uint8_t blockid;		/*0     */
+	uint8_t nandeccmode;		/*1     */
+	uint16_t nandpagesize;		/*2-3   */
+	uint32_t blocksize;		/*4-7   */
+	uint32_t rsvd1;			/*8-11  */
+	uint32_t srcaddr;		/*12-15 */
+	uint32_t destaddr;		/*16-19 */
+	uint32_t execaddr;		/*20-23 */
+	uint8_t satapiomode;		/*24    */
+	uint8_t rsvd3;			/*25    */
+	uint16_t ddrinitdelay;		/*26-27 */
+	uint16_t rsvd2;			/*28-29 */
+	uint8_t ext;			/*30    */
+	uint8_t checkSum;		/*31    */
+} bhr_t, *pbhr_t;
+
+struct reg_config {
+	uint32_t raddr;
+	uint32_t rdata;
+};
+
+typedef struct extbhr_t {
+	uint32_t dramregsoffs;
+	uint8_t rsrvd1[0x20 - sizeof(uint32_t)];
+	struct reg_config rcfg[KWBIMAGE_MAX_CONFIG];
+	uint8_t rsrvd2[7];
+	uint8_t checkSum;
+} extbhr_t, *pextbhr_t;
+
+struct kwb_header {
+	bhr_t kwb_hdr;
+	extbhr_t kwb_exthdr;
+};
+
+/*
+ * functions
+ */
+void init_kwb_image_type (void);
+
+#endif /* _KWBIMAGE_H_ */
diff --git a/tools/mkimage.c b/tools/mkimage.c
index c43b207..ab6ea32 100644
--- a/tools/mkimage.c
+++ b/tools/mkimage.c
@@ -148,6 +148,8 @@ main (int argc, char **argv)
 	int retval = 0;
 	struct image_type_params *tparams = NULL;
 
+	/* Init Kirkwood Boot image generation/list support */
+	init_kwb_image_type ();
 	/* Init FIT image generation/list support */
 	init_fit_image_type ();
 	/* Init Default image generation/list support */
-- 
1.5.3.3

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH v3 4/4] tools: mkimage: Add: Kirkwood Boot Image support (kwbimage)
  2009-08-24 17:33     ` [U-Boot] [PATCH v3 4/4] tools: mkimage: Add: Kirkwood Boot Image support (kwbimage) Prafulla Wadaskar
@ 2009-09-01 17:15       ` Prafulla Wadaskar
  2009-09-03 12:00       ` Simon Kagstrom
  1 sibling, 0 replies; 16+ messages in thread
From: Prafulla Wadaskar @ 2009-09-01 17:15 UTC (permalink / raw)
  To: u-boot

 

> -----Original Message-----
> From: Prafulla Wadaskar [mailto:prafulla at marvell.com] 
> Sent: Monday, August 24, 2009 11:04 PM
> To: u-boot at lists.denx.de
> Cc: Prabhanjan Sarnaik; Ashish Karkare; Prafulla Wadaskar
> Subject: [PATCH v3 4/4] tools: mkimage: Add: Kirkwood Boot 
> Image support (kwbimage)
> 
> This patch adds type kwbimabe support for new mkimage core
> For more details refer docs/README.kwbimage
> 
> This patch is tested with Sheevaplug board
> 
> Signed-off-by: Prafulla Wadaskar <prafulla@marvell.com>
> ---
> Change log:
> v2: updated as per review comments for v1
> added len checks in checksum functions
> added printable strings for each valid table entry
> use of sccanf not changed since it offers return value for failure
> 
> v3: resolved merge issues on mkimage branch

Ping... (for this entire patch series)

Regards..
Prafulla . .

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH v3 4/4] tools: mkimage: Add: Kirkwood Boot Image support (kwbimage)
  2009-08-24 17:33     ` [U-Boot] [PATCH v3 4/4] tools: mkimage: Add: Kirkwood Boot Image support (kwbimage) Prafulla Wadaskar
  2009-09-01 17:15       ` Prafulla Wadaskar
@ 2009-09-03 12:00       ` Simon Kagstrom
  2009-09-03 14:15         ` Prafulla Wadaskar
  1 sibling, 1 reply; 16+ messages in thread
From: Simon Kagstrom @ 2009-09-03 12:00 UTC (permalink / raw)
  To: u-boot

On Mon, 24 Aug 2009 23:03:59 +0530
Prafulla Wadaskar <prafulla@marvell.com> wrote:

> This patch adds type kwbimabe support for new mkimage core
> For more details refer docs/README.kwbimage

> +Command syntax:
> +--------------
> +./tools/mkimage -l <kwboot_file>
> +		to list the kwb image file details
> +
> +./tools/mkimage -n <board specific configuration file> \
> +                -T kwbimage -a <start address> -e <execution address> \
> +		-d <input_raw_binary> <output_kwboot_file>
> +
> +for ex.
> +./tools/mkimage -n ./board/Marvell/openrd_base/kwbimage.cfg \
> +                -T kwbimage -a 0x00600000 -e 0x00600000 \
> +		-d u-boot.bin u-boot.kwb

I think it could also be useful to be able to produce just the boot
header without the U-boot image. For example if you want to place
U-boot at some other location on the flash or (as a developer)
frequently re-flash U-boot, but don't want to write to the first block
all the time (you only need to rewrite it when moving U-boot).

Perhaps something like

> +Typical example of kwimage.cfg file:
> +-----------------------------------
> +
> +# Boot Media configurations
> +BOOT_FROM	nand
> +NAND_ECC_MODE	default
> +NAND_PAGE_SIZE	0x0800

SOURCE_OFFSET 0x0   # Relative to the header or NAND start?

> +static void kwbimage_set_header (void *ptr, struct stat *sbuf, int ifd,
> +				struct mkimage_params *params)
> +{
> +	struct kwb_header *hdr = (struct kwb_header *)ptr;
> [...]
> +	mhdr->srcaddr = sizeof(struct kwb_header);

and this could then be changed to have this info.

// Simon

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH v3 4/4] tools: mkimage: Add: Kirkwood Boot Image support (kwbimage)
  2009-09-03 12:00       ` Simon Kagstrom
@ 2009-09-03 14:15         ` Prafulla Wadaskar
  2009-09-04  6:30           ` Simon Kagstrom
  0 siblings, 1 reply; 16+ messages in thread
From: Prafulla Wadaskar @ 2009-09-03 14:15 UTC (permalink / raw)
  To: u-boot

 

> -----Original Message-----
> From: Simon Kagstrom [mailto:simon.kagstrom at netinsight.net] 
> Sent: Thursday, September 03, 2009 5:30 PM
> To: Prafulla Wadaskar
> Cc: u-boot at lists.denx.de; Ashish Karkare; Prabhanjan Sarnaik
> Subject: Re: [U-Boot] [PATCH v3 4/4] tools: mkimage: Add: 
> Kirkwood Boot Image support (kwbimage)
> 
> On Mon, 24 Aug 2009 23:03:59 +0530
> Prafulla Wadaskar <prafulla@marvell.com> wrote:
> 
> > This patch adds type kwbimabe support for new mkimage core
> > For more details refer docs/README.kwbimage
> 
> > +Command syntax:
> > +--------------
> > +./tools/mkimage -l <kwboot_file>
> > +		to list the kwb image file details
> > +
> > +./tools/mkimage -n <board specific configuration file> \
> > +                -T kwbimage -a <start address> -e 
> <execution address> \
> > +		-d <input_raw_binary> <output_kwboot_file>
> > +
> > +for ex.
> > +./tools/mkimage -n ./board/Marvell/openrd_base/kwbimage.cfg \
> > +                -T kwbimage -a 0x00600000 -e 0x00600000 \
> > +		-d u-boot.bin u-boot.kwb
> 
> I think it could also be useful to be able to produce just the boot
> header without the U-boot image. For example if you want to place
> U-boot at some other location on the flash or (as a developer)
> frequently re-flash U-boot, but don't want to write to the first block
> all the time (you only need to rewrite it when moving U-boot).
Hi Simon
This is not possible.
Boot Header is a part of Kirkwood boot image,
Header contains u-boot imagesize so for this, first block need to be written each time.
Secondly u-boot header is of 512bytes only whereas minimum sector size could be 4kbytes (typical),
so rest part of first sector will be a waste.
Also at the end of boot image checksum need to be calculated on entire image including header.

If one need just header, just use only initial 512 byte
I don't see any good use case for this at this moment.

Regards..
Prafulla . .

> 
> Perhaps something like
> 
> > +Typical example of kwimage.cfg file:
> > +-----------------------------------
> > +
> > +# Boot Media configurations
> > +BOOT_FROM	nand
> > +NAND_ECC_MODE	default
> > +NAND_PAGE_SIZE	0x0800
> 
> SOURCE_OFFSET 0x0   # Relative to the header or NAND start?
> 
> > +static void kwbimage_set_header (void *ptr, struct stat 
> *sbuf, int ifd,
> > +				struct mkimage_params *params)
> > +{
> > +	struct kwb_header *hdr = (struct kwb_header *)ptr;
> > [...]
> > +	mhdr->srcaddr = sizeof(struct kwb_header);
> 
> and this could then be changed to have this info.
> 
> // Simon
> 

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH v3 4/4] tools: mkimage: Add: Kirkwood Boot Image support (kwbimage)
  2009-09-03 14:15         ` Prafulla Wadaskar
@ 2009-09-04  6:30           ` Simon Kagstrom
  2009-09-04  7:17             ` Prafulla Wadaskar
  2009-09-04  8:24             ` Wolfgang Denk
  0 siblings, 2 replies; 16+ messages in thread
From: Simon Kagstrom @ 2009-09-04  6:30 UTC (permalink / raw)
  To: u-boot

Hi Prafulla!

I see the complications and understand that it might be difficult to
get it running.

On Thu, 3 Sep 2009 07:15:48 -0700
Prafulla Wadaskar <prafulla@marvell.com> wrote:

> > I think it could also be useful to be able to produce just the boot
> > header without the U-boot image. For example if you want to place
> > U-boot at some other location on the flash or (as a developer)
> > frequently re-flash U-boot, but don't want to write to the first block
> > all the time (you only need to rewrite it when moving U-boot).
>
> This is not possible.
> Boot Header is a part of Kirkwood boot image,
> Header contains u-boot imagesize so for this, first block need to be written each time.

Understandable. On the other hand, it should be possible to pad the
U-boot image to some specific size to keep the size constant. Typically
to the erase size.

> Secondly u-boot header is of 512bytes only whereas minimum sector size could be 4kbytes (typical),
> so rest part of first sector will be a waste.

I'd be prepared to waste a couple of bytes :-)

> Also at the end of boot image checksum need to be calculated on entire image including header.

This is not how I read the documentation. I thought the 32-bit checksum
is for the image only, not the headers? Anyway, if it does include the
headers, then I see why this would be impossible.


Thanks for the explanation!

// Simon

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH v3 4/4] tools: mkimage: Add: Kirkwood Boot Image support (kwbimage)
  2009-09-04  6:30           ` Simon Kagstrom
@ 2009-09-04  7:17             ` Prafulla Wadaskar
  2009-09-04  7:30               ` Simon Kagstrom
  2009-09-04  8:24             ` Wolfgang Denk
  1 sibling, 1 reply; 16+ messages in thread
From: Prafulla Wadaskar @ 2009-09-04  7:17 UTC (permalink / raw)
  To: u-boot

 

> -----Original Message-----
> From: Simon Kagstrom [mailto:simon.kagstrom at netinsight.net] 
> Sent: Friday, September 04, 2009 12:00 PM
> To: Prafulla Wadaskar
> Cc: u-boot at lists.denx.de; Ashish Karkare; Prabhanjan Sarnaik
> Subject: Re: [U-Boot] [PATCH v3 4/4] tools: mkimage: Add: 
> Kirkwood Boot Image support (kwbimage)
> 
> Hi Prafulla!
> 
> I see the complications and understand that it might be difficult to
> get it running.
Dear Simon
So we can keep this complex enhancement for future updates, keeping this patch simpler
 
> 
> On Thu, 3 Sep 2009 07:15:48 -0700
> Prafulla Wadaskar <prafulla@marvell.com> wrote:
> 
> > > I think it could also be useful to be able to produce 
> just the boot
> > > header without the U-boot image. For example if you want to place
> > > U-boot at some other location on the flash or (as a developer)
> > > frequently re-flash U-boot, but don't want to write to 
> the first block
> > > all the time (you only need to rewrite it when moving U-boot).
> >
> > This is not possible.
> > Boot Header is a part of Kirkwood boot image,
> > Header contains u-boot imagesize so for this, first block 
> need to be written each time.
> 
> Understandable. On the other hand, it should be possible to pad the
> U-boot image to some specific size to keep the size constant. 
> Typically
> to the erase size.
Again it would be problem it image size jumps over sector size boundary

> 
> > Secondly u-boot header is of 512bytes only whereas minimum 
> sector size could be 4kbytes (typical),
> > so rest part of first sector will be a waste.
> 
> I'd be prepared to waste a couple of bytes :-)
You will have to waste 128Kbytes-512bytes on sheevaplug :-)
Finally you will waste one extra sector (u-boot.kwb size is ~160kb)

> 
> > Also at the end of boot image checksum need to be 
> calculated on entire image including header.
> 
> This is not how I read the documentation. I thought the 
> 32-bit checksum
> is for the image only, not the headers? Anyway, if it does include the
> headers, then I see why this would be impossible.
Currently it is done in the way I explained with some reference,
I will do some exercise with your suggestions and let you know.

Regards..
Prafulla . .

> 
> 
> Thanks for the explanation!
> 
> // Simon
> 

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH v3 4/4] tools: mkimage: Add: Kirkwood Boot Image support (kwbimage)
  2009-09-04  7:17             ` Prafulla Wadaskar
@ 2009-09-04  7:30               ` Simon Kagstrom
  0 siblings, 0 replies; 16+ messages in thread
From: Simon Kagstrom @ 2009-09-04  7:30 UTC (permalink / raw)
  To: u-boot

On Fri, 4 Sep 2009 00:17:57 -0700
Prafulla Wadaskar <prafulla@marvell.com> wrote:

> > I see the complications and understand that it might be difficult to
> > get it running.
>
> So we can keep this complex enhancement for future updates, keeping this patch simpler

I agree, let's merge this patch first before thinking of some
enhancements.

// Simon

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH v3 4/4] tools: mkimage: Add: Kirkwood Boot Image support (kwbimage)
  2009-09-04  6:30           ` Simon Kagstrom
  2009-09-04  7:17             ` Prafulla Wadaskar
@ 2009-09-04  8:24             ` Wolfgang Denk
  2009-09-04  8:36               ` Simon Kagstrom
  1 sibling, 1 reply; 16+ messages in thread
From: Wolfgang Denk @ 2009-09-04  8:24 UTC (permalink / raw)
  To: u-boot

Dear Simon Kagstrom,

In message <20090904083003.3f7f0d1f@marrow.netinsight.se> you wrote:
> 
> Understandable. On the other hand, it should be possible to pad the
> U-boot image to some specific size to keep the size constant. Typically
> to the erase size.

This makes no sense. Why would such padding be needed? It only adds
overhead everywhere where the image needs to be processed, stored,
downloaded, programmed, etc.


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Conceptual integrity in turn dictates that the  design  must  proceed
from  one  mind,  or  from  a  very small number of agreeing resonant
minds.               - Frederick Brooks Jr., "The Mythical Man Month" 

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH v3 4/4] tools: mkimage: Add: Kirkwood Boot Image support (kwbimage)
  2009-09-04  8:24             ` Wolfgang Denk
@ 2009-09-04  8:36               ` Simon Kagstrom
  2009-09-04 10:57                 ` Wolfgang Denk
  0 siblings, 1 reply; 16+ messages in thread
From: Simon Kagstrom @ 2009-09-04  8:36 UTC (permalink / raw)
  To: u-boot

On Fri, 04 Sep 2009 10:24:38 +0200
Wolfgang Denk <wd@denx.de> wrote:

> Dear Simon Kagstrom,
> 
> In message <20090904083003.3f7f0d1f@marrow.netinsight.se> you wrote:
> > 
> > Understandable. On the other hand, it should be possible to pad the
> > U-boot image to some specific size to keep the size constant. Typically
> > to the erase size.
> 
> This makes no sense. Why would such padding be needed? It only adds
> overhead everywhere where the image needs to be processed, stored,
> downloaded, programmed, etc.

In this case to have keep the kirkwood boot header unchanged, and to
just update the U-boot image.

// Simon

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH v3 4/4] tools: mkimage: Add: Kirkwood Boot Image support (kwbimage)
  2009-09-04  8:36               ` Simon Kagstrom
@ 2009-09-04 10:57                 ` Wolfgang Denk
  2009-09-04 11:07                   ` Simon Kagstrom
  0 siblings, 1 reply; 16+ messages in thread
From: Wolfgang Denk @ 2009-09-04 10:57 UTC (permalink / raw)
  To: u-boot

Dear Simon Kagstrom,

In message <20090904103602.7a0ec3fd@marrow.netinsight.se> you wrote:
> 
> > > Understandable. On the other hand, it should be possible to pad the
> > > U-boot image to some specific size to keep the size constant. Typically
> > > to the erase size.
> > 
> > This makes no sense. Why would such padding be needed? It only adds
> > overhead everywhere where the image needs to be processed, stored,
> > downloaded, programmed, etc.
> 
> In this case to have keep the kirkwood boot header unchanged, and to
> just update the U-boot image.

Doesn't the header contain checksums and such? And what would that
save you?  Building the image with header is supposed to be a very
cheap operation.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"What if" is a trademark of Hewlett Packard, so stop using it in your
sentences without permission, or risk being sued.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH v3 4/4] tools: mkimage: Add: Kirkwood Boot Image support (kwbimage)
  2009-09-04 10:57                 ` Wolfgang Denk
@ 2009-09-04 11:07                   ` Simon Kagstrom
  0 siblings, 0 replies; 16+ messages in thread
From: Simon Kagstrom @ 2009-09-04 11:07 UTC (permalink / raw)
  To: u-boot

On Fri, 04 Sep 2009 12:57:57 +0200
Wolfgang Denk <wd@denx.de> wrote:

> Dear Simon Kagstrom,
> 
> In message <20090904103602.7a0ec3fd@marrow.netinsight.se> you wrote:
> > 
> > > > Understandable. On the other hand, it should be possible to pad the
> > > > U-boot image to some specific size to keep the size constant. Typically
> > > > to the erase size.
> > > 
> > > This makes no sense. Why would such padding be needed? It only adds
> > > overhead everywhere where the image needs to be processed, stored,
> > > downloaded, programmed, etc.
> > 
> > In this case to have keep the kirkwood boot header unchanged, and to
> > just update the U-boot image.
> 
> Doesn't the header contain checksums and such? And what would that
> save you?  Building the image with header is supposed to be a very
> cheap operation.

I believe the checksums are for the header and the header extension -
the image itself contains a checksum in the last 4 bytes.

The idea was to avoid having to rewrite the same block all the time.
Anyway, Prafulla has explained why it's difficult (or maybe impossible)
to use this method, so I think we can safely drop this subject for now.

// Simon

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH v3 4/4] tools: mkimage: Add: Kirkwood Boot Image support (kwbimage)
  2009-09-03 11:39 Prafulla Wadaskar
@ 2009-09-04 21:05 ` Wolfgang Denk
  0 siblings, 0 replies; 16+ messages in thread
From: Wolfgang Denk @ 2009-09-04 21:05 UTC (permalink / raw)
  To: u-boot

Dear Prafulla Wadaskar,

In message <73173D32E9439E4ABB5151606C3E19E202E5D0E9B4@SC-VEXCH1.marvell.com> you wrote:
>  
> Sorry for pinging again,

That's perfectly OK. Actually I wanted to fog into this all the time,
yet all the time other things came inbetween.

> Shall I re-post this patch series?

If you could be so kind - it would help me a lot to have everything
together in one place. Thanks in advance.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Intel told us the Pentium would have "RISK" features...

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH v3 4/4] tools: mkimage: Add: Kirkwood Boot Image support (kwbimage)
@ 2009-09-03 11:39 Prafulla Wadaskar
  2009-09-04 21:05 ` Wolfgang Denk
  0 siblings, 1 reply; 16+ messages in thread
From: Prafulla Wadaskar @ 2009-09-03 11:39 UTC (permalink / raw)
  To: u-boot

 

> -----Original Message-----
> From: Prafulla Wadaskar 
> Sent: Tuesday, September 01, 2009 10:45 PM
> To: u-boot at lists.denx.de
> Cc: Prabhanjan Sarnaik; Ashish Karkare
> Subject: RE: [PATCH v3 4/4] tools: mkimage: Add: Kirkwood 
> Boot Image support (kwbimage)
> 
>  
> 
> > -----Original Message-----
> > From: Prafulla Wadaskar [mailto:prafulla at marvell.com] 
> > Sent: Monday, August 24, 2009 11:04 PM
> > To: u-boot at lists.denx.de
> > Cc: Prabhanjan Sarnaik; Ashish Karkare; Prafulla Wadaskar
> > Subject: [PATCH v3 4/4] tools: mkimage: Add: Kirkwood Boot 
> > Image support (kwbimage)
> > 
> > This patch adds type kwbimabe support for new mkimage core
> > For more details refer docs/README.kwbimage
> > 
> > This patch is tested with Sheevaplug board
> > 
> > Signed-off-by: Prafulla Wadaskar <prafulla@marvell.com>
> > ---
> > Change log:
> > v2: updated as per review comments for v1
> > added len checks in checksum functions
> > added printable strings for each valid table entry
> > use of sccanf not changed since it offers return value for failure
> > 
> > v3: resolved merge issues on mkimage branch
> 
> Ping... (for this entire patch series)
Hi Wolfgang
Sorry for pinging again,
Shall I re-post this patch series?

Regards..
Prafulla . 

> 
> Regards..
> Prafulla . .
> 

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2009-09-04 21:05 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-24 17:33 [U-Boot] [PATCH 1/4][repost] tools: mkimage: Making genimg_print_size API global Prafulla Wadaskar
2009-08-24 17:33 ` [U-Boot] [PATCH 2/4][repost] tools: mkimage: Making table_entry code global Prafulla Wadaskar
2009-08-24 17:33   ` [U-Boot] [PATCH 3/4][repost] Kirkwood: Sheevaplug: kwimage configuration Prafulla Wadaskar
2009-08-24 17:33     ` [U-Boot] [PATCH v3 4/4] tools: mkimage: Add: Kirkwood Boot Image support (kwbimage) Prafulla Wadaskar
2009-09-01 17:15       ` Prafulla Wadaskar
2009-09-03 12:00       ` Simon Kagstrom
2009-09-03 14:15         ` Prafulla Wadaskar
2009-09-04  6:30           ` Simon Kagstrom
2009-09-04  7:17             ` Prafulla Wadaskar
2009-09-04  7:30               ` Simon Kagstrom
2009-09-04  8:24             ` Wolfgang Denk
2009-09-04  8:36               ` Simon Kagstrom
2009-09-04 10:57                 ` Wolfgang Denk
2009-09-04 11:07                   ` Simon Kagstrom
2009-09-03 11:39 Prafulla Wadaskar
2009-09-04 21:05 ` Wolfgang Denk

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.