Skip to content

Commit

Permalink
Merge branch 'master' into crypto
Browse files Browse the repository at this point in the history
  • Loading branch information
jpk233 committed Jun 2, 2021
2 parents a0256fc + 5d54fac commit a36794b
Show file tree
Hide file tree
Showing 83 changed files with 5,519 additions and 1,525 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ jobs:
uses: actions/checkout@v2
with:
submodules: true
# - name: Initialize CodeQL
# uses: github/codeql-action/init@v1
# with:
# languages: "cpp, python"
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: "cpp"

- name: Bootstrap
run: scripts/build/gn_bootstrap.sh
Expand Down Expand Up @@ -81,6 +81,6 @@ jobs:
run: find out -type d -name "dbus" -exec rm -rf {} +
# - name: Remove nrfxlib binaries for CodeQL Analysis
# run: find . -type d -name "nrfxlib" -exec rm -rf {} +
# - name: Perform CodeQL Analysis
# if: ${{ github.event_name == 'push' }}
# uses: github/codeql-action/analyze@v1
- name: Perform CodeQL Analysis
if: ${{ github.event_name == 'push' }}
uses: github/codeql-action/analyze@v1
1 change: 1 addition & 0 deletions config/nrfconnect/app/overlay-dfu_support.conf
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ CONFIG_MCUMGR_CMD_IMG_MGMT=y
CONFIG_MCUMGR_CMD_OS_MGMT=y
CONFIG_MCUMGR_SMP_BT=y
CONFIG_MCUMGR_SMP_BT_AUTHEN=n
CONFIG_MCUMGR_BUF_COUNT=6

# Increase BT MTU and RX buffer for big size DFU messages
CONFIG_BT_L2CAP_TX_MTU=252
Expand Down
1 change: 1 addition & 0 deletions config/nrfconnect/app/sample-defaults.conf
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ CONFIG_BT_DEVICE_NAME_MAX=15
CONFIG_BT_MAX_CONN=1
CONFIG_BT_PHY_UPDATE=n
CONFIG_BT_CTLR_PHY_2M=n
CONFIG_SDC_MAX_CONN_EVENT_LEN_DEFAULT=3000

# Enable NFC support
CONFIG_CHIP_NFC_COMMISSIONING=y
Expand Down
125 changes: 125 additions & 0 deletions docs/guides/nrfconnect_examples_software_update.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# Performing Device Firmware Upgrade in the nRF Connect SDK examples

The following examples for the development kits from Nordic Semiconductor
support over-the-air Device Firmware Upgrade:

- [CHIP nRF Connect Lock Example Application](../../examples/lock-app/nrfconnect/README.md)
- [CHIP nRF Connect Lighting Example Application](../../examples/lighting-app/nrfconnect/README.md)

Currently, the Bluetooth LE is the only available transport for performing the
DFU operation and it uses
[Simple Management Protocol](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/guides/device_mgmt/index.html#device-mgmt).
The upgrade can be done either using a smartphone application or a PC command
line tool.

## Device Firmware Upgrade using smartphone

To upgrade your device firmware over Bluetooth LE using smartphone, complete the
following steps:

1. Install one of the following applications on your smartphone:

- [nRF Connect for Mobile](https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Connect-for-mobile)
- [nRF Toolbox](https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Toolbox)

2. Push **Button 1** on the device to enable the software update functionality.
3. Push **Button 4** on the device to start the Bluetooth LE advertising.
4. Follow the instructions about downloading the new image to a device on the
[FOTA upgrades](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/ug_nrf52.html#fota-upgrades)
page in the nRF Connect documentation.

## Device Firmware Upgrade using PC command line tool

To upgrade your device firmware over Bluetooth LE, you can use the PC command
line tool provided by the [mcumgr](https://github.com/zephyrproject-rtos/mcumgr)
project.

> **_WARNING:_** mcumgr tool using Bluetooth LE is available only for Linux and
> macOS systems. On Windows, there is no support for Device Firmware Upgrade
> over Bluetooth LE yet.
Complete the following steps to perform DFU using mcumgr:

1. Install the tool by following the
[mcumgr command line tool installation instructions](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/guides/device_mgmt/index.html#command-line-tool).
2. Push **Button 1** on the device to enable software update functionality.
3. Push **Button 4** on the device to start the Bluetooth LE advertising.

> **_NOTE:_** In all of the commands listed in the following steps, replace
> `ble-hci-number` with the Bluetooth hci integer value (for example, `0`) and
> `ble-device-name` with the CHIP device name advertised over Bluetooth LE (for
> example, `ChipLock`).
4. Upload the firmware image to the device by running the following command in
your example directory:

$ sudo mcumgr --conntype ble --hci ble-hci-number --connstring peer_name='ble-device-name' image upload build/zephyr/app_update.bin

The operation can take few minutes. Wait until the progress bar reaches
100%.

5. Obtain the list of images present in the device memory by running following
command:

$ sudo mcumgr --conntype ble --hci ble-hci-number --connstring peer_name='ble-device-name' image list

The displayed output contains the old image in slot 0 that is currently
active and the new image in slot 1, which is not active yet (flags field
empty):

Images:
image=0 slot=0
version: 0.0.0
bootable: true
flags: active confirmed
hash: 7bb0e909a846e833465cbb44c581cf045413a5446c6953a30a3dcc2c3ad51764
image=0 slot=1
version: 0.0.0
bootable: true
flags:
hash: cbd58fc3821e749d3abfb00b3069f98c078824735f1b2a333e8a1579971e7de1
Split status: N/A (0)

6. Swap the firmware images by calling the following method with `image-hash`
replaced by the image present in the slot 1 hash (for example,
`cbd58fc3821e749d3abfb00b3069f98c078824735f1b2a333e8a1579971e7de1`):

$ sudo mcumgr --conntype ble --hci ble-hci-number --connstring peer_name='ble-device-name' image test image-hash

You can observe that the `flags:` field in the image for slot 1 changes
value to `pending`:

Images:
image=0 slot=0
version: 0.0.0
bootable: true
flags: active confirmed
hash: 7bb0e909a846e833465cbb44c581cf045413a5446c6953a30a3dcc2c3ad51764
image=0 slot=1
version: 0.0.0
bootable: true
flags: pending
hash: cbd58fc3821e749d3abfb00b3069f98c078824735f1b2a333e8a1579971e7de1
Split status: N/A (0)

7. Reset the device with the following command to let the bootloader swap
images:

$ sudo mcumgr --conntype ble --hci ble-hci-number --connstring peer_name='ble-device-name' reset

The device is reset and the following notifications appear in its console:

*** Booting Zephyr OS build zephyr-v2.5.0-1101-ga9d3aef65424 ***
I: Starting bootloader
I: Primary image: magic=good, swap_type=0x2, copy_done=0x1, image_ok=0x1
I: Secondary image: magic=good, swap_type=0x2, copy_done=0x3, image_ok=0x3
I: Boot source: none
I: Swap type: test

Swapping operation can take some time, and after it completes, the new
firmware is booted.

Visit the
[mcumgr image management](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/guides/device_mgmt/indexhtml#image-management)
section to get familiar with all image management commands supported by the
tool.
97 changes: 97 additions & 0 deletions examples/all-clusters-app/all-clusters-common/all-clusters-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -6488,6 +6488,103 @@
}
]
},
{
"name": "Binary Input (Basic)",
"code": 15,
"mfgCode": null,
"define": "BINARY_INPUT_BASIC_CLUSTER",
"side": "client",
"enabled": 0,
"commands": [],
"attributes": [
{
"name": "cluster revision",
"code": 65533,
"mfgCode": null,
"side": "client",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0x0001",
"reportable": 0,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
}
]
},
{
"name": "Binary Input (Basic)",
"code": 15,
"mfgCode": null,
"define": "BINARY_INPUT_BASIC_CLUSTER",
"side": "server",
"enabled": 1,
"commands": [],
"attributes": [
{
"name": "out of service",
"code": 81,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0x00",
"reportable": 0,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "present value",
"code": 85,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "status flags",
"code": 111,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0x00",
"reportable": 1,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "cluster revision",
"code": 65533,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0x0001",
"reportable": 0,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
}
]
},
{
"name": "Descriptor",
"code": 29,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ EmberAfStatus emberAfApplicationLauncherClusterServerCommandParse(EmberAfCluster
EmberAfStatus emberAfAudioOutputClusterServerCommandParse(EmberAfClusterCommand * cmd);
EmberAfStatus emberAfBarrierControlClusterServerCommandParse(EmberAfClusterCommand * cmd);
EmberAfStatus emberAfBasicClusterServerCommandParse(EmberAfClusterCommand * cmd);
EmberAfStatus emberAfBinaryInputBasicClusterServerCommandParse(EmberAfClusterCommand * cmd);
EmberAfStatus emberAfBindingClusterServerCommandParse(EmberAfClusterCommand * cmd);
EmberAfStatus emberAfBridgedDeviceBasicClusterServerCommandParse(EmberAfClusterCommand * cmd);
EmberAfStatus emberAfColorControlClusterServerCommandParse(EmberAfClusterCommand * cmd);
Expand Down Expand Up @@ -136,6 +137,10 @@ EmberAfStatus emberAfClusterSpecificCommandParse(EmberAfClusterCommand * cmd)
case ZCL_BASIC_CLUSTER_ID:
result = emberAfBasicClusterServerCommandParse(cmd);
break;
case ZCL_BINARY_INPUT_BASIC_CLUSTER_ID:
// No commands are enabled for cluster Binary Input (Basic)
result = status(false, true, cmd->mfgSpecific);
break;
case ZCL_BINDING_CLUSTER_ID:
result = emberAfBindingClusterServerCommandParse(cmd);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId)
case ZCL_BASIC_CLUSTER_ID:
emberAfBasicClusterInitCallback(endpoint);
break;
case ZCL_BINARY_INPUT_BASIC_CLUSTER_ID:
emberAfBinaryInputBasicClusterInitCallback(endpoint);
break;
case ZCL_BINDING_CLUSTER_ID:
emberAfBindingClusterInitCallback(endpoint);
break;
Expand Down Expand Up @@ -203,6 +206,11 @@ void __attribute__((weak)) emberAfBasicClusterInitCallback(EndpointId endpoint)
// To prevent warning
(void) endpoint;
}
void __attribute__((weak)) emberAfBinaryInputBasicClusterInitCallback(EndpointId endpoint)
{
// To prevent warning
(void) endpoint;
}
void __attribute__((weak)) emberAfBindingClusterInitCallback(EndpointId endpoint)
{
// To prevent warning
Expand Down
Loading

0 comments on commit a36794b

Please sign in to comment.