[U-Boot] adding NAND support for omap4 (based on pandaboard)

Abraham V. abraham.varricatt at vvdntech.com
Thu Nov 28 12:40:23 CET 2013


Hello all,
(cc Pekon - my efforts are based on his earlier commit)

My firm is developing an omap4-based board with NAND memory as a boot
option. For the most part it's identical to the pandaboard (OMAP4460)
without most of the peripheral interfaces. After a recent commit which
generalized the omap NAND driver, I began the task of porting it to my
board. With some trial-and-error, I was able to get the main u-boot image
built, but am facing errors during SPL compilation.

To explain my problem, I've taken the latest uboot mainline code and have
made edits so as to get NAND working on a pandaboard (it's not possible
schematically, but does demonstrate my compilation problem). Hopefully,
this will help get the drivers working for the omap4 SoC as well.

My build steps are like this;
> make distclean
> make omap4_panda_config
> make

Here are the 6 steps/changes I made to the source code (working off uboot
mainline ).

1. Added NAND as a configuration option in boards.cfg by changing this line,

Active  arm   armv7   omap4   ti   panda   omap4_panda   -    Sricharan R <
r.sricharan at ti.com>

to this,

Active  arm   armv7   omap4   ti   panda   omap4_panda   omap4_panda:NAND
 Sricharan R <r.sricharan at ti.com>

2. Added NAND support in omap4_common.h configuration file as below (Just
copied the lines from am335x_evm.h

diff --git a/include/configs/omap4_common.h b/include/configs/omap4_common.h
index ea56eeb..49d5d8a 100644
--- a/include/configs/omap4_common.h
+++ b/include/configs/omap4_common.h
@@ -154,4 +154,49 @@
 #define CONFIG_SPL_DISPLAY_PRINT
 #define CONFIG_SPL_LDSCRIPT "$(CPUDIR)/omap-common/u-boot-spl.lds"

+#ifdef CONFIG_NAND
+#define CONFIG_NAND_OMAP_GPMC
+#define CONFIG_NAND_OMAP_ELM
+#define CONFIG_SYS_NAND_5_ADDR_CYCLE
+#define CONFIG_SYS_NAND_PAGE_COUNT     (CONFIG_SYS_NAND_BLOCK_SIZE / \
+                                        CONFIG_SYS_NAND_PAGE_SIZE)
+#define CONFIG_SYS_NAND_PAGE_SIZE      2048
+#define CONFIG_SYS_NAND_OOBSIZE                64
+#define CONFIG_SYS_NAND_BLOCK_SIZE     (128*1024)
+#define CONFIG_SYS_NAND_BAD_BLOCK_POS  NAND_LARGE_BADBLOCK_POS
+#define CONFIG_SYS_NAND_ECCPOS         { 2, 3, 4, 5, 6, 7, 8, 9, \
+                                        10, 11, 12, 13, 14, 15, 16, 17, \
+                                        18, 19, 20, 21, 22, 23, 24, 25, \
+                                        26, 27, 28, 29, 30, 31, 32, 33, \
+                                        34, 35, 36, 37, 38, 39, 40, 41, \
+                                        42, 43, 44, 45, 46, 47, 48, 49, \
+                                        50, 51, 52, 53, 54, 55, 56, 57, }
+
+#define CONFIG_SYS_NAND_ECCSIZE                512
+#define CONFIG_SYS_NAND_ECCBYTES       14
+#define CONFIG_SYS_NAND_ONFI_DETECTION
+#define CONFIG_NAND_OMAP_ECCSCHEME     OMAP_ECC_BCH8_CODE_HW
+#define CONFIG_SYS_NAND_U_BOOT_START   CONFIG_SYS_TEXT_BASE
+#define CONFIG_SYS_NAND_U_BOOT_OFFS    0x80000
+#endif
+
+/* NAND support */
+#ifdef CONFIG_NAND
+#define CONFIG_CMD_NAND
+#define GPMC_NAND_ECC_LP_x16_LAYOUT    1
+#if !defined(CONFIG_SPI_BOOT) && !defined(CONFIG_NOR_BOOT)
+#define MTDIDS_DEFAULT                 "nand0=omap2-nand.0"
+#define MTDPARTS_DEFAULT               "mtdparts=omap2-nand.0:128k(SPL)," \
+                                       "128k(SPL.backup1)," \
+                                       "128k(SPL.backup2)," \
+                                       "128k(SPL.backup3),1792k(u-boot)," \
+                                       "128k(u-boot-spl-os)," \
+
"128k(u-boot-env),5m(kernel),-(rootfs)"
+#define CONFIG_ENV_IS_IN_NAND
+#define CONFIG_ENV_OFFSET              0x260000 /* environment starts here
*/
+#define CONFIG_SYS_ENV_SECT_SIZE       (128 << 10)     /* 128 KiB */
+#endif
+#endif
+
 #endif /* __CONFIG_OMAP4_COMMON_H */


