Preview only show first 10 pages with watermark. For full document please download

An6 Using Raspberry Pi With Homeplug Green Phy

   EMBED


Share

Transcript

AN6 Using Raspberry Pi with HomePlug Green PHYTM Powerline Evaluation Kit I2SE GmbH: Michael Heimpold January 13, 2017 1/9 CONTENTS CONTENTS Contents 1 Revisions 3 2 Introduction 3 3 Hardware Requirements 3 4 SD Card Preparation 4 5 Preparing the Evaluation Board for PLC Stamp micro 4 6 Physical Wiring 5 7 Software configuration 5 8 FAQ 8.1 8.2 8.3 8.4 8.5 Raspberry Pi model . . . . . . . . . . . . . . . . . . . . . . HAT compliance . . . . . . . . . . . . . . . . . . . . . . . . Static MAC Address for Powerline Network Interface . . . . . Bridging between Powerline Interface and Wired Ethernet/Wifi What to do next? . . . . . . . . . . . . . . . . . . . . . . . . 9 Contact . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 7 7 7 8 9 9 2/9 3 1 Revisions Revision 1 2 HARDWARE REQUIREMENTS Release Date January 13, 2017 Changes Initial release Introduction I2SE’s Evaluation Board for PLC Stamp micro is a simple yet powerful solution to get familiar with powerline communication for the Internet of Things. The heart of this board is the PLC Stamp micro module by I2SE which in turn is based on the QCA7000 by Qualcomm Atheros. This is a HomePlug Green PHY chip which is fully compatible to the HomePlugAV standard. The Raspberry Pi is a full-featured development board, backed by a huge family of contributor and many ready-touse applications etc. Therefore it is obvious to combine these both boards to evaluate and/or create new powerline solutions. This guide shows how fast the marriage of the two boards is done and additionally discusses some frequently asked questions and common pitfalls. The Evaluation Board for PLC Stamp micro is connected to mains power for communication. There exists the risk of an electric shock when the cable is installed. So follow this instructions carefully and double-check before powering on. 3 Hardware Requirements The hardware required cuts down to the following list: • Raspberry Pi • I2SE’s Evaluation Board for PLC Stamp micro • USB power supply for Raspberry Pi • power cord with plug on the one side and wires ends with end terminals (wire ferrules) on the second one • short USB A to USB micro cable • short 40-pin to 26-pin ribbon cable • micro SD card (at least 2 GB) • ethernet patch cable (used during Raspberry Pi setup) • wall plug powerline to ethernet adapter • ethernet patch cable to connect powerline adapter to router/switch If you want to control your Raspberry Pi with keyboard and display, then you need to attach these two. To start as fast as possible I2SE sells bundles consisting of all required components. These bundles are available with the article number I2PLC-RPIKIT-001. 3/9 5 PREPARING THE EVALUATION BOARD FOR PLC STAMP MICRO Figure 1: Required hardware components 4 SD Card Preparation To prepare the SD card, simply following the next steps: 1. Download latest Raspbian Image https://www.raspberrypi.org/downloads/raspbian/ For powerline communcation it does not matter whether you chose Raspbian Jessie with Pixel or Raspbian Jessie Lite. This only depends on your environment, e.g. whether you want to use GUI etc. 2. Extract the raw disk image from the downloaded ZIP archive. 3. Download Win32 Disk Image https://sourceforge.net/projects/win32diskimager/ We recommend this tool for Windows platform to write the raw disk image to the SD card. 4. Once the write finished, Windows will recognize the boot partition with the FAT filesystem on the SD card. Locate the config.txt and open it with Notepad or another simple text editor. Add the following line to the file and save it afterwards: dtoverlay=qca7000 That’s all. The QCA7000 kernel driver is already included as module. Also a devicetree overlay for QCA7000 is available, which you simply enable in the last step. Now you can safely remove the SD card and insert it in your Raspberry Pi. If you need further help on this topic, please visit https://www.raspberrypi.org/ for detailed instructions. 5 Preparing the Evaluation Board for PLC Stamp micro The Evaluation Board for PLC Stamp micro has several jumpers for configuration. It’s recommended to start with the following jumper setup: • JP4: all removed • JP5: removed • JP11: all set • JP13: – GPIO 0: pull-up (jumper connects middle and right pins) – GPIO 1: pull-down (jumper connects left and middle pins) – GPIO 2: pull-up (jumper connects middle and right pins) – GPIO 3: pull-up (jumper connects middle and right pins) 4/9 7 SOFTWARE CONFIGURATION • JP15: all removed According to this setup, the QCA7000 starts its firmware from attached SPI flash. Please refer to the evaluation board’s datasheet for further details. You can download the latest version at https: //www.i2se.com/product/plc-stamp-micro-evk/ 6 Physical Wiring This most important wiring is the connection between the Raspberry Pi GPIO pins and the X1 socket with 26 pin on the Evaluation Board for PLC Stamp micro. For this use the short ribbon cable. On the Raspberry Pi side, there is no mechanical key at the pins, so double-check that you do not confuse the pins: pin 1 is next to the boards border and is also marked on the ribbon cable. Unfortunately, it’s not possible to feed power over this ribbon cable to the Evaluation Board for PLC Stamp micro. Power can be supplied only via its mini USB socket: attach the USB A to USB mini cable to it and insert the USB A side into one of Raspberry Pi’s USB ports. Danger! Ensure that the power cord is not plugged into mains before doing the next steps! Otherwise you might encounter an electric shock! Then attach the power cord to the X3 connector of the Evaluation Board for PLC Stamp micro. Please verify that the connection is solid and cannot dissolve itself when the board is moved! On X3 there are 4 terminals for wires: use number 3 and 4. This are the two lower terminals, or in other words: the two terminals which are nearest to the C3 printing (The upper two terminals are intended for electrical vehicle communication evaluation and use special transformers.) Now attach the USB power supply to Raspberry Pi’s micro USB slot and plug in the network patch cable into Raspberry Pi and your router/PC. Plug in both the USB power supply and the power plug for the powerline communication into power points and wait until Raspberry Pi starts up. Figure 2: Hardware components wired 7 Software configuration Login to your Raspberry Pi to check whether the SPI connection to the Evaluation Board for PLC Stamp micro works. 5/9 7 SOFTWARE CONFIGURATION You can see whether the driver for the QCA7000 successfully found the chip and created a second ethernet interface. Use dmesg to check: pi@raspberrypi:˜ $ dmesg | grep qca [ 8.679849] qcaspi spi0.0: ver=0.2.7−i, clkspeed=12000000, burst len=5000, pluggable=0 [ 8.679951] qcaspi spi0.0: Using random MAC address: f6:45:27:00:4e:6b pi@raspberrypi:˜ $ Check whether the new network interface (usually eth1) is available: pi@raspberrypi:˜ $ ifconfig eth0 Link encap:Ethernet HWaddr b8:27:eb:b1:21:3b inet6 addr: fe80::5e25:34e9:e4c0:83ed/64 Scope:Link UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) eth1 Link encap:Ethernet HWaddr f6:45:27:00:4e:6b inet6 addr: fe80::74d9:733b:5639:8eb/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:100 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) wlan0 Link encap:Ethernet HWaddr b8:27:eb:e4:74:6e inet6 addr: fe80::fae6:5af0:3990:fc60/64 Scope:Link UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:2 errors:0 dropped:2 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:123 (123.0 B) TX bytes:0 (0.0 B) It’s assumed that your Raspberry Pi is configured via DHCP and already obtained an IP address from your router via wired and/or wireless connection and you can access the Internet to download further software packages. We recommend to install the open-plc-utils, a tool collection to manage and debug the Qualcomm Atheros based powerline chipsets. For this we recommend using precompiled packages for Raspbian as provided by the community. So installation cuts down to: pi@raspberrypi:˜ $ curl −s https://packagecloud.io/install/repositories/mhei/open−plc−utils/script.deb.sh | sudo bash pi@raspberrypi:˜ $ sudo apt install open−plc−utils 6/9 8 FAQ The tool plctool can be used to query the QCA7000’s firmware version. pi@raspberrypi:˜ $ sudo plctool −r eth1 00:B0:52:00:00:01 Request Version Information eth1 00:01:87:FF:FF:2B QCA7000 MAC−QCA7000−1.1.3.1531−00−20150204−CS pi@raspberrypi:˜ $ If this is successfully, then the SPI connection to the evaluation board works perfectly. When your HomePlug wall plug adapter is already setup and working, you are now ready to join the powerline network. For this you need to pair the wall plug adapter with the evaluation board. One possibilty is to press the powerline security button on the wallplug adapter to start the pairing, and then to run the following command on the Raspberry Pi - this emulates pressing the pairing button of the evaluation board: pi@raspberrypi:˜ $ sudo plctool −B join eth1 00:B0:52:00:00:01 Join Network eth1 00:01:87:FF:FF:2B Joining ... pi@raspberrypi:˜ $ After a short while, you should see the remote powerline adapter: pi@raspberrypi:˜ $ sudo plcstat −t P/L NET TEI −−−−−− MAC −−−−−− −−−−−− BDA −−−−−− TX RX CHIPSET FIRMWARE LOC STA 002 00:01:87:FF:FF:2B 00:01:87:FF:FF:FE n/a n/a QCA7000 MAC−QCA7000 −1.1.3.1531−00−20150204−CS REM CCO 001 00:0B:3B:AA:86:55 E0:CB:4E:ED:1F:53 009 009 INT6400 INT6000−MAC −4−1−4102−00−3679−20090724−FINAL−B pi@raspberrypi:˜ $ Then you’ve successfully created a powerline connection. Now you can configure the eth1 interface according to your needs, e.g. enable DHCP or assign a static IP address etc. After this setup is finished, you should be able to remove the Raspberry Pi’s network cable. Communication should now be possible with the IP address of the powerline network interface. 8 8.1 FAQ Raspberry Pi model Q: This application note uses a Raspberry Pi 3. But I have an older Raspberry Pi x around. Can I use this instead? A: Yes, of course. The pin out of the GPIOs is same for every Raspberry Pi model. The QCA7000 chip is attached via SPI to the Raspberry Pi and requires on GPIO as interrupt line. The required signals are within the first 26 pins, so you could even use such an old Raspberry Pi A/B (Rev 2). 8.2 HAT compliance Q: Why do I need to manually edit the config.txt to enable driver and pin muxing. What about HAT (Hardware Attached on Top) compliance? A: The current hardware version of the Evaluation Board for PLC Stamp micro was developed long time before the HAT specification was published. This is also the reason for the 26 pin socket on the board instead of a 40 pin one. So the board is missing the required I2C identification chip. Q: Are you planning a new - HAT compliant - version of your evaluation board? A: That depends on multiple factors, e.g. other customer projects and demands. Best would be to drop us a short email to signal your interest. 8.3 Static MAC Address for Powerline Network Interface Q: The network interface created by QCA driver has a random MAC address after every boot. How can I prevent this? 7/9 8.4 Bridging between Powerline Interface and Wired Ethernet/Wifi 8 FAQ A: It’s usually the task of a boot loader and board support package code to bridge between the persistent MAC address storage (e.g. some OTP bits) and the Device Tree/platform data to tell the driver which MAC address to use. In the case of the RPi there simply does not exist such a static assignment, so the driver has no chance but to use a random MAC address. However, you can workaround this by specifying an MAC address in Raspbian network configuration. For this create a file /etc/network/interfaces.d/eth1 with the following content: auto eth1 iface eth1 inet dhcp hwaddress ether 00:01:87:ff:ff:fe The line with hwaddress ether does the trick. Please adapt the other settings according to your needs. 8.4 Bridging between Powerline Interface and Wired Ethernet/Wifi While it is possible to bridge the powerline network interface (eth1) with other network interfaces of the Raspberry Pi, we do not recommend this due to the limitations of the QCA7000 chipset: this chipset is intended for HomePlug Green PHY communication, that is for Internet of Things devices. These devices are expected to have a single MAC address ,,behind” the QCA7000, thus the QCA firmware only announces one ,,bridged MAC address” to other powerline peers. Communication is therefore only stable to a single device behind the bridge. So this single device should be the Raspberry Pi itself, i.e the MAC address of the powerline network interface on the Raspberry Pi. However, it would be possible to install a proxy server or similar on the Raspberry Pi. This way, communication on layer 2 is terminated at the Raspberry Pi and higher layers will take care to reach the final destination. On the other hand, if you still want to bridge the powerline interface, here are some hints. First, install the bridge-utils package on Raspbian: pi@raspberrypi:˜ $ sudo apt update pi@raspberrypi:˜ $ sudo apt install bridge−utils Then you have to adapt the network configuration. See https://wiki.debian.org/NetworkConfiguration for details. The following configuration file is a simple example which bridges the wired network interface with the powerline network interface and configures it for DHCP. # interfaces(5) file used by ifup(8) and ifdown(8) # Please note that this file is written to be used with dhcpcd # For static IP, consult /etc/dhcpcd.conf and ’man dhcpcd.conf’ # Include files from /etc/network/interfaces.d: source−directory /etc/network/interfaces.d auto lo iface lo inet loopback iface eth0 inet manual iface eth1 inet manual auto br0 iface br0 inet dhcp bridge ports eth0 eth1 bridge fd 0 hwaddress ether b8:27:eb:b1:21:3b allow−hotplug wlan0 iface wlan0 inet manual wpa−conf /etc/wpa supplicant/wpa supplicant.conf allow−hotplug wlan1 iface wlan1 inet manual wpa−conf /etc/wpa supplicant/wpa supplicant.conf 8/9 8.5 What to do next? 9 CONTACT Please note that bridge interface ,,inherits” the MAC address of one of its children. As described above, the powerline interface has a random MAC address, so it’s best to statically assign the MAC address of the eth0 interface to the bridge, too. 8.5 What to do next? Q: This is a really nice application note. But why should I use your evaluation board with a Raspberry Pi? A simpler solution would be to use a second wallplug ethernet adapter on the Rasberry Pi side. A: This is just one point of view. We provide the Evaluation Board in order to let you play with ideas and try them out quickly. Maybe you have new projects in mind, e.g. based on Raspberry Pi computer module or Raspberry Pi Zero. Then you could make your own PCB with a design in of the PLC Stamp micro 2 module. In this case you could test your software already on the Raspberry Pi without having your own PCB available finished. Imagine the amazing possibilities you have with the CPU power of the Raspberry Pi and no need for extra cables or Wifi connectivity. Since you have to power the Raspberry Pi anyway, it makes really sense to use this required one wire additionally for communication. For example if you intent to create a home automation server you will benefit from the minimal power consumption of the HomePlug Green PHY technology compared to the consumption of a 1.2Gbit adapter. And by the way, ideal counterparts for your Home Automation server are the I2SE XPL Rail devices: the JSON API is documented at http://xpl-rest-api.readthedocs.io/en/latest/. 9 Contact I2SE GmbH Friedrich-Ebert-Str. 61 04109 Leipzig Deutschland http://www.i2se.com/ 9/9