1# OpenThread Border Router on OpenWRT 2 3## Build 4 5This is for local development. 6 7### 1. Add OpenThread feed 8 9Assuming `OPENWRT_TOP_SRCDIR` is the root of openwrt sources. 10 11```bash 12echo src-link openthread "$(pwd)/etc/openwrt" >> ${OPENWRT_TOP_SRCDIR}/feeds.conf 13cd "${OPENWRT_TOP_SRCDIR}" 14./scripts/feeds update openthread 15./scripts/feeds install openthread-br 16``` 17 18### 2. Enable OpenThread Border Router 19 20OpenThread is not selected by default, so use menuconfig to select openthread-br (OpenThread Border Router). 21 22```bash 23make menuconfig 24``` 25 26In the configure window, use the Up and Down keys to move the cursor and the Left and Right keys to choose an action. 27 281. Select _Network_ to enter its submenu. 292. Enable _openthread-br_ by moving the cursor to it and pressing **Y**. 303. Select _Exit_ to exit. 31 32### 3. Build OpenThread Border Router 33 34```bash 35make package/openthread-br/compile 36``` 37 38or to do a verbose make for debugging: 39 40```bash 41make -j1 V=sc package/openthread-br/compile 42``` 43 44### 4. Install 45 46Copy the generated **ipk** file into OpenWRT, and install with **opkg**. 47 48```bash 49opkg install openthread-br-1.0*.ipk 50``` 51 52NOTES: 53 54- `openthread-br` requires `ipset` and `iptables-mod-extra` packages if the firewall feature is enabled. 55- `openthread-br` requires `libavahi-client` and `avahi-daemon` package if the MDNS feature is enabled. 56 57## Usage 58 59### Start 60 61Start otbr-agent manually: 62 63```bash 64# Assuming that ttyACM0 is a RCP with baudrate 115200. 65/usr/sbin/otbr-agent -I wpan0 'spinel+hdlc+uart:///dev/ttyACM0?uart-baudrate=115200' 66``` 67 68Edit the service file `/etc/init.d/otbr-agent` if RCP device is not `/dev/ttyACM0` and then start with: 69 70```bash 71service otbr-agent start 72``` 73 74Note: The service `otbr-agent` require the service `otbr-firewall` to work properly. 75 76On startup the services `otbr-firewall` and `otbr-agent` will be automatically started. 77 78If you need to change the thread network interface (`wpan0` by default), you need to configure it through uci: 79 80```bash 81service otbr-firewall stop 82service otbr-agent stop 83uci set otbr-agent.service.thread_if_name=wpan1 84uci commit otbr-agent 85service otbr-firewall start 86service otbr-agent start 87``` 88 89### Test 90 91Enter the OpenWRT web GUI. There will be a new item _Thread_ under _Network_. Scan or create network here. 92