Because of the holidays, TI E2E™ design support forum responses will be delayed from Dec. 25 through Jan. 2. Thank you for your patience.

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.

U-Boot: how to write to SD / MMC?

I'm trying to "clone" our working (development) NAND flash so I can then program it into multiple boards. My initial idea was to use U-Boot to read the NAND flash contents:

U-Boot# nand read 0x80000000 0 0x4000000

and then write that data to a file on the MMC / SD Card.

"Cloning" then becomes a simple matter of reading the file from the MMC / SD card and writing it to flash:

U-Boot# fatload mmc 0 0x80000000 clone.bin

U-Boot#: nand erase.chip

U-Boot# nand write.i 0x80000000 0 0x4000000

Well, that was the idea. In practice I'm currently stuck on the part where I try to write the NAND flash data to the MMC / SD card. There doesn't appear to be any way to write to the card, that I can see anyway.

Any suggestions on how to do this (or suggestions on alternate ways of achieving the same goal)?  Thanks.

  • The mainline U-boot has support for the fatwrite command. Never used it myself. Heard of others being able to back-port the fatwrite code to their TI based U-boot code.

    If you are booting up into Linux, you could access the NAND memory as a MTD partition from there. Depending on the configuration, TFTP it out or save it the SD Card.

  • I've been trying to do it in linux but it's not working for a quite different reason. If I try this:

    cat /dev/mtd0 > /media/mmcblk0p1/mtd0.bin

    it works fine. But if I try the same with a larger mtd block:

    cat /dev/mtd7 > /media/mmcblk0p1/mtd7.bin

    linux crashes, dumping a whole bunch of printout to the console, when it's created a file of around 18 - 20 MB in size (the exact file size varies each time, but it's in that range). My guess is it's trying to buffer the whole thing, and simply running out of RAM to do it.

    Hmm.

  • It's been a while. Never had much sucess with cat and cp with MTDs. I remember using mtdutils like flashcp to properly write into flash. However mtdutils don't provide any reading utilities. Perhaps try the dd command:

    dd if=/dev/mtd7 of=/media/mmcblk0p1/mtd7.bin

    It has the block size "bs" option that should limit the transfer size.

  • Hi,

    nanddump commad can be used to read from nand flash in Linux

    usage

    nanddump -o /dev/mtd<x> -f <output file> -s <start offset> -l <size of data>

    Thanks, Avinash

  • Thanks for the suggestions.