FLASH overflow when merging AWS IoT MQTT sample into existing project (TF-M overflow issue)

Hi,

We have an existing nRF91 (nRF9151) project (NCS 2.9.0) that already includes multiple modules such as ECG, external flash, RTC, modem, etc.
Now we want to integrate AWS IoT MQTT functionality directly into our main application.

Since our original project did not have a prj.conf for AWS IoT, we manually merged the Kconfig and options from the aws_iot_mqtt sample into our existing configuration.

The project builds until TF-M, but after merging AWS configs, the build fails with a FLASH overflow inside TF-M

EMPTY_0:
  address: 0xc000
  end_address: 0x10000
  placement:
    before:
    - mcuboot_pad
  region: flash_primary
  size: 0x4000
EMPTY_1:
  address: 0xfe000
  end_address: 0x100000
  placement:
    after:
    - nvs_storage
  region: flash_primary
  size: 0x2000
EMPTY_2:
  address: 0xf0000
  end_address: 0xf8000
  placement:
    after:
    - mcuboot_secondary
  region: flash_primary
  size: 0x8000
app:
  address: 0x18000
  end_address: 0x80000
  region: flash_primary
  size: 0x68000
mcuboot:
  address: 0x0
  end_address: 0xc000
  placement:
    align:
      end: 0x1000
    before:
    - mcuboot_primary
  region: flash_primary
  size: 0xc000
mcuboot_pad:
  address: 0x10000
  end_address: 0x10200
  placement:
    align:
      start: 0x8000
    before:
    - mcuboot_primary_app
  region: flash_primary
  size: 0x200
mcuboot_primary:
  address: 0x10000
  end_address: 0x80000
  orig_span: &id001
  - mcuboot_pad
  - app
  - tfm
  region: flash_primary
  sharers: 0x1
  size: 0x70000
  span: *id001
mcuboot_primary_app:
  address: 0x10200
  end_address: 0x80000
  orig_span: &id002
  - app
  - tfm
  region: flash_primary
  size: 0x6fe00
  span: *id002
mcuboot_secondary:
  address: 0x80000
  end_address: 0xf0000
  placement:
    after:
    - mcuboot_primary
    align:
      start: 0x8000
  region: flash_primary
  share_size:
  - mcuboot_primary
  size: 0x70000
mcuboot_sram:
  address: 0x20000000
  end_address: 0x20008000
  orig_span: &id003
  - tfm_sram
  region: sram_primary
  size: 0x8000
  span: *id003
nonsecure_storage:
  address: 0xf8000
  end_address: 0xfe000
  orig_span: &id004
  - nvs_storage
  region: flash_primary
  size: 0x6000
  span: *id004
nrf_modem_lib_ctrl:
  address: 0x20008000
  end_address: 0x200084e8
  inside:
  - sram_nonsecure
  placement:
    after:
    - tfm_sram
    - start
  region: sram_primary
  size: 0x4e8
nrf_modem_lib_rx:
  address: 0x2000a568
  end_address: 0x2000c568
  inside:
  - sram_nonsecure
  placement:
    after:
    - nrf_modem_lib_tx
  region: sram_primary
  size: 0x2000
nrf_modem_lib_sram:
  address: 0x20008000
  end_address: 0x2000c568
  orig_span: &id005
  - nrf_modem_lib_ctrl
  - nrf_modem_lib_tx
  - nrf_modem_lib_rx
  region: sram_primary
  size: 0x4568
  span: *id005
nrf_modem_lib_tx:
  address: 0x200084e8
  end_address: 0x2000a568
  inside:
  - sram_nonsecure
  placement:
    after:
    - nrf_modem_lib_ctrl
  region: sram_primary
  size: 0x2080
nvs_storage:
  address: 0xf8000
  end_address: 0xfe000
  inside:
  - nonsecure_storage
  placement:
    align:
      start: 0x8000
    before:
    - end
  region: flash_primary
  size: 0x6000
otp:
  address: 0xff8108
  end_address: 0xff83fc
  region: otp
  size: 0x2f4
sram_nonsecure:
  address: 0x20008000
  end_address: 0x20040000
  orig_span: &id006
  - sram_primary
  - nrf_modem_lib_ctrl
  - nrf_modem_lib_tx
  - nrf_modem_lib_rx
  region: sram_primary
  size: 0x38000
  span: *id006
sram_primary:
  address: 0x2000c568
  end_address: 0x20040000
  region: sram_primary
  size: 0x33a98
sram_secure:
  address: 0x20000000
  end_address: 0x20008000
  orig_span: &id007
  - tfm_sram
  region: sram_primary
  size: 0x8000
  span: *id007
tfm:
  address: 0x10200
  end_address: 0x18000
  inside:
  - mcuboot_primary_app
  placement:
    before:
    - app
  region: flash_primary
  size: 0x7e00
tfm_nonsecure:
  address: 0x18000
  end_address: 0x80000
  orig_span: &id008
  - app
  region: flash_primary
  size: 0x68000
  span: *id008
tfm_secure:
  address: 0x10000
  end_address: 0x18000
  orig_span: &id009
  - mcuboot_pad
  - tfm
  region: flash_primary
  size: 0x8000
  span: *id009
tfm_sram:
  address: 0x20000000
  end_address: 0x20008000
  inside:
  - sram_secure
  placement:
    after:
    - start
  region: sram_primary
  size: 0x8000


# log
CONFIG_LOG=y
CONFIG_LOG_MODE_DEFERRED=y # for non-bloking mode
CONFIG_LOG_BUFFER_SIZE=4096
CONFIG_LOG_PROCESS_THREAD_SLEEP_MS=10
CONFIG_LOG_PROCESS_THREAD_STACK_SIZE=2048
CONFIG_CBPRINTF_FP_SUPPORT=y

# LOG ON RTT NOT UART0
CONFIG_CONSOLE=n #for wifi uart keep this n
CONFIG_USE_SEGGER_RTT=y
CONFIG_RTT_CONSOLE=y
CONFIG_LOG_BACKEND_RTT=y
CONFIG_LOG_BACKEND_UART=n
CONFIG_UART_CONSOLE=n

# stack_size
# CONFIG_MAIN_STACK_SIZE=14336
CONFIG_MAIN_STACK_SIZE=6144
# by default 2048
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
CONFIG_HEAP_MEM_POOL_SIZE=5120

# clock
CONFIG_CLOCK_CONTROL_NRF_K32SRC_XTAL=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=n

# configuration of i2c and spi
CONFIG_I2C=y
CONFIG_SPI=y
CONFIG_SENSOR=y
# tfm disable for use uart1 as spi1
CONFIG_TFM_SECURE_UART=n
CONFIG_TFM_LOG_LEVEL_SILENCE=y

# configuration for LIS2DW12
# CONFIG_LIS2DW12=y
# CONFIG_LIS2DW12_TRIGGER_GLOBAL_THREAD=y
# CONFIG_LIS2DW12_THRESHOLD=y
CONFIG_LIS2DW12=y
CONFIG_LIS2DW12_TAP=y
CONFIG_LIS2DW12_TRIGGER_OWN_THREAD=y


# configuration for hw id
CONFIG_HW_ID_LIBRARY=y
CONFIG_HW_ID_LIBRARY_SOURCE_DEVICE_ID=y

# configuration for fuel gauge npm1300
CONFIG_REGULATOR=y
CONFIG_NRF_FUEL_GAUGE=y
CONFIG_LED=y

# Date and time configuration
CONFIG_DATE_TIME=y
CONFIG_DATE_TIME_UPDATE_INTERVAL_SECONDS=0
CONFIG_DATE_TIME_TOO_OLD_SECONDS=0
CONFIG_DATE_TIME_NTP=y
CONFIG_NETWORKING=y
CONFIG_NET_SOCKETS=y

# for nand flash
CONFIG_DISK_ACCESS=y

# systemoff
CONFIG_PM_DEVICE=y
CONFIG_POWEROFF=y
CONFIG_DISABLE_FLASH_PATCH=y

# json
CONFIG_CJSON_LIB=y


# siw917y uart
CONFIG_SERIAL=y
CONFIG_UART_ASYNC_API=y
CONFIG_UART_0_INTERRUPT_DRIVEN=y
CONFIG_UART_0_ASYNC=y
CONFIG_NRFX_UARTE0=y


# nvs
CONFIG_NVS=y
CONFIG_FLASH=y
CONFIG_FLASH_MAP=y
CONFIG_FLASH_PAGE_LAYOUT=y



# Enable mcumgr DFU in application
# Enable MCUMGR 
CONFIG_MCUMGR=y

# Enable MCUMGR management for both OS and Images
CONFIG_MCUMGR_GRP_OS=y
CONFIG_MCUMGR_GRP_IMG=y

# Configure MCUMGR transport to UART
CONFIG_MCUMGR_TRANSPORT_UART=y

# Dependencies
# Configure dependencies for CONFIG_MCUMGR  
CONFIG_NET_BUF=y
CONFIG_ZCBOR=y
CONFIG_CRC=y

# Configure dependencies for CONFIG_MCUMGR_GRP_IMG  
CONFIG_IMG_MANAGER=y

# Configure dependencies for CONFIG_IMG_MANAGER  
CONFIG_STREAM_FLASH=y

# Configure dependencies for CONFIG_MCUMGR_TRANSPORT_UART 
CONFIG_BASE64=y

CONFIG_REBOOT=y

CONFIG_DFU_TARGET=y
CONFIG_DFU_TARGET_MCUBOOT=y


#_________________cellular_part_started_______________________



CONFIG_AWS_IOT_LOG_LEVEL_DBG=y
CONFIG_AWS_TEST_SUITE_DQP=n

CONFIG_MAIN_STACK_SIZE=8192
CONFIG_ENTROPY_GENERATOR=y
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_INIT_STACKS=y
CONFIG_HW_STACK_PROTECTION=y
CONFIG_REQUIRES_FULL_LIBC=y
CONFIG_SNTP=y
CONFIG_JSON_LIBRARY=y
CONFIG_POSIX_API=y

# DNS
CONFIG_DNS_RESOLVER=y
CONFIG_DNS_RESOLVER_ADDITIONAL_BUF_CTR=2
CONFIG_DNS_RESOLVER_MAX_SERVERS=1
CONFIG_DNS_SERVER_IP_ADDRESSES=y
CONFIG_DNS_SERVER1="8.8.8.8"
CONFIG_NET_SOCKETS_DNS_TIMEOUT=5000
CONFIG_DNS_RESOLVER_LOG_LEVEL_DBG=n

# Generic networking options
CONFIG_NETWORKING=y
CONFIG_NET_UDP=y
CONFIG_NET_TCP=y
CONFIG_NET_IPV6=y
CONFIG_NET_IPV4=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_SOCKOPT_TLS=y

# Logging
CONFIG_LOG=y

# Network buffers
CONFIG_NET_PKT_RX_COUNT=32
CONFIG_NET_PKT_TX_COUNT=16
CONFIG_NET_BUF_RX_COUNT=64
CONFIG_NET_BUF_TX_COUNT=32

# MQTT
CONFIG_MQTT_LIB=y
CONFIG_MQTT_LIB_TLS=y
CONFIG_MQTT_KEEPALIVE=600
CONFIG_MQTT_LIB_TLS_USE_ALPN=y

# TLS
CONFIG_NRF_SECURITY=y
CONFIG_MBEDTLS_TLS_LIBRARY=y
CONFIG_MBEDTLS_LEGACY_CRYPTO_C=y
CONFIG_MBEDTLS_ENABLE_HEAP=y
CONFIG_MBEDTLS_HEAP_SIZE=4096
CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=8192
CONFIG_MBEDTLS_PEM_CERTIFICATE_FORMAT=y
CONFIG_MBEDTLS_SERVER_NAME_INDICATION=y
CONFIG_MBEDTLS_AES_ROM_TABLES=y
CONFIG_MBEDTLS_TLS_VERSION_1_2=y
CONFIG_MBEDTLS_MEMORY_DEBUG=y
CONFIG_MBEDTLS_HAVE_TIME_DATE=y
CONFIG_MBEDTLS_SSL_ALPN=y

CONFIG_MBEDTLS_SSL_CLI_C=y
CONFIG_MBEDTLS_X509_CRT_PARSE_C=y
CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED=y
CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED=y
CONFIG_MBEDTLS_KEY_EXCHANGE_PSK_ENABLED=y
CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED=y

CONFIG_MBEDTLS_SSL_SRV_C=y
CONFIG_MBEDTLS_SSL_CLI_C=y
CONFIG_MBEDTLS_KEY_EXCHANGE_RSA_ENABLED=y

CONFIG_HEAP_MEM_POOL_SIZE=8192

CONFIG_MBEDTLS_CIPHER=y
CONFIG_MBEDTLS_MD=y

# Required mbedTLS dependencies
CONFIG_MBEDTLS_PK_C=y
CONFIG_MBEDTLS_PK_PARSE_C=y
CONFIG_MBEDTLS_PK_WRITE_C=y
CONFIG_MBEDTLS_RSA_C=y
CONFIG_MBEDTLS_PKCS1_V15=y
CONFIG_MBEDTLS_ECP_C=y
CONFIG_MBEDTLS_ECDSA_C=y
CONFIG_MBEDTLS_ECDH_C=y
CONFIG_MBEDTLS_DHM_C=y
CONFIG_MBEDTLS_GCM_C=y
CONFIG_MBEDTLS_SHA256_C=y
CONFIG_MBEDTLS_X509_USE_C=y
CONFIG_MBEDTLS_X509_CRT_PARSE_C=y

CONFIG_MBEDTLS_RSA_C=y
CONFIG_MBEDTLS_DHM_C=y

CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED=y
CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED=y
CONFIG_MBEDTLS_KEY_EXCHANGE_PSK_ENABLED=y
CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED=y
CONFIG_MBEDTLS_SSL_CONTEXT_SERIALIZATION=y
CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=y

# LOG ON RTT NOT UART0
CONFIG_CONSOLE=n
CONFIG_UART_CONSOLE=n
CONFIG_USE_SEGGER_RTT=y
CONFIG_RTT_CONSOLE=y
CONFIG_LOG_BACKEND_RTT=y
CONFIG_LOG_BACKEND_UART=n

CONFIG_NRF_MODEM_LIB=y
CONFIG_LTE_LINK_CONTROL=y


# Let the modem handle sockets, DNS, and SNTP
CONFIG_NET_NATIVE=n
CONFIG_NET_SOCKETS_OFFLOAD=y

CONFIG_SNTP_LOG_LEVEL_DBG=y

CONFIG_MQTT_HELPER_SEC_TAG=212

# Copyright (c) 2023 Lucas Dietrich <[email protected]>
#
# SPDX-License-Identifier: Apache-2.0
#

menu "AWS"
mainmenu "AWS IoT Core MQTT sample application"

config AWS_ENDPOINT
	string "AWS endpoint"
	default ""
	help
	  Endpoint (hostname) of the AWS MQTT broker.
	  Note that the endpoint is different when using AWS Device Advisor.

config AWS_MQTT_PORT
	int "MQTT Port"
	default 8883
	help
	  Set port of AWS MQTT broker.

config AWS_THING_NAME
	string "AWS Thing name"
	default "myThingName"
	help
	  Set the AWS Thing name created on IoT Console

config AWS_SUBSCRIBE_TOPIC
	string "MQTT subscribe topic"
	default "myThingName/downlink"
	help
	  MQTT topic the client should subscribe to.

config AWS_PUBLISH_TOPIC
	string "MQTT publish topic"
	default "myThingName/data"
	help
	  MQTT topic the client should publish to.

choice AWS_TEST_SUITE
	prompt "Device Advisor test suite"
	default AWS_TEST_SUITE_NONE
	help
	  Select the AWS Device Advisor test suite to run.

config AWS_TEST_SUITE_NONE
	bool "No test suite running"

config AWS_TEST_SUITE_DQP
	bool "Device Qualification Program (DQP)"
	help
	  Make sure your region supports AWS Device Advisor for DQP

config AWS_TEST_SUITE_RECV_QOS1
	bool "Test suite for receiving QoS 1 messages"
	help
	  For single test case "MQTT Client Puack QoS1"

endchoice

config AWS_QOS
	int "MQTT QoS"
	default 0 if AWS_TEST_SUITE_DQP
	default 1 if AWS_TEST_SUITE_RECV_QOS1
	default 0
	range 0 1
	help
	  Quality of Service to use for publishing and subscribing to topics.
	  Notes:
	  	- Use QoS 0 when passing DQP test suite
	  	- QoS 2 is not supported by AWS MQTT broker


config AWS_EXPONENTIAL_BACKOFF
	bool "enable exponential backoff"
	default n if AWS_TEST_SUITE_DQP || AWS_TEST_SUITE_RECV_QOS1
	default y
	help
	  Enable AWS exponential backoff for reconnecting to AWS MQTT broker.

endmenu

source "Kconfig.zephyr"


/*
 * Copyright (C) 2023 Nordic Semiconductor ASA
 * SPDX-License-Identifier: Apache-2.0
 */
 #include <dt-bindings/regulator/npm1300.h>
 #include <zephyr/dt-bindings/input/input-event-codes.h>
 
 
 &gpio0 {status = "okay";};
 
 &i2c0 {status = "disabled";};
 &i2c1 {status = "disabled";};
 &spi0 {status = "disabled";};
 &spi2 {status = "disabled";};
 &pwm0 {status = "disabled";};
 // &led1 {status = "disabled";};
 // &led2 {status = "disabled";};
 // &led3 {status = "disabled";};
 &uart1 {status = "disabled";};
 &button0 {status = "disabled";};
 &button1 {status = "disabled";};
 
 
 /{
     chosen {
         /delete-property/ zephyr,console;
         zephyr,uart-mcumgr = &uart0;
     };
 
     leds {
         compatible = "gpio-leds";
         led2: led_2 {
             gpios = <&gpio0 3 GPIO_ACTIVE_HIGH>;
             label = "Green LED 3";
         };
         led3: led_3 {
             gpios = <&gpio0 4 GPIO_ACTIVE_HIGH>;
             label = "Green LED 4";
         };
     };
 
     buttons {
         button4: button_4 {
             gpios = <&gpio0 2 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>;
         };
         button5: button_5 {
             gpios = <&gpio0 5 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
         };
         sil23: sil_23 {
             gpios = <&gpio0 23 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
         };
         sil24: sil_24 {
             gpios = <&gpio0 24 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
         };
         fl_hld: fl_hld_1 {
             gpios = <&gpio0 10 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
         };
         fl_wp: fl_wp_1 {
             gpios = <&gpio0 7 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
         };
         // buck: buck_1 {
         //     gpios = <&gpio0 1 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
         // };
     };
 
     aliases {
         sw4 = &button4; //for rtc interrupt
         sw5 = &button5; //for wifi interrupt
         sw6 = &sil23; //for wifi 
         sw7 = &sil24; //for wifi interrupt
         sw8 = &fl_hld; //for wifi interrupt
         sw9 = &fl_wp; //for wifi interrupt
         // sw10 = &buck; //for wifi interrupt
         lis2dw12 = &lis2dw12;
         max30001g = &max30001g;
     };
 };
 
 
 
 &pinctrl {
 
 
     uart0_default: uart0_default {
         group1 {
             psels = <NRF_PSEL(UART_TX, 0, 27)>;
         };
         group2 {
             psels = <NRF_PSEL(UART_RX, 0, 26)>;
             bias-pull-up;
         };
     };
 
     uart0_sleep: uart0_sleep {
         group1 {
             psels = <NRF_PSEL(UART_TX, 0, 27)>,
                     <NRF_PSEL(UART_RX, 0, 26)>;
             low-power-enable;
         };
     };
 
     i2c2_default {
         group1 {
             /delete-property/ bias-pull-up;
         };
     };
 
     spi1_default: spi1_default {
         group1 {
             psels = <NRF_PSEL(SPIM_SCK, 0, 16)>,
                     <NRF_PSEL(SPIM_MISO, 0, 29)>,
                     <NRF_PSEL(SPIM_MOSI, 0, 28)>;
             nordic,drive-mode = <NRF_DRIVE_H0H1>;
         };
     };
 
     spi1_sleep: spi1_sleep {
         group1 {
             psels = <NRF_PSEL(SPIM_SCK, 0, 16)>,
                     <NRF_PSEL(SPIM_MISO, 0, 29)>,
                     <NRF_PSEL(SPIM_MOSI, 0, 28)>;
             low-power-enable;
         };
     };
 };
 
 &uart0 {
     current-speed = <115200>;
 };
 
 
 &i2c2 {
     status = "okay";
     lis2dw12: lis2dw12@19 {
         compatible = "st,lis2dw12";
         reg = <0x19>;
         label = "LIS2DW12";
         irq-gpios = <&gpio0 8 (GPIO_ACTIVE_HIGH|GPIO_PULL_UP)>,
                     <&gpio0 9 (GPIO_ACTIVE_HIGH)>;
         odr = <100>; /* Set Output Data Rate to 100Hz (adjust as needed) */
 
         range = <2>; /* ±2g sensitivity */
 
         power-mode = <4>; /* High-performance mode */
         bw-filt = <0>; /* Set digital filter bandwidth to ODR/2 */
 
         tap-mode = <1>; /* Enable both single and double tap detection */
         tap-threshold = <12 12 12>; /* Set X, Y, Z tap threshold (adjust as needed) */
         tap-shock = <1>; /* Tap shock duration */
         tap-latency = <3>; /* Time between two taps for double tap detection */
         tap-quiet = <1>; /* Quiet time after a tap */
 
         wakeup-duration = <3>; /* Wakeup duration = 4 ODR cycles (adjust as needed) */
     };
 };
 
 &i2c2 {
     status = "okay";
     max31341: max31341@69 {
         compatible = "i2c-device";
         reg = <0x69>;
     };
 };
 
 
 &arduino_i2c {
     npm1300_ek_pmic: pmic@6b {
         compatible = "nordic,npm1300";
         reg = <0x6b>;
 
         npm1300_ek_gpio: gpio-controller {
             compatible = "nordic,npm1300-gpio";
             gpio-controller;
             #gpio-cells = <2>;
             ngpios = <5>;
         };
 
         npm1300_ek_regulators: regulators {
             compatible = "nordic,npm1300-regulator";
 
             npm1300_ek_buck1: BUCK1 {
                 // regulator-min-microvolt = <3300000>;
                 // regulator-max-microvolt = <3300000>;
                 // regulator-init-microvolt = <3300000>;
                 regulator-min-microvolt = <1800000>;
                 regulator-max-microvolt = <1800000>;
                 regulator-init-microvolt = <1800000>;
                 // regulator-always-on; // Optional: Keeps BUCK1 on
             };
 
             npm1300_ek_buck2: BUCK2 {
                 regulator-min-microvolt = <1000000>;
                 regulator-max-microvolt = <3300000>;
                 regulator-init-microvolt = <3300000>;
                 // regulator-min-microvolt = <1800000>;
                 // regulator-max-microvolt = <1800000>;
                 // regulator-init-microvolt = <1800000>;
                 // regulator-always-on; // Optional: Keeps BUCK2 on
                 /delete-property/ enable-gpios;
                 /delete-property/ retention-gpios;
                 /delete-property/ pwm-gpios;
             };
 
             npm1300_ek_ldo1: LDO1 {
                 regulator-min-microvolt = <1800000>;
                 regulator-max-microvolt = <1800000>;
                 regulator-init-microvolt = <1800000>;
                 regulator-initial-mode = <NPM1300_LDSW_MODE_LDSW>;
                 /delete-property/ enable-gpios;
             };
 
             npm1300_ek_ldo2: LDO2 {
                 regulator-min-microvolt = <1800000>;
                 regulator-max-microvolt = <1800000>;
                 regulator-init-microvolt = <1800000>;
                 regulator-initial-mode = <NPM1300_LDSW_MODE_LDSW>;
                 /delete-property/ enable-gpios;
             };
         };
 
         npm1300_ek_charger: charger {
             compatible = "nordic,npm1300-charger";
             term-microvolt = <3600000>;
             term-warm-microvolt = <4000000>;
             current-microamp = <150000>;
             dischg-limit-microamp = <1000000>;
             vbus-limit-microamp = <500000>;
             thermistor-ohms = <10000>;
             thermistor-beta = <3380>;
             charging-enable;
         };
 
         npm1300_ek_buttons: buttons {
             status = "disabled";
             compatible = "gpio-keys";
             pmic_button0: pmic_button_0 {
                 status = "disabled";
                 gpios = <&npm1300_ek_gpio 0 GPIO_ACTIVE_HIGH>;
                 label = "Pmic button switch 0";
                 zephyr,code = <INPUT_KEY_0>;
             };
         };
 
         npm1300_ek_leds: leds {
             compatible = "nordic,npm1300-led";
             nordic,led0-mode = "charging";
             nordic,led1-mode = "host";
             nordic,led2-mode = "host";
         };
     };
 };
 
 &spi1 {
     compatible = "nordic,nrf-spim";
     clock-frequency = <DT_FREQ_M(12)>;
     status = "okay";
     cs-gpios = <&gpio0 17 GPIO_ACTIVE_LOW>;
     pinctrl-0 = <&spi1_default>;
     pinctrl-1 = <&spi1_sleep>;
     pinctrl-names = "default", "sleep";
     max30001g: max30001g@0 {
         compatible = "maxim,max30001g";
         status = "okay";
         reg = <0x0>;
         spi-max-frequency = <DT_FREQ_M(12)>;
         ecg-enabled;
         rtor-enabled;
         ecg-dcloff-enable;
         ecg-dcloff-current = <4>;
     };
 };
 
 &spi3 {
     status = "okay";
     clock-frequency = <DT_FREQ_M(83)>;
     /delete-property/ cs-gpios;
 };

