diff --git a/armsrc/i2c.h b/armsrc/i2c.h index 06f7d2eb7..62dc1fd1a 100644 --- a/armsrc/i2c.h +++ b/armsrc/i2c.h @@ -39,11 +39,10 @@ // // v4.42 - the stock firmware, T=0 only // v4.51 - adds SEND_T1 (0x08) and PPS (0x09) -// -// Anything at or above the baseline is reported as ok, so a module does not go -// red every time its firmware moves on. +// v4.56 - T=0 reads to the expected length instead of an idle timeout +// v4.57 - the ATR does too #define SIM_MODULE_VERS_MIN_HI 4 -#define SIM_MODULE_VERS_MIN_LO 42 +#define SIM_MODULE_VERS_MIN_LO 57 #define SIM_MODULE_VERS_T1_HI 4 #define SIM_MODULE_VERS_T1_LO 51 @@ -51,10 +50,15 @@ #define ISO7816_MAX_FRAME 270 // Bit banged bus timing. 1CLK is spent twice per bit, 2CLK once, so the bit -// period is 2 * 1CLK + 2CLK, here 17 us or about 59 kHz. Every timeout below -// derives from these, so they are the only two numbers to change. -#define I2C_DELAY_1CLK_US 5 -#define I2C_DELAY_2CLK_US 7 +// period is 2 * 1CLK + 2CLK, 62 us or about 16 kHz. Every timeout below derives +// from these, so they are the only two numbers to change. +// +// 5/7 (59 kHz) has been tried twice and is too fast: the link works for a while +// then corrupts, an ATR coming back with flipped bits and a mangled length +// header rather than not arriving at all. Anything below 20/22 wants a scope on +// SCL/SDA first. +#define I2C_DELAY_1CLK_US 20 +#define I2C_DELAY_2CLK_US 22 // The SCL wait loops spend one 1CLK per iteration, so their timeouts are // iteration counts. Written in ms and converted here so the two cannot drift. diff --git a/client/src/cmdhficlass.c b/client/src/cmdhficlass.c index 8319ede72..4e915948b 100644 --- a/client/src/cmdhficlass.c +++ b/client/src/cmdhficlass.c @@ -8033,7 +8033,10 @@ static int CmdHFiClassSAMExtract(const char *Cmd) { CLIParserFree(ctx); - if (IsHIDSamPresent(verbose) == false) { + // The ARM pings the SAM itself before anything else, so this costs a card + // reset and an ATR to learn what it is about to learn again. Only pay for + // it when the detail was asked for. + if (verbose && (IsHIDSamPresent(verbose) == false)) { return PM3_ESOFT; } diff --git a/client/src/cmdhfseos.c b/client/src/cmdhfseos.c index 910194445..104085a86 100644 --- a/client/src/cmdhfseos.c +++ b/client/src/cmdhfseos.c @@ -2313,7 +2313,10 @@ static int CmdHfSeosSAM(const char *Cmd) { CLIParserFree(ctx); - if (IsHIDSamPresent(verbose) == false) { + // The ARM pings the SAM itself before anything else, so this costs a card + // reset and an ATR to learn what it is about to learn again. Only pay for + // it when the detail was asked for. + if (verbose && (IsHIDSamPresent(verbose) == false)) { return PM3_ESOFT; } @@ -2337,6 +2340,7 @@ static int CmdHfSeosSAM(const char *Cmd) { } default: { PrintAndLogEx(WARNING, "SAM select failed"); + PrintAndLogEx(HINT, "Hint: is a HID SAM in the slot? try `" _YELLOW_("smart info") "`"); return resp.status; } }