mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 13:23:51 -07:00
fix failed spi flash detection
fallback to 4 pages when SPI IC is unknown some code styling remove some unused code
This commit is contained in:
parent
52c46db3db
commit
68e354d7ef
2 changed files with 6 additions and 17 deletions
|
@ -455,16 +455,9 @@ void Flashmem_print_info(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//read spi flash JEDEC ID and fill the global variable spi_flash_p64k
|
//read spi flash JEDEC ID and fill the global variable spi_flash_p64k
|
||||||
bool FlashDetect(bool flash_init) {
|
bool FlashDetect(void) {
|
||||||
flash_device_type_t flash_device = {0};
|
flash_device_type_t flash_device = {0};
|
||||||
|
|
||||||
if (flash_init) {
|
|
||||||
if (!FlashInit()) {
|
|
||||||
if (g_dbglevel > 3) Dbprintf("FlashDetect() FlashInit fail");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Flash_ReadID(&flash_device, true)) {
|
if (!Flash_ReadID(&flash_device, true)) {
|
||||||
if (g_dbglevel > 3) Dbprintf("Flash_ReadID failed");
|
if (g_dbglevel > 3) Dbprintf("Flash_ReadID failed");
|
||||||
return false;
|
return false;
|
||||||
|
@ -472,7 +465,7 @@ bool FlashDetect(bool flash_init) {
|
||||||
|
|
||||||
uint32_t identifier = (flash_device.manufacturer_id << 16) + (flash_device.device_id <<8 ) + flash_device.device_id2;
|
uint32_t identifier = (flash_device.manufacturer_id << 16) + (flash_device.device_id <<8 ) + flash_device.device_id2;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (; i < ARRAYLEN(SpiFlashTable); i++) {
|
for (; i < ARRAYLEN(SpiFlashTable)-1; i++) {
|
||||||
if (SpiFlashTable[i].identifier == identifier) {
|
if (SpiFlashTable[i].identifier == identifier) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -480,10 +473,6 @@ bool FlashDetect(bool flash_init) {
|
||||||
|
|
||||||
spi_flash_p64k = SpiFlashTable[i].pages64;
|
spi_flash_p64k = SpiFlashTable[i].pages64;
|
||||||
|
|
||||||
if (flash_init) {
|
|
||||||
FlashStop();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -503,7 +492,7 @@ bool FlashInit(void) {
|
||||||
|
|
||||||
#ifndef AS_BOOTROM
|
#ifndef AS_BOOTROM
|
||||||
if (spi_flash_p64k == 0) {
|
if (spi_flash_p64k == 0) {
|
||||||
if (!FlashDetect(false)) {
|
if (!FlashDetect()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,7 +151,6 @@ typedef struct spi_flash_s {
|
||||||
const char *desc;
|
const char *desc;
|
||||||
} spi_flash_t;
|
} spi_flash_t;
|
||||||
|
|
||||||
// spi_flash_t is expected to be NULL terminated
|
|
||||||
const static spi_flash_t SpiFlashTable[] = {
|
const static spi_flash_t SpiFlashTable[] = {
|
||||||
// Manufacturer: Puya
|
// Manufacturer: Puya
|
||||||
{ 0x856015, 32, "P25Q16H" },
|
{ 0x856015, 32, "P25Q16H" },
|
||||||
|
@ -165,6 +164,7 @@ const static spi_flash_t SpiFlashTable[] = {
|
||||||
{ 0xEF4016, 64, "W25Q32BV" },
|
{ 0xEF4016, 64, "W25Q32BV" },
|
||||||
|
|
||||||
{ 0xEF7022, 4, "W25Q02JV" },
|
{ 0xEF7022, 4, "W25Q02JV" },
|
||||||
|
// (default) last record
|
||||||
{ 0x000000, 4, "Unknown!" }
|
{ 0x000000, 4, "Unknown!" }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ const static spi_flash_t SpiFlashTable[] = {
|
||||||
|
|
||||||
extern uint8_t spi_flash_p64k;
|
extern uint8_t spi_flash_p64k;
|
||||||
|
|
||||||
bool FlashDetect(bool);
|
bool FlashDetect(void);
|
||||||
|
|
||||||
#endif // #ifndef AS_BOOTROM
|
#endif // #ifndef AS_BOOTROM
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue