]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
arm:at91: enable ROM loadable atmel image
authorAndreas Bießmann <andreas.devel@googlemail.com>
Mon, 19 May 2014 12:23:40 +0000 (14:23 +0200)
committerAndreas Bießmann <andreas.devel@googlemail.com>
Mon, 26 May 2014 22:10:49 +0000 (00:10 +0200)
For sama5d3xek we need to modify the SPL image for correct detection by ROM
code.

Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>
Tested-by: Bo Shen <voice.shen@atmel.com>
arch/arm/cpu/armv7/at91/config.mk [new file with mode: 0644]
doc/README.atmel_pmecc
spl/Makefile
tools/Makefile
tools/atmel_pmecc_params.c [new file with mode: 0644]

diff --git a/arch/arm/cpu/armv7/at91/config.mk b/arch/arm/cpu/armv7/at91/config.mk
new file mode 100644 (file)
index 0000000..09eab70
--- /dev/null
@@ -0,0 +1,10 @@
+#
+# Copyright (C) 2014, Andreas Bießmann <andreas.devel@googlemail.com>
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+ifdef CONFIG_SPL_BUILD
+ALL-y  += boot.bin
+else
+ALL-y  += u-boot.img
+endif
index cf8373b54e826c8877acca3382e21cf9ed3e7197..cc0f73db8f1c70dbca708b5529ed5fee35e8a87e 100644 (file)
@@ -27,3 +27,24 @@ Take AT91SAM9X5EK as an example, the board definition file likes:
 #define CONFIG_ATMEL_NAND_HW_PMECC     1
 #define CONFIG_PMECC_CAP               2
 #define CONFIG_PMECC_SECTOR_SIZE       512
+
+How to enable PMECC header for direct programmable boot.bin
+-----------------------------------------------------------
+2014-05-19 Andreas Bießmann <andreas.devel@googlemail.com>
+
+The usual way to program SPL into NAND flash is to use the SAM-BA Atmel tool.
+This however is often not usable when doing field updates. To be able to
+program a SPL binary into NAND flash we need to add the PMECC header to the
+binary before. Chapter '12.4.4.1 NAND Flash Boot: NAND Flash Detection' in
+sama5d3 SoC spec (as of 03. April 2014) defines how this PMECC header has to
+look like. In order to do so we have a new image type added to mkimage to
+generate this PMECC header and integrated this into the build process of SPL.
+
+To enable the generation of atmel PMECC header for SPL one need to define
+CONFIG_SPL_GENERATE_ATMEL_PMECC_HEADER. The required parameters are taken from
+board configuration and compiled into the host tools atmel_pmecc_params. This
+tool will be called in build process to parametrize mkimage for atmelimage
+type. The mkimage tool has intentionally _not_ compiled in those parameters.
+
+The mkimage image type atmelimage also set the 6'th interrupt vector to the
+correct value. This feature can also be used to setup a boot.bin for MMC boot.
index bfb7c8aec89826e303527a193a592846ca616d63..bf677aa42a6027fb7a069f20507a793eea819df8 100644 (file)
@@ -183,6 +183,17 @@ MKIMAGEFLAGS_MLO.byteswap = -T omapimage -n byteswap -a $(CONFIG_SPL_TEXT_BASE)
 MLO MLO.byteswap: $(obj)/u-boot-spl.bin
        $(call if_changed,mkimage)
 
+MKIMAGEFLAGS_boot.bin = -T atmelimage
+
+ifeq ($(CONFIG_SPL_GENERATE_ATMEL_PMECC_HEADER),y)
+MKIMAGEFLAGS_boot.bin += -n $(shell $(obj)/../tools/atmel_pmecc_params)
+
+boot.bin: $(obj)/../tools/atmel_pmecc_params
+endif
+
+boot.bin: $(obj)/u-boot-spl.bin
+       $(call if_changed,mkimage)
+
 ALL-y  += $(obj)/$(SPL_BIN).bin
 
 ifdef CONFIG_SAMSUNG
index e6d804596b69741d1a6988c987719d8c73eee9f8..761055764bf6ab1e27bd8f4c27602879244effe6 100644 (file)
@@ -38,6 +38,8 @@ ENVCRC-$(CONFIG_ENV_IS_IN_NVRAM) = y
 ENVCRC-$(CONFIG_ENV_IS_IN_SPI_FLASH) = y
 CONFIG_BUILD_ENVCRC ?= $(ENVCRC-y)
 
+hostprogs-$(CONFIG_SPL_GENERATE_ATMEL_PMECC_HEADER) += atmel_pmecc_params$(SFX)
+
 # TODO: CONFIG_CMD_LICENSE does not work
 hostprogs-$(CONFIG_CMD_LICENSE) += bin2header$(SFX)
 hostprogs-$(CONFIG_LCD_LOGO) += bmp_logo$(SFX)
diff --git a/tools/atmel_pmecc_params.c b/tools/atmel_pmecc_params.c
new file mode 100644 (file)
index 0000000..8eaf27f
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * (C) Copyright 2014 Andreas Bießmann <andreas.devel@googlemail.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+/*
+ * This is a host tool for generating an appropriate string out of board
+ * configuration. The string is required for correct generation of PMECC
+ * header which in turn is required for NAND flash booting of Atmel AT91 style
+ * hardware.
+ *
+ * See doc/README.atmel_pmecc for more information.
+ */
+
+#include <config.h>
+#include <stdlib.h>
+
+static int pmecc_get_ecc_bytes(int cap, int sector_size)
+{
+       int m = 12 + sector_size / 512;
+       return (m * cap + 7) / 8;
+}
+
+int main(int argc, char *argv[])
+{
+       unsigned int use_pmecc = 0;
+       unsigned int sector_per_page;
+       unsigned int sector_size = CONFIG_PMECC_SECTOR_SIZE;
+       unsigned int oob_size = CONFIG_SYS_NAND_OOBSIZE;
+       unsigned int ecc_bits = CONFIG_PMECC_CAP;
+       unsigned int ecc_offset;
+
+#ifdef CONFIG_ATMEL_NAND_HW_PMECC
+       use_pmecc = 1;
+#endif
+
+       sector_per_page = CONFIG_SYS_NAND_PAGE_SIZE / CONFIG_PMECC_SECTOR_SIZE;
+       ecc_offset = oob_size -
+               pmecc_get_ecc_bytes(ecc_bits, sector_size) * sector_per_page;
+
+       printf("usePmecc=%d,", use_pmecc);
+       printf("sectorPerPage=%d,", sector_per_page);
+       printf("sectorSize=%d,", sector_size);
+       printf("spareSize=%d,", oob_size);
+       printf("eccBits=%d,", ecc_bits);
+       printf("eccOffset=%d", ecc_offset);
+       printf("\n");
+
+       exit(EXIT_SUCCESS);
+}