mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 13:00:42 -07:00
Move T55XX config to spiffs file
This commit is contained in:
parent
4b5d532c9a
commit
dd17effaab
2 changed files with 14 additions and 40 deletions
|
@ -325,33 +325,9 @@ void setT55xxConfig(uint8_t arg0, const t55xx_configurations_t *c) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!FlashInit()) {
|
rdv40_spiffs_write(T55XX_CONFIG_FILE, (uint8_t*)&T55xx_Timing, T55XX_CONFIG_LEN, RDV40_SPIFFS_SAFETY_SAFE);
|
||||||
BigBuf_free();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t *buf = BigBuf_malloc(T55XX_CONFIG_LEN);
|
|
||||||
Flash_CheckBusy(BUSY_TIMEOUT);
|
|
||||||
uint16_t res = Flash_ReadDataCont(T55XX_CONFIG_OFFSET, buf, T55XX_CONFIG_LEN);
|
|
||||||
if (res == 0) {
|
|
||||||
FlashStop();
|
|
||||||
BigBuf_free();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(buf, &T55xx_Timing, T55XX_CONFIG_LEN);
|
|
||||||
|
|
||||||
// delete old configuration
|
|
||||||
Flash_CheckBusy(BUSY_TIMEOUT);
|
|
||||||
Flash_WriteEnable();
|
|
||||||
Flash_Erase4k(3, 0xD);
|
|
||||||
|
|
||||||
// write new
|
|
||||||
res = Flash_Write(T55XX_CONFIG_OFFSET, buf, T55XX_CONFIG_LEN);
|
|
||||||
|
|
||||||
if (res == T55XX_CONFIG_LEN && g_dbglevel > 1) {
|
|
||||||
DbpString("T55XX Config save " _GREEN_("success"));
|
DbpString("T55XX Config save " _GREEN_("success"));
|
||||||
}
|
|
||||||
|
|
||||||
BigBuf_free();
|
BigBuf_free();
|
||||||
#endif
|
#endif
|
||||||
|
@ -364,15 +340,17 @@ t55xx_configurations_t *getT55xxConfig(void) {
|
||||||
void loadT55xxConfig(void) {
|
void loadT55xxConfig(void) {
|
||||||
#ifdef WITH_FLASH
|
#ifdef WITH_FLASH
|
||||||
|
|
||||||
if (!FlashInit()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t *buf = BigBuf_malloc(T55XX_CONFIG_LEN);
|
uint8_t *buf = BigBuf_malloc(T55XX_CONFIG_LEN);
|
||||||
|
|
||||||
Flash_CheckBusy(BUSY_TIMEOUT);
|
uint32_t size = 0;
|
||||||
uint16_t isok = Flash_ReadDataCont(T55XX_CONFIG_OFFSET, buf, T55XX_CONFIG_LEN);
|
if (exists_in_spiffs(T55XX_CONFIG_FILE)) {
|
||||||
FlashStop();
|
size = size_in_spiffs(T55XX_CONFIG_FILE);
|
||||||
|
}
|
||||||
|
if (size == 0) {
|
||||||
|
Dbprintf("Spiffs file: %s does not exists or empty.", T55XX_CONFIG_FILE);
|
||||||
|
BigBuf_free();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// verify read mem is actual data.
|
// verify read mem is actual data.
|
||||||
uint8_t cntA = T55XX_CONFIG_LEN, cntB = T55XX_CONFIG_LEN;
|
uint8_t cntA = T55XX_CONFIG_LEN, cntB = T55XX_CONFIG_LEN;
|
||||||
|
@ -381,6 +359,7 @@ void loadT55xxConfig(void) {
|
||||||
if (buf[i] == 0x00) cntB--;
|
if (buf[i] == 0x00) cntB--;
|
||||||
}
|
}
|
||||||
if (!cntA || !cntB) {
|
if (!cntA || !cntB) {
|
||||||
|
Dbprintf("Spiffs file: %s does not malformed or empty.", T55XX_CONFIG_FILE);
|
||||||
BigBuf_free();
|
BigBuf_free();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -388,7 +367,7 @@ void loadT55xxConfig(void) {
|
||||||
if (buf[0] != 0xFF) // if not set for clear
|
if (buf[0] != 0xFF) // if not set for clear
|
||||||
memcpy((uint8_t *)&T55xx_Timing, buf, T55XX_CONFIG_LEN);
|
memcpy((uint8_t *)&T55xx_Timing, buf, T55XX_CONFIG_LEN);
|
||||||
|
|
||||||
if (isok == T55XX_CONFIG_LEN) {
|
if (size == T55XX_CONFIG_LEN) {
|
||||||
if (g_dbglevel > 1) DbpString("T55XX Config load success");
|
if (g_dbglevel > 1) DbpString("T55XX Config load success");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,12 +65,7 @@
|
||||||
# define T55XX_CONFIG_LEN sizeof( t55xx_configurations_t )
|
# define T55XX_CONFIG_LEN sizeof( t55xx_configurations_t )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef T55XX_CONFIG_OFFSET
|
#define T55XX_CONFIG_FILE "cfg_t55xx.bin"
|
||||||
# define T55XX_CONFIG_OFFSET (FLASH_MEM_MAX_4K_SECTOR - 0x2000)
|
|
||||||
#endif
|
|
||||||
#ifndef T55XX_CONFIG_OFFSET_P
|
|
||||||
# define T55XX_CONFIG_OFFSET_P(p64k) (FLASH_MEM_MAX_4K_SECTOR_P(p64k) - 0x2000)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// T55XX PWD stored in spiffs
|
// T55XX PWD stored in spiffs
|
||||||
#define T55XX_KEYS_FILE "dict_t55xx.bin"
|
#define T55XX_KEYS_FILE "dict_t55xx.bin"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue