When I first saw the BeagleBone Black, it was a no-brainer instant buy. An open platform, powerful enough to run Android effectively, for under $50, with an onboard eMMC for storage! That last piece was the prime driver. Basically every platform out there today (even those used in many production devices) rely on an external SD/MMC card for storage rather than providing any capable flash on the board; and that really bugs me. So when I saw the opportunity to do away with block-writing images to partitioned SD cards, I jumped.
After reading through the latest Developer Guide for Android on the AM335X, I was even more ecstatic to find that it claimed fastboot support, the same protocol Google uses to flash partition images onto the Nexus devices. This would make it so much easier to make changes to a system image and flash it back to the device without the constant swapping of SD cards (especially if, like me, your Linux environment is in a VM, adding extra annoying steps to getting the SD card mounted each time you need to update it)! I was a bit saddened at first to learn that this capability was not built into the bootloader that the board was shipped with. I believe the eMMC on this board is one of its greatest features and the community should be pushing people to use it by enabling that support out of the box. However, the instructions didn’t seem awful, so I gave it a try.
Well, as one might expect the instructions set forth don’t give you the full picture. So, in hopes of saving others from similar fits of rage, here are the basic steps I went through to finally get this enabled on my BeagleBone Black. For reference, my hardware is a Rev A5A, but at least as it stands today the process should be the same for any subsequent revision as well.
How It Works
As I mentioned, the bootloader currently resident on the eMMC when you unbox your BBB does not support fastboot. Furthermore, the version of u-boot in the TI DevKit sources does allow enabling of fastboot, but it directs all writes to the external SD card, so it can’t be used to flash the on-board eMMC. What follows are the steps to get a proper u-boot image built and flashed onto the eMMC of the board. From this point forward, I’m assuming you have the TI Android DevKit Sources installed in your Linux environment.
Step 0: Download the correct sources.
We first need to clone and checkout the proper commit that includes the eMMC support necessary for fastboot, since the DevKit gave us the wrong version.
$ git clone git://gitorious.org/rowboat/u-boot.git $ cd u-boot $ git checkout 6d40c2a2b5e6a1243da890c3b36bf3d89e275940
Step 1: Modify the configuration
Before we build, we have to enable the fastboot support for eMMC in
#define CONFIG_MMC_FASTBOOT_DEV 1 /*Uncomment this to enable NAND fastboot*/ /*#define CONFIG_FASTBOOT_NAND */ /*Uncomment this to support eMMC booting*/ #define CONFIG_STORAGE_EMMC
CONFIG_MMC_FASTBOOT_DEV option tells the bootloader to direct output to MMC1, which is the address of the eMMC (this option is ignored in the sources provided with the current DevKit); this option should already be defined if you are using the right sources. The
CONFIG_STORAGE_EMMC option enables booting from the eMMC; this option needs to be uncommented. Make sure to keep
CONFIG_FASTBOOT_NAND commented out, it is not compatible with the eMMC mode.
Step 2: Build u-boot
You need to first have a valid toolchain in your path, which is available from the Android prebuilts in the DevKit sources:
$ export PATH=<devkit_path>/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin:$PATH
At this point, you can pretty well follow the instructions given in the Developer Guide for Fastboot to create the MLO and u-boot.img output files, and pre-pend the raw eMMC header to MLO.
Step 3: Make Your Last SD Card Image
If you have an existing SD card image that works, simple replace MLO and u-boot.img in that image and flash a new SD card. If you don’t, you can do the same with the Pre-built image for the BeagleBone Black from the DevKit Downloads Page. In this case, replace MLO and u-boot.img in the Boot_Images directory.
Insert this card in your BBB, hold down the USER button (S2), and apply power with the button held down. The device will boot with your new u-boot on the SD card (check the build date on the serial port output). Hit enter to break into the u-boot console when it says “Hit any key to stop autoboot:”
Step 4: Use fastboot from the SD card to get fastboot on the eMMC.
From the u-boot console prompt, type “fastboot”and hit enter. The device will say “fastboot entered…” or “fastboot initialized…” over the serial output. The BBB is now in fastboot mode. If you connect the USB mini cable to your host machine, you can check if the device is visible:
$ fastboot devices c8:a0:30:ac:53:61 fastboot $
If you see the device number echoed back, you’re good to go. If you don’t know where to find the fastboot binary on your host machine, it will either be in
<devkit_path>/out/host/linux-x86/bin/fastboot (if you’ve successfully built an Android image before), or you can find it in the
platform-tools/ directory of your Android SDK installation (my personal location of choice).
To flash MLO and u-boot onto the eMMC:
$ fastboot oem format $ fastboot flash spl <MLO_PATH>/MLO $ fastboot flash bootloader <UBOOT_PATH>/u-boot.img
You may also flash additional images at this time if you wish (system.img, userdata.img, etc.), or simply:
$ fastboot reboot
…to reset the device.
You can now remove your SD card an never use it again!
If you boot the device without an SD card inserted, and break back into the u-boot console, you will see that the “fastboot” command is now enabled on the bootloader burned into the eMMC. Using a modified version of Step 4, you can now flash any Android images directly onto the board memory using
fastboot flash. You won’t need to load the SPL or bootloader anymore either; just the partitions you need to update.