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

AWS FOTA fails when using my upload.bin file for nrf9160

Previously I have been successful getting the AWS FOTA update working using the AWS FOTA example project, the example update.bin file and location provided

by Nordic for the nrf9160. I did have excellent help from Nordic to get that working.

Now I have created my own update.bin from the AWS FOTA project

1) Create update.bin by making a build (get its exact file size from Windows Explorer)

2) Create an s3 bucket for the update.bin file (it has logging turned on)

3) Create another s3 bucket for the logging of events from the bucket with update.bin

4) Upload the update.bin file to the s3 bucket

5) Create a json file to point to the update.bin file

6) Upload code to nrf9160 using Segger

7) Wait for LTE connect complete and board ready for update by observing Termite terminal 

8) Create a job to perform FOTA update using the update.bin file

9) Get MQTT disconnect error

here are related screen shots

Parents
  • Hello,

    First of all, what version of NCS are you running and what is current modem FW?

    I see that you have configured your job file for an HTTPS address. Have you configured this accordingly as described in the download client? In the original job file example shown in AWS FOTA library, the address points to a nRFCloud address using HTTP.

    Error message -57 is defined as follows:

    ENOTCONN 57     /* Socket is not connected */

    Kind regards,

    Øyvind

  • Dear Øyvind

    The NCS version is 1.0.0

    The Modem Firmware is 1.0.0

  • Thanks for the update. Right now my json file is set to HTTP and the FOTA using a FW image I am hosting on AWS is still failing. As I mentioned above the FOTA starts and then hangs. See the text cut from the terminal window below: Note that I have added some printfk statements to the aws_fota.c and you will see them in the output

    ***** Booting Zephyr OS v1.14.99-ncs2 *****
    The MQTT AWS Jobs FOTA Sample Start Image
    nrf_inbuilt_key_delete(16842753, 0) => result=0
    nrf_inbuilt_key_delete(16842753, 1) => result=0
    nrf_inbuilt_key_delete(16842753, 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 0x072adf12
    client_id: My_nRF9160_Brd01B
    aws_fota_init
    construct_notify_next_topic
    aws_fota_mqtt_evt_handler
    update_device_shadow_version
    [mqtt_evt_handler:129] MQTT client connected!
    aws_fota_mqtt_evt_handler
    [mqtt_evt_handler:194] SUBACK packet id: 2112
    aws_fota_mqtt_evt_handler
    [mqtt_evt_handler:184] PUBACK packet id: 31846
    aws_fota_mqtt_evt_handler
    aws_fota_on_publish_evt
    publish_get_payload
    publish_get_payload mqtt_read_publish_payload_blocking
    construct_job_id_update_topic
    construct_job_id_update_topic
    aws_fota_mqtt_evt_handler
    [mqtt_evt_handler:199] default: 8
    aws_fota_mqtt_evt_handler
    update_job_execution
    aws_fota_mqtt_evt_handler
    [mqtt_evt_handler:184] PUBACK packet id: 12393
    aws_fota_mqtt_evt_handler
    aws_fota_on_publish_evt
    publish_get_payload
    publish_get_payload mqtt_read_publish_payload_blocking

  • The following snapshot shows a comparison of the printfk statements when running the Nordic example of the AWS FOTA update on the left and my example using my image stored in an AWS S3 bucket on the right.

  • There are two different links in use here: 

    1. From https://firmware.nrfcloud.com/, the link generated for your file is in the format given in the job-file example.
      http://s3.amazonaws.com/nordic-firmware-files/fcb2394f-49cf-4d66-826c-b5f2d04828b3
      An image from my account on nRF Cloud:
    2. From https://s3.console.aws.amazon.com, the link to your file will have this format:
      https://[USERNAME].s3.eu-north-1.amazonaws.com/update.bin

    As our sample does not support HTTPS out-of-box, it is not sufficient to change the protocol in the job file to "HTTPS" when trying to download from AWS S3. You must follow the instructions given in this link.

    Please try this solution, 
    and let me know how this works for you.

    Kind regards,
    Øyvind

  • Thank you. That is very clear. I will test later today.

  • Another thing to test before my last comment:
    In the AWS FOTA sample documentation, under Prerequisites, you are instructed to add a permissive policy for testing only. Could you try to add a new Policy with the following:

    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Effect": "Allow",
                "Action": "s3:GetObject",
                "Resource": "arn:aws:s3:::your_S3_bucket/*"
            }
        ]
    } 

    I found this in the AWS documentaion.

Reply Children
  • Here is my new policy

    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Allow",
          "Action": "s3:GetObject",
          "Resource": "arn:aws:s3:::mynrf9160fwupdatev1/*"
        }
      ]
    }

    But now the code on the board does not proceed far

    enough to indicate that it is ready for the FOTA update

    But my original policy

    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Allow",
          "Action": "iot:*",
          "Resource": "*"
        }
      ]
    }

    At least allows the code to get ready for the FOTA update

  • I tried this policy instead and it got me back to where I was 2 days ago. The FOTA update will

    start but then get stuck in progress

    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Allow",
          "Action": "s3:GetObject",
          "Resource": "arn:aws:s3:::mynrf9160fwupdatev1/*"
        },
        {
          "Effect": "Allow",
          "Action": "iot:*",
          "Resource": "*"
        }
      ]
    }

  • Thanks for testing this at least.

    hmichel said:

    Here is my new policy

    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Allow",
          "Action": "s3:GetObject",
          "Resource": "arn:aws:s3:::mynrf9160fwupdatev1/*"
        }
      ]
    }

    But now the code on the board does not proceed far

    enough to indicate that it is ready for the FOTA update

    Then the issue is clearly with the Download Client and the HTTPS settings that you need to configure.  I'm sorry for the inconvenience, but I hope this will solve the issue. And for what it's worth, this is a huge help for us to improve our documentation.  

  • Thank you for all the effort. I am happy to help with your documentation process.

Related