mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
FPC experiments: got so far TX_only, usart=115200 + usb=460800, see full commit msg
* Add \r\n to sent strings * remove usart_init() from UsbPacketReceive cmd, it's already init in main. * Add PLATFORM PM3RDV4FPC to ease dev * TX: US_TCR is len of data to send, not len of buffer * Use only one PDC bank as we're using it in sync * Busy loop to wait for end of TX as we'using it in sync * Change usart speed to 115200 * Don't downgrade USB speed, keep 460800 * Attempt to detect received data, fail so far
This commit is contained in:
parent
d448549524
commit
7bd95dd5c3
5 changed files with 29 additions and 37 deletions
|
@ -1105,30 +1105,32 @@ void UsbPacketReceived(uint8_t *packet, int len) {
|
|||
*/
|
||||
|
||||
|
||||
char dest[USB_CMD_DATA_SIZE] = { '\0' };
|
||||
static const char *welcome = "Proxmark3 Serial interface via FPC ready\n";
|
||||
strncat(dest, welcome, sizeof(dest) - strlen(dest) - 1);
|
||||
sprintf(dest + strlen(dest) - 1, "| bytes 0x%02x 0x%02x 0x%02x 0x%02x \n"
|
||||
char dest[USB_CMD_DATA_SIZE]={'\0'};
|
||||
sprintf(dest, usart_dataavailable() ? "DATA!\r\n" : "no data\r\n");
|
||||
cmd_send(CMD_DEBUG_PRINT_STRING, strlen(dest), 0, 0, dest, strlen(dest));
|
||||
|
||||
static const char *welcome = "Proxmark3 Serial interface via FPC ready\r\n";
|
||||
usart_writebuffer((uint8_t *)welcome, strlen(welcome));
|
||||
|
||||
sprintf(dest, "| bytes 0x%02x 0x%02x 0x%02x 0x%02x\r\n"
|
||||
, c->d.asBytes[0]
|
||||
, c->d.asBytes[1]
|
||||
, c->d.asBytes[2]
|
||||
, c->d.asBytes[3]
|
||||
);
|
||||
usart_writebuffer((uint8_t *)dest, strlen(dest));
|
||||
|
||||
UsbCommand txcmd = { CMD_DEBUG_PRINT_STRING, { strlen(dest), 0, 0 } };
|
||||
memcpy(txcmd.d.asBytes, dest, sizeof(dest));
|
||||
|
||||
LED_A_ON();
|
||||
|
||||
usart_init();
|
||||
usart_writebuffer((uint8_t *)&txcmd, sizeof(UsbCommand));
|
||||
|
||||
//usb
|
||||
cmd_send(CMD_DEBUG_PRINT_STRING, strlen(dest), 0, 0, dest, strlen(dest));
|
||||
|
||||
sprintf(dest, usart_dataavailable() ? "DATA!\r\n" : "no data\r\n");
|
||||
cmd_send(CMD_DEBUG_PRINT_STRING, strlen(dest), 0, 0, dest, strlen(dest));
|
||||
LED_A_OFF();
|
||||
|
||||
|
||||
/*
|
||||
/*
|
||||
uint8_t my_rx[sizeof(UsbCommand)];
|
||||
while (!BUTTON_PRESS() && !usb_poll_validate_length()) {
|
||||
LED_B_INV();
|
||||
|
@ -1136,13 +1138,12 @@ void UsbPacketReceived(uint8_t *packet, int len) {
|
|||
//UsbPacketReceived(my_rx, sizeof(my_rx));
|
||||
|
||||
UsbCommand *my = (UsbCommand *)my_rx;
|
||||
if (mc->cmd > 0 ) {
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
*/
|
||||
//cmd_send(CMD_DEBUG_PRINT_STRING, strlen(dest), 0, 0, dest, strlen(dest));
|
||||
|
||||
cmd_send(CMD_ACK, 0, 0, 0, 0, 0);
|
||||
|
|
|
@ -5,6 +5,8 @@ define KNOWN_PLATFORMS
|
|||
+--------------------------------------------------------+
|
||||
| PM3RDV4 (def) | Proxmark3 rdv4 with AT91SAM7S512 |
|
||||
+--------------------------------------------------------+
|
||||
| PM3RDV4FPC | Proxmark3 rdv4+FPC (experimental) |
|
||||
+--------------------------------------------------------+
|
||||
| PM3EVO | Proxmark3 EVO with AT91SAM7S512 |
|
||||
+--------------------------------------------------------+
|
||||
| PM3EASY | Proxmark3 rdv3 Easy with AT91SAM7S256 |
|
||||
|
@ -31,6 +33,10 @@ 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
|
||||
PLTNAME = Proxmark3 rdv4
|
||||
else ifeq ($(PLATFORM),PM3EVO)
|
||||
MCU = AT91SAM7S512
|
||||
PLTNAME = Proxmark3 EVO
|
||||
|
|
|
@ -66,27 +66,20 @@ inline int16_t usart_readbuffer(uint8_t *data, size_t len) {
|
|||
}
|
||||
}
|
||||
|
||||
inline bool usart_dataavailable(void) {
|
||||
return (pUS1->US_CSR & AT91C_US_RXRDY) != 0;
|
||||
}
|
||||
|
||||
// transfer from device to client
|
||||
inline int16_t usart_writebuffer(uint8_t *data, size_t len) {
|
||||
|
||||
// Check if the first PDC bank is free
|
||||
if (!(pUS1->US_TCR)) {
|
||||
if (pUS1->US_TCR == 0) {
|
||||
memcpy(us_outbuf, data, len);
|
||||
pUS1->US_TPR = (uint32_t)us_outbuf;
|
||||
pUS1->US_TCR = sizeof(us_outbuf);
|
||||
pUS1->US_TCR = len;
|
||||
|
||||
pUS1->US_PTCR = AT91C_PDC_TXTEN | AT91C_PDC_RXTDIS;
|
||||
while((pUS1->US_CSR & AT91C_US_TXEMPTY) ==0) {};
|
||||
return 2;
|
||||
}
|
||||
// Check if the second PDC bank is free
|
||||
else if (!(pUS1->US_TNCR)) {
|
||||
memcpy(us_outbuf, data, len);
|
||||
pUS1->US_TNPR = (uint32_t)us_outbuf;
|
||||
pUS1->US_TNCR = sizeof(us_outbuf);
|
||||
|
||||
pUS1->US_PTCR = AT91C_PDC_TXTEN | AT91C_PDC_RXTDIS;
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
@ -130,7 +123,7 @@ void usart_init(void) {
|
|||
// 115200 * 16 == 1843200
|
||||
//
|
||||
//pUS1->US_BRGR = (48UL*1000*1000) / (9600*16);
|
||||
pUS1->US_BRGR = 48054841 / (9600 << 4);
|
||||
pUS1->US_BRGR = 48054841 / (115200 << 4);
|
||||
|
||||
// Write the Timeguard Register
|
||||
pUS1->US_TTGR = 0;
|
||||
|
|
|
@ -9,4 +9,5 @@ void usart_close(void);
|
|||
|
||||
int16_t usart_readbuffer(uint8_t *data, size_t len);
|
||||
int16_t usart_writebuffer(uint8_t *data, size_t len);
|
||||
bool usart_dataavailable(void);
|
||||
#endif
|
||||
|
|
|
@ -194,14 +194,6 @@ serial_port uart_open(const char *pcPortName) {
|
|||
// Flush all lingering data that may exist
|
||||
tcflush(sp->fd, TCIOFLUSH);
|
||||
|
||||
#ifdef WITH_FPC
|
||||
if (uart_set_speed(sp, 115200)) {
|
||||
printf("[=] UART Setting serial baudrate 115200 [FPC enabled]\n");
|
||||
} else {
|
||||
uart_set_speed(sp, 9600);
|
||||
printf("[=] UART Setting serial baudrate 9600 [FPC enabled]\n");
|
||||
}
|
||||
#else
|
||||
// set speed, works for UBUNTU 14.04
|
||||
bool success = uart_set_speed(sp, 460800);
|
||||
if (success) {
|
||||
|
@ -210,7 +202,6 @@ serial_port uart_open(const char *pcPortName) {
|
|||
uart_set_speed(sp, 115200);
|
||||
printf("[=] UART Setting serial baudrate 115200\n");
|
||||
}
|
||||
#endif
|
||||
return sp;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue