mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-08-19 21:03:23 -07:00
Decreased BigBuff mem, some elf flasher fixes (needs more work) but flashing correctly currently.
This commit is contained in:
parent
8caef54055
commit
815f3f2559
4 changed files with 17 additions and 16 deletions
|
@ -271,7 +271,7 @@ void SimulateTagHfListen(void)
|
||||||
|
|
||||||
void ReadMem(int addr)
|
void ReadMem(int addr)
|
||||||
{
|
{
|
||||||
const DWORD *data = ((DWORD *)addr);
|
const BYTE *data = ((BYTE *)addr);
|
||||||
|
|
||||||
Dbprintf("%x: %02x %02x %02x %02x %02x %02x %02x %02x",
|
Dbprintf("%x: %02x %02x %02x %02x %02x %02x %02x %02x",
|
||||||
addr, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]);
|
addr, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]);
|
||||||
|
|
|
@ -13,7 +13,7 @@ typedef unsigned char byte_t;
|
||||||
|
|
||||||
// The large multi-purpose buffer, typically used to hold A/D samples,
|
// The large multi-purpose buffer, typically used to hold A/D samples,
|
||||||
// maybe processed in some way.
|
// maybe processed in some way.
|
||||||
DWORD BigBuf[12000];
|
DWORD BigBuf[8000];
|
||||||
|
|
||||||
/// appmain.h
|
/// appmain.h
|
||||||
void ReadMem(int addr);
|
void ReadMem(int addr);
|
||||||
|
|
|
@ -9,8 +9,6 @@
|
||||||
#include "hitag2.h"
|
#include "hitag2.h"
|
||||||
#include "../common/crc16.c"
|
#include "../common/crc16.c"
|
||||||
|
|
||||||
int sprintf(char *dest, const char *fmt, ...);
|
|
||||||
|
|
||||||
void AcquireRawAdcSamples125k(BOOL at134khz)
|
void AcquireRawAdcSamples125k(BOOL at134khz)
|
||||||
{
|
{
|
||||||
if (at134khz)
|
if (at134khz)
|
||||||
|
|
|
@ -46,9 +46,6 @@ struct partition partitions[] = {
|
||||||
{0, 0, 0, NULL},
|
{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)
|
void WriteBlock(unsigned int block_start, unsigned int len, unsigned char *buf)
|
||||||
{
|
{
|
||||||
unsigned char temp_buf[256];
|
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};
|
UsbCommand c = {CMD_SETUP_WRITE};
|
||||||
|
|
||||||
// printf("expected = %08x flush, ", ExpectedAddr);
|
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i < 240; i += 48) {
|
for(i = 0; i < 240; i += 48) {
|
||||||
memcpy(c.d.asBytes, temp_buf+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.cmd = CMD_FINISH_WRITE;
|
||||||
c.arg[0] = block_start;
|
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);
|
memcpy(c.d.asBytes, temp_buf+240, 16);
|
||||||
SendCommand(&c);
|
SendCommand(&c);
|
||||||
WaitForAck();
|
WaitForAck();
|
||||||
|
@ -104,8 +99,8 @@ void LoadFlashFromFile(const char *file, int start_addr, int end_addr)
|
||||||
for (i=0; i<header.e_phnum; i++) {
|
for (i=0; i<header.e_phnum; i++) {
|
||||||
fseek(f, header.e_phoff + i * sizeof(Elf32_Phdr), SEEK_SET);
|
fseek(f, header.e_phoff + i * sizeof(Elf32_Phdr), SEEK_SET);
|
||||||
fread(&phdr, 1, sizeof(phdr), f);
|
fread(&phdr, 1, sizeof(phdr), f);
|
||||||
// printf("type=%d offset=%x paddr=%x vaddr=%x filesize=%x memsize=%x flags=%x align=%x\n",
|
printf("type=%d offset=%x paddr=%x vaddr=%x filesize=%x memsize=%x flags=%x align=%x\n",
|
||||||
// phdr.p_type, phdr.p_offset, phdr.p_paddr, phdr.p_vaddr, phdr.p_filesz, phdr.p_memsz, phdr.p_flags, phdr.p_align);
|
phdr.p_type, phdr.p_offset, phdr.p_paddr, phdr.p_vaddr, phdr.p_filesz, phdr.p_memsz, phdr.p_flags, phdr.p_align);
|
||||||
if (phdr.p_type == PT_LOAD && phdr.p_filesz > 0 && phdr.p_paddr >= PHYSICAL_FLASH_START
|
if (phdr.p_type == PT_LOAD && phdr.p_filesz > 0 && phdr.p_paddr >= PHYSICAL_FLASH_START
|
||||||
&& (phdr.p_paddr + phdr.p_filesz) < PHYSICAL_FLASH_END) {
|
&& (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);
|
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");
|
printf("skipping forward 0x2000 because of strange linker thing\n");
|
||||||
phdr.p_offset += 0x2000;
|
phdr.p_offset += 0x2000;
|
||||||
phdr.p_paddr += 0x2000;
|
phdr.p_paddr += 0x2000;
|
||||||
|
phdr.p_filesz -= 0x2000;
|
||||||
|
phdr.p_memsz -= 0x2000;
|
||||||
}
|
}
|
||||||
|
|
||||||
fseek(f, phdr.p_offset, SEEK_SET);
|
fseek(f, phdr.p_offset, SEEK_SET);
|
||||||
ExpectedAddr = phdr.p_paddr;
|
ExpectedAddr = phdr.p_paddr;
|
||||||
while (ExpectedAddr < (phdr.p_paddr + phdr.p_filesz)) {
|
while (ExpectedAddr < (phdr.p_paddr + phdr.p_filesz)) {
|
||||||
unsigned int bytes_to_read = phdr.p_paddr + phdr.p_filesz - ExpectedAddr;
|
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);
|
fread(QueuedToSend, 1, bytes_to_read, f);
|
||||||
// printf("read %d bytes\n", bytes_to_read);
|
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,
|
||||||
printf("WriteBlock(%x, %d, %p)\n", ExpectedAddr, bytes_to_read, QueuedToSend);
|
QueuedToSend[0], QueuedToSend[1], QueuedToSend[2], QueuedToSend[3],
|
||||||
WriteBlock(ExpectedAddr, bytes_to_read, QueuedToSend);
|
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;
|
ExpectedAddr += bytes_to_read;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue