AWS IOT example - utilizing ~92.5% flash without configuration changes on 7002DK

Hi Nordic Support Team,I'm experiencing severe memory constraints with the AWS IoT Core example on the nRF7002DK (nRF5340) that make it impractical for real-world applications requiring WiFi provisioning and custom functionality.

Current Memory Usage:

Memory region         Used Size  Region Size  %age Used
           FLASH:      742308 B       784 KB     92.46%
             RAM:      327392 B       400 KB     79.93%
        IDT_LIST:          0 GB        32 KB      0.00%

I appreciate that the example includes comprehensive crypto and certificate handling, but the current memory footprint makes it challenging to build practical applications on top of it.

The AWS IoT Core example leaves only ~40KB of flash memory available, which is insufficient for adding WiFi provisioning logic and custom application code that would be required in a production scenario

Build Configuration:

  • SDK: nRF Connect SDK v3.1.1
  • Toolchain: nRF Connect SDK Toolchain v3.1.1
  • Board target: nrf7002dk/nrf5340/cpuapp/ns
  • Extra Kconfig fragments: boards/nrf7002dk_nrf5340_cpuapp_ns.conf
  • Optimization level: Use project default
  • Build directory: build
  • System build (sysbuild):
  • Build system default
  • Use sysbuild: Yes
  • No sysbuild: No

Key Configuration Details:

  • Using external flash (mx25r64) for partition manager
  • FOTA enabled (required for our use case)
  • TF-m optimizations are applied.

Attempts Made:

  1. Tried building without /ns suffix: Build failed
  1. WiFi Firmware Patches: I understand these could potentially be moved to save space, but I've seen Nordic support advise against relocating them - seems complicated with FOTA, but does give 83KB. I was not able to get this to apply to the project successfuly.

Requirements:

  • FOTA capability (non-negotiable)
  • WiFi provisioning functionality
  • IOT Core shadow states and telemetry.
  • Production-ready security (not necessarily using TF-M). but SSL/https required.

Questions:

  1. What would be the easiest Flash saving for a project based on this example, given that FOTA is needed.
  1. What is the official guidance on building without TF-M (/ns) for production applications? What security implications should we consider?
  1. Is there a way to optimize the TF-M memory allocation to reclaim some of the apparent 16KB waste in trustzone storage? Or shrink the 128KB it is taking?

    If its not possible to make quite big savings, I'll consider not using IOT core, but it requires doing all the telemetry and much more work on the FOTA manually.

Any guidance on the largest bang for buck memory optimization strategies or alternative starting point would be greatly appreciated.

Kind Regards

Dan

  • Hi Dan,

    You are right in that flash space can be a problem with the nRF7002 stack, unfortunately. We have some documentations with things that could be tried though, but what you can configure would of course depend on the application. Have you seen this, this and this for instance?

    Is switching to the nRF54Ls an option for you?

    Regards,

    Elfving

  • Hi,

    Thanks for getting back to me.

    Switching to the nRF54L will seemingly have too little RAM (max 256KB and we are at 80% with the example with 512KB+64KB? on the nrf53)? So that doesn't look viable.

    Thanks for sharing those links, have come across them. While they do look worth exploring - most of them look like they are RAM saving measures. My expectation is that I'll manage to shave a few KB of flash, not 10s of KB using that alone.

    Could you get back to me on XIP for the wifi patches? I can't find any clear documentation on how that interacts with FOTA.

    Are my other questions regarding different ways of building (around the TF-M, potentially not using it) worth exploring?

    Regards

    Dan

     

  • ddavson said:
    Switching to the nRF54L will seemingly have too little RAM (max 256KB and we are at 80% with the example with 512KB+64KB? on the nrf53)? So that doesn't look viable.

    Have you considered the new nrf54LM20? It has 512 KB RAM.

    ddavson said:

    Thanks for sharing those links, have come across them. While they do look worth exploring - most of them look like they are RAM saving measures. My expectation is that I'll manage to shave a few KB of flash, not 10s of KB using that alone.

    Yeah. It depends on the application of course, but that might be right. 

    ddavson said:

    Could you get back to me on XIP for the wifi patches? I can't find any clear documentation on how that interacts with FOTA.

    There is some documentation on this here for instance and here.

    ddavson said:

    Are my other questions regarding different ways of building (around the TF-M, potentially not using it) worth exploring?

    What is the official guidance on building without TF-M (/ns) for production applications? What security implications should we consider?

    Without TF-M you wouldn't get several security features, like no PSA RoT or APIs, no secure DFU. It is generally considered good practice to have layers of security, eg. security by separation, but there is also an increasing focus on security certifications these days, which are slowly becoming mandated. So what features you would need might also depend on what markets you'd like to potentially sell your products in. Have a look here for a bit on the EU market for instance.

    Is there a way to optimize the TF-M memory allocation to reclaim some of the apparent 16KB waste in trustzone storage? Or shrink the 128KB it is taking?

    Yeah there are a few configs you can try. Have you had a look at the minimal profile CONFIG_TFM_PROFILE_TYPE_MINIMAL?

    Regards,

    Elfving

  • Hi

    NRF54L20
    I had been looking at https://www.nordicsemi.com/-/media/Publications/WQ-Product-guide/Nordic-Product-Comparison-table-WQ-Dec-2024.pdf so was not aware the NRF54L20 was released! That's great that its been released! We could consider it - how do i get hold of an EVK? Mouser etc show no stock.

    Flash savings:

    overlay-memory-optimized.conf used marginally more flash (so confirms that its mostly RAM optimizations)


    FYI - some flash saving measures I've found - and for others reading the thread in future:

    CONFIG_WIFI_NM_WPA_SUPPLICANT_WPA3=n # 17KB flash saving

    CONFIG_NET_IPV6=y # saves 36KB, a problem if we want thread/matter? breaks fota, but may be solvable (downloader fails).

    Of course disabling the shell is also significant (around >30KB). Inconvenient for development though.

    XiP / Wifi Patches


    Do you know why XIP not supported on the EVK?

    Do you know how much RAM will be used using externally stored patches loaded into RAM? I'd like to know this before trying it as it's a dead end if its the full 83KB thats stored in flash.

    Regards

    Dan


    CONFIG_TFM_PROFILE_TYPE_MINIMAL=y fails for IOT core example - the SSL relies on it. The options selected for the example use basically the full 128KB (122KB) and you can't really save the rest because of the alignment restrictions - less of a problem on the 54 series, so thanks for sharing that link too.

  • Hope you've had a nice week-end Dan,

    ddavson said:

    I had been looking at https://www.nordicsemi.com/-/media/Publications/WQ-Product-guide/Nordic-Product-Comparison-table-WQ-Dec-2024.pdf so was not aware the NRF54L20 was released! That's great that its been released! We could consider it - how do i get hold of an EVK? Mouser etc show no stock.

    Please contact your local RSM for that, or let me know if you need her contact info. For that though I would need to make the case private, since I do not want to spread that info into the open.

    ddavson said:

    Do you know why XIP not supported on the EVK?

    I believe this is because the flash on that is connected with SPI, and you need QSPI for XiP.

    ddavson said:
    Do you know how much RAM will be used using externally stored patches loaded into RAM? I'd like to know this before trying it as it's a dead end if its the full 83KB thats stored in flash.

    You can transfer it in configurable chunk sizes.

    ddavson said:
    CONFIG_TFM_PROFILE_TYPE_MINIMAL=y fails for IOT core example - the SSL relies on it. The options selected for the example use basically the full 128KB (122KB) and you can't really save the rest because of the alignment restrictions - less of a problem on the 54 series, so thanks for sharing that link too.

    Glad it works on devices with a larger flash. So yeah, if I understood you correctly, that was not really a question

    Regards,

    Elfving

Related