Skip to contentSkip to conversation

Add atmel ROM code image

RFC PATCH Superseded Andreas Bießmann 2 participants 7 messages Apr 23, 2014 – Apr 24, 2014

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover Add atmel ROM code image

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
Signature · 1 line
1.7.10.4
#1 lore raw

RFC PATCH 1/2 mkimage: add atmelimage

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.

---

 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
common/image.c +1 -0
index 9c6bec5..86bcd10 100644
@@ -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,		    "",		  "",			},
 };
 
include/image.h +1 -0
index 2508d7d..542c90d 100644
@@ -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
tools/Makefile +1 -0
index c34df4f..003727e 100644
@@ -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 \
tools/atmelimage.c new file +88 -0

88 lines not on this page · raw message

tools/imagetool.c +2 -0
index 29d2189..27072c8 100644
@@ -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 */
tools/imagetool.h +1 -0
index c2c9aea..558f332 100644
@@ -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);
Signature · 1 line
1.7.10.4
#4 lore raw

RFC PATCH 2/2 arm:at91: enable ROM loadable atmel image

In reply to Andreas Bießmann

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

---

 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
arch/arm/cpu/armv7/at91/config.mk new file +10 -0
new file mode 100644
index 0000000..09eab70
@@ -0,0 +1,10 @@
+#
+# Copyright (C) 2014, Andreas Bie?mann <[email protected]>
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+ifdef CONFIG_SPL_BUILD
+ALL-y	+= boot.bin
+else
+ALL-y	+= u-boot.img
+endif
spl/Makefile +5 -0
index 6fec252..031bf54 100644
@@ -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
Signature · 1 line
1.7.10.4
#6 lore raw

cover Add atmel ROM code image

In reply to Andreas Bießmann

Hi Andreas,
Thanks for your work.

Quoted 26 lines · Andreas Bie?mann

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(+)
Quoted 3 lines

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

#2 lore raw

RFC PATCH 1/2 mkimage: add atmelimage

In reply to Andreas Bießmann

Hi Andreas,

tools/atmelimage.c line 63

Quoted 10 lines · Andreas Bie?mann
tools/atmelimage.c new file +10 -0
+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

#5 lore raw

RFC PATCH 2/2 arm:at91: enable ROM loadable atmel image

In reply to Andreas Bießmann

Hi Andreas,

Quoted 4 lines · Andreas Bie?mann

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

For whole series,

Quoted 30 lines

---

  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

arch/arm/cpu/armv7/at91/config.mk new file +10 -0
new file mode 100644
index 0000000..09eab70
@@ -0,0 +1,10 @@
+#
+# Copyright (C) 2014, Andreas Bie?mann <[email protected]>
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+ifdef CONFIG_SPL_BUILD
+ALL-y	+= boot.bin
+else
+ALL-y	+= u-boot.img
+endif
spl/Makefile +0 -0
index 6fec252..031bf54 100644
@@ -182,6 +182,11 @@ MKIMAGEFLAGS_MLO.byteswap = -T omapimage -n byteswap -a $(CONFIG_SPL_TEXT_BASE)
  MLO MLO.byteswap: $(obj)/u-boot-spl.bin

spl/Makefile MKIMAGEFLAGS_MLO.byteswap = -T omapimage -n byteswap -a $(CONFIG_SPL_TEXT_BASE) · line 192

Quoted 10 lines
spl/Makefile +5 -0
  	$(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

#3 lore raw

RFC PATCH 1/2 mkimage: add atmelimage

In reply to Bo Shen

Hi Bo,

Quoted 16 lines · Bo Shen

Hi Andreas,

tools/atmelimage.c line 63

Quoted 10 lines · Andreas Bie?mann
tools/atmelimage.c new file +10 -0
+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.

Quoted 3 lines

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