Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / examples / persistent-storage / efr32 / README.md
1 #CHIP EFR32 Persistent Storage Example
2
3 An example testing and demonstrating the key value storage API.
4
5 <hr>
6
7 -   [CHIP EFR32 Persistent Storage Example](#chip-efr32-persistent-storage-example)
8     -   [Introduction](#introduction)
9     -   [EFR32](#efr32)
10         -   [Building](#building)
11         -   [Flashing the Application](#flashing-the-application)
12         -   [Viewing Logging Output](#viewing-logging-output)
13
14 <hr>
15
16 <a name="intro"></a>
17
18 ## Introduction
19
20 This example serves to both test the key value storage implementation and API as
21 it is brought-up on different platforms, as well as provide an example for how
22 to use the API.
23
24 In the future this example can be moved into a unit test when available on all
25 platforms.
26
27 <a name="EFR32"></a>
28
29 ## EFR32
30
31 The EFR32 platform KVS is fully implemented, the KVS is enabled and configured
32 using theese defines:
33
34 ```
35 defines = [
36   "CHIP_KVS_SECTOR_COUNT=4",
37   "CHIP_KVS_BASE_SECTOR_INDEX=((FLASH_SIZE/FLASH_PAGE_SIZE)-(CHIP_KVS_SECTOR_COUNT))",
38 ]
39 ```
40
41 <a name="building"></a>
42
43 ### Building
44
45 -   Download the
46     [Simplicity Commander](https://www.silabs.com/mcu/programming-options)
47     command line tool, and ensure that `commander` is your shell search path.
48     (For Mac OS X, `commander` is located inside
49     `Commander.app/Contents/MacOS/`.)
50
51 -   Download and install a suitable ARM gcc tool chain:
52     [GNU Arm Embedded Toolchain 9-2019-q4-major](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads)
53
54 -   Install some additional tools(likely already present for CHIP developers):
55
56 #Linux \$ sudo apt-get install git libwebkitgtk-1.0-0 ninja-build
57
58 #Mac OS X \$ brew install ninja
59
60 -   Supported hardware:
61
62     MG12 boards:
63
64     -   BRD4161A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@19dBm
65     -   BRD4166A / SLTB004A / Thunderboard Sense 2 / 2.4GHz@10dBm
66     -   BRD4170A / SLWSTK6000B / Multiband Wireless Starter Kit / 2.4GHz@19dBm,
67         915MHz@19dBm
68     -   BRD4304A / SLWSTK6000B / MGM12P Module / 2.4GHz@19dBm
69
70     MG21 boards:
71
72     -   BRD4180A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm
73
74 *   Build the example application:
75
76           cd ~/connectedhomeip
77           ./scripts/examples/gn_efr32_example.sh ./examples/persistent-storage/efr32/ ./out/persistent-storage BRD4161A
78
79 -   To delete generated executable, libraries and object files use:
80
81           $ cd ~/connectedhomeip
82           $ rm -rf ./out/persistent-storage
83
84 OR use GN/Ninja directly
85
86           $ cd ~/connectedhomeip/examples/persistent-storage/efr32
87           $ git submodule update --init
88           $ source third_party/connectedhomeip/scripts/activate.sh
89           $ export EFR32_BOARD=BRD4161A
90           $ gn gen out/debug --args="efr32_sdk_root=\"${EFR32_SDK_ROOT}\" efr32_board=\"${EFR32_BOARD}\""
91           $ ninja -C out/debug
92
93 -   To delete generated executable, libraries and object files use:
94
95           $ cd ~/connectedhomeip/examples/persistent-storage/efr32
96           $ rm -rf out/
97
98 <a name="flashing"></a>
99
100 ### Flashing the Application
101
102 -   On the command line:
103
104           $ cd ~/connectedhomeip/examples/persistent-storage/efr32
105           $ python3 out/debug/chip-efr32-persistent_storage-example.flash.py
106
107 -   Or with the Ozone debugger, just load the .out file.
108
109 <a name="view-logging"></a>
110
111 ### Viewing Logging Output
112
113 The example application is built to use the SEGGER Real Time Transfer (RTT)
114 facility for log output. RTT is a feature built-in to the J-Link Interface MCU
115 on the WSTK development board. It allows bi-directional communication with an
116 embedded application without the need for a dedicated UART.
117
118 Using the RTT facility requires downloading and installing the _SEGGER J-Link
119 Software and Documentation Pack_
120 ([web site](https://www.segger.com/downloads/jlink#J-LinkSoftwareAndDocumentationPack)).
121 Alternatively the _SEGGER Ozone - J-Link Debugger_ can be used to view RTT logs.
122
123 -   Download the J-Link installer by navigating to the appropriate URL and
124     agreeing to the license agreement.
125
126 -   [JLink_Linux_x86_64.deb](https://www.segger.com/downloads/jlink/JLink_Linux_x86_64.deb)
127 -   [JLink_MacOSX.pkg](https://www.segger.com/downloads/jlink/JLink_MacOSX.pkg)
128
129 *   Install the J-Link software
130
131           $ cd ~/Downloads
132           $ sudo dpkg -i JLink_Linux_V*_x86_64.deb
133
134 *   In Linux, grant the logged in user the ability to talk to the development
135     hardware via the linux tty device (/dev/ttyACMx) by adding them to the
136     dialout group.
137
138           $ sudo usermod -a -G dialout ${USER}
139
140 Once the above is complete, log output can be viewed using the JLinkExe tool in
141 combination with JLinkRTTClient as follows:
142
143 -   Run the JLinkExe tool with arguments to autoconnect to the WSTK board:
144
145     For MG12 use:
146
147           $ JLinkExe -device EFR32MG12PXXXF1024 -if JTAG -speed 4000 -autoconnect 1
148
149     For MG21 use:
150
151           $ JLinkExe -device EFR32MG21AXXXF1024 -if SWD -speed 4000 -autoconnect 1
152
153 -   In a second terminal, run the JLinkRTTClient to view logs:
154
155           $ JLinkRTTClient
156
157 ## Memory settings
158
159 While most of the RAM usage in CHIP is static, allowing easier debugging and
160 optimization with symbols analysis, we still need some HEAP for the crypto and
161 OpenThread. Size of the HEAP can be modified by changing the value of the
162 `SL_STACK_SIZE` define inside of the BUILD.gn file of this example. Please take
163 note that a HEAP size smaller than 5k can and will cause a Mbedtls failure
164 during the BLE rendez-vous.