{"id":19702529,"url":"https://github.com/microchiptech/atsamr21_openthread_h3","last_synced_at":"2026-03-03T19:33:23.344Z","repository":{"id":87706447,"uuid":"550671559","full_name":"MicrochipTech/ATSAMR21_OPENTHREAD_H3","owner":"MicrochipTech","description":"\"IoT Made Easy!\" - Build and Test an OpenThread Application using Microchip MPLAB X IDE with SAM R21 SoC","archived":false,"fork":false,"pushed_at":"2022-10-18T12:36:02.000Z","size":43288,"stargazers_count":0,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-20T20:26:21.883Z","etag":null,"topics":["mesh","openthread","samr21","thread"],"latest_commit_sha":null,"homepage":"","language":"Makefile","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MicrochipTech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-13T06:21:18.000Z","updated_at":"2025-01-22T17:53:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"32a647e5-a304-456f-8ead-0422f662221f","html_url":"https://github.com/MicrochipTech/ATSAMR21_OPENTHREAD_H3","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MicrochipTech/ATSAMR21_OPENTHREAD_H3","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MicrochipTech%2FATSAMR21_OPENTHREAD_H3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MicrochipTech%2FATSAMR21_OPENTHREAD_H3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MicrochipTech%2FATSAMR21_OPENTHREAD_H3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MicrochipTech%2FATSAMR21_OPENTHREAD_H3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MicrochipTech","download_url":"https://codeload.github.com/MicrochipTech/ATSAMR21_OPENTHREAD_H3/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MicrochipTech%2FATSAMR21_OPENTHREAD_H3/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30056069,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-03T18:21:05.932Z","status":"ssl_error","status_checked_at":"2026-03-03T18:20:59.341Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mesh","openthread","samr21","thread"],"created_at":"2024-11-11T21:15:26.081Z","updated_at":"2026-03-03T19:33:23.335Z","avatar_url":"https://github.com/MicrochipTech.png","language":"Makefile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ATSAMR21_OPENTHREAD_H3\n\n\u003cimg src=\"images/IoT-Made-Easy-Logo.png\" width=100\u003e\n\n\u003e \"IoT Made Easy!\" - Build and Test an OpenThread Application using Microchip MPLAB X IDE with SAM R21 SoC \n\nDevices: **ATSAMR21**\u003cbr\u003e\nFeatures: **OpenThread | FTD | CLI**\n\n## ⚠ Disclaimer\n\n\u003cp\u003e\u003cspan style=\"color:red\"\u003e\u003cb\u003e\nTHE SOFTWARE ARE PROVIDED \"AS IS\" AND GIVE A PATH FOR SELF-SUPPORT AND SELF-MAINTENANCE. This repository contains example code intended to help accelerate client product development. \u003c/br\u003e\n\nFor additional Microchip repos, see: \u003ca href=\"https://github.com/Microchip-MPLAB-Harmony\" target=\"_blank\"\u003ehttps://github.com/Microchip-MPLAB-Harmony\u003c/a\u003e\n\nCheckout the \u003ca href=\"https://microchipsupport.force.com/s/\" target=\"_blank\"\u003eTechnical support portal\u003c/a\u003e to access our knowledge base, community forums or submit support ticket requests.\n\u003c/span\u003e\u003c/p\u003e\u003c/b\u003e\n\n## A la carte\n\n1. [Introduction](#step1)\n1. [Bill of materials](#step2)\n1. [Hardware Setup](#step3)\n1. [Software Setup](#step4)\n1. [Repository Structure](#step5)\n1. [MCC Harmony Configuration](#step6)\n1. [Board Programming](#step7)\n1. [Run the demo](#step8)\n   1. [Form a network](#step8a)\n   1. [Join the network](#step8b)\n   1. [Enable leader to child communication](#step8c)\n   1. [More CLI commands](#step8d)\n1. [Known limitations](#step9)\n\n## Introduction\u003ca name=\"step1\"\u003e\u003c/a\u003e\n\nThis application, made for testing purpose, demonstrates how to enable a simple wireless communication with a [Full Thread Devices (FTD)](https://openthread.io/guides/thread-primer/node-roles-and-types) over a simple Command Line Interface (CLI).\n\nIt is based on [OpenThread for SAM R21](https://github.com/openthread/ot-samr21) implementation ported by the community. More details [here](https://openthread.io/platforms).\n\nTypically, a Full Thread Device (FTD) has always its radio ON, subscribes to the all-routers multicast address, and maintains IPv6 address mappings.\n\nThis example application exposes OpenThread configuration and management APIs via a simple Command Line Interface (CLI). \n\nMoreover, this repository describes the setup required to create a build and test CLI FTD Application for OpenThread stack running on [SAMR21G18A SoC](https://www.microchip.com/en-us/product/ATSAMR21G18A). \n\nIt provides the following:\n* Lists the software tools and devices required to setup the test environment\n* Steps to build the OpenThread CLI firmware\n* Steps to program the DUTs with OpenThread firmware\n* Steps to perform the following tests with DUTs:\n  * Network formation between 1 FTD leader and 1 FTD child\n  * UDP communication from a leader to a child\n\nFor more details on OpenThread implementation:\n- checkout the [OpenThread GitHub repo](https://github.com/openthread/)\n- checkout the [OpenThread.io](https://openthread.io/) webpage\n\n## Bill of materials\u003ca name=\"step2\"\u003e\u003c/a\u003e\n\nTwo sets of the following hardware are required:\n\n* [SAM R21 Xplained Pro Evaluation Kit](https://www.microchip.com/en-us/development-tool/ATSAMR21-XPRO)\n* A micro-USB cable\n\n## Hardware Setup\u003ca name=\"step3\"\u003e\u003c/a\u003e\n\n* Simply plug the SAM R21 Xplained Pro EVK through the EDBG USB connector to the computer using a micro-USB cable\n\n## Software Setup\u003ca name=\"step4\"\u003e\u003c/a\u003e\n\n[Clone](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository) this repository to your local computer. Make sure to clone it in the root directory (e.g. C:\\\\ot-samr21).\n\nThe sample project has been created and tested with the following Software Development Tools:\n- [MPLAB X IDE v6.00](https://www.microchip.com/en-us/development-tools-tools-and-software/mplab-x-ide)\n- [MPLAB X IPE v6.00](https://www.microchip.com/en-us/development-tools-tools-and-software/mplab-x-ide)\n- [MPLAB XC32 v4.10](https://www.microchip.com/en-us/development-tools-tools-and-software/mplab-xc-compilers)\n\n\u003e -Os settings MUST be enabled manually by adding FULL XC32 compiler licence from registering at [http://licenses.microchip.com/ ](http://licenses.microchip.com/)\n\n- SAMR21_DFP v2.0.46\n  - Install SAM R21 Device Family Pack (DFP) from MPLAB X IDE\n    - Tools -\u003e Packs\n    - Go to Device Family Packs tab\n    - Select Install Pack from Local Source\n    - Locate the folder *mplab_x_ide* from the cloned repository and select the device family pack *Microchip.SAMR21_DFP-2.0.46.atpack*\n    - Verify the installation of the device family pack by typing *samr21* in the search bar\n    - Close and restart MPLAB X IDE\n\n- EDBG_TP v1.4.384\n  - To program SAM R21 Xplained Pro board, install the Tool Packs (TP) from MPLAB X IDE\n    - Tools -\u003e Packs\n    - Go to Tool Packs tab\n    - Install/update the Tool Packs: EDBG_TP v1.4.384\n    - Close and restart MPLAB X IDE\n\n- [MPLAB Code Configurator v5.1.17](https://www.microchip.com/en-us/tools-resources/configure/mplab-code-configurator)\n   - [csp v3.11.0](https://github.com/Microchip-MPLAB-Harmony/csp/tree/v3.11.0)\n   - [core v3.10.0](https://github.com/Microchip-MPLAB-Harmony/core/tree/v3.10.0)\n   - [dev_packs v3.11.2](https://github.com/Microchip-MPLAB-Harmony/dev_packs/tree/v3.11.2)\n   - [wolfssl v4.7.0](https://github.com/Microchip-MPLAB-Harmony/wolfssl/tree/v4.7.0)\n   - [crypto v3.7.5](https://github.com/Microchip-MPLAB-Harmony/crypto/tree/v3.7.6)\n\nThe following additional software tools are required for running the project:\n- Any Serial Terminal application like [Tera Term](https://osdn.net/projects/ttssh2/releases/) terminal application\n\n\n## Repository Structure\u003ca name=\"step5\"\u003e\u003c/a\u003e\n\nThe ot-samr21 directory is organized as below: \n\n```bash\n├── examples/\n├── openthread/\n├── script/\n├── src/\n├── third_party/\n├── CMakeLists.txt\n├── LICENSE\n└── README.md\n```\n\n| Folder |\tDescription |\n| ------ | ------------ |\n| examples |\tCLI Example applications ported to MPLAB MCC Harmony framework |\n| openthread | The openthread repository as a submodule |\n| script\t| Scripts for building, testing, linting |\n| src |\tThe platform abstraction layer implementation |\n| third_party |\tLocation for any third-party sources |\n\n\n## MCC Harmony Configuration\u003ca name=\"step6\"\u003e\u003c/a\u003e\n\n### Project structure\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"images/cli_project_structure.png\" width=320\u003e\n\u003c/p\u003e\n\n### Project dashboard\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"images/cli_ftd_dashboard.png\" width=320\u003e\n\u003c/p\u003e\n\n```bash\nTotal ROM used  :     0x394af      234671  89.5% of 0x40000\n        --------------------------------------------------------------------------\n         Total Program Memory used  :     0x394af      234671  89.5% of 0x40000\n        --------------------------------------------------------------------------\n\n\nTotal RAM used  :      0x4349       17225  52.6% of 0x8000\n        --------------------------------------------------------------------------\n            Total Data Memory used  :      0x4349       17225  52.6% of 0x8000\n        --------------------------------------------------------------------------\n```\n\n### Project graph\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"images/cli_project_graph.png\" width=640\u003e\n\u003c/p\u003e\n\n\n## Board Programming\u003ca name=\"step7\"\u003e\u003c/a\u003e\n\nMake sure the SAM R21 Xplained Pro Kits are plugged to the computer through micro-USB cables.\n\n### Program the precompiled hex file using MPLAB X IPE\n\nUsing MPLAB IPE:\n* Select **ATSAMR21G18A** as Device flash and hit the *Apply* button\n* Select the tool connected: **EDBG**\n* Browse for the following file: *hex/CLI_FTD.X.production.hex*\n* Hit the *Program* button\n* Repeat the above steps for the second kit\n\n### Build and program the application using MPLAB X IDE\n\nUsing MPLAB IDE:\n* Check the settings in the project properties\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"images/cli_project_properties.png\" width=640\u003e\n\u003c/p\u003e\n\n* Compile the application by clicking on the *Clean and Build* button\n* Program the application to the device by clicking on the *Make and Program* button\n\n\n## Run the demo\u003ca name=\"step8\"\u003e\u003c/a\u003e\n\n### Form a network\u003ca name=\"step8a\"\u003e\u003c/a\u003e\n\nTo create the network, start with the router eligible Node 1 (Leader) and enter the following commands.\n\n#### Node 1 commands\n\nPress `Enter` to see a prompt `\u003e`. \n\n- Start by issuing the command to create a new network configuration\n- Set a particular channel\n- Commit new dataset to the active operational dataset\n- Bring up the Thread IPv6 interface\n- Start Thread protocol operation\n- Wait few seconds\n- Read the current state of the node. It should be the Leader\n- View the network configuration and make note of the Network Key which will be used later \n\n```bash\n\u003e dataset init new\nDone\n\u003e dataset channel 18\nDone\n\u003e dataset commit active\nDone\n\u003e ifconfig up\nDone\n\u003e thread start\nDone\n\u003e state\nLeader\n\u003e dataset\n...\n```\n\n#### Node 1 console\n\nSerial Port Setup: 115200 / 8 / N / 1\n\nAccording to the response of the command state and dataset, the leader is created.\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"images/cli_ftd_network_formation.png\" width=480\u003e\n\u003c/p\u003e\n\n### Join the network\u003ca name=\"step8b\"\u003e\u003c/a\u003e\n\nTo add child Node 2 to the network, enter the commands lines below in the console.\n\n#### Node 2 commands\n\nPress `Enter` to see a prompt `\u003e`. \n\n- Start by setting the channel used in the alive network which is to decrease latency\n- Set the Network Key of the leader. This step is required for a device to attach to a Thread network\n- Commit new dataset to the active operational dataset\n- Bring up the Thread IPv6 interface\n- Start Thread protocol operation\n- Wait few seconds\n- Read the current status of the node. It should be a Child\n- Check its IPv6 address using `ipaddr` command. Make note of the Mesh-Local IPv6 address which will be use later.\n\n*Note: the `ipaddr` command should return 3 IPv6 addresses\u003c/br\u003exxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx First one corresponds to the Routing Locator (RLOC): this address is created when the device is attached to the network, and is generally not used by applications\u003c/br\u003exxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx This one is the Mesh-Local EID (ML-EID): this address is independent of the network topology, and is\nused to communicate with the other interface in the same thread network\u003c/br\u003exxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx The last one is the Link-Local Address (LLA): this address starts with fe80::/16 prefix, it is created with the MAC address. It is not used to communicate between nodes. We can still use them between two nodes if there is only a link, one radio transmission, not more than one cable to retransmit the message*\n\n```bash\n\u003e dataset channel 18\nDone\n\u003e dataset networkkey f13b6c20290e6dc620c3eb8bb8916fe5\nDone\n\u003e dataset commit active\nDone\n\u003e ifconfig up\nDone\n\u003e thread start\nDone\n\u003e state\nchild\n\u003e ipaddr\nfdde:a5c0:c0fe:2e79:0:ff:fe00:ec01\nfdde:a5c0:c0fe:2e79:ab88:3eb:9fa5:ce22\nfe80:0:0:0:6c3b:3194:8bf5:b56f\nDone\n```\n\n#### Node 2 console\n\nSerial Port Setup: 115200 / 8 / N / 1\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"images/cli_ftd_joining_into_the_network.png\" width=480\u003e\n\u003c/p\u003e\n\n### Enable leader to child communication\u003ca name=\"step8c\"\u003e\u003c/a\u003e\n\nOne of the application services that OpenThread provides is User Datagram Protocol (UDP), a transport Layer protocol. An application built on OpenThread could use the UDP API to pass messages between nodes in a Thread network, or to other devices in an external network (like the internet, if the Thread network features a Border Router).\n\nUDP sockets are exposed through the OpenThread CLI. Let's use it to pass messages between the two FTDs.\n\nGet the Mesh-Local EID address for the FTD Joiner. We're using this address because it's reachable from anywhere within the Thread network.\n\n#### Node 2 (child) commands\n\n- Open UDP socket\n- Bind UDP to a socket for any IPv6 address using `udp bind :: \u003cudp port number\u003e`\n\n*Note: The `::` specifies the IPv6 Unspecified Address*\n\n```bash\n\u003e udp open\nDone\n\u003e udp bind :: 1234\nDone\n```\n\n#### Node 1 (leader) commands\n\n- Open UDP socket\n- Send UDP packet using `udp send \u003cmesh-local ip address\u003e \u003cudp port number\u003e \u003cstring\u003e`\n\n```bash\n\u003e udp open\nDone\n\u003e udp send fdbb:48ee:3b7c:d3cf:ab88:3eb:9fa5:ce22 1234 HelloMicrochip\nDone\n```\n\n#### Node 2 (child) result\n\nOn Node 2, you should see a print out similar to below:\n\n```bash\n\u003e 14 bytes from fdbb:48ee:3b7c:d3cf:e7e5:8cae:deb2:350c 49153 HelloMicrochip\n```\n\n#### Node consoles\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"images/cli_ftd_leader_to_child_communication.png\" width=640\u003e\n\u003c/p\u003e\n\n### More CLI commands\u003ca name=\"step8d\"\u003e\u003c/a\u003e\n\nFor a list of all available commands, visit [OpenThread CLI Reference README.md][cli]\n\n[cli]: https://github.com/openthread/openthread/blob/main/src/cli/README.md\n\n\n## Known limitations\u003ca name=\"step9\"\u003e\u003c/a\u003e\n\n1. This [OpenThread implementation for SAM R21](https://github.com/openthread/ot-samr21) is originally coming from [community ports](https://openthread.io/platforms/community/microchip). The [OpenThread.io](https://openthread.io/platforms#support) website claims these platforms have not been fully tested and may be missing some key functionality.\n\n2. Multiple ping option is disabled.\n\n\n\n\n\n\n\u003ca href=\"#top\"\u003eBack to top\u003c/a\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrochiptech%2Fatsamr21_openthread_h3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicrochiptech%2Fatsamr21_openthread_h3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrochiptech%2Fatsamr21_openthread_h3/lists"}