public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [RFC PATCH 0/2] Add atmel ROM code image
@ 2014-04-23 14:29 Andreas Bießmann
  2014-04-23 14:29 ` [U-Boot] [RFC PATCH 1/2] mkimage: add atmelimage Andreas Bießmann
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Andreas Bießmann @ 2014-04-23 14:29 UTC (permalink / raw)
  To: u-boot

This series add atmelimage support to mkimage.

An atmelimage is a quite dumb image type cause it has no real header. The file
is mostly unmodified but the 6'th ARM vector gets replaced by the image size
to load.

Heiko, I know your approach setting the vector in start.S but I think this
solution is a bit smarter. We would need to patch at least 2 start.S files
(arm926ejs and armv7), maybe also the arm920t one too. In fact is the
conversion of executable BLOB to ROM detected executable BLOB something that
should really be done afterwards as all other SoC vendors do.


Andreas Bie?mann (2):
  mkimage: add atmelimage
  arm:at91: enable ROM loadable atmel image

 arch/arm/cpu/armv7/at91/config.mk |   10 +++++
 common/image.c                    |    1 +
 include/image.h                   |    1 +
 spl/Makefile                      |    5 +++
 tools/Makefile                    |    1 +
 tools/atmelimage.c                |   88 +++++++++++++++++++++++++++++++++++++
 tools/imagetool.c                 |    2 +
 tools/imagetool.h                 |    1 +
 8 files changed, 109 insertions(+)
 create mode 100644 arch/arm/cpu/armv7/at91/config.mk
 create mode 100644 tools/atmelimage.c

-- 
1.7.10.4

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

* [U-Boot] [RFC PATCH 1/2] mkimage: add atmelimage
  2014-04-23 14:29 [U-Boot] [RFC PATCH 0/2] Add atmel ROM code image Andreas Bießmann
@ 2014-04-23 14:29 ` Andreas Bießmann
  2014-04-24  3:09   ` Bo Shen
  2014-04-23 14:29 ` [U-Boot] [RFC PATCH 2/2] arm:at91: enable ROM loadable atmel image Andreas Bießmann
  2014-04-24  3:03 ` [U-Boot] [RFC PATCH 0/2] Add atmel ROM code image Bo Shen
  2 siblings, 1 reply; 7+ messages in thread
From: Andreas Bießmann @ 2014-04-23 14:29 UTC (permalink / raw)
  To: u-boot

The new atmelimage converts a machine code BLOB to bootable ROM image. Atmel
ROM has no sophisticated image format, it only checks the first 7 ARM vectors.
The vectors can contain valid B or LDR opcodes, the 6'th vector contains the
image size to load. The image size must not exceed 64 KiB.

Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>
---

 common/image.c     |    1 +
 include/image.h    |    1 +
 tools/Makefile     |    1 +
 tools/atmelimage.c |   88 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/imagetool.c  |    2 ++
 tools/imagetool.h  |    1 +
 6 files changed, 94 insertions(+)
 create mode 100644 tools/atmelimage.c

diff --git a/common/image.c b/common/image.c
index 9c6bec5..86bcd10 100644
--- a/common/image.c
+++ b/common/image.c
@@ -138,6 +138,7 @@ static const table_entry_t uimage_type[] = {
 	{	IH_TYPE_STANDALONE, "standalone", "Standalone Program", },
 	{	IH_TYPE_UBLIMAGE,   "ublimage",   "Davinci UBL image",},
 	{	IH_TYPE_MXSIMAGE,   "mxsimage",   "Freescale MXS Boot Image",},
+	{	IH_TYPE_ATMELIMAGE, "atmelimage", "ATMEL ROM-Boot Image",},
 	{	-1,		    "",		  "",			},
 };
 
diff --git a/include/image.h b/include/image.h
index 2508d7d..542c90d 100644
--- a/include/image.h
+++ b/include/image.h
@@ -224,6 +224,7 @@ struct lmb;
 #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	*/
+#define IH_TYPE_ATMELIMAGE	17	/* ATMEL ROM bootable Image	*/
 
 /*
  * Compression Types
diff --git a/tools/Makefile b/tools/Makefile
index c34df4f..003727e 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -69,6 +69,7 @@ RSA_OBJS-$(CONFIG_FIT_SIGNATURE) := rsa-sign.o rsa-verify.o rsa-checksum.o
 
 # common objs for dumpimage and mkimage
 dumpimage-mkimage-objs := aisimage.o \
+			atmelimage.o \
 			$(FIT_SIG_OBJS-y) \
 			crc32.o \
 			default_image.o \
diff --git a/tools/atmelimage.c b/tools/atmelimage.c
new file mode 100644
index 0000000..21436d3
--- /dev/null
+++ b/tools/atmelimage.c
@@ -0,0 +1,88 @@
+/*
+ * (C) Copyright 2014
+ * Andreas Bie?mann <andreas.devel@googlemail.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include "imagetool.h"
+#include <image.h>
+
+static int atmel_check_image_type(uint8_t type)
+{
+	if (type == IH_TYPE_ATMELIMAGE)
+		return EXIT_SUCCESS;
+	else
+		return EXIT_FAILURE;
+}
+
+static int atmel_verify_header(unsigned char *ptr, int image_size,
+			struct image_tool_params *params)
+{
+	uint32_t *ints = (uint32_t *)ptr;
+	size_t pos;
+
+	/* The size must not exceed 64 Kbytes */
+	if (image_size >= 64 * 1024)
+		return 1;
+
+	for (pos = 0; pos < 7; pos++) {
+		/*
+		 * all vectors except the 6'th one must contain valid
+		 * LDR or B Opcode
+		 */
+		if (pos == 5)
+			/* 6'th vector has image size set, check later */
+			continue;
+		if ((ints[pos] & 0xff000000) == 0xea000000)
+			/* valid B Opcode */
+			continue;
+		if ((ints[pos] & 0xfffff000) == 0xe59ff000)
+			/* valid LDR (I=0, P=1, U=1, B=0, W=0, L=1) */
+			continue;
+		/* ouch, one of the checks has missed ... */
+		return 1;
+	}
+	return ints[5] != image_size;
+}
+
+static void atmel_print_header(const void *ptr)
+{
+	printf("Image Type:   ATMEL ROM-Boot Image\n");
+}
+
+static void atmel_set_header(void *ptr, struct stat *sbuf, int ifd,
+				struct image_tool_params *params)
+{
+	/* just save the image size into 6'th interrupt vector */
+	uint32_t *ints = (uint32_t *)ptr;
+
+	/* The size must not exceed 64 Kbytes */
+	if (sbuf->st_size < 64 * 1024)
+		ints[5] = sbuf->st_size;
+}
+
+static int atmel_check_params(struct image_tool_params *params)
+{
+	return !(!params->eflag &&
+		!params->fflag &&
+		!params->xflag &&
+		((params->dflag && !params->lflag) ||
+		 (params->lflag && !params->dflag)));
+}
+
+static struct image_type_params atmelimage_params = {
+	.name		= "ATMEL ROM-Boot Image support",
+	.header_size	= 0,
+	.hdr		= NULL,
+	.check_image_type = atmel_check_image_type,
+	.verify_header	= atmel_verify_header,
+	.print_header	= atmel_print_header,
+	.set_header	= atmel_set_header,
+	.check_params	= atmel_check_params,
+};
+
+void init_atmel_image_type(void)
+{
+	register_image_type(&atmelimage_params);
+}
diff --git a/tools/imagetool.c b/tools/imagetool.c
index 29d2189..27072c8 100644
--- a/tools/imagetool.c
+++ b/tools/imagetool.c
@@ -27,6 +27,8 @@ void register_image_tool(imagetool_register_t image_register)
 	 */
 	register_func = image_register;
 
+	/* Init ATMEL ROM Boot Image generation/list support */
+	init_atmel_image_type();
 	/* Init Freescale PBL Boot image generation/list support */
 	init_pbl_image_type();
 	/* Init Kirkwood Boot image generation/list support */
diff --git a/tools/imagetool.h b/tools/imagetool.h
index c2c9aea..558f332 100644
--- a/tools/imagetool.h
+++ b/tools/imagetool.h
@@ -159,6 +159,7 @@ void register_image_type(struct image_type_params *tparams);
  * Supported image types init functions
  */
 void init_default_image_type(void);
+void init_atmel_image_type(void);
 void init_pbl_image_type(void);
 void init_ais_image_type(void);
 void init_kwb_image_type(void);
-- 
1.7.10.4

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

* [U-Boot] [RFC PATCH 2/2] arm:at91: enable ROM loadable atmel image
  2014-04-23 14:29 [U-Boot] [RFC PATCH 0/2] Add atmel ROM code image Andreas Bießmann
  2014-04-23 14:29 ` [U-Boot] [RFC PATCH 1/2] mkimage: add atmelimage Andreas Bießmann
