mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-02-15 19:59:34 +08:00
Restored * 8
Revert back to store and use the full value (*8) for the timing.
This commit is contained in:
parent
4e0e69ed63
commit
5de04f84e9
3 changed files with 50 additions and 43 deletions
|
@ -110,19 +110,20 @@
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
// Initial values if not in flash
|
// Initial values if not in flash
|
||||||
|
/*
|
||||||
// Note: Moved * 8 to apply when used. Saving 28 bytes here (- the *8) and 28 bytes flash.
|
// 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
|
// 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
|
t55xx_config T55xx_Timing = {{{ 29 , 17 , 15 , 50 , 0 , 0 , 15 }, // Default Fixed
|
||||||
{ 31 , 20 , 18 , 50 , 0 , 0 , 15 }, // Long Leading Ref.
|
{ 31 , 20 , 18 , 50 , 0 , 0 , 15 }, // Long Leading Ref.
|
||||||
{ 31 , 20 , 18 , 40 , 0 , 0 , 15 }, // Leading 0
|
{ 31 , 20 , 18 , 40 , 0 , 0 , 15 }, // Leading 0
|
||||||
{ 29 , 17 , 15 , 31 , 47 , 63 , 15 } }}; // 1 of 4
|
{ 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 Bit 10 Bit 11 ReadGap
|
||||||
t55xx_config T55xx_Timing = {{{ 29 * 8 , 17 * 8 , 15 * 8 , 50 * 8 , 0 , 0 , 15 * 8 }, // Default Fixed
|
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 , 50 * 8 , 0 , 0 , 15 * 8 }, // Long Leading Ref.
|
||||||
{ 31 * 8 , 20 * 8 , 18 * 8 , 40 * 8 , 0 , 0 , 15 * 8 }, // Leading 0
|
{ 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 , 31 * 8 , 47 * 8, 63 * 8, 15 * 8 } }}; // 1 of 4
|
||||||
*/
|
|
||||||
|
|
||||||
// Some defines for readability
|
// Some defines for readability
|
||||||
#define T55xx_DLMode_Fixed 0 // Default Mode
|
#define T55xx_DLMode_Fixed 0 // Default Mode
|
||||||
|
@ -142,36 +143,37 @@ void printT55xxConfig(void) {
|
||||||
case T55xx_DLMode_Leading0 : Dbprintf("r 2 leading zero"); break;
|
case T55xx_DLMode_Leading0 : Dbprintf("r 2 leading zero"); break;
|
||||||
case T55xx_DLMode_1of4 : Dbprintf("r 3 1 of 4 coding reference"); break;
|
case T55xx_DLMode_1of4 : Dbprintf("r 3 1 of 4 coding reference"); break;
|
||||||
}
|
}
|
||||||
// Save 36 bytes by not showing dec. all data sheets and entry is the x * 8 value, so not sure what we get for the 36 bytes dec?
|
Dbprintf(" [a] startgap............%d*8 (%d)", T55xx_Timing.m[DLMode].start_gap / 8, T55xx_Timing.m[DLMode].start_gap);
|
||||||
Dbprintf(" [a] startgap............%d*8", T55xx_Timing.m[DLMode].start_gap );//, T55xx_Timing.start_gap[DLMode]);
|
Dbprintf(" [b] writegap............%d*8 (%d)", T55xx_Timing.m[DLMode].write_gap / 8, T55xx_Timing.m[DLMode].write_gap);
|
||||||
Dbprintf(" [b] writegap............%d*8", T55xx_Timing.m[DLMode].write_gap );//, T55xx_Timing.write_gap[DLMode]);
|
Dbprintf(" [c] write_0.............%d*8 (%d)", T55xx_Timing.m[DLMode].write_0 / 8, T55xx_Timing.m[DLMode].write_0 );
|
||||||
Dbprintf(" [c] write_0.............%d*8", T55xx_Timing.m[DLMode].write_0 );//, T55xx_Timing.write_0 [DLMode]);
|
Dbprintf(" [d] write_1.............%d*8 (%d)", T55xx_Timing.m[DLMode].write_1 / 8, T55xx_Timing.m[DLMode].write_1 );
|
||||||
Dbprintf(" [d] write_1.............%d*8", T55xx_Timing.m[DLMode].write_1 );//, T55xx_Timing.write_1 [DLMode]);
|
|
||||||
if (DLMode == T55xx_DLMode_1of4) {
|
if (DLMode == T55xx_DLMode_1of4) {
|
||||||
Dbprintf(" [e] write_2.............%d*8", T55xx_Timing.m[DLMode].write_2 );//, T55xx_Timing.write_2 [DLMode]);
|
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", T55xx_Timing.m[DLMode].write_3 );//, T55xx_Timing.write_3 [DLMode]);
|
Dbprintf(" [f] write_3.............%d*8 (%d)", T55xx_Timing.m[DLMode].write_3 / 8, T55xx_Timing.m[DLMode].write_3);
|
||||||
}
|
}
|
||||||
Dbprintf(" [g] readgap.............%d*8", T55xx_Timing.m[DLMode].read_gap );//, T55xx_Timing.read_gap [DLMode]);
|
Dbprintf(" [g] readgap.............%d*8 (%d)", T55xx_Timing.m[DLMode].read_gap / 8, T55xx_Timing.m[DLMode].read_gap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setT55xxConfig(uint8_t arg0, t55xx_config *c) {
|
void setT55xxConfig(uint8_t arg0, t55xx_config *c) {
|
||||||
uint8_t DLMode;
|
uint8_t DLMode;
|
||||||
|
// uint8_t ClearT55Settings = c->m[0].start_gap & 0xffff; // all values will be ffff if clear requested
|
||||||
|
|
||||||
|
|
||||||
for (DLMode = 0; DLMode < 4; DLMode++) {
|
for (DLMode = 0; DLMode < 4; DLMode++) {
|
||||||
if (c->m[DLMode].start_gap != 0) T55xx_Timing.m[DLMode].start_gap = c->m[DLMode].start_gap;
|
if (c->m[DLMode].start_gap != 0) T55xx_Timing.m[DLMode].start_gap = c->m[DLMode].start_gap;// * 8;
|
||||||
if (c->m[DLMode].write_gap != 0) T55xx_Timing.m[DLMode].write_gap = c->m[DLMode].write_gap;
|
if (c->m[DLMode].write_gap != 0) T55xx_Timing.m[DLMode].write_gap = c->m[DLMode].write_gap;// * 8;
|
||||||
if (c->m[DLMode].write_0 != 0) T55xx_Timing.m[DLMode].write_0 = c->m[DLMode].write_0 ;
|
if (c->m[DLMode].write_0 != 0) T55xx_Timing.m[DLMode].write_0 = c->m[DLMode].write_0 ;// * 8;
|
||||||
if (c->m[DLMode].write_1 != 0) T55xx_Timing.m[DLMode].write_1 = c->m[DLMode].write_1 ;
|
if (c->m[DLMode].write_1 != 0) T55xx_Timing.m[DLMode].write_1 = c->m[DLMode].write_1 ;// * 8;
|
||||||
if (DLMode == T55xx_DLMode_1of4) {
|
if (DLMode == T55xx_DLMode_1of4) {
|
||||||
if (c->m[DLMode].write_2 != 0) T55xx_Timing.m[DLMode].write_2 = c->m[DLMode].write_2 ;
|
if (c->m[DLMode].write_2 != 0) T55xx_Timing.m[DLMode].write_2 = c->m[DLMode].write_2;// * 8;
|
||||||
if (c->m[DLMode].write_3 != 0) T55xx_Timing.m[DLMode].write_3 = c->m[DLMode].write_3 ;
|
if (c->m[DLMode].write_3 != 0) T55xx_Timing.m[DLMode].write_3 = c->m[DLMode].write_3;// * 8 ;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
T55xx_Timing.m[DLMode].write_2 = 0x00;
|
T55xx_Timing.m[DLMode].write_2 = 0x00;
|
||||||
T55xx_Timing.m[DLMode].write_3 = 0x00;
|
T55xx_Timing.m[DLMode].write_3 = 0x00;
|
||||||
}
|
}
|
||||||
if (c->m[DLMode].read_gap != 0) T55xx_Timing.m[DLMode].read_gap = c->m[DLMode].read_gap ;
|
if (c->m[DLMode].read_gap != 0) T55xx_Timing.m[DLMode].read_gap = c->m[DLMode].read_gap;//* 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
printT55xxConfig();
|
printT55xxConfig();
|
||||||
|
@ -186,6 +188,7 @@ void setT55xxConfig(uint8_t arg0, t55xx_config *c) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint8_t *buf = BigBuf_malloc(T55XX_CONFIG_LEN);
|
uint8_t *buf = BigBuf_malloc(T55XX_CONFIG_LEN);
|
||||||
Flash_CheckBusy(BUSY_TIMEOUT);
|
Flash_CheckBusy(BUSY_TIMEOUT);
|
||||||
uint16_t res = Flash_ReadDataCont(T55XX_CONFIG_OFFSET, buf, T55XX_CONFIG_LEN);
|
uint16_t res = Flash_ReadDataCont(T55XX_CONFIG_OFFSET, buf, T55XX_CONFIG_LEN);
|
||||||
|
@ -195,6 +198,7 @@ void setT55xxConfig(uint8_t arg0, t55xx_config *c) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if ( ClearT55Settings) // dont copy over new timings
|
||||||
memcpy(buf, &T55xx_Timing, T55XX_CONFIG_LEN);
|
memcpy(buf, &T55xx_Timing, T55XX_CONFIG_LEN);
|
||||||
|
|
||||||
Flash_CheckBusy(BUSY_TIMEOUT);
|
Flash_CheckBusy(BUSY_TIMEOUT);
|
||||||
|
@ -202,13 +206,13 @@ void setT55xxConfig(uint8_t arg0, t55xx_config *c) {
|
||||||
Flash_Erase4k(3, 0xD);
|
Flash_Erase4k(3, 0xD);
|
||||||
|
|
||||||
// if not a settings erase, write data
|
// if not a settings erase, write data
|
||||||
if (buf[0] != 0xff) {
|
// if ( ClearT55Settings) {
|
||||||
res = Flash_Write(T55XX_CONFIG_OFFSET, buf, T55XX_CONFIG_LEN);
|
res = Flash_Write(T55XX_CONFIG_OFFSET, buf, T55XX_CONFIG_LEN);
|
||||||
|
|
||||||
if (res == T55XX_CONFIG_LEN && DBGLEVEL > 1) {
|
if (res == T55XX_CONFIG_LEN && DBGLEVEL > 1) {
|
||||||
DbpString("T55XX Config save success");
|
DbpString("T55XX Config save success");
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
|
|
||||||
BigBuf_free();
|
BigBuf_free();
|
||||||
#endif
|
#endif
|
||||||
|
@ -242,6 +246,7 @@ void loadT55xxConfig(void) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (buf[0] != 0xFF) // if not set for clear
|
||||||
memcpy((uint8_t *)&T55xx_Timing, buf, T55XX_CONFIG_LEN);
|
memcpy((uint8_t *)&T55xx_Timing, buf, T55XX_CONFIG_LEN);
|
||||||
|
|
||||||
if (isok == T55XX_CONFIG_LEN) {
|
if (isok == T55XX_CONFIG_LEN) {
|
||||||
|
@ -1477,15 +1482,15 @@ void T55xxWriteBit(uint8_t bit, uint8_t downlink_idx) {
|
||||||
// Dbprintf ("%d",bit);
|
// Dbprintf ("%d",bit);
|
||||||
// If bit = 4 Send Long Leading Reference which is (138*8) + WRITE_0
|
// If bit = 4 Send Long Leading Reference which is (138*8) + WRITE_0
|
||||||
switch (bit){
|
switch (bit){
|
||||||
case 0 : TurnReadLFOn(T55xx_Timing.m[downlink_idx].write_0 * 8); break; // Send bit 0/00
|
case 0 : TurnReadLFOn(T55xx_Timing.m[downlink_idx].write_0 ); break; // Send bit 0/00
|
||||||
case 1 : TurnReadLFOn(T55xx_Timing.m[downlink_idx].write_1 * 8); break; // Send bit 1/01
|
case 1 : TurnReadLFOn(T55xx_Timing.m[downlink_idx].write_1 ); break; // Send bit 1/01
|
||||||
case 2 : TurnReadLFOn(T55xx_Timing.m[downlink_idx].write_2 * 8); break; // Send bits 10 (1 of 4)
|
case 2 : TurnReadLFOn(T55xx_Timing.m[downlink_idx].write_2 ); break; // Send bits 10 (1 of 4)
|
||||||
case 3 : TurnReadLFOn(T55xx_Timing.m[downlink_idx].write_3 * 8); break; // Send bits 11 (1 of 4)
|
case 3 : 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); break; // Send Long Leading Reference
|
case 4 : TurnReadLFOn(T55xx_Timing.m[downlink_idx].write_0 + (136 * 8)); break; // Send Long Leading Reference
|
||||||
}
|
}
|
||||||
|
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||||
WaitUS(T55xx_Timing.m[downlink_idx].write_gap * 8);
|
WaitUS(T55xx_Timing.m[downlink_idx].write_gap );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to abstract an Arbitrary length byte array to store bit pattern.
|
// Function to abstract an Arbitrary length byte array to store bit pattern.
|
||||||
|
@ -1632,7 +1637,7 @@ void T55xxResetRead(uint8_t flags) {
|
||||||
|
|
||||||
T55xx_SendCMD (0, 0, arg);
|
T55xx_SendCMD (0, 0, arg);
|
||||||
|
|
||||||
TurnReadLFOn(T55xx_Timing.m[downlink_mode].read_gap * 8);
|
TurnReadLFOn(T55xx_Timing.m[downlink_mode].read_gap);
|
||||||
|
|
||||||
// Acquisition
|
// Acquisition
|
||||||
DoPartialAcquisition(0, true, BigBuf_max_traceLen(), 0);
|
DoPartialAcquisition(0, true, BigBuf_max_traceLen(), 0);
|
||||||
|
|
|
@ -2606,18 +2606,20 @@ static int CmdT55xxSetDeviceConfig(const char *Cmd) {
|
||||||
|
|
||||||
// printf ("DLmode %d\n",downlink_mode);
|
// printf ("DLmode %d\n",downlink_mode);
|
||||||
t55xx_config conf = {0};
|
t55xx_config conf = {0};
|
||||||
|
printf ("Size conf %lld\n",sizeof(conf));
|
||||||
if (erase) {
|
if (erase) {
|
||||||
memset (&conf,0xff, sizeof(conf));
|
memset (&conf,0xff, sizeof(conf));
|
||||||
|
printf ("Conf.m[0] %x\n",conf.m[0].start_gap);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
conf.m[downlink_mode].start_gap = startgap;// * 8;
|
conf.m[downlink_mode].start_gap = startgap * 8;
|
||||||
conf.m[downlink_mode].write_gap = writegap;// * 8;
|
conf.m[downlink_mode].write_gap = writegap * 8;
|
||||||
conf.m[downlink_mode].write_0 = write0 ;// * 8;
|
conf.m[downlink_mode].write_0 = write0 * 8;
|
||||||
conf.m[downlink_mode].write_1 = write1 ;// * 8;
|
conf.m[downlink_mode].write_1 = write1 * 8;
|
||||||
conf.m[downlink_mode].write_2 = write2 ;// * 8;
|
conf.m[downlink_mode].write_2 = write2 * 8;
|
||||||
conf.m[downlink_mode].write_3 = write3 ;// * 8;
|
conf.m[downlink_mode].write_3 = write3 * 8;
|
||||||
conf.m[downlink_mode].read_gap = readgap ;// * 8;
|
conf.m[downlink_mode].read_gap = readgap * 8;
|
||||||
}
|
}
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandOLD(CMD_SET_LF_T55XX_CONFIG, shall_persist, 0, 0, &conf, sizeof(t55xx_config));
|
SendCommandOLD(CMD_SET_LF_T55XX_CONFIG, shall_persist, 0, 0, &conf, sizeof(t55xx_config));
|
||||||
|
|
|
@ -131,13 +131,13 @@ typedef struct {
|
||||||
|
|
||||||
// Extended to support 1 of 4 timing
|
// Extended to support 1 of 4 timing
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t start_gap ;
|
uint16_t start_gap ;
|
||||||
uint8_t write_gap ;
|
uint16_t write_gap ;
|
||||||
uint8_t write_0 ;
|
uint16_t write_0 ;
|
||||||
uint8_t write_1 ;
|
uint16_t write_1 ;
|
||||||
uint8_t write_2 ;
|
uint16_t write_2 ;
|
||||||
uint8_t write_3 ;
|
uint16_t write_3 ;
|
||||||
uint8_t read_gap ;
|
uint16_t read_gap ;
|
||||||
} t55xx_config_t;
|
} t55xx_config_t;
|
||||||
// This setup will allow for the 4 downlink modes "m" as well as other items if needed.
|
// 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.
|
// Given the one struct we can then read/write to flash/client in one go.
|
||||||
|
|
Loading…
Reference in a new issue