Regarding flash overflow when dfu is enabled

I am working on a module MS12SF1(nrf7002+nrf5340). I am using wifi,ble,sdcard,uart and https functionalities in my code. Currently my flash usage is 72.44%. I also want to use dfu through ble. If I enable the configurations of dfu, the flash overflows by 270940 bytes.

I don't know what else I should optimise to solve this.

I am using nrf sdk v2.6.1

This is my prj.conf file

# Wi-Fi
CONFIG_WIFI=y
CONFIG_WIFI_NRF700X=y
CONFIG_WPA_SUPP=y

# Wi-Fi credentials
CONFIG_WIFI_CREDENTIALS=y
CONFIG_WIFI_CREDENTIALS_STATIC=y
CONFIG_WIFI_CREDENTIALS_STATIC_SSID="UltraHuman-4th Floor"
CONFIG_WIFI_CREDENTIALS_STATIC_PASSWORD="Ultra@Human$!"

# Networking Management API
CONFIG_NET_MGMT=y
CONFIG_NET_MGMT_EVENT=y
CONFIG_NET_MGMT_EVENT_INFO=y
CONFIG_NET_MGMT_EVENT_STACK_SIZE=4096
CONFIG_NET_CONNECTION_MANAGER=y
CONFIG_WIFI_MGMT_EXT=y


# DK library
CONFIG_DK_LIBRARY=n

# System settings
CONFIG_NEWLIB_LIBC=y
CONFIG_NEWLIB_LIBC_NANO=y
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=n

# Networking
CONFIG_NETWORKING=y
CONFIG_NET_NATIVE=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_POSIX_MAX_FDS=12

CONFIG_NET_L2_ETHERNET=y
CONFIG_NET_IPV4=y
CONFIG_NET_IPV6=n
CONFIG_NET_TCP=y
CONFIG_NET_DHCPV4=y
CONFIG_DNS_RESOLVER=y

# Memory
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
CONFIG_MAIN_STACK_SIZE=4096
CONFIG_HEAP_MEM_POOL_SIZE=153600

CONFIG_NET_TCP_WORKQ_STACK_SIZE=2048
CONFIG_NET_TX_STACK_SIZE=4096
CONFIG_NET_RX_STACK_SIZE=4096
CONFIG_NET_BUF_RX_COUNT=20
CONFIG_NET_BUF_TX_COUNT=20

CONFIG_NET_BUF_DATA_SIZE=256
CONFIG_NET_TC_TX_COUNT=0

# # HTTP
# STEP 1 -  Enable the HTTP client library
CONFIG_HTTP_CLIENT=y

CONFIG_LOG=y
CONFIG_USE_SEGGER_RTT=y
CONFIG_LOG_BACKEND_RTT=y
CONFIG_LOG_BACKEND_UART=n
CONFIG_LOG_PRINTK=y

CONFIG_USE_SEGGER_RTT=y
CONFIG_RTT_CONSOLE=y
CONFIG_CBPRINTF_FP_SUPPORT=y

# Enable the UART driver
CONFIG_UART_ASYNC_API=y                             #to enable the asynchronous API of the serial driver.
CONFIG_NRFX_UARTE0=y
CONFIG_SERIAL=y                                     #to enable serial support in code like uart

CONFIG_GPIO=y

# Make sure printk is printing to the UART console
CONFIG_CONSOLE=y
# CONFIG_UART_CONSOLE=n

CONFIG_SETTINGS=y                                   #Enables the settings subsystem
CONFIG_FLASH=y                                      #Enables the flash drivers
CONFIG_FLASH_PAGE_LAYOUT=y                          #API for retrieving the layout of pages
CONFIG_FLASH_MAP=y                                  #Enables the flash map abstraction module
CONFIG_NVS=y                                       #Enables support for non-volatile storage




CONFIG_CLOCK_CONTROL_NRF_K32SRC_SYNTH=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_XTAL=n
# CONFIG_SOC_ENABLE_LFXO=n 

#for system uptime
# CONFIG_TIMESLICING=y

#for sd card
CONFIG_DISK_ACCESS=y

CONFIG_FILE_SYSTEM=y
CONFIG_FAT_FILESYSTEM_ELM=y

# CONFIG_DEBUG_OPTIMIZATIONS=y
CONFIG_DEBUG=n

CONFIG_SIZE_OPTIMIZATIONS=y

# CONFIG_NET_BUF_TX_COUNT=40
# CONFIG_NET_BUF_RX_COUNT=40
# CONFIG_NET_BUF_VARIABLE_DATA_SIZE=y
# CONFIG_NET_RX_STACK_SIZE=4096
# CONFIG_NET_TCP_WORKQ_STACK_SIZE=2048

# CONFIG_NET_PKT_TX_COUNT=20
# CONFIG_NET_PKT_RX_COUNT=20

# CONFIG_NET_BUF_POOL_USAGE=y

# CONFIG_WIFI_LOG_LEVEL_DBG=y
# # Memory statistics and debugging
# CONFIG_THREAD_ANALYZER=y
# CONFIG_THREAD_ANALYZER_AUTO=y
# CONFIG_STACK_SENTINEL=y
# CONFIG_INIT_STACKS=y
# CONFIG_ASSERT=y
# CONFIG_ASSERT_LEVEL=2
# CONFIG_UART_0_NRF_HW_ASYNC=y

# CONFIG_SYS_HEAP_ALLOC_LOOPS=3
# CONFIG_SYS_HEAP_RUNTIME_STATS=y
# CONFIG_PM_DEVICE=n
# CONFIG_UART_0_NRF_HW_ASYNC_TIMER=2
# CONFIG_UART_0_NRF_HW_ASYNC=y

# Microphone (PDM) configuration
CONFIG_NRFX_PDM=y
CONFIG_REBOOT=n

CONFIG_PSA_WANT_ALG_DETERMINISTIC_ECDSA=y
# CONFIG_PSA_WANT_ALG_ECDSA=y
# CONFIG_PSA_WANT_KEY_TYPE_ECC_KEY_PAIR=y
CONFIG_PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY=y

# CONFIG_PSA_WANT_KEY_TYPE_ECC_KEY_PAIR_BASIC=n
CONFIG_PSA_WANT_ALG_HMAC=y


# CONFIG_PRINTK=y
CONFIG_FS_FATFS_LFN=y
CONFIG_TLS_CREDENTIALS=y


CONFIG_RESET_ON_FATAL_ERROR=n
CONFIG_SETTINGS=y
CONFIG_SETTINGS_NVS=y

CONFIG_WPA_SUPP_CRYPTO_PSA=y

# # TLS
# # STEP 1.1 - Enable the TLS library and security relevant configurations
CONFIG_NET_SOCKETS_SOCKOPT_TLS=y
CONFIG_TLS_CREDENTIALS=y
CONFIG_MBEDTLS_RSA_C=y
CONFIG_MBEDTLS_DHM_C=y 

# # # STEP 1.2 - Enable support for server name indication (SNI)
CONFIG_MBEDTLS_SSL_SERVER_NAME_INDICATION=y


CONFIG_MBEDTLS=y
CONFIG_MBEDTLS_TLS_LIBRARY=y
CONFIG_TLS_CREDENTIALS_BACKEND_PROTECTED_STORAGE=y


CONFIG_POSIX_CLOCK=y

CONFIG_NET_CONNECTION_MANAGER=y
CONFIG_NET_CONNECTION_MANAGER_MONITOR_STACK_SIZE=1024

# CONFIG_BUILD_WITH_TFM=y

CONFIG_NORDIC_SECURITY_BACKEND=y
CONFIG_CC3XX_BACKEND=y
CONFIG_MBEDTLS_TLS_LIBRARY=y
CONFIG_MBEDTLS_ECDSA_DETERMINISTIC=n
CONFIG_MBEDTLS_SSL_SRV_C=n
CONFIG_MBEDTLS_X509_CSR_WRITE_C=y
CONFIG_MBEDTLS_X509_CREATE_C=y
CONFIG_MBEDTLS_PK_WRITE_C=y
CONFIG_MBEDTLS_SSL_SERVER_NAME_INDICATION=y
CONFIG_MBEDTLS_PKCS1_V15=y

# For hardware crypto accelerator
CONFIG_PSA_CRYPTO_DRIVER_OBERON=n
CONFIG_PSA_CRYPTO_DRIVER_CC3XX=y

CONFIG_MBEDTLS_PSA_CRYPTO_C=y
CONFIG_MBEDTLS_ENABLE_HEAP=y
CONFIG_MBEDTLS_HEAP_SIZE=81920
CONFIG_MBEDTLS_ENABLE_HEAP=y
CONFIG_MBEDTLS_MAC_SHA256_ENABLED=y
# CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=8192
CONFIG_MBEDTLS_TLS_LIBRARY=y
# CONFIG_MBEDTLS=y
# CONFIG_MBEDTLS_ENABLE_HEAP=y
# CONFIG_MBEDTLS_LEGACY_CRYPTO_C=y
# CONFIG_PSA_WANT_RSA_KEY_SIZE_4096=y

# CONFIG_CC3XX_BACKEND=y
# CONFIG_OBERON_BACKEND=n
# CONFIG_MBEDTLS_HEAP_SIZE=81920


#To enable BLE
CONFIG_BT=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEVICE_NAME="UH_112233445566"
CONFIG_BT_MAX_CONN=1
CONFIG_BT_MAX_PAIRED=1
CONFIG_BT_SETTINGS=y
CONFIG_BT_HCI_IPC=y

# CONFIG_BT_SMP=y
CONFIG_BT_DEVICE_NAME_DYNAMIC=y

# Enable the NUS service
CONFIG_BT_NUS=y

# CONFIG_BT_ATT_PREPARE_COUNT=4
CONFIG_BT_L2CAP_TX_MTU=300
# CONFIG_BT_L2CAP_TX_BUF_COUNT=10
# CONFIG_BT_L2CAP_TX_FRAG_COUNT=15
CONFIG_BT_BUF_EVT_RX_SIZE=251
CONFIG_BT_BUF_CMD_TX_SIZE=251
CONFIG_BT_BUF_ACL_RX_SIZE=300
# CONFIG_BT_BUF_ACL_TX_COUNT=15
# CONFIG_BT_BUF_ACL_TX_SIZE=251
# CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
# CONFIG_BT_CONN_TX_MAX=10

# CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU_SPEEDUP=y
CONFIG_BT_USER_DATA_LEN_UPDATE=y

CONFIG_BT_GATT_CLIENT=y

# CONFIG_BT_NUS_THREAD_STACK_SIZE= 4096


CONFIG_SNTP=y
CONFIG_NET_UDP=y

# CONFIG_HW_STACK_PROTECTION=y
# CONFIG_STACK_CANARIES=y
# CONFIG_STACK_SENTINEL=y
# CONFIG_INIT_STACKS=y
# CONFIG_THREAD_STACK_INFO=y

# CONFIG_LOG_PROCESS_THREAD_STACK_SIZE=2048

# CONFIG_NET_SOCKETS_OFFLOAD=n
# Enable additional buffers
# CONFIG_DNS_RESOLVER_ADDITIONAL_BUF_CTR=5
# # # Enable additional queries
# CONFIG_DNS_RESOLVER_ADDITIONAL_QUERIES=2
# CONFIG_DNS_RESOLVER_MAX_SERVERS=4

CONFIG_NET_LOG=y

# CONFIG_DNS_NUM_CONCUR_QUERIES=2
# CONFIG_DNS_RESOLVER_AI_MAX_ENTRIES=4

# for dns logs
# CONFIG_DNS_RESOLVER_LOG_LEVEL_DBG=y
# CONFIG_NET_SOCKETS_LOG_LEVEL_DBG=y
# # CONFIG_NET_SHELL=y

# CONFIG_NET_CONFIG_SCONFIG_NET_PING=y

# CONFIG_NFCT_PINS_AS_GPIOS=y
# CONFIG_NET_SOCKETS_DNS_TIMEOUT=8000

# # # # DFU THROUGH BLE
CONFIG_BOOTLOADER_MCUBOOT=y
# #Include MCUMGR and the dependencies in the build
CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y
# CONFIG_BT_DEBUG_LOG=n


This is my nrf7002dk_nrf5340_cpuapp.conf file

CONFIG_DISK_DRIVER_SDMMC=y
CONFIG_SPI=y
CONFIG_DISK_DRIVERS=y

CONFIG_WIFI_CREDENTIALS_BACKEND_SETTINGS=y





  • Hi, 

    It's possible to run the full Bluetooth LE stack on the network core (currently supported for development only), but not for the network. See this doc

    -Amanda H.

  • Hey
    I was curious that can we do something like that if I enable the BOOTLOADER_MCUBOOT configuration it doesn't creates 2 slots and creates a single slot with more size and when we want to add a new firmware it can get replaced with the older one?

    Actually I saw one more configuration CONFIG_SINGLE_APPLICATION_SLOT which does this but I think it doesn't supports dfu through ble so won't be helping but if I could make a change in the existing procedure which will still support dfu through ble that could be very helpful

  • So actually for the net core I wanted to move all the other configurations except the network related to net core including the main application too 
    Wanted to test it once, how can I make a separate source file for net core and run it along with the app core?

  • Hi,

    Rakshita said:
    can we do something like that if I enable the BOOTLOADER_MCUBOOT configuration it doesn't creates 2 slots and creates a single slot with more size and when we want to add a new firmware it can get replaced with the older one?

    The CONFIG_SINGLE_APPLICATION_SLOT is only supported with DFU via USB/UART, not for BLE DFU. 

    Rakshita said:
    So actually for the net core I wanted to move all the other configurations except the network related to net core including the main application too 
    Wanted to test it once, how can I make a separate source file for net core and run it along with the app core?

    The net core is for radio communication and for real-time processing tasks involving low-level radio protocol layers. You cannot move all the other configurations except the network related to net core. 

    For your use case, I would suggest using an external flash as the secondary slot for BLE DFU. 

    -Amanda H.

  • Do we have any sample code for fota over wifi through http/https?

Related