Minimal Debian Install for BeagleBone Black
Note: This is superseded by this article.
Some time ago, I settled on the BeagleBone Black as my “IoT” platform. I’m mostly using them to control RGB LEDs. I know this is overkill, but after several iterations (Arduino + XBee and Raspberry PI), this seems to be the best fit for me.
Some of my BBB’s have 2GB flash and some 4GB. I don’t need X windows, node, or a lot of other things included in the default Debian and Angstrom images. Fortunately, with some digging you can find a “console” image.
BeagleBone Black Debian Releases
Debian 7 and 8 images are provided. I ran into issues with the Adafruit_BBIO library under Debian 8 (the device tree seems to be very different). So I’m sticking with Debian 7 for now.
Unfortunately, the console images don’t quite work out of the box. I want a stand alone, bootable, micro SD card. The console image is lacking the boot partition, some firmware, and a few other packages.
You’ll need both the console image and a full LXDE image in order to proceed:
wget https://rcn-ee.com/rootfs/bb.org/release/2015-11-03/lxde-4gb/bone-debian-7.9-lxde-4gb-armhf-2015-11-03-4gb.img.xz
wget https://rcn-ee.com/rootfs/bb.org/release/2015-11-03/console/bone-debian-7.9-console-armhf-2015-11-03-2gb.img.xz
sha256sum bone-debian-7.9-*.xz
# Output:
# 63e78f417db62737804877c056c4632173d2b970eed1cf1c59b2b99e9752ef0e bone-debian-7.9-console-armhf-2015-11-03-2gb.img.xz
# 0f27fb05bca2c64e89abc20f54e35bef7fbdbd391ec38c2ea9d56c6356be5fab bone-debian-7.9-lxde-4gb-armhf-2015-11-03-4gb.img.xz
First set up the partition map on your micro SD card. I will be using /dev/mmcblk0, yours might be /dev/sdb or anything else. Adjust these instructions accordingly.
As root:
cat << EOF | sfdisk /dev/mmcblk0
# partition table of /dev/mmcblk1
unit: sectors
/dev/mmcblk1p1 : start= 63, size= 144522, Id= c, bootable
/dev/mmcblk1p2 : start= 144585, size= 3598560, Id=83
/dev/mmcblk1p3 : start= 0, size= 0, Id= 0
/dev/mmcblk1p4 : start= 0, size= 0, Id= 0
EOF
Next, set up the boot partition from the LXDE image. Note that your
system may assign something other than loop0
:
sudo kpartx -a -v bone-debian-7.9-lxde-4gb-armhf-2015-11-03-4gb.img
# Output:
# add map loop0p1 (253:2): 0 196608 linear /dev/loop0 2048
# add map loop0p2 (253:3): 0 6764544 linear /dev/loop0 198656
mkdir src target
sudo mount /dev/mapper/loop0p1 src
sudo mkfs.vfat /dev/mmcblk0p1
sudo mount /dev/mmcblk0p1 target
sudo cp -ar src/* target/
sudo umount src
sudo umount target
Now, set up the rootfs, copying from the console image. Note that we
still have the LXDE image mounted as /dev/loop0
, so kpartx assigned
loop1
:
sudo kpartx -v -a bone-debian-7.9-console-armhf-2015-11-03-2gb.img
# Output:
# add map loop1p1 (253:4): 0 3479552 linear /dev/loop1 2048
sudo mkfs.ext4 /dev/mmcblk0p2
# Output:
# mke2fs 1.42.13 (17-May-2015)
# Creating filesystem with 449820 4k blocks and 112672 inodes
# Filesystem UUID: b23f1941-a7c9-45d1-b48b-f7b4ebe23f14
# Superblock backups stored on blocks:
# 32768, 98304, 163840, 229376, 294912
#
# Allocating group tables: done
# Writing inode tables: done
# Creating journal (8192 blocks): done
# Writing superblocks and filesystem accounting information: done
sudo mount /dev/mapper/loop1p1 src
sudo mount /dev/mmcblk0p2 target
sudo cp -ar src/* target/
For some reason, the console image is also missing some firmware, so copy this from the LXDE image:
sudo umount src
sudo mount /dev/mapper/loop0p2 src
sudo cp -ar src/lib/firmware/* target/lib/firmware/
Clean up:
sudo umount src
sudo umount target
sudo kpartx -d /dev/loop1
sudo kpartx -d /dev/loop0
sync
You should be able to boot off the micro SD card. Note you may need to hold the button next to the SD card to boot from it.
Let’s update our minimal image and fix a few things. Login as debian/temppwd from the console (serial, HDMI, or SSH). Your BeagleBone will need a working Internet connection to proceed.
sudo -s
apt-get update
# Output:
# Get:1 http://security.debian.org wheezy/updates Release.gpg [1554 B]
# ... lots of output ...
# Fetched 8631 kB in 16s (539 kB/s)
# Reading package lists... Done
Fix the default locale. Select the en_US.UTF-8 and set it as the default. (Unless you want something different):
apt-get install debconf locales
dpkg-reconfigure locales
Now, install some missing packages and update the system:
apt-get install am335x-pru-package atmel-firmware firmware-libertas \
firmware-ralink firmware-realtek zd1211-firmware ntpdate
apt-get upgrade
You might want to set the clock before proceeding too much further:
ntpdate pool.ntp.org
# 24 Jan 22:35:40 ntpdate[2967]: step time server 142.54.181.202 offset 7103177.314425 sec
You might also want to rebuild your ssh keys:
rm /etc/ssh/ssh_host_*
dpkg-reconfigure openssh-server
You can disable the heartbeat LED effect by:
echo none > /sys/class/leds/beaglebone\:green\:usr0/trigger
You can stop here. Note that you have a very minimal system, and you will likely need to install many of your favorite tools.
At one time, python3 worked with the Adafruit_BBIO, however as of this Writing updating distribute breaks pip.
Python 3 (may or may not work):
apt-get install python3 python3-pip
easy_install3 -U distribute
pip-3.2 install Adafruit_BBIO
Python 2 does seem to work, and is almost the same setup:
apt-get install python python-pip python-dev
easy_install -U distribute
pip install Adafruit_BBIO
See Setting up IO Python Library on BeagleBone Black for more information from Adafruit.
My ultimate goal is to port my code to Elixir. Debian 7 wants to install Erlang 15, which won’t cut it for Elixir. So far I am having problems building Erlang 18. I’ll post instructions once I get it going.
Promising leads: