March 4, 2020

The Beaglebone Black

Let's examine a flasher image

Having just made one of these (by downloading and running "dd") I am curious about what makes it tick. There is nothing stopping us from plugging it into a card reader on our linux desktop and poking around.

Running fdisk shows just one big partition, so let's mount it.

/dev/sdf1  *     8192 6963199 6955008  3.3G 83 Linux

[root@trona tom]# mount /dev/sdf1 /mnt
[root@trona tom]# cd /mnt
[root@trona mnt]# ls
bbb-uEnv.txt  bin  boot  dev  etc  home  ID.txt  lib  lost+found  media  mnt  nfs-uEnv.txt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
[root@trona mnt]# ls /boot
config-5.4.17-100.fc30.x86_64  elf-memtest86+-5.01                                      initramfs-5.4.17-100.fc30.x86_64.img  lost+found                         System.map-5.5.7-100.fc30.x86_64                   vmlinuz-5.5.7-100.fc30.x86_64
config-5.5.6-100.fc30.x86_64   extlinux                                                 initramfs-5.5.6-100.fc30.x86_64.img   memtest86+-5.01                    vmlinuz-0-rescue-092a4d65f77a437a92b72004573f8bea
config-5.5.7-100.fc30.x86_64   grub2                                                    initramfs-5.5.7-100.fc30.x86_64.img   System.map-5.4.17-100.fc30.x86_64  vmlinuz-5.4.17-100.fc30.x86_64
efi                            initramfs-0-rescue-092a4d65f77a437a92b72004573f8bea.img  loader                                System.map-5.5.6-100.fc30.x86_64   vmlinuz-5.5.6-100.fc30.x86_64
Just an everyday linux system, so what makes it a flasher image? Taking a brute force approach, we search for "Flasher" in the entire filesystem, taking out cue from messages seen on the console when running the flasher. This yields a modest set of results.
cd /mnt
grep -r Flasher .

./boot/uEnv.txt:##enable Generic eMMC Flasher:
./opt/source/u-boot_ti-2017.01/0001-beagle_x15-uEnv.txt-bootz-n-fixes.patch:+//Blank Flasher
./opt/source/u-boot_ti-2017.01/0001-beagle_x15-uEnv.txt-bootz-n-fixes.patch:+//Blank Flasher
./opt/source/u-boot_ti-2017.01/0001-beagle_x15-uEnv.txt-bootz-n-fixes.patch:+//Blank Flasher
./opt/source/librobotcontrol/docs/src/flashing.dox:[2018-8-23 BeagleBone Black Flasher Image](http://strawsondesign.com/docs/images/BBB-blank-debian-9.5-iot-armhf-2018-08-23-4gb.img.xz) ([checksum](http://strawsondesign.com/docs/images/BBB-blank-debian-9.5-iot-armhf-2018-08-23-4gb.img.xz.sha256sum))
./opt/source/librobotcontrol/docs/src/flashing.dox:[2018-8-23 BeagleBone Blue Flasher Image](http://strawsondesign.com/docs/images/BBBL-blank-debian-9.5-iot-armhf-2018-08-23-4gb.img.xz) ([checksum](http://strawsondesign.com/docs/images/BBBL-blank-debian-9.5-iot-armhf-2018-08-23-4gb.img.xz.sha256sum))
./opt/scripts/tools/eMMC/init-eMMC-flasher-a335.sh:message="Starting eeprom Flasher from microSD media" ; broadcast
./opt/scripts/tools/eMMC/init-eMMC-flasher-bp00.sh:message="Starting eeprom Flasher from microSD media" ; broadcast
./opt/scripts/tools/eMMC/init-eMMC-flasher-v2.sh:message="Starting eMMC Flasher from microSD media" ; broadcast
./opt/scripts/tools/eMMC/init-eMMC-flasher-from-usb-media.sh:message="Starting eMMC Flasher from usb media" ; broadcast
./opt/scripts/tools/eMMC/init-eMMC-flasher-from-usb-media-v1-bbgw.sh:message="Starting eMMC Flasher from usb media" ; broadcast
./opt/scripts/tools/eMMC/init-eMMC-flasher-from-usb-media-v2-bbgw.sh:message="Starting eMMC Flasher from usb media" ; broadcast
./opt/scripts/tools/eMMC/functions.sh:##enable Generic eMMC Flasher:
./opt/scripts/tools/eMMC/functions.sh:		echo "##enable Generic eMMC Flasher:" >> ${tmp_rootfs_dir}/boot/uEnv.txt
./opt/scripts/tools/eMMC/functions.sh:  echo_broadcast "Starting eMMC Flasher from microSD media"
Looking at the first hit, the last two lines in /boot/uEnv.txt tell the tale:
##enable Generic eMMC Flasher:
cmdline=init=/opt/scripts/tools/eMMC/init-eMMC-flasher-v3.sh
And this turns out to be a simple top level shell script, as follows:
source $(dirname "$0")/functions.sh

#mke2fs -c
#Check the device for bad blocks before creating the file system.
#If this option is specified twice, then a slower read-write test is
#used instead of a fast read-only test.

mkfs_options=""
#mkfs_options="-c"
#mkfs_options="-cc"

device_eeprom="bbb-eeprom"

check_if_run_as_root

startup_message
prepare_environment

countdown 5
check_eeprom
check_running_system
activate_cylon_leds
prepare_drive
This script is a mere 50 lines (including a header that I omitted above). The meat is in functions.sh, which is 1477 lines.

The root filesystem contents are copied using rsync from the root filesystem on the flasher disk.

So, to produce a flasher disk that would target a 2G eMMC system, it might suffice to:

  1. edit uEnv.txt on the flasher so it would boot and run linux.
  2. delete packages until it would fit into 2G
  3. edit the flasher script so it would partition and mkfs 2G properly
  4. restore uEnv.txt


Feedback? Questions? Drop me a line!

Tom's Computer Info / tom@mmto.org