Android fastboot for BeagleBone Black

In this article I describe how to install U-Boot with Android fastboot support on a BeagleBone Black, which means that you can install new Android images onto the internal eMMC memory over a USB cable using the normal “fastboot” command-line tool.

Background on fastboot and Android boot images

If you want some background on fastboot and so on, you might be interested in a presentation I created a little while ago that describes the Android early boot process, how boot images are formatted and how to use the fastboot command:
http://www.slideshare.net/chrissimmonds/android-bootslides20

Fastboot and U-Boot

Mainline U-Boot does not support fastboot. Various vendors have added it to their own versions, including the Rowboat project for the BeagleBone Black (and other devices). However, even this version does not work out of the box and has a few annoyances, so I have cloned it and made some changes to make it easier to use. It is this version that I am going to describe here.

Preparation

The steps are

  • Get the new U-Boot, either by downloading the pre-compiled binaries or building from source
  • Create a bootable micro SD card containing the new U-Boot
  • Boot the BeagelBone from it
  • Use fastboot comands to format the internal memory and copy U-Boot into it
    • I tested using BeagleBone Black rev A5c and rev 6 and Ubuntu 12.04 on my PC.

      As well as the BeagleBone and a micro SD card, you will need a serial-to-USB cable and it is recommended that you use an external power supply
      because the current used when writing to the eMMC chip may exceed that supplied by a typical USB port. See this page for examples: http://elinux.org/Beagleboard:BeagleBone_Black_Accessories.

      Get U-Boot

      For those in a hurry, you can use the pre-compiled binaries from http://2net.co.uk/downloads/u-boot-bbb-fb/u-boot-am335x-v2013.01.01-bbb-....
      Or you can compile them from source following the instructions further down.

      Create a bootable micro SD card

      In essence, this is very easy. Just copy the two files from the tar file onto a partition of a micro SD card. The partition must be

      • the first on the device
      • use the FAT32 (or FAT16) format
      • have the boot flag set

      There are many ways of formatting a card like this. Here is one that uses command-line tools and so can be put in a script.

      Take a micro-SD card and connect it to your PC by:

      • either using a direct SD slot if available, in which case the card will appear as "/dev/mmcblk0"
      • or, using a memory card reader in which case the card wil be seen as "/dev/sdb", or "/dev/sdc", etc

      Now type the command below to partition the micro-SD card, assuming that the card is seen as "/dev/mmcblk0"

      sudo sfdisk -D -H 255 -S 63 /dev/mmcblk0 << EOF
      ,9,0x0C,*
      ,,,-
      EOF
      

      Format the first partition as FAT32

      sudo mkfs.vfat -F 32 -n boot /dev/mmcblk0p1
      

      Remove the card and insert it again. It should automatically be mounted as "/media/boot" (or "/media/[user]/boot" if you are using Ubuntu 12.10 or later).

      Now, copy the files to this partition:

      cp MLO u-boot.img /media/boot
      

      Finally, umount it.

      Boot with the new U-Boot

      WARNING: this will erase everything in the eMMC storage. If you want to restore the the factory default installation later, follow the instructions
      here: http://elinux.org/Beagleboard:Updating_The_Software

      1. With no power on the BeagleBone board, insert the micro-SD card.
      2. Plug in the serial cable. A serial port should appear on your PC as /dev/ttyUSB0.
      3. Start a suitable terminal program such as gtkterm, minicom or picocom and attach to the port at 115200 bps with no flow control:

      $ gtkterm -p /dev/ttyUSB0 -s 115200
      

      4. Press and hold the 'Boot Switch' button on the Beaglebone, power up the board using the external 5V power connector and release the button after about 5 seconds. You should see a U-Boot prompt on the serial console

      U-Boot#
      

      Ignore the error message "booti: cannot find 'boot' partition", that will be fixed when you load the Android images
      5. Type “fastboot” to put U-Boot into fastboot mode.
      6. Make sure that you have plugged in the USB cable between the mini USB port on the BeagleBone and the PC. Then, using the fastboot command from
      the Android SDK or an AOSP build, check that the BeagleBone has been detected by typing (on the PC)

      $ fastboot devices
      90:59:af:5e:94:81	fastboot
      

      7. If instead you see

      $ fastboot devices
      no permissions	fastboot
      

      Add this line to /etc/udev/rules.d/51-android.rules

      SUBSYSTEM =="usb", ATTRS{idVendor}=="0451", ATTRS{idProduct}=="d022" , MODE="0666"
      

      Then unplug the mini USB cable and plug it back in again. Check that the permissions problem has gone away.

      8. Change into the directory where you extracted the MLO and u-boot.img files from the tar archive, or if you compiled U-Boot from source, the u-boot directory. Use fastboot to format the eMMC chip and then flash the files over

      $ fastboot oem format
      $ fastboot flash spl MLO
      $ fastboot flash bootloader u-boot.img
      

      9. Power off the board, remove the SD card and check that you can load the new U-Boot from eMMC and that the prompt is “U-Boot#”. That's it, you are done. Happy fastbooting!

      Flashing Android images

      I show how to build Android with a partition layout that matches that encoded in this version of U-Boot in Building Jelly Bean 4.3 AOSP for Beaglebone Black v2.0 - with fastboot

      Any time you want to flash new a Android build, boot to the “U-Boot#” prompt and put it into fastboot mode by typing “fastboot”. From then on it will appear just like any other Android device and you load the Android images using commands such as

      $ fastboot flash userdata
      $ fastboot flash cache
      $ fastboot flashall
      

      Build from source

      Get my version of U-Boot like so:

      $ git clone https://github.com/csimmonds/u-boot.git
      $ cd u-boot
      $ git checkout am335x-v2013.01.01-bbb-fb
      

      Since you are likely to be building this along with AOSP, I suggest using the Android cross compiler from prebuilts, but probably any recent arm eabi toolchain will do. If you have sourced build/envsetup.sh and selected the lunch combo the path will be set up already. If not, set it now, substituting ${AOSP} with the place where you installed your AOSP. I used Android 4.3, which has gcc v4.7:

      $ PATH=${AOSP}/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7/bin:$PATH
      

      Then configure and build U-Boot:

      $ make CROSS_COMPILE=arm-eabi- distclean
      $ make CROSS_COMPILE=arm-eabi- am335x_evm_config
      $ make CROSS_COMPILE=arm-eabi- 
      

      This produces the two files: MLO and u-boot.img which you can use to create a bootable SD card as shown above

      Want to know more about Android?

      I have two training courses that will help you:
      Android porting: http://www.2net.co.uk/training/android-porting
      Android Internals: http://2net.co.uk/training/android-internals

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Awesome

