Skip to contentSkip to conversation

ARM: mxs: tools: Add mkimage support for MXS bootstream

PATCH New Marek Vasut 2 participants 3 messages Jul 31, 2013 – Aug 6, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: mxs: tools: Add mkimage support for MXS bootstream

Add mkimage support for generating and verifying MXS bootstream. The implementation here is mostly a glue code between MXSSB v0.4 and mkimage, but the long-term goal is to rectify this and merge MXSSB with mkimage more tightly. Once this code is properly in U-Boot, MXSSB shall be deprecated in favor of mkimage-mxsimage support.

Note that the mxsimage generator needs libcrypto from OpenSSL, I therefore enabled the libcrypto/libssl unconditionally.

MXSSB: http://git.denx.de/?p=mxssb.git;a=summary

Cc Tom Rini <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Otavio Salvador <[email protected]>
---
 arch/arm/cpu/arm926ejs/mxs/mxsimage.mx23.cfg |    6 +
 arch/arm/cpu/arm926ejs/mxs/mxsimage.mx28.cfg |    8 +
 common/image.c                               |    1 +
 config.mk                                    |    2 +-
 doc/README.mxsimage                          |  165 ++
 include/image.h                              |    1 +
 tools/Makefile                               |    2 +
 tools/mkimage.c                              |    2 +
 tools/mkimage.h                              |    2 +
 tools/mxsimage.c                             | 2315 ++++++++++++++++++++++++++
 tools/mxsimage.h                             |  203 +++
 11 files changed, 2706 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/cpu/arm926ejs/mxs/mxsimage.mx23.cfg
 create mode 100644 arch/arm/cpu/arm926ejs/mxs/mxsimage.mx28.cfg
 create mode 100644 doc/README.mxsimage
 create mode 100644 tools/mxsimage.c
 create mode 100644 tools/mxsimage.h

NOTE: The code does likely contain a few dozens of checkpatch
errors, but to allow me to easily sync this with MXSSB, I am not fixing those.

arch/arm/cpu/arm926ejs/mxs/mxsimage.mx23.cfg new file +6 -0
new file mode 100644
index 0000000..8118767
@@ -0,0 +1,6 @@
+SECTION 0x0 BOOTABLE
+ TAG LAST
+ LOAD     0x0        spl/u-boot-spl.bin
+ CALL     0x14       0x0
+ LOAD     0x40000100 u-boot.bin
+ CALL     0x40000100 0x0
arch/arm/cpu/arm926ejs/mxs/mxsimage.mx28.cfg new file +8 -0
new file mode 100644
index 0000000..ea772f0
@@ -0,0 +1,8 @@
+SECTION 0x0 BOOTABLE
+ TAG LAST
+ LOAD     0x0        spl/u-boot-spl.bin
+ LOAD IVT 0x8000     0x14
+ CALL HAB 0x8000     0x0
+ LOAD     0x40000100 u-boot.bin
+ LOAD IVT 0x8000     0x40000100
+ CALL HAB 0x8000     0x0
common/image.c +1 -0
index 56a5a62..2c88091 100644
@@ -135,6 +135,7 @@ static const table_entry_t uimage_type[] = {
 	{	IH_TYPE_SCRIPT,     "script",	  "Script",		},
 	{	IH_TYPE_STANDALONE, "standalone", "Standalone Program", },
 	{	IH_TYPE_UBLIMAGE,   "ublimage",   "Davinci UBL image",},
+	{	IH_TYPE_MXSIMAGE,   "mxsimage",   "Freescale MXS Boot Image",},
 	{	-1,		    "",		  "",			},
 };
 
config.mk +1 -1
index 499eed1..968a1e3 100644
@@ -194,9 +194,9 @@ LDFLAGS_FINAL += --gc-sections
 endif
 
 # TODO(sjg at chromium.org): Is this correct on Mac OS?
-ifdef CONFIG_FIT_SIGNATURE
 HOSTLIBS	+= -lssl -lcrypto
 
+ifdef CONFIG_FIT_SIGNATURE
 # This affects include/image.h, but including the board config file
 # is tricky, so manually define this options here.
 HOSTCFLAGS	+= -DCONFIG_FIT_SIGNATURE
doc/README.mxsimage new file +165 -0

165 lines not on this page · raw message

include/image.h +1 -0
index f93a393..ee6eb8d 100644
@@ -212,6 +212,7 @@ struct lmb;
 #define IH_TYPE_AISIMAGE	13	/* TI Davinci AIS Image		*/
 #define IH_TYPE_KERNEL_NOLOAD	14	/* OS Kernel Image, can run from any load address */
 #define IH_TYPE_PBLIMAGE	15	/* Freescale PBL Boot Image	*/
+#define IH_TYPE_MXSIMAGE	16	/* Freescale MXSBoot Image	*/
 
 /*
  * Compression Types
tools/Makefile +2 -0
index 33fad6b..bbae5a2 100644
@@ -83,6 +83,7 @@ NOPED_OBJ_FILES-y += aisimage.o
 NOPED_OBJ_FILES-y += kwbimage.o
 NOPED_OBJ_FILES-y += pblimage.o
 NOPED_OBJ_FILES-y += imximage.o
+NOPED_OBJ_FILES-y += mxsimage.o
 NOPED_OBJ_FILES-y += image-host.o
 NOPED_OBJ_FILES-y += omapimage.o
 NOPED_OBJ_FILES-y += mkenvimage.o
@@ -209,6 +210,7 @@ $(obj)mkimage$(SFX):	$(obj)aisimage.o \
 			$(obj)image-host.o \
 			$(FIT_SIG_OBJS) \
 			$(obj)imximage.o \
+			$(obj)mxsimage.o \
 			$(obj)kwbimage.o \
 			$(obj)pblimage.o \
 			$(obj)md5.o \
tools/mkimage.c +2 -0
index b700b9e..635df02 100644
@@ -144,6 +144,8 @@ main (int argc, char **argv)
 	init_kwb_image_type ();
 	/* Init Freescale imx Boot image generation/list support */
 	init_imx_image_type ();
+	/* Init Freescale mxs Boot image generation/list support */
+	init_mxs_image_type ();
 	/* Init FIT image generation/list support */
 	init_fit_image_type ();
 	/* Init TI OMAP Boot image generation/list support */
