Saturday, 16 August 2014

Cooking with Chef: Create private and pubic subnet EC2 instances in a VPC with Knife

In order to access your AWS instance in a VPC private subnet you need a bastion host ( NAT instance). The setup of a bastion is quite easy as described here.

One important remark: don’t forget to add an outbound (egress) rule to the NAT security group (NATSG) to allow SSH traffic.

As soon as you have your bastion in place you probably want to create or bootstrap new instances in your private subnet. Knife gives you the possibility to create EC2 instances in both private and public subnets, you only have to specify the right options to the knife command.


Create an instance in a private subnet

knife ec2 server create --flavor t2.micro --image ami-d44193a3  \
--security-group-ids sg-abcd1234 --tags Name=instance-name      \
--node-name instance-name  --environment staging                \
--region eu-west-1 --availability-zone eu-west-1a               \
--subnet subnet-1122aabb --ssh-gateway ec2-user@1.2.3.4         \
--server-connect-attribute private_ip_address                   \
--ssh-user ubuntu --ssh-key staging-key                         \
--run-list 'role[nosql]' --ebs-size 24                          \
--ebs-volume-type gp2
  • ssh-key staging-key: the key pair to access you bastion host
  • ssh-gateway ec2-user@1.2.3.4: refers to your bastion host
  • server-connect-attribute private_ip_address: tell knife to access your newly created instance on its private ip through your bastion host.
Remark: this only works if you add the private key (here staging-key) to your authentication agent! Specifying it as identity_file (-i option) does NOT work!
ssh-add staging-key.pem  

SSH access to an instance in a private subnet.

In order to access your instance in a private subnet you need to tunnel your connection. Edit your .ssh/config and add the following lines:
Host sbastion
    HostName 1.2.3.4
    User ec2-user
    StrictHostKeyChecking no
    UserKnownHostsFile /dev/null
    IdentityFile ~/.ssh/staging-key.pem
    LogLevel quiet

Host 10.0.0.*
    User ubuntu
    StrictHostKeyChecking no
    UserKnownHostsFile /dev/null
    IdentityFile ~/.ssh/staging-key.pem
    ProxyCommand ssh -W %h:%p sbastion
    LogLevel quiet
This config allows you to access any instance in your private subnet (10.0.0.*) via a simple command.
Here’s an example:
ssh 10.0.0.23

Create an instance in a public subnet

You have two options to create an instance in a public subnet:
  • Associate the instance with an Elastic ip (here: 55.77.1.1)
    knife ec2 server create --flavor t2.micro --image ami-fd6cbd8a  \
    --security-group-ids sg-abcd1234 --tags Name=instance-name      \
    --node-name instance-name --environment staging                 \
    --region eu-west-1 --availability-zone eu-west-1a               \
    --subnet subnet-2233ccdd --associate-eip 55.77.1.1              \
    --server-connect-attribute public_ip_address                    \
    --run-list 'role[webserver]' --ebs-size 24                      \
    --ebs-volume-type gp2 -x ubuntu -S GP-Staging  
    
  • Associate the instance with a public ip:
    knife ec2 server create --flavor t2.micro --image ami-fd6cbd8a \
    --security-group-ids sg-abcd1234 --tags Name=instance          \
    --node-name instance-name --environment staging                \
    --region eu-west-1 --availability-zone eu-west-1a              \
    --subnet subnet-2233ccdd --associate-public-ip                 \
    --server-connect-attribute public_ip_address                   \
    --run-list 'role[webserver]' --ebs-size 24                     \
    --ebs-volume-type gp2 -x ubuntu -S GP-Staging   
    



Happy cooking!

Monday, 11 August 2014

Banana Pi: Boot your rootfs from SATA

Because the Banana Pi comes with a SATA connector it gives you the possibility to hook up an SSD or other hard drive. Besides it even provides a 5V power connector allowing you to power an SDD right from the board. Just be cautious with the power connector’s polarity, I had to switch the wires of my SATA power cable to get things right!


Move the rootfs to a SATA Drive

Currently it’s impossible to boot from a SATA drive without a SD card. You will still need a small SD card for the bootloader. However, it is possible to adjust the bootscript (which is similar to a bootloader) on the SD card so that it points directly to your SATA drive. This way your system will boot the OS right from the SATA drive.

Here’s what you have to do:

Note: all this commands require root privileges.
  1. Connect your SSD (of course :-) )
  2. run fdisk -l and identify your SATA drive. In this example /dev/sda represents the SSD disk.
  3. Prepare your disk
    > fdisk /dev/sda
    
    Delete all partitions using the “d” option
    Create a new primary partition using the “n” option (you can accept all the defaults)
    Use the “w” option the apply the changes.
    Format the partition for rootfs with EXT4 filesystem
    > mkfs.ext4 /dev/sda1
    

Copying Rootfs

I still assume that /dev/sda represent the SATA drive
> mkdir /tmp/1 /tmp/target
> mount /dev/mmcblk0p2 /tmp/1
> mount /dev/sda1 /tmp/target
> (cd /tmp/1; tar --backup -c *) |tar -C /tmp/target -xv
Change the kernel parameters in order to boot from the SSD drive
> mkdir /tmp/boot
> mount /dev/mmcblk0p1 /tmp/boot
> vim /tmp/boot/uEnv.txt
Change the last line to:
.. root=/dev/sda1 ...
Sync to disk and reboot to your hard drive
> sync
> reboot 
You can test the result with: df -h

Saturday, 9 August 2014

HummingBoard GPIO

GPIO Header Pinout

GPIO Layout

Pin
Signal
Pin
Signal
1
3.3V
2
5V
3
I2C_SDA
4
5V
5
I2C_SCL
6
GND
7
GPIO 1
8
UART TX
9
GND
10
UART RX
11
GPIO 73
12
GPIO 72
13
GPIO 71
14
GND
15
GPIO 10
16
GPIO 194*
17
3.3V
18
GPIO 195*
19
SPI_MOSI
20
GND
21
SPI_MISO
22
GPIO 67
23
SPI_SCLK
24
ECSPI2_SS0
25
GND
26
ECSPI2_SS1

* Pins 16 and 18 are actually SD3_CMD and SD3_CLK signals that can be muxed to support flex can TX/RX interface (i.e. those can be connected to an external CAN) 

Note: SPI and I2C can also be muxed to be GPIO

Accessing GPIO from Linux userspace

The external GPIOs are available under the /sys/class/gpio folder in Linux.

Get the current list of reserved GPIO

> mount -t debugfs none /sys/kernel/debug
> cat /sys/kernel/debug/gpio

Reserve/free a GPIO pin

> echo XX > /sys/class/gpio/export
> echo XX > /sys/class/gpio/unexport

Set GPIO pin Direction

> echo in > /sys/class/gpio/gpioXX/direction
> echo out > /sys/class/gpio/gpioXX/direction

Set the value of an output pin

> echo 1 > /sys/class/gpio/gpioXX/value
> echo 0 > /sys/class/gpio/gpioXX/value

Get the value of an input pin

> cat > /sys/class/gpio/gpioXX/value

Wednesday, 6 August 2014

HummingBoard Benchmarks: Raspberry Pi vs HummingBoard vs Banana Pi

Today I benchmarked another competitor of the Raspberry Pi, the HummingBoard. This board is available in three different flavours: HummingBoard-i1, HummingBoard-i2 and HummingBoard-i2eX. The last one (i2ex edition) is the most powerful and expensive one, it’s also the one I used for my tests.

As you can see in the test results below the HummingBoard performs way better than the Raspberry Pi. It also outperforms the Banana Pi quite nicely.

Currently, the only downside of the HummingBoard is its price. For a Raspberry Pi you pay only $35, for the Banana Pi you pay around $50. The price for a HummingBoard i2eX is $99.99.

Note: for the tests I used an up-to-date version of Debian Jessie.












The full report is available here.

Monday, 28 July 2014

