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.

NAND Flash with AM335x

Hi All,

        I am trying to boot my boot from NAND Flash , for that I have I have modify  my boardevm.c and Able to create partition of  SPL, Uboot, kernel, file-system and I trying to write those files from my SD card to NAND flash in appropriate partition :

For that I have some Question :

Q: Files -> SPL ,Uboot-img , uImage , Env.txt is only required to boot from NAND ?

Q: How to Load Filesystem to the NAND Flash ?

Q: Is Root->files present in SD card are also written to NAND Flash , because psplash and other application are there in Root Partition ?   

Any Suggestion will be greatful to me ..

Best Regards :

Praveen

  • Hi Praveen,

    For booting from NAND flash you have to modify the U-Boot, Linux, and convert the file system to appropriate file system type (ie JFFS2, UBIFS ..)

    1. The same files are required but you have to modify them to Boot from NAND Flash.

    2. For loading file system in to NAND there are two ways with using u-boot with ramfs support,  (a) create file system image in host system and burn it using user space tools.  (b) Format the partition in to required File system type and mount it, later copy entire files.

    3. After Flashing all the files of root file system to NAND flash there is no need of files again in SD card, we can use SD card as external memory. 

  • Hi Praveen,

    Q: Files -> SPL ,Uboot-img , uImage , Env.txt is only required to boot from NAND ?

    You need to understand the boot sequence of ARM.

    X-Loader meant by  (MLO or SPL)

    Please refer the following TI wiki link to understand.

    http://omappedia.org/wiki/Bootloader_Project#OMAP_Boot_Sequence

    Q: How to Load Filesystem to the NAND Flash ?

    Two types are there.

    1) You can write filesystem image into NAND flash partiton at u-boot prompt shell.

    2) You have to boot linux then flash filesystem image or tar ball(*.tar.gz) into NAND flash,

    Which processor are you using ?

    http://processors.wiki.ti.com/index.php/UBIFS_Support#Creating_UBIFS_file_system

    http://processors.wiki.ti.com/index.php/AM335x_NAND_Driver%27s_Guide

    Steps :


    Boot your system with any type of booting method (initramfs or NFS booting) & do the below commands to flash rootfs into NAND flash.

    root@am3517-evm:/# flash_eraseall /dev/mtd4

    root@am3517-evm:/# mount -t jffs2 /dev/mtdblock4 /mnt

    root@am3517-evm:/# cd /mnt

    root@am3517-evm:/# tar -zxvf /rootfs.tar.gz

    root@am3517-evm:/# cd /

    root@am3517-evm:/# sync

    root@am3517-evm:/# umount /mnt

    root@am3517-evm:/# init 0


    Do the below command to write the env variable for jffs2 boot in u-boot terminal

    u-boot # setenv nandargs setenv bootargs 'console=${console} rootwait=5 rw root=/dev/mtdblock4 rootfstype=jffs2'

    u-boot # saveenv

  • Hi  Titusrathinaraj  &  Sreenivas,

          Thanks for the Quick Reply !!

          Gone through your given link it was very useful .

          I am working on AM335x;     

    Regarding Partition I have Created four  that belongs to mtd1 for SPL ; mtd2 for U-boot; mtd3 for kernel and ;mtd4 for file-system; 

    And found something to write on nand like this :

    Flashing SPL to NAND in SD boot


    Flash SPL (MLO) to NAND by executing the following commands:

    U-Boot# mmc rescan

    U-Boot# fatload mmc 0 0x82000000 MLO
    U-Boot# nand erase 0x0 0x20000
    U-Boot# nand write 0x82000000 0x0 0x20000


    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:

    U-Boot# mmc rescan
    U-Boot# fatload mmc 0 0x82000000 u-boot.img
    U-Boot# nand erase 0x80000 0x40000
    U-Boot# nand write 0x82000000 0x80000 0x40000





     Following this is perfect Or I have to go through ->JFFS2  filesystem to mount -> nandwrite -> unmount  for MLO , U-boot and uImage ;

    As you told me to for file-system ;

    Thank you

    Best Regards

    Praveen

  • Hi Praveen,

    If you are using AM335x then better to follow the procedure which you posted previous reply for SPL and u-boot and please use UBIFS for filesystem.

    We have two types for flashing UBIFS filesystem into NAND flash.

    1) At u-boot shell.

    Copy the ubi.img file into MMC/SD card

    u-boot# mw.b 0x82000000 0xFF 
     u-boot# mmc rescan
     u-boot# fatload mmc 0 0x82000000 ubi.img
    u-boot# nand erase 0x780000 0xF880000 u-boot# nand write 0x82000000 0x780000 0xFC0000
    0x780000  --> This address should be the starting address of mtd7 partition.
    #setenv bootargs 'console=ttyO0,115200n8 noinitrd ip=off mem=256M rootwait=1 rw ubi.mtd=7,2048 rootfstype=ubifs root=ubi0:rootfs init=/init'

    2) At Linux shell with the help of NFS or initramfs (ramdisk) booting.

    Use the below TI wiki link.

    U-boot

    http://processors.wiki.ti.com/index.php/AM335x_U-Boot_User%27s_Guide#UBIFS_file_system_flashing

    Linux

    http://processors.wiki.ti.com/index.php/UBIFS_Support#Creating_UBIFS_file_system

  • Hi ,

       When I am writing SPL and U-boot.img and uImage (Till the system not boot I am not Writing File system to NAND)  it shows written and after typing boot it boot as normally boot but when I switch off and then on my kit did not recognizing Nand Flash I dont know why but its not Showing NAND Detection how could i move forward ; Pls let me know first  to boot the system then I will try for File system ;

    --> After nand write i have to save also  ?

    --> Why it most of the time showing it is not detected when restarted  after i have wirtten some data on NAND ?

    --> Is there May be some Address Issue ; I am using 1GB NAND Flash for my Application ?

    Thanks for you Reply!!

  • Hi Praveen,

    --> After nand write i have to save also  ?

    Not required,

    --> Why it most of the time showing it is not detected when restarted  after i have wirtten some data on NAND ?

    Can you please attach your bootup logs before & after you faced the mentioned issues.

  • Hi Titusrathinaraj ,

         I am reply late ; Thank you for your Patience; 

         I am Uploading two files In which I can see NAND is detected , While in Other I have did the 8 Partition ;

        Pls have a look is there any thing wrong I have did ?0027.NANDlogFile.txt5657.LogFor8Partition.txt

  • Hi Praveen,

    After Comparing the both attached logs,

    I found that you are using different kernel version;

       Data Size:    3148896 Bytes = 3 MiB
    [    0.000000] Linux version 3.2.0 (root@ubuntu) (gcc version 4.5.3 20110311 (prerelease) (GCC) ) #1 Mon Mar 3 15:29:06 IST 2014

       Data Size:    3148136 Bytes = 3 MiB
    [    0.000000] Linux version 3.2.0 (root@ubuntu) (gcc version 4.5.3 20110311 (prerelease) (GCC) ) #1 Mon Mar 3 09:23:41 IST 2014

    As per the logs that one kernel has GPMC support which is required for NAND support(CS) and another one is does not.

    [    0.191864] omap-gpmc omap-gpmc: GPMC revision 6.0
    [    0.191894] Registering NAND on CS0

    Please check your flash procedure.

  • Hi Titusrathinaraj , 

        I have tried to Write NAND with the following Command :-

    U-Boot# mmc rescan
    U-Boot# fatload mmc 0 0x82000000 MLO
    U-Boot# nand erase 0x0 0x20000
    U-Boot# nand write 0x82000000 0x0 0x20000

    U-Boot#mmc rescan
    U-Boot#fatload mmc 0 0x82000000 u-boot.img
    U-Boot#nand erase 0x80000 0x40000
    U-Boot#nand write 0x82000000 0x80000 0x40000

    U-Boot#mmc rescan
    U-Boot#fatload mmc 0 0x82000000 uImage
    U-Boot#nand erase 0x280000 0x500000
    U-Boot#nand write 0x82000000 0x280000 0x500000

    U-Boot# mmc rescan
    U-Boot# fatload mmc 0 0x82000000 uEnv.txt
    U-Boot# env import -t 0x82000000 $filesize

     

    After this I have tried to read the content i have wrritten to it  but I found some error  as you can see in next image;

    Pls suggest what should I do !!!

    Thank Alot for your time

  • Hi,

    What is the purpose of this command & Why do you prefer this?

    nand read 0x82000000 0x0 0x20000

    Do this one

    nand read 0x82000000 0x280000 0x500000

    bootm 0x82000000

    In general,

    We will boot the board (with empty NAND flash) from SD card,

    At u-boot, We will write MLO,u-boot,kernel and filesystem (if reqd)

    After wrote everything,  We do nand read only for kernel for copying uImage from NAND flash to RAM (

    fatload mmc 0 0x82000000 uImage

    )and need to mount fs through NFS mode or from SD card fs (/dev/mmcblk0p2 )

    Ex:

    bootargs=console=ttyO0,115200n8 root=/dev/mmcblk0p2 mem=128M rootwait
    bootcmd=mmc rescan; fatload mmc 0 0x82000000 uImage; bootm 0x82000000

    Anyway it should read everything without issue including MLO content as your case,

    Can you please try this & let us know.

    fatload mmc 0 0x82000000 uImage

    http://processors.wiki.ti.com/index.php/AM335x_U-Boot_User%27s_Guide
    http://processors.wiki.ti.com/index.php/Sitara_Linux_Software_Developer%E2%80%99s_Guide
    http://processors.wiki.ti.com/index.php/AM335x_PSP_User%27s_Guide


    or, mount through NFS or SD card fs (/dev/mmcblk0p2 )

  • Hi Titusrathinaraj ,

    I have gone through the follwing Links and Found

    https://support.criticallink.com/redmine/boards/28/topics/1437?r=3602

    http://e2e.ti.com/support/arm/sitara_arm/f/791/t/238825.aspx

    then tried :

    U-Boot# mmc rescan
    U-Boot# fatload mmc 0 0x82000000 MLO
    U-Boot# nandecc hw 2
    U-Boot# nand erase 0x0 0x20000
    U-Boot# nand write.i 0x82000000 0x0 0x20000

    While writng I didnt find any error but while reading I got this Error ;

    but still got error "wrong EEC" when tried to read from NAND Flash ;

    Then I Checked Bad Blocks

    U-Boot#nand bad 

    Device Bad Block:

    05240000

    Thanks Alot :;

  • Hi,

    nand write.i 0x82000000 0x0 0x20000

    mmc rescan

    nand erase 0x0 0x20000

    fatload mmc 0 0x82000000 MLO

    nandecc hw 2

    nand write 0x82000000 0x0 0x20000

    PFA.

    1563.uboot_flash.txt

  • Hi Titusrathinaraj ,

         I have written all files to NAND except filesystem ; Now I want to boot from NAND ;

    When I have tried to set switches as per the instruction in  "AM335x U-Boot User's Guide"  I didn't seen any thing on my screen ;

    -> I have not modifies bootargs till is that is the reason ?

    ->after nand write I have type " boot"  then Switch off  AM335x system ; --> select selection switches  according to above mention file ; tried to boot from NAND but i cant see any thing on my console .

     

    Thank you for constant support ;

     

  • Hi Praveen,

    Try to check whether the MLO and u-boot has been written properly into NAND flash,

    1)

    Boot from SD card

    U-Boot# mmc rescan
    U-Boot# fatload mmc 0 0x82000000 MLO
    U-Boot# nand erase 0x0 0x20000
    U-Boot# nand write 0x82000000 0x0 0x20000

    U-Boot#mmc rescan
    U-Boot#fatload mmc 0 0x82000000 u-boot.img
    U-Boot#nand erase 0x80000 0x40000
    U-Boot#nand write 0x82000000 0x80000 0x40000

    Change the boot jumper settings to NAND flash

    Reset the board & check whether the board is booting u-boot from NAND flash on console.

    2)Try to load the image through kermit (UART boot mode)

    http://processors.wiki.ti.com/index.php/AM335x_U-Boot_User%27s_Guide#Boot_Over_UART

  • Hi Titusrathinaraj ,

        I have followed the 1st step Boot From SD Card ;

        written Each Block As Mention ;

      apart from that tried to Load Back up also;

    SPL ,SPL backup.1 SPL backup.2,SPL backup.3,u-boot-img

    """Change the boot jumper settings to NAND flash

          Reset the board & check whether the board is booting u-boot from NAND flash on console."""""

    here  I didnt find any thing nothing got display ; 

    Is there Some hardware pin need to be enable to Read the NAND Flash in Hardware That must it missing

    I am Attaching my NAND Connection pls Have a look!!

    Out of Which R31 and R32 is not connected Is it required ??

     

    Result on Oscilloscope are :-

    --When Booting from SD Card  Change on PIN RE '  pulled Down and the n got Pulled Up;

    -- While nand write WE ' pin is getting Low ;

    -- On I/O pin there is pulses generated  while nand writing;

    Is R32 and R31 are reqired ??

  • Hi Titusrathinaraj ,

        I have tried to write nand  but not able to boot from NAND ; could u suggest me what should be bootcmd & bootargs for NAND boot so that it boot from NAND flash ;

  • Hi All,

        I have modified bootcmd in from U-boot# terminal ; and I can able to load kernel from NAND ;

    To be sure I have removed uImage Image file from SD Card(MLO , uboot.img , uEnv.txt) and I can able to load Kernel from NAND ;

    but the Issue is ;

    I am not able find the way to boot from NAND after setting SYSBOOT pins ON OFF OFF ON ON  and ON OFF OFF ON OFF respectively 5,4,3,2,1;

    I cant see any Changes on Screen ;

    Pls do suggest I am lacking Some thing ;

    Thank for your support

  • Hi Praveen,

    Sorry for the delayed response,

    I'm not a h/w expert.

    I am not able find the way to boot from NAND after setting SYSBOOT pins ON OFF OFF ON ON  and ON OFF OFF ON OFF respectively 5,4,3,2,1;

    I don't have a AM335x EVM board with me to check.

    Have you maintained/followed boot jumper h/w schematics for your custom board to ensure that you are not having problem on NAND booting(NAND boot settings).

    To be sure I have removed uImage Image file from SD Card(MLO , uboot.img , uEnv.txt) and I can able to load Kernel from NAND ;

    I think that you may have tried the following, If not then please follow and let me know the status.

    To ensure that NAND was working good,

    1) Boot from SD card,

    2) Read kernel image from SD card to RAM and write into NAND flash.

    U-Boot#mmc rescan
    U-Boot#fatload mmc 0 0x82000000 uImage
    U-Boot#nand erase 0x280000 0x500000
    U-Boot#nand write 0x82000000 0x280000 0x500000

    3) Reset the board (power OFF and ON)

    U-Boot# reset

    4) Read kernel image from NAND to RAM and do "bootm"

    U-Boot#nand read 0x82000000 0x280000 0x500000

    U-Boot#bootm 0x82000000

    Please let me know the status

  • Hi Titusrathinaraj ,

         Thanks for your reply ;

    As you Said I have did the Same booting from SD card --> U-boot terminal --> Nand write for MLO , u-boot.img & Kernel ;

    -->Modify bootcmd  variable as you Mention;

    setenv bootcmd 'nand read 0x82000000 0x280000 0x500000 ;bootm 0x82000000'


    It is booting SD Card and  Uncompressing Kernel from NAND ;  So , NAND is Working No Issue ;

    -----------------------

    for Filesystem I have made rootfs.img Next I will try to load file system as u have said erlier;

     

    But How to Directly boot from NAND ??? While I have written MLO ;u-boot.img but my evm board booting from SD Card and uncompressing kernel from NAND ?

     

    Thanks for your support!!

     

  • Hi Praveen,

    But How to Directly boot from NAND ??? While I have written MLO ;u-boot.img but my evm board booting from SD Card and uncompressing kernel from NAND ?


    1) You have written MLO and u-boot in NAND flash

    2) Set the boot jumper to NAND flash boot

    3) The MLO and u-boot will boot from NAND flash,

    If you are  facing any problem while booting from NAND at step 3

    then it could be the problem of following

    1) It could be the problem of boot jumper settings of NAND (May be It doesn't set to NAND boot setting)

    2) Way of writing into NAND for MLO and u-boot. (related to ECC)

    Have you changed u-boot source code for your custom board.

    3) May be timing issue in NAND flash

    4) Please check your NAND flash part no whether your NAND flash is supported by RBL

    http://processors.wiki.ti.com/index.php/List_of_NANDs_devices_supported_by_TI_RBLs

    What is your NAND flash part no ?

    Please share your bootup log (u-boot).

  • Hi Titusrathinaraj ,

          I have gone through  your suggestion ;

    It could be the problem of boot jumper settings of NAND (May be It doesn't set to NAND boot setting)


    ->I have checked its fine although i have performed all setting releted to NAND ; May be some other harware issue if it is ?

            Way of writing into NAND for MLO and u-boot. (related to ECC)

    --> I have follewed nand write is it not proper way ; while from nand I can able to access Kernel  for that there is no    issue;

            Have you changed u-boot source code for your custom board.

          --> No I have not change MLO and u-boot.img for my custom board. Is this is required  for specific board ..

    Please check your NAND flash part no whether your NAND flash is supported by RBL

       --> NAND is Comapatible with my TI RBL it is H27U1G8F2B Series

    and I am attaching the uboot file;

    2781.bcd.txt

    pls have look

      Thanks for support