Experiments with the BeagleBone Black and U-Boot

This is a somewhat unstructured (and work in progress) protocol of me messing around with an embedded linux tutorial in the middle of 2024. These notes are mainly intended for my own potential future benefit. YMMV.

I’ve been working my way through bootlin’s excellent (freely available) course material for their (paid) trainings on embedded Linux. I’m using a BeagleBone Black (BBB) as my hardware testbed of choice.

Bus Pirate Woes

The BBB comes with a serial debug header (J1), where you can attach a serial interface to pins 1 (ground), 4 (receive) and 5 (transmit). I don’t own the required FTDI cable but the Bus Pirate v4 that had been gathering dust in a drawer should do the trick. Or so I thought. An old blog article contained a walk through how to set the Bus Pirate into UART mode to talk to the BBB. However, it turns out that the firmware on my board was so old that it did not include UART support yet. Then, even after reflashing the Bus Pirate to the latest firmware binaries that I could find, I could not get the BBB’s serial to work. This was extremely hard to debug. To make sure that the BBB wasn’t at fault, I downloaded a Debian image that I copied onto an SD card. Once I had inserted that, the BBB happily flashed its LED’s, indicating that it could indeed boot, but nothing that I did changed the fact that the Bus Pirate didn’t receive anything when configured to UART. In my desperation, I then went back and had a second look through my collection of odd USB dongles. I found a likely candidate with a likely-looking PCB. Indeed, searching for the code on the chip (SILABS CP2102) revealed that it was indeed a USB to UART chip. I could have simply plugged it in, where dmesg would have revealed

[129653.912133] usb 1-5.1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[129653.912137] usb 1-5.1.1: Product: CP2102 USB to UART Bridge Controller
[129653.912140] usb 1-5.1.1: Manufacturer: Silicon Labs
[129653.918658] cp210x 1-5.1.1:1.0: cp210x converter detected
[129653.921474] usb 1-5.1.1: cp210x converter now attached to ttyUSB0

And what is more, after attaching RX and TX cables in the right (crossed-over) order to the J1 header on the BBB, I finally could watch the thing boot, although not yet with my self-compiled version.

So, the Bus Pirate was at fault all along. Not sure if I messed it up or simply failed to properly enable UART.

Snagboot Woes

I could not get my self-compiled U-Boot bootloader reliably deployed to the BBB’s internal EMMC. While the Snagboot tool claims to support (re)flashing the bootloader of the BBB via the BOOTP-based recovery mechanism, my board refused to cooperate. It retrieves the SPL via TFTP just fine but then simply does not fetch the main u-boot.img payload in a second TFTP request.

After many retries, booting via USB (in ethernet gadget mode) finally started to work and I could load my own cross-compiled U-Boot and play around in the U-Boot shell. After playing around with further compile flags in an effort to get fastboot mode to work in U-Boot, I at one point ended up with broken SPL that could no longer load the main u-boot.img via USB. I didn’t think it would be an issue, but no matter what I tried, even with a complete vanilla build of U-Boot for the BBB, booting via USB simply stopped working beyond this point, I couldn’t get back to a working snagboot state.

Flashing U-Boot to SD Card

After giving up on snagboot, I followed this howto to copy my version of U-Boot to the raw SD card.

export DISK=/dev/sda
sudo dd if=/dev/zero of=${DISK} bs=1M count=10
sudo dd if=MLO of=${DISK} count=2 seek=1 bs=128k
sudo dd if=u-boot-dtb.img of=${DISK} count=4 seek=1 bs=384k
sync

Resources

Online sites that helped me along: