Change script for apply upstream code
[platform/upstream/connectedhomeip.git] / third_party / openthread / repo / examples / platforms / efr32mg21 / README.md
1 # OpenThread on EFR32MG21 Example
2
3 This directory contains example platform drivers for the [Silicon Labs EFR32MG21][efr32mg] 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. [EFR32MG21 SoC][efr32mg21] has rich memory and peripheral resources which can support all OpenThread capabilities. See the "Run the example with EFR32 boards" section below for an example using basic OpenThread capabilities.
9
10 [efr32mg21]: https://www.silabs.com/products/wireless/mesh-networking/series-2-efr32-mighty-gecko-zigbee-thread-soc/device.efr32mg21a020f768im32
11
12 ## Toolchain
13
14 Download and install the [GNU toolchain for ARM Cortex-M][gnu-toolchain].
15
16 [gnu-toolchain]: https://developer.arm.com/open-source/gnu-toolchain/gnu-rm
17
18 In a Bash terminal, follow these instructions to install the GNU toolchain and other dependencies.
19
20 ```bash
21 $ cd <path-to-openthread>
22 $ ./script/bootstrap
23 ```
24
25 ## Build Examples
26
27 1. Download and install the [Simplicity Studio][simplicity_studio].
28
29 [simplicity_studio]: http://www.silabs.com/products/development-tools/software/simplicity-studio
30
31 2. Install Flex (Gecko) SDK including RAIL Library from Simplicity Studio.
32    - Connect EFR32MG21 Wireless Starter Kit to Simplicity Studio.
33    - Find Flex SDK v2.7 in the Software Update page and click Install.
34    - Flex SDK v2.7 will be installed in the path: `/SimplicityStudio_v4/developer/sdks/gecko_sdk_suite`.
35
36 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].
37
38 [qsg138]: https://www.silabs.com/documents/public/quick-start-guides/qsg138-flex-efr32.pdf
39 [rail]: http://www.silabs.com/products/development-tools/software/radio-abstraction-interface-layer-sdk
40
41 3. Configure the path to Flex SDK source code.
42
43 ```bash
44 $ cd <path-to-Simplicity-Studio>/developer/sdks
45 $ cp -rf gecko_sdk_suite <path-to-openthread>/third_party/silabs/
46 ```
47
48 Alternatively create a symbolic link to the Flex SDK source code.
49
50 ```bash
51 $ cd <path-to-openthread>/third_party
52 $ ln -s <path-to-Simplicity-Studio>/developer/sdks/gecko_sdk_suite silabs/gecko_sdk_suite
53 ```
54
55 Note: Due to an error in the core_cm33.h file provided by ARM, the compiler will throw an error when pedantic option is used on the builds. To avoid this, please add the following lines of code at the top of the file core_cm33.h:
56
57 ```
58 #if defined(__GNUC__)
59 #pragma GCC diagnostic ignored "-Wpedantic"
60 #endif
61 ```
62
63 core_cm33.h can be found at:
64
65 ```
66 <path-to-Simplicity-Studio>/developer/sdks/gecko_sdk_suite/v2.7/platform/CMSIS/Include
67 ```
68
69 4. Build OpenThread Firmware (CLI example) on EFR32 platform.
70
71 ```bash
72 $ cd <path-to-openthread>
73 $ ./bootstrap
74 ```
75
76 For EFR32MG21™ Mighty Gecko Wireless Starter Kit:
77
78 ```bash
79 $ make -f examples/Makefile-efr32mg21 BOARD=BRD4180A
80 ```
81
82 After a successful build, the `elf` files are found in `<path-to-openthread>/output/efr32mg21/bin`.
83
84 ## Flash Binaries
85
86 Simplicity Commander provides a graphical interface for J-Link Commander.
87
88 ```bash
89 $ cd <path-to-openthread>/output/efr32mg21/bin
90 $ arm-none-eabi-objcopy -O ihex ot-cli-ftd ot-cli-ftd.hex
91 $ <path-to-simplicity-studio>/developer/adapter_packs/commander/commander
92 ```
93
94 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.
95
96 ## Run the example with EFR32MG21 boards
97
98 1. Flash two EFR32 boards with the `CLI example` firmware (as shown above).
99 2. Open terminal to first device `/dev/ttyACM0` (serial port settings: 115200 8-N-1). Type `help` for a list of commands.
100
101 ```bash
102 > help
103 help
104 channel
105 childtimeout
106 contextreusedelay
107 extaddr
108 extpanid
109 ipaddr
110 keysequence
111 leaderweight
112 masterkey
113 mode
114 netdataregister
115 networkidtimeout
116 networkname
117 panid
118 ping
119 prefix
120 releaserouterid
121 rloc16
122 route
123 routerupgradethreshold
124 scan
125 start
126 state
127 stop
128 whitelist
129 ```
130
131 3. Start a Thread network as Leader.
132
133 ```bash
134 > panid 0xface
135 Done
136 > ifconfig up
137 Done
138 > thread start
139 Done
140
141 wait a couple of seconds...
142
143 > state
144 leader
145 Done
146 ```
147
148 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.
149
150 ```bash
151 > panid 0xface
152 Done
153 > routerselectionjitter 1
154 Done
155 > ifconfig up
156 Done
157 > thread start
158 Done
159
160 wait a couple of seconds...
161
162 > state
163 router
164 Done
165 ```
166
167 5. List all IPv6 addresses of Leader.
168
169 ```bash
170 > ipaddr
171 fdde:ad00:beef:0:0:ff:fe00:fc00
172 fdde:ad00:beef:0:0:ff:fe00:800
173 fdde:ad00:beef:0:5b:3bcd:deff:7786
174 fe80:0:0:0:6447:6e10:cf7:ee29
175 Done
176 ```
177
178 6. Send an ICMPv6 ping to Leader's Mesh-EID IPv6 address.
179
180 ```bash
181 > ping fdde:ad00:beef:0:5b:3bcd:deff:7786
182 8 bytes from fdde:ad00:beef:0:5b:3bcd:deff:7786: icmp_seq=1 hlim=64 time=24ms
183 ```
184
185 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.
186
187 ```bash
188 $ cd <path-to-openthread>
189 $ ./bootstrap
190 $ make -f examples/Makefile-efr32mg21 COMMISSIONER=1 JOINER=1 DHCP6_CLIENT=1 DHCP6_SERVER=1
191 ```
192
193 For a list of all available commands, visit [OpenThread CLI Reference README.md][cli].
194
195 [cli]: https://github.com/openthread/openthread/blob/master/src/cli/README.md
196
197 ## Verification
198
199 The following toolchain has been used for testing and verification:
200
201 - gcc version 7.3.1
202
203 The EFR32 example has been verified with following Flex SDK/RAIL Library version:
204
205 - Flex SDK version 2.7.0.0