This is an automated email from the ASF dual-hosted git repository.
jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
The following commit(s) were added to refs/heads/master by this push:
new db05f05fe hw/drivers/flash/spiflash: Add option to ignore JEDEC ID
db05f05fe is described below
commit db05f05fedadc7782e6b857400779b8af69eb857
Author: Christoph Honal <[email protected]>
AuthorDate: Mon Jul 4 20:55:01 2022 +0200
hw/drivers/flash/spiflash: Add option to ignore JEDEC ID
---
hw/drivers/flash/spiflash/src/spiflash.c | 33 +++++++++++++++++++++++---------
hw/drivers/flash/spiflash/syscfg.yml | 12 ++++++++++++
2 files changed, 36 insertions(+), 9 deletions(-)
diff --git a/hw/drivers/flash/spiflash/src/spiflash.c
b/hw/drivers/flash/spiflash/src/spiflash.c
index 6879b7ef5..4a59ee0e6 100644
--- a/hw/drivers/flash/spiflash/src/spiflash.c
+++ b/hw/drivers/flash/spiflash/src/spiflash.c
@@ -1374,12 +1374,24 @@ spiflash_identify(struct spiflash_dev *dev)
* different pins, or of different type.
* It is unlikely that flash depended packaged will work correctly.
*/
- assert(manufacturer == supported_chips[0].fc_jedec_id.ji_manufacturer
&&
- memory_type == supported_chips[0].fc_jedec_id.ji_type &&
- capacity == supported_chips[0].fc_jedec_id.ji_capacity);
- if (manufacturer != supported_chips[0].fc_jedec_id.ji_manufacturer ||
- memory_type != supported_chips[0].fc_jedec_id.ji_type ||
- capacity != supported_chips[0].fc_jedec_id.ji_capacity) {
+ 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;
+ }
+ 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)) {
+ rc = -1;
+ goto err;
+ }
+ 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)) {
rc = -1;
goto err;
}
@@ -1413,9 +1425,12 @@ spiflash_identify(struct spiflash_dev *dev)
}
}
for (i = 0; supported_chips[i].fc_jedec_id.ji_manufacturer != 0; ++i) {
- if (manufacturer ==
supported_chips[i].fc_jedec_id.ji_manufacturer &&
- memory_type == supported_chips[i].fc_jedec_id.ji_type &&
- 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;
diff --git a/hw/drivers/flash/spiflash/syscfg.yml
b/hw/drivers/flash/spiflash/syscfg.yml
index 1a0c8222a..205fb3f6a 100644
--- a/hw/drivers/flash/spiflash/syscfg.yml
+++ b/hw/drivers/flash/spiflash/syscfg.yml
@@ -68,14 +68,26 @@ syscfg.defs:
values found in hw/drivers/flash/spiflash/chips/syscfg.yml should
be
set to 1 for desired chips.
value: 0
+ SPIFLASH_IGNORE_MANUFACTURER:
+ description: >
+ Ignore the SpiFlash manufacturer as read by Read JEDEC ID command
9FH
+ value: 0
SPIFLASH_MEMORY_TYPE:
description: >
Expected SpiFlash memory type as read by Read JEDEC ID command 9FH
value: 0
+ SPIFLASH_IGNORE_MEMORY_TYPE:
+ description: >
+ Ignore SpiFlash memory type as read by Read JEDEC ID command 9FH
+ value: 0
SPIFLASH_MEMORY_CAPACITY:
description: >
Expected SpiFlash memory capactity as read by Read JEDEC ID
command 9FH
value: 0
+ SPIFLASH_IGNORE_MEMORY_CAPACITY:
+ description: >
+ Ignore SpiFlash memory capactity as read by Read JEDEC ID command
9FH
+ value: 0
SPIFLASH_READ_STATUS_INTERVAL:
description: >