The platform is MIPS, and the kernel is linux 2.6.31.
First, I reserve 8M RAM zone, out of total RAM of 64M, so the kernel only uses 56M RAM zone.
Second, I use the ioremap()
function to transform the physical address to a virtual address in kernel, then write my data. Like this:
void *virt_addr = (void *)ioremap(0x83800000,0x800000);//0x83800000 is the start physical address of 8M
memset_io(virt_addr,0,0x800000);
memcpy_toio(virt_addr,buf,0x800000);
iounmap(virt_addr);
I then read the data in uboot: Keeping the power, and rebooting the system, I enter uboot. Uboot uses the physical address, so I read the data starting at 0x83800000. Here's the problem: At 0x83800000(0M), one byte of data is wrong, at 0x83c00000(4M), one byte of data is wrong, and at 0x84000000(8M), one byte of data is wrong. But all the rest of the data is right,same as buf!! So strange!! I don't know the reason, who can help me? Thanks...