Skip to contentSkip to conversation

powerpc/p1022ds: boot from SD card/SPI flash with SPL

PATCH New ying.zhang at freescale.com 3 participants 6 messages May 8, 2013 – May 13, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/p1022ds: boot from SD card/SPI flash with SPL

From: Ying Zhang <[email protected]>

This patch introduces SPL to enable a loader stub that runs in the L2 SRAM, after being loaded by the code from the internal on-chip ROM. It loads the final uboot image into DDR, then jump to it to begin execution.

The SPL's size is sizeable, the maximum size must not exceed the size of L2 SRAM.It initializes the DDR through SPD code, and copys final uboot image to DDR. So there are two stage uboot images:
* spl_boot, 96KB size. The env variables are copied to offset 96KB. in L2 SRAM, so that ddr spd code can get the interleaving mode setting in env. It loads final uboot image from offset 96KB.
* final uboot image, size is variable depends on the functions enabled.

---
 README                                  |   24 +++++
 arch/powerpc/cpu/mpc85xx/tlb.c          |    2 +-
 arch/powerpc/cpu/mpc85xx/u-boot-spl.lds |   25 +++++
 arch/powerpc/cpu/mpc85xx/u-boot.lds     |    8 ++
 arch/powerpc/cpu/mpc8xxx/law.c          |    4 +-
 board/freescale/common/Makefile         |    5 +-
 board/freescale/common/sdhc_boot.c      |  123 +++++++++++++++++++++++++
 board/freescale/common/sdhc_boot.h      |   29 ++++++
 board/freescale/common/spi_boot.c       |   96 ++++++++++++++++++++
 board/freescale/common/spi_boot.h       |   26 ++++++
 board/freescale/p1022ds/Makefile        |    3 +
 board/freescale/p1022ds/spl.c           |  148 +++++++++++++++++++++++++++++++
 board/freescale/p1022ds/tlb.c           |    9 ++-
 common/Makefile                         |    5 +
 doc/README.mpc85xx-sd-spi-boot          |   82 +++++++++++++++++
 include/configs/P1022DS.h               |  116 ++++++++++++++++++++----
 lib/Makefile                            |    5 +
 spl/Makefile                            |    3 +
 18 files changed, 688 insertions(+), 25 deletions(-)
 create mode 100644 board/freescale/common/sdhc_boot.h
 create mode 100644 board/freescale/common/spi_boot.c
 create mode 100644 board/freescale/common/spi_boot.h
 create mode 100644 board/freescale/p1022ds/spl.c
 create mode 100644 doc/README.mpc85xx-sd-spi-boot
README +24 -0
index 862bb3e..f974bca 100644
@@ -2887,6 +2887,10 @@ FIT uImage format:
 		CONFIG_SPL_INIT_MINIMAL
 		Arch init code should be built for a very small image
 
+		CONFIG_SPL_INIT_NORMAL
+		This is relative to MINIMAL, this init code contains some
+		features that the minimal SPL doesn't contains.
+
 		CONFIG_SPL_LIBCOMMON_SUPPORT
 		Support for common/libcommon.o in SPL binary
 
@@ -2977,6 +2981,21 @@ FIT uImage format:
 		CONFIG_SPL_LIBGENERIC_SUPPORT
 		Support for lib/libgeneric.o in SPL binary
 
+		CONFIG_SPL_INIT_DDR_SUPPORT
+		Support for common DDR init in SPL binary
+
+		CONFIG_SPL_HWCONFIG_SUPPORT
+		Support for configuring hardware via environment in SPL binary
+
+		CONFIG_SPL_ENV_SUPPORT
+		Support for the environment operating in SPL binary
+
+		CONFIG_SPL_ADDR_MAP_SUPPORT
+		Support for mutual transformation between virtual addr to CPU bus addr
+
+		CONFIG_SPL_UTILITYLIB_SUPPORT
+		Support for some common tools in SPL binary, such as: hashtable
+
 		CONFIG_SPL_PAD_TO
 		Image offset to which the SPL should be padded before appending
 		the SPL payload. By default, this is defined as
@@ -3965,6 +3984,11 @@ Low Level (hardware related) configuration options:
 		that is executed before the actual U-Boot. E.g. when
 		compiling a NAND SPL.
 
+- CONFIG_SYS_MPC85XX_NO_RESETVEC
+		Only for 85xx systems. If this variable is specified, the section
+		.resetvec is not kept and the section .bootpg is placed in the
+		previous 4k of the .text section.
+
 - CONFIG_ARCH_MAP_SYSMEM
 		Generally U-Boot (and in particular the md command) uses
 		effective address. It is therefore not necessary to regard
arch/powerpc/cpu/mpc85xx/tlb.c +1 -1
index 0dff37f..d21b324 100644
@@ -55,7 +55,7 @@ void init_tlbs(void)
 	return ;
 }
 
-#if !defined(CONFIG_NAND_SPL) && !defined(CONFIG_SPL_BUILD)
+#if !defined(CONFIG_NAND_SPL) && !defined(CONFIG_SPL_BUILD_MINIMAL)
 void read_tlbcam_entry(int idx, u32 *valid, u32 *tsize, unsigned long *epn,
 		       phys_addr_t *rpn)
 {
arch/powerpc/cpu/mpc85xx/u-boot-spl.lds +25 -0
index f2b7bff..f1a9ac9 100644
@@ -26,6 +26,13 @@
 #include "config.h"	/* CONFIG_BOARDDIR */
 
 OUTPUT_ARCH(powerpc)
+#ifdef CONFIG_SYS_MPC85XX_NO_RESETVEC
+PHDRS
+{
+  text PT_LOAD;
+  bss PT_LOAD;
+}
+#endif
 SECTIONS
 {
 	. = CONFIG_SPL_TEXT_BASE;
@@ -53,6 +60,11 @@ SECTIONS
 	}
 	_edata  =  .;
 
+	. = .;
+	__start___ex_table = .;
+	__ex_table : { *(__ex_table) }
+	__stop___ex_table = .;
+
 	. = ALIGN(8);
 	__init_begin = .;
 	__init_end = .;
@@ -68,9 +80,21 @@ SECTIONS
 #else
 #error unknown NAND controller
 #endif
+
+#ifndef CONFIG_FSL_IFC
+#ifdef CONFIG_SYS_MPC85XX_NO_RESETVEC
+	.bootpg ADDR(.text) - 0x1000 :
+	{
+		KEEP(*(.bootpg))
+	} :text = 0xffff
+#endif
+#endif
+
+#ifndef CONFIG_SYS_MPC85XX_NO_RESETVEC
 	.resetvec ADDR(.text) + RESET_VECTOR_OFFSET : {
 		KEEP(*(.resetvec))
 	} = 0xffff
+#endif
 
 	/*
 	 * Make sure that the bss segment isn't linked at 0x0, otherwise its
@@ -83,5 +107,6 @@ SECTIONS
 		*(.sbss*)
 		*(.bss*)
 	}
+	. = ALIGN(4);
 	__bss_end = .;
 }
arch/powerpc/cpu/mpc85xx/u-boot.lds +8 -0
index 0503dce..2643563 100644
@@ -95,6 +95,13 @@ SECTIONS
   . = ALIGN(256);
   __init_end = .;
 
+#ifdef CONFIG_SYS_MPC85XX_NO_RESETVEC
+  .bootpg ADDR(.text) - 0x1000 :
+  {
+    KEEP(arch/powerpc/cpu/mpc85xx/start.o (.bootpg))
+  } :text = 0xffff
+  . = ADDR(.text) + 0x80000;
+#else
   .bootpg RESET_VECTOR_ADDRESS - 0xffc :
   {
     arch/powerpc/cpu/mpc85xx/start.o	(.bootpg)
@@ -117,6 +124,7 @@ SECTIONS
 #if (RESET_VECTOR_ADDRESS == 0xfffffffc)
   . |= 0x10;
 #endif
+#endif
 
   __bss_start = .;
   .bss (NOLOAD)       :
arch/powerpc/cpu/mpc8xxx/law.c +2 -2
index 6f9d568..979c3c2 100644
@@ -92,7 +92,7 @@ void disable_law(u8 idx)
 	return;
 }
 
-#if !defined(CONFIG_NAND_SPL) && !defined(CONFIG_SPL_BUILD)
+#if !defined(CONFIG_NAND_SPL) && !defined(CONFIG_SPL_BUILD_MINIMAL)
 static int get_law_entry(u8 i, struct law_entry *e)
 {
 	u32 lawar;
@@ -122,7 +122,7 @@ int set_next_law(phys_addr_t addr, enum law_size sz, enum law_trgt_if id)
 	return idx;
 }
 
-#if !defined(CONFIG_NAND_SPL) && !defined(CONFIG_SPL_BUILD)
+#if !defined(CONFIG_NAND_SPL) && !defined(CONFIG_SPL_BUILD_MINIMAL)
 int set_last_law(phys_addr_t addr, enum law_size sz, enum law_trgt_if id)
 {
 	u32 idx;
board/freescale/common/Makefile +3 -2
index 72bb56c..7340dfe 100644
@@ -45,6 +45,9 @@ COBJS-$(CONFIG_FSL_SGMII_RISER)	+= sgmii_riser.o
 ifndef CONFIG_RAMBOOT_PBL
 COBJS-$(CONFIG_FSL_FIXED_MMC_LOCATION)	+= sdhc_boot.o
 endif
+ifdef CONFIG_SPL_BUILD
+COBJS-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += spi_boot.o
+endif
 
 COBJS-$(CONFIG_MPC8541CDS)	+= cds_pci_ft.o
 COBJS-$(CONFIG_MPC8548CDS)	+= cds_pci_ft.o
@@ -52,9 +55,7 @@ COBJS-$(CONFIG_MPC8555CDS)	+= cds_pci_ft.o
 
 COBJS-$(CONFIG_MPC8536DS)	+= ics307_clk.o
 COBJS-$(CONFIG_MPC8572DS)	+= ics307_clk.o
-ifndef CONFIG_SPL_BUILD
 COBJS-$(CONFIG_P1022DS)		+= ics307_clk.o
-endif
 COBJS-$(CONFIG_P2020DS)		+= ics307_clk.o
 COBJS-$(CONFIG_P3041DS)		+= ics307_clk.o
 COBJS-$(CONFIG_P4080DS)		+= ics307_clk.o
board/freescale/common/sdhc_boot.c +123 -0

138 lines not on this page · raw message

board/freescale/common/sdhc_boot.h new file +29 -0
new file mode 100644
index 0000000..2b5dcb9
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2011 Freescale Semiconductor, Inc.
+ *
+ * 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 __SDHC_BOOT_H_
+#define __SDHC_BOOT_H_    1
+
+
+int mmc_get_env_addr(struct mmc *mmc, u32 *env_addr);
+void mmc_get_env(void);
+void mmc_boot(void);
+
+#endif  /* __SDHC_BOOT_H_ */
+
board/freescale/common/spi_boot.c new file +96 -0

96 lines not on this page · raw message

board/freescale/common/spi_boot.h new file +26 -0
new file mode 100644
index 0000000..125dc84
@@ -0,0 +1,26 @@
+/* Copyright 2011 Freescale Semiconductor, Inc.
+ *
+ * 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 __SPI_BOOT_H_
+#define __SPI_BOOT_H_    1
+
+void spi_get_env(void);
+void spi_boot(void);
+
+#endif  /* __SPI_BOOT_H_ */
+
board/freescale/p1022ds/Makefile +3 -0
index 633161c..5739cf3 100644
@@ -25,6 +25,9 @@ COBJS-y        += spl_minimal.o tlb.o law.o
 
 else
 
+ifdef CONFIG_SPL_BUILD
+COBJS-$(CONFIG_SPL_INIT_NORMAL) += spl.o
+endif
 COBJS-y	+= $(BOARD).o
 COBJS-y	+= ddr.o
 COBJS-y	+= law.o
board/freescale/p1022ds/spl.c new file +148 -0

148 lines not on this page · raw message

board/freescale/p1022ds/tlb.c +8 -1
index ebf5dd7..402d877 100644
@@ -74,7 +74,8 @@ struct fsl_e_tlb_entry tlb_table[] = {
 		      MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
 		      0, 7, BOOKE_PAGESZ_4K, 1),
 
-#if defined(CONFIG_SYS_RAMBOOT) || defined(CONFIG_SPL)
+#if (defined(CONFIG_SYS_RAMBOOT) || defined(CONFIG_SPL)) && \
+	!defined(CONFIG_SPL_COMMON_INIT_DDR)
 	/* **** - eSDHC/eSPI/NAND boot */
 	SET_TLB_ENTRY(1, CONFIG_SYS_DDR_SDRAM_BASE, CONFIG_SYS_DDR_SDRAM_BASE,
 			MAS3_SX|MAS3_SW|MAS3_SR, 0,
@@ -94,6 +95,12 @@ struct fsl_e_tlb_entry tlb_table[] = {
 			0, 10, BOOKE_PAGESZ_16K, 1),
 #endif
 
+#ifdef CONFIG_SYS_INIT_L2_ADDR
+	/* *I*G - L2SRAM */
+	SET_TLB_ENTRY(1, CONFIG_SYS_INIT_L2_ADDR, CONFIG_SYS_INIT_L2_ADDR_PHYS,
+			MAS3_SX|MAS3_SW|MAS3_SR, MAS2_G,
+			0, 11, BOOKE_PAGESZ_256K, 1)
+#endif
 };
 
 int num_tlb_entries = ARRAY_SIZE(tlb_table);
common/Makefile +5 -0
index 0e0fff1..bc80414 100644
@@ -225,6 +225,11 @@ COBJS-$(CONFIG_SPL_NET_SUPPORT) += env_common.o
 COBJS-$(CONFIG_SPL_NET_SUPPORT) += env_flags.o
 COBJS-$(CONFIG_SPL_NET_SUPPORT) += env_nowhere.o
 COBJS-$(CONFIG_SPL_NET_SUPPORT) += miiphyutil.o
+COBJS-$(CONFIG_SPL_HWCONFIG_SUPPORT) += hwconfig.o
+COBJS-$(CONFIG_SPL_INIT_DDR_SUPPORT) += ddr_spd.o
+COBJS-$(CONFIG_SPL_ENV_SUPPORT) += env_attr.o
+COBJS-$(CONFIG_SPL_ENV_SUPPORT) += env_flags.o
+COBJS-$(CONFIG_SPL_ENV_SUPPORT) += env_callback.o
 endif
 COBJS-$(CONFIG_BOUNCE_BUFFER) += bouncebuf.o
 COBJS-y += console.o
doc/README.mpc85xx-sd-spi-boot new file +82 -0

82 lines not on this page · raw message

include/configs/P1022DS.h +97 -19

183 lines not on this page · raw message

lib/Makefile +5 -0
index e901cc7..ab12e63 100644
@@ -66,6 +66,11 @@ endif
 COBJS-$(CONFIG_SPL_NET_SUPPORT) += errno.o
 COBJS-$(CONFIG_SPL_NET_SUPPORT) += hashtable.o
 COBJS-$(CONFIG_SPL_NET_SUPPORT) += net_utils.o
+COBJS-$(CONFIG_SPL_ADDR_MAP_SUPPORT) += addr_map.o
+COBJS-$(CONFIG_SPL_UTILITYLIB_SUPPORT) += hashtable.o
+COBJS-$(CONFIG_SPL_UTILITYLIB_SUPPORT) += display_options.o
+COBJS-$(CONFIG_SPL_UTILITYLIB_SUPPORT) += errno.o
+
 endif
 COBJS-$(CONFIG_BCH) += bch.o
 COBJS-y += crc32.o
spl/Makefile +3 -0
index b5a8de7..3a3b868 100644
@@ -51,6 +51,9 @@ LIBS-y += arch/powerpc/cpu/mpc8xxx/lib8xxx.o
 endif
 ifeq ($(CPU),mpc85xx)
 LIBS-y += arch/powerpc/cpu/mpc8xxx/lib8xxx.o
+ifdef CONFIG_SPL_INIT_DDR_SUPPORT
+LIBS-y += arch/powerpc/cpu/mpc8xxx/ddr/libddr.o
+endif
 endif
 ifeq ($(CPU),mpc86xx)
 LIBS-y += arch/powerpc/cpu/mpc8xxx/lib8xxx.o
Signature · 1 line
1.7.0.4
#1 lore raw

PATCH 1/1 powerpc/p1022ds: boot from SD card/SPI flash with SPL

Quoted 21 lines · ying.zhang at freescale.com

From: Ying Zhang <[email protected]>

This patch introduces SPL to enable a loader stub that runs in the L2 SRAM,
after being loaded by the code from the internal on-chip ROM. It loads the
final uboot image into DDR, then jump to it to begin execution.

The SPL's size is sizeable, the maximum size must not exceed the size of L2
SRAM.It initializes the DDR through SPD code, and copys final uboot image to
DDR. So there are two stage uboot images:
* spl_boot, 96KB size. The env variables are copied to offset
96KB.
in L2 SRAM, so that ddr spd code can get the interleaving
mode setting
in env. It loads final uboot image from offset 96KB.
* final uboot image, size is variable depends on the functions
enabled.

Quoted 2 lines

---

Andy Fleming <[email protected]> is the MMC and mpc85xx maintainer; please CC him on these
patches.

This patch needs to be broken into several patches that each take care of
one logical problem; it's too hard to properly review (and have the right
people pay attention to certain parts) in its current state.

Is this on top of the already-posted P1022DS NAND patch? If so, please say so.

README FIT uImage format: · line 2892

Quoted 12 lines
README +2 -0
index 862bb3e..f974bca 100644
@@ -2887,6 +2887,10 @@ FIT uImage format:
 		CONFIG_SPL_INIT_MINIMAL
 		Arch init code should be built for a very small image
 
+		CONFIG_SPL_INIT_NORMAL
+		This is relative to MINIMAL, this init code contains  

some

README +1 -0
+		features that the minimal SPL doesn't contains.

Why do we need a symbol for this? The only place you use it is already limited to CONFIG_SPL_BUILD and !CONFIG_SPL_INIT_MINIMAL.

Quoted 14 lines
arch/powerpc/cpu/mpc85xx/tlb.c +1 -1
index 0dff37f..d21b324 100644
@@ -55,7 +55,7 @@ void init_tlbs(void)
 	return ;
 }
 
-#if !defined(CONFIG_NAND_SPL) && !defined(CONFIG_SPL_BUILD)
+#if !defined(CONFIG_NAND_SPL) && !defined(CONFIG_SPL_BUILD_MINIMAL)
 void read_tlbcam_entry(int idx, u32 *valid, u32 *tsize, unsigned  
 long *epn,
 		       phys_addr_t *rpn)
Quoted 1 line

{

Aren't you breaking the existing minimal targets? CONFIG_SPL_BUILD_MINIMAL does not currently exist, and you add it only for P1022DS.

Quoted 6 lines
arch/powerpc/cpu/mpc85xx/u-boot-spl.lds +0 -0
index f2b7bff..f1a9ac9 100644

arch/powerpc/cpu/mpc85xx/u-boot-spl.lds line 35

Quoted 10 lines
arch/powerpc/cpu/mpc85xx/u-boot-spl.lds +7 -0
@@ -26,6 +26,13 @@
 #include "config.h"	/* CONFIG_BOARDDIR */
 
 OUTPUT_ARCH(powerpc)
+#ifdef CONFIG_SYS_MPC85XX_NO_RESETVEC
+PHDRS
+{
+  text PT_LOAD;
+  bss PT_LOAD;
+}
+#endif

Whitespace.

Quoted 9 lines
arch/powerpc/cpu/mpc85xx/u-boot-spl.lds +5 -0
@@ -68,9 +80,21 @@ SECTIONS
 #else
 #error unknown NAND controller
 #endif
+
+#ifndef CONFIG_FSL_IFC
+#ifdef CONFIG_SYS_MPC85XX_NO_RESETVEC
+	.bootpg ADDR(.text) - 0x1000 :
+	{

arch/powerpc/cpu/mpc85xx/u-boot-spl.lds SECTIONS · line 97

Quoted 10 lines
arch/powerpc/cpu/mpc85xx/u-boot-spl.lds +7 -0
+		KEEP(*(.bootpg))
+	} :text = 0xffff
+#endif
+#endif
+
+#ifndef CONFIG_SYS_MPC85XX_NO_RESETVEC
 	.resetvec ADDR(.text) + RESET_VECTOR_OFFSET : {
 		KEEP(*(.resetvec))
 	} = 0xffff
+#endif

Get rid of the IFC ifdef -- this should apply equally well to IFC.

Can you make the "no resetvec" stuff a separate patch?

arch/powerpc/cpu/mpc85xx/u-boot-spl.lds SECTIONS · line 112

Quoted 7 lines
arch/powerpc/cpu/mpc85xx/u-boot-spl.lds +1 -0
@@ -83,5 +107,6 @@ SECTIONS
 		*(.sbss*)
 		*(.bss*)
 	}
+	. = ALIGN(4);
 	__bss_end = .;
 }

This seems unrelated.

Quoted 44 lines
board/freescale/common/sdhc_boot.c +1 -0
index e432318..96b0680 100644
@@ -24,6 +24,7 @@
 #include <mmc.h>
 #include <malloc.h>
 
+DECLARE_GLOBAL_DATA_PTR;
 /*
  * The environment variables are written to just after the u-boot  

image
* on SDCard, so we must read the MBR to get the start address and
code

board/freescale/common/sdhc_boot.c +17 -0
@@ -31,6 +32,9 @@
  */
 #define ESDHC_BOOT_IMAGE_SIZE	0x48
 #define ESDHC_BOOT_IMAGE_ADDR	0x50
+#define ESDHC_BOOT_IMAGE_SIGN   0x55AA
+#define ESDHC_BOOT_IMAGE_SIGN_ADDR      0x1FE
+#define CONFIG_CFG_DATA_SECTOR  0
 
 int mmc_get_env_addr(struct mmc *mmc, u32 *env_addr)
 {
@@ -61,3 +65,122 @@ int mmc_get_env_addr(struct mmc *mmc, u32  
 *env_addr)
 
 	return 0;
 }
+
+#ifdef CONFIG_SPL_BUILD
+void mmc_get_env(void)
+{
+	/* load environment */
+	struct mmc *mmc;
+	int err;
+	u32 offset;
+	uint blk_start, blk_cnt, ret;
+
+	mmc_initialize(gd->bd);
+	/* We register only one device. So, the dev id is always 0 */
+	mmc = find_mmc_device(0);
+	if (!mmc) {

board/freescale/common/sdhc_boot.c int mmc_get_env_addr(struct mmc *mmc, u32 · line 91

Quoted 10 lines
board/freescale/common/sdhc_boot.c +10 -0
+		puts("spl: mmc device not found!!\n");
+		hang();
+	}
+	err = mmc_init(mmc);
+	if (err) {
+		puts("spl: mmc init failed!");
+		hang();
+	}
+	if (1 == mmc_get_env_addr(mmc, &offset))
+		puts("spl: mmc get env error!!\n");

Constants go on the right hand side of comparisons.

board/freescale/common/sdhc_boot.c int mmc_get_env_addr(struct mmc *mmc, u32 *env_addr) · line 144

Quoted 5 lines
board/freescale/common/sdhc_boot.c +5 -0
+	val = *(u16 *)(tmp_buf + ESDHC_BOOT_IMAGE_SIGN_ADDR);
+	if ((u16)ESDHC_BOOT_IMAGE_SIGN != val) {
+		free(tmp_buf);
+		return;
+	}

Why do you need this cast?

board/freescale/common/sdhc_boot.c

Quoted 13 lines
board/freescale/common/sdhc_boot.c +10 -0
+	offset = *(u32 *)(tmp_buf + ESDHC_BOOT_IMAGE_ADDR);
+	offset += CONFIG_SYS_MMC_U_BOOT_OFFS;
+	/* Get the code size from offset 0x48 */
+	code_len = *(u32 *)(tmp_buf + ESDHC_BOOT_IMAGE_SIZE);
+	code_len -= CONFIG_SYS_MMC_U_BOOT_OFFS;
+	/*
+	 * Load U-Boot image from mmc into RAM
+	*/
+	/*
+	SDHC card: code offset and length is stored in block units  

rather

board/freescale/common/sdhc_boot.c +2 -0
+	* than a single byte
+	*/

/*
* U-Boot multiline
* comment style is
* like this.
*/

board/freescale/common/sdhc_boot.c int mmc_get_env_addr(struct mmc *mmc, u32 *env_addr) · line 168

Quoted 12 lines
board/freescale/common/sdhc_boot.c +5 -0
+	blk_start = ALIGN(offset, mmc->read_bl_len) / mmc->read_bl_len;
+	blk_cnt = ALIGN(code_len, mmc->read_bl_len) / mmc->read_bl_len;
+
+	err = mmc->block_dev.block_read(0, blk_start, blk_cnt,
+					(uchar  

*)CONFIG_SYS_MMC_U_BOOT_DST);

board/freescale/common/sdhc_boot.c +6 -0
+	if (err != blk_cnt) {
+		free(tmp_buf);
+		return ;
+	}
+}
+void mmc_boot(void)

No space before ;

That return is pointless since you're at the end of the function anyway.

Please put a blank line between functions.

Quoted 25 lines
board/freescale/common/sdhc_boot.h new file +18 -0
new file mode 100644
index 0000000..2b5dcb9
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2011 Freescale Semiconductor, Inc.
+ *
+ * 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
+ */

board/freescale/common/sdhc_boot.h line 28

Quoted 10 lines
board/freescale/common/sdhc_boot.h new file +10 -0
+
+#ifndef __SDHC_BOOT_H_
+#define __SDHC_BOOT_H_    1
+
+
+int mmc_get_env_addr(struct mmc *mmc, u32 *env_addr);
+void mmc_get_env(void);
+void mmc_boot(void);
+
+#endif  /* __SDHC_BOOT_H_ */

Does this stuff really belong in board/freescale? Should probably at least be in arch/powerpc/cpu/mpc85xx, if not more generic.

Quoted 6 lines
board/freescale/common/sdhc_boot.h new file +6 -0
+#include <common.h>
+#include <ns16550.h>
+#include <nand.h>
+#include <asm/fsl_law.h>
+#include <asm/fsl_ddr_sdram.h>
+#include <malloc.h>

board/freescale/common/sdhc_boot.h

Quoted 10 lines
board/freescale/common/sdhc_boot.h new file +10 -0
+#ifdef CONFIG_SDCARD
+#include <mmc.h>
+#include <i2c.h>
+#include "../common/sdhc_boot.h"
+#endif
+#ifdef CONFIG_SPIFLASH
+#include <i2c.h>
+#include "../common/ngpixis.h"
+#include "../common/spi_boot.h"
+#endif

Don't ifdef includes.

Don't use boards.cfg-defined config symbols outside the board config header, unless they're proper U-Boot config symbols which requires better
naming, and documentation in README.

board/freescale/common/sdhc_boot.h

Quoted 6 lines
board/freescale/common/sdhc_boot.h new file +6 -0
+void hang(void)
+{
+	puts("### ERROR ### Please RESET the board ###\n");
+	for (;;)
+		;
+}

Whitespace

Quoted 35 lines
board/freescale/common/sdhc_boot.h new file +31 -0
+ulong get_effective_memsize(void)
+{
+	return CONFIG_SYS_L2_SIZE;
+}
+
+void board_init_f(ulong bootflag)
+{
+	int px_spd;
+	u32 plat_ratio, sys_clk, bus_clk;
+	ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
+
+	console_init_f();
+
+#if defined(CONFIG_SDCARD) || defined(CONFIG_SPIFLASH)
+	/* Set pmuxcr to allow both i2c1 and i2c2 */
+	setbits_be32(&gur->pmuxcr, in_be32(&gur->pmuxcr) | 0x1000);
+	setbits_be32(&gur->pmuxcr,
+		in_be32(&gur->pmuxcr) | MPC85xx_PMUXCR_SD_DATA);
+
+#ifdef CONFIG_SPIFLASH
+	/* Enable the SPI */
+	clrsetbits_8(&pixis->brdcfg0, PIXIS_ELBC_SPI_MASK, PIXIS_SPI);
+#endif
+	/* Read back the register to synchronize the write. */
+	in_be32(&gur->pmuxcr);
+#endif
+
+	/* initialize selected port with appropriate baud rate */
+	px_spd = in_8((unsigned char *)(PIXIS_BASE + PIXIS_SPD));
+	sys_clk = sysclk_tbl[px_spd & PIXIS_SPD_SYSCLK_MASK];
+	plat_ratio = in_be32(&gur->porpllsr) &  

MPC85xx_PORPLLSR_PLAT_RATIO;

board/freescale/common/sdhc_boot.h new file +3 -0
+	bus_clk = sys_clk * plat_ratio / 2;
+
+	NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1,

board/freescale/common/sdhc_boot.h

Quoted 10 lines
board/freescale/common/sdhc_boot.h new file +10 -0
+			bus_clk / 16 / CONFIG_BAUDRATE);
+#ifdef CONFIG_SDCARD
+	puts("\nSD boot...\n");
+#endif
+#ifdef CONFIG_NAND
+	puts("\nNAND boot...\n");
+#endif
+#ifdef CONFIG_SPIFLASH
+	puts("\nSPI Flash boot...\n");
+#endif

Is NAND handled by this file? Isn't this on top of the patch that already adds NAND boot support? I don't see this print being removed from somewhere else.

common/Makefile COBJS-$(CONFIG_SPL_NET_SUPPORT) += env_common.o · line 232

Quoted 13 lines
common/Makefile +5 -0
index 0e0fff1..bc80414 100644
@@ -225,6 +225,11 @@ COBJS-$(CONFIG_SPL_NET_SUPPORT) += env_common.o
 COBJS-$(CONFIG_SPL_NET_SUPPORT) += env_flags.o
 COBJS-$(CONFIG_SPL_NET_SUPPORT) += env_nowhere.o
 COBJS-$(CONFIG_SPL_NET_SUPPORT) += miiphyutil.o
+COBJS-$(CONFIG_SPL_HWCONFIG_SUPPORT) += hwconfig.o
+COBJS-$(CONFIG_SPL_INIT_DDR_SUPPORT) += ddr_spd.o
+COBJS-$(CONFIG_SPL_ENV_SUPPORT) += env_attr.o
+COBJS-$(CONFIG_SPL_ENV_SUPPORT) += env_flags.o
+COBJS-$(CONFIG_SPL_ENV_SUPPORT) += env_callback.o

CONFIG_SPL_ENV_SUPPORT should replace CONFIG_SPL_NET_SUPPORT here (and add it to the boards that already have CONFIG_SPL_NET_SUPPORT). This sort of refactoring needs to be a separate patch, BTW.

Can ddr_spd.o and hwconfig just use their normal CONFIG symbols (i.e. move the existing makefile line out of the !SPL ifdef)? It's getting a bit excessive with all the new SPL symbols.

Maybe one day we can redo it to be a separate config namespace, like I suggested a while ago. :-P It would certainly help with three-stage boot
support.

Quoted 64 lines
common/Makefile +0 -0
 endif
 COBJS-$(CONFIG_BOUNCE_BUFFER) += bouncebuf.o
 COBJS-y += console.o
doc/README.mpc85xx-sd-spi-boot new file +5 -0
new file mode 100644
index 0000000..79f91fc
@@ -0,0 +1,82 @@
+----------------------------------------
+Booting from On-Chip ROM (eSDHC or eSPI)
+----------------------------------------
+
+boot_format is a tool to write SD bootable images to a filesystem  

and build

doc/README.mpc85xx-sd-spi-boot new file +3 -0
+SD/SPI images to a binary file for writing later.
+
+When booting from an SD card/MMC, boot_format puts the configuration  

file and

doc/README.mpc85xx-sd-spi-boot new file +2 -0
+the RAM-based U-Boot image on the card.
+When booting from an EEPROM, boot_format generates a binary image  

that is used

doc/README.mpc85xx-sd-spi-boot new file +19 -0
+to boot from this EEPROM.
+
+Where to get boot_format:
+========================
+
+you can browse it online at:
+http://git.freescale.com/git/cgit.cgi/ppc/sdk/boot-format.git/
+
+Building
+========
+
+Run the following to build this project
+
+	$ make
+
+Execution
+=========
+
+boot_format runs under a regular Linux machine and requires a super  

user mode

doc/README.mpc85xx-sd-spi-boot new file +3 -0
+to run. Execute boot_format as follows.
+
+For building SD images by writing directly to a file system on SD  

media:

doc/README.mpc85xx-sd-spi-boot new file +4 -0
+
+	$ boot_format $config u-boot.bin -sd $device
+
+Where $config is the included config.dat file for your platform and  

$device

doc/README.mpc85xx-sd-spi-boot new file +7 -0
+is the target block device for the SD media on your computer.
+
+For build binary images directly a local file:
+
+	$ boot_format $config u-boot.bin -spi $file
+
+Where $file is the target file. Also keep in mind the u-boot.bin  

file needs

doc/README.mpc85xx-sd-spi-boot new file +3 -0
+to be the u-boot built for your particular platform and target media.
+
+Hint: To generate a u-boot.bin for a P1022DS booting from SD I would  

run the

doc/README.mpc85xx-sd-spi-boot line 49

Quoted 3 lines
doc/README.mpc85xx-sd-spi-boot new file +3 -0
+following in the u-boot repository:
+
+	$ make P1022DS_SDCARD

s/Hint/Example/ and s/from SD I would run/from SD, run/

Quoted 5 lines
lib/Makefile +0 -0
index e901cc7..ab12e63 100644

lib/Makefile endif · line 74

Quoted 9 lines
lib/Makefile +4 -0
@@ -66,6 +66,11 @@ endif
 COBJS-$(CONFIG_SPL_NET_SUPPORT) += errno.o
 COBJS-$(CONFIG_SPL_NET_SUPPORT) += hashtable.o
 COBJS-$(CONFIG_SPL_NET_SUPPORT) += net_utils.o
+COBJS-$(CONFIG_SPL_ADDR_MAP_SUPPORT) += addr_map.o
 
 
+COBJS-$(CONFIG_SPL_UTILITYLIB_SUPPORT) += hashtable.o
+COBJS-$(CONFIG_SPL_UTILITYLIB_SUPPORT) += display_options.o
+COBJS-$(CONFIG_SPL_UTILITYLIB_SUPPORT) += errno.o

As with common/Makefile, Can these just be the normal makefile lines, moved outside the SPL ifdef (and no duplications with CONFIG_SPL_NET_SUPPORT)?

spl/Makefile LIBS-y += arch/powerpc/cpu/mpc8xxx/lib8xxx.o · line 56

Quoted 11 lines
spl/Makefile +3 -0
index b5a8de7..3a3b868 100644
@@ -51,6 +51,9 @@ LIBS-y += arch/powerpc/cpu/mpc8xxx/lib8xxx.o
 endif
 ifeq ($(CPU),mpc85xx)
 LIBS-y += arch/powerpc/cpu/mpc8xxx/lib8xxx.o
+ifdef CONFIG_SPL_INIT_DDR_SUPPORT
+LIBS-y += arch/powerpc/cpu/mpc8xxx/ddr/libddr.o
+endif

Why isn't this handled as part of lib8xxx.o? We should avoid putting hardware-specific things in generic Makefiles. There ones that are already there should be fixed at some point.

-Scott

#2 lore raw

PATCH 1/1 powerpc/p1022ds: boot from SD card/SPI flash with SPL

This patch needs to be broken into several patches that each take care of one logical problem; it's too hard to properly review (and have the right people pay attention to certain parts) in its current state. [Zhang Ying]
It only can be broken to two patches, one for SD boot, another for SPI boot.

Quoted 13 lines
(quoted diff) +0 -0

b/arch/powerpc/cpu/mpc85xx/tlb.c index 0dff37f..d21b324 100644

arch/powerpc/cpu/mpc85xx/tlb.c +1 -1
@@ -55,7 +55,7 @@ void init_tlbs(void)
 	return ;
 }
 
-#if !defined(CONFIG_NAND_SPL) && !defined(CONFIG_SPL_BUILD)
+#if !defined(CONFIG_NAND_SPL) && !defined(CONFIG_SPL_BUILD_MINIMAL)
 void read_tlbcam_entry(int idx, u32 *valid, u32 *tsize, unsigned long 
 *epn,
 		       phys_addr_t *rpn)
Quoted 1 line

{

Aren't you breaking the existing minimal targets?
CONFIG_SPL_BUILD_MINIMAL does not currently exist, and you add it only for P1022DS.
[Zhang Ying]
Yes, it needs to be added for other existing boards that defines CONFIG_SPL_INIT_MINIMAL. It should include p1_p2_rdb_pc.

arch/powerpc/cpu/mpc85xx/tlb.c SECTIONS · line 112

Quoted 7 lines
arch/powerpc/cpu/mpc85xx/tlb.c +1 -0
@@ -83,5 +107,6 @@ SECTIONS
 		*(.sbss*)
 		*(.bss*)
 	}
+	. = ALIGN(4);
 	__bss_end = .;
 }

This seems unrelated.
[Zhang Ying]
It is necessary. In the function clear_bss(), the address of bss is on the basis of the __bss_start, and then to four bytes of incremental growth, finally the last stop is based on the address and __bss_end is equal or not.

board/freescale/common/sdhc_boot.c int mmc_get_env_addr(struct mmc *mmc, u32 *env_addr) · line 144

Quoted 11 lines
board/freescale/common/sdhc_boot.c +5 -0
index e432318..96b0680 100644
 
+	val = *(u16 *)(tmp_buf + ESDHC_BOOT_IMAGE_SIGN_ADDR);
+	if ((u16)ESDHC_BOOT_IMAGE_SIGN != val) {
+		free(tmp_buf);
+		return;
+	}

Why do you need this cast?
[Zhang Ying]
The offset 0x1FE of the config data sector should contain the value 0x55AA. If the value in this location doesn't match 0x55AA, it means that the SD/MMC card doesn't contain a valid user code.

board/freescale/common/sdhc_boot.c

Quoted 13 lines
board/freescale/common/sdhc_boot.c +10 -0
+	offset = *(u32 *)(tmp_buf + ESDHC_BOOT_IMAGE_ADDR);
+	offset += CONFIG_SYS_MMC_U_BOOT_OFFS;
+	/* Get the code size from offset 0x48 */
+	code_len = *(u32 *)(tmp_buf + ESDHC_BOOT_IMAGE_SIZE);
+	code_len -= CONFIG_SYS_MMC_U_BOOT_OFFS;
+	/*
+	 * Load U-Boot image from mmc into RAM
+	*/
+	/*
+	SDHC card: code offset and length is stored in block units

rather

board/freescale/common/sdhc_boot.c +2 -0
+	* than a single byte
+	*/

/*
* U-Boot multiline
* comment style is
* like this.
*/

board/freescale/common/sdhc_boot.c int mmc_get_env_addr(struct mmc *mmc, u32 *env_addr) · line 168

Quoted 12 lines
board/freescale/common/sdhc_boot.c +5 -0
+	blk_start = ALIGN(offset, mmc->read_bl_len) / mmc->read_bl_len;
+	blk_cnt = ALIGN(code_len, mmc->read_bl_len) / mmc->read_bl_len;
+
+	err = mmc->block_dev.block_read(0, blk_start, blk_cnt,
+					(uchar

*)CONFIG_SYS_MMC_U_BOOT_DST);

board/freescale/common/sdhc_boot.c +6 -0
+	if (err != blk_cnt) {
+		free(tmp_buf);
+		return ;
+	}
+}
+void mmc_boot(void)

No space before ;

That return is pointless since you're at the end of the function anyway. [Zhang Ying]
Ok, I can hang the cpu and print the error information.

Quoted 6 lines

+ *
+ * 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
+ */

board/freescale/common/sdhc_boot.c

Quoted 9 lines
board/freescale/common/sdhc_boot.c +9 -0
+
+#ifndef __SDHC_BOOT_H_
+#define __SDHC_BOOT_H_    1
+
+
+int mmc_get_env_addr(struct mmc *mmc, u32 *env_addr); void 
+mmc_get_env(void); void mmc_boot(void);
+
+#endif  /* __SDHC_BOOT_H_ */

Does this stuff really belong in board/freescale? Should probably at least be in arch/powerpc/cpu/mpc85xx, if not more generic.
[Zhang Ying]
Ok, whether we can handle like this: sdhc_boot.c and spi_boot.c will be deleted. All this stuff in the sdhc_boot.c will be moved to drivers/mmc/fsl_esdhc.c, and the functions in the spi_boot.c will be moved to drivers/mmc/fsl_espi.c.

board/freescale/common/sdhc_boot.c

Quoted 6 lines
board/freescale/common/sdhc_boot.c +6 -0
+void hang(void)
+{
+	puts("### ERROR ### Please RESET the board ###\n");
+	for (;;)
+		;
+}

Whitespace
[Zhang Ying]
?

common/Makefile COBJS-$(CONFIG_SPL_NET_SUPPORT) += env_common.o · line 232

Quoted 13 lines
common/Makefile index 0e0fff1..bc80414 renamed from common/Makefile +0 -0

100644

common/Makefile +5 -0
@@ -225,6 +225,11 @@ COBJS-$(CONFIG_SPL_NET_SUPPORT) += env_common.o
 COBJS-$(CONFIG_SPL_NET_SUPPORT) += env_flags.o
 COBJS-$(CONFIG_SPL_NET_SUPPORT) += env_nowhere.o
 COBJS-$(CONFIG_SPL_NET_SUPPORT) += miiphyutil.o
+COBJS-$(CONFIG_SPL_HWCONFIG_SUPPORT) += hwconfig.o
+COBJS-$(CONFIG_SPL_INIT_DDR_SUPPORT) += ddr_spd.o
+COBJS-$(CONFIG_SPL_ENV_SUPPORT) += env_attr.o
+COBJS-$(CONFIG_SPL_ENV_SUPPORT) += env_flags.o
+COBJS-$(CONFIG_SPL_ENV_SUPPORT) += env_callback.o

CONFIG_SPL_ENV_SUPPORT should replace CONFIG_SPL_NET_SUPPORT here (and add it to the boards that already have CONFIG_SPL_NET_SUPPORT). This sort of refactoring needs to be a separate patch, BTW.

Can ddr_spd.o and hwconfig just use their normal CONFIG symbols (i.e.
move the existing makefile line out of the !SPL ifdef)? It's getting a bit excessive with all the new SPL symbols. [Zhang Ying]
If do it, the SPL's size will increase. I fear this will affect the other SPL no CONFIG_SPL_NET_SUPPORT is defined.

Maybe one day we can redo it to be a separate config namespace, like I suggested a while ago. :-P It would certainly help with three-stage boot support.

Quoted 62 lines
common/Makefile +0 -0
 endif
 COBJS-$(CONFIG_BOUNCE_BUFFER) += bouncebuf.o  COBJS-y += console.o 
(quoted diff) +0 -0

b/doc/README.mpc85xx-sd-spi-boot new file mode 100644 index 0000000..79f91fc

doc/README.mpc85xx-sd-spi-boot new file +5 -0
@@ -0,0 +1,82 @@
+----------------------------------------
+Booting from On-Chip ROM (eSDHC or eSPI)
+----------------------------------------
+
+boot_format is a tool to write SD bootable images to a filesystem

and build

doc/README.mpc85xx-sd-spi-boot new file +3 -0
+SD/SPI images to a binary file for writing later.
+
+When booting from an SD card/MMC, boot_format puts the configuration

file and

doc/README.mpc85xx-sd-spi-boot new file +2 -0
+the RAM-based U-Boot image on the card.
+When booting from an EEPROM, boot_format generates a binary image

that is used

doc/README.mpc85xx-sd-spi-boot new file +19 -0
+to boot from this EEPROM.
+
+Where to get boot_format:
+========================
+
+you can browse it online at:
+http://git.freescale.com/git/cgit.cgi/ppc/sdk/boot-format.git/
+
+Building
+========
+
+Run the following to build this project
+
+	$ make
+
+Execution
+=========
+
+boot_format runs under a regular Linux machine and requires a super

user mode

doc/README.mpc85xx-sd-spi-boot new file +3 -0
+to run. Execute boot_format as follows.
+
+For building SD images by writing directly to a file system on SD

media:

doc/README.mpc85xx-sd-spi-boot new file +4 -0
+
+	$ boot_format $config u-boot.bin -sd $device
+
+Where $config is the included config.dat file for your platform and

$device

doc/README.mpc85xx-sd-spi-boot new file +7 -0
+is the target block device for the SD media on your computer.
+
+For build binary images directly a local file:
+
+	$ boot_format $config u-boot.bin -spi $file
+
+Where $file is the target file. Also keep in mind the u-boot.bin

file needs

doc/README.mpc85xx-sd-spi-boot new file +3 -0
+to be the u-boot built for your particular platform and target media.
+
+Hint: To generate a u-boot.bin for a P1022DS booting from SD I would

run the

doc/README.mpc85xx-sd-spi-boot line 49

Quoted 3 lines
doc/README.mpc85xx-sd-spi-boot new file +3 -0
+following in the u-boot repository:
+
+	$ make P1022DS_SDCARD

s/Hint/Example/ and s/from SD I would run/from SD, run/
[Zhang Ying]
run bootsd? This is another independent requirement. If we want, we can do it in another project.

lib/Makefile endif · line 74

Quoted 13 lines
lib/Makefile +4 -0
@@ -66,6 +66,11 @@ endif
 COBJS-$(CONFIG_SPL_NET_SUPPORT) += errno.o
 COBJS-$(CONFIG_SPL_NET_SUPPORT) += hashtable.o
 COBJS-$(CONFIG_SPL_NET_SUPPORT) += net_utils.o
+COBJS-$(CONFIG_SPL_ADDR_MAP_SUPPORT) += addr_map.o
 
 
+COBJS-$(CONFIG_SPL_UTILITYLIB_SUPPORT) += hashtable.o
+COBJS-$(CONFIG_SPL_UTILITYLIB_SUPPORT) += display_options.o
+COBJS-$(CONFIG_SPL_UTILITYLIB_SUPPORT) += errno.o

As with common/Makefile, Can these just be the normal makefile lines, moved outside the SPL ifdef (and no duplications with CONFIG_SPL_NET_SUPPORT)? [Zhang Ying]
Mentioned.

-Scott

#3 lore raw

PATCH 1/1 powerpc/p1022ds: boot from SD card/SPI flash with SPL

Quoted 10 lines · On 05/10/2013 03:44:29 AM, Zhang Ying-B40530 wrote:

This patch needs to be broken into several patches that each take care of one logical problem; it's too hard to properly review (and have the right people pay attention to certain parts) in its current state.
[Zhang Ying]
It only can be broken to two patches, one for SD boot, another for SPI boot.

You can also separate out logical changes in support of your eventual goal (as it looks like you already started doing with the CONFIG_SPL_ENV_SUPPORT patch and such).

Quoted 6 lines
Quoted 6 lines
arch/powerpc/cpu/mpc85xx/u-boot-spl.lds +1 -0
@@ -83,5 +107,6 @@ SECTIONS
 		*(.sbss*)
 		*(.bss*)
 	}
+	. = ALIGN(4);
 	__bss_end = .;
Quoted 8 lines

Review SECTIONS · line 112

Quoted 1 line
(quoted diff) +0 -0
 }

This seems unrelated.
[Zhang Ying]
It is necessary. In the function clear_bss(), the address of bss is on the basis of the __bss_start, and then to four bytes of incremental growth, finally the last stop is based on the address and __bss_end is equal or not.

It may be necessary, but I don't see what it has to do with SD/SPI boot other than by chance. Make this a separate patch with a changelog that explains the problem.

Quoted 6 lines
Quoted 5 lines
board/freescale/common/sdhc_boot.c +0 -0
index e432318..96b0680 100644
Quoted 11 lines

board/freescale/common/sdhc_boot.c int mmc_get_env_addr(struct mmc *mmc, u32 *env_addr) · line 144

Quoted 5 lines
board/freescale/common/sdhc_boot.c +5 -0
+	val = *(u16 *)(tmp_buf + ESDHC_BOOT_IMAGE_SIGN_ADDR);
+	if ((u16)ESDHC_BOOT_IMAGE_SIGN != val) {
+		free(tmp_buf);
+		return;
+	}

Why do you need this cast?
[Zhang Ying]
The offset 0x1FE of the config data sector should contain the value 0x55AA. If the value in this location doesn't match 0x55AA, it means that the SD/MMC card doesn't contain a valid user code.

But why do you need to cast ESDHC_BOOT_IMAGE_SIGN to (u16)?

And the other cast probably violates C99 aliasing rules.

Quoted 17 lines
Quoted 2 lines

+ *
+ * You should have received a copy of the GNU General Public

License

board/freescale/common/sdhc_boot.c

Quoted 13 lines

+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */

board/freescale/common/sdhc_boot.c +9 -0
+
+#ifndef __SDHC_BOOT_H_
+#define __SDHC_BOOT_H_    1
+
+
+int mmc_get_env_addr(struct mmc *mmc, u32 *env_addr); void
+mmc_get_env(void); void mmc_boot(void);
+
+#endif  /* __SDHC_BOOT_H_ */
Quoted 7 lines

Does this stuff really belong in board/freescale? Should probably at least be in arch/powerpc/cpu/mpc85xx, if not more generic. [Zhang Ying]
Ok, whether we can handle like this: sdhc_boot.c and spi_boot.c will be deleted. All this stuff in the sdhc_boot.c will be moved to drivers/mmc/fsl_esdhc.c, and the functions in the spi_boot.c will be moved to drivers/mmc/fsl_espi.c.

Maybe drivers/mmc/fsl_espi_spl.c and such?

Quoted 10 lines

board/freescale/common/sdhc_boot.c

Quoted 6 lines
board/freescale/common/sdhc_boot.c +6 -0
+void hang(void)
+{
+	puts("### ERROR ### Please RESET the board ###\n");
+	for (;;)
+		;
+}

Whitespace
[Zhang Ying]
?

I'm not sure what I meant here. :-P

Maybe I meant to put this comment elsewhere, or trimmed the wrong context...

Quoted 19 lines

common/Makefile index

Quoted 1 line
common/Makefile index renamed from common/Makefile +0 -0

0e0fff1..bc80414

common/Makefile COBJS-$(CONFIG_SPL_NET_SUPPORT) += env_common.o · line 232

Quoted 12 lines

100644

common/Makefile +5 -0
@@ -225,6 +225,11 @@ COBJS-$(CONFIG_SPL_NET_SUPPORT) += env_common.o
 COBJS-$(CONFIG_SPL_NET_SUPPORT) += env_flags.o
 COBJS-$(CONFIG_SPL_NET_SUPPORT) += env_nowhere.o
 COBJS-$(CONFIG_SPL_NET_SUPPORT) += miiphyutil.o
+COBJS-$(CONFIG_SPL_HWCONFIG_SUPPORT) += hwconfig.o
+COBJS-$(CONFIG_SPL_INIT_DDR_SUPPORT) += ddr_spd.o
+COBJS-$(CONFIG_SPL_ENV_SUPPORT) += env_attr.o
+COBJS-$(CONFIG_SPL_ENV_SUPPORT) += env_flags.o
+COBJS-$(CONFIG_SPL_ENV_SUPPORT) += env_callback.o

CONFIG_SPL_ENV_SUPPORT should replace CONFIG_SPL_NET_SUPPORT here (and add it to the boards that already have CONFIG_SPL_NET_SUPPORT). This sort of refactoring needs to be a separate patch, BTW.

Quoted 6 lines

Can ddr_spd.o and hwconfig just use their normal CONFIG symbols (i.e. move the existing makefile line out of the !SPL ifdef)? It's getting a bit excessive with all the new SPL symbols.
[Zhang Ying]
If do it, the SPL's size will increase. I fear this will affect the other SPL no CONFIG_SPL_NET_SUPPORT is defined.

Which SPL in particular are you concerned about, that uses common/Makefile at all, and have CONFIG_SPD and/or CONFIG_HWCONFIG? How much will they grow, after gc-sections (mainly all that's left is anonymous strings)?

Quoted 7 lines
Quoted 3 lines
common/Makefile +1 -0
+Where $file is the target file. Also keep in mind the u-boot.bin

file needs
+to be the u-boot built for your particular platform and target

media.

common/Makefile

Quoted 2 lines
common/Makefile +2 -0
+
+Hint: To generate a u-boot.bin for a P1022DS booting from SD I  

would

Quoted 9 lines

common/Makefile

Quoted 4 lines

run the

common/Makefile +3 -0
+following in the u-boot repository:
+
+	$ make P1022DS_SDCARD

s/Hint/Example/ and s/from SD I would run/from SD, run/ [Zhang Ying]
run bootsd? This is another independent requirement. If we want, we can do it in another project.

Hmm? I was just fixing up the wording -- change "Hint" to "Example" and change "from SD I would run" to "from SD, run".

That said, yes I would like to see "run bootsd". :-)

-Scott

#4 lore raw

PATCH 1/1 powerpc/p1022ds: boot from SD card/SPI flash with SPL

In reply to Scott Wood

spl/Makefile LIBS-y += arch/powerpc/cpu/mpc8xxx/lib8xxx.o · line 56

Quoted 12 lines
spl/Makefile +3 -0
index b5a8de7..3a3b868 100644
@@ -51,6 +51,9 @@ LIBS-y += arch/powerpc/cpu/mpc8xxx/lib8xxx.o
 endif
 ifeq ($(CPU),mpc85xx)
 LIBS-y += arch/powerpc/cpu/mpc8xxx/lib8xxx.o
+ifdef CONFIG_SPL_INIT_DDR_SUPPORT
+LIBS-y += arch/powerpc/cpu/mpc8xxx/ddr/libddr.o
+endif

Why isn't this handled as part of lib8xxx.o? We should avoid putting hardware-specific things in generic Makefiles. There ones that are already there should be fixed at some point.
[Zhang Ying]
Do you mean that all things of the directory " arch/powerpc/cpu/mpc8xxx/ddr " will be moved to the directory "arch/powerpc/cpu/mpc8xxx/"?

#5 lore raw

PATCH 1/1 powerpc/p1022ds: boot from SD card/SPI flash with SPL

Quoted 13 lines · On 05/13/2013 05:17:40 AM, Zhang Ying-B40530 wrote:

spl/Makefile LIBS-y += arch/powerpc/cpu/mpc8xxx/lib8xxx.o · line 56

Quoted 12 lines
spl/Makefile +3 -0
index b5a8de7..3a3b868 100644
@@ -51,6 +51,9 @@ LIBS-y += arch/powerpc/cpu/mpc8xxx/lib8xxx.o
 endif
 ifeq ($(CPU),mpc85xx)
 LIBS-y += arch/powerpc/cpu/mpc8xxx/lib8xxx.o
+ifdef CONFIG_SPL_INIT_DDR_SUPPORT
+LIBS-y += arch/powerpc/cpu/mpc8xxx/ddr/libddr.o
+endif
Quoted 7 lines

Why isn't this handled as part of lib8xxx.o? We should avoid putting hardware-specific things in generic Makefiles. There ones that are already there should be fixed at some point.
[Zhang Ying]
Do you mean that all things of the directory " arch/powerpc/cpu/mpc8xxx/ddr "
will be moved to the directory "arch/powerpc/cpu/mpc8xxx/"?

No. I meant that arch/powerpc/cpu/mpc8xxx/Makefile should contain the LIBS addition for the subdirectory, but apparently it doesn't work that way even in non-SPL. So ignore this; it's more of a future makefile cleanup issue.

-Scott