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

PineStore announcement : the current flash chip is EoL, a new one will be used for future PineTime batches #11

Closed
JF002 opened this issue Jul 21, 2024 · 1 comment · Fixed by #12

Comments

@JF002
Copy link
Collaborator

JF002 commented Jul 21, 2024

A new SPI flash chip will be installed in future PineTime batches since the current one is EoL. The only forseen changes are the JEDEC id of the memory chip.

See InfiniTimeOrg/InfiniTime#2096 for more detail.

Analysis

Since the manufacturer ID, memory type and memory density are defined, the spiflash driver of MyNewt will fail if the IDs reported by the chip are now the ones that are defined in syscfg.yml.

Ideally, we should try to find a solution that would allow a single bootloader version to support both the old and the new memory chip.

Option 1

The version of MyNewt (1.8.0) that is currently used in this project allows to set SPIFLASH_MANUFACTURER, SPIFLASH_MEMORY_TYPE and SPIFLASH_MEMORY_CAPACITY to 0. This way, it'll use a list of white-listed drivers in https://github.com/apache/mynewt-core/blob/mynewt_1_8_0_tag/hw/drivers/flash/spiflash/chips/syscfg.yml.
In this project, none of the drivers are white-listed, and the old and new chips are not supported either.

I quickly PoC'd the following patch which seems to work (but I couldn't test on the new memory chip though) :

Index: repos/apache-mynewt-core/hw/drivers/flash/spiflash/chips/syscfg.yml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/repos/apache-mynewt-core/hw/drivers/flash/spiflash/chips/syscfg.yml b/repos/apache-mynewt-core/hw/drivers/flash/spiflash/chips/syscfg.yml
--- a/repos/apache-mynewt-core/hw/drivers/flash/spiflash/chips/syscfg.yml	(revision cb9df4273aac1c8e627ff4df67b866ba9a22b018)
+++ b/repos/apache-mynewt-core/hw/drivers/flash/spiflash/chips/syscfg.yml	(date 1721500769220)
@@ -491,3 +491,9 @@
     SPIFLASH_EON2580B:
         description: Add support for EON2580B
         value: 0
+    SPIFLASH_XTX25F32B:
+        description: Add support for XTX25F32B
+        value: 1
+    SPIFLASH_BY25Q32:
+        description: Add support for BY25Q32
+        value: 1
Index: repos/apache-mynewt-core/hw/drivers/flash/spiflash/src/spiflash.c
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/repos/apache-mynewt-core/hw/drivers/flash/spiflash/src/spiflash.c b/repos/apache-mynewt-core/hw/drivers/flash/spiflash/src/spiflash.c
--- a/repos/apache-mynewt-core/hw/drivers/flash/spiflash/src/spiflash.c	(revision cb9df4273aac1c8e627ff4df67b866ba9a22b018)
+++ b/repos/apache-mynewt-core/hw/drivers/flash/spiflash/src/spiflash.c	(date 1721501298719)
@@ -565,7 +565,12 @@
 #if MYNEWT_VAL(SPIFLASH_EON2580B)
     EON_CHIP(EN80B, 0x30, FLASH_CAPACITY_8MBIT),
 #endif
-
+#if MYNEWT_VAL(SPIFLASH_XTX25F32B)
+    STD_FLASH_CHIP("", 0x0b, 0x40, 0x16, spiflash_release_power_down_generic),
+#endif
+#if MYNEWT_VAL(SPIFLASH_BY25Q32)
+    STD_FLASH_CHIP("", 0x16, 0x40, 0x16, spiflash_release_power_down_generic),
+#endif
     { {0} },
 };
 
Index: hw/bsp/nrf52/syscfg.yml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/hw/bsp/nrf52/syscfg.yml b/hw/bsp/nrf52/syscfg.yml
--- a/hw/bsp/nrf52/syscfg.yml	(revision 2bd9ead9a22605ade0c9770b6f41ab2f099d39b9)
+++ b/hw/bsp/nrf52/syscfg.yml	(date 1721501134919)
@@ -62,9 +62,9 @@
     SPIFLASH_SPI_NUM:       0   # SPI Interface 0
     SPIFLASH_SPI_CS_PIN:    5   # SPI interface CS pin: P0.05/AIN3, SPI-CE# (SPI-NOR)
     SPIFLASH_BAUDRATE:      8000    # Requested baudrate, 8000 is the fastest baudrate supported by nRF52832
-    SPIFLASH_MANUFACTURER:  0x0B    # Expected SpiFlash manufacturer as read by Read JEDEC ID command 9FH
-    SPIFLASH_MEMORY_TYPE:   0x40    # Expected SpiFlash memory type as read by Read JEDEC ID command 9FH
-    SPIFLASH_MEMORY_CAPACITY: 0x16  # Expected SpiFlash memory capactity as read by Read JEDEC ID command 9FH (2 ^ 0x16 = 32 Mb)
+    SPIFLASH_MANUFACTURER:  0    # Expected SpiFlash manufacturer as read by Read JEDEC ID command 9FH
+    SPIFLASH_MEMORY_TYPE:   0    # Expected SpiFlash memory type as read by Read JEDEC ID command 9FH
+    SPIFLASH_MEMORY_CAPACITY: 0  # Expected SpiFlash memory capactity as read by Read JEDEC ID command 9FH (2 ^ 0x16 = 32 Mb)
     SPIFLASH_SECTOR_COUNT:  1024    # Number of sectors: 1024 sectors of 4 KB each
     SPIFLASH_SECTOR_SIZE:   4096    # TODO Number of bytes that can be erased at a time: 4 KB sector size
     SPIFLASH_PAGE_SIZE:     256     # TODO Number of bytes that can be written at a time

I don't know if MyNewt provide anyway to "override" the code from the repo. If not, we can simply patch those file after they're downloaded by newt upgrade and before building the project.

It looks like a rather limited and safe change.

Option 2

A while ago, @startgate01 contributed this PR that effectively disables the JEDEC IDs check to support many P8 variants.

Applying this PR means adding other changes and upgrading to a new version of MyNewt.

Opportunity to add other changes

We could take the opportunity to add other changes to the bootloader :

  • This PR that ignores the push on the button if it was already pushed when the bootloader started
  • Lower the brightness of the display to help with devices with the battery completely depleted

The bootloader is a very critical piece of code!

The bootloader is a very critical piece of code : any bug might make PineTimes (or other device) unusable, brick them,... When we released the current version 1.0.0 of the bootloader, we spent a lot of time testing it as much as possible to ensure that it was working as expected. We are relying on this very first release since Pine64 ships PineTime with InfiniTime in July 2021.

In order to stay on the safe side, I would favor the implementation that would bring the less risk of regression, bug, crash,... to the new release (option 1), but I'm ok to discuss with the community of other options. Remember that the more changes we add, the more tests we'll need to do before releasing the version to PineStore and users!

@JF002
Copy link
Collaborator Author

JF002 commented Jul 23, 2024

Since I would like to provide the new firmware in a short time frame (to avoid blocking the production of the next batch of PineTime), I decided to implement the Option 1. See #12

@JF002 JF002 closed this as completed in #12 Sep 4, 2024
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 a pull request may close this issue.

1 participant