mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-08-22 06:13:27 -07:00
sc cleanup - add init to all sc commands...
because cmds won't work until the first init happens. (multiple inits don't appear to affect it negatively)
This commit is contained in:
parent
68e93fa639
commit
49d92e3c7e
5 changed files with 109 additions and 105 deletions
|
@ -361,12 +361,15 @@ void SendStatus(void)
|
||||||
{
|
{
|
||||||
BigBuf_print_status();
|
BigBuf_print_status();
|
||||||
Fpga_print_status();
|
Fpga_print_status();
|
||||||
|
#ifdef WITH_SMARTCARD
|
||||||
|
I2C_print_status();
|
||||||
|
#endif
|
||||||
printConfig(); //LF Sampling config
|
printConfig(); //LF Sampling config
|
||||||
printUSBSpeed();
|
printUSBSpeed();
|
||||||
Dbprintf("Various");
|
Dbprintf("Various");
|
||||||
Dbprintf(" MF_DBGLEVEL......%d", MF_DBGLEVEL);
|
Dbprintf(" MF_DBGLEVEL........%d", MF_DBGLEVEL);
|
||||||
Dbprintf(" ToSendMax........%d",ToSendMax);
|
Dbprintf(" ToSendMax..........%d", ToSendMax);
|
||||||
Dbprintf(" ToSendBit........%d",ToSendBit);
|
Dbprintf(" ToSendBit..........%d", ToSendBit);
|
||||||
|
|
||||||
cmd_send(CMD_ACK,1,0,0,0,0);
|
cmd_send(CMD_ACK,1,0,0,0,0);
|
||||||
}
|
}
|
||||||
|
@ -1262,10 +1265,6 @@ void UsbPacketReceived(uint8_t *packet, int len)
|
||||||
SmartCardAtr();
|
SmartCardAtr();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CMD_SMART_SETBAUD:{
|
|
||||||
SmartCardSetBaud(c->arg[0]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CMD_SMART_SETCLOCK:{
|
case CMD_SMART_SETCLOCK:{
|
||||||
SmartCardSetClock(c->arg[0]);
|
SmartCardSetClock(c->arg[0]);
|
||||||
break;
|
break;
|
||||||
|
|
11
armsrc/i2c.c
11
armsrc/i2c.c
|
@ -127,7 +127,7 @@ bool WaitSCL_H(void) {
|
||||||
|
|
||||||
// Wait max 300ms or until SCL goes LOW.
|
// Wait max 300ms or until SCL goes LOW.
|
||||||
// Which ever comes first
|
// Which ever comes first
|
||||||
bool WaitSCL_L_300ms(void){
|
bool WaitSCL_L_300ms(void) {
|
||||||
volatile uint16_t delay = 300;
|
volatile uint16_t delay = 300;
|
||||||
while ( delay-- ) {
|
while ( delay-- ) {
|
||||||
// exit on SCL LOW
|
// exit on SCL LOW
|
||||||
|
@ -584,6 +584,7 @@ void SmartCardAtr(void) {
|
||||||
LED_D_ON();
|
LED_D_ON();
|
||||||
clear_trace();
|
clear_trace();
|
||||||
set_tracing(true);
|
set_tracing(true);
|
||||||
|
I2C_init();
|
||||||
I2C_Reset_EnterMainProgram();
|
I2C_Reset_EnterMainProgram();
|
||||||
bool isOK = GetATR( &card );
|
bool isOK = GetATR( &card );
|
||||||
cmd_send(CMD_ACK, isOK, sizeof(smart_card_atr_t), 0, &card, sizeof(smart_card_atr_t));
|
cmd_send(CMD_ACK, isOK, sizeof(smart_card_atr_t), 0, &card, sizeof(smart_card_atr_t));
|
||||||
|
@ -606,6 +607,7 @@ void SmartCardRaw( uint64_t arg0, uint64_t arg1, uint8_t *data ) {
|
||||||
|
|
||||||
if ((flags & SC_CONNECT)) {
|
if ((flags & SC_CONNECT)) {
|
||||||
|
|
||||||
|
I2C_init();
|
||||||
I2C_Reset_EnterMainProgram();
|
I2C_Reset_EnterMainProgram();
|
||||||
|
|
||||||
if ( !(flags & SC_NO_SELECT) ) {
|
if ( !(flags & SC_NO_SELECT) ) {
|
||||||
|
@ -646,6 +648,7 @@ void SmartCardUpgrade(uint64_t arg0) {
|
||||||
// write. Sector0, with 11,22,33,44
|
// write. Sector0, with 11,22,33,44
|
||||||
// erase is 128bytes, and takes 50ms to execute
|
// erase is 128bytes, and takes 50ms to execute
|
||||||
|
|
||||||
|
I2C_init();
|
||||||
I2C_Reset_EnterBootloader();
|
I2C_Reset_EnterBootloader();
|
||||||
|
|
||||||
bool isOK = true;
|
bool isOK = true;
|
||||||
|
@ -697,12 +700,14 @@ void SmartCardUpgrade(uint64_t arg0) {
|
||||||
LED_C_OFF();
|
LED_C_OFF();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SmartCardSetBaud(uint64_t arg0) {
|
// unfinished (or not needed?)
|
||||||
}
|
//void SmartCardSetBaud(uint64_t arg0) {
|
||||||
|
//}
|
||||||
|
|
||||||
void SmartCardSetClock(uint64_t arg0) {
|
void SmartCardSetClock(uint64_t arg0) {
|
||||||
LED_D_ON();
|
LED_D_ON();
|
||||||
set_tracing(true);
|
set_tracing(true);
|
||||||
|
I2C_init();
|
||||||
I2C_Reset_EnterMainProgram();
|
I2C_Reset_EnterMainProgram();
|
||||||
|
|
||||||
// Send SIM CLC
|
// Send SIM CLC
|
||||||
|
|
|
@ -46,14 +46,13 @@ uint8_t I2C_BufferRead(uint8_t *data, uint8_t len, uint8_t device_cmd, uint8_t d
|
||||||
uint8_t I2C_ReadFW(uint8_t *data, uint8_t len, uint8_t msb, uint8_t lsb, uint8_t device_address);
|
uint8_t I2C_ReadFW(uint8_t *data, uint8_t len, uint8_t msb, uint8_t lsb, uint8_t device_address);
|
||||||
bool I2C_WriteFW(uint8_t *data, uint8_t len, uint8_t msb, uint8_t lsb, uint8_t device_address);
|
bool I2C_WriteFW(uint8_t *data, uint8_t len, uint8_t msb, uint8_t lsb, uint8_t device_address);
|
||||||
|
|
||||||
//
|
|
||||||
bool GetATR(smart_card_atr_t *card_ptr);
|
bool GetATR(smart_card_atr_t *card_ptr);
|
||||||
|
|
||||||
// generice functions
|
// generic functions
|
||||||
void SmartCardAtr(void);
|
void SmartCardAtr(void);
|
||||||
void SmartCardRaw(uint64_t arg0, uint64_t arg1, uint8_t *data);
|
void SmartCardRaw(uint64_t arg0, uint64_t arg1, uint8_t *data);
|
||||||
void SmartCardUpgrade(uint64_t arg0);
|
void SmartCardUpgrade(uint64_t arg0);
|
||||||
void SmartCardSetBaud(uint64_t arg0);
|
//void SmartCardSetBaud(uint64_t arg0);
|
||||||
void SmartCardSetClock(uint64_t arg0);
|
void SmartCardSetClock(uint64_t arg0);
|
||||||
void I2C_print_status(void);
|
void I2C_print_status(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -68,6 +68,7 @@ typedef struct{
|
||||||
#define CMD_SMART_UPGRADE 0x0141
|
#define CMD_SMART_UPGRADE 0x0141
|
||||||
#define CMD_SMART_UPLOAD 0x0142
|
#define CMD_SMART_UPLOAD 0x0142
|
||||||
#define CMD_SMART_ATR 0x0143
|
#define CMD_SMART_ATR 0x0143
|
||||||
|
// CMD_SMART_SETBAUD is unused for now
|
||||||
#define CMD_SMART_SETBAUD 0x0144
|
#define CMD_SMART_SETBAUD 0x0144
|
||||||
#define CMD_SMART_SETCLOCK 0x0145
|
#define CMD_SMART_SETCLOCK 0x0145
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue