livebox:beagleboneporting

Beagle bone notes

Notes on porting the HAH for the beagle bone. These notes really aren't for consumption by anybody but me as reminders for things I did whilst playing around on the Beagle Bone.

The Angstrom distribution was just too warty for my liking and I moved everything to UBUNTU which also allows the Raspberry PI and other embedded boards to also join the fun.

Mounting NFS to get back to the BB development x86 box where the cross compiling happens.

busybox mount -t nfs -o nolock,soft,timeo=5,retry=5 bb-dev:/home/brett /home/brett

Setting up /usr/local where the xAP distribution is compiled and setup pointing to our NFS development box.

ln -s /home/brett/svn/trunk/targets/bb.src /usr/local
root@beaglebone:/usr# ls -l /usr
total 116
drwxr-xr-x  3 root root  4096 Sep 11  2012 arm-angstrom-linux-gnueabi
drwxr-xr-x  8 root root 32768 Jan 11  2000 bin
drwxr-xr-x  3 root root  4096 Sep 11  2012 etc
drwxr-xr-x  2 root root  4096 Aug 26  2012 games
drwxr-xr-x 96 root root 12288 Sep 11  2012 include
drwxr-xr-x 66 root root 40960 Jan 11  2000 lib
drwxr-xr-x 11 root root  4096 Jan 11  2000 libexec
lrwxrwxrwx  1 root root    36 Jan 23 09:40 local -> /home/brett/svn/trunk/targets/bb.src
drwxr-xr-x  2 root root  4096 Jan 11  2000 sbin
drwxr-xr-x 99 root root  4096 Apr 19  2012 share
drwxr-xr-x  3 root root  4096 Sep 11  2012 src

Append/Create a library search path, and rebuild the link cache.

echo "/usr/local/lib" >>/etc/ld.so.conf
ldconfig

Fire something up to test this is working.

root@beaglebone:/usr/local/usr/bin# ./xap-hub --help
xAP HUB
Copyright (C) DBzoo, 2008-2010

./xap-hub: [options]
  -i, --interface IF     Default eth0
  -d, --debug            0-7
  -h, --help

COOL - now we can build/run/debug on x86 and have everything available on the BB.

Lets check out LUA.

root@beaglebone:/usr/local/usr/bin# ./lua
Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
"TERMCAP", line 20, col 1, terminal 'SC': Missing separator
> require "pl"
stdin:1: module 'pl' not found:
        no field package.preload['pl']
        no file './pl.lua'
        no file '/usr/share/lua/5.1/pl.lua'
        no file '/usr/share/lua/5.1/pl/init.lua'
        no file '/usr/lib/lua/5.1/pl.lua'
        no file '/usr/lib/lua/5.1/pl/init.lua'
        no file './pl.so'
        no file '/usr/lib/lua/5.1/pl.so'
        no file '/usr/lib/lua/5.1/loadall.so'
stack traceback:
        [C]: in function 'require'
        stdin:1: in main chunk
        [C]: ?

Its going to look in these paths by default and not/usr/local/usr/share/…

We can workaround that with a small shell script wrapper

# Use for local running
# Once on the HAH the paths will all be fine.
LOCAL=/usr/local/usr
export LUA_CPATH="$LOCAL/lib/lua/5.1/?.so;$LOCAL/lib/lua/5.1/?/core.so"
export LUA_PATH="?.lua;luaxap/?.lua;$LOCAL/share/lua/5.1/?.lua;$LOCAL/share/lua/5.1/?/init.lua;$LOCAL/share/lua/5.1/?/?.lua"
export LD_LIBRARY_PATH=$LOCAL/lib:/usr/local/lib
export _PROMPT2="2>"
$LOCAL/bin/lua $*

Launching with our wrapper.

root@beaglebone:/usr/local# ~/lua.sh
Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
"TERMCAP", line 20, col 1, terminal 'SC': Missing separator
> require "socket"
> require "pl"
>

First get an ipkg to play with.

wget http://feeds.angstrom-distribution.org/feeds/v2012.05/ipk/eglibc/armv7a/base/busybox_1.19.4-r6_armv7a.ipk

What does the file magic say about it.

[brett@bb-dev ~]$ file busybox_1.19.4-r6_armv7a.ipk
busybox_1.19.4-r6_armv7a.ipk: Debian binary package (format 2.0)

That means its just an 'ar' file format file.

[brett@bb-dev ~]$ ar tv busybox_1.19.4-r6_armv7a.ipk
rw-r--r-- 0/0      4 Apr 28 06:02 2012 debian-binary
rw-r--r-- 0/0 287119 Apr 28 06:02 2012 data.tar.gz
rw-r--r-- 0/0   1602 Apr 28 06:02 2012 control.tar.gz

Note the USER and GROUP are both set to 0 (root/root)

Using the opkg-utils we can unpack this file. I suspect doing this as a non-root user is going to munge permissions.

[brett@bb-dev ~]$ ./opkg-utils/opkg-unbuild busybox_1.19.4-r6_armv7a.ipk

This will create

[brett@bb-dev ~]$ tree -A busybox_1.19.4-r6_armv7a
busybox_1.19.4-r6_armv7a
├── bin
│   ├── busybox
│   └── sh -> busybox
├── CONTROL
│   ├── control
│   ├── postinst
│   └── prerm
└── etc
    ├── busybox.links
    ├── default
    │   └── busybox-syslog
    └── init.d
        └── hwclock.sh

5 directories, 8 files

And forward engineering to turn this directory structure back into an .ipk

[brett@bb-dev ~]$ ./opkg-utils/opkg-build busybox_1.19.4-r6_armv7a /tmp
*** Warning: The following files have a UID greater than 99.
You probably want to chown these to a system user:
drwxr-xr-x. 5 brett brett   4096 Jan 23 21:35 .
drwxr-xr-x. 2 brett brett   4096 Apr 28  2012 ./bin
-rwxr-xr-x. 1 brett brett 519160 Apr 28  2012 ./bin/busybox
lrwxrwxrwx. 1 brett brett      7 Jan 23 21:35 ./bin/sh -> busybox
drwxr-xr-x. 2 brett brett   4096 Apr 28  2012 ./CONTROL
-rw-r--r--. 1 brett brett   1649 Apr 28  2012 ./CONTROL/control
-rwxr-xr-x. 1 brett brett    834 Apr 28  2012 ./CONTROL/postinst
-rwxr-xr-x. 1 brett brett   1001 Apr 28  2012 ./CONTROL/prerm
drwxr-xr-x. 4 brett brett   4096 Apr 28  2012 ./etc
-rw-r--r--. 1 brett brett   2113 Apr 28  2012 ./etc/busybox.links
drwxr-xr-x. 2 brett brett   4096 Apr 28  2012 ./etc/default
-rw-r--r--. 1 brett brett     15 Apr 28  2012 ./etc/default/busybox-syslog
drwxr-xr-x. 2 brett brett   4096 Apr 28  2012 ./etc/init.d
-rwxr-xr-x. 1 brett brett   2445 Apr 28  2012 ./etc/init.d/hwclock.sh

Packaged contents of busybox_1.19.4-r6_armv7a into /tmp/busybox_1.19.4-r6_armv7a.ipk

There is going to be a requirement here that the packages are built as root or at least their permissions and ownerships are setup by root prior to building.

Setting up a development package feed

root@beaglebone:/etc/opkg# cat hah.conf
src/gz hah http://bb-dev.local/feeds/eglibc/ipkg/armv7a/hah

Setup feed location on bb-dev

# mkdir -p /var/www/html/feeds/eglibc/ipkg/armv7a/hah

Place the HAH package in the directory and build the Package files.

[root@bb-dev hah]# pwd
/var/www/html/feeds/eglibc/ipkg/armv7a/hah
[root@bb-dev hah]# /home/brett/opkg-utils/opkg-make-index -p Packages -m .
/home/brett/opkg-utils/opkg.py:39: DeprecationWarning: the md5 module is deprecated; use hashlib instead
  import md5
Lost field license, GPLv2+

[root@bb-dev hah]# ls -l
total 1328
-rw-r--r--. 1 root root 1334146 Jan 24 19:59 hah_0.1_armv7a.ipk
-rw-r--r--. 1 root root     447 Jan 24 20:02 Packages
-rw-r--r--. 1 root root    8233 Jan 24 20:02 Packages.filelist
-rw-r--r--. 1 root root     332 Jan 24 20:02 Packages.gz
-rw-r--r--. 1 root root      30 Jan 24 20:02 Packages.stamps
[root@bb-dev hah]#

Update the package caches on the BB - yes mine is in there now (look hard).

root@beaglebone:/etc/opkg# opkg update
Downloading http://feeds.angstrom-distribution.org/feeds/v2012.05/ipk/eglibc/armv7a/base/Packages.gz.
Inflating http://feeds.angstrom-distribution.org/feeds/v2012.05/ipk/eglibc/armv7a/base/Packages.gz.
Updated list of available packages in /var/lib/opkg/lists/base.
Downloading http://feeds.angstrom-distribution.org/feeds/v2012.05/ipk/eglibc/armv7a/machine/beaglebone/Packages.gz.
Inflating http://feeds.angstrom-distribution.org/feeds/v2012.05/ipk/eglibc/armv7a/machine/beaglebone/Packages.gz.
Updated list of available packages in /var/lib/opkg/lists/beaglebone.
Downloading http://feeds.angstrom-distribution.org/feeds/v2012.05/ipk/eglibc/armv7a/debug/Packages.gz.
Inflating http://feeds.angstrom-distribution.org/feeds/v2012.05/ipk/eglibc/armv7a/debug/Packages.gz.
Updated list of available packages in /var/lib/opkg/lists/debug.
Downloading http://feeds.angstrom-distribution.org/feeds/v2012.05/ipk/eglibc/armv7a/gstreamer/Packages.gz.
Inflating http://feeds.angstrom-distribution.org/feeds/v2012.05/ipk/eglibc/armv7a/gstreamer/Packages.gz.
Updated list of available packages in /var/lib/opkg/lists/gstreamer.
Downloading http://bb-dev.local/feeds/eglibc/ipkg/armv7a/hah/Packages.gz.
Inflating http://bb-dev.local/feeds/eglibc/ipkg/armv7a/hah/Packages.gz.
Updated list of available packages in /var/lib/opkg/lists/hah.
Downloading http://feeds.angstrom-distribution.org/feeds/v2012.05/ipk/eglibc/all/Packages.gz.
Inflating http://feeds.angstrom-distribution.org/feeds/v2012.05/ipk/eglibc/all/Packages.gz.
Updated list of available packages in /var/lib/opkg/lists/no-arch.
Downloading http://feeds.angstrom-distribution.org/feeds/v2012.05/ipk/eglibc/armv7a/perl/Packages.gz.
Inflating http://feeds.angstrom-distribution.org/feeds/v2012.05/ipk/eglibc/armv7a/perl/Packages.gz.
Updated list of available packages in /var/lib/opkg/lists/perl.
Downloading http://feeds.angstrom-distribution.org/feeds/v2012.05/ipk/eglibc/armv7a/python/Packages.gz.
Inflating http://feeds.angstrom-distribution.org/feeds/v2012.05/ipk/eglibc/armv7a/python/Packages.gz.
Updated list of available packages in /var/lib/opkg/lists/python.
root@beaglebone:/etc/opkg#

Installing the HAH package

root@beaglebone:/etc/opkg# opkg install hah
Installing hah (0.1) to root...
Downloading http://bb-dev.local/feeds/eglibc/ipkg/armv7a/hah/hah_0.1_armv7a.ipk.
Configuring hah.
 Adding system startup for /etc/init.d/xap.
root@beaglebone:/etc/opkg#

Connman has no right to be used on MY embedded hardware, yeah yeah I know all the argument about fall back and what if the network isn't etc etc… But really I don't give a shit, if the network is not up we are hosed.

I don't want connman anywhere near my beaglebone.

I want this → http://www.unix.com/man-page/Linux/5/interfaces/

How to remove connman and revert to traditional network interface start up.

systemctl disable connman.service

for i in  pre-up up post-up pre-down down post-down; do
  mkdir -p /etc/network/if-${i}.d
done

cat > /etc/network/interfaces <<EOF
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
EOF

cat >/etc/resolv.conf <<EOF
search local
nameserver 192.168.1.20
EOF

cat > /lib/systemd/system/network.service <<EOF
[Unit]
Description=Network interfaces
After=remount-rootfs.service

[Service]
RemainAfterExit=yes
ExecStart=/sbin/ifup -a
ExecStop=/sbin/ifdown -a

[Install]
WantedBy=basic.target
EOF

systemctl enable network.service

After running the Beaglebone for a while you may notice messages like this

[drm:output_poll_execute], [CONNECTOR:5:HDMI-A-1] status updated from 2 to 2

in the log called with dmesg. It's not really a problem unless you are trying to debug but still annoying.

To stop these edit the uEnv.txt file on the FAT partition (not uEnv.txt in /boot)

Mount the partition

mount /dev/mmcblk0p1  /mnt/card

edit the uEnv.txt file to remove the drm_debug part

nano /mnt/card/uEnv.txt

and remove drm.debug=7

Save the file:

Ctrl-X, Y

Unmount the partition:

umount /mnt/card

Reboot the board:

shutdown -r now

After you have got the BBB up and running how you like it, backing up is always a good idea.

You can of course back up the ini settings, plugboard scripts etc using the web GUI but I like to keep a backup of the entire eMMC.

There are a few methods to be found on the 'net that require the use of a script on a microSD card. This is ideally the best way but requires stopping the BBB (and if SWMBO is expecting things to happen, that's never good)

So here is an option to use dd over ssh to backup to another PC (in my case a mac)

on the BBB

sudo dd if=/dev/mmcblk0 bs=1M | ssh themac@192.168.0.X "dd of=/Users/themac/Desktop/BBB_Backup_date.img bs=1m"

n.b. the block size is set on the BBB using bs=1M but on the mac HAS to be bs=1m (lowercase) (I'm not sure if this is the case :) on a pc)

To restore. This needs to be done after booting from an SD card to free up the eMMC The eMMC is then mmcblk1 not mmcblk0

ssh themac@192.168.0.X "dd of=/Users/themac/Desktop/BBB_Backup_date.img bs=1m” | sudo dd of=/dev/mmcblk1 bs=1M

Then power down, remove the SD card and reboot.

  • livebox/beagleboneporting.txt
  • Last modified: 2015/03/13 04:29
  • by brett