Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor spi flash detection #2643

Merged
merged 3 commits into from
Nov 20, 2024

Conversation

ANTodorov
Copy link
Contributor

spi_flash_data is a structure of the data, red from the flash IC
*spi_flash_p is a pointer to the detected flash IC, points to the default '256k/4 pages/unknown' device

Copy link

You are welcome to add an entry to the CHANGELOG.md as well

} else {
// 0x90 Manufacture ID / device ID
FlashSendByte(ID);
FlashSendByte(0x00);
FlashSendByte(0x00);
FlashSendByte(0x00);

result->manufacturer_id = (FlashSendByte(0xFF) & 0xFF);
result->device_id = (FlashSendLastByte(0xFF) & 0xFF);
result->mfr_id = (FlashSendByte(0xFF) & 0xFF);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rename made it hard to understand. Please revert.

{ 0xEF, 0x12, 0x0000, 8, "W25*40BV" }, // 512k
{ 0xEF, 0x13, 0x0000, 16, "W25*80BV" } // 1024k
};
const spi_flash_t *spi_flash_p = SpiFlashTable;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you move this table to the header file where you declare it, you can remove the extern reference to it.
Not sure why you complicate it with pointers. I would have a static extern for table_idx, and a "get_item" function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right.
Actually only the number of the 64k pages is needed outside of the flashmem.c file.
rework in progress...

Reverted 'mfr_id' to 'manufacturer_id'
Moved devices table definition to flashmem.h
Single global variable 'spi_flash_pages64k'
The local structure holding the actual device data is used in firmware.c only

difference in code:
```
   text    data     bss     dec     hex filename
 223189  138560    6067  367816   59cc8 ./armsrc/obj/fullimage.elf <-- c9e751d darkside: fix backdoor support

 223437  138624    6075  368136   59e08 ./armsrc/obj/fullimage.elf <-- this commit
 ======================================
   +248     +64      +8    +320
```
@iceman1001 iceman1001 merged commit 7e041cc into RfidResearchGroup:master Nov 20, 2024
12 checks passed
@iceman1001
Copy link
Collaborator

Awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants