-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
samples: cellular: nrf_cloud_rest_fota: add smp fota for nrf9160dk
Add the option to enable SMP FOTA on the nRF9160DK. IRIS-9481 Signed-off-by: Justin Morton <[email protected]>
- Loading branch information
Showing
8 changed files
with
169 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,6 +115,19 @@ To enable full modem FOTA, add the following parameter to your build command: | |
Also, if you are using an nRF9160 DK, specify your development kit version by appending it to the board name. | ||
For example, if you are using version 1.0.1, use the board name ``[email protected]/nrf9160/ns`` in your build command. | ||
|
||
To enable SMP FOTA (nRF9160 DK only), add the following parameters to your build command: | ||
|
||
* ``-DEXTRA_CONF_FILE=overlay_smp_fota.conf`` | ||
* ``-DEXTRA_DTC_OVERLAY_FILE=nrf9160dk_mcumgr_client_uart2.overlay`` | ||
|
||
The nRF52840 device on your DK must be running an SMP compatible firmware, such as the :ref:`smp_svr` sample. | ||
Build the :ref:`smp_svr` sample for the ``nrf9160dk/nrf52840`` board with the following parameters: | ||
|
||
* ``-DEXTRA_CONF_FILE=overlay_smp_fota.conf`` | ||
* ``-DEXTRA_DTC_OVERLAY_FILE=nrf9160dk_mcumgr_client_uart2.overlay`` | ||
|
||
To change :ref:`smp_svr` sample's application version, set the :kconfig:option:`CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION` Kconfig option. | ||
|
||
Dependencies | ||
************ | ||
|
||
|
46 changes: 46 additions & 0 deletions
46
samples/cellular/nrf_cloud_rest_fota/nrf9160dk_mcumgr_client_uart2.overlay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright (c) 2024 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
*/ | ||
|
||
/* Generic PIN definition for UART2 or UART1 to nRF52840 */ | ||
&pinctrl { | ||
mcumgr_uart_default: mcumgr_uart_default { | ||
group1 { | ||
psels = <NRF_PSEL(UART_TX, 0, 23)>, | ||
<NRF_PSEL(UART_RTS, 0, 17)>; | ||
}; | ||
group2 { | ||
psels = <NRF_PSEL(UART_RX, 0, 21)>, | ||
<NRF_PSEL(UART_CTS, 0, 22)>; | ||
bias-pull-up; | ||
}; | ||
}; | ||
|
||
mcumgr_uart_sleep: mcumgr_uart_sleep { | ||
group1 { | ||
psels = <NRF_PSEL(UART_TX, 0, 23)>, | ||
<NRF_PSEL(UART_RX, 0, 21)>, | ||
<NRF_PSEL(UART_RTS, 0, 17)>, | ||
<NRF_PSEL(UART_CTS, 0, 22)>; | ||
low-power-enable; | ||
}; | ||
}; | ||
}; | ||
|
||
&uart2 { | ||
compatible = "nordic,nrf-uarte"; | ||
current-speed = <1000000>; | ||
status = "okay"; | ||
pinctrl-0 = <&mcumgr_uart_default>; | ||
pinctrl-1 = <&mcumgr_uart_sleep>; | ||
pinctrl-names = "default", "sleep"; | ||
hw-flow-control; | ||
}; | ||
|
||
/ { | ||
chosen { | ||
zephyr,uart-mcumgr = &uart2; | ||
}; | ||
}; |
12 changes: 12 additions & 0 deletions
12
samples/cellular/nrf_cloud_rest_fota/overlay_smp_fota.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# | ||
# Copyright (c) 2024 Nordic Semiconductor ASA | ||
# | ||
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
# | ||
CONFIG_NRF_CLOUD_FOTA_SMP=y | ||
CONFIG_NRF_MCUMGR_SMP_CLIENT=y | ||
CONFIG_MCUMGR_GRP_IMG=y | ||
CONFIG_MCUMGR_GRP_OS=y | ||
CONFIG_MCUMGR_TRANSPORT_UART=y | ||
CONFIG_UART_MCUMGR_RX_BUF_COUNT=4 | ||
CONFIG_BOOT_IMAGE_ACCESS_HOOKS=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright (c) 2024 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
*/ | ||
#include <zephyr/kernel.h> | ||
#include <zephyr/settings/settings.h> | ||
#include <zephyr/logging/log.h> | ||
#include <zephyr/drivers/gpio.h> | ||
#include <zephyr/device.h> | ||
#include <zephyr/devicetree.h> | ||
|
||
LOG_MODULE_REGISTER(nrf_cloud_rest_fota_smp, CONFIG_NRF_CLOUD_REST_FOTA_SAMPLE_LOG_LEVEL); | ||
|
||
#define RESET_NODE DT_NODELABEL(nrf52840_reset) | ||
#define HAS_RECOVERY_MODE (DT_NODE_HAS_STATUS(RESET_NODE, okay)) | ||
|
||
int nrf52840_reset_api(void) | ||
{ | ||
int err; | ||
const struct gpio_dt_spec reset_pin_spec = GPIO_DT_SPEC_GET(RESET_NODE, gpios); | ||
|
||
if (!device_is_ready(reset_pin_spec.port)) { | ||
LOG_ERR("Reset device not ready"); | ||
return -EIO; | ||
} | ||
|
||
/* Configure pin as output and initialize it to inactive state. */ | ||
err = gpio_pin_configure_dt(&reset_pin_spec, GPIO_OUTPUT_INACTIVE); | ||
if (err) { | ||
LOG_ERR("Pin configure err: %d", err); | ||
return err; | ||
} | ||
|
||
/* Reset the nRF52840 and let it wait until the pin is inactive again | ||
* before running to main to ensure that it won't send any data until | ||
* the H4 device is setup and ready to receive. | ||
*/ | ||
err = gpio_pin_set_dt(&reset_pin_spec, 1); | ||
if (err) { | ||
LOG_ERR("GPIO Pin set to 1 err: %d", err); | ||
return err; | ||
} | ||
|
||
/* Wait for the nRF52840 peripheral to stop sending data. | ||
* | ||
* It is critical (!) to wait here, so that all bytes | ||
* on the lines are received and drained correctly. | ||
*/ | ||
k_sleep(K_MSEC(10)); | ||
|
||
/* We are ready, let the nRF52840 run to main */ | ||
err = gpio_pin_set_dt(&reset_pin_spec, 0); | ||
if (err) { | ||
LOG_ERR("GPIO Pin set to 0 err: %d", err); | ||
return err; | ||
} | ||
|
||
LOG_DBG("Reset Pin %d", reset_pin_spec.pin); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* Copyright (c) 2024 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
*/ | ||
|
||
#ifndef _SMP_RESET_H_ | ||
#define _SMP_RESET_H_ | ||
|
||
#if defined(CONFIG_NRF_CLOUD_FOTA_SMP) && defined(CONFIG_BOARD_NRF9160DK_NRF9160_NS) | ||
#define SMP_FOTA_ENABLED 1 | ||
#else | ||
#define SMP_FOTA_ENABLED 0 | ||
#endif | ||
|
||
/** | ||
* @brief Reset the nRF52840 for SMP FOTA. | ||
*/ | ||
int nrf52840_reset_api(void); | ||
|
||
#endif /* _SMP_RESET_H_ */ |