BeagleBoneBlack Stock Debian from External HD

Jump to: navigation, search

As an alternative to the official Debian images, you can install stock Debian Stretch since most features necessary for BBB support were mainlined. TODO What about other BeagleBone variants?

Note: Under heavy load, the external HD / UAS (USB-Attached-SCSI) may display errors. This appears to be fixed when using Debian Buster rather than Debian Stretch.

This guide assumes the Beaglebone Black was booted from an external MicroSD card with a standard prebuilt Beaglebone Black Debian image on it. Otherwise the path of /boot/dtbs/4.9.82-ti-r102/am335x-boneblack.dtb may need to be adjusted.

Create or reuse an MBR partition table on the eMMC at /dev/mmcblk1. This guide uses the first eMMC partitioon as the boot partition. If you create a new MBR partition table e.g. with fdisk /dev/mmcblk1, you will need to reinstall das U-Boot as explained at the end of this guide. Your external HD is assumed in this guide to be partitioned with the root partition at /dev/sda2.

mkfs.ext4 /dev/mmcblk1p1
mkfs.ext4 /dev/sda2
mount /dev/sda2 /mnt
mkdir /mnt/boot
mount /dev/mmcblk1p1 /mnt/boot # mount internal 3.6GB eMMC as boot partition

Now download with wget the debootstrap binary as described in Debian installation instructions D.3.2.

/usr/sbin/debootstrap --arch armhf stretch /mnt

DeviceTree information about the Beaglebone Black must be copied over and *changed*: The Sitara processor in the Beaglebone Black has issues in Debian Stretch's Linux kernel with the cppi41dma kernel module. (TODO There probably is a less invasive way to do this.)

dtc -I dtb -O dts -o /tmp/am335x-boneblack.dts /boot/dtbs/4.9.82-ti-r102/am335x-boneblack.dtb

Open /tmp/am335x-boneblack.dts in a text editor. Find the lines:

dma-controller@47402000 {
        compatible = "ti,am3359-cppi41";

Above these lines, there is a line:

dma-names = "rx1", "rx2", "rx3", "rx4", "rx5", "rx6", "rx7", "rx8", "rx9", "rx10", "rx11", "rx12", "rx13", "rx14", "rx15", "tx1", "tx2", "tx3", "tx4", "tx5", "tx6", "tx7", "tx8", "tx9", "tx10", "tx11", "tx12", "tx13", "tx14", "tx15";

Delete this one line. Then:

mkdir -p /mnt/etc/flash-kernel/dtbs
dtc -O dtb -o /mnt/etc/flash-kernel/dtbs/am335x-boneblack.dtb /tmp/am335x-boneblack.dts

Add the partitions to the fstab. You may also use UUIDs or similar instead of /dev/sda2.

cat > /mnt/etc/fstab << EOF
/dev/sda2  /  ext4  defaults  0 1
/dev/mmcblk1p1  /boot  ext4  noatime,errors=remount-ro  0 2

Note: When changing the fstab or the flash-kernel configuration later on, mount *everything*, chroot into /mnt and run: update-initramfs -u

cd /mnt
mount -t proc /proc proc/
mount --rbind /dev dev/
mount --rbind /sys sys/
LANG=C.UTF-8 chroot /mnt
apt update
apt upgrade

flash-kernel will generate a bootscript that boots the Linux kernel via initramfs, unlike the normal BBB boot process which directly boots into the kernel. Booting via initramfs is necessary for loading the kernel modules for the external HD.

apt install linux-image-armmp flash-kernel
cat > /etc/default/flash-kernel << EOF
update-initramfs -u

Note: To repopulate /boot later on if you flashed the eMMC or for other reasons, you need to reinstall linux-base and not just linux-image-armmp flash-kernel.

If at the beginning of this guide you have recreated the partition table of the eMMC, you may need to run:

apt install u-boot-omap
dd if=/usr/lib/u-boot/am335x_boneblack/MLO of=/dev/mmcblk1 count=1 seek=1 bs=128k
dd if=/usr/lib/u-boot/am335x_boneblack/u-boot.img of=/dev/mmcblk1 count=4 seek=3 bs=128k

Failing to do so may mean the BBB cannot find das U-Boot bootloader on the eMMC and just prints CCCCCCCCCCCCCC on the debug serial UART console, cf. [1].

You probably want to setup basic tools like sudo and network, like this for example:

apt install network-manager
adduser yourname
apt install sudo
gpasswd -a yourname sudo

Now you can power off your Beaglebone Black and remove the SD card you booted from. Restarting the BBB will boot your new operating system.