mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 05:13:46 -07:00
Add support for client getting bigbufsize
This commit is contained in:
parent
df4bdc89ea
commit
c11c7ab545
5 changed files with 20 additions and 9 deletions
|
@ -392,6 +392,7 @@ static void SendCapabilities(void) {
|
||||||
capabilities.version = CAPABILITIES_VERSION;
|
capabilities.version = CAPABILITIES_VERSION;
|
||||||
capabilities.via_fpc = g_reply_via_fpc;
|
capabilities.via_fpc = g_reply_via_fpc;
|
||||||
capabilities.via_usb = g_reply_via_usb;
|
capabilities.via_usb = g_reply_via_usb;
|
||||||
|
capabilities.bigbuf_size = BigBuf_get_size();
|
||||||
capabilities.baudrate = 0; // no real baudrate for USB-CDC
|
capabilities.baudrate = 0; // no real baudrate for USB-CDC
|
||||||
#ifdef WITH_FPC_USART
|
#ifdef WITH_FPC_USART
|
||||||
if (g_reply_via_fpc)
|
if (g_reply_via_fpc)
|
||||||
|
@ -2051,11 +2052,15 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern uint32_t _stack_start;
|
||||||
|
|
||||||
void __attribute__((noreturn)) AppMain(void) {
|
void __attribute__((noreturn)) AppMain(void) {
|
||||||
|
|
||||||
SpinDelay(100);
|
SpinDelay(100);
|
||||||
BigBuf_initialize();
|
BigBuf_initialize();
|
||||||
|
|
||||||
|
_stack_start = 0xdeadbeef;
|
||||||
|
|
||||||
if (common_area.magic != COMMON_AREA_MAGIC || common_area.version != 1) {
|
if (common_area.magic != COMMON_AREA_MAGIC || common_area.version != 1) {
|
||||||
/* Initialize common area */
|
/* Initialize common area */
|
||||||
memset(&common_area, 0, sizeof(common_area));
|
memset(&common_area, 0, sizeof(common_area));
|
||||||
|
@ -2121,6 +2126,10 @@ void __attribute__((noreturn)) AppMain(void) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
WDT_HIT();
|
WDT_HIT();
|
||||||
|
|
||||||
|
if (_stack_start != 0xdeadbeef) {
|
||||||
|
Dbprintf("Stack overflow detected! Please increase stack size.");
|
||||||
|
}
|
||||||
|
|
||||||
// Check if there is a packet available
|
// Check if there is a packet available
|
||||||
PacketCommandNG rx;
|
PacketCommandNG rx;
|
||||||
memset(&rx.data, 0, sizeof(rx.data));
|
memset(&rx.data, 0, sizeof(rx.data));
|
||||||
|
|
|
@ -567,7 +567,7 @@ int ASKDemod_ext(const char *Cmd, bool verbose, bool emSearch, uint8_t askType,
|
||||||
|
|
||||||
sscanf(Cmd, "%i %i %i %zu %c", &clk, &invert, &maxErr, &maxLen, &);
|
sscanf(Cmd, "%i %i %i %zu %c", &clk, &invert, &maxErr, &maxLen, &);
|
||||||
|
|
||||||
if (!maxLen) maxLen = BIGBUF_SIZE;
|
if (!maxLen) maxLen = pm3_capabilities.bigbuf_size;
|
||||||
|
|
||||||
if (invert != 0 && invert != 1) {
|
if (invert != 0 && invert != 1) {
|
||||||
PrintAndLogEx(WARNING, "Invalid argument: %s", Cmd);
|
PrintAndLogEx(WARNING, "Invalid argument: %s", Cmd);
|
||||||
|
@ -1517,16 +1517,18 @@ static int CmdHexsamples(const char *Cmd) {
|
||||||
uint32_t offset = 0;
|
uint32_t offset = 0;
|
||||||
char string_buf[25];
|
char string_buf[25];
|
||||||
char *string_ptr = string_buf;
|
char *string_ptr = string_buf;
|
||||||
uint8_t got[BIGBUF_SIZE];
|
uint8_t got[512*1024];
|
||||||
|
|
||||||
sscanf(Cmd, "%u %u", &requested, &offset);
|
sscanf(Cmd, "%u %u", &requested, &offset);
|
||||||
|
|
||||||
/* if no args send something */
|
/* if no args send something */
|
||||||
if (requested == 0)
|
if (requested == 0)
|
||||||
requested = 8;
|
requested = 8;
|
||||||
|
if (requested > pm3_capabilities.bigbuf_size)
|
||||||
|
requested = pm3_capabilities.bigbuf_size;
|
||||||
|
|
||||||
if (offset + requested > sizeof(got)) {
|
if (offset + requested > sizeof(got)) {
|
||||||
PrintAndLogEx(NORMAL, "Tried to read past end of buffer, <bytes> + <offset> > %d", BIGBUF_SIZE);
|
PrintAndLogEx(NORMAL, "Tried to read past end of buffer, <bytes> + <offset> > %d", pm3_capabilities.bigbuf_size);
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1595,10 +1597,10 @@ int getSamples(uint32_t n, bool verbose) {
|
||||||
// we don't have to worry about remaining trash
|
// we don't have to worry about remaining trash
|
||||||
// in the last byte in case the bits-per-sample
|
// in the last byte in case the bits-per-sample
|
||||||
// does not line up on byte boundaries
|
// does not line up on byte boundaries
|
||||||
uint8_t got[BIGBUF_SIZE - 1] = { 0 };
|
uint8_t got[512*1024] = { 0 };
|
||||||
|
|
||||||
if (n == 0 || n > sizeof(got))
|
if (n == 0 || n > pm3_capabilities.bigbuf_size)
|
||||||
n = sizeof(got);
|
n = pm3_capabilities.bigbuf_size;
|
||||||
|
|
||||||
if (verbose) PrintAndLogEx(INFO, "Reading " _YELLOW_("%u") " bytes from device memory", n);
|
if (verbose) PrintAndLogEx(INFO, "Reading " _YELLOW_("%u") " bytes from device memory", n);
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,6 @@ int AskEdgeDetect(const int *in, int *out, int len, int threshold);
|
||||||
int demodIdteck(void);
|
int demodIdteck(void);
|
||||||
|
|
||||||
#define MAX_DEMOD_BUF_LEN (1024*128)
|
#define MAX_DEMOD_BUF_LEN (1024*128)
|
||||||
#define BIGBUF_SIZE 40000
|
|
||||||
extern uint8_t DemodBuffer[MAX_DEMOD_BUF_LEN];
|
extern uint8_t DemodBuffer[MAX_DEMOD_BUF_LEN];
|
||||||
extern size_t DemodBufferLen;
|
extern size_t DemodBufferLen;
|
||||||
|
|
||||||
|
|
|
@ -2837,7 +2837,7 @@ static int CmdResetRead(const char *Cmd) {
|
||||||
|
|
||||||
if (resp.status == PM3_SUCCESS) {
|
if (resp.status == PM3_SUCCESS) {
|
||||||
|
|
||||||
uint16_t gotsize = BIGBUF_SIZE - 1;
|
uint16_t gotsize = pm3_capabilities.bigbuf_size - 1;
|
||||||
uint8_t *got = calloc(gotsize, sizeof(uint8_t));
|
uint8_t *got = calloc(gotsize, sizeof(uint8_t));
|
||||||
if (got == NULL) {
|
if (got == NULL) {
|
||||||
PrintAndLogEx(WARNING, "failed to allocate memory");
|
PrintAndLogEx(WARNING, "failed to allocate memory");
|
||||||
|
|
|
@ -175,6 +175,7 @@ typedef struct {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t version;
|
uint8_t version;
|
||||||
uint32_t baudrate;
|
uint32_t baudrate;
|
||||||
|
uint32_t bigbuf_size;
|
||||||
bool via_fpc : 1;
|
bool via_fpc : 1;
|
||||||
bool via_usb : 1;
|
bool via_usb : 1;
|
||||||
// rdv4
|
// rdv4
|
||||||
|
@ -203,7 +204,7 @@ typedef struct {
|
||||||
bool hw_available_flash : 1;
|
bool hw_available_flash : 1;
|
||||||
bool hw_available_smartcard : 1;
|
bool hw_available_smartcard : 1;
|
||||||
} PACKED capabilities_t;
|
} PACKED capabilities_t;
|
||||||
#define CAPABILITIES_VERSION 4
|
#define CAPABILITIES_VERSION 5
|
||||||
extern capabilities_t pm3_capabilities;
|
extern capabilities_t pm3_capabilities;
|
||||||
|
|
||||||
// For CMD_LF_T55XX_WRITEBL
|
// For CMD_LF_T55XX_WRITEBL
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue