hw/drivers/flash/spiflash: Add option to ignore JEDEC ID - #2858
Conversation
|
@kasjer Is this something you would consider merging? The feature would be opt-in. |
|
Hi, I am out of office, idea is good so definitely I will support it, I
have not seen the code, I will take a look next week.
Thanks for your submittion.
Jerzy
czw., 21 lip 2022, 10:17 użytkownik Christoph Honal <
***@***.***> napisał:
… @kasjer <https://github.com/kasjer> Is this something you would consider
merging? The feature would be opt-in.
—
Reply to this email directly, view it on GitHub
<#2858 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFP6YYGIWOUIS7EBDXHZV7DVVEBQNANCNFSM52T7XHKA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
@StarGate01 maybe you could change your commit a little bit to be more consistent with mynewt style that requires opening brace #if !MYNEWT_VAL(SPIFLASH_IGNORE_MANUFACTURER)
assert(manufacturer == supported_chips[0].fc_jedec_id.ji_manufacturer);
if (manufacturer != supported_chips[0].fc_jedec_id.ji_manufacturer) {
rc = -1;
goto err;
}
#endifwe would have: assert(!MYNEWT_VAL(SPIFLASH_IGNORE_MANUFACTURER) &&
manufacturer == supported_chips[0].fc_jedec_id.ji_manufacturer);
if (!MYNEWT_VAL(SPIFLASH_IGNORE_MANUFACTURER) &&
manufacturer != supported_chips[0].fc_jedec_id.ji_manufacturer) {
rc = -1;
goto err;
}generate code would be the same and compiler would check syntax that otherwise would not be checked in some build depending on ignore flags and mynewt style would be preserved without additional pre-processor conditions added for style sake only. You can amend your commit and force push. |
d4a553e to
d58a7e1
Compare
|
@kasjer Thank you for the style comments; I have applied your suggestions. |
d58a7e1 to
de64d4f
Compare
Style check summaryNo suggestions at this time! |
|
@StarGate01 thanks for contributions |
This PR introduces three new optional configuration parameters:
SPIFLASH_IGNORE_MANUFACTURER,SPIFLASH_IGNORE_MEMORY_TYPE, andSPIFLASH_IGNORE_MEMORY_CAPACITY. (Default:0).These parameters selectively disable the whitelist checks of the SPI Flash JEDEC IDs.
Rationale
I am currently porting the InfiniTime OS (written for the PineTime smartwatch) to a popular Chinese smartwatch series called "P8".
mynewt-coreis used for the bootloader.These P8 watches come in a whole zoo of variants, each being compatible with the firmware but containing sometimes a bit different chips due to the silicon shortage and general chip availability on the global market. This is usually no problem to handle.
However, the SPI driver of
mynewt-coreenforces a strict whitelist on the reported SPI Flash JEDEC ID. I see how this is useful in normal applications where the hardware configuration is known in detail and compatibility has to be ensured, however this leads to my bootloader refusing to work on prior unknown / new smartwatch variants, bricking them.In the past, others and I have added definitions for SPI IDs (e.g. #2798 , #2582 ), but I can't keep up with all the models and I don't want to brick any more watches due to a purely whitelisting (not technical) issue.
I am open to suggestions, I think these optional configuration parameters would be quite useful to have.