This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
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

Update code via UART instead of FOTA nRF9160

Hello,

I am using your NRF9160 chip and need Nordic team help.
I have refer to your FOTA sample, I am looking for a safer solution for updating code. On my board, I use ESP32, Is there any way to download the app_update.bin file with ESP32 chip and transmit that file via the UART line for the Nordic chip?

In our living area, NB-IoT signal is not really popular, so it's hard for me to update the FOTA with NB-IoT.

Thanks

  • Yes, this is possible. All you need to do is the following:

    1. Place app_update.bin in the secondary slot of the nrf9160
    2. Reset the nrf9160
      1. The mcuboot will then check the secondary slot and if it finds a valid image, it will swap it with the image in the primary slot and boot the new image
    3. Mark the image as "okay" to prevent rollback on next reset
      1. This can be done from the image itself using boot_write_img_confirmed()

    You can set up everything yourself, by sending app_update.bin one block at the time over UART from the ESP32 to the nRF9160  and putting it in the secondary slot. Then executing step 2 and 3 from the nRF9160.

    You can also use the mcumgr protocol, which supports commands that makes it possible to send the image, confirm the image and reset the client (nrf9160) from the host (ESP32) side. We do have solutions for this in NCS/Zephyr, however if the ESP32 doesn't support NCS/Zephyr I think you'll have some work to do, but it should be manageable.

    Please let me know what approach sounds the best and if you have any more question.

    Best regards,

    Simon

  • Thanks for your information. 

    Can you give me a sample how to send .bin file via uart, I really don't have any ideal about it.

    Thank.

  • Is there no way of downloading the DFU update directly to the nRF9160? That would really simplify this.

    If I have understood it correctly, you want to first download it to the ESP32 and then transfer it to the nRF9160?

    The .bin file is just a big block of bytes, so you need to set up a uart on the ESP32 and a uart on the nRF9160 and send all the bytes over, a few bytes at the time.

    Regarding the ESP32, you have to first download the .bin file and either transfer it directly (as you receive it from the cloud) to the nR9160 or save it in flash temporarily and then send it over. However, I can't really help you with the ESP32, since this is not our product, you have to ask here: https://www.espressif.com/.

    When you've gotten that to work, you need to set up UART on the nRF9160 to receive the .bin file. For that you can use the LPUART sample. Then you can connect RX91<->TX ESP32 and TX91<->RX ESP32 and GND<->GND (and optionally the flow control lines).

    After this, you have to execute the steps 1-3, which I mentioned in the initial post. But we can get back to this later, when you have been able to set up UART communication between the two boards.

    Here is the lpuart sample: https://github.com/nrfconnect/sdk-nrf/tree/v1.6.0/samples/peripheral/lpuart

    Here is the lpuart sample with flow control disabled: https://github.com/simon-iversen/sdk-nrf/tree/b548980db67ad4f05cfe2ac64e321d143c1111c7/samples/peripheral/lpuart 

  • Thank you, I will try it.

Related