Utilize external flash with nrf9160 SiP on Custom board.

Hi,

I would like to use the external flash to increase the internal flash, no intention, at the moment, to use it for MCUBoot file or FOTA .

How do I configure it, if it is even possible.

Info:

- nRF Connect SDK: 2.0.0

- nrf9160 SiP on custom board.

- Flash commuincate over SPI.

- Flash is working.

Thanks in advance.

Parents
  • Hi,

    Yes, this is possible.

    On our nRF9160DK, we have an external flash, and you can see a sample for testing this at nRF9160: HTTP application update using the nRF9160DK's external flash.
    This sample is for v1.7.0, but it is possible to do the same for v2.0.0.

    Regards,
    Sigurd Hellesvik

  • Thank you.

    After setting up the external flash in the .overlay file:

    nordic,pm-ext-flash = &mx25r16;
    It builds fine but when running the program this is what I get:
    When getting the partition_manager_report:
    external_flash (0x200000 - 2048kB):
    +---------------------------------------------+
    | 0x0: mcuboot_secondary (0xe8000 - 928kB) |
    | 0xe8000: external_flash (0x118000 - 1120kB) |
    +---------------------------------------------+
    
    flash_primary (0x100000 - 1024kB):
    +--------------------------------------------------+
    | 0x0: mcuboot (0xc000 - 48kB) |
    | 0xc000: EMPTY_0 (0x4000 - 16kB) |
    +---0x10000: mcuboot_primary (0xe8000 - 928kB)-----+
    +---0x10000: tfm_secure (0xc200 - 48kB)------------+
    | 0x10000: mcuboot_pad (0x200 - 512B) |
    +---0x10200: mcuboot_primary_app (0xe7e00 - 927kB)-+
    | 0x10200: tfm (0xc000 - 48kB) |
    +---0x1c200: tfm_nonsecure (0xdbe00 - 879kB)-------+
    | 0x1c200: app (0xdbe00 - 879kB) |
    +---0xf8000: nonsecure_storage (0x2000 - 8kB)------+
    | 0xf8000: settings_storage (0x2000 - 8kB) |
    +--------------------------------------------------+
    | 0xfa000: EMPTY_1 (0x6000 - 24kB) |
    +--------------------------------------------------+
    
    otp (0x2f4 - 756B):
    +------------------------------+
    | 0xff8108: otp (0x2f4 - 756B) |
    +------------------------------+
    
    sram_primary (0x40000 - 256kB):
    +--------------------------------------------------+
    +---0x20000000: sram_secure (0x10000 - 64kB)-------+
    | 0x20000000: tfm_sram (0x10000 - 64kB) |
    +---0x20010000: sram_nonsecure (0x30000 - 192kB)---+
    +---0x20010000: nrf_modem_lib_sram (0x44e8 - 17kB)-+
    | 0x20010000: nrf_modem_lib_ctrl (0x4e8 - 1kB) |
    | 0x200104e8: nrf_modem_lib_tx (0x2000 - 8kB) |
    | 0x200124e8: nrf_modem_lib_rx (0x2000 - 8kB) |
    +--------------------------------------------------+
    | 0x200144e8: sram_primary (0x2bb18 - 174kB) |
    +--------------------------------------------------+
    When I tried to add this to the .prj file:
    CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=n
    This works as expected.
    My question is now; Is it possible to utilize the external flash compile time?
    The HTTP sample uses it run time, correct me if I'm wrong on that.
    Another question is: the external flash do not have the correct size, even though I have added the size to the spi setup in the .overlay file. Do I need to add a pm_static.yml for getting the correct sized configured?
  • If the total size is 0x200000, try this

    external_flash:
      address: 0x0
      end_address: 0x1000000
      region: external_flash
      size: 0x1000000
    empty_placeholder_partition:
      address: 0x1000000
      end_address: 0x2000000
      region: external_flash
      size: 0x1000000

    Regards,
    Sigurd Hellesvik

  • I still get the same build error.

    I cannot increase the size of the external flash to more than 0x200000. 

  • That number is in decimal. 2097152 = 0x200000

    In my below sample I think I have too many Zeros.

    Try to change it to use 100 000 and 200 000 instead.

    Regards,
    Sigurd Hellesvik

  • Okay, I have misunderstood the purpose of the pm_static.yml file.

    Everything is building fine now and the partition_manager_report makes sense to me.

    But now I'm back to:

     

    I have been following along with this thread:  RE: MCUBoot, Zephyr, and static partition manager 

    There is a difference, I get an ERROR: Image in the primary slot is not valid! - So maybe there is an another problem.

    Hope you can help. 

  • In my experience, the warning  "W: Failed reading sectors; BOOT_MAX_IMG_SECTORS=128 - too small?" can mean two things:

    1. CONFIG_BOOT_MAX_IMG_SECTORS is too small. Try setting this to 256 in mcuboot.conf.
    2. The external flash driver has not been initialized for MCUboot.
      Have you configured Using external flash memory partitions, and more specifically, External flash memory partitions?

    Regards,
    Sigurd Hellesvik

Reply Children
Related