Skip to contentSkip to conversation

SPL: Port SPL framework to powerpc

PATCH Superseded Stefan Roese 3 participants 21 messages Aug 27, 2012 – Aug 28, 2012

Subsystems (3)

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v2 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 4th 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!

Note: I switched to using patman with this 2nd patchset version. Hopefully I didn't screw too much up with this.

Tom, I would prefer, if you could merge some of those patches into your SPL rework series. Perhaps those first 6 patches once we agree on them?

SPL: Fix build problems on ARM with new SPL framework
SPL: Use image_get_xxx() functions to access header values
SPL: Add option to skip copying of the mkimage header
SPL: Add NOR flash booting support
powerpc: Extract EPAPR_MAGIC constants into processor.h
SPL: Port SPL framework to powerpc

What do you think?

Thanks,
Stefan

Changes in v2:
- Add option to skip copying of the mkimage header
- Rebased on Tom's SPL framework patches v4
- a3m071 build: Concat SPL binary and u-boot.img directly (no padding)

Stefan Roese (12):
SPL: Fix build problems on ARM with new SPL framework
SPL: Use image_get_xxx() functions to access header values
SPL: Add option to skip copying of the mkimage header
SPL: Add NOR flash booting support
powerpc: Extract EPAPR_MAGIC constants into processor.h
SPL: Port SPL framework to powerpc
env: Extract getenv_f() into separate source file
mpc5200: Add SPL support
mpc5200: Add a3m071 board support
fdt: cmd_fdt: Call fdt_chosen() from "fdt boardsetup"
Makefile: Add possibility to set entry-point for u-boot.img
Makefile: Add target for combined spl/u-boot.bin & u-boot.img

 MAINTAINERS                             |   2 +
 Makefile                                |  14 +-
 arch/arm/lib/spl.c                      |   2 +
 arch/powerpc/cpu/mpc5xxx/Makefile       |   4 +
 arch/powerpc/cpu/mpc5xxx/spl_boot.c     |  81 +++++++
 arch/powerpc/cpu/mpc5xxx/start.S        |  22 ++
 arch/powerpc/cpu/mpc5xxx/u-boot-spl.lds |  57 +++++
 arch/powerpc/include/asm/processor.h    |   6 +
 arch/powerpc/include/asm/spl.h          |  28 +++
 arch/powerpc/lib/Makefile               |   5 +
 arch/powerpc/lib/bootm.c                |   6 -
 arch/powerpc/lib/spl.c                  |  42 ++++
 board/a3m071/Makefile                   |  36 +++
 board/a3m071/README                     |  79 +++++++
 board/a3m071/a3m071.c                   | 335 ++++++++++++++++++++++++++++
 board/a3m071/mt46v16m16-75.h            |  32 +++
 boards.cfg                              |   1 +
 common/Makefile                         |   4 +
 common/cmd_fdt.c                        |   4 +-
 common/cmd_nvedit.c                     |  58 -----
 common/env_getenv_f.c                   |  82 +++++++
 common/spl/Makefile                     |   1 +
 common/spl/spl.c                        |  50 ++++-
 common/spl/spl_nor.c                    |  71 ++++++
 include/configs/a3m071.h                | 383 ++++++++++++++++++++++++++++++++
 include/spl.h                           |   6 +
 26 files changed, 1334 insertions(+), 77 deletions(-)
 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
 create mode 100644 arch/powerpc/lib/spl.c
 create mode 100644 board/a3m071/Makefile
 create mode 100644 board/a3m071/README
 create mode 100644 board/a3m071/a3m071.c
 create mode 100644 board/a3m071/mt46v16m16-75.h
 create mode 100644 common/env_getenv_f.c
 create mode 100644 common/spl/spl_nor.c
 create mode 100644 include/configs/a3m071.h
Signature · 1 line
1.7.12
#1 lore raw

PATCH v2 1/12 SPL: Fix build problems on ARM with new SPL framework

v4 of the SPL rework introduced some small issues. This patch fixes them.

---

 arch/arm/lib/spl.c | 2 ++
 common/spl/spl.c   | 2 --
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/lib/spl.c +2 -0
index 2d1f47a..3a5c593 100644
@@ -33,6 +33,8 @@ DECLARE_GLOBAL_DATA_PTR;
 
 extern char __bss_start[], __bss_end__[];
 
+gd_t gdata __attribute__ ((section(".data")));
+
 /*
  * In the context of SPL, board_init_f must ensure that any clocks/etc for
  * DDR are enabled, ensure that the stack pointer is valid, clear the BSS
common/spl/spl.c +0 -2
index eaea1c8..d36416c 100644
@@ -43,8 +43,6 @@ DECLARE_GLOBAL_DATA_PTR;
 u32 *boot_params_ptr = NULL;
 struct spl_image_info spl_image;
 
-/* Define global data structure pointer to it*/
-gd_t gdata __attribute__ ((section(".data")));
 static bd_t bdata __attribute__ ((section(".data")));
 
 inline void hang(void)
Signature · 1 line
1.7.12
#2 lore raw

PATCH v2 1/12 SPL: Fix build problems on ARM with new SPL framework

Quoted 2 lines · Stefan Roese

v4 of the SPL rework introduced some small issues. This patch fixes them.

OK, I see how you're doing GD on powerpc now, I'll re-work what I had done in my series for v5. Thanks!

Signature · 1 line
Tom
#3 lore raw

PATCH v2 2/12 SPL: Use image_get_xxx() functions to access header values

In reply to Stefan Roese

---

 common/spl/spl.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
common/spl/spl.c +5 -5
index d36416c..cc8df84 100644
@@ -75,13 +75,13 @@ void spl_parse_image_header(const struct image_header *header)
 {
 	u32 header_size = sizeof(struct image_header);
 
-	if (__be32_to_cpu(header->ih_magic) == IH_MAGIC) {
-		spl_image.size = __be32_to_cpu(header->ih_size) + header_size;
-		spl_image.entry_point = __be32_to_cpu(header->ih_load);
+	if (image_get_magic(header) == IH_MAGIC) {
+		spl_image.size = image_get_data_size(header) + header_size;
+		spl_image.entry_point = image_get_load(header);
 		/* Load including the header */
 		spl_image.load_addr = spl_image.entry_point - header_size;
-		spl_image.os = header->ih_os;
-		spl_image.name = (const char *)&header->ih_name;
+		spl_image.os = image_get_os(header);
+		spl_image.name = image_get_name(header);
 		debug("spl: payload image: %s load addr: 0x%x size: %d\n",
 			spl_image.name, spl_image.load_addr, spl_image.size);
 	} else {
Signature · 1 line
1.7.12
#4 lore raw

PATCH v2 2/12 SPL: Use image_get_xxx() functions to access header values

Quoted 1 line · Stefan Roese

Good spotting, I'll grab this for my v5 series.

Signature · 1 line
Tom
#5 lore raw

PATCH v2 3/12 SPL: Add option to skip copying of the mkimage header

In reply to Stefan Roese

On some system (e.g. powerpc), the load-address and entry-point is located at address 0. So the current approach to load the image (payload) including the header to the address "load-address - 64" can't work here.

This patch adds an flag to skip this copying including header to the SPL framework. By setting SPL_COPY_PAYLOAD_ONLY, only the playload will be copied. This will be used by the SPL NOR flash driver on powerpc.

---

 common/spl/spl.c | 21 +++++++++++++++++----
 include/spl.h    |  3 +++
 2 files changed, 20 insertions(+), 4 deletions(-)
common/spl/spl.c +17 -4
index cc8df84..13bebbc 100644
@@ -76,10 +76,23 @@ void spl_parse_image_header(const struct image_header *header)
 	u32 header_size = sizeof(struct image_header);
 
 	if (image_get_magic(header) == IH_MAGIC) {
-		spl_image.size = image_get_data_size(header) + header_size;
-		spl_image.entry_point = image_get_load(header);
-		/* Load including the header */
-		spl_image.load_addr = spl_image.entry_point - header_size;
+		if (spl_image.flags & SPL_COPY_PAYLOAD_ONLY) {
+			/*
+			 * On some system (e.g. powerpc), the load-address and
+			 * entry-point is located at address 0. We can't load
+			 * to 0-0x40. So skip header in this case.
+			 */
+			spl_image.load_addr = image_get_load(header);
+			spl_image.entry_point = image_get_ep(header);
+			spl_image.size = image_get_data_size(header);
+		} else {
+			spl_image.entry_point = image_get_load(header);
+			/* Load including the header */
+			spl_image.load_addr = spl_image.entry_point -
+				header_size;
+			spl_image.size = image_get_data_size(header) +
+				header_size;
+		}
 		spl_image.os = image_get_os(header);
 		spl_image.name = image_get_name(header);
 		debug("spl: payload image: %s load addr: 0x%x size: %d\n",
include/spl.h +3 -0
index 478aa10..673c4a4 100644
@@ -38,8 +38,11 @@ struct spl_image_info {
 	u32 load_addr;
 	u32 entry_point;
 	u32 size;
+	u32 flags;
 };
 
+#define SPL_COPY_PAYLOAD_ONLY	1
+
 extern struct spl_image_info spl_image;
 extern u32 *boot_params_ptr;
 extern gd_t gdata;
Signature · 1 line
1.7.12
#6 lore raw

PATCH v2 4/12 SPL: Add NOR flash booting support

In reply to 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.

---
Changes in v2:
- Add option to skip copying of the mkimage header

 common/spl/Makefile  |  1 +
 common/spl/spl.c     |  5 ++++
 common/spl/spl_nor.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/spl.h        |  3 +++
 4 files changed, 80 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 13bebbc..61936ee 100644
@@ -155,6 +155,11 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 		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 +71 -0

71 lines not on this page · raw message

include/spl.h +3 -0
index 673c4a4..4a76239 100644
@@ -60,6 +60,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
#7 lore raw

PATCH v2 4/12 SPL: Add NOR flash booting support

Quoted 9 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.

Added to my v5 series, thanks!

Signature · 1 line
Tom
#8 lore raw

PATCH v2 4/12 SPL: Add NOR flash booting support

In reply to Stefan Roese

Hi Stefan,

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

Quoted 72 lines

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.

---
Changes in v2:
- Add option to skip copying of the mkimage header

 common/spl/Makefile  |  1 +
 common/spl/spl.c     |  5 ++++
 common/spl/spl_nor.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/spl.h        |  3 +++
 4 files changed, 80 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 13bebbc..61936ee 100644
@@ -155,6 +155,11 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
                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 +18 -0
new file mode 100644
index 0000000..a1c13a4
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2012 Stefan Roese <[email protected]>
+ *
+ * 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 <common.h>

common/spl/spl_nor.c line 28

Quoted 10 lines
common/spl/spl_nor.c new file +10 -0
+#include <spl.h>
+
+/*
+ * Don't use the special MPC5xxx memcpy implementation, only use
+ * the standard one.
+ */
+#if defined(CONFIG_MPC512X) || defined(CONFIG_MPC5200)
+extern void *__memcpy(void *, const void *, size_t);
+#define memcpy         __memcpy
+#endif

can't we move this to arch-specifc spl code?
I think arch/CPU/SoC specific definitions should be avoided in new generic frameworks.

how about:

__weak void *spl_memcpy(void *dst, const void *src, size_t size)

{
         return memcpy(dst, src, size);
}

and in arch/powerpc/cpu/mpc5xxx/spl_boot.c:

void *spl_memcpy(void *dst, const void *src, size_t size)

{
         return __memcpy(dst, src, size);
}
Quoted 64 lines
common/spl/spl_nor.c new file +43 -0
+
+void spl_nor_load_image(void)
+{
+       /*
+        * Loading of the payload to SDRAM is done with skipping of
+        * the mkimage header in this SPL NOR driver
+        */
+       spl_image.flags |= SPL_COPY_PAYLOAD_ONLY;
+
+       if (spl_start_uboot()) {
+               /*
+                * Load real U-Boot from its location in NOR flash to its
+                * defined location in SDRAM
+                */
+               spl_parse_image_header(
+                       (const struct image_header *)CONFIG_SYS_UBOOT_BASE);
+
+               memcpy((void *)spl_image.load_addr,
+                      (void *)(CONFIG_SYS_UBOOT_BASE +
+                               sizeof(struct image_header)),
+                      spl_image.size);
+       } else {
+               /*
+                * Load Linux from its location in NOR flash to its defined
+                * location in SDRAM
+                */
+               spl_parse_image_header(
+                       (const struct image_header *)CONFIG_SYS_OS_BASE);
+
+               memcpy((void *)spl_image.load_addr,
+                      (void *)(CONFIG_SYS_OS_BASE +
+                               sizeof(struct image_header)),
+                      spl_image.size);
+
+               /*
+                * Copy DT blob (fdt) to SDRAM. Passing pointer to flash
+                * doesn't work (16 KiB should be enough for DT)
+                */
+               memcpy((void *)CONFIG_SYS_SPL_ARGS_ADDR,
+                      (void *)(CONFIG_SYS_FDT_BASE),
+                      (16 << 10));
+       }
+}
include/spl.h +3 -1
index 673c4a4..4a76239 100644
@@ -60,6 +60,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);
 
--

1.7.12

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

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

PATCH v2 4/12 SPL: Add NOR flash booting support

Quoted 12 lines · Daniel Schwierzeck

Hi Stefan,

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

Quoted 9 lines

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.

[snip]

Quoted 4 lines
Quoted 4 lines

+/*
+ * Don't use the special MPC5xxx memcpy implementation, only use
+ * the standard one.
+ */

Quoted 8 lines

common/spl/spl_nor.c line 28

Quoted 4 lines
common/spl/spl_nor.c new file +4 -0
+#if defined(CONFIG_MPC512X) || defined(CONFIG_MPC5200)
+extern void *__memcpy(void *, const void *, size_t);
+#define memcpy         __memcpy
+#endif

can't we move this to arch-specifc spl code?
I think arch/CPU/SoC specific definitions should be avoided in new generic frameworks.

This is a good point. And I think we can further tweak this by modifying arch/powerpc/lib/Makefile to just not build memcpy_5200.c for CONFIG_SPL_BUILD. So lets go with that, and I'll just fixup my local copy.

Signature · 1 line
Tom
#10 lore raw

PATCH v2 4/12 SPL: Add NOR flash booting support

Quoted 27 lines · Tom Rini
Quoted 12 lines · Daniel Schwierzeck

Hi Stefan,

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

Quoted 9 lines

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.

[snip]

Quoted 4 lines
Quoted 4 lines

+/*
+ * Don't use the special MPC5xxx memcpy implementation, only use
+ * the standard one.
+ */

Quoted 8 lines

common/spl/spl_nor.c line 28

Quoted 4 lines
common/spl/spl_nor.c new file +4 -0
+#if defined(CONFIG_MPC512X) || defined(CONFIG_MPC5200)
+extern void *__memcpy(void *, const void *, size_t);
+#define memcpy         __memcpy
+#endif

can't we move this to arch-specifc spl code?
I think arch/CPU/SoC specific definitions should be avoided in new generic frameworks.

Quoted 3 lines

This is a good point. And I think we can further tweak this by modifying arch/powerpc/lib/Makefile to just not build memcpy_5200.c for CONFIG_SPL_BUILD. So lets go with that, and I'll just fixup my local copy.

Good idea. I'll change the powerpc Makefile accordingly.

Thanks,
Stefan

#11 lore raw

PATCH v2 5/12 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 53dc4df..e3fee0b 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
#12 lore raw

PATCH v2 6/12 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.

---
Changes in v2:
- Add option to skip copying of the mkimage header
- Rebased on Tom's SPL framework patches v4

 arch/powerpc/lib/Makefile |  1 +
 arch/powerpc/lib/spl.c    | 42 ++++++++++++++++++++++++++++++++++++++++++
 common/spl/spl.c          | 16 ++++++++++++++--
 3 files changed, 57 insertions(+), 2 deletions(-)
 create mode 100644 arch/powerpc/lib/spl.c
arch/powerpc/lib/Makefile +1 -0
index cdd62a2..9c86c96 100644
@@ -51,6 +51,7 @@ COBJS-y	+= cache.o
 COBJS-y	+= extable.o
 COBJS-y	+= interrupts.o
 COBJS-$(CONFIG_CMD_KGDB) += kgdb.o
+COBJS-$(CONFIG_SPL_FRAMEWORK) += spl.o
 COBJS-y	+= time.o
 
 # Workaround for local bus unaligned access problems
arch/powerpc/lib/spl.c new file +42 -0

42 lines not on this page · raw message

common/spl/spl.c +14 -2
index 61936ee..3eb269e 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,6 +35,9 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#ifndef CONFIG_SYS_UBOOT_START
+#define CONFIG_SYS_UBOOT_START	CONFIG_SYS_TEXT_BASE
+#endif
 #ifndef CONFIG_SYS_MONITOR_LEN
 #define CONFIG_SYS_MONITOR_LEN	(200 * 1024)
 #endif
@@ -71,6 +73,16 @@ __weak int spl_start_uboot(void)
 }
 #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! */
+}
+
 void spl_parse_image_header(const struct image_header *header)
 {
 	u32 header_size = sizeof(struct image_header);
@@ -104,7 +116,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 = CONFIG_SYS_MONITOR_LEN;
-		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";
Signature · 1 line
1.7.12
#13 lore raw

PATCH v2 6/12 SPL: Port SPL framework to powerpc

Quoted 4 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 +0 -0
index 61936ee..3eb269e 100644

[snip]

Quoted 10 lines
common/spl/spl.c +3 -0
@@ -36,6 +35,9 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#ifndef CONFIG_SYS_UBOOT_START
+#define CONFIG_SYS_UBOOT_START	CONFIG_SYS_TEXT_BASE
+#endif
 #ifndef CONFIG_SYS_MONITOR_LEN
 #define CONFIG_SYS_MONITOR_LEN	(200 * 1024)
 #endif

[snip]

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

Quoted 9 lines
common/spl/spl.c +1 -1
@@ -104,7 +116,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 = CONFIG_SYS_MONITOR_LEN;
-		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";

Can you post this as it's own patch? I'll pick that up for v5.

Signature · 1 line
Tom
#14 lore raw

PATCH v2 6/12 SPL: Port SPL framework to powerpc

Quoted 23 lines · Tom Rini
Quoted 4 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 +0 -0
index 61936ee..3eb269e 100644

[snip]

Quoted 10 lines
common/spl/spl.c +3 -0
@@ -36,6 +35,9 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#ifndef CONFIG_SYS_UBOOT_START
+#define CONFIG_SYS_UBOOT_START	CONFIG_SYS_TEXT_BASE
+#endif
 #ifndef CONFIG_SYS_MONITOR_LEN
 #define CONFIG_SYS_MONITOR_LEN	(200 * 1024)
 #endif

[snip]

Quoted 11 lines

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

Quoted 9 lines
common/spl/spl.c +1 -1
@@ -104,7 +116,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 = CONFIG_SYS_MONITOR_LEN;
-		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";

Can you post this as it's own patch? I'll pick that up for v5.

Okay. Will do.

Thanks,
Stefan

#15 lore raw

PATCH v2 7/12 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
#16 lore raw

PATCH v2 8/12 mpc5200: Add SPL support

In reply to Stefan Roese

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

---
Changes in v2:
- Rebased on Tom's SPL framework patches v4

 arch/powerpc/cpu/mpc5xxx/Makefile       |  4 ++
 arch/powerpc/cpu/mpc5xxx/spl_boot.c     | 81 +++++++++++++++++++++++++++++++++
 arch/powerpc/cpu/mpc5xxx/start.S        | 22 +++++++++
 arch/powerpc/cpu/mpc5xxx/u-boot-spl.lds | 57 +++++++++++++++++++++++
 arch/powerpc/include/asm/spl.h          | 28 ++++++++++++
 arch/powerpc/lib/Makefile               |  4 ++
 6 files changed, 196 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 +81 -0

81 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 +57 -0

57 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 9c86c96..0248ca8 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
@@ -76,12 +78,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
#17 lore raw

PATCH v2 9/12 mpc5200: Add a3m071 board support

In reply to Stefan Roese

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

---
Changes in v2:
- Rebased on Tom's SPL framework patches v4
- a3m071 build: Concat SPL binary and u-boot.img directly (no padding)

 MAINTAINERS                  |   2 +
 board/a3m071/Makefile        |  36 ++++
 board/a3m071/README          |  79 +++++++++
 board/a3m071/a3m071.c        | 335 +++++++++++++++++++++++++++++++++++++
 board/a3m071/mt46v16m16-75.h |  32 ++++
 boards.cfg                   |   1 +
 include/configs/a3m071.h     | 383 +++++++++++++++++++++++++++++++++++++++++++
 7 files changed, 868 insertions(+)
 create mode 100644 board/a3m071/Makefile
 create mode 100644 board/a3m071/README
 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/README new file +79 -0

79 lines not on this page · raw message

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 +383 -0

383 lines not on this page · raw message

Signature · 1 line
1.7.12
#18 lore raw

PATCH v2 10/12 fdt: cmd_fdt: Call fdt_chosen() from "fdt boardsetup"

In reply to Stefan Roese

By calling fdt_chosen(), the chosen node will be updated / created by the "fdt boardsetup" command. This is useful for setting of the kernel commandline via the "bootargs" env variable.

With this change, the "fdt boardsetup" can be used to prepare the DT blob for SPL booting. The patched DT blob can be saved to flash and can be used by the SPL U-Boot version directly for Linux booting.

---

 common/cmd_fdt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
common/cmd_fdt.c +3 -1
index 9a5c53e..083a2c2 100644
@@ -414,8 +414,10 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 	}
 #ifdef CONFIG_OF_BOARD_SETUP
 	/* Call the board-specific fixup routine */
-	else if (strncmp(argv[1], "boa", 3) == 0)
+	else if (strncmp(argv[1], "boa", 3) == 0) {
 		ft_board_setup(working_fdt, gd->bd);
+		fdt_chosen(working_fdt, 1);
+	}
 #endif
 	/* Create a chosen node */
 	else if (argv[1][0] == 'c') {
Signature · 1 line
1.7.12
#19 lore raw

PATCH v2 11/12 Makefile: Add possibility to set entry-point for u-boot.img

In reply to Stefan Roese

This patch enabled boards using the SPL framework to set an entry point in the U-Boot mkimage image "u-boot.img". Until now the entry point in the header has been set to 0. By setting CONFIG_SYS_UBOOT_START in the board header, boards can override this default location.

This will be used by the upcoming a3m071 MPC5200 board port.

---

 Makefile | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
Makefile +10 -1
index 8738d55..c759446 100644
@@ -412,9 +412,18 @@ $(obj)u-boot.ldr.hex:	$(obj)u-boot.ldr
 $(obj)u-boot.ldr.srec:	$(obj)u-boot.ldr
 		$(OBJCOPY) ${OBJCFLAGS} -O srec $< $@ -I binary
 
+#
+# U-Boot entry point, needed for booting of full-blown U-Boot
+# from the SPL U-Boot version.
+#
+ifndef CONFIG_SYS_UBOOT_START
+CONFIG_SYS_UBOOT_START := 0
+endif
+
 $(obj)u-boot.img:	$(obj)u-boot.bin
 		$(obj)tools/mkimage -A $(ARCH) -T firmware -C none \
-		-O u-boot -a $(CONFIG_SYS_TEXT_BASE) -e 0 \
+		-O u-boot -a $(CONFIG_SYS_TEXT_BASE) \
+		-e $(CONFIG_SYS_UBOOT_START) \
 		-n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
 			sed -e 's/"[	 ]*$$/ for $(BOARD) board"/') \
 		-d $< $@
Signature · 1 line
1.7.12
#20 lore raw

PATCH v2 12/12 Makefile: Add target for combined spl/u-boot.bin & u-boot.img

In reply to Stefan Roese

This new make target "u-boot-img.bin" consists of the U-Boot SPL image with the real, full-blown U-Boot image directly attached to it. The full-blown U-Boot image has the mkimage header included, with its load-address and entry-point.

This will be used by the upcoming a3m071 MPC5200 board port.

---

 Makefile | 3 +++
 1 file changed, 3 insertions(+)
Makefile +3 -0
index c759446..a4ea4f9 100644
@@ -482,6 +482,9 @@ $(obj)u-boot.spr:	$(obj)u-boot.img $(obj)spl/u-boot-spl.bin
 			conv=notrunc 2>/dev/null
 		cat $(obj)spl/u-boot-spl-pad.img $(obj)u-boot.img > $@
 
+$(obj)u-boot-img.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.img
+		cat $(obj)spl/u-boot-spl.bin $(obj)u-boot.img > $@
+
 ifeq ($(CONFIG_SANDBOX),y)
 GEN_UBOOT = \
 		cd $(LNDIR) && $(CC) $(SYMS) -T $(obj)u-boot.lds \
Signature · 1 line
1.7.12