Skip to content

Commit

Permalink
Add low-power support to the e-lock demo application (#9156)
Browse files Browse the repository at this point in the history
  • Loading branch information
doru91 authored and pull[bot] committed Sep 1, 2021
1 parent bd6f379 commit 6757b99
Show file tree
Hide file tree
Showing 43 changed files with 1,831 additions and 4,897 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/examples-k32w.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
if: github.actor != 'restyled-io[bot]'

container:
image: connectedhomeip/chip-build-k32w:0.4.23
image: connectedhomeip/chip-build-k32w:0.5.1
volumes:
- "/tmp/bloat_reports:/tmp/bloat_reports"
- "/tmp/output_binaries:/tmp/output_binaries"
Expand Down
8 changes: 4 additions & 4 deletions examples/lighting-app/k32w/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,18 +162,18 @@ will be initiated.
In order to build the Project CHIP example, we recommend using a Linux
distribution (the demo-application was compiled on Ubuntu 20.04).

- Download [K32W061 SDK 2.6.3 for Project CHIP](https://mcuxpresso.nxp.com/).
- Download [K32W061 SDK 2.6.4 for Project CHIP](https://mcuxpresso.nxp.com/).
Creating an nxp.com account is required before being able to download the
SDK. Once the account is created, login and follow the steps for downloading
SDK_2.6.3_K32W061DK6. The SDK Builder UI selection should be similar with
SDK_2_6_4_K32W061DK6. The SDK Builder UI selection should be similar with
the one from the image below.
![MCUXpresso SDK Download](../../platform/k32w/doc/images/mcux-sdk-download.JPG)

- Start building the application either with Secure Element or without
- with Secure Element

```
user@ubuntu:~/Desktop/git/connectedhomeip$ export K32W061_SDK_ROOT=/home/user/Desktop/SDK_2.6.3_K32W061DK6/
user@ubuntu:~/Desktop/git/connectedhomeip$ export K32W061_SDK_ROOT=/home/user/Desktop/SDK_2_6_4_K32W061DK6/
user@ubuntu:~/Desktop/git/connectedhomeip$ ./third_party/k32w_sdk/sdk_fixes/patch_k32w_sdk.sh
user@ubuntu:~/Desktop/git/connectedhomeip$ source ./scripts/activate.sh
user@ubuntu:~/Desktop/git/connectedhomeip$ cd examples/lighting-app/k32w/
Expand All @@ -186,7 +186,7 @@ user@ubuntu:~/Desktop/git/connectedhomeip/examples/lighting-app/k32w$ $K32W061_S
Exactly the same steps as above but set chip_with_se05x=0 in the gn command

Note that "patch_k32w_sdk.sh" script must be run for patching the K32W061 SDK
2.6.3.
2.6.4.

Also, in case the OM15082 Expansion Board is not attached to the DK6 board, the
build argument (chip_with_OM15082) inside the gn build instruction should be set
Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/k32w/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include <support/CHIPPlatformMemory.h>
#include <support/logging/CHIPLogging.h>

#include "FreeRtosMbedtlsUtils.h"
#include "FreeRtosHooks.h"
#include "app_config.h"

#include "radio.h"
Expand Down
42 changes: 37 additions & 5 deletions examples/lock-app/k32w/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,10 @@ will be initiated.
In order to build the Project CHIP example, we recommend using a Linux
distribution (the demo-application was compiled on Ubuntu 20.04).

- Download [K32W061 SDK 2.6.3 for Project CHIP](https://mcuxpresso.nxp.com/).
- Download [K32W061 SDK 2.6.4 for Project CHIP](https://mcuxpresso.nxp.com/).
Creating an nxp.com account is required before being able to download the
SDK. Once the account is created, login and follow the steps for downloading
SDK_2.6.3_K32W061DK6. The SDK Builder UI selection should be similar with
SDK_2_6_4_K32W061DK6. The SDK Builder UI selection should be similar with
the one from the image below.
![MCUXpresso SDK Download](../../platform/k32w/doc/images/mcux-sdk-download.JPG)

Expand All @@ -177,7 +177,7 @@ distribution (the demo-application was compiled on Ubuntu 20.04).
- with Secure Element

```
user@ubuntu:~/Desktop/git/connectedhomeip$ export K32W061_SDK_ROOT=/home/user/Desktop/SDK_2.6.3_K32W061DK6/
user@ubuntu:~/Desktop/git/connectedhomeip$ export K32W061_SDK_ROOT=/home/user/Desktop/SDK_2_6_4_K32W061DK6/
user@ubuntu:~/Desktop/git/connectedhomeip$ ./third_party/k32w_sdk/sdk_fixes/patch_k32w_sdk.sh
user@ubuntu:~/Desktop/git/connectedhomeip$ source ./scripts/activate.sh
user@ubuntu:~/Desktop/git/connectedhomeip$ cd examples/lock-app/k32w/
Expand All @@ -190,7 +190,7 @@ user@ubuntu:~/Desktop/git/connectedhomeip/examples/lock-app/k32w$ $K32W061_SDK_R
Exactly the same steps as above but set chip_with_se05x=0 in the gn command

Note that "patch_k32w_sdk.sh" script must be run for patching the K32W061 SDK
2.6.3.
2.6.4.

Also, in case the OM15082 Expansion Board is not attached to the DK6 board, the
build argument (chip_with_OM15082) inside the gn build instruction should be set
Expand Down Expand Up @@ -228,10 +228,42 @@ used or with _out/debug/chip-k32w061-lock-example_ if MCUXpresso is used.

<a name="knownissues"></a>

## Low power

The example also offers the possibility to run in low power mode. This means
that the board will go in a deep power down mode most of the time and the power
consumption will be very low.

In order build with low power support, the _chip_with_low_power=1_ must be
provided to the build system. In this case, please note that the GN build
arguments chip*with_OM15082 and \_chip_with_ot_cli* must be set to 0.

In order to maintain a low power consumption, the LEDs showing the state of the
elock and the internal state are disabled. Console logs can be used instead.
Also, please note that once the board is flashed with MCUXpresso the debugger
disconnects because the board enters low power.

Power Measurement Tool can be used inside MCUXpresso for checking the power
consumption pattern: Window -> Show View -> Other -> Power Measurement Tool. The
configuration for this tool is the next one:

![POWER_CONF](../../platform/k32w/doc/images/power_conf.JPG)

Also, please make sure that the J14 jumper is set to the _ENABLED_ position and
no expansion board is attached to the DK6. A view from this tool is illustrated
below:

![POWER_VIEW](../../platform/k32w/doc/images/power_view.JPG)

Please note that that the Power Measurement Tool is not very accurate and
professional tools must be used if exact power consumption needs to be kwnown.

## Known issues

- When cross-compiling on Linux - Log messages from the Plug&Trust middleware
stack may not echo to the console.
stack may not echo to the console;
- Power Measurement Tool may not work correctly in MCUXpresso versions greater
that 11.0.1.

## Testing the example

Expand Down
27 changes: 26 additions & 1 deletion examples/lock-app/k32w/include/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,23 @@
*----------------------------------------------------------*/

#define configUSE_PREEMPTION 1

#if defined(cPWR_UsePowerDownMode) && (cPWR_UsePowerDownMode)
#define configUSE_TICKLESS_IDLE 1
#else
#define configUSE_TICKLESS_IDLE 0
#endif

#define configCPU_CLOCK_HZ (SystemCoreClock)
#define configTICK_RATE_HZ ((TickType_t) 100)
#define configMAX_PRIORITIES (8)

#if defined(cPWR_UsePowerDownMode) && (cPWR_UsePowerDownMode)
#define configMINIMAL_STACK_SIZE ((unsigned short) 250)
#else
#define configMINIMAL_STACK_SIZE ((unsigned short) 90)
#endif

#define configMAX_TASK_NAME_LEN 20
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 1
Expand Down Expand Up @@ -73,9 +85,12 @@
#define configAPPLICATION_ALLOCATED_HEAP 1

/* Hook function related definitions. */
#ifndef configUSE_IDLE_HOOK
#if defined(cPWR_UsePowerDownMode) && (cPWR_UsePowerDownMode)
#define configUSE_IDLE_HOOK 1
#else
#define configUSE_IDLE_HOOK 0
#endif

#define configUSE_TICK_HOOK 0
#define configCHECK_FOR_STACK_OVERFLOW 0
#ifndef configUSE_MALLOC_FAILED_HOOK
Expand All @@ -102,13 +117,23 @@
#define configTIMER_TASK_STACK_DEPTH (configMINIMAL_STACK_SIZE * 4)

/* Define to trap errors during development. */
#if defined gLoggingActive_d && (gLoggingActive_d != 0)
#include "dbg_logging.h"
#define configASSERT(x) \
if ((x) == 0) \
{ \
taskDISABLE_INTERRUPTS(); \
DbgLogDump(1); \
}
#else
#define configASSERT(x) \
if ((x) == 0) \
{ \
taskDISABLE_INTERRUPTS(); \
for (;;) \
; \
}
#endif

/* Optional functions - most linkers will remove unused functions anyway. */
#define INCLUDE_vTaskPrioritySet 1
Expand Down
Loading

0 comments on commit 6757b99

Please sign in to comment.