Pages

Sunday, 8 June 2014

Raspberry Pi: Overclocking on Arch linux

Execute the following commands to overclock your Raspberry Pi on Arch linux:

  • Open the config file:

    sudo vim /boot/config.txt
    
  • Uncomment one of the following blocks:

    ...
    ##Modest
    #arm_freq=800
    #core_freq=300
    #sdram_freq=400
    #over_voltage=0
    
    ##Medium
    #arm_freq=900
    #core_freq=333
    #sdram_freq=450
    #over_voltage=2
    
    ##High
    #arm_freq=950
    #core_freq=450
    #sdram_freq=450
    #over_voltage=6
    
    ##Turbo
    #arm_freq=1000
    #core_freq=500
    #sdram_freq=500
    #over_voltage=6
    ...
    
  • Reboot

    sudo reboot
    

Raspberry Pi: changing the memory split on Arch linux

Changing the memory split between ARM and GPU on the Raspberry Pi running Arch linux is simple. Just execute the following commands:

  • Open the config file:

    sudo vim /boot/config.txt
    
  • Change the gpu_mem settings:
    • gpu_mem_256: GPU memory in megabyte for the 256 MB Raspberry Pi. (min:16 - max 192)
    • gpu_mem_512: GPU memory in megabyte for the 512 MB Raspberry Pi. (min 16 - max 448)
      ...
      gpu_mem_512=16
      gpu_mem_256=128
      ...
      
  • Reboot

    sudo reboot
    

Monday, 2 June 2014

Compile or install RethinkDB on the Cubietruck

Introduction

For one of the projects I’m currently working on, I needed a NoSQL database that could run on a simple ARM SBC. Until the Cubietruck crossed my path I never considered doing these kinds of things since most SBCs use SD cards as storage. Adding my precious data to an unreliable SD card is just not something I could live with :)

This all changed when I recently bought a Cubietruck, this device not only offers a lot more performance, it also offers the option to hook up a SATA drive. With the ability to have a NoSQL database on an ARM SBC, my next step was to choose which database to use.

MongoDB was my first choice since I’m very familiar with that one. There’s only one problem, MongoDB’s codebase seems to contain x86 specific code, so a MongoDB ARM version seems not something you could easily build.

My second choice was CouchDB. However, while searching for some extra info about it, I stumbled upon RethinkDB. A few articles later I decided to abandon my plans to use CouchDB and picked RethinkDB.

I haven’t regret my choice for a moment. The little help I needed in order to get the sources compiled, I easily got from the community. Both from their IRC channel as from their forum I immediately got the help I needed.

Install RethinkDB

In order to get this tutorial running I assume you’ve installed Ubuntu on the Cubietruck. You find an installation manual to Install Ubuntu on the Cubietruck here.

sudo apt-get install git g++ protobuf-compiler libprotobuf-dev libv8-dev libboost-dev curl build-essential nodejs npm

sudo vim /etc/fstab

Change the tmp storage to 128mb (the default of 20mb it too small for the compiler)

tmpfs            /tmp           tmpfs    size=128m 0       0

Get the sources and compile them

wget http://download.rethinkdb.com/dist/rethinkdb-latest.tgz
tar xvzf rethinkdb-latest.tgz
cd rethinkdb
./configure --without-tcmalloc --allow-fetch
make

if you get the following error:

gcc: error: unrecognized command line option "-m32"

change the following files:

  • ~/rethinkdb–1.12.5/external/v8_3.22.24.17/third_party/icu/source/aclocal.m4
    • CXXFLAGS=“${CXXFLAGS} -m32”, change to: CFLAGS=“${CFLAGS}”
    • CFLAGS=“${CFLAGS} -m32”, change to: CFLAGS=“${CFLAGS}”
  • ~/rethinkdb–1.12.5/external/v8_3.22.24.17/third_party/icu/source/configure:
    • CXXFLAGS=“${CXXFLAGS} -m32”, change to: CXXFLAGS=“${CXXFLAGS}”
    • CFLAGS=“${CFLAGS} -m32”, change to: CFLAGS=“${CFLAGS}”
  • ~/rethinkdb–1.12.5/external/v8_3.22.24.17/third_party/icu/icu.gyp:
    • ‘cflags’: [ ‘-m32’ ], change to: ‘cflags’: [ ’’ ]
    • ‘ldflags’: [ ‘-m32’ ], change to: ‘ldflags’: [ ’’ ]

