sget.c
Go to the documentation of this file.00001
00002
00003
00004
00005 int cmd_sget(int argc,char **argv)
00006 {
00007 unsigned long download_addr;
00008 char *buf;
00009 int fd;
00010 unsigned int size;
00011
00012 if(argc<4)return -1;
00013 size=strtoul(argv[3],0,0);
00014
00015
00016 buf=malloc(size);
00017 if(!buf)printf("error allocate memory\n");
00018
00019 download_addr=strtoul(argv[2],0,0);
00020
00021 jtag_getmem(buf,download_addr,size);
00022
00023 fd=open(argv[1],O_WRONLY|O_CREAT|O_TRUNC);
00024 if(fd){
00025 write(fd,buf,size);
00026 close(fd);
00027 }
00028 else
00029 {
00030 printf("open file %s for write error\n",argv[1]);
00031 }
00032
00033 free(buf);
00034
00035 return 0;
00036 }
00037
00038 mycmd_init(sget,cmd_sget,"sget","sget filename address size");