Skip to contentSkip to conversation

SPL: Port SPL framework to powerpc

PATCH Superseded Stefan Roese 5 participants 34 messages Aug 23, 2012 – Aug 25, 2012 PowerPC

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

cover SPL: Port SPL framework to powerpc

This patchset ports the SPL framework to powerpc. Its based on the SPL generalization lately done by Tom Rini. The patches can be applied on top of his 3rd version located here:

http://github.com/trini/u-boot WIP/spl-improvements

Additionally, a new MPC5200 board port is included, the a3m071 board port. This board port uses this SPL framework mainly to speed up booting into the OS (Linux of course). Detection of Linux vs. U-Boot booting is done here by checking the environment variable "boot_os". If "boot_os" is set to "yes", then the OS (Linux) is booted. Otherwise the "real" U-Boot is booted. For this env checking in the SPL, a small restructuring of the env code has been done.

Comments welcome!

Thanks,
Stefan

#1 lore raw

PATCH 1/6 SPL: Add NOR flash booting support

SPL NOR flash booting support is quite simple. Only copying of the images is needed.

On MPC5xxx we need to make sure to only use the standard memcpy() implementation and not the MPC5xxx specific one. As the MPC5xxx version has some complexity which is not needed for this SPL booting.

---
 common/spl/Makefile  |  1 +
 common/spl/spl.c     |  5 ++++
 common/spl/spl_nor.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/spl.h        |  3 +++
 4 files changed, 77 insertions(+)
 create mode 100644 common/spl/spl_nor.c
common/spl/Makefile +1 -0
index b61b438..53a82c4 100644
@@ -15,6 +15,7 @@ LIB	= $(obj)libspl.o
 
 ifdef CONFIG_SPL_BUILD
 COBJS-$(CONFIG_SPL_FRAMEWORK) += spl.o
+COBJS-$(CONFIG_SPL_NOR_SUPPORT) += spl_nor.o
 COBJS-$(CONFIG_SPL_YMODEM_SUPPORT) += spl_ymodem.o
 endif
 
common/spl/spl.c +5 -0
index dcf8556..4c0135e 100644
@@ -170,6 +170,11 @@ void board_init_r(gd_t *id, ulong dummy)
 		spl_nand_load_image();
 		break;
 #endif
+#ifdef CONFIG_SPL_NOR_SUPPORT
+	case BOOT_DEVICE_NOR:
+		spl_nor_load_image();
+		break;
+#endif
 #ifdef CONFIG_SPL_YMODEM_SUPPORT
 	case BOOT_DEVICE_UART:
 		spl_ymodem_load_image();
common/spl/spl_nor.c new file +68 -0

68 lines not on this page · raw message

include/spl.h +3 -0
index 3b3051f..efa160e 100644
@@ -55,6 +55,9 @@ void spl_display_print(void);
 /* NAND SPL functions */
 void spl_nand_load_image(void);
 
+/* NOR SPL functions */
+void spl_nor_load_image(void);
+
 /* MMC SPL functions */
 void spl_mmc_load_image(void);
 
Signature · 1 line
1.7.12
#2 lore raw

PATCH 1/6 SPL: Add NOR flash booting support

Quoted 7 lines · Stefan Roese

SPL NOR flash booting support is quite simple. Only copying of the images is needed.

On MPC5xxx we need to make sure to only use the standard memcpy() implementation and not the MPC5xxx specific one. As the MPC5xxx version has some complexity which is not needed for this SPL booting.

I assume there's good reason to use SPL on NOR here? Is a near-future goal to do SPL-boots-Linux and thus the desire for a very small loader?
Thanks!

Signature · 1 line
Tom
#3 lore raw

PATCH 1/6 SPL: Add NOR flash booting support

Quoted 11 lines · Tom Rini
Quoted 7 lines · Stefan Roese

SPL NOR flash booting support is quite simple. Only copying of the images is needed.

On MPC5xxx we need to make sure to only use the standard memcpy() implementation and not the MPC5xxx specific one. As the MPC5xxx version has some complexity which is not needed for this SPL booting.

I assume there's good reason to use SPL on NOR here? Is a near-future goal to do SPL-boots-Linux and thus the desire for a very small loader?

Yes. As explained in the cover-letter, the board port using this SPL NOR support (MPC5200 based) mainly uses this SPL framework to speed up booting into Linux. Less code loaded from NOR, zero relocation (on this PPC port at least), etc.

My first quick tests show a boot to Linux speedup by approx. 0.5 seconds compared to the good-old U-Boot -> Linux booting. So it definitely makes sense in time-critical bootup situation.

Thanks,
Stefan

#4 lore raw

PATCH 2/6 powerpc: Extract EPAPR_MAGIC constants into processor.h

In reply to Stefan Roese

By extracting these defines into a header, they can be re-used by other C sources as well. This will be done by the SPL framework OS boot support.

---
 arch/powerpc/include/asm/processor.h | 6 ++++++
 arch/powerpc/lib/bootm.c             | 6 ------
 2 files changed, 6 insertions(+), 6 deletions(-)
arch/powerpc/include/asm/processor.h +6 -0
index dc009d6..daa670b 100644
@@ -1329,4 +1329,10 @@ void _nmask_and_or_msr(unsigned long nmask, unsigned long or_val);
 #endif
 #endif /* CONFIG_MACH_SPECIFIC */
 
+#if defined(CONFIG_MPC85xx) || defined(CONFIG_440)
+ #define EPAPR_MAGIC	(0x45504150)
+#else
+ #define EPAPR_MAGIC	(0x65504150)
+#endif
+
 #endif /* __ASM_PPC_PROCESSOR_H */
arch/powerpc/lib/bootm.c +0 -6
index 0c54c72..09bb7e6 100644
@@ -87,12 +87,6 @@ static void boot_jump_linux(bootm_headers_t *images)
 		 *   r8: 0
 		 *   r9: 0
 		 */
-#if defined(CONFIG_MPC85xx) || defined(CONFIG_440)
- #define EPAPR_MAGIC	(0x45504150)
-#else
- #define EPAPR_MAGIC	(0x65504150)
-#endif
-
 		debug ("   Booting using OF flat tree...\n");
 		WATCHDOG_RESET ();
 		(*kernel) ((bd_t *)of_flat_tree, 0, 0, EPAPR_MAGIC,
Signature · 1 line
1.7.12
#5 lore raw

PATCH 3/6 SPL: Port SPL framework to powerpc

In reply to Stefan Roese

This patch enables the SPL framework to be used on powerpc platforms and not only ARM.

---
 common/spl/spl.c | 45 ++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 42 insertions(+), 3 deletions(-)
common/spl/spl.c +42 -3
index 4c0135e..7a8f2a8 100644
@@ -25,7 +25,6 @@
 #include <common.h>
 #include <spl.h>
 #include <asm/u-boot.h>
-#include <asm/utils.h>
 #include <nand.h>
 #include <fat.h>
 #include <version.h>
@@ -36,11 +35,17 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#ifndef CONFIG_SYS_UBOOT_START
+#define CONFIG_SYS_UBOOT_START	CONFIG_SYS_TEXT_BASE
+#endif
+
 u32 *boot_params_ptr = NULL;
 struct spl_image_info spl_image;
 
+#ifdef CONFIG_ARM
 /* Define global data structure pointer to it*/
 gd_t gdata __attribute__ ((section(".data")));
+#endif
 static bd_t bdata __attribute__ ((section(".data")));
 
 inline void hang(void)
@@ -50,6 +55,7 @@ inline void hang(void)
 		;
 }
 
+#ifdef CONFIG_ARM
 void __weak board_init_f(ulong dummy)
 {
 	/*
@@ -61,6 +67,17 @@ void __weak board_init_f(ulong dummy)
 	debug(">>board_init_f()\n");
 	relocate_code(CONFIG_SPL_STACK, &gdata, CONFIG_SPL_TEXT_BASE);
 }
+#endif
+
+/*
+ * Weak default function for board specific cleanup/preparation before
+ * Linux boot. Some boards/platforms might now need it, so just provide
+ * an empty stub here.
+ */
+__weak void spl_board_prepare_for_linux(void)
+{
+	/* Nothing to do! */
+}
 
 /*
  * Default function to determine if u-boot or the OS should
@@ -89,7 +106,11 @@ void spl_parse_image_header(const struct image_header *header)
 		spl_image.size = __be32_to_cpu(header->ih_size) + header_size;
 		spl_image.entry_point = __be32_to_cpu(header->ih_load);
 		/* Load including the header */
+#ifdef CONFIG_ARM
 		spl_image.load_addr = spl_image.entry_point - header_size;
+#else
+		spl_image.load_addr = __be32_to_cpu(header->ih_load);
+#endif
 		spl_image.os = header->ih_os;
 		spl_image.name = (const char *)&header->ih_name;
 		debug("spl: payload image: %s load addr: 0x%x size: %d\n",
@@ -101,7 +122,7 @@ void spl_parse_image_header(const struct image_header *header)
 			header->ih_magic);
 		/* Let's assume U-Boot will not be more than 200 KB */
 		spl_image.size = 200 * 1024;
-		spl_image.entry_point = CONFIG_SYS_TEXT_BASE;
+		spl_image.entry_point = CONFIG_SYS_UBOOT_START;
 		spl_image.load_addr = CONFIG_SYS_TEXT_BASE;
 		spl_image.os = IH_OS_U_BOOT;
 		spl_image.name = "U-Boot";
@@ -114,6 +135,7 @@ void spl_parse_image_header(const struct image_header *header)
  * arg: Pointer to paramter image in RAM
  */
 #ifdef CONFIG_SPL_OS_BOOT
+#ifdef CONFIG_ARM
 static void __noreturn jump_to_image_linux(void *arg)
 {
 	debug("Entering kernel arg pointer: 0x%p\n", arg);
@@ -124,7 +146,22 @@ static void __noreturn jump_to_image_linux(void *arg)
 	cleanup_before_linux();
 	image_entry(0, CONFIG_MACH_TYPE, arg);
 }
-#endif
+#endif /* CONFIG_ARM */
+
+#ifdef CONFIG_PPC
+static void __noreturn jump_to_image_linux(void *arg)
+{
+	debug("Entering kernel arg pointer: 0x%p\n", arg);
+	typedef void (*image_entry_arg_t)(void *, ulong r4, ulong r5, ulong r6,
+					  ulong r7, ulong r8, ulong r9)
+		__attribute__ ((noreturn));
+	image_entry_arg_t image_entry =
+		(image_entry_arg_t)spl_image.entry_point;
+
+	image_entry(arg, 0, 0, EPAPR_MAGIC, CONFIG_SYS_BOOTMAPSZ, 0, 0);
+}
+#endif /* CONFIG_PPC */
+#endif /* CONFIG_SPL_OS_BOOT */
 
 static void __noreturn jump_to_image_no_args(void)
 {
@@ -213,7 +250,9 @@ void board_init_r(gd_t *id, ulong dummy)
 /* This requires UART clocks to be enabled */
 void preloader_console_init(void)
 {
+#ifdef CONFIG_ARM
 	gd = &gdata;
+#endif
 	gd->bd = &bdata;
 	gd->flags |= GD_FLG_RELOC;
 	gd->baudrate = CONFIG_BAUDRATE;
Signature · 1 line
1.7.12
#6 lore raw

PATCH 3/6 SPL: Port SPL framework to powerpc

Quoted 2 lines · Stefan Roese

This patch enables the SPL framework to be used on powerpc platforms and not only ARM.

[snip]

common/spl/spl.c line 48

Quoted 4 lines
common/spl/spl.c +2 -0
+#ifdef CONFIG_ARM
 /* Define global data structure pointer to it*/
 gd_t gdata __attribute__ ((section(".data")));
+#endif

So you handle cleaning up the BSS differently, interesting. I'm going to see if that would work for ARM too..

[snip]

common/spl/spl.c void spl_parse_image_header(const struct image_header *header) · line 113

Quoted 9 lines
common/spl/spl.c +4 -0
@@ -89,7 +106,11 @@ void spl_parse_image_header(const struct image_header *header)
 		spl_image.size = __be32_to_cpu(header->ih_size) + header_size;
 		spl_image.entry_point = __be32_to_cpu(header->ih_load);
 		/* Load including the header */
+#ifdef CONFIG_ARM
 		spl_image.load_addr = spl_image.entry_point - header_size;
+#else
+		spl_image.load_addr = __be32_to_cpu(header->ih_load);
+#endif

This isn't an ARM-ism but is instead because spl_nor.c isn't offsetting where the header is like mmc/nand/ymodem do, yes? Would it be possible to make spl_nor.c behave like the others? One of the reasons I ask is I'm looking at a NOR chip on my desk...

Signature · 1 line
Tom
#7 lore raw

PATCH 3/6 SPL: Port SPL framework to powerpc

Quoted 7 lines · Tom Rini

common/spl/spl.c line 48

Quoted 4 lines
common/spl/spl.c +2 -0
+#ifdef CONFIG_ARM
 /* Define global data structure pointer to it*/
 gd_t gdata __attribute__ ((section(".data")));
+#endif

So you handle cleaning up the BSS differently, interesting. I'm going to see if that would work for ARM too..

Yes. Might be that I missed something though. I'll re-check tomorrow.

Quoted 15 lines

[snip]

common/spl/spl.c void spl_parse_image_header(const struct image_header *header) · line 113

Quoted 9 lines
common/spl/spl.c +4 -0
@@ -89,7 +106,11 @@ void spl_parse_image_header(const struct image_header *header)
 		spl_image.size = __be32_to_cpu(header->ih_size) + header_size;
 		spl_image.entry_point = __be32_to_cpu(header->ih_load);
 		/* Load including the header */
+#ifdef CONFIG_ARM
 		spl_image.load_addr = spl_image.entry_point - header_size;
+#else
+		spl_image.load_addr = __be32_to_cpu(header->ih_load);
+#endif

This isn't an ARM-ism but is instead because spl_nor.c isn't offsetting where the header is like mmc/nand/ymodem do, yes? Would it be possible to make spl_nor.c behave like the others? One of the reasons I ask is I'm looking at a NOR chip on my desk...

I was wondering about this line as well. Please explain: Why can't ARM just use header->ih_load as load_addr?

Thanks,
Stefan

#8 lore raw

PATCH 3/6 SPL: Port SPL framework to powerpc

Quoted 27 lines · Stefan Roese
Quoted 7 lines · Tom Rini

common/spl/spl.c line 48

Quoted 4 lines
common/spl/spl.c +2 -0
+#ifdef CONFIG_ARM
 /* Define global data structure pointer to it*/
 gd_t gdata __attribute__ ((section(".data")));
+#endif

So you handle cleaning up the BSS differently, interesting. I'm going to see if that would work for ARM too..

Yes. Might be that I missed something though. I'll re-check tomorrow.

Quoted 15 lines

[snip]

common/spl/spl.c void spl_parse_image_header(const struct image_header *header) · line 113

Quoted 9 lines
common/spl/spl.c +4 -0
@@ -89,7 +106,11 @@ void spl_parse_image_header(const struct image_header *header)
 		spl_image.size = __be32_to_cpu(header->ih_size) + header_size;
 		spl_image.entry_point = __be32_to_cpu(header->ih_load);
 		/* Load including the header */
+#ifdef CONFIG_ARM
 		spl_image.load_addr = spl_image.entry_point - header_size;
+#else
+		spl_image.load_addr = __be32_to_cpu(header->ih_load);
+#endif

This isn't an ARM-ism but is instead because spl_nor.c isn't offsetting where the header is like mmc/nand/ymodem do, yes? Would it be possible to make spl_nor.c behave like the others? One of the reasons I ask is I'm looking at a NOR chip on my desk...

Quoted 2 lines

I was wondering about this line as well. Please explain: Why can't ARM just use header->ih_load as load_addr?

Off the top of my head, I believe what goes on is that we read things into SDRAM such that the header is taken into account and we don't need to relocate the payload (U-Boot or Linux).

Signature · 1 line
Tom
#9 lore raw

PATCH 3/6 SPL: Port SPL framework to powerpc

Hi Tom,

Quoted 15 lines · Tom Rini
Quoted 15 lines
Quoted 14 lines

common/spl/spl.c void spl_parse_image_header(const struct image_header *header) · line 113

Quoted 9 lines
common/spl/spl.c +4 -0
@@ -89,7 +106,11 @@ void spl_parse_image_header(const struct image_header *header)
 		spl_image.size = __be32_to_cpu(header->ih_size) + header_size;
 		spl_image.entry_point = __be32_to_cpu(header->ih_load);
 		/* Load including the header */
+#ifdef CONFIG_ARM
 		spl_image.load_addr = spl_image.entry_point - header_size;
+#else
+		spl_image.load_addr = __be32_to_cpu(header->ih_load);
+#endif

This isn't an ARM-ism but is instead because spl_nor.c isn't offsetting where the header is like mmc/nand/ymodem do, yes? Would it be possible to make spl_nor.c behave like the others? One of the reasons I ask is I'm looking at a NOR chip on my desk...

Quoted 6 lines
Quoted 2 lines

I was wondering about this line as well. Please explain: Why can't ARM just use header->ih_load as load_addr?

Off the top of my head, I believe what goes on is that we read things into SDRAM such that the header is taken into account and we don't need to relocate the payload (U-Boot or Linux).

Hmmm. So for example, when ih_load is set to 0x100000, then you load the image to (0x100000 - 0x40) = 0xfffc0? Is this correct?

This can't work for powerpc. As here for Linux both load-address and entry-point are set to 0. So when loading the image (e.g. from NOR flash) can't copy the image header in front of the image.

Another thing I'm wondering about: Why is only ih_load from the mkimage header used and not ih_ep (entry-point)?

I suggest that we switch to copying the "real" image (payload) to the load address, skipping the header. Then "ih_load" and "ih_ep" can be used without modification.

BTW: There also seems to be a bug in some of the SPL loaders:

For example in drivers/mtd/nand/nand_spl_load.c:

		...
		if (header->ih_os == IH_OS_LINUX) {
			/* happy - was a linux */
			nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
				spl_image.size, (void *)spl_image.load_addr);

The problem here is that the last 64 bytes of the image are not copied to SDRAM. Since the header is copied which is not included in the spl_image.size variable. With my idea of only copying the payload (skipping the header) this would be:

			nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS +
				sizeof(struct image_header),
				spl_image.size, (void *)spl_image.load_addr);

What do you think? Should we switch to this way of loading images? Seems more logical to me. And we don't run into problems where the load address is 0.

Thanks,
Stefan

#10 lore raw

PATCH 3/6 SPL: Port SPL framework to powerpc

Hello Stefan

Quoted 32 lines · Stefan Roese

Hi Tom,

Quoted 15 lines · Tom Rini
Quoted 15 lines
Quoted 14 lines

common/spl/spl.c void spl_parse_image_header(const struct image_header *header) · line 113

Quoted 9 lines
common/spl/spl.c +4 -0
@@ -89,7 +106,11 @@ void spl_parse_image_header(const struct image_header *header)
  		spl_image.size = __be32_to_cpu(header->ih_size) + header_size;
  		spl_image.entry_point = __be32_to_cpu(header->ih_load);
  		/* Load including the header */
+#ifdef CONFIG_ARM
  		spl_image.load_addr = spl_image.entry_point - header_size;
+#else
+		spl_image.load_addr = __be32_to_cpu(header->ih_load);
+#endif

This isn't an ARM-ism but is instead because spl_nor.c isn't offsetting where the header is like mmc/nand/ymodem do, yes? Would it be possible to make spl_nor.c behave like the others? One of the reasons I ask is I'm looking at a NOR chip on my desk...

Quoted 6 lines
Quoted 2 lines

I was wondering about this line as well. Please explain: Why can't ARM just use header->ih_load as load_addr?

Off the top of my head, I believe what goes on is that we read things into SDRAM such that the header is taken into account and we don't need to relocate the payload (U-Boot or Linux).

Hmmm. So for example, when ih_load is set to 0x100000, then you load the image to (0x100000 - 0x40) = 0xfffc0? Is this correct?

This can't work for powerpc. As here for Linux both load-address and entry-point are set to 0. So when loading the image (e.g. from NOR flash) can't copy the image header in front of the image.

Quoted 6 lines

Another thing I'm wondering about: Why is only ih_load from the mkimage header used and not ih_ep (entry-point)?

I suggest that we switch to copying the "real" image (payload) to the load address, skipping the header. Then "ih_load" and "ih_ep" can be used without modification.

Yep, this seems a good idea to me.

Quoted 15 lines

BTW: There also seems to be a bug in some of the SPL loaders:

For example in drivers/mtd/nand/nand_spl_load.c:

		...
		if (header->ih_os == IH_OS_LINUX) {
			/* happy - was a linux */
			nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
				spl_image.size, (void *)spl_image.load_addr);

The problem here is that the last 64 bytes of the image are not copied to SDRAM. Since the header is copied which is not included in the spl_image.size variable. With my idea of only copying the payload (skipping the header) this would be:

Quoted 7 lines
			nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS +
				sizeof(struct image_header),
				spl_image.size, (void *)spl_image.load_addr);

What do you think? Should we switch to this way of loading images? Seems more logical to me. And we don't run into problems where the load address is 0.

Yes, that should be the way to go ... @Simon: Do you see here some reason for not switching to copy the real payload?

bye,
Heiko

Signature · 2 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#11 lore raw

PATCH 3/6 SPL: Port SPL framework to powerpc

Hi Heiko,

Quoted 10 lines · Heiko Schocher
Quoted 10 lines

BTW: There also seems to be a bug in some of the SPL loaders:

For example in drivers/mtd/nand/nand_spl_load.c:

		...
		if (header->ih_os == IH_OS_LINUX) {
			/* happy - was a linux */
			nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
				spl_image.size, (void *)spl_image.load_addr);
Quoted 3 lines
Quoted 3 lines

The problem here is that the last 64 bytes of the image are not copied to SDRAM. Since the header is copied which is not included in the spl_image.size variable.

Okay. I just noticed that it's not a bug. spl_image.size is set to header->ih_size + header_size. So 64 is added and the complete payload is copied.

I still would like to move to my suggestion to not copy the header and use the mkimage header values ih_load and ih_ep directly. Right now I don't see any showstopper for doing it this way. I'll send a patch to change this shortly (if everything works out).

Stay tuned...

Thanks,
Stefan

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office at denx.de

#12 lore raw

PATCH 3/6 SPL: Port SPL framework to powerpc

Quoted 4 lines · Stefan Roese

I still would like to move to my suggestion to not copy the header and use the mkimage header values ih_load and ih_ep directly. Right now I don't see any showstopper for doing it this way. I'll send a patch to change this shortly (if everything works out).

Hmmm. As it seems some SPL loading drivers (block like mmc, streaming like ymodem) are not that easily converted to skipping the header. So I'm not so sure if we should go this way after all...

Comments?

Thanks,
Stefan

#13 lore raw

PATCH 3/6 SPL: Port SPL framework to powerpc

Hi Stefan,

2012/8/24 Stefan Roese <[email protected]>:

Quoted 6 lines · Stefan Roese
Quoted 4 lines

I still would like to move to my suggestion to not copy the header and use the mkimage header values ih_load and ih_ep directly. Right now I don't see any showstopper for doing it this way. I'll send a patch to change this shortly (if everything works out).

Quoted 6 lines

Hmmm. As it seems some SPL loading drivers (block like mmc, streaming like ymodem) are not that easily converted to skipping the header. So I'm not so sure if we should go this way after all...

Comments?

I did similar work for my upcoming Lantiq MIPS SoC port. In my approach I also support compressed u-boot
images as payload (LZO, LZMA). The u-boot image is merged with SPL image without any padding or
fixed flash offsets to achieve a maximum reduction of flash footprint.

I ended up with doing something like this:

static int spl_parse_image(const image_header_t *hdr, struct spl_image *spl)

{
       u32 magic;

       magic = image_get_magic(hdr);
       if (magic != IH_MAGIC)
               return -1;

       spl->data_addr += image_get_header_size();
       spl->entry_addr = image_get_load(hdr);
       spl->size = image_get_data_size(hdr);
       spl->comp = image_get_comp(hdr);

       if (spl->comp == IH_COMP_NONE)
               spl->load_addr = spl->entry_addr;
       else
               spl->load_addr = CONFIG_LOADADDR;

       return 0;
}

spl->data_addr points to the image header of the payload and is initialized by the caller
dependent on the used load mechanism. If the payload is uncompressed it can be directly copied to
its final RAM location. A compressed payload needs an intermediate copy step if it is stored in SPI or NAND flash.
I chose CONFIG_LOADADDR. After this the decompression function extracts the image to its final RAM location.

I think we should keep an architecture-neutral SPL image context inside the generic SPL framework.
The content of this context should be filled by architecture/SoC/board specific code.

Signature · 2 lines
Best regards,
Daniel
#14 lore raw

PATCH 3/6 SPL: Port SPL framework to powerpc

Hi Daniel,

Quoted 9 lines · Daniel Schwierzeck
Quoted 9 lines
Quoted 4 lines

I still would like to move to my suggestion to not copy the header and use the mkimage header values ih_load and ih_ep directly. Right now I don't see any showstopper for doing it this way. I'll send a patch to change this shortly (if everything works out).

Hmmm. As it seems some SPL loading drivers (block like mmc, streaming like ymodem) are not that easily converted to skipping the header. So I'm not so sure if we should go this way after all...

Quoted 5 lines
Quoted 1 line

Comments?

I did similar work for my upcoming Lantiq MIPS SoC port. In my approach I also support compressed u-boot
images as payload (LZO, LZMA).

Yes, I thought about adding this as well. Nice.

Quoted 3 lines

The u-boot image is merged with SPL
image without any padding or
fixed flash offsets to achieve a maximum reduction of flash footprint.

Interesting. I'm still padding to the fixed offset. Let me look into squeezing those two images together as well...

Quoted 15 lines

I ended up with doing something like this:

static int spl_parse_image(const image_header_t *hdr, struct spl_image *spl)

{
       u32 magic;

       magic = image_get_magic(hdr);
       if (magic != IH_MAGIC)
               return -1;

       spl->data_addr += image_get_header_size();
       spl->entry_addr = image_get_load(hdr);
       spl->size = image_get_data_size(hdr);
       spl->comp = image_get_comp(hdr);
Quoted 7 lines
       if (spl->comp == IH_COMP_NONE)
               spl->load_addr = spl->entry_addr;
       else
               spl->load_addr = CONFIG_LOADADDR;

       return 0;
}

So you introduced a new "struct spl_image" and did not use "struct spl_image_info" from the SPL framework? Why is that? We should definitely consolidate to one structure here.

Quoted 3 lines

spl->data_addr points to the image header of the payload and is initialized by the caller
dependent on the used load mechanism.

Good idea. Looks like your spl_parse_image might be a potential replacement for spl_parse_image_header() from this common SPL framework.

Quoted 6 lines

If the payload is uncompressed
it can be directly copied to
its final RAM location. A compressed payload needs an intermediate copy step if it is stored in SPI or NAND flash.
I chose CONFIG_LOADADDR. After this the decompression function extracts the image to its final RAM location.

Sounds good. Do you have some patches that you could send for review? Did you try to keep as much platform/arch independent as possible?

Quoted 4 lines

I think we should keep an architecture-neutral SPL image context inside the generic SPL framework.
The content of this context should be filled by architecture/SoC/board specific code.

Ack. It would be great to review your code here. Please keep us informed.

Thanks,
Stefan

#15 lore raw

PATCH 3/6 SPL: Port SPL framework to powerpc

Hi Stefan,

2012/8/24 Stefan Roese <[email protected]>:

Quoted 47 lines

Hi Daniel,

Quoted 9 lines · Daniel Schwierzeck
Quoted 9 lines
Quoted 4 lines

I still would like to move to my suggestion to not copy the header and use the mkimage header values ih_load and ih_ep directly. Right now I don't see any showstopper for doing it this way. I'll send a patch to change this shortly (if everything works out).

Hmmm. As it seems some SPL loading drivers (block like mmc, streaming like ymodem) are not that easily converted to skipping the header. So I'm not so sure if we should go this way after all...

Quoted 5 lines
Quoted 1 line

Comments?

I did similar work for my upcoming Lantiq MIPS SoC port. In my approach I also support compressed u-boot
images as payload (LZO, LZMA).

Yes, I thought about adding this as well. Nice.

Quoted 3 lines

The u-boot image is merged with SPL
image without any padding or
fixed flash offsets to achieve a maximum reduction of flash footprint.

Interesting. I'm still padding to the fixed offset. Let me look into squeezing those two images together as well...

Quoted 20 lines

I ended up with doing something like this:

static int spl_parse_image(const image_header_t *hdr, struct spl_image *spl)

{
       u32 magic;

       magic = image_get_magic(hdr);
       if (magic != IH_MAGIC)
               return -1;

       spl->data_addr += image_get_header_size();
       spl->entry_addr = image_get_load(hdr);
       spl->size = image_get_data_size(hdr);
       spl->comp = image_get_comp(hdr);

       if (spl->comp == IH_COMP_NONE)
               spl->load_addr = spl->entry_addr;
       else
               spl->load_addr = CONFIG_LOADADDR;
Quoted 6 lines
Quoted 2 lines
       return 0;
}

So you introduced a new "struct spl_image" and did not use "struct spl_image_info" from the SPL framework? Why is that? We should definitely consolidate to one structure here.

I implemented this after the initial SPL infrastructure got merged into mainline one year ago.
At this time a generic SPL framework did not exist ;)