so please guide us how we solve this issue

best regards
Parents
  • after updating my 

    pm_static.yml my code successfully build and flash but not run other prj config, overlay as it is

    updated pm_static.yml

    EMPTY_0:
      address: 0xc000
      end_address: 0x10000
      placement:
        before:
          - mcuboot_pad
      region: flash_primary
      size: 0x4000
    
    EMPTY_1:
      address: 0xfe000
      end_address: 0x100000
      placement:
        after:
          - nvs_storage
      region: flash_primary
      size: 0x2000
    
    EMPTY_2:
      address: 0xf0000
      end_address: 0xf8000
      placement:
        after:
          - mcuboot_secondary
      region: flash_primary
      size: 0x8000
    
    app:
      address: 0x20000
      end_address: 0x80000
      region: flash_primary
      size: 0x60000
    
    mcuboot:
      address: 0x0
      end_address: 0xc000
      placement:
        align:
          end: 0x1000
        before:
          - mcuboot_primary
      region: flash_primary
      size: 0xc000
    
    mcuboot_pad:
      address: 0x10000
      end_address: 0x10200
      placement:
        align:
          start: 0x8000
        before:
          - mcuboot_primary_app
      region: flash_primary
      size: 0x200
    
    mcuboot_primary:
      address: 0x10000
      end_address: 0x80000
      orig_span: &id001
        - mcuboot_pad
        - app
        - tfm
      region: flash_primary
      sharers: 0x1
      size: 0x70000
      span: *id001
    
    mcuboot_primary_app:
      address: 0x10200
      end_address: 0x80000
      orig_span: &id002
        - app
        - tfm
      region: flash_primary
      size: 0x6fe00
      span: *id002
    
    mcuboot_secondary:
      address: 0x80000
      end_address: 0xf0000
      placement:
        after:
          - mcuboot_primary
        align:
          start: 0x8000
      region: flash_primary
      share_size:
        - mcuboot_primary
      size: 0x70000
    
    mcuboot_sram:
      address: 0x20000000
      end_address: 0x20008000
      orig_span: &id003
        - tfm_sram
      region: sram_primary
      size: 0x8000
      span: *id003
    
    nonsecure_storage:
      address: 0xf8000
      end_address: 0xfe000
      orig_span: &id004
        - nvs_storage
      region: flash_primary
      size: 0x6000
      span: *id004
    
    nrf_modem_lib_ctrl:
      address: 0x20008000
      end_address: 0x200084e8
      inside:
        - sram_nonsecure
      placement:
        after:
          - tfm_sram
          - start
      region: sram_primary
      size: 0x4e8
    
    nrf_modem_lib_rx:
      address: 0x2000a568
      end_address: 0x2000c568
      inside:
        - sram_nonsecure
      placement:
        after:
          - nrf_modem_lib_tx
      region: sram_primary
      size: 0x2000
    
    nrf_modem_lib_sram:
      address: 0x20008000
      end_address: 0x2000c568
      orig_span: &id005
        - nrf_modem_lib_ctrl
        - nrf_modem_lib_tx
        - nrf_modem_lib_rx
      region: sram_primary
      size: 0x4568
      span: *id005
    
    nrf_modem_lib_tx:
      address: 0x200084e8
      end_address: 0x2000a568
      inside:
        - sram_nonsecure
      placement:
        after:
          - nrf_modem_lib_ctrl
      region: sram_primary
      size: 0x2080
    
    nvs_storage:
      address: 0xf8000
      end_address: 0xfe000
      inside:
        - nonsecure_storage
      placement:
        align:
          start: 0x8000
        before:
          - end
      region: flash_primary
      size: 0x6000
    
    otp:
      address: 0xff8108
      end_address: 0xff83fc
      region: otp
      size: 0x2f4
    
    sram_nonsecure:
      address: 0x20008000
      end_address: 0x20040000
      orig_span: &id006
        - sram_primary
        - nrf_modem_lib_ctrl
        - nrf_modem_lib_tx
        - nrf_modem_lib_rx
      region: sram_primary
      size: 0x38000
      span: *id006
    
    sram_primary:
      address: 0x2000c568
      end_address: 0x20040000
      region: sram_primary
      size: 0x33a98
    
    sram_secure:
      address: 0x20000000
      end_address: 0x20008000
      orig_span: &id007
        - tfm_sram
      region: sram_primary
      size: 0x8000
      span: *id007
    
    tfm:
      address: 0x10200
      end_address: 0x20000
      inside:
        - mcuboot_primary_app
      placement:
        before:
          - app
      region: flash_primary
      size: 0xfe00
    
    tfm_nonsecure:
      address: 0x20000
      end_address: 0x80000
      orig_span: &id008
        - app
      region: flash_primary
      size: 0x60000
      span: *id008
    
    tfm_secure:
      address: 0x10000
      end_address: 0x20000
      orig_span: &id009
        - mcuboot_pad
        - tfm
      region: flash_primary
      size: 0x10000
      span: *id009
    
    tfm_sram:
      address: 0x20000000
      end_address: 0x20008000
      inside:
        - sram_secure
      placement:
        after:
          - start
      region: sram_primary
      size: 0x8000


    our proj also use dfu for ota thats why we use child image but we dont change but we give only for source mcuboot.conf
    #Enable logging for MCUboot
    CONFIG_LOG=y
    CONFIG_MCUBOOT_LOG_LEVEL_WRN=y ## after dfu done change this in warning.
    
    #Enable Serial Recovery over UART
    CONFIG_MCUBOOT_SERIAL=y
    CONFIG_BOOT_SERIAL_UART=y
    
    # Disable console UART, since Serial Recovery uses UART
    CONFIG_UART_CONSOLE=n
    
    CONFIG_DISABLE_FLASH_PATCH=y



    so guide us any changes we do here or any other place please guide us for

    after updating my 

    pm_static.yml my code successfully build and flash but not run 


  • Hi,

    The project builds until TF-M, but after merging AWS configs, the build fails with a FLASH overflow inside TF-M

    How did you resolve this initial error?

    Can you provide details about your main application? What is your final goal after integrating AWS IoT functionality?

    Do you get any output after resetting the board? Do you have any log that you can share?

    Best regards,
    Dejan

  • We are currently developing an application on the nRF9151 using nRF Connect SDK 2.9.0.
    The project integrates multiple peripherals and features, all of which are working correctly with DFU OTA support.

    Integrated Peripherals
    SPI Interfaces

    MAX30001G – ECG acquisition module

    MT29F NAND Flash – External storage

    I2C Interfaces

    RTC module

    LIS2DW12 – Accelerometer

    NPM1300 – Power management IC

    UART Interface

    SIWG917Y Wi-Fi module

    Current Application Status

    All major functionalities are implemented and working as expected.

    DFU OTA update mechanism is functional and stable.

    Upcoming Enhancement

    We now want to extend the application by adding Cellular connectivity (LTE-M / NB-IoT) in addition to the existing Wi-Fi support.
    The goal is to have both Wi-Fi and Cellular as available communication options, integrated cleanly within the same firmware.

    NO as per above configuration boot so no log and no led on

    now we using partitions.yml using we create pm_static.yml and we add configuration in main code and cellular aws driver add and prj.conf change but not call just add

    now our main code boot but cellular modular code not boot

    # AWS IoT MQTT
    CONFIG_AWS_IOT_LOG_LEVEL_DBG=y
    CONFIG_AWS_TEST_SUITE_DQP=n
    CONFIG_MQTT_LIB=y
    CONFIG_MQTT_LIB_TLS=y
    CONFIG_MQTT_KEEPALIVE=600
    CONFIG_MQTT_LIB_TLS_USE_ALPN=y
    
    # TLS (nRF Security only)
    CONFIG_NRF_SECURITY=y
    CONFIG_MBEDTLS_TLS_LIBRARY=y
    CONFIG_MBEDTLS_LEGACY_CRYPTO_C=y
    CONFIG_MBEDTLS_ENABLE_HEAP=y
    CONFIG_MBEDTLS_HEAP_SIZE=10240
    CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=10240
    CONFIG_MBEDTLS_PEM_CERTIFICATE_FORMAT=y
    CONFIG_MBEDTLS_SERVER_NAME_INDICATION=y
    CONFIG_MBEDTLS_AES_ROM_TABLES=y
    CONFIG_MBEDTLS_TLS_VERSION_1_2=y
    CONFIG_MBEDTLS_MEMORY_DEBUG=y
    CONFIG_MBEDTLS_HAVE_TIME_DATE=y
    CONFIG_MBEDTLS_SSL_ALPN=y
    CONFIG_MBEDTLS_SSL_CLI_C=y
    CONFIG_MBEDTLS_X509_CRT_PARSE_C=y
    CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED=y
    CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED=y
    CONFIG_MBEDTLS_KEY_EXCHANGE_PSK_ENABLED=y
    CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED=y
    CONFIG_MBEDTLS_SSL_SRV_C=y
    CONFIG_MBEDTLS_KEY_EXCHANGE_RSA_ENABLED=y
    CONFIG_MBEDTLS_CIPHER=y
    CONFIG_MBEDTLS_MD=y
    CONFIG_MBEDTLS_PK_C=y
    CONFIG_MBEDTLS_PK_PARSE_C=y
    CONFIG_MBEDTLS_PK_WRITE_C=y
    CONFIG_MBEDTLS_RSA_C=y
    CONFIG_MBEDTLS_PKCS1_V15=y
    CONFIG_MBEDTLS_ECP_C=y
    CONFIG_MBEDTLS_ECDSA_C=y
    CONFIG_MBEDTLS_ECDH_C=y
    CONFIG_MBEDTLS_DHM_C=y
    CONFIG_MBEDTLS_GCM_C=y
    CONFIG_MBEDTLS_SHA256_C=y
    CONFIG_MBEDTLS_X509_USE_C=y
    CONFIG_MBEDTLS_SSL_CONTEXT_SERIALIZATION=y
    CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=y
    
    # LTE/Modem
    CONFIG_NRF_MODEM_LIB=y
    CONFIG_LTE_LINK_CONTROL=y
    
    # Sockets offload for modem (if using LTE for AWS)
    CONFIG_NET_NATIVE=n
    CONFIG_NET_SOCKETS_OFFLOAD=y
    
    # AWS IoT MQTT Helper
    CONFIG_MQTT_HELPER_SEC_TAG=212
    
    # SNTP
    CONFIG_SNTP=y
    CONFIG_SNTP_LOG_LEVEL_DBG=y


    so we want configurtion and modular code which work saperatly and after merge it working 

    so please guide us to solve

  • Hi Dejan,

    Thanks for the support.

    Yes, the main issue right now is flash overflow.
    When we merge the AWS IoT MQTT + mbedTLS configs, our firmware size increases to ~400 KB, but our primary app partition is only 384 KB (because we use OTA/DFU with two app partitions).
    Because of this, the build fails inside TF-M due to FLASH overflow.

    We have already shared our prj.conf, pm_static.yml, and the merged AWS code.
    Could you please guide us on whether it’s possible to reduce flash usage or optimize the configuration so that AWS IoT can fit within the available partition size?

    Best regards,
    Milan

Reply
  • Hi Dejan,

    Thanks for the support.

    Yes, the main issue right now is flash overflow.
    When we merge the AWS IoT MQTT + mbedTLS configs, our firmware size increases to ~400 KB, but our primary app partition is only 384 KB (because we use OTA/DFU with two app partitions).
    Because of this, the build fails inside TF-M due to FLASH overflow.

    We have already shared our prj.conf, pm_static.yml, and the merged AWS code.
    Could you please guide us on whether it’s possible to reduce flash usage or optimize the configuration so that AWS IoT can fit within the available partition size?

    Best regards,
    Milan

Children
  • Hi Milan,

    It is not clear to me if you managed to build and flash your project successfully or your build failed with the error due to flash overflow? Can you clarify this?

    Best regards,
    Dejan

  • merge time we check different scinarios check like

    1) when we we one of paripheral disable that time build but flash is full thats why not boot
    2) when we multiple 2 or 3 paripheral disable that time build flash and boot also

    so my concern is after merge aws_iot_mqtt example to our main code that time our flash is overflow due to above reason as i mantion my firmware is nearly 400KB but partitions.yml dynamically set 384KB thats why flash overflow is final conclusion

    so please guide us how to manage it 

  • Hi Milan,

    Milan Pipaliya said:
    merge time we check different scinarios check like

    1) when we we one of paripheral disable that time build but flash is full thats why not boot
    2) when we multiple 2 or 3 paripheral disable that time build flash and boot also

    Can you elaborate on 2 mentioned scenarios?
    Are there any other differences between 2 mentioned scenarios apart from different number of peripherals disabled?

    Best regards,
    Dejan

  • here means is 

    when one paripheral disable that time my nearly 99% flash use that time not boot and more 2 paripheral disable that time 94% flash usage in primary app usage that time build ,flash,boot successfully

    it means flash overflow issue

    when i secondary app partition remove so primary app total 800KB available and its working with all paripheral my firmware use 400 KB its perfectly working

    so when we primary and secondary parition that time flash overflow after adding this aws_iot_mqtt part it use huge flash usage so any solution for reduce flash usage 

  • Hi Milan,

    You could check if there are any unused features and drivers that can be disabled in your application. You could also consider disabling logging. Additionally, you can look at this guide for some hints.

    Best regards,
    Dejan

Related