Skip to contentSkip to conversation

imx: mx6: Add support for MX6 plugin images

PATCH Superseded Ye.Li 3 participants 7 messages Nov 4, 2014 – Nov 5, 2014

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Ye.Li

author
#0 lore raw

PATCH 1/4 imx: mx6: Add support for MX6 plugin images

Plugin image is a firmware which can be executed by boot ROM to do device initialization, custom settings, delay assertion, etc.

The boot ROM detects the image type using the plugin flag of the boot data structure. If the plugin flag is 1, then the ROM uses the image as a plugin function. The function must initialize the boot device and copy the program image to the final location. At the end the plugin function must return with the program image parameters.

This patch supports generating plugin images and implement a framework for plugin code entry and exit. For any board to generate the plugin image, the macros below must be implemented:
imx6_ddr_setting
imx6_clock_gating
imx6_qos_setting

---
 arch/arm/include/asm/arch-mx6/mx6_plugin.S |  145 +++++++++++++++
 tools/imximage.c                           |  263 ++++++++++++++++++++++------
 tools/imximage.h                           |   10 +-
 3 files changed, 366 insertions(+), 52 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-mx6/mx6_plugin.S
arch/arm/include/asm/arch-mx6/mx6_plugin.S new file +145 -0
new file mode 100644
index 0000000..1f5ae83
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2012-2014 Freescale Semiconductor, Inc.
+ *
+ * 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.
+ */
+
+#include <config.h>
+
+#ifdef CONFIG_ROM_UNIFIED_SECTIONS
+#define ROM_API_TABLE_BASE_ADDR_LEGACY		0x180
+#define ROM_VERSION_OFFSET               	0x80
+#else
+#define ROM_API_TABLE_BASE_ADDR_LEGACY		0xC0
+#define ROM_VERSION_OFFSET               	0x48
+#endif
+#define ROM_API_TABLE_BASE_ADDR_MX6DQ_TO15	0xC4
+#define ROM_API_TABLE_BASE_ADDR_MX6DL_TO12	0xC4
+#define ROM_API_HWCNFG_SETUP_OFFSET		0x08
+#define ROM_VERSION_TO10			0x10
+#define ROM_VERSION_TO12			0x12
+#define ROM_VERSION_TO15			0x15
+
+plugin_start:
+
+	push    {r0-r4, lr}
+
+	imx6_ddr_setting
+	imx6_clock_gating
+	imx6_qos_setting
+
+/*
+ * The following is to fill in those arguments for this ROM function
+ * pu_irom_hwcnfg_setup(void **start, size_t *bytes, const void *boot_data)
+ * This function is used to copy data from the storage media into DDR.
+ * start - Initial (possibly partial) image load address on entry.
+ *         Final image load address on exit.
+ * bytes - Initial (possibly partial) image size on entry.
+ *         Final image size on exit.
+ * boot_data - Initial @ref ivt Boot Data load address.
+ */
+	adr r0, boot_data2
+	adr r1, image_len2
+	adr r2, boot_data2
+
+#ifdef CONFIG_SYS_BOOT_EIMNOR
+#ifdef CONFIG_MX6SX
+	ldr r3, =ROM_VERSION_OFFSET
+	ldr r4, [r3]
+	cmp r4, #ROM_VERSION_TO10
+	bgt before_calling_rom___pu_irom_hwcnfg_setup
+	ldr r3, =0x00900b00
+	ldr r4, =0x50000000
+	str r4, [r3, #0x5c]
+#else
+	ldr r3, =0x00900800
+	ldr r4, =0x08000000
+	str r4, [r3, #0xc0]
+#endif
+#endif
+
+/*
+ * check the _pu_irom_api_table for the address
+ */
+before_calling_rom___pu_irom_hwcnfg_setup:
+	ldr r3, =ROM_VERSION_OFFSET
+	ldr r4, [r3]
+#if defined(CONFIG_MX6SOLO) || defined(CONFIG_MX6DL)
+	ldr r3, =ROM_VERSION_TO12
+	cmp r4, r3
+	ldrge r3, =ROM_API_TABLE_BASE_ADDR_MX6DL_TO12
+	ldrlt r3, =ROM_API_TABLE_BASE_ADDR_LEGACY
+#elif defined(CONFIG_MX6Q)
+	ldr r3, =ROM_VERSION_TO15
+	cmp r4, r3
+	ldrge r3, =ROM_API_TABLE_BASE_ADDR_MX6DQ_TO15
+	ldrlt r3, =ROM_API_TABLE_BASE_ADDR_LEGACY
+#else
+	ldr r3, =ROM_API_TABLE_BASE_ADDR_LEGACY
+#endif
+	ldr r4, [r3, #ROM_API_HWCNFG_SETUP_OFFSET]
+	blx r4
+after_calling_rom___pu_irom_hwcnfg_setup:
+
+
+/* To return to ROM from plugin, we need to fill in these argument.
+ * Here is what need to do:
+ * Need to construct the paramters for this function before return to ROM:
+ * plugin_download(void **start, size_t *bytes, UINT32 *ivt_offset)
+ */
+	pop {r0-r4, lr}
+	push {r5}
+	ldr r5, boot_data2
+	str r5, [r0]
+	ldr r5, image_len2
+	str r5, [r1]
+	ldr r5, second_ivt_offset
+	str r5, [r2]
+	mov r0, #1
+	pop {r5}
+
+	/* return back to ROM code */
+	bx lr
+
+/* make the following data right in the end of the output*/
+.ltorg
+
+#if (defined(CONFIG_SYS_BOOT_EIMNOR) || defined(CONFIG_SYS_BOOT_QSPI))
+#define FLASH_OFFSET 0x1000
+#else
+#define FLASH_OFFSET 0x400
+#endif
+
+/*
+ * second_ivt_offset is the offset from the "second_ivt_header" to
+ * "image_copy_start", which involves FLASH_OFFSET, plus the first
+ * ivt_header, the plugin code size itself recorded by "ivt2_header"
+ */
+
+second_ivt_offset:      .long (ivt2_header + 0x2C + FLASH_OFFSET)
+
+/*
+ * The following is the second IVT header plus the second boot data
+ */
+ivt2_header:            .long 0x0
+app2_code_jump_v:       .long 0x0
+reserv3:                .long 0x0
+dcd2_ptr:               .long 0x0
+boot_data2_ptr:         .long 0x0
+self_ptr2:              .long 0x0
+app_code_csf2:          .long 0x0
+reserv4:                .long 0x0
+boot_data2:             .long 0x0
+image_len2:             .long 0x0
+plugin2:                .long 0x0
tools/imximage.c +212 -51

334 lines not on this page · raw message

tools/imximage.h +9 -1
index 5b5ad0e..ef41d52 100644
@@ -8,7 +8,9 @@
 #ifndef _IMXIMAGE_H_
 #define _IMXIMAGE_H_
 
+#include <config.h>
 #define MAX_HW_CFG_SIZE_V2 220 /* Max number of registers imx can set for v2 */
+#define MAX_PLUGIN_CODE_SIZE (16*1024)
 #define MAX_HW_CFG_SIZE_V1 60  /* Max number of registers imx can set for v1 */
 #define APP_CODE_BARKER	0xB1
 #define DCD_BARKER	0xB17219E9
@@ -54,6 +56,7 @@ enum imximage_cmd {
 	CMD_BOOT_OFFSET,
 	CMD_DATA,
 	CMD_CSF,
+	CMD_PLUGIN,
 };
 
 enum imximage_fld_types {
@@ -149,7 +152,12 @@ typedef struct {
 typedef struct {
 	flash_header_v2_t fhdr;
 	boot_data_t boot_data;
-	dcd_v2_t dcd_table;
+	union {
+		dcd_v2_t dcd_table;
+#ifdef CONFIG_USE_PLUGIN
+		char plugin_code[MAX_PLUGIN_CODE_SIZE];
+#endif
+	} data;
 } imx_header_v2_t;
 
 /* The header must be aligned to 4k on MX53 for NAND boot */
Signature · 1 line
1.7.4.1
author
#1 lore raw

PATCH 2/4 imx: mx6q/dlarm2: Add support for building plugin image

Update "cfg" script to build for plugin image. This default plugin image supports the boot devices as DCD image.

To enable the plugin, must define the CONFIG_USE_PLUGIN in "mx6qarm2.h"

---
 board/freescale/mx6qarm2/Makefile           |    4 +
 board/freescale/mx6qarm2/imximage.cfg       |    9 +
 board/freescale/mx6qarm2/imximage_mx6dl.cfg |    9 +
 board/freescale/mx6qarm2/plugin.S           |  943 +++++++++++++++++++++++++++
 4 files changed, 965 insertions(+), 0 deletions(-)
 create mode 100644 board/freescale/mx6qarm2/plugin.S
board/freescale/mx6qarm2/Makefile +4 -0
index 79401f4..ed08acd 100644
@@ -7,3 +7,7 @@
 #
 
 obj-y	:= mx6qarm2.o
+
+extra-$(CONFIG_USE_PLUGIN) :=  plugin.bin
+$(obj)/plugin.bin: $(obj)/plugin.o
+	$(OBJCOPY) -O binary --gap-fill 0xff $< $@
board/freescale/mx6qarm2/imximage.cfg +9 -0
index c85bde5..c5b927a 100644
@@ -10,6 +10,9 @@
  * The syntax is taken as close as possible with the kwbimage
  */
 
+#define __ASSEMBLY__
+#include <config.h>
+
 /* image version */
 IMAGE_VERSION 2
 
@@ -19,6 +22,11 @@ IMAGE_VERSION 2
  */
 BOOT_FROM	sd
 
+#ifdef CONFIG_USE_PLUGIN
+/*PLUGIN    plugin-binary-file    IRAM_FREE_START_ADDR*/
+PLUGIN	board/freescale/mx6qarm2/plugin.bin 0x00907000
+#else
+
 /*
  * Device Configuration Data (DCD)
  *
@@ -336,3 +344,4 @@ DATA 4 0x020e0018 0x007F007F
 DATA 4 0x020e001c 0x007F007F
 
 #endif /* CONFIG_MX6DQ_LPDDR2 */
+#endif
board/freescale/mx6qarm2/imximage_mx6dl.cfg +9 -0
index ae8dcc6..0f4048d 100644
@@ -10,6 +10,9 @@
  * The syntax is taken as close as possible with the kwbimage
  */
 
+#define __ASSEMBLY__
+#include <config.h>
+
 /* image version */
 IMAGE_VERSION 2
 
@@ -19,6 +22,11 @@ IMAGE_VERSION 2
  */
 BOOT_FROM	sd
 
+#ifdef CONFIG_USE_PLUGIN
+/*PLUGIN    plugin-binary-file    IRAM_FREE_START_ADDR*/
+PLUGIN	board/freescale/mx6qarm2/plugin.bin 0x00907000
+#else
+
 /*
  * Device Configuration Data (DCD)
  *
@@ -460,3 +468,4 @@ DATA 4 0x020e0010 0xF00000CF
 DATA 4 0x020e0018 0x007F007F
 DATA 4 0x020e001c 0x007F007F
 #endif /* CONFIG_MX6DL_LPDDR2 */
+#endif
board/freescale/mx6qarm2/plugin.S new file +943 -0

943 lines not on this page · raw message

Signature · 1 line
1.7.4.1
author
#3 lore raw

PATCH 3/4 imx: mx6slevk: Add support for building plugin image

In reply to Ye.Li

Update "cfg" script to build for plugin image. This default plugin image supports the boot devices as DCD image.

To enable the plugin, must define the CONFIG_USE_PLUGIN in "mx6slevk.h"

---
 board/freescale/mx6slevk/Makefile     |    4 +
 board/freescale/mx6slevk/imximage.cfg |    9 ++
 board/freescale/mx6slevk/plugin.S     |  187 +++++++++++++++++++++++++++++++++
 3 files changed, 200 insertions(+), 0 deletions(-)
 create mode 100644 board/freescale/mx6slevk/plugin.S
board/freescale/mx6slevk/Makefile +4 -0
index 6e1971e..fb44826 100644
@@ -4,3 +4,7 @@
 #
 
 obj-y  := mx6slevk.o
+
+extra-$(CONFIG_USE_PLUGIN) :=  plugin.bin
+$(obj)/plugin.bin: $(obj)/plugin.o
+	$(OBJCOPY) -O binary --gap-fill 0xff $< $@
board/freescale/mx6slevk/imximage.cfg +9 -0
index 16ea597..b574357 100644
@@ -9,6 +9,9 @@
  * The syntax is taken as close as possible with the kwbimage
  */
 
+#define __ASSEMBLY__
+#include <config.h>
+
 /* image version */
 
 IMAGE_VERSION 2
@@ -20,6 +23,11 @@ IMAGE_VERSION 2
 
 BOOT_FROM	sd
 
+#ifdef CONFIG_USE_PLUGIN
+/*PLUGIN    plugin-binary-file    IRAM_FREE_START_ADDR*/
+PLUGIN	board/freescale/mx6slevk/plugin.bin 0x00907000
+#else
+
 /*
  * Device Configuration Data (DCD)
  *
@@ -113,3 +121,4 @@ DATA 4 0x021b08b8 0x00000800
 DATA 4 0x021b0004 0x00025564
 DATA 4 0x021b0404 0x00011006
 DATA 4 0x021b001c 0x00000000
+#endif
board/freescale/mx6slevk/plugin.S new file +187 -0

187 lines not on this page · raw message

Signature · 1 line
1.7.4.1
author
#4 lore raw

PATCH 4/4 imx: mx6sxsabresd: Add support for building plugin image

In reply to Ye.Li

Update "cfg" script to build for plugin image. This default plugin image supports the boot devices as DCD image.

To enable the plugin, must define the CONFIG_USE_PLUGIN in "mx6sxsabresd.h"

---
 board/freescale/mx6sxsabresd/Makefile     |    4 +
 board/freescale/mx6sxsabresd/imximage.cfg |    6 ++
 board/freescale/mx6sxsabresd/plugin.S     |  135 +++++++++++++++++++++++++++++
 3 files changed, 145 insertions(+), 0 deletions(-)
 create mode 100644 board/freescale/mx6sxsabresd/plugin.S
board/freescale/mx6sxsabresd/Makefile +4 -0
index 97dbfda..bd9ac6f 100644
@@ -4,3 +4,7 @@
 #
 
 obj-y  := mx6sxsabresd.o
+
+extra-$(CONFIG_USE_PLUGIN) :=  plugin.bin
+$(obj)/plugin.bin: $(obj)/plugin.o
+	$(OBJCOPY) -O binary --gap-fill 0xff $< $@
board/freescale/mx6sxsabresd/imximage.cfg +6 -0
index c862617..9a99208 100644
@@ -18,6 +18,11 @@ IMAGE_VERSION 2
 
 BOOT_FROM	sd
 
+#ifdef CONFIG_USE_PLUGIN
+/*PLUGIN    plugin-binary-file    IRAM_FREE_START_ADDR*/
+PLUGIN	board/freescale/mx6sxsabresd/plugin.bin 0x00907000
+#else
+
 /*
  * Device Configuration Data (DCD)
  *
@@ -130,3 +135,4 @@ DATA 4 0x021b001c 0x04008040
 DATA 4 0x021b0020 0x00000800
 DATA 4 0x021b0818 0x00011117
 DATA 4 0x021b001c 0x00000000
+#endif
board/freescale/mx6sxsabresd/plugin.S new file +135 -0

135 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#2 lore raw

PATCH 2/4 imx: mx6q/dlarm2: Add support for building plugin image

In reply to Ye.Li
Quoted 6 lines · Ye.Li

Update "cfg" script to build for plugin image. This default plugin image supports the boot devices as DCD image.

To enable the plugin, must define the CONFIG_USE_PLUGIN in "mx6qarm2.h"

I'd prefer:

CONFIG_IMX_BOOTROM_PLUGIN

This makes it easier to spot when looking at the config option.

Signature · 3 lines
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750
reviewer
#5 lore raw

PATCH 1/4 imx: mx6: Add support for MX6 plugin images

In reply to Ye.Li

Hi Ye Li,

Quoted 2 lines · Ye.Li

Plugin image is a firmware which can be executed by boot ROM to do device initialization, custom settings, delay assertion, etc.

Could you please elaborate a bit mode about the usage of the 'plugin image'?

When does it become useful? When should we make use of it instead of the current DCD table?

Thanks,

Fabio Estevam

#6 lore raw

PATCH 1/4 imx: mx6: Add support for MX6 plugin images

Hi Fabio,

Quoted 5 lines · Fabio Estevam

Hi Ye Li,

Quoted 2 lines · Ye.Li

Plugin image is a firmware which can be executed by boot ROM to do device initialization, custom settings, delay assertion, etc.

Quoted 8 lines

Could you please elaborate a bit mode about the usage of the 'plugin image'?

When does it become useful? When should we make use of it instead of the current DCD table?

Thanks,

Fabio Estevam

I will improve the patch message in v2.

Best regards,
Ye Li