3. Edited omap4_panda.h to prevent a compilation error (The ENV gets setup
as NAND thanks to earlier change);

diff --git a/include/configs/omap4_panda.h b/include/configs/omap4_panda.h
index 6820e42..d356cfd 100644
--- a/include/configs/omap4_panda.h
+++ b/include/configs/omap4_panda.h
@@ -45,8 +45,10 @@
 /* GPIO */
 #define CONFIG_CMD_GPIO

+#ifndef CONFIG_NAND
 /* ENV related config options */
 #define CONFIG_ENV_IS_NOWHERE
+#endif

 #define CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG


4. Copied over 2 header files from arch-omap3 to arch-omap4 (since they are
from the same processor family, I'm hoping it will work)

> cp arch/arm/include/asm/arch-omap3/mem.h
arch/arm/include/asm/arch-omap4/mem.h
> cp arch/arm/include/asm/arch-omap3/omap_gpmc.h
arch/arm/include/asm/arch-omap4/omap_gpmc.h
>


5. Edited cpu.h to add a few structure members needed for BCH error
correction (compiler complains they are missing otherwise);

diff --git a/arch/arm/include/asm/arch-omap4/cpu.h
b/arch/arm/include/asm/arch-omap4/cpu.h
index 545d9d9..9e389ba 100644
--- a/arch/arm/include/asm/arch-omap4/cpu.h
+++ b/arch/arm/include/asm/arch-omap4/cpu.h
@@ -28,6 +28,10 @@ struct gpmc_cs {
        u8 res[8];              /* blow up to 0x30 byte */
 };

+struct bch_res_0_3 {
+       u32 bch_result_x[4];
+};
+
 struct gpmc {
        u8 res1[0x10];
        u32 sysconfig;          /* 0x10 */
@@ -35,7 +39,7 @@ struct gpmc {
        u32 irqstatus;          /* 0x18 */
        u32 irqenable;          /* 0x1C */
        u8 res3[0x20];
-       u32 timeout_control;    /* 0x40 */
+       u32 timeout_control;    /* 0x40 */
        u8 res4[0xC];
        u32 config;             /* 0x50 */
        u32 status;             /* 0x54 */
@@ -54,6 +58,8 @@ struct gpmc {
        u32 ecc7_result;        /* 0x218 */
        u32 ecc8_result;        /* 0x21C */
        u32 ecc9_result;        /* 0x220 */
+       u8 res7[0x1C];          /* fill up to 0x240 */
+       struct bch_res_0_3 bch_result_0_3[7];   /* 0x240 */
 };

 /* Used for board specific gpmc initialization */


6. Adding a #define in omap.h to allow NAND driver to compile (The value of
ELM_BASE was copied over from arch/arm/include/asm/arch-am33xx/hardware.h)

diff --git a/arch/arm/include/asm/arch-omap4/omap.h
b/arch/arm/include/asm/arch-omap4/omap.h
index e35f51c..770a18c 100644
--- a/arch/arm/include/asm/arch-omap4/omap.h
+++ b/arch/arm/include/asm/arch-omap4/omap.h
@@ -63,6 +63,9 @@
 /* GPMC */
 #define OMAP44XX_GPMC_BASE     0x50000000

+/* BCH Error Location Module */
+#define ELM_BASE                       0x48080000
+
 /*
  * Hardware Register Details
  */


With the above, I'm able to compile u-boot.img, but am having trouble with
the SPL. Here's where the build fails,

/home/abraham/SPACE/BISQUARE/source/uboot_update/gcc-SourceryCodeBenchLite-arm/bin/arm-none-linux-gnueabi-gcc
-E -g  -Os   -ffunction-sections -fdata-sections -fno-common -ffixed-r9
-msoft-float  -D__KERNEL__ -ffunction-sections -fdata-sections
-DCONFIG_SYS_TEXT_BASE=0x80800000 -DCONFIG_SPL_BUILD
 -I/home/abraham/SPACE/uboot_panda_NAND/include
 -I/home/abraham/SPACE/uboot_panda_NAND/arch/arm/include -fno-builtin
-ffreestanding -nostdinc -isystem
/home/abraham/SPACE/BISQUARE/source/uboot_update/gcc-SourceryCodeBenchLite-arm/bin/../lib/gcc/arm-none-linux-gnueabi/4.7.3/include
-pipe  -DCONFIG_ARM -D__ARM__ -mthumb -mthumb-interwork -mabi=aapcs-linux
-march=armv7-a -include
/home/abraham/SPACE/uboot_panda_NAND/include/u-boot/u-boot.lds.h -include
/home/abraham/SPACE/uboot_panda_NAND/include/config.h
-DCPUDIR=arch/arm/cpu/armv7  -I/home/abraham/SPACE/uboot_panda_NAND/spl/.
-ansi -D__ASSEMBLY__ -P - <
/home/abraham/SPACE/uboot_panda_NAND/arch/arm/cpu/armv7/omap-common/u-boot-spl.lds
> /home/abraham/SPACE/uboot_panda_NAND/spl/u-boot-spl.lds
cd /home/abraham/SPACE/uboot_panda_NAND/spl/ &&
/home/abraham/SPACE/BISQUARE/source/uboot_update/gcc-SourceryCodeBenchLite-arm/bin/arm-none-linux-gnueabi-ld
 -T /home/abraham/SPACE/uboot_panda_NAND/spl/u-boot-spl.lds --gc-sections
--gc-sections -Bstatic -Ttext 0x40304350 arch/arm/cpu/armv7/start.o
--start-group arch/arm/cpu/armv7/built-in.o
arch/arm/cpu/armv7/omap4/built-in.o arch/arm/cpu/built-in.o
arch/arm/lib/built-in.o board/ti/panda/built-in.o common/built-in.o
common/spl/built-in.o disk/built-in.o drivers/gpio/built-in.o
drivers/i2c/built-in.o drivers/mmc/built-in.o drivers/mtd/nand/built-in.o
drivers/serial/built-in.o fs/built-in.o lib/built-in.o --end-group
/home/abraham/SPACE/uboot_panda_NAND/spl/arch/arm/lib/eabi_compat.o -L
/home/abraham/SPACE/BISQUARE/source/uboot_update/gcc-SourceryCodeBenchLite-arm/bin/../lib/gcc/arm-none-linux-gnueabi/4.7.3/thumb2
-lgcc -Map u-boot-spl.map -o u-boot-spl
arch/arm/cpu/armv7/built-in.o: In function `spl_board_init':
/home/abraham/SPACE/uboot_panda_NAND/arch/arm/cpu/armv7/omap-common/boot-common.c:75:
undefined reference to `gpmc_init'
drivers/mtd/nand/built-in.o: In function `omap_nand_hwcontrol':
/home/abraham/SPACE/uboot_panda_NAND/drivers/mtd/nand/omap_gpmc.c:52:
undefined reference to `gpmc_cfg'
drivers/mtd/nand/built-in.o: In function `omap_spl_dev_ready':
/home/abraham/SPACE/uboot_panda_NAND/drivers/mtd/nand/omap_gpmc.c:60:
undefined reference to `gpmc_cfg'
drivers/mtd/nand/built-in.o: In function `omap_enable_ecc_bch':
/home/abraham/SPACE/uboot_panda_NAND/drivers/mtd/nand/omap_gpmc.c:362:
undefined reference to `gpmc_cfg'
drivers/mtd/nand/built-in.o: In function `omap_calculate_ecc_bch':
/home/abraham/SPACE/uboot_panda_NAND/drivers/mtd/nand/omap_gpmc.c:479:
undefined reference to `gpmc_cfg'
drivers/mtd/nand/built-in.o: In function `board_nand_init':
/home/abraham/SPACE/uboot_panda_NAND/drivers/mtd/nand/omap_gpmc.c:1027:
undefined reference to `gpmc_cfg'
make[1]: *** [/home/abraham/SPACE/uboot_panda_NAND/spl/u-boot-spl] Error 1
make[1]: Leaving directory `/home/abraham/SPACE/uboot_panda_NAND/spl'
make: *** [spl/u-boot-spl.bin] Error 2
>


Any suggestions on how I could fix this? I can't seem to figure out how SPL
is built and am not sure where to start. Assuming that we can solve this
issue, I can submit a proper patch after running it on real hardware (which
should arrive in about 2 - 4 weeks).

Puzzled,
Abraham V.


More information about the U-Boot mailing list