show SPI flash JEDEC data

Signed-off-by: ANTodorov <ANTodorov@users.noreply.github.com>
This commit is contained in:
ANTodorov 2024-10-02 12:00:22 +03:00
commit 7ffab48e77
No known key found for this signature in database
GPG key ID: 318CC11D7ED4016B
3 changed files with 31 additions and 12 deletions

View file

@ -3,6 +3,7 @@ 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]
- show SPI flash JEDEC Manufacturer ID and Device ID in `hw status` output (@ANTodorov)
- Improved `hf iclass configcards` to support generating config cards using a different key than the default k0 as the card's key (@antiklesys) - Improved `hf iclass configcards` to support generating config cards using a different key than the default k0 as the card's key (@antiklesys)
- Added maur keys (@iceman1001) - Added maur keys (@iceman1001)
- Fixed `hf mfu pwdgen` for the 7 byte UID (@ANTodorov) - Fixed `hf mfu pwdgen` for the 7 byte UID (@ANTodorov)

View file

@ -49,11 +49,20 @@ void FlashmemSetSpiBaudrate(uint32_t baudrate) {
} }
// read ID out // read ID out
bool Flash_ReadID_90(flash_device_type_90_t *result) { bool Flash_ReadID(flash_device_type_t *result, bool read_jedec ) {
if (Flash_CheckBusy(BUSY_TIMEOUT)) return false; if (Flash_CheckBusy(BUSY_TIMEOUT)) return false;
// Manufacture ID / device ID
if ( read_jedec) {
// 0x9F JEDEC
FlashSendByte(JEDECID);
result->manufacturer_id = FlashSendByte(0xFF);
result->device_id = FlashSendByte(0xFF);
result->device_id2 = FlashSendLastByte(0xFF);
} else {
// 0x90 Manufacture ID / device ID
FlashSendByte(ID); FlashSendByte(ID);
FlashSendByte(0x00); FlashSendByte(0x00);
FlashSendByte(0x00); FlashSendByte(0x00);
@ -61,6 +70,7 @@ bool Flash_ReadID_90(flash_device_type_90_t *result) {
result->manufacturer_id = FlashSendByte(0xFF); result->manufacturer_id = FlashSendByte(0xFF);
result->device_id = FlashSendLastByte(0xFF); result->device_id = FlashSendLastByte(0xFF);
}
return true; return true;
} }
@ -346,8 +356,8 @@ void Flashmem_print_status(void) {
// NOTE: It would likely be more useful to use JDEC ID command 9F, // NOTE: It would likely be more useful to use JDEC ID command 9F,
// as it provides a third byte indicative of capacity. // as it provides a third byte indicative of capacity.
flash_device_type_90_t device_type = {0}; flash_device_type_t device_type = {0};
if (!Flash_ReadID_90(&device_type)) { if (!Flash_ReadID(&device_type, false)) {
DbpString(" Device ID............... " _RED_(" --> Not Found <--")); DbpString(" Device ID............... " _RED_(" --> Not Found <--"));
} else { } else {
if (device_type.manufacturer_id == WINBOND_MANID) { if (device_type.manufacturer_id == WINBOND_MANID) {
@ -370,6 +380,13 @@ void Flashmem_print_status(void) {
device_type.device_id device_type.device_id
); );
} }
if (Flash_ReadID(&device_type, true)) {
Dbprintf(" JEDEC Mfr ID / Dev ID... " _YELLOW_("%02X / %02X%02X"),
device_type.manufacturer_id,
device_type.device_id,
device_type.device_id2
);
}
} }
uint8_t uid[8] = {0, 0, 0, 0, 0, 0, 0, 0}; uint8_t uid[8] = {0, 0, 0, 0, 0, 0, 0, 0};

View file

@ -129,8 +129,9 @@ bool Flash_Erase64k(uint8_t block);
typedef struct { typedef struct {
uint8_t manufacturer_id; uint8_t manufacturer_id;
uint8_t device_id; uint8_t device_id;
} flash_device_type_90_t; // to differentiate from JDEC ID via cmd 9F uint8_t device_id2;
bool Flash_ReadID_90(flash_device_type_90_t *result); } flash_device_type_t; // extra device_id used for the JEDEC ID read via cmd 9F
bool Flash_ReadID(flash_device_type_t *result, bool read_jedec);
uint16_t Flash_ReadData(uint32_t address, uint8_t *out, uint16_t len); uint16_t Flash_ReadData(uint32_t address, uint8_t *out, uint16_t len);
uint16_t Flash_ReadDataCont(uint32_t address, uint8_t *out, uint16_t len); uint16_t Flash_ReadDataCont(uint32_t address, uint8_t *out, uint16_t len);