X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/8caef54055ea9311d911dfe4b1d7f88bd24fe08a..815f3f255960c429f62435cc7506ff597385b2cf:/client/flash.c diff --git a/client/flash.c b/client/flash.c index f11505ad..b01bb154 100644 --- a/client/flash.c +++ b/client/flash.c @@ -46,9 +46,6 @@ struct partition partitions[] = { {0, 0, 0, NULL}, }; -/* If translate is set, subtract PHYSICAL_FLASH_START to translate for old - * bootroms. - */ void WriteBlock(unsigned int block_start, unsigned int len, unsigned char *buf) { unsigned char temp_buf[256]; @@ -61,8 +58,6 @@ void WriteBlock(unsigned int block_start, unsigned int len, unsigned char *buf) UsbCommand c = {CMD_SETUP_WRITE}; -// printf("expected = %08x flush, ", ExpectedAddr); - int i; for(i = 0; i < 240; i += 48) { memcpy(c.d.asBytes, temp_buf+i, 48); @@ -74,7 +69,7 @@ void WriteBlock(unsigned int block_start, unsigned int len, unsigned char *buf) c.cmd = CMD_FINISH_WRITE; c.arg[0] = block_start; - printf("writing block %08x\r", c.arg[0]); +// printf("writing block %08x\r", c.arg[0]); memcpy(c.d.asBytes, temp_buf+240, 16); SendCommand(&c); WaitForAck(); @@ -104,8 +99,8 @@ void LoadFlashFromFile(const char *file, int start_addr, int end_addr) for (i=0; i 0 && phdr.p_paddr >= PHYSICAL_FLASH_START && (phdr.p_paddr + phdr.p_filesz) < PHYSICAL_FLASH_END) { printf("flashing offset=%x paddr=%x size=%x\n", phdr.p_offset, phdr.p_paddr, phdr.p_filesz); @@ -113,17 +108,25 @@ void LoadFlashFromFile(const char *file, int start_addr, int end_addr) printf("skipping forward 0x2000 because of strange linker thing\n"); phdr.p_offset += 0x2000; phdr.p_paddr += 0x2000; + phdr.p_filesz -= 0x2000; + phdr.p_memsz -= 0x2000; } fseek(f, phdr.p_offset, SEEK_SET); ExpectedAddr = phdr.p_paddr; while (ExpectedAddr < (phdr.p_paddr + phdr.p_filesz)) { unsigned int bytes_to_read = phdr.p_paddr + phdr.p_filesz - ExpectedAddr; - if (bytes_to_read > 256) bytes_to_read=256; + if (bytes_to_read > 256) + bytes_to_read=256; + else + memset(QueuedToSend, 0xFF, 256); fread(QueuedToSend, 1, bytes_to_read, f); -// printf("read %d bytes\n", bytes_to_read); - printf("WriteBlock(%x, %d, %p)\n", ExpectedAddr, bytes_to_read, QueuedToSend); - WriteBlock(ExpectedAddr, bytes_to_read, QueuedToSend); + printf("WriteBlock(%x, %d, %02x %02x %02x %02x %02x %02x %02x %02x ... %02x %02x %02x %02x %02x %02x %02x %02x)\n", ExpectedAddr, bytes_to_read, + QueuedToSend[0], QueuedToSend[1], QueuedToSend[2], QueuedToSend[3], + QueuedToSend[4], QueuedToSend[5], QueuedToSend[6], QueuedToSend[7], + QueuedToSend[248], QueuedToSend[249], QueuedToSend[250], QueuedToSend[251], + QueuedToSend[252], QueuedToSend[253], QueuedToSend[254], QueuedToSend[255]); + WriteBlock(ExpectedAddr, 256, QueuedToSend); ExpectedAddr += bytes_to_read; } }