Forum Discussion
Altera_Forum
Honored Contributor
19 years agoThanks hippo, I can r/w file on mtdblock0 and save it.
follow is my example: 1) crate a blank text file In ~/rootfs/etc . Rename the file to you wanted. 2)rebuild the zImage and reboot. 3)dd count=1 if=some_source_file of=/dev/mtdblock0 You have crated a jffs2 file after this step. Then you can add c code as following demo code to your APP. So you can r/w and save your jffs2 file. In jffs2 file you can save IP address, informaion,......... # include <fcntl.h> int main(void) { int ret; int fd; chdir("/"); char buffer[10] ={'H','e','l','l','o','j','f','f','s','2'}; ret = system("dd count=1 if=/dev/mtdblock0 of=test_config"); if((fd = open("test_config", O_WRONLY)) == -1) { printf("cannot open file. \n"); exit(1); } if(write(fd,buffer,10) != 10) { printf("write error"); } fclose(fd); ret = system("dd count=1 if=test_config of=/dev/mtdblock0"); return 0; }