linux nor flash 读写

  • Post author:
  • Post category:linux


void reboot_efex(void)

{



int  flash_handle = 0;



char command[32] = “efex”;



int len = 0;






char buf[32] = “test”;






memset(command, 0x00, 32);



memset(buf, 0x00, 32);



strcpy(command,”efex”);



flash_handle = open(“/dev/mtdblock6”,O_RDWR);



if (flash_handle < 0)



fprintf(stderr,”in:reboot_efex open mtd device fail\n”);



len = write(flash_handle,&command[0],32);



sync();



fprintf(stderr,”in:reboot_efex open mtd device len=%d\n”,len);



lseek(flash_handle,0,SEEK_SET);



len = read(flash_handle,buf,strlen(command));



sync();



close(flash_handle);



fprintf(stderr,”in:reboot_efex read mtd device len=%d\n”,len);



fprintf(stderr,”in:reboot_efex read mtd device =%s\n”,buf);

}



版权声明:本文为lbaihao原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。