mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07:00
t55xx detect/read/write/dump etc will fail if you set lf config to something. Moved the reset / restore of lf config to device side for T55XX readblock. t55xx sniff still obeys lf config since it uses lf sniff beneath.
This commit is contained in:
parent
7ec18a040b
commit
765d2acbb0
5 changed files with 27 additions and 35 deletions
|
@ -818,7 +818,6 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||||
sample_config c;
|
sample_config c;
|
||||||
memcpy(&c, packet->data.asBytes, sizeof(sample_config));
|
memcpy(&c, packet->data.asBytes, sizeof(sample_config));
|
||||||
setSamplingConfig(&c);
|
setSamplingConfig(&c);
|
||||||
// setSamplingConfig((sample_config *) packet->data.asBytes);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CMD_LF_ACQ_RAW_ADC: {
|
case CMD_LF_ACQ_RAW_ADC: {
|
||||||
|
|
|
@ -1999,6 +1999,12 @@ void T55xxReadBlock(uint8_t page, bool pwd_mode, bool brute_mem, uint8_t block,
|
||||||
flags |= (downlink_mode & 3) << 3;
|
flags |= (downlink_mode & 3) << 3;
|
||||||
if (brute_mem) flags |= 0x0100;
|
if (brute_mem) flags |= 0x0100;
|
||||||
|
|
||||||
|
sample_config old_config;
|
||||||
|
sample_config *curr_config = getSamplingConfig();
|
||||||
|
memcpy(&old_config, curr_config, sizeof(sample_config));
|
||||||
|
old_config.verbose = false;
|
||||||
|
|
||||||
|
setDefaultSamplingConfig();
|
||||||
|
|
||||||
size_t samples = 12000;
|
size_t samples = 12000;
|
||||||
|
|
||||||
|
@ -2037,6 +2043,9 @@ void T55xxReadBlock(uint8_t page, bool pwd_mode, bool brute_mem, uint8_t block,
|
||||||
reply_ng(CMD_LF_T55XX_READBL, PM3_SUCCESS, NULL, 0);
|
reply_ng(CMD_LF_T55XX_READBL, PM3_SUCCESS, NULL, 0);
|
||||||
LED_A_OFF();
|
LED_A_OFF();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// reset back to old / save config
|
||||||
|
setSamplingConfig(&old_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,18 @@ Default LF config is set to:
|
||||||
samples_to_skip = 0
|
samples_to_skip = 0
|
||||||
verbose = YES
|
verbose = YES
|
||||||
*/
|
*/
|
||||||
static sample_config config = { 1, 8, 1, LF_DIVISOR_125, 0, 0, 1} ;
|
|
||||||
|
static sample_config def_config = {
|
||||||
|
.decimation = 1,
|
||||||
|
.bits_per_sample = 8,
|
||||||
|
.averaging = 1,
|
||||||
|
.divisor = LF_DIVISOR_125,
|
||||||
|
.trigger_threshold = 0,
|
||||||
|
.samples_to_skip = 0,
|
||||||
|
.verbose = false,
|
||||||
|
};
|
||||||
|
|
||||||
|
static sample_config config = { 1, 8, 1, LF_DIVISOR_125, 0, 0, true} ;
|
||||||
|
|
||||||
// Holds bit packed struct of samples.
|
// Holds bit packed struct of samples.
|
||||||
static BitstreamOut data = {0, 0, 0};
|
static BitstreamOut data = {0, 0, 0};
|
||||||
|
@ -57,6 +68,11 @@ void printSamples(void) {
|
||||||
print_stack_usage();
|
print_stack_usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void setDefaultSamplingConfig(void) {
|
||||||
|
setSamplingConfig(&def_config);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called from the USB-handler to set the sampling configuration
|
* Called from the USB-handler to set the sampling configuration
|
||||||
* The sampling config is used for standard reading and sniffing.
|
* The sampling config is used for standard reading and sniffing.
|
||||||
|
|
|
@ -96,7 +96,7 @@ void LFSetupFPGAForADC(int divisor, bool reader_field);
|
||||||
* @param sc
|
* @param sc
|
||||||
*/
|
*/
|
||||||
void setSamplingConfig(sample_config *sc);
|
void setSamplingConfig(sample_config *sc);
|
||||||
|
void setDefaultSamplingConfig(void);
|
||||||
sample_config *getSamplingConfig(void);
|
sample_config *getSamplingConfig(void);
|
||||||
|
|
||||||
void printLFConfig(void);
|
void printLFConfig(void);
|
||||||
|
|
|
@ -942,27 +942,6 @@ static int CmdT55xxDetect(const char *Cmd) {
|
||||||
// detect called so clear data blocks
|
// detect called so clear data blocks
|
||||||
T55x7_ClearAllBlockData();
|
T55x7_ClearAllBlockData();
|
||||||
|
|
||||||
// make sure decimate == 1
|
|
||||||
sample_config curr_lf_config;
|
|
||||||
memset(&curr_lf_config, 0, sizeof(sample_config));
|
|
||||||
|
|
||||||
res = lf_getconfig(&curr_lf_config);
|
|
||||||
if (res != PM3_SUCCESS) {
|
|
||||||
PrintAndLogEx(ERR, "failed to get current device LF config");
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
int8_t old_decimation = curr_lf_config.decimation;
|
|
||||||
if (curr_lf_config.decimation != 1) {
|
|
||||||
curr_lf_config.decimation = 1;
|
|
||||||
curr_lf_config.verbose = false;
|
|
||||||
res = lf_config(&curr_lf_config);
|
|
||||||
if (res != PM3_SUCCESS) {
|
|
||||||
PrintAndLogEx(ERR, "failed to set LF configuration decimation value to 1");
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// sanity check.
|
// sanity check.
|
||||||
if (SanityOfflineCheck(use_gb) != PM3_SUCCESS)
|
if (SanityOfflineCheck(use_gb) != PM3_SUCCESS)
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
|
@ -1038,17 +1017,6 @@ static int CmdT55xxDetect(const char *Cmd) {
|
||||||
PrintAndLogEx(WARNING, "Could not detect modulation automatically. Try setting it manually with " _YELLOW_("\'lf t55xx config\'"));
|
PrintAndLogEx(WARNING, "Could not detect modulation automatically. Try setting it manually with " _YELLOW_("\'lf t55xx config\'"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (old_decimation != curr_lf_config.decimation) {
|
|
||||||
curr_lf_config.decimation = old_decimation;
|
|
||||||
curr_lf_config.verbose = false;
|
|
||||||
res = lf_config(&curr_lf_config);
|
|
||||||
if (res != PM3_SUCCESS) {
|
|
||||||
PrintAndLogEx(ERR, "failed to restore LF configuration");
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue