1e978dfe4a213daa6d0885b5cae4e14296ab098e
[platform/upstream/connectedhomeip.git] / third_party / openthread / repo / examples / platforms / efr32mg12 / README.md
1 # OpenThread on EFR32MG12 Example
2
3 This directory contains example platform drivers for the [Silicon Labs EFR32MG12][efr32mg12] based on [EFR32™ Mighty Gecko Wireless Starter Kit][slwstk6000b] or [Thunderboard™ Sense 2 Sensor-to-Cloud Advanced IoT Development Kit][sltb004a].
4
5 [efr32mg]: http://www.silabs.com/products/wireless/mesh-networking/efr32mg-mighty-gecko-zigbee-thread-soc
6 [slwstk6000b]: http://www.silabs.com/products/development-tools/wireless/mesh-networking/mighty-gecko-starter-kit
7 [sltb004a]: https://www.silabs.com/products/development-tools/thunderboard/thunderboard-sense-two-kit
8
9 The example platform drivers are intended to present the minimal code necessary to support OpenThread. [EFR32MG12P SoC][efr32mg12p] has rich memory and peripheral resources which can support all OpenThread capabilities. See the "Run the example with EFR32MG12 boards" section below for an example using basic OpenThread capabilities.
10
11 See [sleepy-demo/README.md](sleepy-demo/README.md) for instructions for an example that uses the low-energy modes of the EFR32MG12 when running as a Sleepy End Device.
12
13 [efr32mg12p]: http://www.silabs.com/products/wireless/mesh-networking/efr32mg-mighty-gecko-zigbee-thread-soc/device.EFR32MG12P432F1024GL125
14
15 ## Toolchain
16
17 Download and install the [GNU toolchain for ARM Cortex-M][gnu-toolchain].
18
19 [gnu-toolchain]: https://developer.arm.com/open-source/gnu-toolchain/gnu-rm
20
21 In a Bash terminal, follow these instructions to install the GNU toolchain and other dependencies.
22
23 ```bash
24 $ cd <path-to-openthread>
25 $ ./script/bootstrap
26 ```
27
28 ## Build Examples
29
30 1. Download and install the [Simplicity Studio][simplicity_studio].
31
32 [simplicity_studio]: http://www.silabs.com/products/development-tools/software/simplicity-studio
33
34 2. Install Flex (Gecko) SDK including RAIL Library from Simplicity Studio.
35    - Connect EFR32MG12P Wireless Starter Kit to Simplicity Studio.
36    - Find Flex SDK v2.7 in the Software Update page and click Install.
37    - Flex SDK v2.7 will be installed in the path: `/SimplicityStudio_v4/developer/sdks/gecko_sdk_suite`.
38
39 For more information on configuring, building, and installing applications for the Wireless Gecko (EFR32) portfolio using FLEX, see [Getting Started with the Silicon Labs Flex Software Development Kit for the Wireless Gecko (EFR32™) Portfolio][qsg138]. For more information on RAIL, see [Radio Abstraction Interface Layer][rail].
40
41 [qsg138]: https://www.silabs.com/documents/public/quick-start-guides/qsg138-flex-efr32.pdf
42 [rail]: http://www.silabs.com/products/development-tools/software/radio-abstraction-interface-layer-sdk
43
44 3. Configure the path to Flex SDK source code.
45
46 ```bash
47 $ cd <path-to-openthread>/third_party
48 $ mkdir silabs
49 $ cd <path-to-Simplicity-Studio>/developer/sdks
50 $ cp -rf gecko_sdk_suite <path-to-openthread>/third_party/silabs/
51 ```
52
53 Alternatively create a symbolic link to the Flex SDK source code.
54
55 ```bash
56 $ cd <path-to-openthread>/third_party
57 $ mkdir silabs
58 $ ln -s <path-to-Simplicity-Studio>/developer/sdks/gecko_sdk_suite silabs/gecko_sdk_suite
59 ```
60
61 4. Build OpenThread Firmware (CLI example) on EFR32 platform.
62
63 ```bash
64 $ cd <path-to-openthread>
65 $ ./bootstrap
66 ```
67
68 For EFR32MG12™ Mighty Gecko Wireless Starter Kit:
69
70 ```bash
71 $ make -f examples/Makefile-efr32mg12 BOARD=BRD4161A
72 ```
73
74 or alternatively for the Thunderboard™ Sense 2:
75
76 ```bash
77 $ make -f examples/Makefile-efr32mg12 BOARD=BRD4166A
78 ```
79
80 After a successful build, the `elf` files are found in `<path-to-openthread>/output/efr32mg12/bin`.
81
82 ## Flash Binaries
83
84 Compiled binaries may be flashed onto the EFR32 using [JLinkGDBServer][jlinkgdbserver]. EFR32 Starter kit mainboard integrates an on-board SEGGER J-Link debugger.
85
86 [jlinkgdbserver]: https://www.segger.com/jlink-gdb-server.html
87
88 ```bash
89 $ cd <path-to-JLinkGDBServer>
90 $ sudo ./JLinkGDBServer -if swd -device EFR32MG12PxxxF1024
91 $ cd <path-to-openthread>/output/efr32/bin
92 $ arm-none-eabi-gdb ot-cli-ftd
93 $ (gdb) target remote 127.0.0.1:2331
94 $ (gdb) load
95 $ (gdb) monitor reset
96 $ (gdb) c
97 ```
98
99 Note: Support for the "EFR32MG12PxxxF1024" device was added to JLinkGDBServer V6.14d.
100
101 Or Compiled binaries also may be flashed onto the specified EFR32 dev board using [J-Link Commander][j-link-commander].
102
103 [j-link-commander]: https://www.segger.com/products/debug-probes/j-link/tools/j-link-commander/
104
105 ```bash
106 $ cd <path-to-openthread>/output/efr32mg12/bin
107 $ arm-none-eabi-objcopy -O ihex ot-cli-ftd ot-cli-ftd.hex
108 $ JLinkExe -device EFR32MG12PxxxF1024 -speed 4000 -if SWD -autoconnect 1 -SelectEmuBySN <SerialNo>
109 $ J-Link>loadfile ot-cli-ftd.hex
110 $ J-Link>r
111 $ J-Link>q
112 ```
113
114 Note: SerialNo is J-Link serial number. Use the following command to get the serial number of the connected J-Link.
115
116 ```bash
117 $ JLinkExe
118 ```
119
120 Alternatively Simplicity Commander provides a graphical interface for J-Link Commander.
121
122 ```bash
123 $ cd <path-to-openthread>/output/efr32mg12/bin
124 $ arm-none-eabi-objcopy -O ihex ot-cli-ftd ot-cli-ftd.ihex
125 $ <path-to-simplicity-studio>/developer/adapter_packs/commander/commander
126 ```
127
128 In the J-Link Device drop-down list select the serial number of the device to flash. Click the Adapter Connect button. Ensure the Debug Interface drop-down list is set to SWD and click the Target Connect button. Click on the Flash icon on the left side of the window to switch to the flash page. In the Flash MCU pane enter the path of the ot-cli-ftd.s37 file or choose the file with the Browse... button. Click the Flash button located under the Browse... button.
129
130 ## Run the example with EFR32MG12 boards
131
132 1. Flash two EFR32 boards with the `CLI example` firmware (as shown above).
133 2. Open terminal to first device `/dev/ttyACM0` (serial port settings: 115200 8-N-1). Type `help` for a list of commands.
134
135    ```bash
136    > help
137    help
138    channel
139    childtimeout
140    contextreusedelay
141    extaddr
142    extpanid
143    ipaddr
144    keysequence
145    leaderweight
146    masterkey
147    mode
148    netdataregister
149    networkidtimeout
150    networkname
151    panid
152    ping
153    prefix
154    releaserouterid
155    rloc16
156    route
157    routerupgradethreshold
158    scan
159    start
160    state
161    stop
162    whitelist
163    ```
164
165 3. Start a Thread network as Leader.
166
167    ```bash
168    > dataset init new
169    Done
170    > dataset
171    Active Timestamp: 1
172    Channel: 13
173    Channel Mask: 0x07fff800
174    Ext PAN ID: d63e8e3e495ebbc3
175    Mesh Local Prefix: fd3d:b50b:f96d:722d::/64
176    Master Key: dfd34f0f05cad978ec4e32b0413038ff
177    Network Name: OpenThread-8f28
178    PAN ID: 0x8f28
179    PSKc: c23a76e98f1a6483639b1ac1271e2e27
180    Security Policy: 0, onrcb
181    Done
182    > dataset commit active
183    Done
184    > ifconfig up
185    Done
186    > thread start
187    Done
188
189    wait a couple of seconds...
190
191    > state
192    leader
193    Done
194    ```
195
196 4. Open terminal to second device `/dev/ttyACM1` (serial port settings: 115200 8-N-1) and attach it to the Thread network as a Router.
197
198    ```bash
199    > dataset masterkey dfd34f0f05cad978ec4e32b0413038ff
200    Done
201    > dataset commit active
202    Done
203    > routerselectionjitter 1
204    Done
205    > ifconfig up
206    Done
207    > thread start
208    Done
209
210    wait a couple of seconds...
211
212    > state
213    router
214    Done
215    ```
216
217 5. List all IPv6 addresses of Leader.
218
219    ```bash
220    > ipaddr
221    fd3d:b50b:f96d:722d:0:ff:fe00:fc00
222    fd3d:b50b:f96d:722d:0:ff:fe00:c00
223    fd3d:b50b:f96d:722d:7a73:bff6:9093:9117
224    fe80:0:0:0:6c41:9001:f3d6:4148
225    Done
226    ```
227
228 6. Send an ICMPv6 ping to Leader's Mesh-EID IPv6 address.
229
230    ```bash
231    > ping fd3d:b50b:f96d:722d:7a73:bff6:9093:9117
232    16 bytes from fd3d:b50b:f96d:722d:558:f56b:d688:799: icmp_seq=1 hlim=64 time=24ms
233    ```
234
235 The above example demonstrates basic OpenThread capabilities. Enable more features/roles (e.g. commissioner, joiner, DHCPv6 Server/Client, etc.) by assigning compile-options before compiling.
236
237 ```bash
238 $ cd <path-to-openthread>
239 $ ./bootstrap
240 $ make -f examples/Makefile-efr32mg12 COMMISSIONER=1 JOINER=1 DHCP6_CLIENT=1 DHCP6_SERVER=1
241 ```
242
243 For a list of all available commands, visit [OpenThread CLI Reference README.md][cli].
244
245 [cli]: https://github.com/openthread/openthread/blob/master/src/cli/README.md
246
247 ## Verification
248
249 The following toolchain has been used for testing and verification:
250
251 - gcc version 7.3.1
252
253 The EFR32 example has been verified with following Flex SDK/RAIL Library version:
254
255 - Flex SDK version 2.7.0.0