This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Merge application_update and mqtt_simple

In my current application I have a combination of some examples and features, but I couldn't add the resource provided by the http_application_update example.

So I tried to make the combination of the mqtt_simple and application_update examples, I realized that there is some incompatibility between the examples or I'm doing something wrong, because I couldn't succeed.

First I was encountering errors related to the settings below prj.conf:

CONFIG_DOWNLOAD_HOST="nrfconnectsdk.s3.eu-central-1.amazonaws.com"
CONFIG_DOWNLOAD_FILE_V2="app_update.bin"
CONFIG_DOWNLOAD_FILE_V1="app_downgrade.bin"
c:\NordicSDK\My_Apps2\MQTT_HTTP_IKS01A2_FOTA\prj.conf:128: warning: attempt to assign the value '"nrfconnectsdk.s3.eu-central-1.amazonaws.com"' to the undefined symbol DOWNLOAD_HOST
I don't understand why I can't add these settings to the prj.conf of the mqtt_simple example, anyway this would get around removing these settings from prj.conf and transforming them into defines in the application. But what is the correct way to add these settings to prj.conf of mqtt_simple?

Getting around this error I found some duplicates, I ended up cleaning everything that was being overlapped between the samples, such as a double definition of void nrf_modem_recoverable_error_handler().
After some time and edits the code compiled. But something is very wrong because the nRF9160 restarts all the time:
*** Booting Zephyr OS build v2.7.99-ncs1-1 ***
I: The MQTT simple sample started
I: Provisioning certificates
W: Failed to retrieve CMEE status, err -1
ASSERTION FAIL @ WEST_TOPDIR/nrf/lib/modem_key_mgmt/modem_key_mgmt.c:76
E: r0/a1: 0x00000004 r1/a2: 0x0000004c r2/a3: 0x00000001
E: r3/a4: 0x00028041 r12/ip: 0x00007000 r14/lr: 0x0002cdc3
E: xpsr: 0x41000000
E: Faulting instruction address (r15/pc): 0x0003e0f6
E: >>> ZEPHYR FATAL ERROR 4: Kernel panic on CPU 0
E: Current thread: 0x2000d9a0 (unknown)
E: Resetting system
If I remove CONFIG_MODEM_KEY_MGMT=y from prj.conf, the device stops rebooting but nothing works:
*** Booting Zephyr OS build v2.7.99-ncs1-1 ***
I: The MQTT simple sample started
I: Provisioning certificates
I: Disabling PSM and eDRX
E: nrf_modem_at_printf failed, reported error: -1
E: Failed to disable eDRX, reported error: -1
I: LTE Link Connecting...
E: Failed to get system mode, error: -1
E: Could not get current system mode, error: -14
I: Failed to establish LTE connection: -14
I: Retrying in 120 seconds
I'm using NCS 1.9.1, and modem firmware 1.3.1. I can create firmwares based on both samples individually, but I can't combine the samples!
Have you already managed to add the option to perform FOTA via http (as in the application_update sample) in mqtt_simple?
Thank you.
Parents
  • I tried to call the function that starts the firmware update from several places, main, workqueue... I always get errors, for example when I call through a thread I get this error:

    I: Configuring socket timeout (30 s)
    I: Connecting to files.wnology.io
    E: ***** USAGE FAULT *****
    E:   Stack overflow (context area not valid)
    E: r0/a1:  0x0004040a  r1/a2:  0x21040000  r2/a3:  0x0d0f8e00
    E: r3/a4:  0x6207ccbf r12/ip:  0x2350734b r14/lr:  0x0000002c
    E:  xpsr:  0x2001bc00
    E: Faulting instruction address (r15/pc): 0xffffffd9
    E: >>> ZEPHYR FATAL ERROR 2: Stack overflow on CPU 0
    E: Current thread: 0x2000f338 (unknown)
    E: Resetting system

    Please give me tips on how to do this!

  • Hi Gabriel,

    This appears to be a stack overflow on the update thread.

    Which command are you calling when you het this stack overflow?

  • Hello João,

    I'm calling dfu_button_pressed(), this worked in the application_update example!

    But in my custom application and in the mqtt_simple sample, I find the quoted error.

    In the application_update sample and in the merge with the applications I kept the stack settings.

  • Hi,

    Have you tried to increase the Stack size?

    I noticed the application_update uses higher value than the mqtt simple:

    From application_update/proj.conf:

    # Heap and stacks
    CONFIG_HEAP_MEM_POOL_SIZE=2048
    CONFIG_MAIN_STACK_SIZE=8192

    From mqtt_simple/proj.conf:
    # Memory
    CONFIG_MAIN_STACK_SIZE=4096
    CONFIG_HEAP_MEM_POOL_SIZE=2048
  • I only kept CONFIG_DOWNLOAD_CLIENT_STACK_SIZE=4096.

    My current application is already configured as follows:

    # Memory

    CONFIG_MAIN_STACK_SIZE=16384

    CONFIG_HEAP_MEM_POOL_SIZE=16384

    I tried to increase the size but without success!

    CONFIG_MAIN_STACK_SIZE=32768

    CONFIG_HEAP_MEM_POOL_SIZE=32768

Reply
  • I only kept CONFIG_DOWNLOAD_CLIENT_STACK_SIZE=4096.

    My current application is already configured as follows:

    # Memory

    CONFIG_MAIN_STACK_SIZE=16384

    CONFIG_HEAP_MEM_POOL_SIZE=16384

    I tried to increase the size but without success!

    CONFIG_MAIN_STACK_SIZE=32768

    CONFIG_HEAP_MEM_POOL_SIZE=32768

Children
No Data
Related