Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: lib: nrf_cloud_fota: enable SMP FOTA #17489

Merged
merged 3 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,7 @@ Libraries for networking
* The handling of MQTT JITP device association to improve speed and reliability.
* To use nRF Cloud's custom MQTT topics instead of the default AWS topics.
* MQTT and CoAP transports to use a single unified DNS lookup mechanism that supports IPv4 and IPv6, fallback to IPv4, and handling of multiple addresses returned by :c:func:`getaddrinfo`.
* The log module in the :file:`nrf_cloud_fota_common.c` file from ``NRF_CLOUD`` to ``NRF_CLOUD_FOTA``.

* Deprecated:

Expand Down Expand Up @@ -857,6 +858,7 @@ Libraries for networking

* FOTA status callback.
* The :kconfig:option:`CONFIG_NRF_CLOUD_COAP_DISCONNECT_ON_FAILED_REQUEST` Kconfig option to disconnect the CoAP client on a failed request.
* The :kconfig:option:`CONFIG_NRF_CLOUD_FOTA_SMP` Kconfig option to enable experimental support for SMP FOTA using MQTT.

* Updated:

Expand Down
44 changes: 43 additions & 1 deletion include/net/nrf_cloud.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ enum nrf_cloud_fota_type {

/** Full modem update */
NRF_CLOUD_FOTA_MODEM_FULL = 5,
/** Auxiliary device updated using SMP */
NRF_CLOUD_FOTA_SMP = 6,

NRF_CLOUD_FOTA_TYPE__INVALID
};
Expand Down Expand Up @@ -438,9 +440,11 @@ struct nrf_cloud_svc_info_fota {
uint8_t application:1;
/** Flag to indicate if full modem image updates are supported */
uint8_t modem_full:1;
/** Flag to indicate if smp updates are supported */
uint8_t smp:1;

/** Reserved for future use */
uint8_t _rsvd:4;
uint8_t _rsvd:3;
};

/** @brief DEPRECATED - No longer used by nRF Cloud */
Expand Down Expand Up @@ -664,6 +668,12 @@ struct nrf_cloud_init_param {
* @kconfig{CONFIG_NRF_CLOUD_SEND_DEVICE_STATUS} is enabled.
*/
const char *application_version;

/** Callback of type @ref dfu_target_reset_cb_t for resetting the SMP device to enter
* MCUboot recovery mode.
* Used if @kconfig{CONFIG_NRF_CLOUD_FOTA_SMP} is enabled.
*/
void *smp_reset_cb;
};

/**
Expand Down Expand Up @@ -1078,6 +1088,38 @@ bool nrf_cloud_fota_is_type_enabled(const enum nrf_cloud_fota_type type);
*/
int nrf_cloud_fota_job_start(void);

/**
* @brief Install a downloaded SMP FOTA job.
* Called automatically if @kconfig{CONFIG_NRF_CLOUD_FOTA} is enabled (MQTT FOTA).
*
* @retval 0 SMP update installed successfully.
* @retval -ENOTSUP Error; @kconfig{CONFIG_NRF_CLOUD_FOTA_SMP} is not enabled.
* @retval -EIO Error; failed to schedule image installation.
* @retval -EPROTO Error; failed to reset SMP device.
* @return A negative value indicates an error.
*/
int nrf_cloud_fota_smp_install(void);

/**
* @brief Read the image info from the SMP device to obtain the current version.
*
* @retval 0 Success; call @ref nrf_cloud_fota_smp_version_get to get the version string.
* @retval -ENOBUFS Error; internal buffer is too small to hold version string.
* @return A negative value indicates an error.
*/
int nrf_cloud_fota_smp_version_read(void);

/**
* @brief Get the current version string of the SMP device.
* An empty string will be returned if @ref nrf_cloud_fota_smp_version_read has
* not been successfully called.
*
* @retval 0 Success.
* @retval -ENOBUFS Error; internal buffer is too small to hold version string.
* @return A negative value indicates an error.
*/
int nrf_cloud_fota_smp_version_get(char **smp_ver_out);

/**
* @brief Check if credentials exist in the configured location.
*
Expand Down
3 changes: 3 additions & 0 deletions include/net/nrf_cloud_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@
#define NRF_CLOUD_FOTA_TYPE_MODEM_FULL "MDM_FULL"
#define NRF_CLOUD_FOTA_TYPE_BOOT "BOOT"
#define NRF_CLOUD_FOTA_TYPE_APP "APP"
#define NRF_CLOUD_FOTA_TYPE_SMP "SMP"
#define NRF_CLOUD_FOTA_TYPE_CUSTOM "CUSTOM"
#define NRF_CLOUD_FOTA_REST_KEY_JOB_DOC "jobDocument"
#define NRF_CLOUD_FOTA_REST_KEY_JOB_ID "jobId"
#define NRF_CLOUD_FOTA_REST_KEY_PATH "path"
Expand Down Expand Up @@ -196,6 +198,7 @@
#define NRF_CLOUD_JSON_KEY_KEEPALIVE "keepalive"
#define NRF_CLOUD_JSON_KEY_CONN "connection"
#define NRF_CLOUD_JSON_KEY_APP_VER "appVersion"
#define NRF_CLOUD_JSON_KEY_SMP_APP_VER "smpDevAppVer"
#define NRF_CLOUD_JSON_KEY_CONN_INFO "connectionInfo"
#define NRF_CLOUD_JSON_KEY_PROTOCOL "protocol"
#define NRF_CLOUD_JSON_KEY_METHOD "method"
Expand Down
98 changes: 35 additions & 63 deletions subsys/net/lib/nrf_cloud/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,80 +5,34 @@

menu "nRF Cloud"

rsource "Kconfig.nrf_cloud_client_id"
menu "Transport"

rsource "Kconfig.nrf_cloud_mqtt"

rsource "Kconfig.nrf_cloud_fota"

rsource "Kconfig.nrf_cloud_agnss"

rsource "Kconfig.nrf_cloud_pgps"

rsource "Kconfig.nrf_cloud_rest"

rsource "Kconfig.nrf_cloud_location"
if NRF_CLOUD_MQTT || NRF_CLOUD_REST

rsource "Kconfig.nrf_cloud_alert"
config NRF_CLOUD_HOST_NAME
string "nRF Cloud server hostname"
default "mqtt.nrfcloud.com"
help
Used for MQTT and JITP performed with REST

rsource "Kconfig.nrf_cloud_log"
endif # NRF_CLOUD_MQTT || NRF_CLOUD_REST

rsource "Kconfig.nrf_cloud_coap"

rsource "Kconfig.nrf_cloud_shadow_info"

config NRF_CLOUD_VERBOSE_DETAILS
bool "Log more info about cloud connection"
default y
help
Log at INF level the stage, protocol, sec tag, host name, and team ID,
in addition to device id.
endmenu # "Transport"
jayteemo marked this conversation as resolved.
Show resolved Hide resolved

config NRF_CLOUD_GATEWAY
bool "nRF Cloud Gateway"
help
Enables functionality in this device to be compatible with
nRF Cloud LTE gateway support.
menu "Credentials"

config NRF_CLOUD_SEC_TAG
int "Security tag to use for nRF Cloud connection"
default 16842753

if NRF_CLOUD_MQTT || NRF_CLOUD_REST || NRF_CLOUD_PGPS || MODEM_JWT || NRF_CLOUD_COAP

config NRF_CLOUD_HOST_NAME
string "nRF Cloud server hostname"
default "mqtt.nrfcloud.com"
help
Used for MQTT and JITP performed with REST

config NRF_CLOUD_DEVICE_STATUS_ENCODE_VOLTAGE
bool "Include the (battery) voltage when encoding device status"
depends on MODEM_INFO
depends on MODEM_INFO_ADD_DEVICE
default y

choice NRF_CLOUD_WIFI_LOCATION_ENCODE_OPT
prompt "Encoding options for Wi-Fi location requests"
default NRF_CLOUD_WIFI_LOCATION_ENCODE_OPT_MAC_RSSI

config NRF_CLOUD_WIFI_LOCATION_ENCODE_OPT_MAC_ONLY
bool "Encode only the MAC address"
help
The MAC address is the only required parameter.

config NRF_CLOUD_WIFI_LOCATION_ENCODE_OPT_MAC_RSSI
bool "Encode the MAC address and the RSSI value"
help
The RSSI value may improve location accuracy.

config NRF_CLOUD_WIFI_LOCATION_ENCODE_OPT_ALL
bool "Encode all available parameters"
help
This option increases the memory required for creating requests.
It also increases the amount of data sent to nRF Cloud.
endchoice

config NRF_CLOUD_PROVISION_CERTIFICATES
bool "Install credentials for nRF Cloud connection"
select EXPERIMENTAL
Expand Down Expand Up @@ -135,6 +89,8 @@ config NRF_CLOUD_CREDENTIALS_MGMT_TLS_CRED
select TLS_CREDENTIALS
endchoice

endif # NRF_CLOUD_MQTT || NRF_CLOUD_REST || NRF_CLOUD_PGPS || MODEM_JWT || NRF_CLOUD_COAP

config NRF_CLOUD_JWT_SOURCE_CUSTOM
bool "Custom JWT creation and signing"
select EXPERIMENTAL
Expand All @@ -151,21 +107,37 @@ config NRF_CLOUD_JWT_SOURCE_CUSTOM
help
JWTs are created and signed by the nRF Cloud library, not the modem.
The signing key is obtained from the TLS credentials module.
endmenu # "Credentials"

endif # NRF_CLOUD_MQTT || NRF_CLOUD_REST || NRF_CLOUD_PGPS || MODEM_JWT || NRF_CLOUD_COAP
rsource "Kconfig.nrf_cloud_client_id"

rsource "Kconfig.nrf_cloud_fota"

if NRF_CLOUD_AGNSS || NRF_CLOUD_PGPS
rsource "Kconfig.nrf_cloud_location"

module = NRF_CLOUD_GPS
module-str = nRF Cloud GPS Assistance
source "subsys/logging/Kconfig.template.log_config"
rsource "Kconfig.nrf_cloud_alert"

endif
rsource "Kconfig.nrf_cloud_log"

rsource "Kconfig.nrf_cloud_shadow_info"

config NRF_CLOUD_VERBOSE_DETAILS
bool "Log more info about cloud connection"
default y
help
Log at INF level the stage, protocol, sec tag, host name, and team ID,
in addition to device id.

config NRF_CLOUD_GATEWAY
bool "nRF Cloud Gateway"
help
Enables functionality in this device to be compatible with
nRF Cloud LTE gateway support.

module=NRF_CLOUD
module-dep=LOG
module-str=Log level for nRF Cloud
module-help=Enables nRF Cloud log messages.
source "subsys/logging/Kconfig.template.log_config"

endmenu
endmenu # "nRF Cloud"
3 changes: 3 additions & 0 deletions subsys/net/lib/nrf_cloud/Kconfig.nrf_cloud_alert
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#
menu "Alerts"

menuconfig NRF_CLOUD_ALERT
bool "nRF Cloud Alert System"
Expand All @@ -21,3 +22,5 @@ endif # NRF_CLOUD_ALERT
module = NRF_CLOUD_ALERT
module-str = nRF Cloud Alert
source "subsys/logging/Kconfig.template.log_config"

endmenu
68 changes: 42 additions & 26 deletions subsys/net/lib/nrf_cloud/Kconfig.nrf_cloud_fota
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#
menu "Firmware Over-the-Air (FOTA) Updates"

menuconfig NRF_CLOUD_FOTA
bool "Enable nRF Cloud MQTT FOTA library"
bool "nRF Cloud MQTT FOTA library"
select FOTA_DOWNLOAD
select FOTA_DOWNLOAD_PROGRESS_EVT
select DFU_TARGET
select DOWNLOAD_CLIENT
select REBOOT
select CJSON_LIB
select SETTINGS
depends on FOTA_USE_NRF_CLOUD_SETTINGS_AREA
default y if NRF_CLOUD_MQTT

if NRF_CLOUD_FOTA
Expand All @@ -34,26 +36,28 @@ config NRF_CLOUD_FOTA_BLE_DEVICES
bool "Enable API for FOTA of BLE devices"
depends on BT

module = NRF_CLOUD_FOTA
module-str = nRF Cloud FOTA
source "subsys/logging/Kconfig.template.log_config"

endif # NRF_CLOUD_FOTA

config NRF_CLOUD_FOTA_DOWNLOAD_FRAGMENT_SIZE
int "Fragment size for FOTA downloads"
depends on FOTA_DOWNLOAD
range 128 1900
default 1700

config FOTA_USE_NRF_CLOUD_SETTINGS_AREA
bool "Use the same settings area as the nRF Cloud FOTA library"
bool "Use the settings area defined by nRF Cloud FOTA library"
default y
help
Using the same settings area as the nRF Cloud FOTA library will
allow this sample to perform application-FOTA updates to applications
built with CONFIG_NRF_CLOUD_FOTA enabled.

config NRF_CLOUD_FOTA_POLL
bool "FOTA job polling helpers (REST/CoAP)"
depends on !NRF_CLOUD_FOTA
depends on FOTA_DOWNLOAD
select FOTA_DOWNLOAD_EXTERNAL_DL if NRF_CLOUD_COAP_DOWNLOADS
help
When enabled, nRF Cloud FOTA job polling helpers will be built. These
functions make it easy to request, download, and handle modem, boot,
and application FOTA updates when using the REST or CoAP interfaces
to nRF Cloud.
if NRF_CLOUD_FOTA_POLL

config FOTA_SETTINGS_NAME
depends on !FOTA_USE_NRF_CLOUD_SETTINGS_AREA
string "Settings identifier for the FOTA support library"
Expand Down Expand Up @@ -81,6 +85,16 @@ config FOTA_DL_TIMEOUT_MIN
the download will be cancelled and the job status will be
set as failed.

module = NRF_CLOUD_FOTA_POLL
module-str = nRF Cloud FOTA Poll
source "subsys/logging/Kconfig.template.log_config"
endif # NRF_CLOUD_FOTA_POLL

config NRF_CLOUD_FOTA_DOWNLOAD_FRAGMENT_SIZE
int "Fragment size for FOTA downloads"
depends on FOTA_DOWNLOAD
range 128 1900
default 1700
if NRF_CLOUD_REST

config REST_FOTA_DL_TIMEOUT_MIN
Expand All @@ -90,7 +104,7 @@ config REST_FOTA_DL_TIMEOUT_MIN
endif # NRF_CLOUD_REST

menuconfig NRF_CLOUD_FOTA_FULL_MODEM_UPDATE
bool "Enable full modem FOTA updates"
bool "Full modem FOTA updates"
select NRF_MODEM_LIB
select ZCBOR
select DFU_TARGET
Expand All @@ -114,6 +128,14 @@ config NRF_CLOUD_FOTA_FULL_MODEM_UPDATE_BUF_SIZE
default 4096
endif # NRF_CLOUD_FOTA_FULL_MODEM_UPDATE

config NRF_CLOUD_FOTA_SMP
bool "SMP FOTA updates"
depends on NRF_CLOUD_FOTA
select NRF_MCUMGR_SMP_CLIENT
select EXPERIMENTAL
help
Enables FOTA updates to an auxiliary MCU using SMP.

config NRF_CLOUD_FOTA_TRANSPORT_ENABLED
bool
default y if (NRF_CLOUD_REST || NRF_CLOUD_COAP || NRF_CLOUD_FOTA)
Expand Down Expand Up @@ -146,20 +168,14 @@ config NRF_CLOUD_FOTA_TYPE_MODEM_FULL_SUPPORTED
help
This symbol is y when full modem FOTA is supported by the configuration.

config NRF_CLOUD_FOTA_POLL
bool "Enable FOTA job polling helpers"
depends on FOTA_DOWNLOAD
select FOTA_DOWNLOAD_EXTERNAL_DL if NRF_CLOUD_COAP_DOWNLOADS
config NRF_CLOUD_FOTA_TYPE_SMP_SUPPORTED
bool
default y if NRF_CLOUD_FOTA_SMP
help
When enabled, nRF Cloud FOTA job polling helpers will be built. These
functions make it easy to request, download, and handle modem, boot,
and application FOTA updates when using the REST or CoAP interfaces
to nRF Cloud.

if NRF_CLOUD_FOTA_POLL
This symbol is y when SMP FOTA is supported by the configuration.

module = NRF_CLOUD_FOTA_POLL
module-str = nRF Cloud FOTA Poll
module = NRF_CLOUD_FOTA
module-str = nRF Cloud FOTA
source "subsys/logging/Kconfig.template.log_config"
plskeggs marked this conversation as resolved.
Show resolved Hide resolved

endif # NRF_CLOUD_FOTA_POLL
endmenu
Loading
Loading