Quoted 15 lines
Quoted 4 lines

spl->data_addr points to the image header of the payload and is initialized by the caller
dependent on the used load mechanism.

Good idea. Looks like your spl_parse_image might be a potential replacement for spl_parse_image_header() from this common SPL framework.

Quoted 6 lines

If the payload is uncompressed
it can be directly copied to
its final RAM location. A compressed payload needs an intermediate copy step if it is stored in SPI or NAND flash.
I chose CONFIG_LOADADDR. After this the decompression function extracts the image to its final RAM location.

Quoted 2 lines

Sounds good. Do you have some patches that you could send for review? Did you try to keep as much platform/arch independent as possible?

Not yet. I had not time yet to adopt my work to the new common SPL framework.

My current SPL solution is queued here:
http://dev.phrozen.org/gitweb/?p=uboot-upstream.git;a=commitdiff;h=39165fa145b2d959f1eaa6faa3ab3053823bb985

Quoted 8 lines
Quoted 5 lines

I think we should keep an architecture-neutral SPL image context inside the generic SPL framework.
The content of this context should be filled by architecture/SoC/board specific code.

Ack. It would be great to review your code here. Please keep us informed.

Actually this was my response to your original question. Quote:

Quoted 4 lines

I still would like to move to my suggestion to not copy the header and use the mkimage header values ih_load and ih_ep directly. Right now I don't see any showstopper for doing it this way. I'll send a patch to change this shortly (if everything works out).

