mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-14 18:48:13 -07:00
Fix multiple issues with reported flash memory usage:
- Remove unused next_free_memory=BigBuf_get_addr() - Fix size retrieval of compressed data section by chance the corrupted value was > than correct value so decompression was taking place, but was returning an error instead of the decompressed size - Fix reporting of compressed size into common_area returned value of LZ4_decompress_safe is the decompressed size while we needed to report the compressed size - Fix common_area late initialization common_area was initialized (and zeroed) after uncompress_data_section() had reported the compressed size in common_area, so compressed size was erased Compressed size is used in the computation of the used and available flash memory, which is now correct (it was wrongly telling about 6kb were free while they weren't).
This commit is contained in:
parent
e149dc4ad2
commit
e750481d12
2 changed files with 11 additions and 12 deletions
|
@ -2299,14 +2299,6 @@ void __attribute__((noreturn)) AppMain(void) {
|
|||
*p = 0xdeadbeef;
|
||||
}
|
||||
|
||||
if (common_area.magic != COMMON_AREA_MAGIC || common_area.version != 1) {
|
||||
/* Initialize common area */
|
||||
memset(&common_area, 0, sizeof(common_area));
|
||||
common_area.magic = COMMON_AREA_MAGIC;
|
||||
common_area.version = 1;
|
||||
}
|
||||
common_area.flags.osimage_present = 1;
|
||||
|
||||
LEDsoff();
|
||||
|
||||
// The FPGA gets its clock from us from PCK0 output, so set that up.
|
||||
|
|
|
@ -18,14 +18,13 @@
|
|||
#include "BigBuf.h"
|
||||
#include "string.h"
|
||||
|
||||
static uint8_t *next_free_memory;
|
||||
extern struct common_area common_area;
|
||||
extern char __data_src_start__, __data_start__, __data_end__, __bss_start__, __bss_end__;
|
||||
|
||||
|
||||
static void uncompress_data_section(void) {
|
||||
next_free_memory = BigBuf_get_addr();
|
||||
int avail_in;
|
||||
memcpy(&avail_in, &__data_start__, sizeof(int));
|
||||
memcpy(&avail_in, &__data_src_start__, sizeof(int));
|
||||
int avail_out = &__data_end__ - &__data_start__; // uncompressed size. Correct.
|
||||
// uncompress data segment to RAM
|
||||
uintptr_t p = (uintptr_t)&__data_src_start__;
|
||||
|
@ -34,13 +33,21 @@ static void uncompress_data_section(void) {
|
|||
if (res < 0)
|
||||
return;
|
||||
// save the size of the compressed data section
|
||||
common_area.arg1 = res;
|
||||
common_area.arg1 = avail_in;
|
||||
}
|
||||
|
||||
void __attribute__((section(".startos"))) Vector(void);
|
||||
void Vector(void) {
|
||||
/* Stack should have been set up by the bootloader */
|
||||
|
||||
if (common_area.magic != COMMON_AREA_MAGIC || common_area.version != 1) {
|
||||
/* Initialize common area */
|
||||
memset(&common_area, 0, sizeof(common_area));
|
||||
common_area.magic = COMMON_AREA_MAGIC;
|
||||
common_area.version = 1;
|
||||
}
|
||||
common_area.flags.osimage_present = 1;
|
||||
|
||||
uncompress_data_section();
|
||||
|
||||
/* Set up (that is: clear) BSS. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue