Skip to content

Commit

Permalink
net: new downloader
Browse files Browse the repository at this point in the history
The new downloader is replacing the download_client library and is
based on that.

Internal restructuring:

* Restructuring of socket functions and files.
* Parse HTTP header line for line. This reduces the size requirement
  for the download client recv buffer.
* Change TLS range override logic.
* Use range requests for nRF91 TLS only, and when specified by app.

API updates:

* Let application provide client buffer. This allows for multiple
  download clients with different buffer sizes.
* Add downloader_deinit()
* Add downloader_stop()
* Remove downloader_disconnect()
* Changed signature of downloader_init(), downloader_start()
  and downloader_get() to take a URI.
* Added downloader_get_with_host_and_path() for downloads where
  host and path are separate arguments to keep backwards compatibility.
* The transports (http, coap) are now separated out of the download
  client with its own API.

Future work:

* Take uri as input param to fota_download library and use URI in
  other relevant libaries and structures.
* Curent download client is deprecated and will be removed later.

Signed-off-by: Eivind Jølsgard <[email protected]>
  • Loading branch information
eivindj-nordic committed Nov 14, 2024
1 parent d839e3c commit 649d1d7
Show file tree
Hide file tree
Showing 110 changed files with 5,306 additions and 405 deletions.
8 changes: 8 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
/doc/nrf/libraries/networking/azure_*.rst @nrfconnect/ncs-cia-doc
/doc/nrf/libraries/networking/coap_utils.rst @nrfconnect/ncs-terahertz-doc
/doc/nrf/libraries/networking/download_client.rst @nrfconnect/ncs-modem-doc
/doc/nrf/libraries/networking/downloader.rst @nrfconnect/ncs-modem-doc
/doc/nrf/libraries/networking/fota_download.rst @nrfconnect/ncs-pluto-doc
/doc/nrf/libraries/networking/ftp_client.rst @nrfconnect/ncs-iot-oulu-tampere-doc
/doc/nrf/libraries/networking/icalendar_parser.rst @nrfconnect/ncs-doc-leads
Expand Down Expand Up @@ -325,7 +326,10 @@
/include/mgmt/ @nrfconnect/ncs-pluto
/include/modem/ @nrfconnect/ncs-modem
/include/mpsl/ @nrfconnect/ncs-dragoon
/include/net/ @nrfconnect/ncs-co-networking
/include/net/azure_* @nrfconnect/ncs-cia @coderbyheart
/include/net/download_client* @nrfconnect/ncs-modem
/include/net/downloader* @nrfconnect/ncs-modem
/include/net/nrf_cloud_* @nrfconnect/ncs-nrf-cloud
/include/net/wifi_credentials.h @nrfconnect/ncs-cia
/include/nfc/ @nrfconnect/ncs-co-drivers @nrfconnect/ncs-si-muffin
Expand Down Expand Up @@ -674,6 +678,8 @@
/subsys/net/lib/mqtt_helper/ @nrfconnect/ncs-cia
/subsys/net/lib/azure_* @nrfconnect/ncs-cia @coderbyheart
/subsys/net/lib/aws_* @nrfconnect/ncs-cia @coderbyheart
/subsys/net/lib/download_client* @nrfconnect/ncs-modem
/subsys/net/lib/downloader/ @nrfconnect/ncs-modem
/subsys/net/lib/ftp_client/ @nrfconnect/ncs-iot-oulu
/subsys/net/lib/icalendar_parser/ @lats1980
/subsys/net/lib/lwm2m_client_utils/ @nrfconnect/ncs-co-networking @nrfconnect/ncs-iot-oulu
Expand Down Expand Up @@ -777,6 +783,8 @@
/tests/subsys/mpsl/ @nrfconnect/ncs-dragoon
/tests/subsys/net/lib/aws_*/ @nrfconnect/ncs-cia
/tests/subsys/net/lib/azure_iot_hub/ @nrfconnect/ncs-cia
/tests/subsys/net/lib/downloader/ @nrfconnect/ncs-modem
/tests/subsys/net/lib/download_client/ @nrfconnect/ncs-modem
/tests/subsys/net/lib/fota_download/ @nrfconnect/ncs-pluto
/tests/subsys/net/lib/lwm2m_*/ @nrfconnect/ncs-iot-oulu
/tests/subsys/net/lib/mqtt_helper/ @nrfconnect/ncs-cia
Expand Down
3 changes: 1 addition & 2 deletions applications/asset_tracker_v2/boards/native_sim.conf
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ CONFIG_NET_CONFIG_MY_IPV4_GW="192.0.2.2"
# FOTA
CONFIG_FOTA_DOWNLOAD=n
CONFIG_DFU_TARGET=n
CONFIG_DOWNLOAD_CLIENT=n
CONFIG_DOWNLOAD_CLIENT_HTTP_FRAG_SIZE_1024=n
CONFIG_DOWNLOADER=n

# MCUBOOT
CONFIG_BOOTLOADER_MCUBOOT=n
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ This application uses the following |NCS| libraries and drivers:
* :ref:`lib_date_time`
* :ref:`lte_lc_readme`
* :ref:`modem_info_readme`
* :ref:`lib_download_client`
* :ref:`lib_downloader`
* :ref:`lib_fota_download`
* :ref:`caf_leds`

Expand Down
4 changes: 2 additions & 2 deletions applications/asset_tracker_v2/overlay-carrier.conf
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ CONFIG_PDN=y
# AT Monitor is used by PDN library
CONFIG_AT_MONITOR=y

# Download client for DFU
CONFIG_DOWNLOAD_CLIENT_MAX_FILENAME_SIZE=230
# Downloader for DFU
CONFIG_DOWNLOADER_MAX_FILENAME_SIZE=230

# Modem info
CONFIG_MODEM_INFO_BUFFER_SIZE=512
Expand Down
8 changes: 3 additions & 5 deletions applications/asset_tracker_v2/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,9 @@ CONFIG_FCB=y
# FOTA
CONFIG_FOTA_DOWNLOAD=y
CONFIG_DFU_TARGET=y
CONFIG_DOWNLOAD_CLIENT=y
CONFIG_DOWNLOAD_CLIENT_HTTP_FRAG_SIZE_1024=y
CONFIG_DOWNLOAD_CLIENT_STACK_SIZE=4096
CONFIG_DOWNLOAD_CLIENT_BUF_SIZE=2300
CONFIG_DOWNLOAD_CLIENT_MAX_HOSTNAME_SIZE=128
CONFIG_DOWNLOADER=y
CONFIG_DOWNLOADER_STACK_SIZE=4096
CONFIG_DOWNLOADER_MAX_HOSTNAME_SIZE=128

# Flash - Used in FOTA, settings and storage for P-GPS.
CONFIG_FLASH=y
Expand Down
2 changes: 1 addition & 1 deletion applications/serial_lte_modem/doc/slm_description.rst
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ This application uses the following |NCS| libraries:
* :ref:`lib_ftp_client`
* :ref:`sms_readme`
* :ref:`lib_fota_download`
* :ref:`lib_download_client`
* :ref:`lib_downloader`
* :ref:`lib_nrf_cloud`
* :ref:`lib_nrf_cloud_agnss`
* :ref:`lib_nrf_cloud_pgps`
Expand Down
2 changes: 1 addition & 1 deletion applications/serial_lte_modem/overlay-carrier.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ CONFIG_FP_HARDABI=y
CONFIG_PDN=y

# Download client for DFU
CONFIG_DOWNLOAD_CLIENT_MAX_FILENAME_SIZE=230
CONFIG_DOWNLOADER_MAX_FILENAME_SIZE=230

# Modem info
CONFIG_MODEM_INFO_BUFFER_SIZE=512
Expand Down
6 changes: 3 additions & 3 deletions applications/serial_lte_modem/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ CONFIG_HTTP_PARSER_URL=y
CONFIG_FOTA_DOWNLOAD=y
CONFIG_FOTA_DOWNLOAD_PROGRESS_EVT=y
CONFIG_DFU_TARGET=y
CONFIG_DOWNLOAD_CLIENT=y
CONFIG_DOWNLOAD_CLIENT_STACK_SIZE=4096
CONFIG_DOWNLOAD_CLIENT_MAX_FILENAME_SIZE=2048
CONFIG_DOWNLOADER=y
CONFIG_DOWNLOADER_STACK_SIZE=4096
CONFIG_DOWNLOADER_MAX_FILENAME_SIZE=2048
CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_IMG_MANAGER=y

Expand Down
4 changes: 2 additions & 2 deletions applications/serial_lte_modem/src/slm_at_fota.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
LOG_MODULE_REGISTER(slm_fota, CONFIG_SLM_LOG_LEVEL);

/* file_uri: scheme://hostname[:port]path[?parameters] */
#define FILE_URI_MAX CONFIG_DOWNLOAD_CLIENT_MAX_FILENAME_SIZE
#define FILE_URI_MAX CONFIG_DOWNLOADER_MAX_FILENAME_SIZE
#define SCHEMA_HTTP "http"
#define SCHEMA_HTTPS "https"
#define URI_HOST_MAX CONFIG_DOWNLOAD_CLIENT_MAX_HOSTNAME_SIZE
#define URI_HOST_MAX CONFIG_DOWNLOADER_MAX_HOSTNAME_SIZE
#define URI_SCHEMA_MAX 8
#define ERASE_POLL_TIME 2

Expand Down
2 changes: 1 addition & 1 deletion doc/nrf/libraries/bin/lwm2m_carrier/app_integration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ It provides an abstraction of the following modules:
.. lwm2m_osal_mod_list_start
* :ref:`at_monitor_readme`
* :ref:`lib_download_client`
* :ref:`lib_downloader`
* :ref:`sms_readme`
* :ref:`pdn_readme`
* :ref:`lib_dfu_target`
Expand Down
2 changes: 1 addition & 1 deletion doc/nrf/libraries/bin/lwm2m_carrier/requirements.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Following are some of the requirements and limitations of the application while
* For example, setting :kconfig:option:`CONFIG_LWM2M_CARRIER_SERVER_SEC_TAG` to 42 uses the security tag range 43 to 46 instead of 25 to 28.

* The CA certificates that are used for out-of-band FOTA must be provided by the application.
Out-of-band FOTA updates are done by the :ref:`lib_download_client`.
Out-of-band FOTA updates are done by the :ref:`lib_downloader`.
Although the certificates are updated as part of the |NCS| releases, you must check the requirements from your carrier to know which certificates are applicable.

* The LwM2M carrier library uses the following NVS record key range: ``0xCA00`` to ``0xCAFF``.
Expand Down
16 changes: 8 additions & 8 deletions doc/nrf/libraries/networking/aws_fota.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Creating a FOTA job
#. Click the uploaded image file :file:`app_update.bin` and copy the *Object URL* without the *https://* prefix and folder path.
#. Create a text file (job document) with content as in the snippet, replacing the following data:

* *protocol* with either `http` or `https`.
* *protocol* with either ``http`` or ``https``.
* *host_url* with the *Object URL* copied in the previous step (for example, ``examplebucket.s3.eu-central-1.amazonaws.com``).
* *file_path* with the path and file name (for example, ``app_update.bin``).

Expand Down Expand Up @@ -105,10 +105,10 @@ Configure the following parameters when using this library:
* :kconfig:option:`CONFIG_AWS_FOTA_PAYLOAD_SIZE` - Sets the maximum payload size for AWS IoT job messages.
* :kconfig:option:`CONFIG_AWS_FOTA_DOWNLOAD_SECURITY_TAG` - Sets the security tag to be used in case of HTTPS downloads.

Additionally, configure the :ref:`lib_download_client` library:
Additionally, configure the :ref:`lib_downloader` library:

* :kconfig:option:`CONFIG_DOWNLOAD_CLIENT_MAX_HOSTNAME_SIZE` - Sets the maximum length of the host name for the download client.
* :kconfig:option:`CONFIG_DOWNLOAD_CLIENT_MAX_FILENAME_SIZE` - Sets the maximum length of the file name for the download client.
* :kconfig:option:`CONFIG_DOWNLOADER_MAX_HOSTNAME_SIZE` - Sets the maximum length of the host name for the download client.
* :kconfig:option:`CONFIG_DOWNLOADER_MAX_FILENAME_SIZE` - Sets the maximum length of the file name for the download client.

.. _aws_fota_implementation:

Expand All @@ -133,7 +133,7 @@ The following sequence diagram shows how a firmware over-the-air update is imple
AWS IoT jobs
============

The implementation uses a job document like the following (where *protocol* is either `http` or `https`, *bucket_name* is the name of your bucket and *file_name* is the name of your file) for passing information from `AWS IoT jobs`_ to the device:
The implementation uses a job document like the following (where *protocol* is either ``http`` or ``https``, *bucket_name* is the name of your bucket and *file_name* is the name of your file) for passing information from `AWS IoT jobs`_ to the device:

.. parsed-literal::
:class: highlight
Expand Down Expand Up @@ -191,17 +191,17 @@ Presigned URLs

When using the presigned URLs, you might need to increase the value of the following Kconfig options to accommodate the long file name and payload size of the presigned URL and the secure download of the image:

* :kconfig:option:`CONFIG_DOWNLOAD_CLIENT_MAX_FILENAME_SIZE`.
* :kconfig:option:`CONFIG_DOWNLOADER_MAX_FILENAME_SIZE`.
* :kconfig:option:`CONFIG_AWS_FOTA_PAYLOAD_SIZE`.
* :kconfig:option:`CONFIG_MBEDTLS_HEAP_SIZE` - If running Mbed TLS on the application core (Wi-Fi® builds).

Limitations
***********

* If the :kconfig:option:`CONFIG_AWS_FOTA_DOWNLOAD_SECURITY_TAG` Kconfig option is not configured but HTTPS is selected as the protocol, the update job fails.
For further information about HTTPS support, refer to :ref:`the HTTPS section of the download client documentation <download_client_https>`.
For further information about HTTPS support, refer to :ref:`the HTTPS section of the download client documentation <downloader_https>`.
* The library requires a Content-Range header to be present in the HTTP response from the server.
This limitation is inherited from the :ref:`lib_download_client` library.
This limitation is inherited from the :ref:`lib_downloader` library.

API documentation
*****************
Expand Down
8 changes: 4 additions & 4 deletions doc/nrf/libraries/networking/azure_fota.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,16 @@ Configure the following parameters when using this library:
* :kconfig:option:`CONFIG_AZURE_FOTA_TLS` - Enables HTTPS for downloads. By default, TLS is enabled and currently, the transport protocol must be configured at compile time.
* :kconfig:option:`CONFIG_AZURE_FOTA_SEC_TAG` - Sets the security tag for TLS credentials when using HTTPS as the transport layer. See :ref:`azure_iot_hub_flash_certs` for more details.

Additionally, configure the :ref:`lib_download_client` library:
Additionally, configure the :ref:`lib_downloader` library:

* :kconfig:option:`CONFIG_DOWNLOAD_CLIENT_MAX_HOSTNAME_SIZE` - Sets the maximum length of the host name for the download client.
* :kconfig:option:`CONFIG_DOWNLOAD_CLIENT_MAX_FILENAME_SIZE` - Sets the maximum length of the file name for the download client.
* :kconfig:option:`CONFIG_DOWNLOADER_MAX_HOSTNAME_SIZE` - Sets the maximum length of the host name for the download client.
* :kconfig:option:`CONFIG_DOWNLOADER_MAX_FILENAME_SIZE` - Sets the maximum length of the file name for the download client.

Limitations
***********

The library requires a ``Content-Range`` header to be present in the HTTP response from the server.
This limitation is inherited from the :ref:`lib_download_client` library.
This limitation is inherited from the :ref:`lib_downloader` library.

API documentation
*****************
Expand Down
Loading

0 comments on commit 649d1d7

Please sign in to comment.