mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 22:03:42 -07:00
Merge pull request #1765 from mwalker33/spiffs
Prep spiffs for bigger data files
This commit is contained in:
commit
429139f174
6 changed files with 56 additions and 14 deletions
|
@ -3,6 +3,8 @@ 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]
|
||||||
|
- Changed spiffs write/apped to send in 8192 chucks to ensure its eraised (@mwalker)
|
||||||
|
- Fixed spiffs dump to ensure to fails correctly if no big_buff was allocated (@mwalker)
|
||||||
- Change Client Makefile to respect global flags (@blshkv)
|
- Change Client Makefile to respect global flags (@blshkv)
|
||||||
- Change Makefile, honors global CC values (@blshkv)
|
- Change Makefile, honors global CC values (@blshkv)
|
||||||
- Fixed bad memory handling in MifareSim device side (@iceman1001)
|
- Fixed bad memory handling in MifareSim device side (@iceman1001)
|
||||||
|
|
|
@ -2166,8 +2166,12 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||||
uint32_t size = packet->oldarg[1];
|
uint32_t size = packet->oldarg[1];
|
||||||
|
|
||||||
uint8_t *buff = BigBuf_malloc(size);
|
uint8_t *buff = BigBuf_malloc(size);
|
||||||
|
if (buff == NULL) {
|
||||||
|
if (g_dbglevel >= DBG_DEBUG) Dbprintf ("Could not allocate buffer");
|
||||||
|
// Trigger a finish downloading signal with an PM3_EMALLOC
|
||||||
|
reply_ng(CMD_SPIFFS_DOWNLOAD, PM3_EMALLOC, NULL, 0);
|
||||||
|
} else {
|
||||||
rdv40_spiffs_read_as_filetype((char *)filename, (uint8_t *)buff, size, RDV40_SPIFFS_SAFETY_SAFE);
|
rdv40_spiffs_read_as_filetype((char *)filename, (uint8_t *)buff, size, RDV40_SPIFFS_SAFETY_SAFE);
|
||||||
|
|
||||||
// arg0 = filename
|
// arg0 = filename
|
||||||
// arg1 = size
|
// arg1 = size
|
||||||
// arg2 = RFU
|
// arg2 = RFU
|
||||||
|
@ -2180,6 +2184,8 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||||
}
|
}
|
||||||
// Trigger a finish downloading signal with an ACK frame
|
// Trigger a finish downloading signal with an ACK frame
|
||||||
reply_ng(CMD_SPIFFS_DOWNLOAD, PM3_SUCCESS, NULL, 0);
|
reply_ng(CMD_SPIFFS_DOWNLOAD, PM3_SUCCESS, NULL, 0);
|
||||||
|
BigBuf_free ();
|
||||||
|
}
|
||||||
LED_B_OFF();
|
LED_B_OFF();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "ticks.h"
|
#include "ticks.h"
|
||||||
#include "dbprint.h"
|
#include "dbprint.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
#include "spiffs.h"
|
||||||
|
|
||||||
/* here: use NCPS2 @ PA10: */
|
/* here: use NCPS2 @ PA10: */
|
||||||
#define SPI_CSR_NUM 2
|
#define SPI_CSR_NUM 2
|
||||||
|
@ -449,6 +450,9 @@ bool Flash_WipeMemoryPage(uint8_t page) {
|
||||||
Flash_CheckBusy(BUSY_TIMEOUT);
|
Flash_CheckBusy(BUSY_TIMEOUT);
|
||||||
|
|
||||||
FlashStop();
|
FlashStop();
|
||||||
|
|
||||||
|
// let spiffs check and update its info post flash erase
|
||||||
|
rdv40_spiffs_check ();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Wipes flash memory completely, fills with 0xFF
|
// Wipes flash memory completely, fills with 0xFF
|
||||||
|
|
|
@ -433,15 +433,41 @@ int rdv40_spiffs_lazy_mount_rollback(int changed) {
|
||||||
// statement or some function taking function parameters
|
// statement or some function taking function parameters
|
||||||
// TODO : forbid writing to a filename which already exists as lnk !
|
// TODO : forbid writing to a filename which already exists as lnk !
|
||||||
// TODO : forbid writing to a filename.lnk which already exists without lnk !
|
// TODO : forbid writing to a filename.lnk which already exists without lnk !
|
||||||
|
// Note: Writing in SPIFFS_WRITE_CHUNK_SIZE (8192) byte chucks helps to ensure "free space" has been erased by GC (Garbage collection)
|
||||||
int rdv40_spiffs_write(const char *filename, uint8_t *src, uint32_t size, RDV40SpiFFSSafetyLevel level) {
|
int rdv40_spiffs_write(const char *filename, uint8_t *src, uint32_t size, RDV40SpiFFSSafetyLevel level) {
|
||||||
RDV40_SPIFFS_SAFE_FUNCTION(
|
RDV40_SPIFFS_SAFE_FUNCTION(
|
||||||
|
uint32_t idx;
|
||||||
|
if (size <= SPIFFS_WRITE_CHUNK_SIZE) {
|
||||||
|
// write small file
|
||||||
write_to_spiffs(filename, src, size);
|
write_to_spiffs(filename, src, size);
|
||||||
|
size = 0;
|
||||||
|
} else { //
|
||||||
|
// write first SPIFFS_WRITE_CHUNK_SIZE bytes
|
||||||
|
// need to write the first chuck of data, then append
|
||||||
|
write_to_spiffs(filename, src, SPIFFS_WRITE_CHUNK_SIZE);
|
||||||
|
}
|
||||||
|
// append remaing SPIFFS_WRITE_CHUNK_SIZE byte chuncks
|
||||||
|
for (idx = 1; idx < (size / SPIFFS_WRITE_CHUNK_SIZE); idx++) {
|
||||||
|
append_to_spiffs(filename, &src[SPIFFS_WRITE_CHUNK_SIZE * idx], SPIFFS_WRITE_CHUNK_SIZE);
|
||||||
|
}
|
||||||
|
// append remaing bytes
|
||||||
|
if (((int64_t)size - (SPIFFS_WRITE_CHUNK_SIZE * idx)) > 0) {
|
||||||
|
append_to_spiffs(filename, &src[SPIFFS_WRITE_CHUNK_SIZE * idx], size - (SPIFFS_WRITE_CHUNK_SIZE * idx));
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
int rdv40_spiffs_append(const char *filename, uint8_t *src, uint32_t size, RDV40SpiFFSSafetyLevel level) {
|
int rdv40_spiffs_append(const char *filename, uint8_t *src, uint32_t size, RDV40SpiFFSSafetyLevel level) {
|
||||||
RDV40_SPIFFS_SAFE_FUNCTION(
|
RDV40_SPIFFS_SAFE_FUNCTION(
|
||||||
append_to_spiffs(filename, src, size);
|
uint32_t idx;
|
||||||
|
// Append any SPIFFS_WRITE_CHUNK_SIZE byte chunks
|
||||||
|
for (idx = 0; idx < (size/SPIFFS_WRITE_CHUNK_SIZE); idx++) {
|
||||||
|
append_to_spiffs(filename, &src[SPIFFS_WRITE_CHUNK_SIZE * idx], SPIFFS_WRITE_CHUNK_SIZE);
|
||||||
|
}
|
||||||
|
// Append remain bytes
|
||||||
|
if (((int64_t)size - (SPIFFS_WRITE_CHUNK_SIZE * idx)) > 0) {
|
||||||
|
append_to_spiffs(filename, &src[SPIFFS_WRITE_CHUNK_SIZE * idx], size - (SPIFFS_WRITE_CHUNK_SIZE * idx));
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -129,6 +129,8 @@ void rdv40_spiffs_safe_wipe(void);
|
||||||
|
|
||||||
#define SPIFFS_ERR_TEST -10100
|
#define SPIFFS_ERR_TEST -10100
|
||||||
|
|
||||||
|
// Amount of data to write/append to a file in one go.
|
||||||
|
#define SPIFFS_WRITE_CHUNK_SIZE 8192
|
||||||
|
|
||||||
// spiffs file descriptor index type. must be signed
|
// spiffs file descriptor index type. must be signed
|
||||||
typedef s16_t spiffs_file;
|
typedef s16_t spiffs_file;
|
||||||
|
|
|
@ -856,6 +856,8 @@ static bool dl_it(uint8_t *dest, uint32_t bytes, PacketResponseNG *response, siz
|
||||||
|
|
||||||
if (response->cmd == CMD_ACK)
|
if (response->cmd == CMD_ACK)
|
||||||
return true;
|
return true;
|
||||||
|
if (response->cmd == CMD_SPIFFS_DOWNLOAD && response->status == PM3_EMALLOC)
|
||||||
|
return false;
|
||||||
// Spiffs // fpgamem-plot download is converted to NG,
|
// Spiffs // fpgamem-plot download is converted to NG,
|
||||||
if (response->cmd == CMD_SPIFFS_DOWNLOAD || response->cmd == CMD_FPGAMEM_DOWNLOAD)
|
if (response->cmd == CMD_SPIFFS_DOWNLOAD || response->cmd == CMD_FPGAMEM_DOWNLOAD)
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue