mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 13:00:42 -07:00
an attempt to reduce some stack memory. No need for the debug printing to be 512 bytes. Now limited to 200 chars
This commit is contained in:
parent
6c42b723a8
commit
95d1d5646f
5 changed files with 22 additions and 15 deletions
|
@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
|
||||||
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
|
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
|
||||||
|
|
||||||
## [unreleased][unreleased]
|
## [unreleased][unreleased]
|
||||||
|
- Change `dbprint` on device side to use max 200 chars strings. (@iceman1001)
|
||||||
- Fixed bootloader to correctly clear bss segment on start. Fixes USB serial number sometimes not working in the bootloader (@nvx)
|
- Fixed bootloader to correctly clear bss segment on start. Fixes USB serial number sometimes not working in the bootloader (@nvx)
|
||||||
- Change `notes on downgrade attacks` - reworked the original text follow repo style (@iceman1001)
|
- Change `notes on downgrade attacks` - reworked the original text follow repo style (@iceman1001)
|
||||||
- Added `hf mf info` command and static encrypted nonce detection (@merlokk)
|
- Added `hf mf info` command and static encrypted nonce detection (@merlokk)
|
||||||
|
|
|
@ -328,9 +328,9 @@ uint8_t emlGet(uint8_t *out, uint32_t offset, uint32_t length) {
|
||||||
// get the address of the ToSend buffer. Allocate part of Bigbuf for it, if not yet done
|
// get the address of the ToSend buffer. Allocate part of Bigbuf for it, if not yet done
|
||||||
tosend_t *get_tosend(void) {
|
tosend_t *get_tosend(void) {
|
||||||
|
|
||||||
if (toSend.buf == NULL)
|
if (toSend.buf == NULL) {
|
||||||
toSend.buf = BigBuf_malloc(TOSEND_BUFFER_SIZE);
|
toSend.buf = BigBuf_malloc(TOSEND_BUFFER_SIZE);
|
||||||
|
}
|
||||||
return &toSend;
|
return &toSend;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2197,8 +2197,9 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||||
reply_ng(CMD_MEASURE_ANTENNA_TUNING_HF, PM3_SUCCESS, NULL, 0);
|
reply_ng(CMD_MEASURE_ANTENNA_TUNING_HF, PM3_SUCCESS, NULL, 0);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (button_status == BUTTON_SINGLE_CLICK)
|
if (button_status == BUTTON_SINGLE_CLICK) {
|
||||||
reply_ng(CMD_MEASURE_ANTENNA_TUNING_HF, PM3_EOPABORTED, NULL, 0);
|
reply_ng(CMD_MEASURE_ANTENNA_TUNING_HF, PM3_EOPABORTED, NULL, 0);
|
||||||
|
}
|
||||||
uint16_t volt = MeasureAntennaTuningHfData();
|
uint16_t volt = MeasureAntennaTuningHfData();
|
||||||
reply_ng(CMD_MEASURE_ANTENNA_TUNING_HF, PM3_SUCCESS, (uint8_t *)&volt, sizeof(volt));
|
reply_ng(CMD_MEASURE_ANTENNA_TUNING_HF, PM3_SUCCESS, (uint8_t *)&volt, sizeof(volt));
|
||||||
break;
|
break;
|
||||||
|
@ -2225,8 +2226,9 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||||
reply_ng(CMD_MEASURE_ANTENNA_TUNING_LF, PM3_SUCCESS, NULL, 0);
|
reply_ng(CMD_MEASURE_ANTENNA_TUNING_LF, PM3_SUCCESS, NULL, 0);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (button_status == BUTTON_SINGLE_CLICK)
|
if (button_status == BUTTON_SINGLE_CLICK) {
|
||||||
reply_ng(CMD_MEASURE_ANTENNA_TUNING_LF, PM3_EOPABORTED, NULL, 0);
|
reply_ng(CMD_MEASURE_ANTENNA_TUNING_LF, PM3_EOPABORTED, NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t volt = MeasureAntennaTuningLfData();
|
uint32_t volt = MeasureAntennaTuningLfData();
|
||||||
reply_ng(CMD_MEASURE_ANTENNA_TUNING_LF, PM3_SUCCESS, (uint8_t *)&volt, sizeof(volt));
|
reply_ng(CMD_MEASURE_ANTENNA_TUNING_LF, PM3_SUCCESS, (uint8_t *)&volt, sizeof(volt));
|
||||||
|
@ -2839,8 +2841,9 @@ void __attribute__((noreturn)) AppMain(void) {
|
||||||
WDT_HIT();
|
WDT_HIT();
|
||||||
|
|
||||||
if (*_stack_start != 0xdeadbeef) {
|
if (*_stack_start != 0xdeadbeef) {
|
||||||
Dbprintf("Stack overflow detected! Please increase stack size, currently %d bytes", (uint32_t)_stack_end - (uint32_t)_stack_start);
|
Dbprintf("DEBUG: increase stack size, currently " _YELLOW_("%d") " bytes", (uint32_t)_stack_end - (uint32_t)_stack_start);
|
||||||
Dbprintf("Unplug your device now.");
|
Dbprintf("Stack overflow detected");
|
||||||
|
Dbprintf("--> Unplug your device now! <--");
|
||||||
hf_field_off();
|
hf_field_off();
|
||||||
while (1);
|
while (1);
|
||||||
}
|
}
|
||||||
|
|
13
armsrc/cmd.c
13
armsrc/cmd.c
|
@ -18,6 +18,7 @@
|
||||||
#include "usart.h"
|
#include "usart.h"
|
||||||
#include "crc16.h"
|
#include "crc16.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
#include "BigBuf.h"
|
||||||
|
|
||||||
// Flags to tell where to add CRC on sent replies
|
// Flags to tell where to add CRC on sent replies
|
||||||
bool g_reply_with_crc_on_usb = false;
|
bool g_reply_with_crc_on_usb = false;
|
||||||
|
@ -29,8 +30,8 @@ bool g_reply_via_usb = false;
|
||||||
int reply_old(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, const void *data, size_t len) {
|
int reply_old(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, const void *data, size_t len) {
|
||||||
PacketResponseOLD txcmd = {CMD_UNKNOWN, {0, 0, 0}, {{0}}};
|
PacketResponseOLD txcmd = {CMD_UNKNOWN, {0, 0, 0}, {{0}}};
|
||||||
|
|
||||||
// for (size_t i = 0; i < sizeof(PacketResponseOLD); i++)
|
for (size_t i = 0; i < sizeof(PacketResponseOLD); i++)
|
||||||
// ((uint8_t *)&txcmd)[i] = 0x00;
|
((uint8_t *)&txcmd)[i] = 0x00;
|
||||||
|
|
||||||
// Compose the outgoing command frame
|
// Compose the outgoing command frame
|
||||||
txcmd.cmd = cmd;
|
txcmd.cmd = cmd;
|
||||||
|
@ -147,7 +148,8 @@ int reply_mix(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, const v
|
||||||
if (len && data)
|
if (len && data)
|
||||||
memcpy(cmddata + sizeof(arg), data, (int)len);
|
memcpy(cmddata + sizeof(arg), data, (int)len);
|
||||||
|
|
||||||
return reply_ng_internal((cmd & 0xFFFF), status, cmddata, len + sizeof(arg), false);
|
int res = reply_ng_internal((cmd & 0xFFFF), status, cmddata, len + sizeof(arg), false);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int receive_ng_internal(PacketCommandNG *rx, uint32_t read_ng(uint8_t *data, size_t len), bool usb, bool fpc) {
|
static int receive_ng_internal(PacketCommandNG *rx, uint32_t read_ng(uint8_t *data, size_t len), bool usb, bool fpc) {
|
||||||
|
@ -178,9 +180,10 @@ static int receive_ng_internal(PacketCommandNG *rx, uint32_t read_ng(uint8_t *da
|
||||||
memcpy(rx->data.asBytes, rx_raw.data, length);
|
memcpy(rx->data.asBytes, rx_raw.data, length);
|
||||||
rx->length = length;
|
rx->length = length;
|
||||||
} else {
|
} else {
|
||||||
uint64_t arg[3];
|
uint64_t arg[3] = {0};
|
||||||
if (length < sizeof(arg))
|
if (length < sizeof(arg)) {
|
||||||
return PM3_EIO;
|
return PM3_EIO;
|
||||||
|
}
|
||||||
|
|
||||||
memcpy(arg, rx_raw.data, sizeof(arg));
|
memcpy(arg, rx_raw.data, sizeof(arg));
|
||||||
rx->oldarg[0] = arg[0];
|
rx->oldarg[0] = arg[0];
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#include "printf.h"
|
#include "printf.h"
|
||||||
|
|
||||||
#define DEBUG 1
|
#define DEBUG 1
|
||||||
|
#define DEBUG_MAX_MSG_SIZE 200
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
// Debug print functions, to go out over USB, to the usual PC-side client.
|
// Debug print functions, to go out over USB, to the usual PC-side client.
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
@ -31,7 +31,7 @@ void DbpStringEx(uint32_t flags, const char *src, size_t srclen) {
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
struct {
|
struct {
|
||||||
uint16_t flag;
|
uint16_t flag;
|
||||||
uint8_t buf[PM3_CMD_DATA_SIZE - sizeof(uint16_t)];
|
uint8_t buf[DEBUG_MAX_MSG_SIZE];
|
||||||
} PACKED data;
|
} PACKED data;
|
||||||
data.flag = flags;
|
data.flag = flags;
|
||||||
uint16_t len = MIN(srclen, sizeof(data.buf));
|
uint16_t len = MIN(srclen, sizeof(data.buf));
|
||||||
|
@ -49,7 +49,7 @@ void DbpString(const char *str) {
|
||||||
void DbprintfEx(uint32_t flags, const char *fmt, ...) {
|
void DbprintfEx(uint32_t flags, const char *fmt, ...) {
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
// should probably limit size here; oh well, let's just use a big buffer
|
// should probably limit size here; oh well, let's just use a big buffer
|
||||||
char s[PM3_CMD_DATA_SIZE] = {0x00};
|
char s[DEBUG_MAX_MSG_SIZE] = {0x00};
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
kvsprintf(fmt, s, 10, ap);
|
kvsprintf(fmt, s, 10, ap);
|
||||||
|
@ -62,7 +62,7 @@ void DbprintfEx(uint32_t flags, const char *fmt, ...) {
|
||||||
void Dbprintf(const char *fmt, ...) {
|
void Dbprintf(const char *fmt, ...) {
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
// should probably limit size here; oh well, let's just use a big buffer
|
// should probably limit size here; oh well, let's just use a big buffer
|
||||||
char output_string[PM3_CMD_DATA_SIZE] = {0x00};
|
char output_string[DEBUG_MAX_MSG_SIZE] = {0x00};
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue