Reduce nRF7002dk image size

Hello, I'm in the development stage of a product and currently evaluating the nRF5340 as our main processor and nRF7002 as a companion IC for WiFi. Our application can be used in a wide variety of connectivity environments, so we require a WiFi interface, Ethernet interface, a cellular/GPS modem, and BLE. Also, we want to make MQTTS/HTTPS connections to our cloud provider. I've gotten a lot of these individual components to work individually by building our app to run on a nRF7002dk; however, I'm running into issues with the size of the image being too big when I try to include all of the necessary config variables in my build. Is what I'm attempting to do infeasible? My current build is overflowing RAM by 71,272 bytes and Flash is overflowed by 10,160 bytes. I can share my board overlays and configuration files. To be clear, I'm using NCS version 2.8.0, and building an application with nrf/7002dk/nrf5340/cpuapp/ns board as the target.

4336.prj.conf sysbuild.conf 3731.nrf7002dk_nrf5340_cpuapp_ns.conf nrf7002dk_nrf5340_cpuapp_ns.overlay

Parents
  • From my current experience, this is a hard thing to get to work. As you say, all the individual samples will work, but trying to combine the functionalities into a real application is another kettle of fish... My device has networking (wifi/wpa/IPv4/httpS/mqtt to the cloud with JSON parsing), BLE GATT server, BLE ibeacon scanning and emission, serial comm, NFC emulation, audio (I2S and PDM), USB (VCOM and FAT file system), GPIO & I2C for sensors and battery management, ePaper display with touch....  The benefit of the Nordic/zephyr environment is that a lot of useful library/subsystem/driver code is provided, the disadvantage is the complexity to get everything to co-exist (Zephyr is particularly hard I find...)

    An external flash chip to allow DTU (OTA or via USB) is a must (for the secondary image slot), also to store the 128kb required for the wifi nrf70 patches (in theory, haven't got this to work yet). Then, your bootloader (mcuboot) takes up 64kb in real life (because you need the serial DTU/USB option just in case an OTA error bricks it....), leaving you with around 970kB for the app... this seems large, but the whole wifi+WPA supp+TCP+TLS crypto block will use an large percentage of that! 

    For the RAM, I have managed to get an operational config, but only by time consuming tuning of the heap sizes, prj.conf parameters etc... and the interdependancies between these are very much NOT clearly documented in either Zephyr or the Nordic docs.  I don't think its possible to add RAM to the nrf5340 as far as I know, which makes the 440kB you actually have to play with be a major difficulty.

    I can't tell you that definitively it is possible, as right now I cannot get the mbedtls part to actually fit in the space and also work for https connections!

  • Hello Brian,

    I am sorry to hear that. I find that getting things to co-exist is also something that Zephyr does well, the issue is when the components are as memory hungry as the Wi-Fi ones are. Or that for instance Matter and LE Audio is. 

    Is upgrading to 54 an option for you? The amount of features you need might warrant that. 

    Regards,

    Elfving

  • not an error message, but it does say:

    warning: MBEDTLS_ECP_C (defined at C:/ncs/v2.8.0/nrf\modules/trusted-
    firmware-m/Kconfig.mbedtls_minimal.defconfig:41,
    C:/ncs/v2.8.0/nrf\subsys\nrf_security\Kconfig.legacy:557,
    C:/ncs/v2.8.0/zephyr/modules/mbedtls\Kconfig.tls-generic:157, modules\mbedtls\Kconfig.tls-
    generic:157) was assigned the value 'n' but got the value 'y'. See
    docs.zephyrproject.org/.../kconfig.html and/or look up MBEDTLS_ECP_C
    in the menuconfig/guiconfig interface. The Application Development Primer, Setting Configuration
    Values, and Kconfig - Tips and Best Practices sections of the manual might be helpful too.

    which is a lot of blah for not much actual help.

    I tried setting 

    CONFIG_WIFI_NM_WPA_SUPPLICANT_CRYPTO=n
    but this seems to have no effect (no warning, no error, wpa-supp still works for WPA2, code size is not reduced, ECP is still compiled in...
  • Hi Brian, and sorry about the wait. 

    BrianW said:
    CONFIG_WIFI_NM_WPA_SUPPLICANT_CRYPTO=n
    but this seems to have no effect (no warning, no error, wpa-supp still works for WPA2, code size is not reduced, ECP is still compiled in...

    The configuration system can be a bit confusing at times, some configs might select certain others, making it difficult to deselect them if you don't know what is selecting what. We can look into this, but as this issue is progressing a bit beyond OPs original issue, it might be best if you could open a new case with this problem. We prefer to get the tickets focused on one issue.

    Regards,

    Elfving

  • but as this issue is progressing a bit beyond OPs original issue,

    The original issue is how to reduce nrf7002dk image size using wifi : so how to remove components like ECP crypto to be able to reduce the image size feels pretty much in line with the original question, no?

  • BrianW said:
    The original issue is how to reduce nrf7002dk image size using wifi : so how to remove components like ECP crypto to be able to reduce the image size feels pretty much in line with the original question, no?

    It is related to the same subject, but is not an issue the OP is necessarily facing. 

    I wouldn't recommend disabling CONFIG_MBEDTLS_ECP_C, but in order to do that you would have to disable every config that selects it.  

    For recommended configs to disable in order to save memory (which as I understand it, is your main goal) you should rather see here.

    Regards,

    Elfving

  • For recommended configs to disable in order to save memory (which as I understand it, is your main goal) you should rather see here.

    thanks, but I already worked through all the points there : and there aren't any realistic options that reduce the executable size (while keeping basic wifi STA functionality)

    I wouldn't recommend disabling CONFIG_MBEDTLS_ECP_C, but in order to do that you would have to disable every config that selects it.  

    Alas this seems to be impossible while using the WPA_SUPP module, as this is not finely grained anough to remove certain crypto suites...

    Ok, for the moment its a dead end.

Reply Children
Related