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

Abraham V. abraham.varricatt at vvdntech.com
Fri Nov 29 12:23:10 CET 2013


>
> Plz pull the patch mentioned above, and much of things should be cleaned up
> http://lists.denx.de/pipermail/u-boot/2013-November/167696.html
>

Thank you for the reply Pekon, but sadly even after applying your
patch the earlier compile issue is still present. Starting from a copy
of mainline u-boot source code here are the minimal steps required to
reproduce the issue.

1. Apply following patches,

http://lists.denx.de/pipermail/u-boot/2013-November/167697.html
http://lists.denx.de/pipermail/u-boot/2013-November/167698.html
http://lists.denx.de/pipermail/u-boot/2013-November/167700.html
http://lists.denx.de/pipermail/u-boot/2013-November/167699.html
http://lists.denx.de/pipermail/u-boot/2013-November/167701.html

After this is done compiling for all the omap4 boards happens without
issue (example output below).

> ./MAKEALL -s omap4
Configuring for omap4_panda board...
   text   data    bss    dec    hex filename
 193830   9970 305496 509296  7c570 ./u-boot
  32923   2200 197972 233095  38e87 ./spl/u-boot-spl
Configuring for omap4_sdp4430 board...
   text   data    bss    dec    hex filename
 154677   9800 214704 379181  5c92d ./u-boot
  32378   2200 197972 232550  38c66 ./spl/u-boot-spl

--------------------- SUMMARY ----------------------------
Boards compiled: 2
----------------------------------------------------------

2. Since we're interested in bundling in NAND support for the
pandaboard, please apply the following patch (pass on NAND as a
compilation parameter),

diff --git a/boards.cfg b/boards.cfg
index e742746..7bad4a0 100644
--- a/boards.cfg
+++ b/boards.cfg
@@ -334,7 +334,7 @@ Active  arm         armv7          omap3       ti
            evm
 Active  arm         armv7          omap3       ti              evm
             omap3_evm_quick_nand                 -
 Active  arm         armv7          omap3       ti
sdp3430             omap3_sdp3430                        -
 Active  arm         armv7          omap3       timll
devkit8000          devkit8000                           -
-Active  arm         armv7          omap4       ti              panda
             omap4_panda                          -
+Active  arm         armv7          omap4       ti              panda
             omap4_panda                          omap4_panda:NAND
 Active  arm         armv7          omap4       ti
sdp4430             omap4_sdp4430                        -
 Active  arm         armv7          omap5       ti              dra7xx
             dra7xx_evm
dra7xx_evm:CONS_INDEX=1
 Active  arm         armv7          omap5       ti              dra7xx
             dra7xx_evm_uart3
dra7xx_evm:CONS_INDEX=3,S
>


3. Compiling for omap4 boards now gives an error about
"asm/arch/mem.h" missing. A simple work-around is to copy over the
file from the omap3 directory (command below)

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


4. At this point we'll get some complaints about missing static
definitions, so apply the following patch to add them in the common
configuration file;

diff --git a/include/configs/omap4_common.h b/include/configs/omap4_common.h
index ea56eeb..80f5d03 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
+#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)"
+#undef CONFIG_ENV_IS_NOWHERE
+#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 */


The following edit is also needed in the panda configuration file (it
won't work from the common file as the panda configuration will
over-ride it)

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


5. Now, we get a complaint about a missing "hardware.h". Only ELM_BASE
is used from there, so I created the header file with that sole entry
as follows

> echo "#define ELM_BASE 0x48078000" > arch/arm/include/asm/arch-omap4/hardware.h

(I updated the value for ELM_BASE from the public OMAP4460 manual,
page 310 - it looks different from that used on the am335)


And at this point, I encounter the same error I mentioned last time
(output below). Quite frankly, I'm stuck on how to proceed. I
*suspect* that the SPL build has some extra configuration file where I
need to mention the NAND support, but am not sure where to look. :(

> make -s omap4_panda
Configuring for omap4_panda - Board: omap4_panda, Options: NAND
Image Name:   U-Boot 2014.01-rc1-dirty for pan
Created:      Fri Nov 29 16:48:34 2013
Image Type:   ARM U-Boot Firmware (uncompressed)
Data Size:    260136 Bytes = 254.04 kB = 0.25 MB
Load Address: 80800000
Entry Point:  00000000
arch/arm/cpu/armv7/built-in.o: In function `spl_board_init':
/home/abraham/SPACE/patch_uboot_panda/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/patch_uboot_panda/drivers/mtd/nand/omap_gpmc.c:51:
undefined reference to `gpmc_cfg'
drivers/mtd/nand/built-in.o: In function `omap_spl_dev_ready':
/home/abraham/SPACE/patch_uboot_panda/drivers/mtd/nand/omap_gpmc.c:59:
undefined reference to `gpmc_cfg'
drivers/mtd/nand/built-in.o: In function `omap_enable_ecc_bch':
/home/abraham/SPACE/patch_uboot_panda/drivers/mtd/nand/omap_gpmc.c:361:
undefined reference to `gpmc_cfg'
drivers/mtd/nand/built-in.o: In function `omap_calculate_ecc_bch':
/home/abraham/SPACE/patch_uboot_panda/drivers/mtd/nand/omap_gpmc.c:478:
undefined reference to `gpmc_cfg'
drivers/mtd/nand/built-in.o: In function `board_nand_init':
/home/abraham/SPACE/patch_uboot_panda/drivers/mtd/nand/omap_gpmc.c:1026:
undefined reference to `gpmc_cfg'
make[2]: *** [/home/abraham/SPACE/patch_uboot_panda/spl/u-boot-spl] Error 1
make[1]: *** [spl/u-boot-spl.bin] Error 2
make: *** [omap4_panda] Error 2
>


Help?

-Abraham

PS: Sorry about the HTML in my last reply. Hope this is better?


More information about the U-Boot mailing list