Thanks for the tutorials, they're awesome!!

Waiting for the KitKat one ;)

Again, thank you, you rock!

Cheers.

Uboot for Chromium OS

Could Uboot be altered to work for Chromium OS, assuming it can be properly built? I have no luck over the console.

http://www.chromium.org/chromium-os/developer-guide/beaglebone

Re: Uboot for Chromium OS

Fastboot is integrated into the Android build system in such a way as to make it natural and easy to use when flashing images to a device. As far as I know, Chromium OS does not have that support so implementing fastboot in the bootloader does not give you any advantage.

Perfect.

I got over-eager, simply copied u-boot.img from your prebuilts, and bricked my BeagleBoard.
But followed your tutorial over again, and it works flawlessly for me.
Thank you for this :)

Resizing partitions

Hi Chris, great job.
I'm looking for a way to resize the emmc partitions in order to accommodate for a larger system partition.
I'm trying to flash BBBAndroid on the BeagleBone Black, using your u-boot implementation (the one in BBBAndroid does not support fastboot).
I couldn't find the code where the partition sizes are defined.
Can you point me to the right direction?
Thank you,
Domenico.

Re: Resizing partitions

Hi Domenico,

You have to make changes in two places
1. u-boot
Edit drivers/usb/gadget/u_fastboot_mmc.c and adjust the sizes in array "partitions"

2. Android
In /device/ti/beagleboneblack edit BoardConfig.mk and change the image sizes at the bottom to match

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Youtube and Vimeo video links are automatically converted into embedded videos.
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.