UDOO Quad VS Raspberry PI VS Banana PI: Benchmark comparison

I just finished benchmarking the UDOO Quad (running Linaro Ubuntu 12.04). It’s the first quad core ARM SBC I benchmarked and as expected it performs quite nice compared to its single and dual core rivals. It comes with a little price, power consumption. During the tests the board was hooked up to a power supply feeding it 13V DC, at peak levels the board needed more then 700 mA, I can tell you, without a fan the heat sink becomes quite hot…

In the meantime I also got a confirmation that my Hummingboard is on its way, I’m really curious to see how that one will perform compared to the Raspberry and Banana Pi… to be continued

The complete benchmark details are available here.











Saturday, 26 July 2014

Best alternatives to the Raspberry Pi

For a lot of people the Raspberry Pi opened the door to a cheap but quite powerful Single Board Computer (SBC). Its success also revealed that there’s a huge market for these kind of devices. The result (as everybody knows): wherever there’s success, there’re competitors.

As some interesting alternatives where launched recently and because the list of competitors keeps growing, I decided to pick the four alternatives I currently like the most.

Before sharing this list, I want to point out that this not exact science. As many other comparisons have already point out, every board has its own strengths and weaknesses and the best choice will largely depend on the project build around the board. A second big differentiator is of course the price. These boards go from $50 to $116.99. With these things in mind, here are my favourite competitors for the Raspberry Pi.


CubieTruck





http://cubieboard.org/tag/cubietruck/
Price: $99

Highlight

Easy to hook up a 2,5“ SATA drive without the need of an extra power supply. Comes with a nice enclosure out of the box (with mount possibilities and cables to hook up a 2,5” drive)

Main benefits over the RPI:

  • Storage reliability: possibility to store your data on a hard disk drive instead of on a SD card.
  • Performance:
    • Dual core CPU gives extra processing power
    • SSD drive boost you IO operations
  • IO:
    • Gigabit Ethernet
    • Onboard Bluetooth

Board specs:

  • AllWinner A20 SoC (dual-core ARM Cortex-A7 @ 1 GHz CPU, with Mali–400MP2 GPU).
  • 2 GiB DDR3 @ 480 MHz
  • 8 GB NAND flash built-in, 1x microSD slot, 1x SATA 2.0 port.
  • HDMI 1080p output
  • 10/100/1000 RTL8211E Ethernet connector
  • 2x USB Host, 1x USB OTG, 1x CIR.
  • S/PDIF, headphone and HDMI audio out, mic and line-in via extended pins
  • Wi-Fi and Bluetooth on board with PCB antenna (Broadcom BCM4329/BCM40181)
  • 54 extended pins including I²C, SPI

BeagleBone Black (Rev C)




http://beagleboard.org/black
Price: $55

Highlight

If it comes to power per dollar then the BeagleBone Black is king.

Main benefits over the RPI:

  • Performance:
    • 1GHz ARM Cortex-A8
  • Storage:
    • 4GB on-board flash memory
  • IO:
    • 2x 46 pin headers

Board specs:

  • AM335x 1GHz ARM® Cortex-A8
  • 512MB DDR3 RAM
  • 4GB 8-bit eMMC on-board flash storage
  • 3D graphics accelerator
  • NEON floating-point accelerator
  • 2x PRU 32-bit microcontrollers
  • USB
  • USB host
  • Ethernet
  • HDMI
  • 2x 46 pin headers

Banana Pi




http://www.bananapi.org/
Price: $50

Highlight

Raspberry Pi compatible layout: Banana Pi is a fork of the Raspberry Pi project using different components while maintaining compatibility as much as possible.
The main SoC chip is different. Raspberry Pi has a Broadcom ARM11 core chip while Banana Pi has Allwinner ARM Cortex-A7 dual cores. The ARM architecture is the major differences. Banana Pi has more features enabling by ARM v7 architecture and still be compatible to run applications on ARMv6. The physical dimension of Banana Pi is wider than Raspberry.

