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.

Cannot get custom AM3352 board to boot from NAND

We have a custom board based on the am335x-evm design. I have it booting from the SD card, but I need to make it boot from the onboard NAND. I have the partitions set up correctly (I think) in the dts file, and I am able to format the partitions and copy all of the files from the SD card to the NAND in Linux. I am not able to access the NAND flash from uboot. Every time I try to erase the NAND from uboot I get an error and it tells me to reset the board. The uboot is version 2013.10-00189-g78d8ebd-dirty (which I inherited from a previous developer). Does anyone have suggestions for:

1. Exactly how should the first partitions in the NAND be configured and formatted from Linux to store the MLO, u-boot.img, and kernel files?

2. Any ideas on why uboot is not able to erase or write to NAND?

3. Anything I am missing?

Thanks for your help. in advance.

  • Hi,

    This may be an ECC issue. What is the page/spare area size of your NAND? What is your Linux version?
  • The NAND chip is a Micron MT29F4G16ABADAWP, 512MiB, with a page size of 2048, OOB size 64.

    Linux version is Linux am335x-evm 3.12.10-ti2013.12.01
  • This will require BCH-8, which is default in the kernel you use. Have you checked if the NAND is write-protected?
  • Both the write protect line and the write enable line are high, which enables writing. Is there something else that I can check or set in u-boot to enable writing? I do know that once I get up and running Linux, the NAND is writable. I really do appreciate your patience here in helping me. I have been programming embedded systems for more than 30 years, but this is my first experience with NAND flash.

  • Can you post the log file where you get the errors in U-boot? I will ask the software team to check this.
  • Here is the screen log:
    CCCCCCCC
    U-Boot SPL 2013.10-00189-g78d8ebd-dirty (Jul 06 2015 - 10:42:55)

    Enabling I2C Pin Mux
    Initializing I2C...
    Reading Board ID... Silicon Rev: 2, MPU Vdd: 56, efuse max MPU freq: 800

    Found card: OMAP SD/MMC, Device #0, Addr: 80a00508
    reading args
    spl: error reading image args, err=-1
    reading u-boot.img
    reading u-boot.img


    U-Boot 2013.10-00189-g78d8ebd-dirty (Jul 06 2015 - 10:42:55)

    I2C: Ready
    DRAM: 512 MiB
    monitor flash len: 374756 (0x0005B7E4)
    Now running in RAM - U-Boot at: 0x9F752000
    NAND: 512 MiB
    MMC: OMAP SD/MMC: 0, OMAP SD/MMC: 1
    Env: bad CRC, using default environment
    Net: <ethaddr> not set. Validating first E-fuse MAC. Adding <ethaddr> to environment (fc): 68:c9:0b:4e:42:f3 (0)
    <eth1addr> not set. Adding <eth1addr> to environment (fc): 68:c9:0b:4e:42:f5 (0)
    Generic PHY reset timed out
    cpsw connected to Generic PHY

    cpsw, usb_ether
    Hit any key to stop autoboot: 0
    U-Boot# nand
    nand - NAND sub-system

    Usage:
    nand info - show available NAND devices
    nand device [dev] - show or set current device
    nand read - addr off|partition size
    nand write - addr off|partition size
    read/write 'size' bytes starting at offset 'off'
    to/from memory address 'addr', skipping bad blocks.
    nand read.raw - addr off|partition [count]
    nand write.raw - addr off|partition [count]
    Use read.raw/write.raw to avoid ECC and access the flash as-is.
    nand erase[.spread] [clean] off size - erase 'size' bytes from offset 'off'
    With '.spread', erase enough for given file size, otherwise,
    'size' includes skipped bad blocks.
    nand erase.part [clean] partition - erase entire mtd partition'
    nand erase.chip [clean] - erase entire chip'
    nand bad - show bad blocks
    nand dump[.oob] off - dump page
    nand scrub [-y] off size | scrub.part partition | scrub.chip
    really clean NAND erasing bad blocks (UNSAFE)
    nand markbad off [...] - mark bad block(s) at offset (UNSAFE)
    nand biterr off - make a bit error at offset (UNSAFE)
    U-Boot# nand info

    Device 0: nand0, sector size 128 KiB
    Page size 2048 b
    OOB size 64 b
    Erase size 131072 b
    U-Boot# nand erase.chip

    NAND erase.chip: device 0 whole chip


    nand_base.c::2326
    ### ERROR ### Please RESET the board ###
  • Hi,

    You are trying the following procedure:
    processors.wiki.ti.com/.../Linux_Core_U-Boot_User's_Guide
    right?

    As Biser suggested, keep the ECC scheme BCH8:
    processors.wiki.ti.com/.../AM335x_U-Boot_User's_Guide

    Check am335x_evm.h. Also can you share the output of printenv?

    Also the last line right before the RESET message: "nand_base.c::2326" indicates that your nand may contain bad blocks, see line 2326 in drivers/mtd/nand/nand_base.c. Can you test your nand chip:
    1. from u-boot execute:
    nand bad
    2. from linux user space use the mtd-utils tests:
    www.linux-mtd.infradead.org/.../general.html

    Best Regards,
    Yordan
  • Yes, I am trying to use the procedure indicated.

    Yes, the ECC scheme is set to BCH8.

    U-Boot# printenv

    arch=arm

    baudrate=115200

    board=falcon

    board_name=TFalcon

    board_rev=C▒▒

    boot_fdt=try

    boot_targets= mmc0 nand

    bootcmd=for target in ${boot_targets}; do run bootcmd_${target}; done

    bootcmd_mmc0=setenv devnum 0; setenv rootpart 2; run mmc_boot;

    bootcmd_nand=run nandboot;

    bootcmd_usb=setenv devnum 0; run usb_boot;

    bootdelay=3

    bootdir=/boot

    bootenv=uEnv.txt

    bootfile=zImage

    bootpart=0:2

    console=ttyO0,115200n8

    cpu=armv7

    dfu_alt_info_emmc=rawemmc mmc 0 3751936

    dfu_alt_info_mmc=boot part 0 1;rootfs part 0 2;MLO fat 0 1;MLO.raw mmc 100 100;u-boot.img.raw mmc 300 400;spl-os-args.raw mmc 80 80;spl-os-image.raw mmc 900 2000;spl-os-args fat 0 1;spl-os-image fat 0 1;u-boot.img fat 0 1;uEnv.txt fat 0 1

    dfu_alt_info_nand=NAND.SPL part 0 1;NAND.SPL.backup1 part 0 2;NAND.SPL.backup2 part 0 3;NAND.SPL.backup3 part 0 4;NAND.u-boot-spl-os part 0 5;NAND.u-boot part 0 6;NAND.u-boot-env part 0 7;NAND.u-boot-env.backup1 part 0 8;NAND.kernel part 0 9;NAND.rootfs part 0 10

    dfu_alt_info_ram=kernel ram 0x80200000 0xD80000;fdt ram 0x80F80000 0x80000;ramdisk ram 0x81000000 0x4000000

    eth1addr=68:c9:0b:4e:42:f5

    ethact=cpsw

    ethaddr=68:c9:0b:4e:42:f3

    fdt_high=0xa0000000

    fdtaddr=0x80F80000

    fdtfile=undefined

    findfdt=if test $board_name = A335BONE; then setenv fdtfile am335x-bone.dtb; fi; if test $board_name = A335BNLT; then setenv fdtfile am335x-boneblack.dtb; fi; if test $board_name = A33515BB; then setenv fdtfile am335x-evm.dtb; fi; if test $board_name = A335X_SK; then setenv fdtfile am335x-evmsk.dtb; fi; if test $board_name = TFalcon; then setenv fdtfile tsfalcon.dtb; fi; if test $fdtfile = undefined; then echo WARNING: Could not determine device tree to use; fi;

    importbootenv=echo Importing environment from mmc ...; env import -t $loadaddr $filesize

    loadaddr=0x80200000

    loadbootenv=load mmc ${mmcdev} ${loadaddr} ${bootenv}

    loadfdt=load mmc ${bootpart} ${fdtaddr} ${bootdir}/${fdtfile}

    loadimage=load mmc ${bootpart} ${loadaddr} ${bootdir}/${bootfile}

    loadramdisk=load mmc ${mmcdev} ${rdaddr} ramdisk.gz

    mmc_boot=setenv devtype mmc; if mmc dev ${devnum}; then run mmcargs;run scan_boot; run mmcboot;setenv mmcdev 1; setenv bootpart 1:2; run mmcboot;fi

    mmcargs=setenv bootargs console=${console} ${optargs} root=${mmcroot} rootfstype=${mmcrootfstype}

    mmcboot=mmc dev ${mmcdev}; if mmc rescan; then echo SD/MMC found on device ${mmcdev};if run loadbootenv; then echo Loaded environment from ${bootenv};run importbootenv;fi;if test -n $uenvcmd; then echo Running uenvcmd ...;run uenvcmd;fi;if run loadimage; then run mmcloados;fi;fi;

    mmcdev=0

    mmcloados=run mmcargs; if test ${boot_fdt} = yes || test ${boot_fdt} = try; then if run loadfdt; then bootz ${loadaddr} - ${fdtaddr}; else if test ${boot_fdt} = try; then bootz; else echo WARN: Cannot load the DT; fi; fi; else bootz; fi;

    mmcroot=/dev/mmcblk0p2 ro

    mmcrootfstype=ext4 rootwait

    mtddevname=NAND.SPL

    mtddevnum=0

    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-boot),128k(NAND.u-boot-env),128k(NAND.u-boot-env.backup1),8m(NAND.kernel),-(NAND.rootfs)

    nandargs=setenv bootargs console=${console} ${optargs} root=${nandroot} rootfstype=${nandrootfstype}

    nandboot=echo Booting from nand ...; run nandargs; nand read ${fdtaddr} NAND.u-boot-spl-os; nand read ${loadaddr} NAND.kernel; bootz ${loadaddr} - ${fdtaddr}

    nandroot=ubi0:rootfs rw ubi.mtd=NAND.file-system,2048

    nandrootfstype=ubifs rootwait=1

    netargs=setenv bootargs console=${console} ${optargs} root=/dev/nfs nfsroot=${serverip}:${rootpath},${nfsopts} rw ip=dhcp

    netboot=echo Booting from network ...; setenv autoload no; dhcp; tftp ${loadaddr} ${bootfile}; tftp ${fdtaddr} ${fdtfile}; run netargs; bootz ${loadaddr} - ${fdtaddr}

    nfsopts=nolock

    partition=nand0,0

    partitions=uuid_disk=${uuid_gpt_disk};name=rootfs,start=2MiB,size=-,uuid=${uuid_gpt_rootfs}

    ramargs=setenv bootargs console=${console} ${optargs} root=${ramroot} rootfstype=${ramrootfstype}

    ramboot=echo Booting from ramdisk ...; run ramargs; bootz ${loadaddr} ${rdaddr} ${fdtaddr}

    ramroot=/dev/ram0 rw ramdisk_size=65536 initrd=${rdaddr},64M

    ramrootfstype=ext2

    rdaddr=0x81000000

    rootpart=2

    rootpath=/export/rootfs

    scan_boot=echo Scanning ${devtype} ${devnum}...; for prefix in ${bootdir}; do for script in ${bootfile}; do run script_boot; done; done;

    script_boot=if load ${devtype} ${devnum}:${rootpart} ${loadaddr} ${bootdir}/${bootfile}; then run findfdt; load ${devtype} ${devnum}:${rootpart} ${fdtaddr} ${bootdir}/${fdtfile};fi;

    soc=am33xx

    spiargs=setenv bootargs console=${console} ${optargs} root=${spiroot} rootfstype=${spirootfstype}

    spiboot=echo Booting from spi ...; run spiargs; sf probe ${spibusno}:0; sf read ${loadaddr} ${spisrcaddr} ${spiimgsize}; bootz ${loadaddr}

    spibusno=0

    spiimgsize=0x362000

    spiroot=/dev/mtdblock4 rw

    spirootfstype=jffs2

    spisrcaddr=0xe0000

    static_ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off

    stderr=serial

    stdin=serial

    stdout=serial

    usb_boot=setenv devtype usb; run usb_init; if usb dev 0; then run usbargs;run scan_boot; bootz ${loadaddr} - ${fdtaddr}; fi

    usb_init=usb start 0;

    usbargs=setenv bootargs console=${console} ${optargs} root=${usbroot} rootfstype=${usbrootfstype}

    usbnet_devaddr=68:c9:0b:4e:42:f5

    usbroot=/dev/sda2 rw

    usbrootfstype=ext4 rootwait

    vendor=smt

    ver=U-Boot 2013.10-00189-g78d8ebd-dirty (Jul 06 2015 - 10:42:55)

     

    Environment size: 5544/131067 bytes

    U-Boot# <INTERRUPT>

    U-Boot#

     

    The nand bad test does not show any bad blocks, but I believe this is because the entire chip was erased earlier, including the bad block table. Is there a way to recreate the bad block table?

  • I do have the ability to edit and rebuild the u-boot executable. Are there any suggestions for where I should be looking in the code? I would assume that there is a problem in the files that were modified for our board.