#CHIP EFR32 Persistent Storage Example
An example testing and demonstrating the key value storage API.
This example serves to both test the key value storage implementation and API as it is brought-up on different platforms, as well as provide an example for how to use the API.
In the future this example can be moved into a unit test when available on all platforms.
The EFR32 platform KVS is fully implemented, the KVS is enabled and configured using theese defines:
defines = [ "CHIP_KVS_SECTOR_COUNT=4", "CHIP_KVS_BASE_SECTOR_INDEX=((FLASH_SIZE/FLASH_PAGE_SIZE)-(CHIP_KVS_SECTOR_COUNT))", ]
Download the Simplicity Commander command line tool, and ensure that commander
is your shell search path. (For Mac OS X, commander
is located inside Commander.app/Contents/MacOS/
.)
Download and install a suitable ARM gcc tool chain: GNU Arm Embedded Toolchain 9-2019-q4-major
Install some additional tools(likely already present for CHIP developers):
#Linux $ sudo apt-get install git libwebkitgtk-1.0-0 ninja-build
#Mac OS X $ brew install ninja
Supported hardware:
MG12 boards:
MG21 boards:
Build the example application:
cd ~/connectedhomeip ./scripts/examples/gn_efr32_example.sh ./examples/persistent-storage/efr32/ ./out/persistent-storage BRD4161A
To delete generated executable, libraries and object files use:
$ cd ~/connectedhomeip $ rm -rf ./out/persistent-storage
OR use GN/Ninja directly
$ cd ~/connectedhomeip/examples/persistent-storage/efr32 $ git submodule update --init $ source third_party/connectedhomeip/scripts/activate.sh $ export EFR32_BOARD=BRD4161A $ gn gen out/debug --args="efr32_sdk_root=\"${EFR32_SDK_ROOT}\" efr32_board=\"${EFR32_BOARD}\"" $ ninja -C out/debug
To delete generated executable, libraries and object files use:
$ cd ~/connectedhomeip/examples/persistent-storage/efr32 $ rm -rf out/
On the command line:
$ cd ~/connectedhomeip/examples/persistent-storage/efr32 $ python3 out/debug/chip-efr32-persistent_storage-example.flash.py
Or with the Ozone debugger, just load the .out file.
The example application is built to use the SEGGER Real Time Transfer (RTT) facility for log output. RTT is a feature built-in to the J-Link Interface MCU on the WSTK development board. It allows bi-directional communication with an embedded application without the need for a dedicated UART.
Using the RTT facility requires downloading and installing the SEGGER J-Link Software and Documentation Pack (web site). Alternatively the SEGGER Ozone - J-Link Debugger can be used to view RTT logs.
Download the J-Link installer by navigating to the appropriate URL and agreeing to the license agreement.
Install the J-Link software
$ cd ~/Downloads $ sudo dpkg -i JLink_Linux_V*_x86_64.deb
In Linux, grant the logged in user the ability to talk to the development hardware via the linux tty device (/dev/ttyACMx) by adding them to the dialout group.
$ sudo usermod -a -G dialout ${USER}
Once the above is complete, log output can be viewed using the JLinkExe tool in combination with JLinkRTTClient as follows:
Run the JLinkExe tool with arguments to autoconnect to the WSTK board:
For MG12 use:
$ JLinkExe -device EFR32MG12PXXXF1024 -if JTAG -speed 4000 -autoconnect 1
For MG21 use:
$ JLinkExe -device EFR32MG21AXXXF1024 -if SWD -speed 4000 -autoconnect 1
In a second terminal, run the JLinkRTTClient to view logs:
$ JLinkRTTClient
While most of the RAM usage in CHIP is static, allowing easier debugging and optimization with symbols analysis, we still need some HEAP for the crypto and OpenThread. Size of the HEAP can be modified by changing the value of the SL_STACK_SIZE
define inside of the BUILD.gn file of this example. Please take note that a HEAP size smaller than 5k can and will cause a Mbedtls failure during the BLE rendez-vous.