Guest User

Untitled

a guest
Apr 24th, 2021
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.71 KB | None | 0 0
  1. int dump_sunxi1()
  2. {
  3.     int ret;
  4.     int result = 0;
  5.     u32 offset = 0;
  6.     fel_version_t ver = { 0 };
  7.  
  8.     ret = fel_init();
  9.     if (ret)
  10.     {
  11.         printf("Error %d calling fel_init()\n", ret);
  12.         return ret;
  13.     }
  14.     ret = fel_connect(0, NULL);
  15.     if (ret)
  16.     {
  17.         printf("Error %d calling fel_connect()\n", ret);
  18.         fel_exit();
  19.         return ret;
  20.     }
  21.  
  22.     printf("Writing 0 to is_inited flag\r\n");
  23.     u8 nullbuf[4] = { 0x00,0x00,0x00,0x00 };
  24.     ret = fel_cmd_poke(0x40000, &nullbuf, 4);
  25.     if (ret < 0)
  26.     {
  27.         printf("Error writing nulls to is_inited flag!");
  28.         exit(0);
  29.     }
  30.  
  31.     FILE* fp = fopen("sunxi_package_test.bin", "r+b");
  32.  
  33.  
  34.     //int start_sector = 0;
  35.     //int start_sector = 0x1DBF55; // REDUMP THIS LATER FROM OTHER BOARD!!! FUCKED UP!!
  36.     int start_sector = 0x8020;
  37.     printf("Updating sector in memory to %i...\r\n", start_sector);
  38.     ret = fel_cmd_poke(0x40004, &start_sector, 4);
  39.     if (ret < 0)
  40.     {
  41.         printf("Error writing sector to 0");
  42.         exit(0);
  43.     }
  44.  
  45.  
  46.     printf("Uploading payload\r\n");
  47.     ret = upload_file_to_memory("dump_emmc_payload.bin", 0x27000);
  48.  
  49.     if (ret < 0)
  50.     {
  51.         printf("Error while uploading file to memory!\r\n");
  52.     }
  53.  
  54.  
  55.     printf("Starting read sector loop\r\n");
  56.  
  57.  
  58.  
  59.     ret = fel_cmd_execute(0x27000);
  60.     if (ret < 0)
  61.     {
  62.         printf("Error while executing payload!\r\n");
  63.     }
  64.  
  65.     u8 data_read[512];
  66.     ret = fel_cmd_peek(data_read, 0x20000, 512);
  67.  
  68.     if (ret < 0)
  69.     {
  70.         printf("Peeking the read data failed!\r\n");
  71.     }
  72.  
  73.     fwrite(data_read, 512, 1, fp);
  74.     fflush(fp);
  75.  
  76.  
  77.  
  78.     printf("Reading last sector read value..\r\n");
  79.     int last_sector = 0;
  80.     ret = fel_cmd_peek(&last_sector, 0x40004, 4);
  81.     if (ret < 0)
  82.     {
  83.         printf("Error getting last sector read!\r\n");
  84.     }
  85.     printf("Last sector read: %i\r\n", last_sector);
  86.  
  87.  
  88.     fclose(fp);
  89.  
  90. }
  91.  
Add Comment
Please, Sign In to add comment