@ 2014-04-23 14:29 ` Andreas Bießmann
  2014-04-24  3:10   ` Bo Shen
  2014-04-24  3:03 ` [U-Boot] [RFC PATCH 0/2] Add atmel ROM code image Bo Shen
  2 siblings, 1 reply; 7+ messages in thread
From: Andreas Bießmann @ 2014-04-23 14:29 UTC (permalink / raw)
  To: u-boot

For sama5d3xek we need to modify the SPL image for correct detection by ROM
code.

Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>
---

 arch/arm/cpu/armv7/at91/config.mk |   10 ++++++++++
 spl/Makefile                      |    5 +++++
 2 files changed, 15 insertions(+)
 create mode 100644 arch/arm/cpu/armv7/at91/config.mk

diff --git a/arch/arm/cpu/armv7/at91/config.mk b/arch/arm/cpu/armv7/at91/config.mk
new file mode 100644
index 0000000..09eab70
--- /dev/null
+++ b/arch/arm/cpu/armv7/at91/config.mk
@@ -0,0 +1,10 @@
+#
+# Copyright (C) 2014, Andreas Bie?mann <andreas.devel@googlemail.com>
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+ifdef CONFIG_SPL_BUILD
+ALL-y	+= boot.bin
+else
+ALL-y	+= u-boot.img
+endif
diff --git a/spl/Makefile b/spl/Makefile
index 6fec252..031bf54 100644
--- a/spl/Makefile
+++ b/spl/Makefile
@@ -182,6 +182,11 @@ MKIMAGEFLAGS_MLO.byteswap = -T omapimage -n byteswap -a $(CONFIG_SPL_TEXT_BASE)
 MLO MLO.byteswap: $(obj)/u-boot-spl.bin
 	$(call if_changed,mkimage)
 
+MKIMAGEFLAGS_boot.bin = -T atmelimage
+
+boot.bin: $(obj)/u-boot-spl.bin
+	$(call if_changed,mkimage)
+
 ALL-y	+= $(obj)/$(SPL_BIN).bin
 
 ifdef CONFIG_SAMSUNG
-- 
1.7.10.4

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

* [U-Boot] [RFC PATCH 0/2] Add atmel ROM code image
  2014-04-23 14:29 [U-Boot] [RFC PATCH 0/2] Add atmel ROM code image Andreas Bießmann
  2014-04-23 14:29 ` [U-Boot] [RFC PATCH 1/2] mkimage: add atmelimage Andreas Bießmann
  2014-04-23 14:29 ` [U-Boot] [RFC PATCH 2/2] arm:at91: enable ROM loadable atmel image Andreas Bießmann
@ 2014-04-24  3:03 ` Bo Shen
  2 siblings, 0 replies; 7+ messages in thread