So I suggest to not remove the 'struct spl_image_info'.

Signature · 2 lines
Best regards,
Daniel
#16 lore raw

PATCH 3/6 SPL: Port SPL framework to powerpc

In reply to Stefan Roese

Hi Daniel,

Quoted 6 lines · Stefan Roese
Quoted 3 lines

The u-boot image is merged with SPL
image without any padding or
fixed flash offsets to achieve a maximum reduction of flash footprint.

Interesting. I'm still padding to the fixed offset. Let me look into squeezing those two images together as well...

Looks good. One question though: How do you make sure, that your SPL image length is 4-byte aligned?

Thanks,
Stefan

#17 lore raw

PATCH 3/6 SPL: Port SPL framework to powerpc

Hi Stefan,

2012/8/24 Stefan Roese <[email protected]>:

Quoted 7 lines

Hi Daniel,

Quoted 4 lines · Stefan Roese
Quoted 3 lines

The u-boot image is merged with SPL
image without any padding or
fixed flash offsets to achieve a maximum reduction of flash footprint.

Quoted 5 lines
Quoted 2 lines

Interesting. I'm still padding to the fixed offset. Let me look into squeezing those two images together as well...

Looks good. One question though: How do you make sure, that your SPL image length is 4-byte aligned?

I have 4-byte alignments for each section and for each address symbol in my linker script.
Actually all MIPS linker scripts do this.

