I have used following steps to flash nand on my board from u-boot.
Loaded kernel from sdcard to RAM
#mmc read ${loadaddr} 0x800 0x1800
Erased nand flash using nand erase command.
#nand erase offset size
Copied kernel from RAM to nand.
#nand write ${loadaddr} offset size
I want to do the same steps in Kernel, can you guide me how to copy data from sdcard to RAM in kernel(looking for alternate command for u-boot "mmc read"). I am using IMX53 based custom board.
It is not recommended to do that as it may block the kernel, it is recommended to do it in uboot itself or you should write your code in proper manner concerned with locking and sync.
For doing it you can create a function for by using nand & mmc driver function. NAND read/write MMC read/write can be by calling their respective read write Using NAND funtions from kernel and MMC Kernel API reference respectively.
Then call your function inside file /init/main.c
and function __init start_kernel(void)
here.
And your function you can declare in the same file somewhere at last.