This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

To add support for NAND S34ML08G1 in uboot for am3358 based board

Hi,

We are using a NAND spansion S34ML08G1 for our custom board based on am335x processor.

we are using tisdk7.00

Want to know the procedure to add support  of this flash in uboot.

I knew that following files needs to be change.

Files changed for adding NAND support
 
1.arch/arm/include/asm/arch-am33xx/mem.h
2.board/ti/am335x/board.c
3.board/ti/am335x/board.h
4.board/ti/am335x/mux.c
5.include/configs/am335x_evm.h
 
in mem.h file how to set the GPMC_CONFIG1 ---GPMC_CONFIG7 values for the flash parameters.
Thanks & Regards,
Uday
  • Hi,

    What version of u-boot are you using? It should have NAND support in it. See http://processors.wiki.ti.com/index.php/AM335x_U-Boot_User's_Guide

    For GPMC_CONFIGi values please read the AM335X TRM Rev. K, section 7.1.4.3.

  • Hi,

    We are using  "u-boot-2013.10-ti2013.12.01 " from ti-sdk version 7.00

    Thanks & Regards,

    Uday

  • Hi,

    We have done changes as per  following  note in am33xx board type.

    NAND
    ====

    The AM335x GP EVM ships with a 256MiB NAND available in most profiles.  In
    this example to program the NAND we assume that an SD card has been
    inserted with the files to write in the first SD slot and that mtdparts
    have been configured correctly for the board. All images are first loaded
    into memory, then written to NAND.

    Step-1: Building u-boot for NAND boot
        Set following CONFIGxx options for NAND device.
        CONFIG_SYS_NAND_PAGE_SIZE    number of main bytes in NAND page
        CONFIG_SYS_NAND_OOBSIZE        number of OOB bytes in NAND page
        CONFIG_SYS_NAND_BLOCK_SIZE    number of bytes in NAND erase-block
        CONFIG_SYS_NAND_ECCPOS        ECC map for NAND page
        CONFIG_NAND_OMAP_ECCSCHEME    (refer doc/README.nand)

    Step-2: Flashing NAND via MMC/SD
        # select BOOTSEL to MMC/SD boot and boot from MMC/SD card
        U-Boot # mmc rescan
        # erase flash
        U-Boot # nand erase.chip
        U-Boot # env default -f -a
        U-Boot # saveenv
        # flash MLO. Redundant copies of MLO are kept for failsafe
        U-Boot # load mmc 0 0x82000000 MLO
        U-Boot # nand write 0x82000000 0x00000 0x20000
        U-Boot # nand write 0x82000000 0x20000 0x20000
        U-Boot # nand write 0x82000000 0x40000 0x20000
        U-Boot # nand write 0x82000000 0x60000 0x20000
        # flash u-boot.img
        U-Boot # load mmc 0 0x82000000 u-boot.img
        U-Boot # nand write 0x82000000 0x80000 0x60000
        # flash kernel image
        U-Boot # load mmc 0 0x82000000 uImage
        U-Boot # nand write 0x82000000 ${nandsrcaddr} ${nandimgsize}
        # flash filesystem image
        U-Boot # load mmc 0 0x82000000 filesystem.img
        U-Boot # nand write 0x82000000 ${loadaddress} 0x300000

    Step-3: Set BOOTSEL pin to select NAND boot, and POR the device.
        The device should boot from images flashed on NAND device.

    Our problem is  board is getting boot successfully using sd card but unable to boot from flash.

    Thanks& Regards,

    Uday

  • Hi,

    For the SDK 7 you have to write in NAND zImage NOT uImage. Also you have to write devicetree-zimage-am335x-evm.dtb. I copied the sequences:

    * Flash the NAND on the AM335x GP EVM with the SDK 07.00.00.00:

    U-Boot# nand erase.chip

    NAND erase.chip: device 0 whole chip
    Erasing at 0xffe0000 -- 100% complete.
    OK
    U-Boot# mmc rescan
    U-Boot# fatls mmc 0
       107920   mlo
       389768   u-boot.img
           13   .ipaddr
        41564   devicetree-zimage-am335x-evm.dtb
      4117616   zimage
     32768000   arago-base-tisdk-image-am335x-evm.ubi

    6 file(s), 0 dir(s)

    U-Boot# fatload mmc 0 0x81000000 MLO
    reading MLO
    107920 bytes read in 10 ms (10.3 MiB/s)
    U-Boot# cp.b 0x81000000 0x81020000 20000; cp.b 0x81000000 0x81040000 20000; cp.b 0x81000000 0x81060000 20000
    U-Boot# fatload mmc 0 0x81080000 devicetree-zimage-am335x-evm.dtb
    reading devicetree-zimage-am335x-evm.dtb
    41564 bytes read in 8 ms (5 MiB/s)
    U-Boot# fatload mmc 0 0x810c0000 u-boot.img
    reading u-boot.img
    389768 bytes read in 28 ms (13.3 MiB/s)
    U-Boot# fatload mmc 0 0x81200000 zImage
    reading zImage
    4117616 bytes read in 258 ms (15.2 MiB/s)
    U-Boot# fatload mmc 0 0x81a00000 arago-base-tisdk-image-am335x-evm.ubi
    reading arago-base-tisdk-image-am335x-evm.ubi
    32768000 bytes read in 2039 ms (15.3 MiB/s)
    U-Boot# nand write 0x81000000 0x0 0x2950000

    NAND write: device 0 offset 0x0, size 0x2950000
     43319296 bytes written: OK

    BR
    Ivan

  • Hi,
    I apologies for delay in replying due to shifted on other work. Now I am back on this NAND boot issue.
    Following is the procedure we have followed.


    Flashing images to NAND in SD boot
    Boot using SD boot mode as here.
    After the 2nd stage prompt U-Boot# comes up, the images for the 1st stage and 2nd stage can be flashed to NAND
    for persistent storage.

    U-Boot# mtdparts

    device nand0 <nand.0>, # parts = 10
    #: name size offset mask_flags
    0: NAND.SPL 0x00020000 0x00000000 0
    1: NAND.SPL.backup1 0x00020000 0x00020000 0
    2: NAND.SPL.backup2 0x00020000 0x00040000 0
    3: NAND.SPL.backup3 0x00020000 0x00060000 0
    4: NAND.u-boot-spl-os 0x00040000 0x00080000 0
    5: NAND.u-boot 0x00100000 0x000c0000 0
    6: NAND.u-boot-env 0x00020000 0x001c0000 0
    7: NAND.u-boot-env.backup10x00020000 0x001e0000 0
    8: NAND.kernel 0x00800000 0x00200000 0
    9: NAND.rootfs 0x3f600000 0x00a00000 0

    active partition: nand0,0 - (NAND.SPL) 0x00020000 @ 0x00000000

    defaults:
    mtdids : nand0=nand.0
    mtdparts: mtdparts=nand.0:128k(NAND.SPL),128k(NAND.SPL.backup1),128k(NAND.SPL.backup2),128k(NAND.SPL.backup3),256k(NAND.u-boot-spl-os),1m(NAND.u)

    Flashing SPL to NAND in SD boot
    Flash SPL (MLO) to NAND by executing the following commands:
    1) U-Boot# mmc rescan
    2) U-Boot# fatload mmc 0 0x82000000 MLO
    3) U-Boot# nand erase 0x0 0x20000

    NAND erase: device 0 offset 0x0, size 0x20000
    Erasing at 0x0 -- 100% complete.
    OK

    4) U-Boot# nand write 0x82000000 0x0 0x20000

    NAND write: device 0 offset 0x0, size 0x20000
    131072 bytes written: OK

    5) U-Boot# nand erase 0x20000 0x20000

    NAND erase: device 0 offset 0x20000, size 0x20000
    Erasing at 0x20000 -- 100% complete.
    OK

    6) U-Boot# nand write 0x82000000 0x20000 0x20000

    NAND write: device 0 offset 0x20000, size 0x20000
    131072 bytes written: OK

    7) U-Boot# nand erase 0x40000 0x20000

    NAND erase: device 0 offset 0x40000, size 0x20000
    Erasing at 0x40000 -- 100% complete.
    OK

    8) U-Boot# nand write 0x82000000 0x40000 0x20000

    NAND write: device 0 offset 0x40000, size 0x20000
    131072 bytes written: OK

    9) U-Boot# nand erase 0x60000 0x20000

    NAND erase: device 0 offset 0x60000, size 0x20000
    Erasing at 0x60000 -- 100% complete.
    OK

    10) U-Boot# nand write 0x82000000 0x60000 0x20000

    NAND write: device 0 offset 0x60000, size 0x20000
    131072 bytes written: OK

    11) Erasing as 128K block chunks /* Erasing spl-os mem locn, nothing to be put
    here*/
    U-Boot# nand erase 0x80000 0x20000

    NAND erase: device 0 offset 0x80000, size 0x20000
    Erasing at 0x80000 -- 100% complete.
    OK

    11) U-Boot# nand erase 0xa0000 0x20000

    NAND erase: device 0 offset 0xa0000, size 0x20000
    Erasing at 0xa0000 -- 100% complete.
    OK

    If no error messages are displayed the SPL of NAND boot has been successfully
    transferred to NAND.

    Flashing U-Boot to NAND in SD boot
    Flash the 2nd stage U-Boot (u-boot.img) to NAND by executing the following
    commands:
    1) U-Boot# mmc rescan

    2) U-Boot# fatload mmc 0 0x82000000 u-boot.img
    reading u-boot.img
    367884 bytes read in 31 ms (11.3 MiB/s)

    3) U-Boot# nand erase 0x000c0000 0x00100000

    NAND erase: device 0 offset 0xc0000, size 0x100000
    Erasing at 0x1a0000 -- 100% complete.
    OK

    4) U-Boot# nand write 0x82000000 0x000c0000 0x00100000

    NAND write: device 0 offset 0xc0000, size 0x100000
    1048576 bytes written: OK


    Please let us know if any thing we are missing .
  • Hi,

    Why are you using "nand write 0x82000000...". You have to write to "nand write 0x81000000...". Please see the previous post.

    BR
    Ivan
  • Hi ,
    I have used "nand.write 0x81000000 " still no progress.
    For step by step i am writing MLO & uboot.img only on nand for checking weather It is getting boot up to uboot prompt or not but ,it is not getting boot up.
    1) Does it need device tree ,zImage,rootfs to be present for nand boot to checck up to uboot prompt?
    2) If you can check in mtdparts in my previous post ,there is no partition for device tree . Do we have to create partition for device tree also?
    3) IS there any thing else we have to do for making NAND compatible image( MLO ,uboot img)?

    Thanks & Regards,
    Uday
  • We are using AM335x based custom board. and NAND is S34ML08G1. System gets boot fine from SD card but not getting boot from NAND.

    After uboot prompt comes up NAND cammands works fine. Even in Linux kernel NAND gets detected. But not getting boot from NAND.

    following sysboot options used
    SYSBOOR[15:14] SYSBOOR[13:12] SYSBOOR[11:10] SYSBOOR[9] SYSBOOR[8] SYSBOOR[7:6] SYSBOOR[5] SYSBOOR[4:0]
    01b 00b 00b 0b Dont care by ROM code Dont care by ROM code 1b 10011b
  • Hi team,
    waiting for help. Kernel is getting boot from NAND successfully. I am trying now ubifs.

    Thanks
  • Hi Mr. Uday,

    I presume you are using the SDK 7.x . correct?

    Also i hope you have done the changes needed for the Nand flash used on your custom board in uboot and ubl. Is it done?

    Also could you please try all the steps provided by Ivan as is? 

     

    Glad the uboot-> kernel boot is working fine.So the issue is with rbl-> ubl -> uboot steps.  

    Please let us know...

     

    Thanks

    Best Regards

    Feroz

     

  • Hi Feroz,
    Yes I am using sdk7.0.0 .

    NAND settings in am335x_evm.h

    * NAND: device related configs */
    #define CONFIG_SYS_NAND_PAGE_SIZE 2048
    #define CONFIG_SYS_NAND_OOBSIZE 64
    #define CONFIG_SYS_NAND_BLOCK_SIZE (128*1024)
    #define CONFIG_SPL_NAND_DEVICE_WIDTH 8
    #define CONFIG_SYS_NAND_5_ADDR_CYCLE
    #define CONFIG_SYS_NAND_PAGE_COUNT (CONFIG_SYS_NAND_BLOCK_SIZE / \
    CONFIG_SYS_NAND_PAGE_SIZE)
    /* NAND: driver related configs */
    #define CONFIG_NAND_OMAP_GPMC
    #define CONFIG_NAND_OMAP_ELM
    #define CONFIG_CMD_NAND
    #define CONFIG_SYS_NAND_BASE 0x8000000
    #define CONFIG_SYS_MAX_NAND_DEVICE 1
    #define CONFIG_SYS_NAND_ONFI_DETECTION
    #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

    Please let us know is it correct for the S34ML08G1 flash which we are using.
    I dont know what changes to be done in ubl.ls . Pelase let me know so that I will try .
    I have followed the steps from ivan. but using these steps only kernel gets boot from NAND no response for uboot.
    Thanks
    Uday
  • Hi Uday,

    If I understand well, now you can boot successfully from nand and you can start ubifs. Is it true? For ubifs you can you see the:
    http://e2e.ti.com/support/embedded/linux/f/354/p/391494/1387853#1387853

    BR
    Ivan
  • Hi Ivan,
    1) Uboot through NAND is not working.

    I am booting board upto uboot prompt through SD card then through u-boot I erased NAND and wrote device tree and zImage and in booting through NAND .So kernel is booting from NAND successfully. For UBIFS I have used prebuilt file system image "arago-base-tisdk-image-am335x-evm.ubi". With this image file system gets boot up till the starting deamon part but root prompt doesnt comes.
    I have created a one ubifs image but it is not getting start on board.
    Can I send you MLO built by me.( Give me mail info to send the same to you.) I thing there is a problem of header for NAND image. As It would be different for SD card and for NAND. But I didnt fine any reference about the same. I am flashing a NAND with same MLO file which exists on SD card.

    Thanks & Regards,
    Uday
  • Hi Ivan,

    The issue is with nand boot mode start. On hard power up, nothing is seen on the UART prompt. So issue seems to be the MLO or the reading of it from Nand.

    Is there some way to know if there can be a Nand issue in the first blocks where MLO and u-boot are stored? Or if the SD Card ‘s MLO needs to be changed for Nand boot? 

    Best REgards

    Feroz

  • Feroz,

    Can you check if NAND Ready/Busy signal is connected to GPMC_WAIT0? This is a requirement for NAND boot.

  • Hi Uday,

    O'K. In post from "Dec 22, 2014 7:57 AM" you explain that the boot pins are:"1b 10011b". If you see from the "http://processors.wiki.ti.com/index.php/AM335x_U-Boot_User%27s_Guide#Boot_Switch_Settings" - Boot Switch Settings you will see that the correct boot order is: ...10010 [4:0].

    BR
    Ivan
  • Hi Feroz,
    YEs NAND R/B signal is connected to GPMC_WAIT0 and thers is 10k pullup on this line.

    Thanks &Regards,
    Uday
  • Hi Ivan,
    with ...10010 board is not getting boot up. Nothing gets on console also.
    With ...10011 [4-0] atleast board boots from SD card.
    Our custom board is not having ethernet interface on the same. And we have shifted a console from UART0 to UART3.
    Thanks & Regards,
  • Hi Uday,

    OK. Did you change the console output to the ttyO3.

    BR
    Ivan
  • Also for your NAND you can use BCH8. See for more details doc/README.nand file.
  • Hi Ivan,
    Yes console output to ttyO3.
    Thanks & Regards,
    Uday
  • Hi Uday,

    It seems that all is OK. Would you read carefully from the http://www.ti.com/lit/er/sprz360f/sprz360f.pdf 3.1.4 and 3.1.6.

    BR
    Ivan
  • Hi Ivan,
    Link provided by you is not opening. Error occurs while opening the url.
    Thanks & Regards,
    Uday
  • Hi Iavn,
    I have tried to get the console output at UART0 while I am booting from NAND. I can see stream of letter C "CCCCCCCCCCCCCCCCCC" on uart0 console. So this means ROM boot loader is not able to read it from NAND.
    Thanks & Regards,
    Uday Rajeshirke.
  • Hi Uday,

    The "CCCCCCCCCCCCCCCCCC" means that your board is waiting to boot from uart0. The default console output is uart0. Please check console output configuration uart0 <--> uart3.

    BR
    Ivan
  • Hi Ivan,
    My Console output configured in uboot, kernel is uart3. I thought that before console gets change I can see some thing on uart0 through which I can get idea about the what is happening before I get some thing on uart3.
    But on uart0 I am getting CCCC.
    When I am using SD card U boot gets boot from SD card . Then I have boot_targets variable as NAND MMC0 so kernel gets boot from NAND. Even the ubifs fielsystem image which I have used pre-built one is also working fine from nand after kernel boot. I can get console after file system boot at uart0 as it is defined in pre-built ubifs image.
    Can you please share the ubifs making procedure used by TI to make the pre-built process as when I am making it it gives me error.

    but still my MLO, uboot not working from NAND. In other community issues I founf there is no any issue of image header for NAND, SD/emmc MLO, .Make me correct if I am wrong.

    Another thing I want to share is I am using a 10k pullup on NAND R/B pin .Is it ok Or should I have to chaneg it to some different value.

    When I am probing the NAND R/B signal I can see only single LOW to HIGH then LOW pulse .

    Thanks & Regards,
    Uday
  • Hi Uday,

    Once you see "CCCCCCCCCC" this means that your board uart is configured as ttyO0 (uart0). When the board is power up the boards start with boot ROM. It initialize uart0 and the message "CCCCCCC" is from there. This mean that your uart is connected to uart0 NOT to uart3. I suspect that you can boot normally from NAND without console messages.

    For the ubifs please see the following lins:
    http://processors.wiki.ti.com/index.php/UBIFS_Support
    http://processors.wiki.ti.com/index.php/MTD_Utilities
    http://www.linux-mtd.infradead.org/faq/ubi.html#L_ubi_mkimg

    BR
    Ivan
  • Hi Ivan,
    Host PC serial port is now connected to uart0 of board. Now i have compiled a uboot with console as a uart0. In this case also when I am using SD card board boots up ok. Kernel , ubifs file system also getting ok from NAND.
    As soon as I remove a SD card nothing is happening on console .
    When I am using sysboot config where uart boot is not an option I am not getting letter C on console.
    sysboot config [0-4] 11010 --USB ,NAND,SPI0,MMC0 with this I am not getting anything on console when trying to boot from NAND.

    Thanks & Regards,
    Uday
  • Hi Ivan,
    My NAND boot problem is solved. Actually the issue was with sysbootpin-10 as it was not getting LOW for NAND boot through hardware. After making these changes now board is booting up from NAND.
    Thanks for your support.
    Another issues I am facing are as follows.
    1) UBIFS making
    2) Wi-fi wl-18xx
    3) Audio codec -TLV320AIC3106
    4) TS2543-Q1 compatibility for USB.
    I will create a new thread for above problems.
    Thanks & Regards,
    Uday
  • O'K Uday,

    Please would you close the thread.

    BR
    Ivan