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