kientzle/crochet-freebsd — pull request #52 by pkelsey (2014-03-11 15:54:00+00:00)
Title: U-boot 2013.04 mmc improvements

This is a set of patches to be used by crochet for Beaglebone that supports booting FreeBSD from the eMMC on board the Beaglebone Black. The changes to U-boot are:

1. Make a copy of the passed boot parameters and set up the boot parameters pointer for non-SPL builds. This allows bb-uboot.img to be aware of which device the ROM code booted from.

2. For non-SPL builds, if the ROM code booted from an MMC device, set the 'mmcdev' environment variable to the mmc device that was used. This causes bbubldr to be loaded from the same MMC device from which MLO and bb-uboot.img were loaded, instead of the mmcdev that is hardcoded in the board config header, which may be different. That is, with this change, MLO, bb-uboot.img, and bbubldr will always load from the same MMC device when booting from an MMC.

3. A bug in dev_stor_get() that would not correctly set the 'more' flag after finding the first device has been fixed. Without this fix, only the first MMC device will be identified during enumeration, and bb-uboot.img and bbubldr will not see the eMMC.

4. The mmc code now reports empty/failed slots as found devices with DEV_TYPE_UNKNOWN and size 0.

5. The storage enumeration approach has been modified so that enumerated devices of type DEV_TYPE_UNKNOWN are reported in the results as devices with 0 size, and enumeration will continue beyond them. The rest of the existing U-boot API already cleanly handles such devices (such as failing when trying to open one). With this change and (4), above, MMC device enumeration will no longer stop at the first empty slot in the system, so on Beaglebone, with (3), above, the eMMC will always be found by bb-uboot.img and bbubldr whether the card slot is occupied or not.

Since these are patch files being added, it might be easier on the eyes to look at the commit diffs they came from at https://github.com/pkelsey/u-boot/compare/1e17f05...v2013.04-crochet-bbb.

There is a companion change to ubldr that Ian Lepore will be comitting to FREEBSD-CURRENT in the near future that will provide better control over which device the kernel is loaded from. With that change, you will be able to set the environment variable 'loaderdev' in bb-uenv.txt to describe where to load the kernel from, and if loaderdev is empty, all of the disk devices will be tried in order, and the first suitable partition found will be used. With that change to ubldr and the changes to crochet in this pull request, booting from eMMC on Beaglebone Black will be possible.