You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2022/07/04 19:06:54 UTC
[GitHub] [mynewt-core] StarGate01 opened a new pull request, #2858: hw/drivers/flash/spiflash: Add option to ignore JEDEC ID
StarGate01 opened a new pull request, #2858:
URL: https://github.com/apache/mynewt-core/pull/2858
This PR introduces three new **optional** configuration parameters: `SPIFLASH_IGNORE_MANUFACTURER`, `SPIFLASH_IGNORE_MEMORY_TYPE`, and `SPIFLASH_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](https://github.com/InfiniTimeOrg/InfiniTime/pull/1050) (written for the [PineTime smartwatch](https://www.pine64.org/pinetime/)) to a popular Chinese smartwatch series called "P8". `mynewt-core` is 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-core` enforces 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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mynewt.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [mynewt-core] kasjer commented on pull request #2858: hw/drivers/flash/spiflash: Add option to ignore JEDEC ID
Posted by GitBox <gi...@apache.org>.
kasjer commented on PR #2858:
URL: https://github.com/apache/mynewt-core/pull/2858#issuecomment-1203517348
@StarGate01 thanks for contributions
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mynewt.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [mynewt-core] StarGate01 commented on pull request #2858: hw/drivers/flash/spiflash: Add option to ignore JEDEC ID
Posted by GitBox <gi...@apache.org>.
StarGate01 commented on PR #2858:
URL: https://github.com/apache/mynewt-core/pull/2858#issuecomment-1191185810
@kasjer Is this something you would consider merging? The feature would be opt-in.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mynewt.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [mynewt-core] apache-mynewt-bot commented on pull request #2858: hw/drivers/flash/spiflash: Add option to ignore JEDEC ID
Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot commented on PR #2858:
URL: https://github.com/apache/mynewt-core/pull/2858#issuecomment-1203216662
<!-- style-bot -->
## Style check summary
#### No suggestions at this time!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mynewt.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [mynewt-core] kasjer merged pull request #2858: hw/drivers/flash/spiflash: Add option to ignore JEDEC ID
Posted by GitBox <gi...@apache.org>.
kasjer merged PR #2858:
URL: https://github.com/apache/mynewt-core/pull/2858
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mynewt.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [mynewt-core] apache-mynewt-bot commented on pull request #2858: hw/drivers/flash/spiflash: Add option to ignore JEDEC ID
Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot commented on PR #2858:
URL: https://github.com/apache/mynewt-core/pull/2858#issuecomment-1200313023
<!-- style-bot -->
## Style check summary
### Our coding style is [here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
#### hw/drivers/flash/spiflash/src/spiflash.c
<details>
```diff
@@ -1374,24 +1378,24 @@
* different pins, or of different type.
* It is unlikely that flash depended packaged will work correctly.
*/
- assert(MYNEWT_VAL(SPIFLASH_IGNORE_MANUFACTURER) ||
+ 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)) {
+ if (!(MYNEWT_VAL(SPIFLASH_IGNORE_MANUFACTURER) ||
+ manufacturer == supported_chips[0].fc_jedec_id.ji_manufacturer)) {
rc = -1;
goto err;
}
- assert(MYNEWT_VAL(SPIFLASH_IGNORE_MEMORY_TYPE) ||
+ assert(MYNEWT_VAL(SPIFLASH_IGNORE_MEMORY_TYPE) ||
memory_type == supported_chips[0].fc_jedec_id.ji_type);
- if (!(MYNEWT_VAL(SPIFLASH_IGNORE_MEMORY_TYPE) ||
- memory_type == supported_chips[0].fc_jedec_id.ji_type)) {
+ if (!(MYNEWT_VAL(SPIFLASH_IGNORE_MEMORY_TYPE) ||
+ memory_type == supported_chips[0].fc_jedec_id.ji_type)) {
rc = -1;
goto err;
}
- assert(MYNEWT_VAL(SPIFLASH_IGNORE_MEMORY_CAPACITY) ||
+ assert(MYNEWT_VAL(SPIFLASH_IGNORE_MEMORY_CAPACITY) ||
capacity == supported_chips[0].fc_jedec_id.ji_capacity);
- if (!(MYNEWT_VAL(SPIFLASH_IGNORE_MEMORY_CAPACITY) ||
- capacity == supported_chips[0].fc_jedec_id.ji_capacity)) {
+ if (!(MYNEWT_VAL(SPIFLASH_IGNORE_MEMORY_CAPACITY) ||
+ capacity == supported_chips[0].fc_jedec_id.ji_capacity)) {
rc = -1;
goto err;
}
@@ -1425,12 +1429,12 @@
}
}
for (i = 0; supported_chips[i].fc_jedec_id.ji_manufacturer != 0; ++i) {
- if ((MYNEWT_VAL(SPIFLASH_IGNORE_MANUFACTURER) ||
- manufacturer == supported_chips[i].fc_jedec_id.ji_manufacturer) &&
- (MYNEWT_VAL(SPIFLASH_IGNORE_MEMORY_TYPE) ||
- memory_type == supported_chips[i].fc_jedec_id.ji_type) &&
- (MYNEWT_VAL(SPIFLASH_IGNORE_MEMORY_CAPACITY) ||
- capacity == supported_chips[i].fc_jedec_id.ji_capacity)) {
+ if ((MYNEWT_VAL(SPIFLASH_IGNORE_MANUFACTURER) ||
+ manufacturer == supported_chips[i].fc_jedec_id.ji_manufacturer) &&
+ (MYNEWT_VAL(SPIFLASH_IGNORE_MEMORY_TYPE) ||
+ memory_type == supported_chips[i].fc_jedec_id.ji_type) &&
+ (MYNEWT_VAL(SPIFLASH_IGNORE_MEMORY_CAPACITY) ||
+ capacity == supported_chips[i].fc_jedec_id.ji_capacity)) {
/* Device is supported */
dev->flash_chip = &supported_chips[i];
break;
```
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mynewt.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [mynewt-core] kasjer commented on pull request #2858: hw/drivers/flash/spiflash: Add option to ignore JEDEC ID
Posted by GitBox <gi...@apache.org>.
kasjer commented on PR #2858:
URL: https://github.com/apache/mynewt-core/pull/2858#issuecomment-1193666753
@StarGate01 maybe you could change your commit a little bit to be more consistent with mynewt style that requires opening brace `{` to be on the same line as `if`.
Since new syscfg values have default value 0 it can be safely used in plain `if` (not `#if`)
Instead of having:
```c
#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;
}
#endif
```
we would have:
```c
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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mynewt.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [mynewt-core] kasjer commented on pull request #2858: hw/drivers/flash/spiflash: Add option to ignore JEDEC ID
Posted by GitBox <gi...@apache.org>.
kasjer commented on PR #2858:
URL: https://github.com/apache/mynewt-core/pull/2858#issuecomment-1191269201
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
> <https://github.com/apache/mynewt-core/pull/2858#issuecomment-1191185810>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AFP6YYGIWOUIS7EBDXHZV7DVVEBQNANCNFSM52T7XHKA>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mynewt.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [mynewt-core] StarGate01 commented on pull request #2858: hw/drivers/flash/spiflash: Add option to ignore JEDEC ID
Posted by GitBox <gi...@apache.org>.
StarGate01 commented on PR #2858:
URL: https://github.com/apache/mynewt-core/pull/2858#issuecomment-1200314471
@kasjer Thank you for the style comments; I have applied your suggestions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mynewt.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [mynewt-core] apache-mynewt-bot commented on pull request #2858: hw/drivers/flash/spiflash: Add option to ignore JEDEC ID
Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot commented on PR #2858:
URL: https://github.com/apache/mynewt-core/pull/2858#issuecomment-1174112940
<!-- style-bot -->
## Style check summary
#### No suggestions at this time!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mynewt.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org