[U-Boot] [PATCH v4 0/6] Add an SPL to boot the da850evm from SPI

Hi, this is v4 of the last part of my recent patchset
[PATCH v3 00/15] Add an SPL to boot the da850evm from SPI http://lists.denx.de/pipermail/u-boot/2011-November/111182.html
Most of the other parts are already merged, together with this patchset they introduce an SPL for the da850evm to run u-boot directly without the need of a UBL (see doc/README.davinci).
The first patches fix dependencies and introduce a function to load the u-boot image from SPI flash. Patch #4 adds an SPL to the da850evm configuration. Finally, a simple AIS (Application Image Script) is required to start the SPL. This AIS is generated by mkimage. Patch #5 fixes mkimage for building AIS. Finally the last patch introduces a u-boot.ais target in the Makefile.
This patchset applies on top of git://git.denx.de/u-boot-ti.git
Changes for v4: - added documentation for the SPL to doc/README.davinci - split patchset because it got too big - use COBJS-$(CONFIG_SPL_SPI_LOAD) instead of ifdefs in drivers/mtd/spi/Makefile - use __noreturn instead of __attribute__((noreturn)) - added Acked-by
Changes for v3: - removed noise and hardcoded values from drivers/mtd/spi/spi_spl_load.c - replaced $(PAD_TO) in Makefile by $(CONFIG_SPL_MAX_SIZE)
Major changes for v2: - Added code that actually loads u-boot from SPI flash and starts it.
To build run make da850evm_config make u-boot.ais Then program u-boot.ais to the SPI flash on the da850evm.
Best regards, Christian
Cc: Heiko Schocher hs@denx.de Cc: Sandeep Paulraj s-paulraj@ti.com Cc: Tom Rini trini@ti.com
Christian Riesch (6): spl: display_options.o is required for SPI flash support in SPL sf: Add spi_boot() to allow booting from SPI flash in an SPL arm, davinci: Add SPL support for DA850 SoCs arm, da850evm: Add an SPL for SPI boot mkimage: Fix variable length header support arm, davinci: Add support for generating AIS images to the Makefile
.gitignore | 1 + Makefile | 13 ++++ arch/arm/cpu/arm926ejs/davinci/Makefile | 3 +- arch/arm/cpu/arm926ejs/davinci/spl.c | 34 +++++++++++- board/davinci/da8xxevm/da850evm.c | 4 +- board/davinci/da8xxevm/u-boot-spl.lds | 73 +++++++++++++++++++++++ doc/README.SPL | 1 + doc/README.davinci | 9 +++ drivers/mtd/spi/Makefile | 4 + drivers/mtd/spi/spi_spl_load.c | 58 ++++++++++++++++++ include/configs/da850evm.h | 87 +++++++++++++++++++++++++++ include/spi_flash.h | 3 + lib/Makefile | 2 + tools/mkimage.c | 97 ++++++++++++++++--------------- 14 files changed, 338 insertions(+), 51 deletions(-) create mode 100644 board/davinci/da8xxevm/u-boot-spl.lds create mode 100644 drivers/mtd/spi/spi_spl_load.c

Signed-off-by: Christian Riesch christian.riesch@omicron.at Cc: Heiko Schocher hs@denx.de Cc: Mike Frysinger vapier@gentoo.org --- lib/Makefile | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/lib/Makefile b/lib/Makefile index 54708c2..35ba7ff 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -50,6 +50,8 @@ COBJS-$(CONFIG_SHA1) += sha1.o COBJS-$(CONFIG_SHA256) += sha256.o COBJS-y += strmhz.o COBJS-$(CONFIG_RBTREE) += rbtree.o +else +COBJS-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += display_options.o endif
COBJS-y += ctype.o

Signed-off-by: Christian Riesch christian.riesch@omicron.at Cc: Heiko Schocher hs@denx.de Cc: Mike Frysinger vapier@gentoo.org Cc: Scott Wood scottwood@freescale.com --- doc/README.SPL | 1 + drivers/mtd/spi/Makefile | 4 +++ drivers/mtd/spi/spi_spl_load.c | 58 ++++++++++++++++++++++++++++++++++++++++ include/spi_flash.h | 3 ++ 4 files changed, 66 insertions(+), 0 deletions(-) create mode 100644 drivers/mtd/spi/spi_spl_load.c
diff --git a/doc/README.SPL b/doc/README.SPL index 89d24a7..f01a8bd 100644 --- a/doc/README.SPL +++ b/doc/README.SPL @@ -65,3 +65,4 @@ CONFIG_SPL_NAND_SUPPORT (drivers/mtd/nand/libnand.o) CONFIG_SPL_DMA_SUPPORT (drivers/dma/libdma.o) CONFIG_SPL_POST_MEM_SUPPORT (post/drivers/memory.o) CONFIG_SPL_NAND_LOAD (drivers/mtd/nand/nand_spl_load.o) +CONFIG_SPL_SPI_LOAD (drivers/mtd/spi/spi_spl_load.o) diff --git a/drivers/mtd/spi/Makefile b/drivers/mtd/spi/Makefile index 57112af..90f8392 100644 --- a/drivers/mtd/spi/Makefile +++ b/drivers/mtd/spi/Makefile @@ -25,6 +25,10 @@ include $(TOPDIR)/config.mk
LIB := $(obj)libspi_flash.o
+ifdef CONFIG_SPL_BUILD +COBJS-$(CONFIG_SPL_SPI_LOAD) += spi_spl_load.o +endif + COBJS-$(CONFIG_SPI_FLASH) += spi_flash.o COBJS-$(CONFIG_SPI_FLASH_ATMEL) += atmel.o COBJS-$(CONFIG_SPI_FLASH_EON) += eon.o diff --git a/drivers/mtd/spi/spi_spl_load.c b/drivers/mtd/spi/spi_spl_load.c new file mode 100644 index 0000000..1aa30ac --- /dev/null +++ b/drivers/mtd/spi/spi_spl_load.c @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2011 OMICRON electronics GmbH + * + * based on drivers/mtd/nand/nand_spl_load.c + * + * Copyright (C) 2011 + * Heiko Schocher, DENX Software Engineering, hs@denx.de. + * + * 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 + */ + +#include <common.h> +#include <spi_flash.h> + +/* + * The main entry for SPI booting. It's necessary that SDRAM is already + * configured and available since this code loads the main U-Boot image + * from SPI into SDRAM and starts it from there. + */ +void spi_boot(void) +{ + struct spi_flash *flash; + void (*uboot)(void) __noreturn; + + /* + * Load U-Boot image from SPI flash into RAM + */ + + flash = spi_flash_probe(CONFIG_SPL_SPI_BUS, CONFIG_SPL_SPI_CS, + CONFIG_SF_DEFAULT_SPEED, SPI_MODE_3); + if (!flash) { + puts("failed.\n"); + hang(); + } + + spi_flash_read(flash, CONFIG_SYS_SPI_U_BOOT_OFFS, + CONFIG_SYS_SPI_U_BOOT_SIZE, + (void *) CONFIG_SYS_TEXT_BASE); + + /* + * Jump to U-Boot image + */ + uboot = (void *) CONFIG_SYS_TEXT_BASE; + (*uboot)(); +} diff --git a/include/spi_flash.h b/include/spi_flash.h index 2671ab5..9da9062 100644 --- a/include/spi_flash.h +++ b/include/spi_flash.h @@ -25,6 +25,7 @@
#include <spi.h> #include <linux/types.h> +#include <linux/compiler.h>
struct spi_flash { struct spi_slave *spi; @@ -68,4 +69,6 @@ static inline int spi_flash_erase(struct spi_flash *flash, u32 offset, return flash->erase(flash, offset, len); }
+void spi_boot(void) __noreturn; + #endif /* _SPI_FLASH_H_ */

Acked-by: Mike Frysinger vapier@gentoo.org -mike

This code adds an SPL for booting from SPI flash on DA850 SoCs.
Signed-off-by: Christian Riesch christian.riesch@omicron.at Cc: Heiko Schocher hs@denx.de Cc: Sandeep Paulraj s-paulraj@ti.com Cc: Tom Rini trini@ti.com --- arch/arm/cpu/arm926ejs/davinci/Makefile | 3 +- arch/arm/cpu/arm926ejs/davinci/spl.c | 34 ++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/arch/arm/cpu/arm926ejs/davinci/Makefile b/arch/arm/cpu/arm926ejs/davinci/Makefile index 5ae89df..da7efac 100644 --- a/arch/arm/cpu/arm926ejs/davinci/Makefile +++ b/arch/arm/cpu/arm926ejs/davinci/Makefile @@ -38,7 +38,8 @@ COBJS-$(CONFIG_DRIVER_TI_EMAC) += lxt972.o dp83848.o et1011c.o ksz8873.o
ifdef CONFIG_SPL_BUILD COBJS-y += spl.o -COBJS-y += dm365_lowlevel.o +COBJS-$(CONFIG_SOC_DM365) += dm365_lowlevel.o +COBJS-$(CONFIG_SOC_DA8XX) += da850_lowlevel.o endif
SOBJS = reset.o diff --git a/arch/arm/cpu/arm926ejs/davinci/spl.c b/arch/arm/cpu/arm926ejs/davinci/spl.c index d9b9398..20f798e 100644 --- a/arch/arm/cpu/arm926ejs/davinci/spl.c +++ b/arch/arm/cpu/arm926ejs/davinci/spl.c @@ -26,6 +26,16 @@ #include <nand.h> #include <asm/arch/dm365_lowlevel.h> #include <ns16550.h> +#include <malloc.h> +#include <spi_flash.h> + +DECLARE_GLOBAL_DATA_PTR; + +/* Define global data structure pointer to it*/ +static gd_t gdata __attribute__ ((section(".data"))); +static bd_t bdata __attribute__ ((section(".data"))); + +#ifndef CONFIG_SPL_LIBCOMMON_SUPPORT
void puts(const char *str) { @@ -41,6 +51,8 @@ void putc(char c) NS16550_putc((NS16550_t)(CONFIG_SYS_NS16550_COM1), c); }
+#endif /* CONFIG_SPL_LIBCOMMON_SUPPORT */ + inline void hang(void) { puts("### ERROR ### Please RESET the board ###\n"); @@ -50,14 +62,34 @@ inline void hang(void)
void board_init_f(ulong dummy) { +#ifdef CONFIG_SOC_DM365 dm36x_lowlevel_init(0); +#endif +#ifdef CONFIG_SOC_DA8XX + arch_cpu_init(); +#endif relocate_code(CONFIG_SPL_STACK, NULL, CONFIG_SPL_TEXT_BASE); }
void board_init_r(gd_t *id, ulong dummy) { - +#ifdef CONFIG_SOC_DM365 nand_init(); puts("Nand boot...\n"); nand_boot(); +#endif +#ifdef CONFIG_SOC_DA8XX + mem_malloc_init(CONFIG_SYS_TEXT_BASE - CONFIG_SYS_MALLOC_LEN, + CONFIG_SYS_MALLOC_LEN); + + gd = &gdata; + gd->bd = &bdata; + gd->flags |= GD_FLG_RELOC; + gd->baudrate = CONFIG_BAUDRATE; + serial_init(); /* serial communications setup */ + gd->have_console = 1; + + puts("SPI boot...\n"); + spi_boot(); +#endif }

On 12/02/2011 09:12 AM, Christian Riesch wrote:
This code adds an SPL for booting from SPI flash on DA850 SoCs.
Acked-by: Tom Rini trini@ti.com
And, part of my TODO SPL merge for DaVinci/OMAP(ish) is to put the more raw puts/putc into another file I guess for !LIBCOMMON

Signed-off-by: Christian Riesch christian.riesch@omicron.at Cc: Heiko Schocher hs@denx.de Cc: Sandeep Paulraj s-paulraj@ti.com Cc: Tom Rini trini@ti.com Cc: Sudhakar Rajashekhara sudhakar.raj@ti.com --- board/davinci/da8xxevm/da850evm.c | 4 +- board/davinci/da8xxevm/u-boot-spl.lds | 73 +++++++++++++++++++++++++++ doc/README.davinci | 9 +++ include/configs/da850evm.h | 87 +++++++++++++++++++++++++++++++++ 4 files changed, 172 insertions(+), 1 deletions(-) create mode 100644 board/davinci/da8xxevm/u-boot-spl.lds
diff --git a/board/davinci/da8xxevm/da850evm.c b/board/davinci/da8xxevm/da850evm.c index e827256..8e66c35 100644 --- a/board/davinci/da8xxevm/da850evm.c +++ b/board/davinci/da8xxevm/da850evm.c @@ -108,7 +108,7 @@ static const struct pinmux_config gpio_pins[] = { #endif };
-static const struct pinmux_resource pinmuxes[] = { +const struct pinmux_resource pinmuxes[] = { #ifdef CONFIG_DRIVER_TI_EMAC PINMUX_ITEM(emac_pins_mdio), #ifdef CONFIG_DRIVER_TI_EMAC_USE_RMII @@ -135,6 +135,8 @@ static const struct pinmux_resource pinmuxes[] = { PINMUX_ITEM(gpio_pins), };
+const int pinmuxes_size = ARRAY_SIZE(pinmuxes); + static const struct lpsc_resource lpsc[] = { { DAVINCI_LPSC_AEMIF }, /* NAND, NOR */ { DAVINCI_LPSC_SPI1 }, /* Serial Flash */ diff --git a/board/davinci/da8xxevm/u-boot-spl.lds b/board/davinci/da8xxevm/u-boot-spl.lds new file mode 100644 index 0000000..6f6e065 --- /dev/null +++ b/board/davinci/da8xxevm/u-boot-spl.lds @@ -0,0 +1,73 @@ +/* + * (C) Copyright 2002 + * Gary Jennejohn, DENX Software Engineering, garyj@denx.de + * + * (C) Copyright 2008 + * Guennadi Liakhovetki, DENX Software Engineering, lg@denx.de + * + * 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 + */ + +MEMORY { .sram : ORIGIN = CONFIG_SPL_TEXT_BASE,\ + LENGTH = CONFIG_SPL_MAX_SIZE } + +OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") +OUTPUT_ARCH(arm) +ENTRY(_start) +SECTIONS +{ + . = 0x00000000; + + . = ALIGN(4); + .text : + { + __start = .; + arch/arm/cpu/arm926ejs/start.o (.text) + *(.text*) + } >.sram + + . = ALIGN(4); + .rodata : { *(SORT_BY_ALIGNMENT(.rodata*)) } >.sram + + . = ALIGN(4); + .data : { *(SORT_BY_ALIGNMENT(.data*)) } >.sram + . = ALIGN(4); + .rel.dyn : { + __rel_dyn_start = .; + *(.rel*) + __rel_dyn_end = .; + } >.sram + + .dynsym : { + __dynsym_start = .; + *(.dynsym) + } >.sram + + .bss : + { + . = ALIGN(4); + __bss_start = .; + *(.bss*) + . = ALIGN(4); + __bss_end__ = .; + } >.sram + + __image_copy_end = .; + _end = .; +} diff --git a/doc/README.davinci b/doc/README.davinci index 5f1bdc8..aa7c850 100644 --- a/doc/README.davinci +++ b/doc/README.davinci @@ -95,6 +95,15 @@ into the RAM. The programmers and UBL are always released as part of any standard TI software release associated with an SOC.
+Alternative boot method (DA850 EVM only): +For the DA850 EVM an SPL (secondary program loader, see doc/README.SPL) +is provided to load U-Boot directly from SPI flash. In this case, the +SPL does the low level initialization that is otherwise done by the SPL. +To build U-Boot with this SPL, do +make da850evm_config +make u-boot.ais +and program the resulting u-boot.ais file to the SPI flash of the DA850 EVM. + Environment Variables =====================
diff --git a/include/configs/da850evm.h b/include/configs/da850evm.h index 2e2aa19..d716404 100644 --- a/include/configs/da850evm.h +++ b/include/configs/da850evm.h @@ -65,6 +65,75 @@ #define CONFIG_NR_DRAM_BANKS 1 /* we have 1 bank of DRAM */ #define CONFIG_STACKSIZE (256*1024) /* regular stack */
+#define CONFIG_SYS_DA850_SYSCFG_SUSPSRC (0 | \ + DAVINCI_SYSCFG_SUSPSRC_TIMER0 | \ + DAVINCI_SYSCFG_SUSPSRC_SPI1 | \ + DAVINCI_SYSCFG_SUSPSRC_UART2 | \ + DAVINCI_SYSCFG_SUSPSRC_EMAC | \ + DAVINCI_SYSCFG_SUSPSRC_I2C) + +/* + * PLL configuration + */ +#define CONFIG_SYS_DV_CLKMODE 0 +#define CONFIG_SYS_DA850_PLL0_POSTDIV 1 +#define CONFIG_SYS_DA850_PLL0_PLLDIV1 0x8000 +#define CONFIG_SYS_DA850_PLL0_PLLDIV2 0x8001 +#define CONFIG_SYS_DA850_PLL0_PLLDIV3 0x8002 +#define CONFIG_SYS_DA850_PLL0_PLLDIV4 0x8003 +#define CONFIG_SYS_DA850_PLL0_PLLDIV5 0x8002 +#define CONFIG_SYS_DA850_PLL0_PLLDIV6 CONFIG_SYS_DA850_PLL0_PLLDIV1 +#define CONFIG_SYS_DA850_PLL0_PLLDIV7 0x8005 + +#define CONFIG_SYS_DA850_PLL1_POSTDIV 1 +#define CONFIG_SYS_DA850_PLL1_PLLDIV1 0x8000 +#define CONFIG_SYS_DA850_PLL1_PLLDIV2 0x8001 +#define CONFIG_SYS_DA850_PLL1_PLLDIV3 0x8002 + +#define CONFIG_SYS_DA850_PLL0_PLLM 24 +#define CONFIG_SYS_DA850_PLL1_PLLM 21 + +/* + * DDR2 memory configuration + */ +#define CONFIG_SYS_DA850_DDR2_DDRPHYCR (DV_DDR_PHY_PWRDNEN | \ + DV_DDR_PHY_EXT_STRBEN | \ + (0x4 << DV_DDR_PHY_RD_LATENCY_SHIFT)) + +#define CONFIG_SYS_DA850_DDR2_SDBCR (0 | \ + (1 << DV_DDR_SDCR_MSDRAMEN_SHIFT) | \ + (1 << DV_DDR_SDCR_DDREN_SHIFT) | \ + (1 << DV_DDR_SDCR_SDRAMEN_SHIFT) | \ + (1 << DV_DDR_SDCR_BUS_WIDTH_SHIFT) | \ + (0x3 << DV_DDR_SDCR_CL_SHIFT) | \ + (0x2 << DV_DDR_SDCR_IBANK_SHIFT) | \ + (0x2 << DV_DDR_SDCR_PAGESIZE_SHIFT)) + +/* SDBCR2 is only used if IBANK_POS bit in SDBCR is set */ +#define CONFIG_SYS_DA850_DDR2_SDBCR2 0 + +#define CONFIG_SYS_DA850_DDR2_SDTIMR (0 | \ + (14 << DV_DDR_SDTMR1_RFC_SHIFT) | \ + (2 << DV_DDR_SDTMR1_RP_SHIFT) | \ + (2 << DV_DDR_SDTMR1_RCD_SHIFT) | \ + (1 << DV_DDR_SDTMR1_WR_SHIFT) | \ + (5 << DV_DDR_SDTMR1_RAS_SHIFT) | \ + (8 << DV_DDR_SDTMR1_RC_SHIFT) | \ + (1 << DV_DDR_SDTMR1_RRD_SHIFT) | \ + (0 << DV_DDR_SDTMR1_WTR_SHIFT)) + +#define CONFIG_SYS_DA850_DDR2_SDTIMR2 (0 | \ + (7 << DV_DDR_SDTMR2_RASMAX_SHIFT) | \ + (0 << DV_DDR_SDTMR2_XP_SHIFT) | \ + (0 << DV_DDR_SDTMR2_ODT_SHIFT) | \ + (17 << DV_DDR_SDTMR2_XSNR_SHIFT) | \ + (199 << DV_DDR_SDTMR2_XSRD_SHIFT) | \ + (0 << DV_DDR_SDTMR2_RTP_SHIFT) | \ + (0 << DV_DDR_SDTMR2_CKE_SHIFT)) + +#define CONFIG_SYS_DA850_DDR2_SDRCR 0x00000494 +#define CONFIG_SYS_DA850_DDR2_PBBPR 0x30 + /* * Serial Driver info */ @@ -76,6 +145,7 @@ #define CONFIG_CONS_INDEX 1 /* use UART0 for console */ #define CONFIG_BAUDRATE 115200 /* Default baud rate */ #define CONFIG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 } +#define CONFIG_SYS_DA850_LPSC_UART DAVINCI_LPSC_UART2
#define CONFIG_SPI #define CONFIG_SPI_FLASH @@ -242,6 +312,23 @@ #undef CONFIG_CMD_ENV #endif
+/* defines for SPL */ +#define CONFIG_SPL +#define CONFIG_SPL_SPI_SUPPORT +#define CONFIG_SPL_SPI_FLASH_SUPPORT +#define CONFIG_SPL_SPI_LOAD +#define CONFIG_SPL_SPI_BUS 0 +#define CONFIG_SPL_SPI_CS 0 +#define CONFIG_SPL_SERIAL_SUPPORT +#define CONFIG_SPL_LIBCOMMON_SUPPORT +#define CONFIG_SPL_LIBGENERIC_SUPPORT +#define CONFIG_SPL_LDSCRIPT "$(BOARDDIR)/u-boot-spl.lds" +#define CONFIG_SPL_STACK 0x8001ff00 +#define CONFIG_SPL_TEXT_BASE 0x80000000 +#define CONFIG_SPL_MAX_SIZE 32768 +#define CONFIG_SYS_SPI_U_BOOT_OFFS 0x8000 +#define CONFIG_SYS_SPI_U_BOOT_SIZE 0x30000 + /* additions for new relocation code, must added to all boards */ #define CONFIG_SYS_SDRAM_BASE 0xc0000000 #define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_SDRAM_BASE + 0x1000 - /* Fix this */ \

On 12/02/2011 09:12 AM, Christian Riesch wrote:
[snip]
include/configs/da850evm.h | 87 +++++++++++++++++++++++++++++++++
[snip]
+#define CONFIG_SYS_DA850_DDR2_SDTIMR (0 | \
- (14 << DV_DDR_SDTMR1_RFC_SHIFT) | \
- (2 << DV_DDR_SDTMR1_RP_SHIFT) | \
- (2 << DV_DDR_SDTMR1_RCD_SHIFT) | \
- (1 << DV_DDR_SDTMR1_WR_SHIFT) | \
- (5 << DV_DDR_SDTMR1_RAS_SHIFT) | \
- (8 << DV_DDR_SDTMR1_RC_SHIFT) | \
- (1 << DV_DDR_SDTMR1_RRD_SHIFT) | \
- (0 << DV_DDR_SDTMR1_WTR_SHIFT))
'0 | ..' and '0 << ...' don't help readability over just value saying it (same with shifting 0). Also, unless the manual these come from uses decimal here, hex is preferred. Thanks!

Hi Tom, Thanks for your comments.
On Friday, December 2, 2011, Tom Rini trini@ti.com wrote:
On 12/02/2011 09:12 AM, Christian Riesch wrote:
[snip]
include/configs/da850evm.h | 87
+++++++++++++++++++++++++++++++++
[snip]
+#define CONFIG_SYS_DA850_DDR2_SDTIMR (0 | \
(14 << DV_DDR_SDTMR1_RFC_SHIFT) | \
(2 << DV_DDR_SDTMR1_RP_SHIFT) | \
(2 << DV_DDR_SDTMR1_RCD_SHIFT) | \
(1 << DV_DDR_SDTMR1_WR_SHIFT) | \
(5 << DV_DDR_SDTMR1_RAS_SHIFT) | \
(8 << DV_DDR_SDTMR1_RC_SHIFT) | \
(1 << DV_DDR_SDTMR1_RRD_SHIFT) | \
(0 << DV_DDR_SDTMR1_WTR_SHIFT))
'0 | ..' and '0 << ...' don't help readability over just value saying it (same with shifting 0). Also, unless the manual these come from uses decimal here, hex is preferred. Thanks!
'0 | ...'. I agree, I'll remove this.
'0 << ...' Aaaahhh... Yes, that's pretty useless here, the WTR bits are reserved bits :-/
Decimal values: I'd like to keep them. This is DDR timing, the numbers mean number of clock cycles minus one. So actually (1 << DV_DDR_SDTMR1_RRD_SHIFT) means that trrd=13.3333... ns (two clock cycles) at 150 MHz. So I must calculate with these numbers and this is why I prefer decimal over hex. I am lazy ;-)
Christian
-- Tom _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot

On Fri, Dec 2, 2011 at 10:49 PM, Christian Riesch christian.riesch@omicron.at wrote:
Hi Tom, Thanks for your comments.
On Friday, December 2, 2011, Tom Rini trini@ti.com wrote:
On 12/02/2011 09:12 AM, Christian Riesch wrote:
[snip]
include/configs/da850evm.h | 87
+++++++++++++++++++++++++++++++++
[snip]
+#define CONFIG_SYS_DA850_DDR2_SDTIMR (0 | \
- (14 << DV_DDR_SDTMR1_RFC_SHIFT) | \
- (2 << DV_DDR_SDTMR1_RP_SHIFT) | \
- (2 << DV_DDR_SDTMR1_RCD_SHIFT) | \
- (1 << DV_DDR_SDTMR1_WR_SHIFT) | \
- (5 << DV_DDR_SDTMR1_RAS_SHIFT) | \
- (8 << DV_DDR_SDTMR1_RC_SHIFT) | \
- (1 << DV_DDR_SDTMR1_RRD_SHIFT) | \
- (0 << DV_DDR_SDTMR1_WTR_SHIFT))
'0 | ..' and '0 << ...' don't help readability over just value saying it (same with shifting 0). Also, unless the manual these come from uses decimal here, hex is preferred. Thanks!
'0 | ...'. I agree, I'll remove this.
'0 << ...' Aaaahhh... Yes, that's pretty useless here, the WTR bits are reserved bits :-/
Decimal values: I'd like to keep them. This is DDR timing, the numbers mean number of clock cycles minus one. So actually (1 << DV_DDR_SDTMR1_RRD_SHIFT) means that trrd=13.3333... ns (two clock cycles) at 150 MHz. So I must calculate with these numbers and this is why I prefer decimal over hex. I am lazy ;-)
OK, that's fine too, thanks.

Hi Tom,
On Sat, Dec 3, 2011 at 6:49 AM, Christian Riesch christian.riesch@omicron.at wrote:
Hi Tom, Thanks for your comments.
On Friday, December 2, 2011, Tom Rini trini@ti.com wrote:
On 12/02/2011 09:12 AM, Christian Riesch wrote:
[snip]
include/configs/da850evm.h | 87 +++++++++++++++++++++++++++++++++
[snip]
+#define CONFIG_SYS_DA850_DDR2_SDTIMR (0 | \
- (14 << DV_DDR_SDTMR1_RFC_SHIFT) | \
- (2 << DV_DDR_SDTMR1_RP_SHIFT) | \
- (2 << DV_DDR_SDTMR1_RCD_SHIFT) | \
- (1 << DV_DDR_SDTMR1_WR_SHIFT) | \
- (5 << DV_DDR_SDTMR1_RAS_SHIFT) | \
- (8 << DV_DDR_SDTMR1_RC_SHIFT) | \
- (1 << DV_DDR_SDTMR1_RRD_SHIFT) | \
- (0 << DV_DDR_SDTMR1_WTR_SHIFT))
'0 | ..' and '0 << ...' don't help readability over just value saying it (same with shifting 0). Also, unless the manual these come from uses decimal here, hex is preferred. Thanks!
'0 | ...'. I agree, I'll remove this.
'0 << ...' Aaaahhh... Yes, that's pretty useless here, the WTR bits are reserved bits :-/
Uh, sorry, they are not reserved. But a zero value here means that we have one clock cycle (because it's number of clock cycles minus one). So I'd like to keep the line because it will help others to see that WTR is set to one clock cycle. Christian
Decimal values: I'd like to keep them. This is DDR timing, the numbers mean number of clock cycles minus one. So actually (1 << DV_DDR_SDTMR1_RRD_SHIFT) means that trrd=13.3333... ns (two clock cycles) at 150 MHz. So I must calculate with these numbers and this is why I prefer decimal over hex. I am lazy ;-)
Christian
-- Tom _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot

On 12/05/2011 03:20 AM, Christian Riesch wrote:
Hi Tom,
On Sat, Dec 3, 2011 at 6:49 AM, Christian Riesch christian.riesch@omicron.at wrote:
Hi Tom, Thanks for your comments.
On Friday, December 2, 2011, Tom Rini trini@ti.com wrote:
On 12/02/2011 09:12 AM, Christian Riesch wrote:
[snip]
include/configs/da850evm.h | 87 +++++++++++++++++++++++++++++++++
[snip]
+#define CONFIG_SYS_DA850_DDR2_SDTIMR (0 | \
(14 << DV_DDR_SDTMR1_RFC_SHIFT) | \
(2 << DV_DDR_SDTMR1_RP_SHIFT) | \
(2 << DV_DDR_SDTMR1_RCD_SHIFT) | \
(1 << DV_DDR_SDTMR1_WR_SHIFT) | \
(5 << DV_DDR_SDTMR1_RAS_SHIFT) | \
(8 << DV_DDR_SDTMR1_RC_SHIFT) | \
(1 << DV_DDR_SDTMR1_RRD_SHIFT) | \
(0 << DV_DDR_SDTMR1_WTR_SHIFT))
'0 | ..' and '0 << ...' don't help readability over just value saying it (same with shifting 0). Also, unless the manual these come from uses decimal here, hex is preferred. Thanks!
'0 | ...'. I agree, I'll remove this.
'0 << ...' Aaaahhh... Yes, that's pretty useless here, the WTR bits are reserved bits :-/
Uh, sorry, they are not reserved. But a zero value here means that we have one clock cycle (because it's number of clock cycles minus one). So I'd like to keep the line because it will help others to see that WTR is set to one clock cycle.
I'd say it's not obvious that a value of zero means one clock cycle, so drop the define and just comment what the full value contains.

Support for variable length images like AIS image was introduced in commit f0662105b674a3874227316abf8536bebc9b5995. A parameter "-s" was also introduced to prohibit copying of the image file automatically in the main program. However, this parameter was implemented incorrectly and the image file was copied nevertheless.
Signed-off-by: Christian Riesch christian.riesch@omicron.at Cc: Stefano Babic sbabic@denx.de Cc: Heiko Schocher hs@denx.de Acked-by: Stefano Babic sbabic@denx.de --- tools/mkimage.c | 97 ++++++++++++++++++++++++++++--------------------------- 1 files changed, 49 insertions(+), 48 deletions(-)
diff --git a/tools/mkimage.c b/tools/mkimage.c index 36e28ec..eeb1b10 100644 --- a/tools/mkimage.c +++ b/tools/mkimage.c @@ -383,65 +383,66 @@ NXTARG: ; exit (EXIT_FAILURE); }
- if (!params.skipcpy && - (params.type == IH_TYPE_MULTI || - params.type == IH_TYPE_SCRIPT)) { - char *file = params.datafile; - uint32_t size; - - for (;;) { - char *sep = NULL; - - if (file) { - if ((sep = strchr(file, ':')) != NULL) { - *sep = '\0'; + if (!params.skipcpy) { + if (params.type == IH_TYPE_MULTI || + params.type == IH_TYPE_SCRIPT) { + char *file = params.datafile; + uint32_t size; + + for (;;) { + char *sep = NULL; + + if (file) { + if ((sep = strchr(file, ':')) != NULL) { + *sep = '\0'; + } + + if (stat (file, &sbuf) < 0) { + fprintf (stderr, "%s: Can't stat %s: %s\n", + params.cmdname, file, strerror(errno)); + exit (EXIT_FAILURE); + } + size = cpu_to_uimage (sbuf.st_size); + } else { + size = 0; }
- if (stat (file, &sbuf) < 0) { - fprintf (stderr, "%s: Can't stat %s: %s\n", - params.cmdname, file, strerror(errno)); + if (write(ifd, (char *)&size, sizeof(size)) != sizeof(size)) { + fprintf (stderr, "%s: Write error on %s: %s\n", + params.cmdname, params.imagefile, + strerror(errno)); exit (EXIT_FAILURE); } - size = cpu_to_uimage (sbuf.st_size); - } else { - size = 0; - }
- if (write(ifd, (char *)&size, sizeof(size)) != sizeof(size)) { - fprintf (stderr, "%s: Write error on %s: %s\n", - params.cmdname, params.imagefile, - strerror(errno)); - exit (EXIT_FAILURE); - } + if (!file) { + break; + }
- if (!file) { - break; + if (sep) { + *sep = ':'; + file = sep + 1; + } else { + file = NULL; + } }
- if (sep) { - *sep = ':'; - file = sep + 1; - } else { - file = NULL; - } - } + file = params.datafile;
- file = params.datafile; - - for (;;) { - char *sep = strchr(file, ':'); - if (sep) { - *sep = '\0'; - copy_file (ifd, file, 1); - *sep++ = ':'; - file = sep; - } else { - copy_file (ifd, file, 0); - break; + for (;;) { + char *sep = strchr(file, ':'); + if (sep) { + *sep = '\0'; + copy_file (ifd, file, 1); + *sep++ = ':'; + file = sep; + } else { + copy_file (ifd, file, 0); + break; + } } + } else { + copy_file (ifd, params.datafile, 0); } - } else { - copy_file (ifd, params.datafile, 0); }
/* We're a bit of paranoid */

Signed-off-by: Christian Riesch christian.riesch@omicron.at Cc: Stefano Babic sbabic@denx.de Cc: Heiko Schocher hs@denx.de Cc: Mike Frysinger vapier@gentoo.org --- .gitignore | 1 + Makefile | 13 +++++++++++++ 2 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore index ff4bae0..e4e95e2 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,7 @@ /u-boot.dis /u-boot.lds /u-boot.ubl +/u-boot.ais /u-boot.dtb /u-boot.sb
diff --git a/Makefile b/Makefile index fb658f4..5b26f8b 100644 --- a/Makefile +++ b/Makefile @@ -417,6 +417,18 @@ $(obj)u-boot.ubl: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin rm $(obj)u-boot-ubl.bin rm $(obj)spl/u-boot-spl-pad.bin
+$(obj)u-boot.ais: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin + $(obj)tools/mkimage -s -n /dev/null -T aisimage \ + -e $(CONFIG_SPL_TEXT_BASE) -d $(obj)spl/u-boot-spl.bin \ + $(obj)spl/u-boot-spl.ais + $(OBJCOPY) ${OBJCFLAGS} -I binary \ + --pad-to=$(CONFIG_SPL_MAX_SIZE) -O binary \ + $(obj)spl/u-boot-spl.ais $(obj)spl/u-boot-spl-pad.ais + cat $(obj)spl/u-boot-spl-pad.ais $(obj)u-boot.bin > \ + $(obj)u-boot.ais + rm $(obj)spl/u-boot-spl.ais + rm $(obj)spl/u-boot-spl-pad.ais + $(obj)u-boot.sb: $(obj)u-boot.bin $(obj)spl/u-boot-spl.bin elftosb -zdf imx28 -c $(TOPDIR)/board/$(BOARDDIR)/u-boot.bd \ -o $(obj)u-boot.sb @@ -788,6 +800,7 @@ clobber: clean @rm -f $(obj)u-boot.kwb @rm -f $(obj)u-boot.imx @rm -f $(obj)u-boot.ubl + @rm -f $(obj)u-boot.ais @rm -f $(obj)u-boot.dtb @rm -f $(obj)u-boot.sb @rm -f $(obj)tools/{env/crc32.c,inca-swap-bytes}

On Friday 02 December 2011 11:12:10 Christian Riesch wrote:
+$(obj)u-boot.ais: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin
$(obj)tools/mkimage -s -n /dev/null -T aisimage \
-e $(CONFIG_SPL_TEXT_BASE) -d $(obj)spl/u-boot-spl.bin \
$(obj)spl/u-boot-spl.ais
$(OBJCOPY) ${OBJCFLAGS} -I binary \
--pad-to=$(CONFIG_SPL_MAX_SIZE) -O binary \
$(obj)spl/u-boot-spl.ais $(obj)spl/u-boot-spl-pad.ais
cat $(obj)spl/u-boot-spl-pad.ais $(obj)u-boot.bin > \
$(obj)u-boot.ais
lack of indentation on wrapped lines makes it hard to see what's going on
rm $(obj)spl/u-boot-spl.ais
rm $(obj)spl/u-boot-spl-pad.ais
rm $(obj)spl/u-boot-spl{,-pad}.ais -mike

Hi Mike, Thanks for your comments.
On Friday, December 2, 2011, Mike Frysinger vapier@gentoo.org wrote:
On Friday 02 December 2011 11:12:10 Christian Riesch wrote:
+$(obj)u-boot.ais: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin
$(obj)tools/mkimage -s -n /dev/null -T aisimage \
-e $(CONFIG_SPL_TEXT_BASE) -d $(obj)spl/u-boot-spl.bin \
$(obj)spl/u-boot-spl.ais
$(OBJCOPY) ${OBJCFLAGS} -I binary \
--pad-to=$(CONFIG_SPL_MAX_SIZE) -O binary \
$(obj)spl/u-boot-spl.ais $(obj)spl/u-boot-spl-pad.ais
cat $(obj)spl/u-boot-spl-pad.ais $(obj)u-boot.bin > \
$(obj)u-boot.ais
lack of indentation on wrapped lines makes it hard to see what's going on
I'll change that.
The chaos above contains three commands: 1) I run the SPL through mkimage to add an AIS header for booting from SPI. Since an empty config file (-n) is sufficient here I use /dev/null here. 2) I pad the result $(obj)spl/u-boot-spl.ais to $CONFIG_SPL_MAX_SIZE with $(OBJCOPY): The result is $(obj)spl/u-boot-spl-pad.ais 3) Then I add $(obj)u-boot.bin with cat, the result is $(obj)u-boot.ais
rm $(obj)spl/u-boot-spl.ais
rm $(obj)spl/u-boot-spl-pad.ais
rm $(obj)spl/u-boot-spl{,-pad}.ais
Ok.
Regards, Christian
-mike

On Saturday 03 December 2011 00:20:19 Christian Riesch wrote:
The chaos above contains three commands:
- I run the SPL through mkimage to add an AIS header for booting from SPI.
Since an empty config file (-n) is sufficient here I use /dev/null here. 2) I pad the result $(obj)spl/u-boot-spl.ais to $CONFIG_SPL_MAX_SIZE with $(OBJCOPY): The result is $(obj)spl/u-boot-spl-pad.ais 3) Then I add $(obj)u-boot.bin with cat, the result is $(obj)u-boot.ais
right; i was wondering if we could chain these somehow. but i guess going through intermediate files allows for catching errors that would get missed in a pipeline. -mike
participants (4)
-
Christian Riesch
-
Mike Frysinger
-
Tom Rini
-
Tom Rini