From: Bo Shen @ 2014-04-24  3:03 UTC (permalink / raw)
  To: u-boot

Hi Andreas,
   Thanks for your work.

On 04/23/2014 10:29 PM, Andreas Bie?mann wrote:
> This series add atmelimage support to mkimage.
>
> An atmelimage is a quite dumb image type cause it has no real header. The file
> is mostly unmodified but the 6'th ARM vector gets replaced by the image size
> to load.
>
> Heiko, I know your approach setting the vector in start.S but I think this
> solution is a bit smarter. We would need to patch at least 2 start.S files
> (arm926ejs and armv7), maybe also the arm920t one too. In fact is the
> conversion of executable BLOB to ROM detected executable BLOB something that
> should really be done afterwards as all other SoC vendors do.
>
>
> Andreas Bie?mann (2):
>    mkimage: add atmelimage
>    arm:at91: enable ROM loadable atmel image
>
>   arch/arm/cpu/armv7/at91/config.mk |   10 +++++
>   common/image.c                    |    1 +
>   include/image.h                   |    1 +
>   spl/Makefile                      |    5 +++
>   tools/Makefile                    |    1 +
>   tools/atmelimage.c                |   88 +++++++++++++++++++++++++++++++++++++
>   tools/imagetool.c                 |    2 +
>   tools/imagetool.h                 |    1 +
>   8 files changed, 109 insertions(+)
>   create mode 100644 arch/arm/cpu/armv7/at91/config.mk
>   create mode 100644 tools/atmelimage.c
>

