Monday 11 November 2013

Running Ubuntu off USB hard drive on Beaglebone Black

This is how i setup the BBB to run of a USB hard drive (i hate it when the SD-card is killed).

I got my inspiration from The Raspberry Pi Hobbyist and The EmbeddedHobbyist
The first is obviously not for BBB (but Linux is Linux) and the second one didn't really make any sense to me =)

First flash the BBB with Ubuntu using the instruction found on Circuitco homepage.
But unfortunately the direct link to the image is broken, this is the image i used: BBB-eMMC-flasher-ubu...

When flashing is done, remove SD-card and reboot the BBB

After that i logged on to the BBB and became root (username: ubuntu password: temppwd):
#sudo su (bad practice, i know but I'm lazy)

Next partition the hard drive (make sure you know what you're doing here)
#fdisk /dev/sda

Delete any old partitions using d.

Create new partitions with n

I made 3 partitions, 1 for the OS (20 GB), 1 swap (2 GB) and 1 for data (whatever left), in fdisk it looked like this:

OS Partition:
  n                   (new)
  p                   (primary)
  <enter>        (first available)
  <enter>        (start from first available sector)
  +20G           (make the size 20GB)
  a                  (toggle bootable flag)
  1                  (partition 1)

Swap partition:
  n                   (new)
  p                   (primary)
  <enter>        (first available)
  <enter>        (start from first available sector)
  +2G             (make the size 2GB)
  t                   (change partition type)
  2                  (partition 2)
  82                (Linux swap)

Data partition
  n                   (new)
  p                   (primary)
  <enter>        (first available)
  <enter>        (start from first available sector)
  <enter>        (last sector available)

Now were almost done, use p to list the new partition table and it should look something like this:
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048    41945087    20971520   83  Linux
/dev/sda2        41945088    46139391     2097152   82  Linux swap / Solaris

/dev/sda3        46139392   312581807   133221208   83  Linux

Exit fdisk saving the changes by pressing w and enter.

Next prepare the swap partition:
#mkswap /dev/sda2

Format the data partition:
#mkfs.ext4 /dev/sda3

Copy the rootfs from eMMC to the first partition (assuming /dev/mmvblk0p2 is your current root, you can check this by using the mount command):
#dd if=/dev/mmcblk0p2 of=/dev/sda1 bs=32M conv=noerror,sync

After dd is complete, check the filesystem (-f for force check and -y for yes to all questions):
#e2fschck -fy /dev/sda1

Next, resize the filesystem to match the partition:
#resize2fs /dev/sda1

Now its time to make some changes to our rootfs to be, start with mounting /dev/sda1:
#mount /dev/sda1 /mnt

Copy the kernel, uboot etc to the hard drive:
#cp -pvrf /boot/* /mnt/boot

And at last, change the uEnv.txt om the eMMC (not the hard drive)
#nano /boot/uboot/uEnv.txt

Find the line looking like this:
mmcroot=UUID=9363f4b4-869d-48ae-861e-80b18fc1a734 ro
Change it to look like this:
mmcroot=/dev/sda1 ro

Save and quit nano.
Make sure everything is saved:

Reboot and hold thumbs =)

If the system boots correctly, log in and make sure were running from hdd:

Look for the line:
/dev/sda1 on / type ext4 (rw)

Tuesday 19 March 2013

Lighttpd and PHP on the BeagleBone

First of all, i originally found this information here and here, but the site seems down right now so i decided to put the information here aswell (with some modifications).

First of all i disable the web services:

systemctl disable cloud9.service
systemctl disable bone101.service
systemctl disable gateone.service

Then i install the required php packages:

opkg install php php-cgi php-cli
opkg install lighttpd lighttpd-module-fastcgi

Edit the lighttpd config file located at /etc/lighttpd.conf to enable fast-cgi:
Locate the server.modues line and uncomment mod_fastcgi:

Then further down the file is the fastcgi.server configuration, uncomment the lines to look something like this:

Make sure the path for php-cgi is correct!
Save the file and restart the lighted server:
/etc/init.d/lighttpd restart

Now, lets try if it works.
Create a new php file in /www/pages called index.php:

Finally, point your browser to the adress of your beaglebone and the PHP info page should show.

Thursday 14 March 2013

Neorouter on the Beaglebone

I wanted to install the neorouter client on one of my Beaglebone devices running the stock Angstrom image.

This was kind of easy after some trial and error.

First i went to the Neorouter download page, scrolled down to the Raspbian version and used wget to download the free "wheezy" version of the client to the /tmp directory of the Beaglebone.
Then you unpack the .deb package:
ar x <packagename>

Next you unpack the tar.gz file:
tar xvz < data.tar.gz

Next you move the files located in the /tmp/usr/bin directory to the /usr/bin

Then you create a file named neorouter.service in the /lib/systemd/system directory which contains the following:

Next you execute the command:
systemctl enable neorouter.service

This will make the client start at boot.
After that you can either reboot the Beaglebone or issue the command:
systemctl start neorouter.service

Last thing to do is configure the client by running:

and fill out the required parameters, then a list of computers connected to you neorouter network should display.
You exit the nrclientcmd by typing "quit".

All done

Sunday 26 August 2012

Runninglights on the Arduino

This is a small project i created to try the Arduinos analog and digital input aswell as controlling the outputs.
This is also my first attempt at trying to debounce a switch and to make it pause and start the running lights.

It worked out quite well =)

What i used for this project was (beside the Arduino):

  • 9 LED's 
  • 9 330ohms resistors (R1-R9)
  • 1 10Kohms pull-up resistor (R10)
  • 1 10Kohms pot (P1)
  • 1 Switch (K1)
Other legends for the wire diagram beside the above:
  • DP - Arduino digital pin (DP4 = pin 4 on Arduino)
  • A0 - Arduino analog pin 0
  • V5 - 5v pin
  • GND - Arduino ground pin

The wire diagram

The code: