mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-02-01 21:08:18 +08:00
Merge pull request #288 from mwalker33/master
Bug Fix : T55x7 timings save to flash
This commit is contained in:
commit
f44343aa20
5 changed files with 91 additions and 38 deletions
|
@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
|
|||
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
|
||||
|
||||
## [unreleased][unreleased]
|
||||
- Fix T55x7 Downlink timings backward compatible (@mwalker33)
|
||||
- Add proper Makefile halting when using incompatible STANDALONE and PLATFORM vars (@doegox)
|
||||
- Add T55x7 Downlink mode support (@mwalker33)
|
||||
- Add SPIFFS Flash filesystem support (@cjbrigato)
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#include "pmflash.h"
|
||||
#include "flashmem.h" // persistence on mem
|
||||
|
||||
|
||||
|
||||
//#define START_GAP 31*8 // was 250 // SPEC: 1*8 to 50*8 - typ 15*8 (15fc)
|
||||
//#define WRITE_GAP 8*8 // 17*8 // was 160 // SPEC: 1*8 to 20*8 - typ 10*8 (10fc)
|
||||
//#define WRITE_0 15*8 // 18*8 // was 144 // SPEC: 16*8 to 32*8 - typ 24*8 (24fc)
|
||||
|
@ -114,19 +116,19 @@
|
|||
// Note: Moved * 8 to apply when used. Saving 28 bytes here (- the *8) and 28 bytes flash.
|
||||
// StartGap WriteGap Bit 0/00 Bit 1/01 Bit 10 Bit 11 ReadGap
|
||||
t55xx_config T55xx_Timing = {{
|
||||
{ 29 , 17 , 15 , 50 , 0 , 0 , 15 }, // Default Fixed
|
||||
{ 29 , 17 , 15 , 47 , 0 , 0 , 15 }, // Default Fixed
|
||||
{ 31 , 20 , 18 , 50 , 0 , 0 , 15 }, // Long Leading Ref.
|
||||
{ 31 , 20 , 18 , 40 , 0 , 0 , 15 }, // Leading 0
|
||||
{ 29 , 17 , 15 , 31 , 47 , 63 , 15 } // 1 of 4
|
||||
}
|
||||
};
|
||||
*/
|
||||
// StartGap WriteGap Bit 0/00 Bit 1/01 Bit 10 Bit 11 ReadGap
|
||||
// StartGap WriteGap Bit 0/00 Bit 1/01 ReadGap Bit 10 Bit 11
|
||||
t55xx_config T55xx_Timing = {{
|
||||
{ 29 * 8, 17 * 8, 15 * 8, 50 * 8, 0, 0, 15 * 8 }, // Default Fixed
|
||||
{ 31 * 8, 20 * 8, 18 * 8, 50 * 8, 0, 0, 15 * 8 }, // Long Leading Ref.
|
||||
{ 31 * 8, 20 * 8, 18 * 8, 40 * 8, 0, 0, 15 * 8 }, // Leading 0
|
||||
{ 29 * 8, 17 * 8, 15 * 8, 31 * 8, 47 * 8, 63 * 8, 15 * 8 } // 1 of 4
|
||||
{ 29 * 8, 17 * 8, 15 * 8, 47 * 8, 15 * 8, 0, 0 }, // Default Fixed
|
||||
{ 31 * 8, 20 * 8, 18 * 8, 50 * 8, 15 * 8, 0, 0 }, // Long Leading Ref.
|
||||
{ 31 * 8, 20 * 8, 18 * 8, 40 * 8, 15 * 8, 0, 0 }, // Leading 0
|
||||
{ 29 * 8, 17 * 8, 15 * 8, 31 * 8, 15 * 8, 47 * 8, 63 * 8 } // 1 of 4
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -161,11 +163,11 @@ void printT55xxConfig(void) {
|
|||
Dbprintf(" [b] writegap............%d*8 (%d)", T55xx_Timing.m[DLMode].write_gap / 8, T55xx_Timing.m[DLMode].write_gap);
|
||||
Dbprintf(" [c] write_0.............%d*8 (%d)", T55xx_Timing.m[DLMode].write_0 / 8, T55xx_Timing.m[DLMode].write_0);
|
||||
Dbprintf(" [d] write_1.............%d*8 (%d)", T55xx_Timing.m[DLMode].write_1 / 8, T55xx_Timing.m[DLMode].write_1);
|
||||
Dbprintf(" [e] readgap.............%d*8 (%d)", T55xx_Timing.m[DLMode].read_gap / 8, T55xx_Timing.m[DLMode].read_gap);
|
||||
if (DLMode == T55xx_DLMode_1of4) {
|
||||
Dbprintf(" [e] write_2.............%d*8 (%d)", T55xx_Timing.m[DLMode].write_2 / 8, T55xx_Timing.m[DLMode].write_2);
|
||||
Dbprintf(" [f] write_3.............%d*8 (%d)", T55xx_Timing.m[DLMode].write_3 / 8, T55xx_Timing.m[DLMode].write_3);
|
||||
Dbprintf(" [f] write_2.............%d*8 (%d)", T55xx_Timing.m[DLMode].write_2 / 8, T55xx_Timing.m[DLMode].write_2);
|
||||
Dbprintf(" [g] write_3.............%d*8 (%d)", T55xx_Timing.m[DLMode].write_3 / 8, T55xx_Timing.m[DLMode].write_3);
|
||||
}
|
||||
Dbprintf(" [g] readgap.............%d*8 (%d)", T55xx_Timing.m[DLMode].read_gap / 8, T55xx_Timing.m[DLMode].read_gap);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -211,21 +213,17 @@ void setT55xxConfig(uint8_t arg0, t55xx_config *c) {
|
|||
return;
|
||||
}
|
||||
|
||||
// if ( ClearT55Settings) // dont copy over new timings
|
||||
memcpy(buf, &T55xx_Timing, T55XX_CONFIG_LEN);
|
||||
|
||||
Flash_CheckBusy(BUSY_TIMEOUT);
|
||||
Flash_WriteEnable();
|
||||
Flash_Erase4k(3, 0xD);
|
||||
|
||||
// if not a settings erase, write data
|
||||
// if ( ClearT55Settings) {
|
||||
res = Flash_Write(T55XX_CONFIG_OFFSET, buf, T55XX_CONFIG_LEN);
|
||||
|
||||
if (res == T55XX_CONFIG_LEN && DBGLEVEL > 1) {
|
||||
DbpString("T55XX Config save success");
|
||||
}
|
||||
// }
|
||||
|
||||
BigBuf_free();
|
||||
#endif
|
||||
|
@ -1482,6 +1480,7 @@ void TurnReadLF_off(uint32_t delay) {
|
|||
// Macro for code readability
|
||||
#define BitStream_Byte(X) ((X) >> 3)
|
||||
#define BitStream_Bit(X) ((X) & 7)
|
||||
#define t55_llr_ref (136 * 8)
|
||||
#define t55_send_PwdMode (arg & 0x01)
|
||||
#define t55_send_Page ((arg & 0x02) >> 1)
|
||||
#define t55_send_TestMode ((arg & 0x04) >> 2)
|
||||
|
@ -1508,7 +1507,7 @@ void T55xxWriteBit(uint8_t bit, uint8_t downlink_idx) {
|
|||
TurnReadLFOn(T55xx_Timing.m[downlink_idx].write_3);
|
||||
break; // Send bits 11 (1 of 4)
|
||||
case 4 :
|
||||
TurnReadLFOn(T55xx_Timing.m[downlink_idx].write_0 + (136 * 8));
|
||||
TurnReadLFOn(T55xx_Timing.m[downlink_idx].write_0 + t55_llr_ref);
|
||||
break; // Send Long Leading Reference
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,13 @@
|
|||
|
||||
#include "cmdlft55xx.h"
|
||||
|
||||
// Some defines for readability
|
||||
#define T55xx_DLMode_Fixed 0 // Default Mode
|
||||
#define T55xx_DLMode_LLR 1 // Long Leading Reference
|
||||
#define T55xx_DLMode_Leading0 2 // Leading Zero
|
||||
#define T55xx_DLMode_1of4 3 // 1 of 4
|
||||
#define T55xx_LongLeadingReference 4 // Value to tell Write Bit to send long reference
|
||||
|
||||
// Default configuration
|
||||
t55xx_conf_block_t config = { .modulation = DEMOD_ASK, .inverted = false, .offset = 0x00, .block0 = 0x00, .Q5 = false };
|
||||
|
||||
|
@ -254,13 +261,13 @@ static int usage_lf_deviceconfig() {
|
|||
PrintAndLogEx(NORMAL, " b <8..255> - Set write gap");
|
||||
PrintAndLogEx(NORMAL, " c <8..255> - Set write ZERO gap");
|
||||
PrintAndLogEx(NORMAL, " d <8..255> - Set write ONE gap");
|
||||
PrintAndLogEx(NORMAL, " e <8..255> - Set write TWO gap (1 of 4 only)");
|
||||
PrintAndLogEx(NORMAL, " f <8..255> - Set write THREE gap (1 of 4 only)");
|
||||
PrintAndLogEx(NORMAL, " g <8..255> - Set read gap");
|
||||
PrintAndLogEx(NORMAL, " e <8..255> - Set read gap");
|
||||
PrintAndLogEx(NORMAL, " f <8..255> - Set write TWO gap (1 of 4 only)");
|
||||
PrintAndLogEx(NORMAL, " g <8..255> - Set write THREE gap (1 of 4 only)");
|
||||
PrintAndLogEx(NORMAL, " p - persist to flashmemory");
|
||||
PrintAndLogEx(NORMAL, " r <mode> - downlink encoding '0' fixed bit length (default), '1' long leading ref.");
|
||||
PrintAndLogEx(NORMAL, " '2' leading zero, '3' 1 of 4 coding ref.");
|
||||
PrintAndLogEx(NORMAL, " z - erase t55x7 timings (needs p and reboot to load defaults)");
|
||||
PrintAndLogEx(NORMAL, " z - Set default t55x7 timings (use p to save if required)");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Examples:");
|
||||
PrintAndLogEx(NORMAL, " lf t55xx deviceconfig a 29 b 17 c 15 d 47 e 15 - default T55XX");
|
||||
|
@ -2549,7 +2556,7 @@ static int CmdT55xxSetDeviceConfig(const char *Cmd) {
|
|||
bool errors = false, shall_persist = false;
|
||||
uint8_t cmdp = 0;
|
||||
uint8_t downlink_mode = 0;
|
||||
bool erase = false;
|
||||
bool set_defaults = false;
|
||||
|
||||
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
||||
switch (tolower(param_getchar(Cmd, cmdp))) {
|
||||
|
@ -2572,15 +2579,15 @@ static int CmdT55xxSetDeviceConfig(const char *Cmd) {
|
|||
cmdp += 2;
|
||||
break;
|
||||
case 'e':
|
||||
errors |= param_getdec(Cmd, cmdp + 1, &write2);
|
||||
errors |= param_getdec(Cmd, cmdp + 1, &readgap);
|
||||
cmdp += 2;
|
||||
break;
|
||||
case 'f':
|
||||
errors |= param_getdec(Cmd, cmdp + 1, &write3);
|
||||
errors |= param_getdec(Cmd, cmdp + 1, &write2);
|
||||
cmdp += 2;
|
||||
break;
|
||||
case 'g':
|
||||
errors |= param_getdec(Cmd, cmdp + 1, &readgap);
|
||||
errors |= param_getdec(Cmd, cmdp + 1, &write3);
|
||||
cmdp += 2;
|
||||
break;
|
||||
case 'r':
|
||||
|
@ -2593,7 +2600,7 @@ static int CmdT55xxSetDeviceConfig(const char *Cmd) {
|
|||
cmdp++;
|
||||
break;
|
||||
case 'z':
|
||||
erase = true;
|
||||
set_defaults = true;
|
||||
cmdp++;
|
||||
break;
|
||||
default:
|
||||
|
@ -2606,22 +2613,61 @@ static int CmdT55xxSetDeviceConfig(const char *Cmd) {
|
|||
//Validations
|
||||
if (errors || cmdp == 0) return usage_lf_deviceconfig();
|
||||
|
||||
// printf ("DLmode %d\n",downlink_mode);
|
||||
t55xx_config conf = {0};
|
||||
printf("Size conf %zu\n", sizeof(conf));
|
||||
if (erase) {
|
||||
memset(&conf, 0xff, sizeof(conf));
|
||||
printf("Conf.m[0] %x\n", conf.m[0].start_gap);
|
||||
} else {
|
||||
/* if (erase) {
|
||||
memset (&conf,0xff, sizeof(conf));
|
||||
printf ("Conf.m[0] %x\n",conf.m[0].start_gap);
|
||||
*/
|
||||
//
|
||||
if (set_defaults){
|
||||
// fixed bit length
|
||||
conf.m[T55xx_DLMode_Fixed].start_gap = 29 * 8;
|
||||
conf.m[T55xx_DLMode_Fixed].write_gap = 17 * 8;
|
||||
conf.m[T55xx_DLMode_Fixed].write_0 = 15 * 8;
|
||||
conf.m[T55xx_DLMode_Fixed].write_1 = 47 * 8;
|
||||
conf.m[T55xx_DLMode_Fixed].read_gap = 15 * 8;
|
||||
conf.m[T55xx_DLMode_Fixed].write_2 = 0;
|
||||
conf.m[T55xx_DLMode_Fixed].write_3 = 0;
|
||||
|
||||
// long leading reference
|
||||
conf.m[T55xx_DLMode_LLR].start_gap = 31 * 8;
|
||||
conf.m[T55xx_DLMode_LLR].write_gap = 20 * 8;
|
||||
conf.m[T55xx_DLMode_LLR].write_0 = 18 * 8;
|
||||
conf.m[T55xx_DLMode_LLR].write_1 = 50 * 8;
|
||||
conf.m[T55xx_DLMode_LLR].read_gap = 15 * 8;
|
||||
conf.m[T55xx_DLMode_LLR].write_2 = 0;
|
||||
conf.m[T55xx_DLMode_LLR].write_3 = 0;
|
||||
|
||||
// leading zero
|
||||
conf.m[T55xx_DLMode_Leading0].start_gap = 31 * 8;
|
||||
conf.m[T55xx_DLMode_Leading0].write_gap = 20 * 8;
|
||||
conf.m[T55xx_DLMode_Leading0].write_0 = 18 * 8;
|
||||
conf.m[T55xx_DLMode_Leading0].write_1 = 40 * 8;
|
||||
conf.m[T55xx_DLMode_Leading0].read_gap = 15 * 8;
|
||||
conf.m[T55xx_DLMode_Leading0].write_2 = 0;
|
||||
conf.m[T55xx_DLMode_Leading0].write_3 = 0;
|
||||
|
||||
conf.m[downlink_mode].start_gap = startgap * 8;
|
||||
conf.m[downlink_mode].write_gap = writegap * 8;
|
||||
conf.m[downlink_mode].write_0 = write0 * 8;
|
||||
conf.m[downlink_mode].write_1 = write1 * 8;
|
||||
conf.m[downlink_mode].write_2 = write2 * 8;
|
||||
conf.m[downlink_mode].write_3 = write3 * 8;
|
||||
conf.m[downlink_mode].read_gap = readgap * 8;
|
||||
}
|
||||
// 1 of 4 coding reference
|
||||
conf.m[T55xx_DLMode_1of4].start_gap = 29 * 8;
|
||||
conf.m[T55xx_DLMode_1of4].write_gap = 17 * 8;
|
||||
conf.m[T55xx_DLMode_1of4].write_0 = 15 * 8;
|
||||
conf.m[T55xx_DLMode_1of4].write_1 = 31 * 8;
|
||||
conf.m[T55xx_DLMode_1of4].read_gap = 15 * 8;
|
||||
conf.m[T55xx_DLMode_1of4].write_2 = 47 * 8;
|
||||
conf.m[T55xx_DLMode_1of4].write_3 = 63 * 8;
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
conf.m[downlink_mode].start_gap = startgap * 8;
|
||||
conf.m[downlink_mode].write_gap = writegap * 8;
|
||||
conf.m[downlink_mode].write_0 = write0 * 8;
|
||||
conf.m[downlink_mode].write_1 = write1 * 8;
|
||||
conf.m[downlink_mode].read_gap = readgap * 8;
|
||||
conf.m[downlink_mode].write_2 = write2 * 8;
|
||||
conf.m[downlink_mode].write_3 = write3 * 8;
|
||||
}
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandOLD(CMD_SET_LF_T55XX_CONFIG, shall_persist, 0, 0, &conf, sizeof(t55xx_config));
|
||||
return PM3_SUCCESS;
|
||||
|
|
|
@ -5,6 +5,12 @@ pm3 --> mem load f default_keys m
|
|||
pm3 --> mem load f default_pwd t
|
||||
pm3 --> mem load f default_iclass_keys i
|
||||
pm3 --> lf t55xx deviceconfig a 29 b 17 c 15 d 47 e 15 p
|
||||
pm3 --> lf t55xx deviceconfig r 1 a 31 b 20 c 18 d 50 e 15 p
|
||||
pm3 --> lf t55xx deviceconfig r 2 a 31 b 20 c 18 d 40 e 15 p
|
||||
pm3 --> lf t55xx deviceconfig r 3 a 29 b 17 c 15 d 31 e 15 f 47 g 63 p
|
||||
|
||||
Set all t55xx settings to defaults (will set all 4 at once)
|
||||
pm3 --> lf t55xx deviceconfig z p
|
||||
```
|
||||
|
||||
### Verify sim module firmware version
|
||||
|
|
|
@ -135,9 +135,10 @@ typedef struct {
|
|||
uint16_t write_gap ;
|
||||
uint16_t write_0 ;
|
||||
uint16_t write_1 ;
|
||||
uint16_t read_gap ;
|
||||
uint16_t write_2 ;
|
||||
uint16_t write_3 ;
|
||||
uint16_t read_gap ;
|
||||
|
||||
} t55xx_config_t;
|
||||
// This setup will allow for the 4 downlink modes "m" as well as other items if needed.
|
||||
// Given the one struct we can then read/write to flash/client in one go.
|
||||
|
|
Loading…
Reference in a new issue