Beispiel #1
0
void DumpNand(char * dest) {
    float pct = 0.0f;

    FILE *f = fopen(dest, "wb");

    if (App.Warning("Warning dump nand ???") == FALSE) {
        return;
    }

    if (f) {
        unsigned char* buff = (unsigned char*) malloc(sfc.block_sz_phys);

        unsigned int buffer_len = sfc.block_sz_phys;
        unsigned nand_size = sfc.size_bytes;

        // Dump only 64mb on big nand
        if ((nand_size == NAND_SIZE_512MB) | (nand_size == NAND_SIZE_256MB)) {
            nand_size = NAND_SIZE_64MB;
        }

        for (unsigned int i = 0; i < nand_size; i += sfc.block_sz) {
            sfcx_read_block(buff, i, 1);

            if (buffer_len != fwrite(buff, 1, buffer_len, f)) {
                App.Alert("Error dumping nand !!! please check disk space !!");
            }
            pct = ((float) i / (float) (nand_size));
            App.SetProgressValue(pct);
        }

        fclose(f);
        free(buff);
    }
}
Beispiel #2
0
/**
* Read the NAND into a file.
*
* @param path - The path to the target file e.g "uda:/flashdmp.bin"
* @param size the size of the packet buffer to allocate
* @return none
*/
void readNand(char *path, int bb_64mb_only)
{
  FILE *f;
  int i;
  int nand_sz = sfc.size_bytes;
  unsigned char *buf = (unsigned char *) malloc(sfc.block_sz_phys);
  
  console_clrscr();
  
  if (!buf)
  {
     printf("Memory error!\n");
     waitforexit();
  }
            
  f = fopen(path, "wb");
  if (!f){
     printf(" ! %s failed to open\n", path);
     waitforexit();
  }
            
  if(bb_64mb_only){ 
     printf(" ! Detected a BIG BLOCK Console with INTEGRATED Memory Unit!\n");
     printf(" ! Will ONLY read 64 MB!\n");
     nand_sz = NAND_SIZE_64MB;
  }
            
  printf("Please wait while reading NAND to %s ... \n",path);
            
  int status;
            
  for (i = 0; i < nand_sz; i += sfc.block_sz) 
  {
     status = sfcx_read_block(buf, i, 1);
              
     if (!SFCX_SUCCESS(status))
       printf(" ! Error occured while dumping the NAND! Status: %04X\n",status);

     if(!fwrite(buf, 1, sfc.block_sz_phys, f))
     {   
       printf(" ! Error dumping NAND! Please check disk space!\n");
       waitforexit();                 
     }
  }
            
  printf("\n");
  printf("Closing file, freeing memory...\n");

  fclose(f);
  free(buf);
             
             
  printf("Reading NAND finished. Do whatever you like to do now !\n");
  waitforexit();
}