For more info on this issue see also Yoeori/docs

The compiled archive is also available for download here.

Sunday, 1 June 2014

Cubietruck: Ubuntu SSD install and boot from disk

Installation

  • Get the ubuntu image (you can find a list of available images here)
    curl -O http://dl.cubieboard.org/software/a20-cubietruck/lubuntu/ct-lubuntu-nand-v1.02/lubuntu-server-nand-hdmi.img.gz
    
    gzip -d lubuntu-server-nand-hdmi.img.gz
    
  • Download and install LiveSuit
    http://docs.cubieboard.org/tutorials/common/livesuit_installation_guide
  • Run LiveSuit
    • Select the Ubuntu image
    • Connect to your Cubietruck in FEL mode:
      1. Press FEL key and while holding it
      2. Plug in mini usb cable, and wait the following prompt
      3. Release FEL key
      4. When seeing the prompt, you have enter FEL mode. Select Yes to continue
  • you can login (via ssh) with username/password linaro/linaro

Move Rootfs to SSD

Prepare the drive for rootfs

Login as root
  • list all available drives
    fdisk -l
    
  • Choose the drive you want to make changes to (e.g. sda):
    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

We assume that, /dev/sda is the hard drive we want to install
mkdir /tmp/1 /tmp/target
mount /dev/nandb /tmp/1
mount /dev/sda1 /tmp/target
(cd /tmp/1; tar --backup -c *) |tar -C /tmp/target -xv
  • Changing kernel parameters in order to boot from the SSD drive
    mkdir /tmp/boot
    mount /dev/nanda /tmp/boot
    pico /tmp/boot/uEnv.txt
    
    Change the last line to:
    root=/dev/sda1
    
  • Sync to disk, and reboot to your hard drive
    sync
    reboot 
    

Optional post install

  • Remove MySQL
    sudo apt-get remove --purge mysql-server mysql-client mysql-common
    sudo apt-get autoremove
    sudo apt-get autoclean
    
  • Install extra packages
    sudo apt-get install vim htop
    
  • Upgrade Ubuntu Server
    sudo apt-get install python-apt
    sudo do-release-upgrade
    
  • Enable local discover services
    sudo apt-get install avahi-daemon
    sudo apt-get install libnss-mdns
    
    sudo pico /etc/nsswitch.conf
    
    Add mdns to the end of the following line:
    hosts:      files mdns4_minimal [NOTFOUND=return] dns mdns4 mdns
    
    sudo /etc/init.d/avahi-daemon restart
    
  • Add a user
    sudo useradd -d /home/newuser -m newuser
    usermod -s /bin/bash newuser
    sudo passwd newuser
    
    visudo 
    
    Add the following line (second one just underneath the first one)
    root    ALL=(ALL:ALL) ALL
    newuser ALL=(ALL:ALL) ALL
    
  • Enable color prompt
    https://help.ubuntu.com/community/CustomizingBashPrompt
  • Set the correct time
    • Find your time zone
      ls /usr/share/zoneinfo
      
      Ex.: “Europe/Brussels”
    • Remove your old timezone link.
      rm /etc/localtime
      
    • Create a symlink to the appropriate timezone information.
      ln -s /usr/share/zoneinfo/Europe/Brussels /etc/localtime
      
    • Second option
      pico /etc/timezone. 
      
      Replace the old timezone by yours. Ex. “Europe/Brussels"
    • Sync your local clock
      sudo apt-get install ntp
      
    • Test your setup
      date