The Do-It-Yourself 21 Bitcoin Computer - ODROID XU4 Edition

Posted by Tyler Pate

The Do-It-Yourself 21 Bitcoin Computer - ODROID XU4 Edition

Overview

21 enables users to create and sell services on the 21 Marketplace from any Linux or OSX based system. The ODROID XU4 single board computer is a powerful standalone computer for home users to host data and services for sale. This tutorial will guide you through the steps necessary to host 21 Marketplace apps from your own XU4.

We will download and flash the image to an SD card with an OSX or Linux host computer, assemble the board, boot the single board computer, configure the system, and then install 21.

Prerequisites

You will need the following items:

Number Item Price
1 ODROID XU4 $99.99
2 Class 10+ MicroSD Card (16GB+ recommended) $19.99
3 USB WiFi Dongle $9.95
4 HDMI Monitor
5 HDMI Cable
6 USB Keyboard & Mouse
7 MicroSD Card Reader
8 Enclosure
Total $129.93

You should have all of the items in this picture before continuing. Note, the power supply comes with the ODROID XU4, so it is signified with a 1 in the image below.

Complete Kit

Enclosures

You can print the STL file on your own printer. Alternatively, you can order the official enclosure or one of numerous after market enclosures available.

3d Printed 21 Enclosure

Building your DIY 21 Bitcoin Computer

Now that we have all the requirements ready, we can start to build our DIY 21 Bitcoin Computer.

Linux Image - OSX Host System

Let's get the operating system image and prepare it for flashing. We are using Ubuntu 15.10 Linux, provided by Hardkernel for the XU4. Open a terminal on your host OSX machine and run the following commands:

cd
wget http://odroid.in/ubuntu-15.10/ubuntu-15.10-mate-odroid-xu3-20160114.img.xz

# Verify file integrity
wget http://odroid.in/ubuntu-15.10/ubuntu-15.10-mate-odroid-xu3-20160114.img.xz.md5sum

# The output of the md5 operation and the cat operation
# should have the same md5 sum output. 
md5 ubuntu-15.10-mate-odroid-xu3-20160114.img.xz 
cat ubuntu-15.10-mate-odroid-xu3-20160114.img.xz.md5sum

# If the md5 command output matches the cat output, untar 
# ubuntu-15.10-mate-odroid-xu3-20160114.img.xz.
gunzip ubuntu-15.10/ubuntu-15.10-mate-odroid-xu3-20160114.img.xz

# Set the image file name variable for use in the flashing step.
IMAGE_NAME="ubuntu-15.10/ubuntu-15.10-mate-odroid-xu3-20160114.img"

Insert the SD card into the SD card reader and connect it to your host machine. We will identify the disk and unmount any mounted partitions.

diskutil list

Look for a SD Card. You can match the size output from diskutil list with the size of your SD Card. You will see output similar to the following image. Here, the disk we are looking for is disk3.

OSX diskutil output

Warning: later in this tutorial you will be overwriting all data on whatever device you choose, so it's absolutely critical that you choose the correct device. In the following code, fill in the number of the device you found using diskutil above:

# IMPORTANT: Replace the "#" with your disk number
DEVICE=/dev/disk#

Now, unmount any mounted SD card partitions.

# This command will unmount any mounted SD card partitions on your system.
test -b $DEVICE && sudo diskutil unmountDisk $DEVICE || echo "ERROR with ${DEVICE:-device}"

If you run the command above and it doesn't print any output, it was successful. If it prints an error message, please check to see that you followed the instructions above; if you did and it still prints an error, please send a copy of the error message to support@21.co so we can investigate.

Linux Image - Ubuntu Host System

Let's get the operating system image and prepare it for flashing. We are using Ubuntu 15.10 Linux, provided by Hardkernel for the XU4. Open a terminal on your host Ubuntu machine and run the following commands:

cd
wget http://odroid.in/ubuntu-15.10/ubuntu-15.10-mate-odroid-xu3-20160114.img.xz

# Verify file integrity
wget http://odroid.in/ubuntu-15.10/ubuntu-15.10-mate-odroid-xu3-20160114.img.xz.md5sum
md5sum -c <<< cat ubuntu-15.10-mate-odroid-xu3-20160114.img.xz.md5sum

# If the md5 command output matches the cat output, untar 
# ubuntu-15.10-mate-odroid-xu3-20160114.img.xz.
unxz ubuntu-15.10/ubuntu-15.10-mate-odroid-xu3-20160114.img.xz

# Set the image file name variable for use in the flashing step.
IMAGE_NAME="ubuntu-15.10/ubuntu-15.10-mate-odroid-xu3-20160114.img"

Insert the SD card into the SD card reader and connect it to your host machine. We will identify the disk and unmount any mounted partitions.

lsblk 

Look for a SD Card. You may see multiple partitions as /dev/mmcblk* or /dev/sd*. You will see output similar to the following. Here, the disk we are looking for is mmcblk0.

Ubuntu diskutil output

# Unmount any mounted SD card partitions on your system.
# Replace "mmcblk0p1" and "mmcblk0p2" with the partitions you found above
sudo umount /dev/mccblk0p1
sudo umount /dev/mccblk0p2

Warning: later in this tutorial you will be overwriting all data on whatever device you choose, so it's absolutely critical that you choose the correct device. In the following code, fill in the base name of the device you found using lsblk above:

# If you found a device starting with /dev/mmcblk you want to provide
#   everything up to and including the number that comes after "blk"
# For example, /dev/mmcblk0
# DO NOT add the parts starting with "p"
#
# If you found a device starting with /dev/sd you want to provide
#   everything up to and including the letter immediatly after the "sd"
# For example, /dev/sdc
# DO NOT add any numbers from the name
DEVICE=/dev/

The following command will ensure the device you chose exists:

test -b $DEVICE || echo "ERROR with ${DEVICE:-device}"

If you run the command above and it doesn't print any output, it was successful. If it prints an error message, please check to see that you followed the instructions above; if you did and it still prints an error, please send a copy of the error message to support@21.co so we can investigate.

Flashing your SD Card

Now, it is time to flash the image. First let's perform some checks to make sure we have the correct data.

# Verify IMAGE_NAME is set.  This should print out a name such as
# "ubuntu-15.10/ubuntu-15.10-mate-odroid-xu3-20160114.img"
echo $IMAGE_NAME

# Verify DEVICE is set.  This should print out a name such a /dev/disk3,
# /dev/mmcblk2, or /dev/sdc
echo $DEVICE

Flash the image:

DEV=${DEVICE/disk/rdisk} ; test -b $DEV && sudo dd if=$IMAGE_NAME of=$DEV || echo "ERROR writing $DEV"

Note: You will not see progress updates during the operation, until dd exits.

If you run the command above and it prints an error message, please check to see that you followed the instructions above; if you did and it still prints an error, please send a copy of the error message to support@21.co so we can investigate.

First boot

If you have an enclosure, go ahead and put your XU4 in the case.

Insert your flashed SD card, connect the HDMI cable, keyboard, mouse, and finally the power supply.

You should see several small graphics on the top of your screen and scrolling kernel messages. Then, a graphical desktop environment (GDE) will appear.

Log into the machine as the odroid user.

Now, open a terminal window to configure your installation. Enter keystroke Ctrl-Alt-F1 to open one of 6 terminals (F1-F6) from a GDE or terminal. To return to the GDE Desktop, hit Ctrl-Alt-F7.

Securing your system

Let's take a few basic security precautions for your system. Change the default and root user passwords:

# As odroid user
passwd
# enter old password: odroid
# enter new challenging password
# re-enter password

# As root user
sudo passwd
# enter odroid user password
# enter new challenging password
# re-enter password

Configuring internet access

Now, let's configure the wireless settings. We are going to use the graphical desktop environment to edit the wireless settings. Return to the GDE with Ctrl-Alt-F7. Now, click on the network connection icon in the upper menu bar.

Odroid Connectivity Screenshot

If you are using a wireless connection, enter your network details through the prompts. If you are wired ethernet, you should already be connected. You will see two arrows pointing up and down if you are already connected to wired LAN.

Verify your internet connectivity with a ping operation. Return to a terminal with Ctrl-Alt-F1, and enter:

ping google.com

You should see ping statistics returned if you are connected. Hit keystroke Ctrl-C to stop the ping process.

Expand the SD card file system

Now we are going to expand the SD card filesystem.

The default filesystem size is determined by the size of the image you burned earlier, which was around 4GB. If you burned this to a 128GB SD Card, there would be 124GB of unparitioned and unusable space. It's important to resize any flashed image in order to be able to use the full amount of free space.

Return to the GDE by entering Ctrl-Alt-F7, and double click on Odroid Utility on your desktop. The application will update itself when it starts. Once the update is complete, navigate to "Expand Filesystem" and confirm expansion of your filesystem by hitting enter.

Odroid Filesystem Expansion Image

Now, click on system in the upper menu bar, and click on "Shut Down." Choose to restart your system.

On reboot, the system will run resize2fs, which will expand your filesystem's image to fill the full size of your SD Card. When your system reboots and returns the Desktop, enter Ctrl-Alt-F1 again to open a terminal.

Updating your system

Now, let's update package sources and upgrade your packages to the latest versions. These two commands may take some time, and require internet connectivity.

# Respond yes to the prompts
sudo apt-get update
sudo apt-get -y upgrade

Linux Safe Shutdown

To keep the integrity of your filesystem, it is important to issue a shutdown or restart command before removing power from your RPi. Execute a safe shutdown or restart as needed with the following commands. Note, you do not need to run these commands now. They are included for your reference.

# Shutdown
sudo shutdown now

# Reboot
sudo reboot now

Installing 21

Now, install 21 by running the following command:

curl https://21.co | sh

Register for an account

Click here to register for an account. You will need to validate your email.

Log into your 21 account and run 21 status

21 login
# Enter your username & password

21 status

21 login

You should see output from the 21 status command.

21 status

21 sell

(available now on OSX; coming soon to other distributions)

On supported devices, install and publish bundled 21 apps with the 21 sell command.

21 sell start --all

This will join the 21market ZeroTier network, permitting network access to other machines running 21.

Verify your ping21 installation with the following:

curl -g -6 'http://[::1]/ping21'

You should see "Payment Required" in response to this command.

Developing your own applications

Congrats! If you have made it this far, you now have your own DIY 21 Bitcoin Computer! A standalone machine is perfect for running always-on applications like ping21 and others. Now it's time to develop your own applications!

The ODROID XU4 platform is a very powerful platform to develop advanced applications, like computer vision and video processing, audio analysis, sensor reading capture, and more. Here are a few links to get you started on your own projects.