dresden-elektronik / openthread-r21

OpenThread Border Router for R21 based ConBee II and RaspBee II
BSD 3-Clause "New" or "Revised" License
38 stars 0 forks source link

OpenThread-R21

An OpenThread Border Router firmware port for Atmel-R21 (Microchip samr21) based ConBee II and RaspBee II.
Note: the port is still in development, watch this repository to get notified when first beta test version is released.

For interested Useres

For Developers

Build Guide (RCP-Firmware):

This Part describes how to build the openthread RCP-firmware from source. This will be obsolete once the .gcf image is available.

Prerequisites:

  1. Clone this Repo:

    git clone https://github.com/dresden-elektronik/openthread-r21
  2. cd into the directory and init the openthread and tinyusb submodule

    
    cd openthread-r21
    git submodule update --init openthread/
    git submodule update --init third_party/tinyusb

or

git submodule update --init --recursive --depth 1


3. execute the bootstrap script (This will install necessary dependencies and download the arm-none-eabi-gcc **x86** Toolchain)
```console
bash script/bootstrap.sh

If your are on an unsupported Platform, you will have to manually install the following dependencies: automake, g++, libtool, make, cmake, ninja-build, shellcheck

  1. build the RCP-Firmware

    bash script/build.sh
  2. Done! You will find the linked Firmware (.elf Format) at /openthread/out/build/ot-rcp

Flash Firmware via OpenOCD and GDB

This Part describes how to flash the previously build RCP-firmware onto the samr21 ROM-Flash by using a OpenOCD compatible Debugging Tool.

  1. Install OpenOCD (This Step may be skipped on debian and fedora based Systems, bootstrap.sh should install OpenOCD via apt or dnf )

  2. Find the Open-OCD configuration file for your Debugger (Checkout eLinux-Page where to find your config File)

    A Configuration for the ATMEL-ICE and the ATSAMR21ZLL-EK are provided in script/openocd_config/. You can also use them as a Template for your config

  3. Start an OpenOCD-Server (Do this in a seperate Terminal, this may require sudo-rights) Make Sure Your Devices are Powered!

    
    #For Atmel-ICE
    (sudo) openocd -f script/openocd_config/ATMEL-ICE-OpenOCD-samr21e18a.cfg

Generic Debugger

(sudo) openocd -f .cfg

If everything goes well, you should see the following Output:
```console
Info : Listening on port 3333 for gdb connections
  1. Start the GDB-Debugger, Connect to the OpenOCD-Server and flash the Firmware-File
gcc-arm-none-eabi/bin/arm-none-eabi-gdb \
    --init-eval-command='target extended-remote localhost:3333' \
    ./out/build/bin/ot-rcp \
    --eval-command='load'
  1. Reset the MCU (via gdb shell)

    (gdb) r
  2. Exit GDB by pressing CTRL + C and typing quit into the GDB Shell:

    (gdb) quit
  3. Done! The Firmware on your Device is ready to act as an Openthread-RCP Dongle

Install-Guide OpenThread Border-Router Daemon (Program running on the Host Side)

This Part describes how to prepare a host Platform to operate as a Openthread Border Router in conjunction with the connected RCP-Device. It is strongly advised to follow the Guide on the Official Openthread Website.

Official Openthread Border Router Guide

Tested on Debian11/Ubuntu22.04LTS/RaspberryPiOS(32Bit)

  1. Start with a fresh OS-Installation on whatever Platform you are planning to Use (Like RaspberryPi, VM, NUC).

    The OpenThread Border Router works best with debian based Platforms

  2. On your desired Host-Platform clone into the Openthread-Borader-Router-repository

git clone https://github.com/openthread/ot-br-posix
  1. cd into the repository and run the bootstrap script
cd ot-br-posix
(sudo) bash script/bootstrap
  1. Install the Border Router Daemon and specify the interface used to communicate with the local network
    
    #Raspberry Pi on Ethernet
    (sudo) bash INFRA_IF_NAME=eth0 ./script/setup

Raspberry Pi on Wifi

(sudo) bash INFRA_IF_NAME=wlan0 ./script/setup

4. Check if the serial connection got initialized correctly
```console
ls /dev/ | grep tty*

should return something like

ttyACM0

or

ttyACM1
  1. Modify the otbr-agent settings to use the expected serial-device for communication with the RCP
    (sudo) nano /etc/default/otbr-agent

The Device will likely aper as /dev/ttyACM0 but you should double check that with something like dmesg. You should modify your config-file according to your system. Some examples:

WIFI and RCP mapped to /dev/ttyACM0

OTBR_AGENT_OPTS="-I wpan0 -B wlan0 spinel+hdlc+uart:///dev/ttyACM0 trel://wlan0"

Ethernet and RCP mapped to /dev/ttyACM1

OTBR_AGENT_OPTS="-I wpan0 -B eth0 spinel+hdlc+uart:///dev/ttyACM1 trel://eth0"
  1. After modifying the otbr-agent config-file you should reboot your Host.

    sudo reboot now
  2. After Reboot you should be able to reach the Openthread Border Router Web-Interface by typing http://YOURHOSTADDR/ into your Web-Browser