This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

FOTA for Thingy91

Hi,

From the Ref ticket https://devzone.nordicsemi.com/f/nordic-q-a/54350/thingy91-fota-with-nb-iot/220513#220513  we could see that there is no relevant example for FOTA for Thingy91 (PCA20035).

But as per our requirement, we would like to update the firmware over the air.

So please help us with relevant inputs to Implement the FOTA on Thingy91.

Thanks

Parents
  • Hi,

     

    Yes, its correct that there is no sample that does this out-of-the-box for thingy:91, but the concepts are similar for the DK as for thingy:91.

    Have you tried this sample?

    https://github.com/NordicPlayground/fw-nrfconnect-nrf/blob/v1.2.0/samples/nrf9160/http_application_update/prj.conf#L53

    It downloads an image for nrf9160_pca10090ns, but it should atleast work until it runs the actual downloaded binary file. You can easily switch out the URI for the image it should download. Read more about this project here: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.2.0/nrf/samples/nrf9160/http_application_update/README.html?highlight=http_application

     

    Kind regards,

    Håkon

  • Hi Hakon,

    Thank you for the confirmation.

    We have tried the standalone sample given in https://github.com/NordicPlayground/fw-nrfconnect-nrf/tree/v1.1.0/samples/nrf9160/aws_fota on nRF9160 DK PCA10090.

    As per the guidelines given in the documentation https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/nrf9160/aws_fota/README.html#usage  we have configured AWS IoT without any issues.

    Everything went smoothly, but at the end once we queues the job it is going into "In Progress" state forever and see NO response on Teraterm.

    Sometimes we see the job getting Failed as well.

    Since we don't have any clear idea on AWS IoT services, we don't know how to debug further.

    We got the following logs shared below:

    ***** Booting Zephyr OS build v2.0.99-ncs1 *****
    MQTT AWS Jobs FOTA Sample, version: v1.1.0
    Initializing bsdlib
    Initialized bsdlib
    Certificates are provisioning.
    ************************* WARNING *************************
    provision_certificates called do not use this in production!
    This will store the certificates in readable flash and leave
    them exposed on modem_traces. Only use this once for
    provisioning certificates for development to reduce flash tear.
    ************************* WARNING *************************
    nrf_inbuilt_key_delete(12345678, 0) => result=2
    nrf_inbuilt_key_delete(12345678, 1) => result=2
    nrf_inbuilt_key_delete(12345678, 2) => result=2
    nrf_inbuilt_key_write => result=0
    nrf_inbuilt_key_write => result=0
    nrf_inbuilt_key_write => result=0
    Certificates are provisioned.
    LTE Link Connecting ...
    LTE Link Connected!
    Modem is configured.
    IPv4 Address 34.210.66.48
    Client is initialized.
    aws_fota_init initialized.
    MQTT connection established.
    [mqtt_evt_handler:170] MQTT client connected!
    [mqtt_evt_handler:223] PUBACK packet id: 2016
    [mqtt_evt_handler:233] SUBACK packet id: 2114
    [00:01:40.055,572] <inf> aws_jobs: Subscribe: $aws/things/nrf-352656100219636/jo                                                                             bs/notify-next
    [00:01:40.056,640] <inf> aws_jobs: Subscribe: $aws/things/nrf-352656100219636/jo                                                                             bs/$next/get/#
    [00:01:40.490,509] <inf> aws_fota: subscribed to notify-next topic
    [00:01:40.490,600] <inf> aws_jobs: Publish topic: $aws/things/nrf-35265610021963                                                                             6/jobs/$next/get
    [00:01:40.490,631] <inf> aws_jobs: Publish payload {"clientToken": ""}
    [mqtt_evt_handler:223] PUBACK packet id: 16077
    [00:01:41.291,595] <inf> aws_fota: Received topic: $aws/things/nrf-3526561002196                                                                             36/jobs/$next/get/accepted
    [00:01:41.291,778] <inf> aws_fota: Got only one field: {"clientToken":"","timest                                                                             amp":1585635840}

    Also sharing the Kconfig file and AWS IoT Job file as well.

    The changes in Kconfig looks like:

    config APP_VERSION
    	string "Application version"
    	default "v1.1.0"
    
    if !USE_NRF_CLOUD
    config CLOUD_CERT_SEC_TAG
    	int "Security tag for TLS credentials"
    	default 12345678
    
    config PROVISION_CERTIFICATES
    	bool "Provision certificates from the certificates.h file"
    	default y
    	help
    	  If enabled, the sample provisions server certificates into
    	  the modem by storing the certificates defined in the
    	  certificates.h file in the modem under the given security tag.
    	  Use this option only once to provision the device.
    	  The certificates are stored in the application binary and are
    	  therefore shown in the modem trace information. This is a
    	  security risk. After provisioning the certificates, turn off
    	  this option and compile and program the sample again.
    	  Also, do not share the binary that includes the compiled
    	  certificates with anyone.
    
    config USE_CLOUD_CLIENT_ID
    	bool "Custom MQTT client ID"
    	default y
    if USE_CLOUD_CLIENT_ID
        
    config CLOUD_CLIENT_ID
    	string "Client ID"
    	default "our_client_id"
    endif
    
    config MQTT_BROKER_HOSTNAME
    	string "AWS IoT MQTT broker hostname"
    	default "our_aws_mqtt_broker_hostname.amazonaws.com"
    	help
    	  Default is set to be the nRF Cloud MQTT broker.
    	 

    The AWS IoT job file look like:

    {
      "operation": "app_fw_update",
      "fwversion": "v1.1.1",
      "size": 181124,
      "location": {
        "protocol": "https:",
        "host": "[bucket_name].s3-us-west-2.amazonaws.com",
        "path": "s3://[bucket_name]/app_update.bin"
       }
    }

    Please help us with your inputs to resolve this issue and download the application firmware.

  • Hi,

     

    It looks like your job file path is incorrect. See chapter "Testing" point 11 here: https://github.com/NordicPlayground/fw-nrfconnect-nrf/blob/v1.1.0/samples/nrf9160/aws_fota/README.rst#testing

    Could you try updating that and see if the job is parsed correctly?

     

    Kind regards,

    Håkon

  • Hi Hakon,

    Yes, we noticed and resolved the above issue.

    We successfully tested aws_fota sample on nrf9160 DK (PCA10090) but we need FOTA feature to be available on thingy91 (PCA20035).

    So, we have tried aws_fota sample on thingy91 but it was unsuccessful.

    We have seen the below issues:

    MQTT AWS Jobs FOTA Sample, version: v1.1.0
    Initializing bsdlib
    [00:00:00.004,455] <err> board_nonsecure: AT socket could not be opened
    [00:00:00.004,455] <err> board_nonsecure: pca20035_magpio_configure failed with error: -14
    Initialized bsdlib

    Find the respective Logs are attached below:

    ***** Booting Zephyr OS version 2.1.0-rc1 *****
    MQTT AWS Jobs FOTA Sample, version: v1.1.0
    Initializing bsdlib
    [00:00:00.004,455] <err> board_nonsecure: AT socket could not be opened
    [00:00:00.004,455] <err> board_nonsecure: pca20035_magpio_configure failed with error: -14
    Initialized bsdlib
    ************************* WARNING *************************
    provision_certificates called do not use this in production!
    This will store the certificates in readable flash and leave
    them exposed on modem_traces. Only use this once for
    provisioning certificates for development to reduce flash tear.
    ************************* WARNING *************************
    nrf_inbuilt_key_delete(12345678, 0) => result=0
    nrf_inbuilt_key_delete(12345678, 1) => result=0
    nrf_inbuilt_key_delete(12345678, 2) => result=0
    nrf_inbuilt_key_write => result=0
    nrf_inbuilt_key_write => result=0
    nrf_inbuilt_key_write => result=0
    LTE Link Connecting ...
    LTE Link Connected!
    IPv4 Address 35.163.176.243
    client_id: "our_client_id"
    ERROR: mqtt_connect -95

    FYI, 

    Used "west build -b nrf9160_pca20035ns" non-secure image to flash on nrf9160 SiP. 

    We have enabled the BSD library and at_commands as well. but still, we are facing the above issue.

    # BSD library
    CONFIG_BSD_LIBRARY=y
    CONFIG_BSD_LIBRARY_SYS_INIT=n

    # AT Host

    CONFIG_UART_INTERRUPT_DRIVEN=y
    CONFIG_AT_HOST_LIBRARY=y

    Please share some inputs from your end if we are missing anything here.

    Thank you

  • Hi,

     

    Dheeraj said:
    [00:00:00.004,455] <err> board_nonsecure: AT socket could not be opened
    [00:00:00.004,455] <err> board_nonsecure: pca20035_magpio_configure failed with error: -14

     Since bsdlib is initialized in main, this function will now fail to run properly:

    https://github.com/NordicPlayground/fw-nrfconnect-nrf/blob/v1.2.0/boards/arm/nrf9160_pca20035/board_nonsecure.c#L94

     

    In order to get this running properly, you have to copy the content above function and run that in main, after bsdlib init, but before modem_configure().

    Alternative if using ncs v1.2.0 or newer:

    set CONFIG_BSD_LIBRARY_SYS_INIT=y and add changes to how main works, like http_update_application does in master now:

    https://github.com/NordicPlayground/fw-nrfconnect-nrf/blob/master/samples/nrf9160/http_application_update/src/main.c#L185

    https://github.com/NordicPlayground/fw-nrfconnect-nrf/blob/master/samples/nrf9160/http_application_update/src/main.c#L235

     

    This function should then be guarded with a similar ifdef as in http_application update (#if !defined(CONFIG_BSD_LIBRARY_SYS_INIT))

    https://github.com/NordicPlayground/fw-nrfconnect-nrf/blob/v1.2.0/samples/nrf9160/aws_fota/src/main.c#L441

    https://github.com/NordicPlayground/fw-nrfconnect-nrf/blob/v1.2.0/samples/nrf9160/aws_fota/src/main.c#L493

     

    "our_client_id" - is this the same one you used earlier, when you got it working?

     

    Kind regards,

    Håkon

  • Hi,

    Thanks for your help.

    Yes, we noticed and resolved the above issues.

    Its working.

    Thanks

Reply Children
Related