Signature · 2 lines
Best regards,
Daniel
#18 lore raw

PATCH 3/6 SPL: Port SPL framework to powerpc

Quoted 7 lines · Daniel Schwierzeck
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines

The u-boot image is merged with SPL
image without any padding or
fixed flash offsets to achieve a maximum reduction of flash footprint.

Interesting. I'm still padding to the fixed offset. Let me look into squeezing those two images together as well...

Quoted 6 lines
Quoted 2 lines

Looks good. One question though: How do you make sure, that your SPL image length is 4-byte aligned?

I have 4-byte alignments for each section and for each address symbol in my linker script.
Actually all MIPS linker scripts do this.

Yes. I have those section alignments in the linker script as well. The problem is the end of the last (physical end in flash) section. If I have here a string with length 7 for example, the SPL binary has a non-4-byte aligned length.

Any ideas on this?

Thanks,
Stefan

#19 lore raw

PATCH 3/6 SPL: Port SPL framework to powerpc

2012/8/24 Stefan Roese <[email protected]>:

Quoted 15 lines · Daniel Schwierzeck
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines

The u-boot image is merged with SPL
image without any padding or
fixed flash offsets to achieve a maximum reduction of flash footprint.

Interesting. I'm still padding to the fixed offset. Let me look into squeezing those two images together as well...

Quoted 6 lines
Quoted 2 lines

Looks good. One question though: How do you make sure, that your SPL image length is 4-byte aligned?

I have 4-byte alignments for each section and for each address symbol in my linker script.
Actually all MIPS linker scripts do this.

Quoted 6 lines

Yes. I have those section alignments in the linker script as well. The problem is the end of the last (physical end in flash) section. If I have here a string with length 7 for example, the SPL binary has a non-4-byte aligned length.

Any ideas on this?

MIPS linker scripts have a symbol in front of the BSS section that is named uboot_end_data.
I think most ARM linker scripts have it too but it is named __image_copy_end. This symbol is 4-byte-aligned. If I want to know the length of SPL image i can simply do

ulong len = (ulong) &__image_copy_end - CONFIG_SPL_TEXT_BASE

and len is 4-byte-aligned

Signature · 2 lines
Best regards,
Daniel
#20 lore raw

PATCH 3/6 SPL: Port SPL framework to powerpc

In reply to Stefan Roese
Quoted 9 lines · Stefan Roese
Quoted 4 lines · Stefan Roese

I still would like to move to my suggestion to not copy the header and use the mkimage header values ih_load and ih_ep directly. Right now I don't see any showstopper for doing it this way. I'll send a patch to change this shortly (if everything works out).

Hmmm. As it seems some SPL loading drivers (block like mmc, streaming like ymodem) are not that easily converted to skipping the header. So I'm not so sure if we should go this way after all...

Maybe I'm missing something, but maybe we just need to mimic the behavior full U-Boot does and if we haven't been loaded where we need to execute, shift bits around?

Signature · 1 line
Tom
#21 lore raw

PATCH 3/6 SPL: Port SPL framework to powerpc

Quoted 5 lines · Tom Rini
Quoted 5 lines
Quoted 4 lines

I still would like to move to my suggestion to not copy the header and use the mkimage header values ih_load and ih_ep directly. Right now I don't see any showstopper for doing it this way. I'll send a patch to change this shortly (if everything works out).

Quoted 7 lines
Quoted 3 lines

Hmmm. As it seems some SPL loading drivers (block like mmc, streaming like ymodem) are not that easily converted to skipping the header. So I'm not so sure if we should go this way after all...

Maybe I'm missing something, but maybe we just need to mimic the behavior full U-Boot does and if we haven't been loaded where we need to execute, shift bits around?

Of course its possible. The main problem is speed here. With the "problematic" drivers like mmc, you would need to copy the image a 2nd time, once from MMC to a temp. SDRAM location, and then to its final (load_addr) destination. With the current approach, the image is only copied once from MMC to SDRAM. The 2nd copy shouldn't take that long though. Its SDRAM to SDRAM after all.

I really do like Daniel's approach, with the decompression support:

http://dev.phrozen.org/gitweb/?p=uboot-upstream.git;a=commitdiff;h=39165fa145b2d959f1eaa6faa3ab3053823bb985

We should try to merge this into the current SPL framework. I'll try to look into this next week.

Thanks,
Stefan

#22 lore raw

PATCH 3/6 SPL: Port SPL framework to powerpc

In reply to Stefan Roese
Quoted 2 lines · Stefan Roese

This patch enables the SPL framework to be used on powerpc platforms and not only ARM.

[snip]

common/spl/spl.c void board_init_r(gd_t *id, ulong dummy) · line 255

Quoted 3 lines
common/spl/spl.c +2 -0
+#ifdef CONFIG_ARM
 	gd = &gdata;
+#endif

So, here's what I don't understand. On ARM, in general, we can't rely on the global data pointer register (r8) to be set to a useful value, so we do the above to ensure it points to something useful. Are you always able to rely on r2 it looks like pointing to something useful? Or do you take care of this much earlier on in powerpc? Thanks!

Signature · 1 line
Tom
#23 lore raw

PATCH 3/6 SPL: Port SPL framework to powerpc

Hi Tom,

Quoted 5 lines · Tom Rini
Quoted 2 lines · Stefan Roese

This patch enables the SPL framework to be used on powerpc platforms and not only ARM.

[snip]

Quoted 9 lines

common/spl/spl.c void board_init_r(gd_t *id, ulong dummy) · line 255

Quoted 3 lines
common/spl/spl.c +2 -0
+#ifdef CONFIG_ARM
 	gd = &gdata;
+#endif

So, here's what I don't understand. On ARM, in general, we can't rely on the global data pointer register (r8) to be set to a useful value, so we do the above to ensure it points to something useful. Are you always able to rely on r2 it looks like pointing to something useful? Or do you take care of this much earlier on in powerpc? Thanks!

You are correct, I missed something here. r2 was still configured to the value written to it from the "real" U-Boot (pointing to internal SRAM).

I can't use the code in preloader_console_init() though to setup the gd pointer. As I need to write some values in gd *before* calling preloader_console_init() (mainly clocks for serial driver). And since this "gd stuff" is quite platform specific, we should probably move this into an platform/arch spl file instead. As you also mentioned in another reply to create an arch/${ARCH}/lib/spl.c file.

What do you think? Can you move this gd init stuff into such a common ARM spl file in the next patchset version?

Thanks,
Stefan

#24 lore raw

PATCH 3/6 SPL: Port SPL framework to powerpc

Quoted 28 lines · Stefan Roese

Hi Tom,

Quoted 5 lines · Tom Rini
Quoted 2 lines · Stefan Roese

This patch enables the SPL framework to be used on powerpc platforms and not only ARM.

[snip]

Quoted 9 lines

common/spl/spl.c void board_init_r(gd_t *id, ulong dummy) · line 255

Quoted 3 lines
common/spl/spl.c +2 -0
+#ifdef CONFIG_ARM
 	gd = &gdata;
+#endif

So, here's what I don't understand. On ARM, in general, we can't rely on the global data pointer register (r8) to be set to a useful value, so we do the above to ensure it points to something useful. Are you always able to rely on r2 it looks like pointing to something useful? Or do you take care of this much earlier on in powerpc? Thanks!

You are correct, I missed something here. r2 was still configured to the value written to it from the "real" U-Boot (pointing to internal SRAM).

I can't use the code in preloader_console_init() though to setup the gd pointer. As I need to write some values in gd *before* calling preloader_console_init() (mainly clocks for serial driver). And since this "gd stuff" is quite platform specific, we should probably move this into an platform/arch spl file instead. As you also mentioned in another reply to create an arch/${ARCH}/lib/spl.c file.

Quoted 2 lines

What do you think? Can you move this gd init stuff into such a common ARM spl file in the next patchset version?

Yes. We should probably say it's the job of board_init_f. I know full U-Boot does it at the start of board_init_r but I think for SPL it makes sense to document that board_init_f does any early init it needs to, clears BSS, sets up gd and calls board_init_r.

Signature · 1 line
Tom
#25 lore raw

PATCH 3/6 SPL: Port SPL framework to powerpc

Quoted 16 lines · Tom Rini
Quoted 16 lines
Quoted 5 lines

So, here's what I don't understand. On ARM, in general, we can't rely on the global data pointer register (r8) to be set to a useful value, so we do the above to ensure it points to something useful. Are you always able to rely on r2 it looks like pointing to something useful? Or do you take care of this much earlier on in powerpc? Thanks!

You are correct, I missed something here. r2 was still configured to the value written to it from the "real" U-Boot (pointing to internal SRAM).

I can't use the code in preloader_console_init() though to setup the gd pointer. As I need to write some values in gd *before* calling preloader_console_init() (mainly clocks for serial driver). And since this "gd stuff" is quite platform specific, we should probably move this into an platform/arch spl file instead. As you also mentioned in another reply to create an arch/${ARCH}/lib/spl.c file.

Quoted 7 lines
Quoted 2 lines

What do you think? Can you move this gd init stuff into such a common ARM spl file in the next patchset version?

Yes. We should probably say it's the job of board_init_f. I know full U-Boot does it at the start of board_init_r but I think for SPL it makes sense to document that board_init_f does any early init it needs to, clears BSS, sets up gd and calls board_init_r.

Full ack. In my next patchset version, I already extracted this gd setup into board_init_f().

Thanks,
Stefan

#26 lore raw

PATCH 3/6 SPL: Port SPL framework to powerpc

Quoted 20 lines · Stefan Roese
Quoted 19 lines · Tom Rini
Quoted 18 lines
Quoted 5 lines

So, here's what I don't understand. On ARM, in general, we can't rely on the global data pointer register (r8) to be set to a useful value, so we do the above to ensure it points to something useful. Are you always able to rely on r2 it looks like pointing to something useful? Or do you take care of this much earlier on in powerpc? Thanks!

You are correct, I missed something here. r2 was still configured to the value written to it from the "real" U-Boot (pointing to internal SRAM).

I can't use the code in preloader_console_init() though to setup the gd pointer. As I need to write some values in gd *before* calling preloader_console_init() (mainly clocks for serial driver). And since this "gd stuff" is quite platform specific, we should probably move this into an platform/arch spl file instead. As you also mentioned in another reply to create an arch/${ARCH}/lib/spl.c file.

What do you think? Can you move this gd init stuff into such a common ARM spl file in the next patchset version?

Quoted 7 lines
Quoted 4 lines

Yes. We should probably say it's the job of board_init_f. I know full U-Boot does it at the start of board_init_r but I think for SPL it makes sense to document that board_init_f does any early init it needs to, clears BSS, sets up gd and calls board_init_r.

Full ack. In my next patchset version, I already extracted this gd setup into board_init_f().

OK good, I just booted and reset my arm9 platform with this proof-of-concepted over. I should post v4 today.

Signature · 1 line
Tom
#27 lore raw

PATCH 3/6 SPL: Port SPL framework to powerpc

Quoted 8 lines · Tom Rini
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines

What do you think? Can you move this gd init stuff into such a common ARM spl file in the next patchset version?

Yes. We should probably say it's the job of board_init_f. I know full U-Boot does it at the start of board_init_r but I think for SPL it makes sense to document that board_init_f does any early init it needs to, clears BSS, sets up gd and calls board_init_r.

Quoted 5 lines
Quoted 2 lines

Full ack. In my next patchset version, I already extracted this gd setup into board_init_f().

OK good, I just booted and reset my arm9 platform with this proof-of-concepted over. I should post v4 today.

Great. I'll rebase my patches on top of that next week then.

Thanks,
Stefan

#28 lore raw

PATCH 3/6 SPL: Port SPL framework to powerpc

In reply to Stefan Roese
Quoted 2 lines · Stefan Roese

This patch enables the SPL framework to be used on powerpc platforms and not only ARM.

[snip]

