Ubuntu – How to flash Snappy Ubuntu Core onto a BeagleBone Black’s eMMC

beagleboardemmcubuntu-core

I have successfully followed the instructions under Snappy: Getting started with a Beaglebone Black and currently my BeagleBone Black always boots Ubuntu Core from the microSD card.

Is it possible to flash Ubuntu Core on the on-board flash memory (eMMC) itself, so that I no longer need the SD card at all? (The eMMC's storage capacity is ~4GB.)

Best Answer

The result and remaining problem
This walkthrough boots Snappy Ubuntu Core from the Beaglebone Black's(BBB) eMMC instead of the default boot from SD card. But for that to work, it breaks the a/b fallback mechanism constructed in the U-boot step of the Snappy Core default image. The reason the fallback mechanism is broken is because it uses the "saveenv" U-boot command which for an still unknown reason doesn't seem to work on the BBB's eMMC.

The walkthrough

  1. Create bootable sd card to dd the Snappy Core img to the eMMC of the BBB.

    • Download the latest Debian image provided by the beaglebone.org:

      $ wget https:// debian.beagleboard.org/images/bone-debian-7.8-lxde-4gb-armhf-2015-03-01-4gb.img.xz

    • Unpack and copy the debian image to your SD card. BE CAREFUL you can overwrite your root filesystem if you pick the wrong device! Check "dmesg | tail" when inserting SD card find the correct device.

      $ unxz -c bone-debian-7.8-lxde-4gb-armhf-2015-03-01-4gb.img.xz | sudo dd of=/dev/sdX bs=32M
      $ sync

  2. Overwrite the eMMC default image with the Snappy Ubuntu Core image.

    • Download a compressed Snappy Ubuntu Core image on the SD Card.
      Insert the newly created Debian SD card in the BBB and boot from it using the boot button. Once booted, download the Snappy Ubuntu Core compressed image to the sd card.

      $ wget http://releases.ubuntu.com/15.04/ubuntu-15.04-snappy-armhf-bbb.img.xz

    • Find out which device is the eMMC.
      During boot, the debian image will mount the root filesystem from the SD card to "/". Usually this is "/dev/mmcblk0".

      $ cat /etc/fstab | grep mmc
      /dev/mmcblk0p2 / ext4 noatime,erros=remount -ro 0 1

      Check which is the other available mmc device. Usually this means the eMMC is /dev/mmcblk1.

      $ ls /dev/mmcblk?
      /dev/mmcblk0 /dev/mmcblk1

    • Unpack and dd the Snappy Ubuntu Core image to the eMMC of the BBB.

      $ unxz -c ubuntu-15.04-snappy-armhf-bbb.img.xz | sudo dd of=/dev/mmcblk1 bs=32M
      $ sync

  3. Change the U-Boot settings to boot from eMMC instead of SD card.
    By default U-boot will not boot since the U-boot environment is still pointing to the SD card. I used the uEnv.txt example to get started and adjust a few things in order to point to the eMMC. Actually 3 lines are changed:
    • Change the mmc device from SD card (1) to eMMC (0)
      Original
      mmcdev=0
      New:
      mmcdev=1
    • Change the snappy_ab fallback system to snappy_kernel=a, which is now fixed at the first rootfs (a).
      Original
      snappy_ab=a
      snappy_boot=if test "${snappy_mode}" = "try"; then if test "${snappy_trial_boot}" = "1"; then setenv snappy_os "${snappy_good_os}"; setenv snappy_kernel "${snappy_good_kernel}"; saveenv; else setenv snappy_trial_boot 1; saveenv; fi; fi; run loadfiles; setenv mmcroot /dev/disk/by-label/writable ${snappy_cmdline} snappy_os=${snappy_os} snappy_kernel=${snappy_kernel}; run mmcargs; bootz ${loadaddr} ${initrd_addr}:${initrd_size} ${fdtaddr}

      New
      snappy_kernel=a snappy_boot=run loadfiles; setenv mmcroot /dev/disk/by-label/system-${snappy_kernel} ${snappy_cmdline} snappy_os=${snappy_os} snappy_kernel=${snappy_kernel} rootfstype=ext4; run mmcargs; bootz ${loadaddr} ${initrd_addr}:${initrd_size} ${fdtaddr}
  4. Remove the SD card and reboot
Related Question