2008-08-27 09:53:00 mtdblock* access problem
Zhi Qiang Zhang (CHINA)
Message: 61178
Hi,
I want my device can be updated by external stored file, so I created 2 partitions in my device, one is the u-boot partition, another is the kernel partition, this partition begin at 0x20040000 to end of the flash.
After I rebuild the kernel image, I copy it to a SD card, then mout this SD card to my device, then run this command will update the kernel
cat /mnt/uImage.initramfs > /dev/mtdblock1
Now I want to create a program to do this,
int fd_img, fd_mtd;
fd_img = open("/mnt/uImage.initramfs", O_RDONLY);
fd_mtd = open("/dev/mtdblock1", O_WRONLY);
unsigned char buf[4096];
int r;
do {
r = read(fd_img, buf, 4096);
write(fd_mtd, buf, r);
} while (r != 0);
close(fd_img);
close(fd_mtd);
run this program to update the kerenl, and reboot, the u-boot prompts that "CRC error"
what is this program different from 'cat /mnt/uImage.initramfs > /dev/mtdblock1"?
Regards,
ZhangZQ
QuoteReplyEditDelete
2008-08-27 16:14:57 Re: mtdblock* access problem
Mike Frysinger (UNITED STATES)
Message: 61192
you cant write mtdblock devices directly. they're flash, so you need to erase things before you program. use the programs with mtd-utils to manage things.
QuoteReplyEditDelete
2008-08-27 18:51:30 Re: mtdblock* access problem
Zhi Qiang Zhang (CHINA)
Message: 61206
Mike,
I can use 'cat /mnt/uImage.initramfs > /dev/mtdblock1' to update the flash without erase the flash first, it is OK, what is the problem?
Regards,
ZhangZQ
QuoteReplyEditDelete
2008-08-29 01:32:45 Re: mtdblock* access problem
Zhi Qiang Zhang (CHINA)
Message: 61308
Is there someone know this problem.
QuoteReplyEditDelete
2008-08-29 08:00:58 Re: mtdblock* access problem
Robin Getz (UNITED STATES)
Message: 61376
Zhi:
When you are not willing to follow Mike's directions - what kind of help are you looking for? He told you what to do. Did you try using the mtdutils?
-Robin
QuoteReplyEditDelete
2008-09-25 19:42:58 Re: mtdblock* access problem
Mike Frysinger (UNITED STATES)
Message: 62734
you can run things through strace to see how they differ in function ... you didnt say what hardware platform you're working on