Quoted 4 lines
common/spl/spl.c +4 -0
+#ifdef CONFIG_PPC
+static void __noreturn jump_to_image_linux(void *arg)
+{
+	debug("Entering kernel arg pointer: 0x%p\n", arg);

common/spl/spl.c static void __noreturn jump_to_image_linux(void *arg) · line 164

Quoted 10 lines
common/spl/spl.c +10 -0
+	typedef void (*image_entry_arg_t)(void *, ulong r4, ulong r5, ulong r6,
+					  ulong r7, ulong r8, ulong r9)
+		__attribute__ ((noreturn));
+	image_entry_arg_t image_entry =
+		(image_entry_arg_t)spl_image.entry_point;
+
+	image_entry(arg, 0, 0, EPAPR_MAGIC, CONFIG_SYS_BOOTMAPSZ, 0, 0);
+}
+#endif /* CONFIG_PPC */
+#endif /* CONFIG_SPL_OS_BOOT */

This, along with board_init_f make me wonder if we shouldn't have an arch/${ARCH}/lib/spl.c that contains them and make them non-static. Perhaps sharing with the non-SPL code portion as well?

Signature · 1 line
Tom
#29 lore raw

PATCH 3/6 SPL: Port SPL framework to powerpc

Hi Tom,

Quoted 15 lines · Tom Rini
Quoted 2 lines · Stefan Roese

This patch enables the SPL framework to be used on powerpc platforms and not only ARM.

[snip]

Quoted 10 lines
common/spl/spl.c +10 -0
+#ifdef CONFIG_PPC
+static void __noreturn jump_to_image_linux(void *arg)
+{
+	debug("Entering kernel arg pointer: 0x%p\n", arg);
+	typedef void (*image_entry_arg_t)(void *, ulong r4, ulong r5, ulong r6,
+					  ulong r7, ulong r8, ulong r9)
+		__attribute__ ((noreturn));
+	image_entry_arg_t image_entry =
+		(image_entry_arg_t)spl_image.entry_point;
+
Quoted 8 lines

common/spl/spl.c static void __noreturn jump_to_image_linux(void *arg) · line 164

Quoted 4 lines
common/spl/spl.c +4 -0
+	image_entry(arg, 0, 0, EPAPR_MAGIC, CONFIG_SYS_BOOTMAPSZ, 0, 0);
+}
+#endif /* CONFIG_PPC */
+#endif /* CONFIG_SPL_OS_BOOT */

This, along with board_init_f make me wonder if we shouldn't have an arch/${ARCH}/lib/spl.c that contains them and make them non-static. Perhaps sharing with the non-SPL code portion as well?

Yes. Makes definitely sense. Please see my comments in the other mail.

Thanks,
Stefan

#30 lore raw

PATCH 4/6 env: Extract getenv_f() into separate source file

In reply to Stefan Roese

By extracting getenv_f and envmatch() from cmd_nvedit.c into a separate file, getenv_f() can be included easily into the SPL binary. With this, SPL boards can now use getenv_f() to read environment variables (e.g. to detect if the OS or U-Boot shall be executed).

In the approach this is done for env stored in NOR flash, as this will be used by an upcoming MPC5200 board port.

---
 common/Makefile       |  4 +++
 common/cmd_nvedit.c   | 58 ------------------------------------
 common/env_getenv_f.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 86 insertions(+), 58 deletions(-)
 create mode 100644 common/env_getenv_f.c
common/Makefile +4 -0
index 3d62775..2cd539a 100644
@@ -50,6 +50,7 @@ XCOBJS-$(CONFIG_ENV_IS_EMBEDDED) += env_embedded.o
 COBJS-$(CONFIG_ENV_IS_IN_EEPROM) += env_embedded.o
 XCOBJS-$(CONFIG_ENV_IS_IN_FLASH) += env_embedded.o
 COBJS-$(CONFIG_ENV_IS_IN_NVRAM) += env_embedded.o
+COBJS-y += env_getenv_f.o
 COBJS-$(CONFIG_ENV_IS_IN_FLASH) += env_flash.o
 COBJS-$(CONFIG_ENV_IS_IN_MMC) += env_mmc.o
 COBJS-$(CONFIG_ENV_IS_IN_FAT) += env_fat.o
@@ -187,6 +188,9 @@ COBJS-$(CONFIG_USB_KEYBOARD) += usb_kbd.o
 endif
 
 ifdef CONFIG_SPL_BUILD
+COBJS-y += env_common.o
+COBJS-y += env_getenv_f.o
+COBJS-$(CONFIG_ENV_IS_IN_FLASH) += env_flash.o
 COBJS-$(CONFIG_SPL_YMODEM_SUPPORT) += xyzModem.o
 endif
 COBJS-y += console.o
common/cmd_nvedit.c +0 -58

70 lines not on this page · raw message

common/env_getenv_f.c new file +82 -0

82 lines not on this page · raw message

Signature · 1 line
1.7.12
#31 lore raw

PATCH 5/6 mpc5200: Add SPL support

In reply to Stefan Roese

This patch adds SPL booting support (NOR flash) for the MPC5200 platforms.

---
 arch/powerpc/cpu/mpc5xxx/Makefile       |  4 +++
 arch/powerpc/cpu/mpc5xxx/spl_boot.c     | 62 +++++++++++++++++++++++++++++++++
 arch/powerpc/cpu/mpc5xxx/start.S        | 22 ++++++++++++
 arch/powerpc/cpu/mpc5xxx/u-boot-spl.lds | 53 ++++++++++++++++++++++++++++
 arch/powerpc/include/asm/spl.h          | 28 +++++++++++++++
 arch/powerpc/lib/Makefile               |  4 +++
 6 files changed, 173 insertions(+)
 create mode 100644 arch/powerpc/cpu/mpc5xxx/spl_boot.c
 create mode 100644 arch/powerpc/cpu/mpc5xxx/u-boot-spl.lds
 create mode 100644 arch/powerpc/include/asm/spl.h
arch/powerpc/cpu/mpc5xxx/Makefile +4 -0
index 1a088b7..8de2c13 100644
@@ -41,6 +41,10 @@ COBJS-y += speed.o
 COBJS-$(CONFIG_CMD_USB) += usb_ohci.o
 COBJS-$(CONFIG_CMD_USB) += usb.o
 
+ifdef CONFIG_SPL_BUILD
+COBJS-y += spl_boot.o
+endif
+
 SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS-y:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS-y))
 START	:= $(addprefix $(obj),$(SSTART) $(CSTART))
arch/powerpc/cpu/mpc5xxx/spl_boot.c new file +62 -0

62 lines not on this page · raw message

arch/powerpc/cpu/mpc5xxx/start.S +22 -0
index 51cc4e2..ad5bc0a 100644
@@ -50,6 +50,7 @@
 #define MSR_KERNEL (MSR_FP|MSR_ME|MSR_RI)
 #endif
 
+#ifndef CONFIG_SPL_BUILD
 /*
  * Set up GOT: Global Offset Table
  *
@@ -68,6 +69,7 @@
 	GOT_ENTRY(__bss_end__)
 	GOT_ENTRY(__bss_start)
 	END_GOT
+#endif
 
 /*
  * Version string
@@ -84,6 +86,18 @@ version_string:
 	. = EXC_OFF_SYS_RESET
 	.globl	_start
 _start:
+
+#if defined(CONFIG_SPL) && !defined(CONFIG_SPL_BUILD)
+	/*
+	 * This is the entry of the real U-Boot from a board port
+	 * that supports SPL booting on the MPC5200. We only need
+	 * to call board_init_f() here. Everything else has already
+	 * been done in the SPL u-boot version.
+	 */
+	GET_GOT			/* initialize GOT access		*/
+	bl	board_init_f	/* run 1st part of board init code (in Flash)*/
+	/* NOTREACHED - board_init_f() does not return */
+#else
 	mfmsr	r5			/* save msr contents		*/
 
 	/* Move CSBoot and adjust instruction pointer                   */