Main benefits over the RPI:

  • Performance:
    • ARM Cortex-A7 dual-core CPU
    • 1GiB DDR3 SDRAM
  • IO:
    • Gigabit Ethernet
    • On-board microphone,
    • SATA connector
    • IR receiver
    • OTG connector

Board specs:

  • Allwinner A20 SoC (Cortex-A7 dual-core CPU, with Mali–400MP2 GPU).
  • 1GiB DDR3 SDRAM
  • SD slot (maximum 64GB),
  • 7-pin SATA data port (with a separate power connector), supporting maximum 1 TB hard drive.
  • HDMI 1080p/CVBS output.
  • 10/100/1000 Ethernet connector.
  • 2x USB Host, 1x USB OTG, 1x CSI camera connector.
  • 26 extended pins including I²C, SPI, UART, CAN bus
  • Power and Reset switches mounted on board.
  • Onboard IR receiver
  • Microphone-In
  • Ø3.5mm Audio Jack
  • Expects 5V/2A source to microUSB connector.
  • Dimensions: 9.2cm × 6cm; (The board size of Banana Pi is similar to Raspberry Pi)

HummingBoard




http://www.solid-run.com/products/hummingboard/
Price: $44.99 - $116.99

Highlight

Another contender for the Raspberry Pi is the HummingBoard, it packs a nice amount of power and connectivity into the same size and shape as the Raspberry Pi. Just released and available in 3 flavours.

Main benefits over the RPI:

  • Performance:
    • ARM Cortex-A9 dual-core CPU
    • 1GiB DDR3 SDRAM
  • IO:
    • Gigabit Ethernet
    • On-board microphone,
    • mSATA connector
    • IR receiver
    • PCI-Express

Board specs (i2eX)

  • Freescale i.MX6 Dual
  • 1GB SDRAM
  • GPU GC2000
  • OOpenGL ES1.1,2.0 Quad Shader
  • Multi format video decoder and encoder
  • HDMI 1080p with CEC 1.4, 3D support
  • LVDS Display Out
  • MIPI 2 Lane CSI–2
  • Wired Network 10/100/1000
  • PCI-Express Gen 2
  • mSATA II
  • 2 USB 2.0 Ports
  • UHS–1 Micro SD interface
  • RTC with backup battery
  • Coax SPDIF audio out
  • Audio Out Stereo out and MIC In
  • Infra Red Remote Control Receive
  • GPIO header UART, 8 GPIO, SPI with 2 CS, I2C

Friday, 25 July 2014

Raspberry Pi B+ VS Raspberry PI B: benchmark comparison

Although the new Raspberry PI has almost the same hardware under the hood, I just couldn’t resist to compare it with its predecessor on the test bench.

As expected, the outcome of the tests doesn’t show a performance difference between the old and the new version…. but although there is no difference in performance, power consumption is another story. During benchmarking, the Pi’s were connected to a bench top power supply to monitor their power consumption. This is the result.





The full benchmark report can be found here.

Monday, 14 July 2014

Cubietruck Benchmarks (with and without SSD): Cubietruck VS Raspberry Pi VS Banana Pi VS BeagleBone Black

I just benchmarked another board: the Cubietruck. It’s one of my favourite boards because you can easily hook up an SSD to it. To see if that makes any difference in performance, I ran all test with and without an SSD attached. Here are the results:














Full Phoronix test is available here.



Wednesday, 9 July 2014

BeagleBone Black (rev B) benchmarks: BeagleBone VS Raspberry Pi VS Banana Pi

Since I was running some benchmarks anyway I decided to add some extra competitors to the list. The first one I added is the BeagleBone Black revision B. The next boards on my list are:
  • Cubietruck
  • Wandboard (Quad) 
  • Radxa
  • UDOO Board
  • HummingBoard (ordered)
  • Cubieboard 8 (not yet available for ordering) 
You can expect some benchmark results for these boards in the next couple of weeks. Here are the latest results for the BeagleBone Black.

The Black was running Ubuntu 14.04