{"id":20885295,"url":"https://github.com/lab11/raspberrypi-cc2520","last_synced_at":"2025-07-30T08:10:11.274Z","repository":{"id":6362076,"uuid":"7599241","full_name":"lab11/raspberrypi-cc2520","owner":"lab11","description":"Code, hardware, and instructions to use the TI CC2520 with the Raspberry Pi.","archived":false,"fork":false,"pushed_at":"2015-05-26T04:49:48.000Z","size":14059,"stargazers_count":31,"open_issues_count":3,"forks_count":11,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-12T17:50:27.814Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Eagle","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lab11.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-01-14T05:56:34.000Z","updated_at":"2023-06-30T00:37:48.000Z","dependencies_parsed_at":"2022-09-14T19:10:26.724Z","dependency_job_id":null,"html_url":"https://github.com/lab11/raspberrypi-cc2520","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/lab11/raspberrypi-cc2520","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lab11%2Fraspberrypi-cc2520","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lab11%2Fraspberrypi-cc2520/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lab11%2Fraspberrypi-cc2520/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lab11%2Fraspberrypi-cc2520/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lab11","download_url":"https://codeload.github.com/lab11/raspberrypi-cc2520/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lab11%2Fraspberrypi-cc2520/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267834807,"owners_count":24151642,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-11-18T08:13:04.973Z","updated_at":"2025-07-30T08:10:11.198Z","avatar_url":"https://github.com/lab11.png","language":"Eagle","funding_links":[],"categories":[],"sub_categories":[],"readme":"raspberrypi-cc2520\n==================\n\nCode, hardware, and instructions to use the TI CC2520 with the Raspberry Pi.\n\n[\n![rpi-cc2520](https://raw.github.com/bradjc/raspberrypi-cc2520/master/media/rpi-cc2520_2ndgen_500px.jpg)\n](https://raw.github.com/bradjc/raspberrypi-cc2520/master/media/rpi-cc2520_2ndgen.jpg)\n\nThe CC2520 is a 802.15.4 (Zigbee) radio commonly used in low power wireless\nsensor networks. Typically 802.15.4 radios are used with WSN motes and embedded\nmicrocontrollers. A side-effect of being used in WSNs, however, is the\nmicrocontrollers are very memory constrained. This is often a problem when\ncertain nodes need to keep data about a large network of nodes, for instance\nrouting information for all of the nodes. To remedy this we propose using a\nRaspberry Pi as a mote in a WSN. This provides both ample storage (memory) and\nconvenient control as all the utilities in Linux are available.\n\n\nHardware\n--------\n\nI have a small PCB that fits directly on to the main header on the\nRPi. It contains the CC2520, an SMA connector for an antenna, the DS2411\nid chip, and three LEDs. The eagle files, gerbers and BOM can be found in the\n`hardware/eagle/rpi-cc2520` folder.\n\n\nSoftware\n--------\n\n### Kernel Module\n\nIn order to support the CC2520\nyou need the kernel module from https://github.com/ab500/linux-cc2520-driver.\nThis kernel module is designed to run on top of the Raspbian Linux distribution.\n\n### Custom Version of Raspbian\n\nInstead of compiling and installing the CC2520 kernel module yourself, you can\ndownload a pre-configured\n[image](http://nuclear.eecs.umich.edu/public/raspbian_cc2520_2013-09-18.zip)\nof raspbian and put that on the sdcard instead.\nDownload the img and then install it to an SD\ncard ([here](http://elinux.org/RPi_Easy_SD_Card_Setup) is a helpful guide). For\nreference, I use:\n\n    dcfldd bs=4M if=raspbian_cc2520_2013-06-27.img of=/dev/sdd statusinterval=4\n\n### TinyOS\n\nAll of the code I have for the RPi/CC2520 is based on TinyOS. You can use the\nCC2520 driver without TinyOS (see the tests in the linux-cc2520-driver repo),\nbut for my purposes TinyOS was the best option.\n\nTo setup my workflow,\non your non-RPI computer you need a copy of the main TinyOS repository and the\ntinyos folder from this repo. You also need to install the dependencies for\nTinyOS. There are instructions here:\n[http://docs.tinyos.net/tinywiki/index.php/Installing_TinyOS]. If you want\nthe simple Linux install I use, look here:\n[http://energy.eecs.umich.edu/wiki/doku.php?id=tinyos_install]. The TinyOS\napplications are designed to be cross compiled for the RPI.\n\nIn order for the TinyOS build system to figure out all the correct paths you\nneed to help it along a bit. Add the following to your `.bashrc` file:\n\n    export TINYOS_ROOT_DIR=\u003cpath to git repo\u003e/tinyos-main\n    export TINYOS_ROOT_DIR_ADDITIONAL=\u003cpath to git repo\u003e/raspberrypi-cc2520/tinyos:$TINYOS_ROOT_DIR_ADDITIONAL\n\n\nYou will also need the correct cross compiler for the RPi:\n`arm-linux-gnueabi-gcc`. On Ubuntu:\n\n    sudo apt-get install gcc-arm-linux-gnueabi\n\n#### NesC\n\nNesC is the first pass compiler for TinyOS. This compiler converts .nc files\ninto c code that gcc can handle. This code requires nesc version 1.3.5+.\n\n#### Supported TinyOS Features\n\n  - Gpio\n  - Interrupts (high latency, can't use for timing critical operations)\n  - 802.15.4 Packets\n  - Active Message\n  - Timers\n  - DS2411\n  - Busy wait\n  - Command line arguments\n  - Printf\n  - Random numbers\n  - Unix timestamps\n  - Uart receive\n  - TUN interface\n\n\nSetup\n-----\n\nOnce you have an RPi setup with Raspbian, there are various changes you may\nneed to make to the Raspbian install depending on what you want to do.\n\n### Use IPv6\nTo use IPv6 you need to enable IPV6 on the RPI:\n\n    $ sudo vim /etc/modules\n    add ipv6 on a newline\n\n### Enable Interface Forwarding\n\nBy default, Linux will not forward packets between interfaces. This\nfunctionality is critical, however, if you want the RPi to act as a border\nrouter for a  wireless network. Once interface forwarding is enabled, Linux\nconsiders the machine to be a\nrouter. This causes it to no longer receive IPv6 router advertisements, because\nrouters are typically statically configured. In most cases we'd rather not deal\nwith that, so we would like Linux to both accept router advertisements and to\nforward packets.\nTo enable these you need to do\nthe following:\n\n    sudo vim /etc/sysctl.conf\n    uncomment the line: net.ipv6.conf.all.forwarding=1\n    add the line: net.ipv6.conf.eth0.accept_ra=2\n\n\n\nUsage\n-----\n\nNow to test the TinyOS code and the kernel module.\n\n### Blink\n\nAssuming you have the correct compilers, you should be able to run the following\non your desktop and have it compile successfully:\n\n    cd tinyos-main/apps/Blink\n    make rpi\n\nTo install it to the RPi you can simply do:\n\n    make rpi install scp.\u003cipaddress of the rpi\u003e\n\nThen on the rpi:\n\n    sudo ./BlinkAppC\n\nPins 7, 12, and 13 should be toggling and the LEDs on the interface board should\nbe blinking.\n\n\n### RadioCountToLeds\n\nTo test the radio with TinyOS, run the RadioCountToLeds app on the RPi and\nanother mote. The basic process is the same as with the blink app above.\n\n\n### Debug\n\nIf you need to, you can run the TinyOS application with GDB. To add the debug\nsymbols:\n\n    make rpi debug\n\nThen on the RPi:\n\n    sudo gdb ./AppC\n\n\nSetting Up an Actual Border Router\n----------------------------------\n\nThese are the instructions for how I'm testing the RPI as a border router.\nBecause IPv6 support is anything but universal, this requires more manual setup\nthan desired.\n\nMy setup consists of using Hurricane Electric to tunnel IPv6 to the RPi and all\ncomputers I wish to send packets to.\n\n### Setting up the Tunnel\n\nGo to http://www.tunnelbroker.net/ to setup a tunnel to the IP address of the\nRPI. The Hurricane Electric instructions will setup an IPv6 in IPv4 tunnel\ndevice on the RPi.\n\nHurricane Electric conveniently provides every tunnel it creates a /64 prefix\nthat they route to the end of the tunnel. This is perfect for the BorderRouter\napplication as the WSN nodes can use IP addresses in this range.\n\n### Setting Up the Border Router\n\nThe RPi will be running the BorderRouter app.\nThe border router is required to determine the 64 bit IPv6 prefix that the\nnetwork uses. How this prefix is assigned can be handled in several ways:\nIPv6 Neighbor Discovery, DHCP, or static configuration.\n\n#### Addressing: IPv6 Neighbor Discovery\n\nTo use router solicitations and router advertisements to assign a prefix\nfor the network, set `BLIP_ADDR_AUTOCONF=1` in the Makefile, as well\nas `BLIP_SEND_ROUTER_SOLICITATIONS=1`. This will cause the border router\nto send a router solicitation in order to receive a router solicitation\nand then use the prefix that it receives from the router advertisement as the\nnetwork prefix.\n\nThe next step is something must respond to the router solicitations. To do\nthis, setup [radvd](https://github.com/reubenhwk/radvd) to respond to router\nsolictitations on the interface that the border router creates. To configure\nthe name of the TUN device the border router creates, run the border router\napp like this:\n\n    sudo ./BorderRouterC -i tunname\n\n#### Addressing: DHCP\n\nBlip supports both static and dynamic IP addresses. If you wish to reduce your\nburden when flashing nodes and use dynamic addresses, you need to be\nrunning a DHCP server. Ideally you could use any router's DHCP server, but in\nthe likely case that isn't available, you can run a DHCP server on the RPI.\n\nI'm using [Dibbler](http://klub.com.pl/dhcpv6/). I couldn't figure out how to\ncross compile it so I downloaded it to the RPi and built it on there (yeah it\ntook a little while). Alternatively, you can try getting\n[these directions](http://klub.com.pl/dhcpv6/doxygen/dc/dec/compilation.html#compilationCross)\nfor cross-compiling Dibbler to work.\n\n    tar xf dibbler-x.x.x.tar.gz\n    ./configure\n    make\n    sudo make install\n\nRunning Dibbler is pretty straightforward. The last key is the configuration file\nlocated at `/etc/dibbler/server.conf`. Here is mine:\n\n    log-colors true\n\n    iface relay1 {\n     relay tun0\n\n     class {\n      pool \u003cipv6/64 from Hurricane Electric\u003e/64\n     }\n    }\n\n    iface \"tun0\" {\n     class {\n      pool \u003cipv6/64 from Hurricane Electric\u003e/64\n     }\n\n     client link-local fe80::212:6d52:5000:1 {\n      address \u003cipv6/64 from Hurricane Electric\u003e:1\n      prefix \u003cipv6/64 from Hurricane Electric\u003e/64\n     }\n    }\n\n#### Addressing: Static\n\nTo assign a static prefix, uncomment `components StaticIPAddressC;` from `BorderRouterC.nc`\nand update the prefix in `brconfig.ini`.\n\n### Compile and Install\n\nIn `/tinyos/apps/BorderRouter`:\n    \n    make rpi install scp.\u003cip address of rpi\u003e\n\n### Operation\n\nOnce running the BorderRouter application will forward all IPv6 packets that are not destined\nfor a node in the network to the TUN interface, and then Linux can route those packets\nto the Internet.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flab11%2Fraspberrypi-cc2520","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flab11%2Fraspberrypi-cc2520","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flab11%2Fraspberrypi-cc2520/lists"}