@@ -152,7 +166,9 @@ lowboot_reentry:
 	/* Be careful to keep code relocatable !			*/
 	/*--------------------------------------------------------------*/
 
+#ifndef CONFIG_SPL_BUILD
 	GET_GOT			/* initialize GOT access		*/
+#endif
 
 	/* r3: IMMR */
 	bl	cpu_init_f	/* run low-level CPU init code (in Flash)*/
@@ -160,7 +176,9 @@ lowboot_reentry:
 	bl	board_init_f	/* run 1st part of board init code (in Flash)*/
 
 	/* NOTREACHED - board_init_f() does not return */
+#endif
 
+#ifndef CONFIG_SPL_BUILD
 /*
  * Vector Table
  */
@@ -333,6 +351,7 @@ int_return:
 	lwz	r1,GPR1(r1)
 	SYNC
 	rfi
+#endif /* CONFIG_SPL_BUILD */
 
 /*
  * This code initialises the MPC5xxx processor core
@@ -522,6 +541,7 @@ get_pvr:
 	mfspr	r3, PVR
 	blr
 
+#ifndef CONFIG_SPL_BUILD
 /*------------------------------------------------------------------------------*/
 
 /*
@@ -759,3 +779,5 @@ trap_init:
 
 	mtlr	r4			/* restore link register    */
 	blr
+
+#endif /* CONFIG_SPL_BUILD */
arch/powerpc/cpu/mpc5xxx/u-boot-spl.lds new file +53 -0

53 lines not on this page · raw message

arch/powerpc/include/asm/spl.h new file +28 -0
new file mode 100644
index 0000000..fd69253
@@ -0,0 +1,28 @@
+/*
+ * (C) Copyright 2012
+ * Texas Instruments, <www.ti.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	_ASM_SPL_H_
+#define	_ASM_SPL_H_
+
+#define BOOT_DEVICE_NOR		1
+
+#endif
arch/powerpc/lib/Makefile +4 -0
index cdd62a2..6e6688d 100644
@@ -44,7 +44,9 @@ SOBJS-y	+= ticks.o
 SOBJS-y	+= reloc.o
 
 COBJS-$(CONFIG_BAT_RW) += bat_rw.o
+ifndef CONFIG_SPL_BUILD
 COBJS-y	+= board.o
+endif
 COBJS-y	+= bootm.o
 COBJS-$(CONFIG_BOOTCOUNT_LIMIT) += bootcount.o
 COBJS-y	+= cache.o
@@ -75,12 +77,14 @@ TARGETS += $(LIB)
 all: $(TARGETS)
 
 $(LIB):	$(obj).depend $(OBJS)
+ifndef CONFIG_SPL_BUILD
 	@if ! $(CROSS_COMPILE)readelf -S $(OBJS) | grep -q '\.fixup.*PROGBITS';\
 	then \
 		echo "ERROR: Your compiler doesn't generate .fixup sections!";\
 		echo "       Upgrade to a recent toolchain."; \
 		exit 1; \
 	fi;
+endif
 	$(call cmd_link_o_target, $(OBJS))
 
 $(LIBGCC): $(obj).depend $(LGOBJS)
Signature · 1 line
1.7.12
#32 lore raw

PATCH 6/6 mpc5200: Add a3m071 board support

In reply to Stefan Roese

This patch adds support for the a3m071 board based on the MPC5200.

---
 MAINTAINERS                  |   2 +
 board/a3m071/Makefile        |  36 ++++
 board/a3m071/a3m071.c        | 335 +++++++++++++++++++++++++++++++++++++
 board/a3m071/mt46v16m16-75.h |  32 ++++
 boards.cfg                   |   1 +
 include/configs/a3m071.h     | 384 +++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 790 insertions(+)
 create mode 100644 board/a3m071/Makefile
 create mode 100644 board/a3m071/a3m071.c
 create mode 100644 board/a3m071/mt46v16m16-75.h
 create mode 100644 include/configs/a3m071.h
MAINTAINERS +2 -0
index c5a6f2f..d848ffc 100644
@@ -390,6 +390,8 @@ Ricardo Ribalda <[email protected]>
 
 Stefan Roese <[email protected]>
 
+	a3m071		MPC5200
+
 	P3M7448		MPC7448
 
 	uc100		MPC857
board/a3m071/Makefile new file +36 -0
new file mode 100644
index 0000000..6f961fb
@@ -0,0 +1,36 @@
+#
+# 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 $(TOPDIR)/config.mk
+
+LIB	= $(obj)lib$(BOARD).o
+
+COBJS	:= $(BOARD).o
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+SOBJS	:= $(addprefix $(obj),$(SOBJS))
+
+$(LIB):	$(obj).depend $(OBJS)
+	$(call cmd_link_o_target, $(OBJS))
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
board/a3m071/a3m071.c new file +335 -0

335 lines not on this page · raw message

board/a3m071/mt46v16m16-75.h new file +32 -0
new file mode 100644
index 0000000..e49e996
@@ -0,0 +1,32 @@
+/*
+ * (C) Copyright 2004
+ * Mark Jonas, Freescale Semiconductor, mark.jonas at motorola.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.
+ */
+
+#define SDRAM_DDR		/* is DDR */
+
+#if defined(CONFIG_MPC5200)
+/* Settings for XLB = 132 MHz */
+#define SDRAM_MODE	0x018D0000
+#define SDRAM_EMODE	0x40090000
+#define SDRAM_CONTROL	0x704f0f00
+#define SDRAM_CONFIG1	0x73722930
+#define SDRAM_CONFIG2	0x47770000
+#define SDRAM_TAPDELAY	0x10000000
+
+#else
+#error CONFIG_MPC5200 not defined
+#endif
boards.cfg +1 -0
index fdb84ad..cbe9c27 100644
@@ -431,6 +431,7 @@ mpc5121ads                   powerpc     mpc512x     mpc5121ads          freesca
 mpc5121ads_rev2              powerpc     mpc512x     mpc5121ads          freescale      -           mpc5121ads:MPC5121ADS_REV2
 cmi_mpc5xx                   powerpc     mpc5xx      cmi
 PATI                         powerpc     mpc5xx      pati                mpl
+a3m071                       powerpc     mpc5xxx     a3m071
 a4m072                       powerpc     mpc5xxx     a4m072
 BC3450                       powerpc     mpc5xxx     bc3450
 canmb                        powerpc     mpc5xxx
include/configs/a3m071.h new file +384 -0

384 lines not on this page · raw message

Signature · 1 line
1.7.12
#33 lore raw

cover SPL: Port SPL framework to powerpc

In reply to Stefan Roese
Quoted 14 lines · Stefan Roese

This patchset ports the SPL framework to powerpc. Its based on the SPL generalization lately done by Tom Rini. The patches can be applied on top of his 3rd version located here:

http://github.com/trini/u-boot WIP/spl-improvements

Additionally, a new MPC5200 board port is included, the a3m071 board port. This board port uses this SPL framework mainly to speed up booting into the OS (Linux of course). Detection of Linux vs. U-Boot booting is done here by checking the environment variable "boot_os". If "boot_os" is set to "yes", then the OS (Linux) is booted. Otherwise the "real" U-Boot is booted. For this env checking in the SPL, a small restructuring of the env code has been done.

Quoted 1 line

Comments welcome!

My first comment is, yay! In general, things look good, and I've just got a few questions I've replied to the respective patch with.

Signature · 1 line
Tom