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

FOTA update own server

Dear Community;

We are trying to implement  HTTP application update with our own server. We have flashed the "http_application_update" project to an nRF9160. It works fine with AWS, but we get an error with our own server:

Press Button 1 to start the FOTA download
I: Attempting to connect over IPv4
I: Connected to x.x.x.x
I: Downloading: app_update.bin [0]
I: Downloaded 4096/144540 bytes (2%)
I: Erasing sector at offset 0x00088000
I: Erasing sector at offset 0x00089000
ASSERTION FAIL [dl->offset < sizeof(dl->buf)] @ /Users/Documents/ncs_last/nrf/subsys/net/lib/download_client/src/down5
        Buffer overflow

Any clue about what's going wrong?

Thanks in advance.

Parents
  • Hi,

    Which SDK version are you using?

    Could you try again with added logging in the download_client library?

    Add the following lines to your prj.conf file (if you are using SES, you must re-open the project for the changes to take effect):

    CONFIG_DOWNLOAD_CLIENT_LOG_LEVEL_DBG=y
    CONFIG_FOTA_DOWNLOAD_LOG_LEVEL_DBG=y
    CONFIG_LOG_MINIMAL=n

    Also, are you certain that your server did not send a fragment that was too big?

    Finally, are you using TLS?

    Best regards,

    Didrik

Reply
  • Hi,

    Which SDK version are you using?

    Could you try again with added logging in the download_client library?

    Add the following lines to your prj.conf file (if you are using SES, you must re-open the project for the changes to take effect):

    CONFIG_DOWNLOAD_CLIENT_LOG_LEVEL_DBG=y
    CONFIG_FOTA_DOWNLOAD_LOG_LEVEL_DBG=y
    CONFIG_LOG_MINIMAL=n

    Also, are you certain that your server did not send a fragment that was too big?

    Finally, are you using TLS?

    Best regards,

    Didrik

Children
  • Hi,

    Thank you for your answer. 

    Could you try again with added logging in the download_client library?

    Press Button 1 to start the FOTA download
    [00:00:06.328,125] <inf> download_client: Attempting to connect over IPv4
    [00:00:06.677,612] <inf> download_client: Connected to x.x.x.x
    [00:00:06.677,612] <inf> download_client: Downloading: app_update.bin [0]
    [00:00:06.677,734] <dbg> download_client.get_request_send: Sending HTTP request
    [00:00:06.678,344] <dbg> download_client.download_thread: Receiving up to 4096 bytes at 0x20020004...
    [00:00:07.021,667] <dbg> download_client.download_thread: Read 227 bytes from socket
    [00:00:07.021,697] <dbg> download_client.header_parse: GET header size: 227
    [00:00:07.021,728] <dbg> download_client.header_parse: File size = 144540
    [00:00:07.021,789] <dbg> download_client.download_thread: Awaiting full fragment (0)
    [00:00:07.021,789] <dbg> download_client.download_thread: Receiving up to 4096 bytes at 0x20020004...
    [00:00:07.145,996] <dbg> download_client.download_thread: Read 708 bytes from socket
    [00:00:07.146,026] <dbg> download_client.download_thread: Awaiting full fragment (708)
    [00:00:07.146,057] <dbg> download_client.download_thread: Receiving up to 3388 bytes at 0x200202c8...
    [00:00:07.258,178] <dbg> download_client.download_thread: Read 708 bytes from socket
    [00:00:07.258,178] <dbg> download_client.download_thread: Awaiting full fragment (1416)
    [00:00:07.258,178] <dbg> download_client.download_thread: Receiving up to 2680 bytes at 0x2002058c...
    [00:00:08.726,654] <dbg> download_client.download_thread: Read 1024 bytes from socket
    [00:00:08.726,684] <dbg> download_client.download_thread: Awaiting full fragment (2440)
    [00:00:08.726,684] <dbg> download_client.download_thread: Receiving up to 1656 bytes at 0x2002098c...
    [00:00:08.727,294] <dbg> download_client.download_thread: Read 1656 bytes from socket
    [00:00:08.727,294] <inf> download_client: Downloaded 4096/144540 bytes (2%)
    [00:00:08.727,355] <inf> fota_flash_block: Erasing sector at offset 0x00088000
    [00:00:08.858,001] <inf> fota_flash_block: Erasing sector at offset 0x00089000
    [00:00:08.949,737] <dbg> download_client.get_request_send: Sending HTTP request
    [00:00:08.950,286] <dbg> download_client.download_thread: Receiving up to 4096 bytes at 0x20020004...
    [00:00:08.950,531] <dbg> download_client.download_thread: Read 3692 bytes from socket
    [00:00:08.950,592] <dbg> download_client.header_parse: Awaiting full header in response
    [00:00:08.950,592] <dbg> download_client.download_thread: Receiving up to 404 bytes at 0x20020e70...
    ASSERTION FAIL [dl->offset < sizeof(dl->buf)] @ /Users/Documents/ncs_last/nrf/subsys/net/lib/do5
            Buffer overflow
    [00:00:09.210,021] <dbg> download_client.download_thread: Read 404 bytes from socket
    [00:00:09.210,052] <dbg> download_client.header_parse: Awaiting full header in response
    [00:00:09.224,609] <err> os: r0/a1:  0x00000004  r1/a2:  0x0000019f  r2/a3:  0x00000001
    [00:00:09.224,609] <err> os: r3/a4:  0x0001dc65 r12/ip:  0x00000000 r14/lr:  0x00022583
    [00:00:09.224,609] <err> os:  xpsr:  0x61000000
    [00:00:09.224,639] <err> os: s[ 0]:  0x00000000  s[ 1]:  0x00000000  s[ 2]:  0x00000000  s[ 3]:  0x00000000
    [00:00:09.224,639] <err> os: s[ 4]:  0x00000000  s[ 5]:  0x00000000  s[ 6]:  0x00000000  s[ 7]:  0x00000000
    [00:00:09.224,670] <err> os: s[ 8]:  0x00000000  s[ 9]:  0x00000000  s[10]:  0x00000000  s[11]:  0x00000000
    [00:00:09.224,670] <err> os: s[12]:  0x00000000  s[13]:  0x00000000  s[14]:  0x00000000  s[15]:  0x00000000
    [00:00:09.224,670] <err> os: fpscr:  0x00000000
    [00:00:09.224,700] <err> os: Faulting instruction address (r15/pc): 0x0002fdba
    [00:00:09.224,731] <err> os: >>> ZEPHYR FATAL ERROR 4: Kernel panic on CPU 0
    [00:00:09.224,731] <err> os: Current thread: 0x20021030 (unknown)
    [00:00:09.333,007] <err> fatal_error: Resetting system

    Which SDK version are you using?

    We use "Zephyr OS build v2.1.99-ncs1-16-ge23d8ac48dd0"

    Finally, are you using TLS?

    We don't use TLS.

    Also, are you certain that your server did not send a fragment that was too big?

    Not 100% sure, is there any way to check that?

    Regards;

    Ander.

  • Thanks for the log.

    It looks like the device is able to download the first fragment of 4096 bytes, but fails on the second one.

    How does the server send the image to the device? Does it just send the whole image in one go?

    I haven't looked deep into exactly how the download_client library downloads an image, but my impression was that it asks for only a small part, and then send a new HTTP request for the next part, and so on.

    If it then only receives more of the file, and not a new HTTP response, that might explain this failure.

    And from the logs, it seems it doesn't find a HTTP header in response to the second request.

    Could you capture a modem trace? Or capture the IP packets sent from the server?

Related