InfiniTimeOrg / pinetime-mcuboot-bootloader

An open source bootloader for the PineTime based on MyNEWT and MCUBoot.
Apache License 2.0
67 stars 18 forks source link

[FR][P8] support multiple SPI flash for one platform #6

Open ildar opened 3 years ago

ildar commented 3 years ago

While Colme P8 is one platform, it happens to have different SPI flash components. The fixed SPIFLASH_MANUFACTURER looks excessive. Could that be flexible or ignored?

ildar commented 3 years ago

I hope I did everything right. So

  1. apply patch to apache-mynewt-core 0001-hw-drivers-flash-spiflash-add-JEDEC_MFC_XTX-and-XT25.patch.gz (would be nice to upstream it)
  2. add this to hw/bsp/nrf52/syscfg.yml:
    SPIFLASH_XT25F32B:      1   # PineTime standard chip
  3. having XT25F32B added to the number of standard chips, define "custom" chip as it always was (only one allowed!). E.g. as @tt1pjm suggested, SPIFLASH_MANUFACTURER: 0x20

@tt1pjm, could you please read the SPI flash chip model you have? I guess it should be Micron chip.

tt1pjm commented 3 years ago

Hey @ildar, When I stepped through the mcuboot code to get the SPIFLASH_MANUFACTURER I did notice that a lookup was performed against the SPIFlash to be able to compare with the value provided. I think there was an assertion failure if no match and no further progress on booting/boot looping. It seems to be a redundant check as you suggest. If we're able to determine the correct jedec manufacturer we should be able to use it and continue to boot but would require changes to mcuboot. On my SPIFlash I can see the text "XMC QH32BWIG" which I believe corresponds to the XM25QH32B model.

ildar commented 3 years ago
  1. I got datasheet of your chip and confirmed that jedec manufacturer is 0x20, just as you wrote in https://github.com/tt1pjm/pinetime-rust-mynewt/commit/3fb35bceeb40766d28229e82ed6757af46e706ee
  2. As I wrote, it's possible to support several chips in one mcuboot. You just need to add it to the list of well-known chips and use it in syscfg.yml, just as I did in my patch: https://github.com/JF002/pinetime-mcuboot-bootloader/issues/6#issuecomment-798906985
  3. would you confirm the bootloader works with your P8 as well as with mine? attaching the hex. mynewt.elf.hex.gz
tt1pjm commented 3 years ago

I flashed your bootloader above using OpenOCD. On restart all worked as expected and booted last loaded firmware. I've also tested a couple of OTA installs of firmware which also work as expected.

ildar commented 3 years ago

very nice! thanks a lot for testing. I plan to make OTA packages, would you be able to test?

tt1pjm commented 3 years ago

Happy to help. I'll be taking a closer look at the newer bootloader/reloader compatibility with the P8 so keep posting your progress.

ildar commented 3 years ago

https://github.com/apache/mynewt-core/pull/2552 is now upstreamed.

ildar commented 3 years ago

@tt1pjm , you could add your P8's flash chip to mynewt-core, as I did for PineTime: https://github.com/ildar/mynewt-core/commit/6555463a5bf591494a0bdb3ab50e9ba742ccbf98

tt1pjm commented 3 years ago

Flash chip for P8 now merged into mynewt-core: https://github.com/apache/mynewt-core/pull/2582

StarGate01 commented 2 years ago

Multiple flash chips are allowed via #10 , see https://github.com/InfiniTimeOrg/pinetime-mcuboot-bootloader/pull/10/files#diff-1bcea6a127a33f80b40cfb7ecb5f8de407aaaaca084179d9e3d32904e9c40bdeR64 . P25Q32H support was upstreamed some time ago: https://github.com/apache/mynewt-core/pull/2798 .