mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -07:00
Merge branch 'master' of https://github.com/RfidResearchGroup/proxmark3
This commit is contained in:
commit
62f1c82fda
8 changed files with 95 additions and 21 deletions
|
@ -1136,7 +1136,7 @@ void UsbPacketReceived(uint8_t *packet, int len) {
|
||||||
uint8_t my_rx[sizeof(UsbCommand)];
|
uint8_t my_rx[sizeof(UsbCommand)];
|
||||||
while (!BUTTON_PRESS() && !usb_poll_validate_length()) {
|
while (!BUTTON_PRESS() && !usb_poll_validate_length()) {
|
||||||
LED_B_INV();
|
LED_B_INV();
|
||||||
if (usart_readbuffer(my_rx, sizeof(UsbCommand)) ) {
|
if (usart_readbuffer(my_rx) ) {
|
||||||
//UsbPacketReceived(my_rx, sizeof(my_rx));
|
//UsbPacketReceived(my_rx, sizeof(my_rx));
|
||||||
|
|
||||||
UsbCommand *my = (UsbCommand *)my_rx;
|
UsbCommand *my = (UsbCommand *)my_rx;
|
||||||
|
@ -1565,10 +1565,11 @@ void __attribute__((noreturn)) AppMain(void) {
|
||||||
}
|
}
|
||||||
#ifdef WITH_FPC_HOST
|
#ifdef WITH_FPC_HOST
|
||||||
// Check if there is a FPC packet available
|
// Check if there is a FPC packet available
|
||||||
if (usart_readcommand(rx) > 0) {
|
if (usart_readbuffer(rx)) {
|
||||||
reply_via_fpc = 1;
|
reply_via_fpc = 1;
|
||||||
UsbPacketReceived(rx, sizeof(rx));
|
UsbPacketReceived(rx, sizeof(rx));
|
||||||
}
|
}
|
||||||
|
usart_readcheck(rx, sizeof(rx));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Press button for one second to enter a possible standalone mode
|
// Press button for one second to enter a possible standalone mode
|
||||||
|
|
|
@ -449,6 +449,9 @@ void FpgaWriteConfWord(uint8_t v) {
|
||||||
// the samples from the ADC always flow through the FPGA.
|
// the samples from the ADC always flow through the FPGA.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void SetAdcMuxFor(uint32_t whichGpio) {
|
void SetAdcMuxFor(uint32_t whichGpio) {
|
||||||
|
|
||||||
|
#ifndef WITH_FPC
|
||||||
|
// When compiled without FPC support
|
||||||
AT91C_BASE_PIOA->PIO_OER =
|
AT91C_BASE_PIOA->PIO_OER =
|
||||||
GPIO_MUXSEL_HIPKD |
|
GPIO_MUXSEL_HIPKD |
|
||||||
GPIO_MUXSEL_LOPKD |
|
GPIO_MUXSEL_LOPKD |
|
||||||
|
@ -463,9 +466,15 @@ void SetAdcMuxFor(uint32_t whichGpio) {
|
||||||
|
|
||||||
LOW(GPIO_MUXSEL_HIPKD);
|
LOW(GPIO_MUXSEL_HIPKD);
|
||||||
LOW(GPIO_MUXSEL_LOPKD);
|
LOW(GPIO_MUXSEL_LOPKD);
|
||||||
#ifndef WITH_FPC
|
|
||||||
LOW(GPIO_MUXSEL_HIRAW);
|
LOW(GPIO_MUXSEL_HIRAW);
|
||||||
LOW(GPIO_MUXSEL_LORAW);
|
LOW(GPIO_MUXSEL_LORAW);
|
||||||
|
|
||||||
|
#else
|
||||||
|
// FPC serial 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);
|
||||||
|
LOW(GPIO_MUXSEL_LOPKD);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
HIGH(whichGpio);
|
HIGH(whichGpio);
|
||||||
|
|
|
@ -1314,12 +1314,12 @@ static int CmdRawDemod(const char *Cmd) {
|
||||||
|
|
||||||
str_lower((char *)Cmd);
|
str_lower((char *)Cmd);
|
||||||
|
|
||||||
if (str_startswith(Cmd, "fs")) ans = CmdFSKrawdemod(Cmd + 2);
|
if (str_startswith(Cmd, "fs") || Cmd[0] == 'f' ) ans = CmdFSKrawdemod(Cmd+2);
|
||||||
else if (str_startswith(Cmd, "ab")) ans = Cmdaskbiphdemod(Cmd + 2);
|
else if (str_startswith(Cmd, "ab")) ans = Cmdaskbiphdemod(Cmd + 2);
|
||||||
else if (str_startswith(Cmd, "am")) ans = Cmdaskmandemod(Cmd + 2);
|
else if (str_startswith(Cmd, "am")) ans = Cmdaskmandemod(Cmd + 2);
|
||||||
else if (str_startswith(Cmd, "ar")) ans = Cmdaskrawdemod(Cmd + 2);
|
else if (str_startswith(Cmd, "ar")) ans = Cmdaskrawdemod(Cmd + 2);
|
||||||
else if (str_startswith(Cmd, "nr")) ans = CmdNRZrawDemod(Cmd + 2);
|
else if (str_startswith(Cmd, "nr") || Cmd[0] == 'n') ans = CmdNRZrawDemod(Cmd+2);
|
||||||
else if (str_startswith(Cmd, "p1")) ans = CmdPSK1rawDemod(Cmd + 2);
|
else if (str_startswith(Cmd, "p1") || Cmd[0] == 'p') ans = CmdPSK1rawDemod(Cmd + 2);
|
||||||
else if (str_startswith(Cmd, "p2")) ans = CmdPSK2rawDemod(Cmd + 2);
|
else if (str_startswith(Cmd, "p2")) ans = CmdPSK2rawDemod(Cmd + 2);
|
||||||
else PrintAndLogEx(WARNING, "Unknown modulation entered - see help ('h') for parameter structure");
|
else PrintAndLogEx(WARNING, "Unknown modulation entered - see help ('h') for parameter structure");
|
||||||
|
|
||||||
|
|
|
@ -189,9 +189,6 @@ int CmdLFCommandRead(const char *Cmd) {
|
||||||
int CmdFlexdemod(const char *Cmd) {
|
int CmdFlexdemod(const char *Cmd) {
|
||||||
(void)Cmd; // Cmd is not used so far
|
(void)Cmd; // Cmd is not used so far
|
||||||
|
|
||||||
if (GraphTraceLen < 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
#ifndef LONG_WAIT
|
#ifndef LONG_WAIT
|
||||||
#define LONG_WAIT 100
|
#define LONG_WAIT 100
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -276,9 +276,11 @@ QColor Plot::getColor(int graphNum) {
|
||||||
|
|
||||||
void Plot::setMaxAndStart(int *buffer, size_t len, QRect plotRect) {
|
void Plot::setMaxAndStart(int *buffer, size_t len, QRect plotRect) {
|
||||||
if (len == 0) return;
|
if (len == 0) return;
|
||||||
startMax = (len - (int)((plotRect.right() - plotRect.left() - 40) / GraphPixelsPerPoint));
|
startMax = 0;
|
||||||
if (startMax < 0) {
|
if (plotRect.right() >= plotRect.left() + 40) {
|
||||||
startMax = 0;
|
uint32_t t = (plotRect.right() - plotRect.left() - 40) / GraphPixelsPerPoint;
|
||||||
|
if (len >= t)
|
||||||
|
startMax = len - t;
|
||||||
}
|
}
|
||||||
if (GraphStart > startMax) {
|
if (GraphStart > startMax) {
|
||||||
GraphStart = startMax;
|
GraphStart = startMax;
|
||||||
|
@ -470,9 +472,6 @@ void Plot::paintEvent(QPaintEvent *event) {
|
||||||
|
|
||||||
painter.setFont(QFont("Courier New", 10));
|
painter.setFont(QFont("Courier New", 10));
|
||||||
|
|
||||||
if (GraphStart < 0)
|
|
||||||
GraphStart = 0;
|
|
||||||
|
|
||||||
if (CursorAPos > GraphTraceLen)
|
if (CursorAPos > GraphTraceLen)
|
||||||
CursorAPos = 0;
|
CursorAPos = 0;
|
||||||
if (CursorBPos > GraphTraceLen)
|
if (CursorBPos > GraphTraceLen)
|
||||||
|
|
|
@ -364,8 +364,13 @@ int main(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// default speed for USB 460800, USART(FPC serial) 115200 baud
|
||||||
if (speed == 0)
|
if (speed == 0)
|
||||||
|
#ifdef WITH_FPC
|
||||||
|
speed = 115200;
|
||||||
|
#else
|
||||||
speed = 460800;
|
speed = 460800;
|
||||||
|
#endif
|
||||||
|
|
||||||
// If the user passed the filename of the 'script' to execute, get it from last parameter
|
// If the user passed the filename of the 'script' to execute, get it from last parameter
|
||||||
if (lastarg) {
|
if (lastarg) {
|
||||||
|
|
|
@ -42,7 +42,7 @@ void usart_close(void) {
|
||||||
|
|
||||||
static uint8_t us_inbuf[sizeof(UsbCommand)];
|
static uint8_t us_inbuf[sizeof(UsbCommand)];
|
||||||
static uint8_t us_outbuf[sizeof(UsbCommand)];
|
static uint8_t us_outbuf[sizeof(UsbCommand)];
|
||||||
|
/*
|
||||||
// transfer from client to device
|
// transfer from client to device
|
||||||
inline int16_t usart_readbuffer(uint8_t *data) {
|
inline int16_t usart_readbuffer(uint8_t *data) {
|
||||||
uint32_t rcr = pUS1->US_RCR;
|
uint32_t rcr = pUS1->US_RCR;
|
||||||
|
@ -58,6 +58,38 @@ inline int16_t usart_readbuffer(uint8_t *data) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
uint8_t check = 0;
|
||||||
|
inline int16_t usart_readbuffer(uint8_t *data) {
|
||||||
|
// Check if the first PDC bank is free
|
||||||
|
if (pUS1->US_RCR == 0) {
|
||||||
|
pUS1->US_RPR = (uint32_t)data;
|
||||||
|
pUS1->US_RCR = sizeof(UsbCommand);
|
||||||
|
pUS1->US_PTCR = AT91C_PDC_RXTEN | AT91C_PDC_TXTEN;
|
||||||
|
check = 0;
|
||||||
|
return 2;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void usart_readcheck(uint8_t *data,size_t len) {
|
||||||
|
if (pUS1->US_RCR<len){
|
||||||
|
if (check == 0){
|
||||||
|
StartCountUS();
|
||||||
|
check = 1;
|
||||||
|
}
|
||||||
|
//300ms
|
||||||
|
if (GetCountUS() > 300000){
|
||||||
|
pUS1->US_RPR = (uint32_t)data;
|
||||||
|
pUS1->US_RCR = len;
|
||||||
|
check = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
check = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
inline bool usart_dataavailable(void) {
|
inline bool usart_dataavailable(void) {
|
||||||
return pUS1->US_RCR < sizeof(us_inbuf);
|
return pUS1->US_RCR < sizeof(us_inbuf);
|
||||||
|
@ -66,14 +98,14 @@ inline bool usart_dataavailable(void) {
|
||||||
inline int16_t usart_readcommand(uint8_t *data) {
|
inline int16_t usart_readcommand(uint8_t *data) {
|
||||||
if (pUS1->US_RCR == 0)
|
if (pUS1->US_RCR == 0)
|
||||||
return usart_readbuffer(data);
|
return usart_readbuffer(data);
|
||||||
else
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool usart_commandavailable(void) {
|
inline bool usart_commandavailable(void) {
|
||||||
return pUS1->US_RCR == 0;
|
return (pUS1->US_RCR == 0);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
// transfer from device to client
|
// transfer from device to client
|
||||||
inline int16_t usart_writebuffer(uint8_t *data, size_t len) {
|
inline int16_t usart_writebuffer(uint8_t *data, size_t len) {
|
||||||
|
|
||||||
|
@ -90,6 +122,31 @@ inline int16_t usart_writebuffer(uint8_t *data, size_t len) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
// transfer from device to client
|
||||||
|
inline int16_t usart_writebuffer(uint8_t *data, size_t len) {
|
||||||
|
|
||||||
|
while (pUS1->US_TCR && pUS1->US_TNCR) {};
|
||||||
|
|
||||||
|
// Check if the first PDC bank is free
|
||||||
|
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_PTCR = AT91C_PDC_TXTEN | AT91C_PDC_RXTEN;
|
||||||
|
}
|
||||||
|
// Check if the second PDC bank is free
|
||||||
|
else if (pUS1->US_TNCR == 0) {
|
||||||
|
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_RXTEN;
|
||||||
|
}
|
||||||
|
//wait until finishing transfer
|
||||||
|
while (pUS1->US_TCR && pUS1->US_TNCR) {};
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void usart_init(void) {
|
void usart_init(void) {
|
||||||
|
@ -141,11 +198,12 @@ void usart_init(void) {
|
||||||
pUS1->US_RNPR = (uint32_t)0;
|
pUS1->US_RNPR = (uint32_t)0;
|
||||||
pUS1->US_RNCR = 0;
|
pUS1->US_RNCR = 0;
|
||||||
|
|
||||||
|
|
||||||
// re-enable receiver / transmitter
|
// re-enable receiver / transmitter
|
||||||
pUS1->US_CR = (AT91C_US_RXEN | AT91C_US_TXEN);
|
pUS1->US_CR = (AT91C_US_RXEN | AT91C_US_TXEN);
|
||||||
|
|
||||||
// ready to receive
|
// ready to receive
|
||||||
pUS1->US_RPR = (uint32_t)us_inbuf;
|
pUS1->US_RPR = (uint32_t)us_inbuf;
|
||||||
pUS1->US_RCR = sizeof(us_inbuf);
|
pUS1->US_RCR = 0;
|
||||||
|
pUS1->US_RNCR = 0;
|
||||||
pUS1->US_PTCR = AT91C_PDC_RXTEN;
|
pUS1->US_PTCR = AT91C_PDC_RXTEN;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include "proxmark3.h"
|
#include "proxmark3.h"
|
||||||
|
#include "../armsrc/ticks.h" // startcountus
|
||||||
|
|
||||||
|
#define AT91_BAUD_RATE 115200
|
||||||
|
|
||||||
void usart_init(void);
|
void usart_init(void);
|
||||||
void usart_close(void);
|
void usart_close(void);
|
||||||
|
@ -11,5 +14,7 @@ int16_t usart_readbuffer(uint8_t *data);
|
||||||
int16_t usart_writebuffer(uint8_t *data, size_t len);
|
int16_t usart_writebuffer(uint8_t *data, size_t len);
|
||||||
bool usart_dataavailable(void);
|
bool usart_dataavailable(void);
|
||||||
int16_t usart_readcommand(uint8_t *data);
|
int16_t usart_readcommand(uint8_t *data);
|
||||||
|
void usart_readcheck(uint8_t *data,size_t len);
|
||||||
|
|
||||||
bool usart_commandavailable(void);
|
bool usart_commandavailable(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue