mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 21:33:47 -07:00
fix: 'mem load' - wrong offset when uploading
This commit is contained in:
parent
3ef9102c17
commit
e50fef6607
3 changed files with 12 additions and 13 deletions
|
@ -1134,6 +1134,8 @@ void UsbPacketReceived(uint8_t *packet, int len) {
|
||||||
|
|
||||||
Dbprintf("FlashMem init idx | %u | len %u ", startidx, len );
|
Dbprintf("FlashMem init idx | %u | len %u ", startidx, len );
|
||||||
|
|
||||||
|
uint8_t* data = c->d.asBytes;
|
||||||
|
|
||||||
uint32_t tmp = startidx + len;
|
uint32_t tmp = startidx + len;
|
||||||
|
|
||||||
// inside 256b page?
|
// inside 256b page?
|
||||||
|
@ -1147,22 +1149,23 @@ void UsbPacketReceived(uint8_t *packet, int len) {
|
||||||
uint8_t first_len = (~startidx & 0xFF)+1;
|
uint8_t first_len = (~startidx & 0xFF)+1;
|
||||||
|
|
||||||
// first mem page
|
// first mem page
|
||||||
res = Flash_WriteData(startidx, c->d.asBytes, first_len);
|
res = Flash_WriteData(startidx, data, first_len);
|
||||||
Dbprintf("after 1. offset and larger A | %u | %u | %u == %u", startidx , len, first_len, res);
|
Dbprintf("after 1. offset and larger A | %u | %u | %u == %u", startidx , len, first_len, res);
|
||||||
|
|
||||||
// second mem page (should be a mod 256)
|
// second mem page (should be a mod 256)
|
||||||
res = Flash_WriteData(startidx + first_len, c->d.asBytes + first_len, len - first_len);
|
res = Flash_WriteData(startidx + first_len, data + first_len, len - first_len);
|
||||||
|
|
||||||
Dbprintf("after 2. offset and larger B | %u | %u | %u == %u", startidx + first_len, len, len-first_len, res);
|
Dbprintf("after 2. offset and larger B | %u | %u | %u == %u", startidx + first_len, len, len-first_len, res);
|
||||||
|
|
||||||
isok = (res == (len - first_len)) ? 1 : 0;
|
isok = (res == (len - first_len)) ? 1 : 0;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
res = Flash_WriteData(startidx, c->d.asBytes, len);
|
res = Flash_WriteData(startidx, data, len);
|
||||||
Dbprintf("offset and within | %u | %u | %u", startidx, len, res);
|
Dbprintf("offset and within | %u | %u | %u", startidx, len, res);
|
||||||
isok = (res == len) ? 1 : 0;
|
isok = (res == len) ? 1 : 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
res = Flash_WriteData(startidx, c->d.asBytes, len);
|
res = Flash_WriteData(startidx, data, len);
|
||||||
Dbprintf("writing idx | %u | len %u ", startidx, len );
|
Dbprintf("writing idx | %u | len %u ", startidx, len );
|
||||||
isok = (res == len) ? 1 : 0;
|
isok = (res == len) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -251,10 +251,6 @@ uint16_t Flash_WriteData(uint32_t address, uint8_t *in, uint16_t len) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if 256b, empty out lower index.
|
|
||||||
if (len == 256)
|
|
||||||
address &= 0xFFFF00;
|
|
||||||
|
|
||||||
if (!FlashInit()) {
|
if (!FlashInit()) {
|
||||||
Dbprintf("Flash_WriteData init fail");
|
Dbprintf("Flash_WriteData init fail");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -131,7 +131,7 @@ int CmdFlashMemLoad(const char *Cmd){
|
||||||
|
|
||||||
UsbCommand c = {CMD_WRITE_FLASH_MEM, {start_index + bytes_sent, bytes_in_packet, 0}};
|
UsbCommand c = {CMD_WRITE_FLASH_MEM, {start_index + bytes_sent, bytes_in_packet, 0}};
|
||||||
|
|
||||||
memcpy(c.d.asBytes, dump + start_index + bytes_sent, bytes_in_packet);
|
memcpy(c.d.asBytes, dump + bytes_sent, bytes_in_packet);
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommand(&c);
|
SendCommand(&c);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue