HOME ABOUT PROJECTS CONTACT BLOG

Ethereum Private Network Using Raspberry Pi & Beaglebone

Part 1, May 20, 2018

Introduction

This is the first part of multiple posts which provide a step-by-step guide to setting up a private Ethereum network using devices such as; Raspberry-pi 3 Model B, Raspberry Pi Zero, and Beaglebone Black Rev. C. This tutorial will also use another machine instance such as a laptop/VM to act as a miner on the private network. For the purpose of this tutorial I will be manually installing and configuring the required software to help understand the entire process. The end objective of this series of posts is to allow the communication of data between peers/IoT device participants on the private network.

Requirements

OS Installation

The first step is to install Rasbian Lite on the Raspberry Pis and Debian on the Beaglebone. Raspbian Lite can be downloaded from here, and the version of Debian I used on the Beaglebone is found here (bone-debian-9.3-iot-armhf-2018-03-05-4gb.img.xz). The recommended GUI based image writing application called Etcher can be downloaded here. Otherwise if you are using Linux, use a command line tool such as dd can be used to write the image to the SD card. First run a lsblk command to view the currently mounted partitions/devices. Then plug in the SD card and run the same lsblk command to see the label of the newly mounted device. For example the device can be labeled sdb. Assuming the SD card is labeled as sdX (where X is the letter of the target SD card) and the zipped Raspbian image is in the current directory, run the following command:
Note: Running the following command will overwrite the device specified so ensure to select the right block device for the SD Card and double check!!!

unzip -p 2018-04-18-raspbian-stretch-lite.zip | sudo dd of=/dev/sdX bs=4M status=progress conv=fsync
This command unzips the image, writes the resulting image to /dev/sdX to the SD card using a block size of 4MB, while enabling visual progress using the status argument.

Again to write the Debian based image to the SD card for the Beaglebone, Etcher can be used or otherwise use the following command:
Note: Running the following command will overwrite the device specified so ensure to select the right block device for the SD Card and double check!!!

xz -dc bone-debian-9.3-iot-armhf-2018-03-05-4gb.img.xz | sudo dd of=/dev/sdX bs=4M status=progress conv=fsync
A useful feature of the Beaglebone Black Rev. C is that it has 4GB of on-board eMMC storage which can be used to store the OS. This is preferable over running the OS from the micro SD card for increased performance reasons. To enable the flash of the OS to the on-board storage of the Beaglebone, edit the /boot/uEnv.txt file on the Linux partition on the microSD card and remove the # on the line with cmdline=init=/opt/scripts/tools/eMMC/init-eMMC-flasher-v3.sh. Doing this will cause booting the microSD card to flash the eMMC. Insert the SD card into the Beaglebone and insert the barrel connector power supply while holding the S2 (boot button) on the board. Hold the button until the 4 LED indicator begin to flash in a loop manner and process of flashing may take up to 25 minutes. Once the process has completed successfully the LED indicator lights will become solid blue and you should remove the SD card. Otherwise if you have waited and suspect the flash has failed, just unplug the power and redo the previous steps.

Initial Configuration

To check the IP address of the devices on the LAN, I like to use a tool on Linux named nmap which can be installed using the following command:
Note: Running the following command will overwrite the device specified so ensure to select the right block device for the SD Card and double check!!!
sudo apt-get update && sudo apt-get -y install nmap
nmap -n 192.168.1.0/24
Where your relevant LAN subnet should be used in place of 192.168.1.0/24. The IPs with port 22 open are likely to be one of boards if you have separate the devices onto a subnet. Otherwise you can log into your router and from there you can determine via the hostnames of the devices on the network their related IPs.
The next step involves accessing the boards and configuring basic details such as usernames and passwords. The default login credentials for the boards are as follows: The adduser command can be used to create new users, the passwd command can be used to change the password for the current user, and the sudo passwd command can be used to change the root password. Additionally there is an Apache web server (httpd) instance pre-bundled in the Debian image you may like to disable or uninstall altogether from the board.

Software Installation

For this section I will outline the basic software used to create a private Blockchain which utilises off-chain storage for a more scalable data storage solution. The Ethereum platform will be used as the basis of our Blockchain due to it having the ability of smart contracts, its open source foundations, and large community. Furthermore I chose to use the Geth (Golang ETHereum) Ethereum client in order to interact with our private Ethereum network. I will mention that there are many other Ethereum clients written in many languages such as C++, Python, Java etc. For the purposes of this tutorial I will be outlining how to install and configure the Geth client on each of the network peer devices. In relation to the off-chain storage solution, I will use IPFS distributed storage for this exact purpose. I believe IPFS is an amazing technology which I will certainly be addressing in a future post to give it the attention it rightly deserves but for now all you need to know is that it is suitable for our off-chain storage requirements. It is worth noting at this stage that both the Raspberry Pi Zero and Beaglebone Black are running on a single core ARMv6 (32-bit) architecture whereas the Raspberry Pi 3 Model B uses a quad core ARMv7 (64-bit) architecture and thus different packages are sometimes required. The Geth clent package can be downloaded from here and the IPFS client software can be downloaded here. Below is an example of the installation process: If these commands succeed you should see the help page for both Geth and IPFS respectively.

So this is the end of the first part of this multi part post. In the next post I will go into detail of how to initialise and configure the Geth and IPFS clients on the each of the devices. If you've made it this far, thank you for reading. I hope it was a little helpful in getting you started with establishing a private Ethereum based Blockchain network. Until next time!