For this patch set, test ok on sama5d33ek with spi flash and mmc boot.

For nand flash boot, it doesn't support to add PMECC header, so only 
works in software ECC or none ECC mode (that means, u-boot flash 
boot.bin to NAND flash won't work). So, do you plan to add following patch?

Best Regards,
Bo Shen

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

* [U-Boot] [RFC PATCH 1/2] mkimage: add atmelimage
  2014-04-23 14:29 ` [U-Boot] [RFC PATCH 1/2] mkimage: add atmelimage Andreas Bießmann
@ 2014-04-24  3:09   ` Bo Shen
  2014-04-24  5:23     ` Andreas Bießmann
  0 siblings, 1 reply; 7+ messages in thread
From: Bo Shen @ 2014-04-24  3:09 UTC (permalink / raw)
  To: u-boot

Hi Andreas,

On 04/23/2014 10:29 PM, Andreas Bie?mann wrote:
> +static void atmel_set_header(void *ptr, struct stat *sbuf, int ifd,
> +				struct image_tool_params *params)
> +{
> +	/* just save the image size into 6'th interrupt vector */
> +	uint32_t *ints = (uint32_t *)ptr;
> +
> +	/* The size must not exceed 64 Kbytes */
> +	if (sbuf->st_size < 64 * 1024)
> +		ints[5] = sbuf->st_size;
> +}

Here, just a reminder.

As only sama5d3xek support SPL, so it won't hurt. However, if plan to 
add other Atmel boards with SPL support, we need check it more strictly 
(e.g: sam9x5 only support up to 24k bytes).

Best Regards,
Bo Shen

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

* [U-Boot] [RFC PATCH 2/2] arm:at91: enable ROM loadable atmel image
  2014-04-23 14:29 ` [U-Boot] [RFC PATCH 2/2] arm:at91: enable ROM loadable atmel image Andreas Bießmann
@ 2014-04-24  3:10   ` Bo Shen
  0 siblings, 0 replies; 7+ messages in thread
From: Bo Shen @ 2014-04-24  3:10 UTC (permalink / raw)
  To: u-boot

Hi Andreas,

On 04/23/2014 10:29 PM, Andreas Bie?mann wrote:
> For sama5d3xek we need to modify the SPL image for correct detection by ROM
> code.
>
> Signed-off-by: Andreas Bie?mann <andreas.devel@googlemail.com>

For whole series,
Tested-by: Bo Shen <voice.shen@atmel.com>

> ---
>
>   arch/arm/cpu/armv7/at91/config.mk |   10 ++++++++++
>   spl/Makefile                      |    5 +++++
>   2 files changed, 15 insertions(+)
>   create mode 100644 arch/arm/cpu/armv7/at91/config.mk
>
> diff --git a/arch/arm/cpu/armv7/at91/config.mk b/arch/arm/cpu/armv7/at91/config.mk
> new file mode 100644
> index 0000000..09eab70
> --- /dev/null
> +++ b/arch/arm/cpu/armv7/at91/config.mk
> @@ -0,0 +1,10 @@
> +#
> +# Copyright (C) 2014, Andreas Bie?mann <andreas.devel@googlemail.com>
> +#
> +# SPDX-License-Identifier:	GPL-2.0+
> +#
> +ifdef CONFIG_SPL_BUILD
> +ALL-y	+= boot.bin
> +else
> +ALL-y	+= u-boot.img
> +endif
> diff --git a/spl/Makefile b/spl/Makefile
> index 6fec252..031bf54 100644
> --- a/spl/Makefile
> +++ b/spl/Makefile
> @@ -182,6 +182,11 @@ MKIMAGEFLAGS_MLO.byteswap = -T omapimage -n byteswap -a $(CONFIG_SPL_TEXT_BASE)
>   MLO MLO.byteswap: $(obj)/u-boot-spl.bin
>   	$(call if_changed,mkimage)
>
> +MKIMAGEFLAGS_boot.bin = -T atmelimage
> +
> +boot.bin: $(obj)/u-boot-spl.bin
> +	$(call if_changed,mkimage)
> +
>   ALL-y	+= $(obj)/$(SPL_BIN).bin
>
>   ifdef CONFIG_SAMSUNG
>

Best Regards,
Bo Shen

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

* [U-Boot] [RFC PATCH 1/2] mkimage: add atmelimage
  2014-04-24  3:09   ` Bo Shen
@ 2014-04-24  5:23     ` Andreas Bießmann
  0 siblings, 0 replies; 7+ messages in thread
From: Andreas Bießmann @ 2014-04-24  5:23 UTC (permalink / raw)
  To: u-boot

Hi Bo,

On 24.04.14 05:09, Bo Shen wrote:
> Hi Andreas,
> 
> On 04/23/2014 10:29 PM, Andreas Bie?mann wrote:
>> +static void atmel_set_header(void *ptr, struct stat *sbuf, int ifd,
>> +                struct image_tool_params *params)
>> +{
>> +    /* just save the image size into 6'th interrupt vector */
>> +    uint32_t *ints = (uint32_t *)ptr;
>> +
>> +    /* The size must not exceed 64 Kbytes */
>> +    if (sbuf->st_size < 64 * 1024)
>> +        ints[5] = sbuf->st_size;
>> +}
> 
> Here, just a reminder.
> 
> As only sama5d3xek support SPL, so it won't hurt. However, if plan to
> add other Atmel boards with SPL support, we need check it more strictly
> (e.g: sam9x5 only support up to 24k bytes).

Well, I'd like to have other devices also support SPL. I think we should
just remove that check here. We should use the linker for size checking.

Best regards

Andreas Bie?mann

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

end of thread, other threads:[~2014-04-24  5:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-23 14:29 [U-Boot] [RFC PATCH 0/2] Add atmel ROM code image Andreas Bießmann
2014-04-23 14:29 ` [U-Boot] [RFC PATCH 1/2] mkimage: add atmelimage Andreas Bießmann
2014-04-24  3:09   ` Bo Shen
2014-04-24  5:23     ` Andreas Bießmann
2014-04-23 14:29 ` [U-Boot] [RFC PATCH 2/2] arm:at91: enable ROM loadable atmel image Andreas Bießmann
2014-04-24  3:10   ` Bo Shen
2014-04-24  3:03 ` [U-Boot] [RFC PATCH 0/2] Add atmel ROM code image Bo Shen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox