mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 05:13:46 -07:00
spiffs prep
added define for chuck size update changelog
This commit is contained in:
parent
96876c0111
commit
9406ef9fd3
3 changed files with 18 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)
|
||||||
|
|
|
@ -433,26 +433,26 @@ 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 8192 byte chucks helps to ensure "free space" has been erased by GC (Garbage collection)
|
// 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;
|
uint32_t idx;
|
||||||
if (size <= 8192) {
|
if (size <= SPIFFS_WRITE_CHUNK_SIZE) {
|
||||||
// write small file
|
// write small file
|
||||||
write_to_spiffs(filename, src, size);
|
write_to_spiffs(filename, src, size);
|
||||||
size = 0;
|
size = 0;
|
||||||
} else { //
|
} else { //
|
||||||
// write first 8192 bytes
|
// write first SPIFFS_WRITE_CHUNK_SIZE bytes
|
||||||
// need to write the first chuck of data, then append
|
// need to write the first chuck of data, then append
|
||||||
write_to_spiffs(filename, src, 8192);
|
write_to_spiffs(filename, src, SPIFFS_WRITE_CHUNK_SIZE);
|
||||||
}
|
}
|
||||||
// append remaing 8192 byte chuncks
|
// append remaing SPIFFS_WRITE_CHUNK_SIZE byte chuncks
|
||||||
for (idx = 1; idx < (size / 8192); idx++) {
|
for (idx = 1; idx < (size / SPIFFS_WRITE_CHUNK_SIZE); idx++) {
|
||||||
append_to_spiffs(filename, &src[8192 * idx], 8192);
|
append_to_spiffs(filename, &src[SPIFFS_WRITE_CHUNK_SIZE * idx], SPIFFS_WRITE_CHUNK_SIZE);
|
||||||
}
|
}
|
||||||
// append remaing bytes
|
// append remaing bytes
|
||||||
if (((int64_t)size - (8192 * idx)) > 0) {
|
if (((int64_t)size - (SPIFFS_WRITE_CHUNK_SIZE * idx)) > 0) {
|
||||||
append_to_spiffs(filename, &src[8192 * idx], size - (8192 * idx));
|
append_to_spiffs(filename, &src[SPIFFS_WRITE_CHUNK_SIZE * idx], size - (SPIFFS_WRITE_CHUNK_SIZE * idx));
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -460,13 +460,13 @@ int rdv40_spiffs_write(const char *filename, uint8_t *src, uint32_t size, RDV40S
|
||||||
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(
|
||||||
uint32_t idx;
|
uint32_t idx;
|
||||||
// Append any 8192 byte chunks
|
// Append any SPIFFS_WRITE_CHUNK_SIZE byte chunks
|
||||||
for (idx = 0; idx < (size/8192); idx++) {
|
for (idx = 0; idx < (size/SPIFFS_WRITE_CHUNK_SIZE); idx++) {
|
||||||
append_to_spiffs(filename, &src[8192 * idx], 8192);
|
append_to_spiffs(filename, &src[SPIFFS_WRITE_CHUNK_SIZE * idx], SPIFFS_WRITE_CHUNK_SIZE);
|
||||||
}
|
}
|
||||||
// Append remain bytes
|
// Append remain bytes
|
||||||
if (((int64_t)size - (8192 * idx)) > 0) {
|
if (((int64_t)size - (SPIFFS_WRITE_CHUNK_SIZE * idx)) > 0) {
|
||||||
append_to_spiffs(filename, &src[8192 * idx], size - (8192 * idx));
|
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;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue