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.

How to get exact size of the image from the nand using nand read in u-boot?

Hi All,

 # For flashing the image into nand thr  u-boot , we generaly follow the sequence like

mmc rescan 0
mw.b 0x82000000 0xFF 0x20000
fatload mmc 0 0x82000000 MLO

(here say 38000 bytes read i.e size of MLO)
nandecc hw 2
nand erase 0x0 0x20000
nand write.i 0x82000000 0x0 0x20000

(while writing we write 0x20000 bytes).

# but in reverse case , suppose i have to read the MLO from the nand i.e only size of MLO .

i can use the nand read command in u-boot , but how i get the exact size of the MLO.? ......if i read the entire size and create the new backup MLO  but the original and backup MLO size may be different.

Can any one help me on this issue and correct me if am wrong?

  • Surendra,

    You can get the info by reading the first page of NAND, and then parse the first 4 bytes of it. This will say the size of the MLO file. The next 4 bytes will say the load address. Remaining bytes will contain the x-loader executable. 

    Hope this will help you.

    Alternate way of verifying the same is by doing memory dump. You should be able to see the bytes 0xFF 0XFF from where the MLO ends. 

  • Renjith,

    Thanks for your valuable reply. I get the idea. I will try with this solution.

    I have one another doubt , regarding MLO , How we check the CRC or integrity of the MLO image?

  • Hi Surendra,

    I am not sure about CRC checking, but if the NAND read is successful, then you can assume that the data is correct, because the ECC logic(hw/sw) inside NAND driver should figureout if there is any corruption. If there is it will try to correct upto few bits. Above that it will fail.

    So if you are able to read the data successfully, you can assume that data is proper.