tools/mkimage.h +2 -0
index 950e190..1a87bc7 100644
@@ -112,6 +112,7 @@ struct image_type_params {
 	int (*verify_header) (unsigned char *, int, struct mkimage_params *);
 	/* Prints image information abstracting from image header */
 	void (*print_header) (const void *);
+
 	/*
 	 * The header or image contents need to be set as per image type to
 	 * be generated using this callback function.
@@ -158,6 +159,7 @@ void init_pbl_image_type(void);
 void init_ais_image_type(void);
 void init_kwb_image_type (void);
 void init_imx_image_type (void);
+void init_mxs_image_type (void);
 void init_default_image_type (void);
 void init_fit_image_type (void);
 void init_ubl_image_type(void);
tools/mxsimage.c new file +2315 -0

2,315 lines not on this page · raw message

tools/mxsimage.h new file +203 -0

203 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 1/1 ARM: mxs: tools: Add mkimage support for MXS bootstream

Quoted 9 lines · Marek Vasut

Add mkimage support for generating and verifying MXS bootstream. The implementation here is mostly a glue code between MXSSB v0.4 and mkimage, but the long-term goal is to rectify this and merge MXSSB with mkimage more tightly. Once this code is properly in U-Boot, MXSSB shall be deprecated in favor of mkimage-mxsimage support.

Note that the mxsimage generator needs libcrypto from OpenSSL, I therefore enabled the libcrypto/libssl unconditionally.

OK, we need to figure out something here. Can we start by just enabling this for MX platforms and see what the fallout is? And like the FIT code, have a "not supported" print happen when it's not enabled.

[snip]

tools/mkimage.h struct image_type_params { · line 118

Quoted 10 lines
tools/mkimage.h +1 -0
@@ -112,6 +112,7 @@ struct image_type_params {
 	int (*verify_header) (unsigned char *, int, struct mkimage_params *);
 	/* Prints image information abstracting from image header */
 	void (*print_header) (const void *);
+
 	/*
 	 * The header or image contents need to be set as per image type to
 	 * be generated using this callback function.

Extra space change.

[snip]

tools/mkimage.h

Quoted 6 lines
tools/mkimage.h +6 -0
+/*
+ * CRC32
+ */
+static uint32_t crc32(uint8_t *data, uint32_t len)
+{
+	const uint32_t poly = 0x04c11db7;

Please comment a bit more about how we need to use the following polynomial as documented by Freescale ... somewhere ...

Quoted 7 lines
tools/mkimage.h +7 -0
+/*
+ * Code
+ */
+static time_t sb_get_timestamp(void)
+{
+#if 0
+	struct tm time_2000 = {

tools/mkimage.h

Quoted 10 lines
tools/mkimage.h +10 -0
+		.tm_yday	= 1,	/* Jan. 1st */
+		.tm_year	= 100,	/* 2000 */
+	};
+	time_t seconds_to_2000 = mktime(&time_2000);
+	time_t seconds_to_now = time(NULL);
+
+	return seconds_to_now - seconds_to_2000;
+#endif
+	return 427398871;
+}

What? If we need to use a magic timestamp, please say why. And in general, the file could use some further commenting on what/why.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130806/413453cc/attachment.pgp>
#2 lore raw

PATCH 1/1 ARM: mxs: tools: Add mkimage support for MXS bootstream

Dear Tom Rini,

Quoted 36 lines · Marek Vasut
Quoted 9 lines

Add mkimage support for generating and verifying MXS bootstream. The implementation here is mostly a glue code between MXSSB v0.4 and mkimage, but the long-term goal is to rectify this and merge MXSSB with mkimage more tightly. Once this code is properly in U-Boot, MXSSB shall be deprecated in favor of mkimage-mxsimage support.

Note that the mxsimage generator needs libcrypto from OpenSSL, I therefore enabled the libcrypto/libssl unconditionally.

OK, we need to figure out something here. Can we start by just enabling this for MX platforms and see what the fallout is? And like the FIT code, have a "not supported" print happen when it's not enabled.

[snip]

Quoted 10 lines
tools/mkimage.h +1 -0
@@ -112,6 +112,7 @@ struct image_type_params {
 
 	int (*verify_header) (unsigned char *, int, struct mkimage_params *);
 	/* Prints image information abstracting from image header */
 	void (*print_header) (const void *);
 
+
 

tools/mkimage.h struct image_type_params { · line 118

Quoted 4 lines
tools/mkimage.h +0 -0
 	/*
 
 	 * The header or image contents need to be set as per image type to
 	 * be generated using this callback function.

Extra space change.

[snip]

Quoted 9 lines

tools/mkimage.h

Quoted 6 lines
tools/mkimage.h +6 -0
+/*
+ * CRC32
+ */
+static uint32_t crc32(uint8_t *data, uint32_t len)
+{
+	const uint32_t poly = 0x04c11db7;

Please comment a bit more about how we need to use the following polynomial as documented by Freescale ... somewhere ...

It's a regular CRC32 CCITT .

Quoted 11 lines
Quoted 11 lines
tools/mkimage.h +11 -0
+/*
+ * Code
+ */
+static time_t sb_get_timestamp(void)
+{
+#if 0
+	struct tm time_2000 = {
+		.tm_yday	= 1,	/* Jan. 1st */
+		.tm_year	= 100,	/* 2000 */
+	};
+	time_t seconds_to_2000 = mktime(&time_2000);
Quoted 8 lines

tools/mkimage.h

Quoted 6 lines
tools/mkimage.h +6 -0
+	time_t seconds_to_now = time(NULL);
+
+	return seconds_to_now - seconds_to_2000;
+#endif
+	return 427398871;
+}

What? If we need to use a magic timestamp, please say why.

F* ... this part shouldn't be there of course. The code in #if 0 should be enabled.

Quoted 2 lines

And in
general, the file could use some further commenting on what/why.

What do you mean?

Best regards,
Marek Vasut