mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2024-09-20 15:26:13 +08:00
Add usart dev cmds & dynamic flash support capability
This commit is contained in:
parent
8e2d5370f9
commit
3176684f4a
|
@ -43,7 +43,7 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac
|
|||
- Change better strong wave detection for biphase (@iceman)
|
||||
- Add 'script run test_t55x7' (@iceman)
|
||||
- Add new lua scripting support for some t55xx commands (@iceman)
|
||||
- *WIP* Add FPC usart with pm3 client: WITH_FPC_HOST. (@doegox)
|
||||
- Add FPC USART for BT add-on with pm3 client. (@doegox)
|
||||
- Add '-b baudrate' option to the pm3 client. (@doegox)
|
||||
- Change 'lf t55xx info': tell if known configuration block0. (@iceman)
|
||||
- Fix/Add FPC usart: fix TX, bring RX, full speed. (@doegox)
|
||||
|
|
8
Makefile
8
Makefile
|
@ -28,15 +28,19 @@ ifeq ($(PLATFORM),)
|
|||
ifeq ($(PLATFORM),)
|
||||
PLATFORM=PM3RDV4
|
||||
else
|
||||
${info using saved PLATFORM '$(PLATFORM)'}
|
||||
${info using saved PLATFORM: '$(PLATFORM)'}
|
||||
endif
|
||||
ifneq ($(PLATFORM_EXTRAS),)
|
||||
${info using saved PLATFORM_EXTRAS: '$(PLATFORM_EXTRAS)'}
|
||||
endif
|
||||
endif
|
||||
|
||||
include common/Makefile.hal
|
||||
|
||||
$(info ===================================================================)
|
||||
$(info PLATFORM: $(PLATFORM))
|
||||
$(info Platform name: $(PLTNAME))
|
||||
$(info PLATFORM: $(PLATFORM))
|
||||
$(info PLATFORM_EXTRAS: $(PLATFORM_EXTRAS))
|
||||
$(info Included options: $(PLATFORM_DEFS_INFO))
|
||||
$(info Standalone mode: $(PLATFORM_DEFS_INFO_STANDALONE))
|
||||
$(info ===================================================================)
|
||||
|
|
|
@ -14,12 +14,16 @@ ifeq ($(PLTNAME),)
|
|||
ifeq ($(PLATFORM),)
|
||||
PLATFORM=PM3RDV4
|
||||
else
|
||||
${info using saved PLATFORM '$(PLATFORM)'}
|
||||
${info using saved PLATFORM: '$(PLATFORM)'}
|
||||
endif
|
||||
ifneq ($(PLATFORM_EXTRAS),)
|
||||
${info using saved PLATFORM_EXTRAS: '$(PLATFORM_EXTRAS)'}
|
||||
endif
|
||||
include ../common/Makefile.hal
|
||||
$(info ===================================================================)
|
||||
$(info PLATFORM: $(PLATFORM))
|
||||
$(info Platform name: $(PLTNAME))
|
||||
$(info PLATFORM: $(PLATFORM))
|
||||
$(info PLATFORM_EXTRAS: $(PLATFORM_EXTRAS))
|
||||
$(info Included options: $(PLATFORM_DEFS_INFO))
|
||||
$(info Standalone mode: $(PLATFORM_DEFS_INFO_STANDALONE))
|
||||
$(info ===================================================================)
|
||||
|
@ -56,7 +60,7 @@ else
|
|||
SRC_SMARTCARD =
|
||||
endif
|
||||
|
||||
ifneq (,$(findstring WITH_FPC,$(APP_CFLAGS)))
|
||||
ifneq (,$(findstring WITH_FPC_USART,$(APP_CFLAGS)))
|
||||
SRC_FPC = usart.c
|
||||
else
|
||||
SRC_FPC =
|
||||
|
|
130
armsrc/appmain.c
130
armsrc/appmain.c
|
@ -36,7 +36,7 @@
|
|||
#include "i2c.h"
|
||||
#endif
|
||||
|
||||
#ifdef WITH_FPC
|
||||
#ifdef WITH_FPC_USART
|
||||
#include "usart.h"
|
||||
#endif
|
||||
|
||||
|
@ -441,8 +441,7 @@ void SendCapabilities(void) {
|
|||
|
||||
#ifdef WITH_FLASH
|
||||
capabilities.compiled_with_flash = true;
|
||||
// TODO
|
||||
capabilities.hw_available_flash = true;
|
||||
capabilities.hw_available_flash = FlashInit();
|
||||
#else
|
||||
capabilities.compiled_with_flash = false;
|
||||
capabilities.hw_available_flash = false;
|
||||
|
@ -455,18 +454,23 @@ void SendCapabilities(void) {
|
|||
capabilities.compiled_with_smartcard = false;
|
||||
capabilities.hw_available_smartcard = false;
|
||||
#endif
|
||||
#ifdef WITH_FPC
|
||||
capabilities.compiled_with_fpc = true;
|
||||
#ifdef WITH_FPC_USART
|
||||
capabilities.compiled_with_fpc_usart = true;
|
||||
#else
|
||||
capabilities.compiled_with_fpc = false;
|
||||
capabilities.compiled_with_fpc_usart = false;
|
||||
#endif
|
||||
#ifdef WITH_FPC_HOST
|
||||
capabilities.compiled_with_fpc_host = true;
|
||||
// TODO
|
||||
capabilities.hw_available_fpc_host = true;
|
||||
#ifdef WITH_FPC_USART_DEV
|
||||
capabilities.compiled_with_fpc_usart_dev = true;
|
||||
#else
|
||||
capabilities.compiled_with_fpc_host = false;
|
||||
capabilities.hw_available_fpc_host = false;
|
||||
capabilities.compiled_with_fpc_usart_dev = false;
|
||||
#endif
|
||||
#ifdef WITH_FPC_USART_HOST
|
||||
capabilities.compiled_with_fpc_usart_host = true;
|
||||
// TODO
|
||||
capabilities.hw_available_fpc_usart_btaddon = true;
|
||||
#else
|
||||
capabilities.compiled_with_fpc_usart_host = false;
|
||||
capabilities.hw_available_fpc_usart_btaddon = false;
|
||||
#endif
|
||||
#ifdef WITH_LF
|
||||
capabilities.compiled_with_lf = true;
|
||||
|
@ -1181,79 +1185,45 @@ static void PacketReceived(PacketCommandNG *packet) {
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef WITH_FPC
|
||||
case CMD_FPC_SEND: {
|
||||
|
||||
|
||||
StartTicks();
|
||||
DbpString("Mutual USB/FPC sending from device to client");
|
||||
|
||||
/*
|
||||
char at[11] = {'\0'};
|
||||
static const char* s_at = "AT+BAUD8\0D\0A";
|
||||
strncat(at, s_at, sizeof(at) - strlen(at) - 1);
|
||||
DbpString("Try AT baud rate setting");
|
||||
usart_init();
|
||||
int16_t res = usart_writebuffer_sync((uint8_t*)&at, sizeof(at));
|
||||
WaitMS(1);
|
||||
Dbprintf("SEND %d | %c%c%c%c%c%c%c%c%c%c%c", res, at[0], at[1], at[2], at[3], at[4], at[5], at[6], at[7], at[8], at[9], at[10]);
|
||||
|
||||
uint8_t my_rx[20];
|
||||
memset(my_rx, 0, sizeof(my_rx));
|
||||
res = usart_readbuffer(my_rx);
|
||||
WaitMS(1);
|
||||
Dbprintf("GOT %d | %c%c%c%c%c%c%c%c", res, my_rx[0], my_rx[1], my_rx[2], my_rx[3], my_rx[4], my_rx[5], my_rx[6], my_rx[7]);
|
||||
*/
|
||||
|
||||
|
||||
char dest[USART_FIFOLEN] = {'\0'};
|
||||
#ifdef WITH_FPC_USART_DEV
|
||||
case CMD_USART_TX: {
|
||||
usart_writebuffer_sync(packet->data.asBytes, packet->length);
|
||||
reply_ng(CMD_USART_TX, PM3_SUCCESS, NULL, 0);
|
||||
break;
|
||||
}
|
||||
case CMD_USART_RX: {
|
||||
uint8_t dest[USART_FIFOLEN] = {'\0'};
|
||||
uint16_t available = usart_rxdata_available();
|
||||
if (available > 0) {
|
||||
Dbprintf("RX DATA!");
|
||||
uint16_t len = usart_read_ng((uint8_t *)dest, available);
|
||||
dest[len] = '\0';
|
||||
Dbprintf("RX: %d | %02X %02X %02X %02X %02X %02X %02X %02X ", len, dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
|
||||
uint16_t len = usart_read_ng(dest, available);
|
||||
reply_ng(CMD_USART_RX, PM3_SUCCESS, dest, len);
|
||||
} else {
|
||||
reply_ng(CMD_USART_RX, PM3_ENODATA, NULL, 0);
|
||||
}
|
||||
|
||||
static const char *welcome = "Proxmark3 Serial interface via FPC ready\r\n";
|
||||
usart_writebuffer_sync((uint8_t *)welcome, strlen(welcome));
|
||||
|
||||
sprintf(dest, "| bytes 0x%02x 0x%02x 0x%02x 0x%02x\r\n"
|
||||
, packet->data.asBytes[0]
|
||||
, packet->data.asBytes[1]
|
||||
, packet->data.asBytes[2]
|
||||
, packet->data.asBytes[3]
|
||||
);
|
||||
usart_writebuffer_sync((uint8_t *)dest, strlen(dest));
|
||||
|
||||
|
||||
LED_A_ON();
|
||||
|
||||
|
||||
//usb
|
||||
reply_old(CMD_DEBUG_PRINT_STRING, strlen(dest), 0, 0, dest, strlen(dest));
|
||||
LED_A_OFF();
|
||||
/*
|
||||
uint8_t my_rx[sizeof(PacketCommandOLD)];
|
||||
while (!BUTTON_PRESS() && !usb_poll_validate_length()) {
|
||||
LED_B_INV();
|
||||
if (usart_read_ng(my_rx) ) {
|
||||
//PacketReceived(my_rx, sizeof(my_rx));
|
||||
|
||||
PacketCommandOLD *my = (PacketCommandOLD *)my_rx;
|
||||
if (my->cmd > 0 ) {
|
||||
Dbprintf("received command: 0x%04x and args: %d %d %d", my->cmd, my->arg[0], my->arg[1], my->arg[2]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CMD_USART_TXRX: {
|
||||
struct p {
|
||||
uint32_t waittime;
|
||||
uint8_t data[PM3_CMD_DATA_SIZE - sizeof(uint32_t)];
|
||||
} PACKED;
|
||||
struct p *payload = (struct p *) &packet->data.asBytes;
|
||||
usart_writebuffer_sync(payload->data, packet->length - sizeof(payload->waittime));
|
||||
uint16_t available;
|
||||
WaitMS(payload->waittime);
|
||||
uint8_t dest[USART_FIFOLEN] = {'\0'};
|
||||
available = usart_rxdata_available();
|
||||
// Dbprintf("avail (%u)", available);
|
||||
if (available > 0) {
|
||||
uint16_t len = usart_read_ng(dest, available);
|
||||
reply_ng(CMD_USART_TXRX, PM3_SUCCESS, dest, len);
|
||||
} else {
|
||||
reply_ng(CMD_USART_TXRX, PM3_ENODATA, NULL, 0);
|
||||
}
|
||||
*/
|
||||
//reply_old(CMD_DEBUG_PRINT_STRING, strlen(dest), 0, 0, dest, strlen(dest));
|
||||
|
||||
reply_old(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
StopTicks();
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
case CMD_BUFF_CLEAR:
|
||||
BigBuf_Clear();
|
||||
BigBuf_free();
|
||||
|
@ -1525,7 +1495,7 @@ static void PacketReceived(PacketCommandNG *packet) {
|
|||
case 2:
|
||||
SetAdcMuxFor(GPIO_MUXSEL_HIPKD);
|
||||
break;
|
||||
#ifndef WITH_FPC
|
||||
#ifndef WITH_FPC_USART
|
||||
case 1:
|
||||
SetAdcMuxFor(GPIO_MUXSEL_LORAW);
|
||||
break;
|
||||
|
@ -1642,7 +1612,7 @@ void __attribute__((noreturn)) AppMain(void) {
|
|||
I2C_init();
|
||||
#endif
|
||||
|
||||
#ifdef WITH_FPC
|
||||
#ifdef WITH_FPC_USART
|
||||
usart_init();
|
||||
#endif
|
||||
|
||||
|
|
|
@ -450,8 +450,8 @@ void FpgaWriteConfWord(uint8_t v) {
|
|||
//-----------------------------------------------------------------------------
|
||||
void SetAdcMuxFor(uint32_t whichGpio) {
|
||||
|
||||
#ifndef WITH_FPC
|
||||
// When compiled without FPC support
|
||||
#ifndef WITH_FPC_USART
|
||||
// When compiled without FPC USART support
|
||||
AT91C_BASE_PIOA->PIO_OER =
|
||||
GPIO_MUXSEL_HIPKD |
|
||||
GPIO_MUXSEL_LOPKD |
|
||||
|
@ -472,7 +472,7 @@ void SetAdcMuxFor(uint32_t whichGpio) {
|
|||
#else
|
||||
if ((whichGpio == GPIO_MUXSEL_LORAW) || (whichGpio == GPIO_MUXSEL_HIRAW))
|
||||
return;
|
||||
// FPC serial uses HIRAW/LOWRAW pins, so they are excluded here.
|
||||
// FPC USART uses HIRAW/LOWRAW pins, so they are excluded here.
|
||||
AT91C_BASE_PIOA->PIO_OER = GPIO_MUXSEL_HIPKD | GPIO_MUXSEL_LOPKD;
|
||||
AT91C_BASE_PIOA->PIO_PER = GPIO_MUXSEL_HIPKD | GPIO_MUXSEL_LOPKD;
|
||||
LOW(GPIO_MUXSEL_HIPKD);
|
||||
|
|
|
@ -10,12 +10,16 @@ ifeq ($(PLTNAME),)
|
|||
ifeq ($(PLATFORM),)
|
||||
PLATFORM=PM3RDV4
|
||||
else
|
||||
${info using saved PLATFORM '$(PLATFORM)'}
|
||||
${info using saved PLATFORM: '$(PLATFORM)'}
|
||||
endif
|
||||
ifneq ($(PLATFORM_EXTRAS),)
|
||||
${info using saved PLATFORM_EXTRAS: '$(PLATFORM_EXTRAS)'}
|
||||
endif
|
||||
include ../common/Makefile.hal
|
||||
$(info ===================================================================)
|
||||
$(info PLATFORM: $(PLATFORM))
|
||||
$(info Platform name: $(PLTNAME))
|
||||
$(info PLATFORM: $(PLATFORM))
|
||||
$(info PLATFORM_EXTRAS: $(PLATFORM_EXTRAS))
|
||||
$(info Included options: $(PLATFORM_DEFS_INFO))
|
||||
$(info Standalone mode: $(PLATFORM_DEFS_INFO_STANDALONE))
|
||||
$(info ===================================================================)
|
||||
|
@ -222,6 +226,7 @@ CMDSRCS = crapto1/crapto1.c \
|
|||
cmdtrace.c \
|
||||
cmdflashmem.c \
|
||||
cmdsmartcard.c \
|
||||
cmdusart.c \
|
||||
cmdparser.c \
|
||||
cmdmain.c \
|
||||
pm3_binlib.c \
|
||||
|
|
|
@ -485,47 +485,7 @@ static char *pb(uint32_t b) {
|
|||
|
||||
static int CmdAnalyseA(const char *Cmd) {
|
||||
|
||||
int hexlen = 0;
|
||||
uint8_t cmdp = 0;
|
||||
bool errors = false;
|
||||
uint8_t data[PM3_CMD_DATA_SIZE] = {0x00};
|
||||
|
||||
if (!IfPm3Fpc()) {
|
||||
PrintAndLogEx(ERR, "Device has no FPC USART support");
|
||||
return PM3_EDEVNOTSUPP;
|
||||
}
|
||||
|
||||
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
||||
switch (tolower(param_getchar(Cmd, cmdp))) {
|
||||
case 'd':
|
||||
param_gethex_ex(Cmd, cmdp + 1, data, &hexlen);
|
||||
hexlen >>= 1;
|
||||
if (hexlen != sizeof(data)) {
|
||||
PrintAndLogEx(WARNING, "Read %d bytes of %u", hexlen, sizeof(data));
|
||||
}
|
||||
cmdp += 2;
|
||||
break;
|
||||
case 'h':
|
||||
return usage_analyse_a();
|
||||
default:
|
||||
PrintAndLogEx(WARNING, "Unknown parameter '%c'", param_getchar(Cmd, cmdp));
|
||||
errors = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//Validations
|
||||
if (errors || cmdp == 0) return usage_analyse_a();
|
||||
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandOLD(CMD_FPC_SEND, 0, 0, 0, data, PM3_CMD_DATA_SIZE);
|
||||
|
||||
PacketResponseNG resp;
|
||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
|
||||
return 1;
|
||||
}
|
||||
PrintAndLogEx(NORMAL, "got ack. Status %d", resp.oldarg[0]);
|
||||
return 0;
|
||||
return usage_analyse_a();
|
||||
/*
|
||||
PrintAndLogEx(NORMAL, "-- " _BLUE_("its my message") "\n");
|
||||
PrintAndLogEx(NORMAL, "-- " _RED_("its my message") "\n");
|
||||
|
|
|
@ -498,11 +498,14 @@ void pm3_version(bool verbose) {
|
|||
PrintAndLogEx(NORMAL, "\n" _BLUE_(" [ Proxmark3 RFID instrument ]") "\n");
|
||||
PrintAndLogEx(NORMAL, "\n [ CLIENT ]");
|
||||
PrintAndLogEx(NORMAL, " client: RRG/Iceman"); // TODO version info?
|
||||
PrintAndLogEx(NORMAL, "\n [ PROXMARK ]");
|
||||
PrintAndLogEx(NORMAL, " external flash: %s", IfPm3Flash() ? _GREEN_("present") : _YELLOW_("absent"));
|
||||
PrintAndLogEx(NORMAL, " smartcard reader: %s", IfPm3Smartcard() ? _GREEN_("present") : _YELLOW_("absent"));
|
||||
PrintAndLogEx(NORMAL, " USART for addon support: %s\n", IfPm3FpcHost() ? _GREEN_("present") : _YELLOW_("absent"));
|
||||
|
||||
PrintAndLogEx(NORMAL, "\n [ PROXMARK RDV4 ]");
|
||||
PrintAndLogEx(NORMAL, " external flash: %s", IfPm3Flash() ? _GREEN_("present") : _YELLOW_("absent"));
|
||||
PrintAndLogEx(NORMAL, " smartcard reader: %s", IfPm3Smartcard() ? _GREEN_("present") : _YELLOW_("absent"));
|
||||
PrintAndLogEx(NORMAL, "\n [ PROXMARK RDV4 Extras ]");
|
||||
PrintAndLogEx(NORMAL, " FPC USART for BT add-on support: %s", IfPm3FpcUsartHost() ? _GREEN_("present") : _YELLOW_("absent"));
|
||||
if (IfPm3FpcUsartDevFromUsb())
|
||||
PrintAndLogEx(NORMAL, " FPC USART for developer support: %s", _GREEN_("present"));
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, (char *)resp.data.asBytes);
|
||||
lookupChipID(resp.oldarg[0], resp.oldarg[1]);
|
||||
}
|
||||
|
|
|
@ -42,21 +42,22 @@ static int CmdRev(const char *Cmd) {
|
|||
}
|
||||
|
||||
static command_t CommandTable[] = {
|
||||
{"help", CmdHelp, AlwaysAvailable, "This help. Use '<command> help' for details of a particular command."},
|
||||
{"analyse", CmdAnalyse, AlwaysAvailable, "{ Analyse utils... }"},
|
||||
{"data", CmdData, AlwaysAvailable, "{ Plot window / data buffer manipulation... }"},
|
||||
{"hf", CmdHF, AlwaysAvailable, "{ High Frequency commands... }"},
|
||||
{"hw", CmdHW, AlwaysAvailable, "{ Hardware commands... }"},
|
||||
{"lf", CmdLF, AlwaysAvailable, "{ Low Frequency commands... }"},
|
||||
{"emv", CmdEMV, AlwaysAvailable, "{ EMV iso14443 and iso7816... }"},
|
||||
{"rem", CmdRem, AlwaysAvailable, "{ Add text to row in log file }"},
|
||||
{"reveng", CmdRev, AlwaysAvailable, "{ Crc calculations from the RevEng software... }"},
|
||||
{"script", CmdScript, AlwaysAvailable, "{ Scripting commands }"},
|
||||
{"trace", CmdTrace, AlwaysAvailable, "{ Trace manipulation... }"},
|
||||
{"mem", CmdFlashMem, IfPm3Flash, "{ Flash Memory manipulation... }"},
|
||||
{"sc", CmdSmartcard, IfPm3Smartcard, "{ Smart card ISO7816 commands... }"},
|
||||
{"quit", CmdQuit, AlwaysAvailable, ""},
|
||||
{"exit", CmdQuit, AlwaysAvailable, "Exit program"},
|
||||
{"help", CmdHelp, AlwaysAvailable, "This help. Use '<command> help' for details of a particular command."},
|
||||
{"analyse", CmdAnalyse, AlwaysAvailable, "{ Analyse utils... }"},
|
||||
{"data", CmdData, AlwaysAvailable, "{ Plot window / data buffer manipulation... }"},
|
||||
{"hf", CmdHF, AlwaysAvailable, "{ High Frequency commands... }"},
|
||||
{"hw", CmdHW, AlwaysAvailable, "{ Hardware commands... }"},
|
||||
{"lf", CmdLF, AlwaysAvailable, "{ Low Frequency commands... }"},
|
||||
{"emv", CmdEMV, AlwaysAvailable, "{ EMV iso14443 and iso7816... }"},
|
||||
{"rem", CmdRem, AlwaysAvailable, "{ Add text to row in log file }"},
|
||||
{"reveng", CmdRev, AlwaysAvailable, "{ Crc calculations from the RevEng software... }"},
|
||||
{"script", CmdScript, AlwaysAvailable, "{ Scripting commands }"},
|
||||
{"trace", CmdTrace, AlwaysAvailable, "{ Trace manipulation... }"},
|
||||
{"mem", CmdFlashMem, IfPm3Flash, "{ Flash Memory manipulation... }"},
|
||||
{"sc", CmdSmartcard, IfPm3Smartcard, "{ Smart card ISO7816 commands... }"},
|
||||
{"usart", CmdUsart, IfPm3FpcUsartDevFromUsb, "{ USART commands... }"},
|
||||
{"quit", CmdQuit, AlwaysAvailable, ""},
|
||||
{"exit", CmdQuit, AlwaysAvailable, "Exit program"},
|
||||
{NULL, NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "emv/cmdemv.h" // EMV
|
||||
#include "cmdflashmem.h" // rdv40 flashmem commands
|
||||
#include "cmdsmartcard.h" // rdv40 smart card ISO7816 commands
|
||||
#include "cmdusart.h" // rdv40 FPC USART commands
|
||||
|
||||
int CommandReceived(char *Cmd);
|
||||
command_t *getTopLevelCommandTable(void);
|
||||
|
|
|
@ -43,18 +43,27 @@ bool IfPm3Smartcard(void) {
|
|||
return pm3_capabilities.hw_available_smartcard;
|
||||
}
|
||||
|
||||
bool IfPm3Fpc(void) {
|
||||
bool IfPm3FpcUsart(void) {
|
||||
if (!IfPm3Present())
|
||||
return false;
|
||||
return pm3_capabilities.compiled_with_fpc;
|
||||
return pm3_capabilities.compiled_with_fpc_usart;
|
||||
}
|
||||
|
||||
bool IfPm3FpcHost(void) {
|
||||
bool IfPm3FpcUsartHost(void) {
|
||||
if (!IfPm3Present())
|
||||
return false;
|
||||
if (!pm3_capabilities.compiled_with_fpc_host)
|
||||
return pm3_capabilities.compiled_with_fpc_usart_host;
|
||||
}
|
||||
|
||||
bool IfPm3FpcUsartDevFromUsb(void) {
|
||||
// true if FPC USART developer support and if talking from USB-CDC interface
|
||||
if (!IfPm3Present())
|
||||
return false;
|
||||
return pm3_capabilities.hw_available_fpc_host;
|
||||
if (!pm3_capabilities.compiled_with_fpc_usart_dev)
|
||||
return false;
|
||||
if (conn.send_via_fpc_usart)
|
||||
PrintAndLogEx(WARNING, "This command is not available via FPC, only via " _YELLOW_("USB-CDC"));
|
||||
return !conn.send_via_fpc_usart;
|
||||
}
|
||||
|
||||
bool IfPm3Lf(void) {
|
||||
|
@ -156,7 +165,7 @@ int CmdsParse(const command_t Commands[], const char *Cmd) {
|
|||
if (Commands[i].IsAvailable()) {
|
||||
break;
|
||||
} else {
|
||||
PrintAndLogEx(WARNING, "This command is only available in " _YELLOW_("online") "mode");
|
||||
PrintAndLogEx(WARNING, "This command is " _YELLOW_("not available") "in this mode");
|
||||
return PM3_ENOTIMPL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,8 +24,9 @@ bool AlwaysAvailable(void);
|
|||
bool IfPm3Present(void);
|
||||
bool IfPm3Flash(void);
|
||||
bool IfPm3Smartcard(void);
|
||||
bool IfPm3Fpc(void);
|
||||
bool IfPm3FpcHost(void);
|
||||
bool IfPm3FpcUsart(void);
|
||||
bool IfPm3FpcUsartHost(void);
|
||||
bool IfPm3FpcUsartDevFromUsb(void);
|
||||
bool IfPm3Lf(void);
|
||||
bool IfPm3Hitag(void);
|
||||
bool IfPm3Hfsniff(void);
|
||||
|
|
|
@ -138,7 +138,7 @@ static void SendCommandNG_internal(uint16_t cmd, uint8_t *data, size_t len, bool
|
|||
txBufferNG.pre.cmd = cmd;
|
||||
memcpy(&txBufferNG.data, data, len);
|
||||
|
||||
if ((conn.send_via_fpc && conn.send_with_crc_on_fpc) || ((!conn.send_via_fpc) && conn.send_with_crc_on_usb)) {
|
||||
if ((conn.send_via_fpc_usart && conn.send_with_crc_on_fpc) || ((!conn.send_via_fpc_usart) && conn.send_with_crc_on_usb)) {
|
||||
uint8_t first, second;
|
||||
compute_crc(CRC_14443_A, (uint8_t *)&txBufferNG, sizeof(PacketCommandNGPreamble) + len, &first, &second);
|
||||
tx_post->crc = (first << 8) + second;
|
||||
|
@ -559,7 +559,7 @@ bool OpenProxmark(void *port, bool wait_for_port, int timeout, bool flash_mode,
|
|||
conn.send_with_crc_on_usb = false;
|
||||
conn.send_with_crc_on_fpc = true;
|
||||
// "Session" flag, to tell via which interface next msgs should be sent: USB or FPC USART
|
||||
conn.send_via_fpc = false;
|
||||
conn.send_via_fpc_usart = false;
|
||||
|
||||
pthread_create(&USB_communication_thread, NULL, &uart_communication, &conn);
|
||||
|
||||
|
@ -597,16 +597,15 @@ int TestProxmark(void) {
|
|||
SendCommandNG(CMD_CAPABILITIES, NULL, 0);
|
||||
if (WaitForResponseTimeoutW(CMD_PING, &resp, 1000, false)) {
|
||||
memcpy(&pm3_capabilities, resp.data.asBytes, resp.length);
|
||||
conn.send_via_fpc = pm3_capabilities.via_fpc;
|
||||
conn.send_via_fpc_usart = pm3_capabilities.via_fpc;
|
||||
conn.uart_speed = pm3_capabilities.baudrate;
|
||||
PrintAndLogEx(INFO, "Communicating with PM3 over %s", conn.send_via_fpc ? _YELLOW_("FPC UART") : _YELLOW_("USB-CDC"));
|
||||
if (conn.send_via_fpc) {
|
||||
PrintAndLogEx(INFO, "Communicating with PM3 over %s", conn.send_via_fpc_usart ? _YELLOW_("FPC UART") : _YELLOW_("USB-CDC"));
|
||||
if (conn.send_via_fpc_usart) {
|
||||
PrintAndLogEx(INFO, "UART Serial baudrate: " _YELLOW_("%u") "\n", conn.uart_speed);
|
||||
}
|
||||
|
||||
// reconfigure.
|
||||
if (conn.send_via_fpc == false) {
|
||||
|
||||
if (conn.send_via_fpc_usart == false) {
|
||||
#if defined(_WIN32)
|
||||
pthread_mutex_lock(&spMutex);
|
||||
#endif
|
||||
|
@ -669,7 +668,7 @@ void CloseProxmark(void) {
|
|||
// ~ = 12000000 / USART_BAUD_RATE
|
||||
// Let's take 2x (maybe we need more for BT link?)
|
||||
static size_t communication_delay(void) {
|
||||
if (conn.send_via_fpc) // needed also for Windows USB USART??
|
||||
if (conn.send_via_fpc_usart) // needed also for Windows USB USART??
|
||||
return 2 * (12000000 / conn.uart_speed);
|
||||
return 100;
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ typedef struct {
|
|||
bool send_with_crc_on_usb;
|
||||
bool send_with_crc_on_fpc;
|
||||
// "Session" flag, to tell via which interface next msgs are sent: USB or FPC USART
|
||||
bool send_via_fpc;
|
||||
bool send_via_fpc_usart;
|
||||
// To memorise baudrate
|
||||
uint32_t uart_speed;
|
||||
} communication_arg_t;
|
||||
|
|
|
@ -1,22 +1,26 @@
|
|||
define KNOWN_PLATFORMS
|
||||
|
||||
+--------------------------------------------------------+
|
||||
| PLATFORM | DESCRIPTION |
|
||||
+--------------------------------------------------------+
|
||||
| PM3RDV4 (def) | Proxmark3 rdv4 with AT91SAM7S512 |
|
||||
+--------------------------------------------------------+
|
||||
| PM3RDV4FPC | Proxmark3 rdv4+FPC (experimental) |
|
||||
+--------------------------------------------------------+
|
||||
| PM3EVO | Proxmark3 EVO with AT91SAM7S512 |
|
||||
+--------------------------------------------------------+
|
||||
| PM3EASY | Proxmark3 rdv3 Easy with AT91SAM7S256 |
|
||||
+--------------------------------------------------------+
|
||||
| PM3RDV2 | Proxmark3 rdv2 with AT91SAM7S512 |
|
||||
+--------------------------------------------------------+
|
||||
| PM3OLD256 | Proxmark3 V1 with AT91SAM7S256 |
|
||||
+--------------------------------------------------------+
|
||||
| PM3OLD512 | Proxmark3 V1 with AT91SAM7S512 |
|
||||
+--------------------------------------------------------+
|
||||
+==========================================================+
|
||||
| PLATFORM | DESCRIPTION |
|
||||
+==========================================================+
|
||||
| PM3RDV4 (def) | Proxmark3 rdv4 with AT91SAM7S512 |
|
||||
+----------------------------------------------------------+
|
||||
| PM3EVO | Proxmark3 EVO with AT91SAM7S512 |
|
||||
+----------------------------------------------------------+
|
||||
| PM3EASY | Proxmark3 rdv3 Easy with AT91SAM7S256 |
|
||||
+----------------------------------------------------------+
|
||||
| PM3RDV2 | Proxmark3 rdv2 with AT91SAM7S512 |
|
||||
+----------------------------------------------------------+
|
||||
| PM3OLD256 | Proxmark3 V1 with AT91SAM7S256 |
|
||||
+----------------------------------------------------------+
|
||||
| PM3OLD512 | Proxmark3 V1 with AT91SAM7S512 |
|
||||
+----------------------------------------------------------+
|
||||
|
||||
+==========================================================+
|
||||
| PLATFORM_EXTRAS | DESCRIPTION |
|
||||
+==========================================================+
|
||||
| BTADDON | Proxmark3 rdv4 BT add-on |
|
||||
+----------------------------------------------------------+
|
||||
|
||||
Options to define platform:
|
||||
(1) Run make with PLATFORM specified as follows:
|
||||
|
@ -25,6 +29,12 @@ make PLATFORM=PM3EASY
|
|||
(2) Save a file called Makefile.platform with contents:
|
||||
PLATFORM=PM3EASY
|
||||
|
||||
or if you have a Proxmark 3 RDV4 with the BT add-on:
|
||||
PLATFORM=PM3RDV4
|
||||
PLATFORM_EXTRAS=BTADDON
|
||||
|
||||
!! Make sure to "make clean" when you change platform settings !!
|
||||
|
||||
endef
|
||||
|
||||
PLTNAME = Unknown Platform
|
||||
|
@ -33,10 +43,6 @@ ifeq ($(PLATFORM),PM3RDV4)
|
|||
MCU = AT91SAM7S512
|
||||
PLATFORM_DEFS = -DWITH_SMARTCARD -DWITH_FLASH
|
||||
PLTNAME = Proxmark3 rdv4
|
||||
else ifeq ($(PLATFORM),PM3RDV4FPC)
|
||||
MCU = AT91SAM7S512
|
||||
PLATFORM_DEFS = -DWITH_SMARTCARD -DWITH_FLASH -DWITH_FPC_HOST
|
||||
PLTNAME = Proxmark3 rdv4
|
||||
else ifeq ($(PLATFORM),PM3EVO)
|
||||
MCU = AT91SAM7S512
|
||||
PLTNAME = Proxmark3 EVO
|
||||
|
@ -56,6 +62,20 @@ else
|
|||
$(error Invalid or empty PLATFORM: $(PLATFORM). Known platforms: $(KNOWN_PLATFORMS))
|
||||
endif
|
||||
|
||||
# parsing additional PLATFORM_EXTRAS tokens
|
||||
PLATFORM_EXTRAS_TMP:=$(PLATFORM_EXTRAS)
|
||||
ifneq (,$(findstring BTADDON,$(PLATFORM_EXTRAS_TMP)))
|
||||
PLATFORM_DEFS += -DWITH_FPC_USART_HOST
|
||||
PLATFORM_EXTRAS_TMP := $(strip $(filter-out BTADDON,$(PLATFORM_EXTRAS_TMP)))
|
||||
endif
|
||||
ifneq (,$(findstring FPC_USART_DEV,$(PLATFORM_EXTRAS_TMP)))
|
||||
PLATFORM_DEFS += -DWITH_FPC_USART_DEV
|
||||
PLATFORM_EXTRAS_TMP := $(strip $(filter-out FPC_USART_DEV,$(PLATFORM_EXTRAS_TMP)))
|
||||
endif
|
||||
ifneq (,$(PLATFORM_EXTRAS_TMP))
|
||||
$(error Unknown PLATFORM_EXTRAS token(s): $(PLATFORM_EXTRAS_TMP))
|
||||
endif
|
||||
|
||||
# common LF support
|
||||
PLATFORM_DEFS += \
|
||||
-DWITH_LF \
|
||||
|
@ -90,9 +110,9 @@ $(info $(findstring WITH_STANDALONE_*,$(PLATFORM_DEFS)))
|
|||
|
||||
# Add flags dependencies :
|
||||
|
||||
# WITH_FPC_* needs WITH_FPC :
|
||||
ifneq (,$(findstring WITH_FPC_,$(PLATFORM_DEFS)))
|
||||
PLATFORM_DEFS += -DWITH_FPC
|
||||
# WITH_FPC_USART_* needs WITH_FPC_USART :
|
||||
ifneq (,$(findstring WITH_FPC_USART_,$(PLATFORM_DEFS)))
|
||||
PLATFORM_DEFS += -DWITH_FPC_USART
|
||||
endif
|
||||
|
||||
PLATFORM_DEFS_INFO = $(strip $(filter-out STANDALONE%, $(subst -DWITH_,,$(PLATFORM_DEFS))))
|
||||
|
@ -105,6 +125,7 @@ endif
|
|||
|
||||
|
||||
export PLATFORM
|
||||
export PLATFORM_EXTRAS
|
||||
export PLTNAME
|
||||
export MCU
|
||||
export PLATFORM_DEFS
|
||||
|
|
|
@ -38,7 +38,7 @@ bool reply_with_crc_on_fpc = true;
|
|||
// "Session" flag, to tell via which interface next msgs should be sent: USB or FPC USART
|
||||
bool reply_via_fpc = false;
|
||||
|
||||
#ifdef WITH_FPC_HOST
|
||||
#ifdef WITH_FPC_USART_HOST
|
||||
extern void Dbprintf(const char *fmt, ...);
|
||||
#define Dbprintf_usb(...) {\
|
||||
bool tmp = reply_via_fpc;\
|
||||
|
@ -71,7 +71,7 @@ int reply_old(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *d
|
|||
// Send frame and make sure all bytes are transmitted
|
||||
|
||||
if (reply_via_fpc) {
|
||||
#ifdef WITH_FPC_HOST
|
||||
#ifdef WITH_FPC_USART_HOST
|
||||
result = usart_writebuffer_sync((uint8_t *)&txcmd, sizeof(PacketResponseOLD));
|
||||
// Dbprintf_usb("Sent %i bytes over usart", len);
|
||||
#else
|
||||
|
@ -123,7 +123,7 @@ static int reply_ng_internal(uint16_t cmd, int16_t status, uint8_t *data, size_t
|
|||
// Send frame and make sure all bytes are transmitted
|
||||
|
||||
if (reply_via_fpc) {
|
||||
#ifdef WITH_FPC_HOST
|
||||
#ifdef WITH_FPC_USART_HOST
|
||||
result = usart_writebuffer_sync((uint8_t *)&txBufferNG, txBufferNGLen);
|
||||
// Dbprintf_usb("Sent %i bytes over usart", len);
|
||||
#else
|
||||
|
@ -225,7 +225,7 @@ int receive_ng(PacketCommandNG *rx) {
|
|||
if (usb_poll_validate_length())
|
||||
return receive_ng_internal(rx, usb_read_ng, false);
|
||||
|
||||
#ifdef WITH_FPC_HOST
|
||||
#ifdef WITH_FPC_USART_HOST
|
||||
// Check if there is a FPC packet available
|
||||
if (usart_rxdata_available() > 0)
|
||||
return receive_ng_internal(rx, usart_read_ng, true);
|
||||
|
|
|
@ -296,7 +296,7 @@ Empirically measured delay (FTDI cable) with "hw pingng 512" :
|
|||
9600 -> 1100..1150ms
|
||||
(client/comms.c)
|
||||
static size_t communication_delay(void) {
|
||||
if (conn.send_via_fpc) // needed also for Windows USB USART??
|
||||
if (conn.send_via_fpc_usart) // needed also for Windows USB USART??
|
||||
return 2 * (12000000 / uart_speed);
|
||||
return 100;
|
||||
}
|
||||
|
|
|
@ -144,8 +144,9 @@ typedef struct {
|
|||
// rdv4
|
||||
bool compiled_with_flash;
|
||||
bool compiled_with_smartcard;
|
||||
bool compiled_with_fpc;
|
||||
bool compiled_with_fpc_host;
|
||||
bool compiled_with_fpc_usart;
|
||||
bool compiled_with_fpc_usart_dev;
|
||||
bool compiled_with_fpc_usart_host;
|
||||
// lf
|
||||
bool compiled_with_lf;
|
||||
bool compiled_with_hitag;
|
||||
|
@ -165,7 +166,7 @@ typedef struct {
|
|||
bool hw_available_flash;
|
||||
bool hw_available_smartcard;
|
||||
// rdv4 bt addon
|
||||
bool hw_available_fpc_host;
|
||||
bool hw_available_fpc_usart_btaddon;
|
||||
} PACKED capabilities_t;
|
||||
|
||||
extern capabilities_t pm3_capabilities;
|
||||
|
@ -211,9 +212,10 @@ extern capabilities_t pm3_capabilities;
|
|||
#define CMD_SMART_SETBAUD 0x0144
|
||||
#define CMD_SMART_SETCLOCK 0x0145
|
||||
|
||||
// RDV40, FPC serial
|
||||
#define CMD_FPC_SEND 0x0160
|
||||
#define CMD_FPC_READ 0x0161
|
||||
// RDV40, FPC USART
|
||||
#define CMD_USART_RX 0x0160
|
||||
#define CMD_USART_TX 0x0161
|
||||
#define CMD_USART_TXRX 0x0162
|
||||
|
||||
// For low-frequency tags
|
||||
#define CMD_READ_TI_TYPE 0x0202
|
||||
|
@ -459,7 +461,7 @@ extern capabilities_t pm3_capabilities;
|
|||
// File error client: error related to file access on host
|
||||
#define PM3_EFILE -13
|
||||
|
||||
// No data pm3: reserved, no host frame available (not really an error)
|
||||
// No data pm3: no data available, no host frame available (not really an error)
|
||||
#define PM3_ENODATA -98
|
||||
// Quit program client: reserved, order to quit the program
|
||||
#define PM3_EFATAL -99
|
||||
|
|
Loading…
Reference in a new issue