BBB Rev C uBoot order

Hello -

I am a bit of a newbie when it comes to Linux and modifying uBoot is something that is very new to me. I remember with the Rev B boards that you needed to hold the S2 switch in order to boot from the SD card. This was “fixed” by the time the Rev C hardware came out - I assume by patching uBoot. Anyway, the current behavior (Debian Wheezy) when there is both a valid eMMC image and valid SD image is to boot off the SD card regardless of the state of the S2 switch. I get that this is because the uBoot on the eMMC and the SD card are the same and both defaul to booting the SD card if it is there.

I’d like to get the old behavior back so that the S2 switch forces a boot from the SD card and the eMMC will ignore the SD card for the purpose of finding the boot image.

The reason for this is that I am making a deeply embedded system and want to be able to update the eMMC by booting from SD card using the scripts provided (set the cmdline in uEnv.txt to make it a flasher) and I won;t have physical access to the uSD slot.

Alternatively, and here is where I am a rank newbie, is there a way (script) that I can boot into the eMMC (no boot image on the SD card) and trigger a reflash of the eMMC?

Thanks in advance,
Ed

Rebuild u-boot:

https://eewiki.net/display/linuxonarm/BeagleBone+Black#BeagleBoneBlack-Bootloader:U-Boot

after you've patched above,

find this and remove "mmc 0"

http://git.denx.de/?p=u-boot.git;a=blob;f=include/configs/am335x_evm.h;h=6ebe0b3866f9b137472cc080c9eb8f1e38233186;hb=refs/tags/v2016.03#l87

87
<http://git.denx.de/?p=u-boot.git;a=blob;f=include/configs/am335x_evm.h;h=6ebe0b3866f9b137472cc080c9eb8f1e38233186;hb=refs/tags/v2016.03#l87>
        func(MMC, mmc, 0) \
88
<http://git.denx.de/?p=u-boot.git;a=blob;f=include/configs/am335x_evm.h;h=6ebe0b3866f9b137472cc080c9eb8f1e38233186;hb=refs/tags/v2016.03#l88>
        func(LEGACY_MMC, legacy_mmc, 0) \

Flash it "only" to eMMC, now the eMMC will never look to microSD..

Regards,

Made all of the changes and got a clean build for the MLO and u-boot.img (thanks!!!). What is the best way to flash the eMMC? I figure it is to modify an image of my existing eMMC and use your script to flash the SD to the eMMC. That being the case - where is the u-boot.img file? I poked around the .img file and haven’t been able to find anythign in the /boot directory. Thanks again!

Ed

Made all of the changes and got a clean build for the MLO and u-boot.img (thanks!!!). What is the best way to flash the eMMC? I figure it is to modify an image of my existing eMMC and use your script to flash the SD to the eMMC. That being the case - where is the u-boot.img file? I poked around the .img file and haven’t been able to find anythign in the /boot directory. Thanks again!

Ed

Here if you look closely, you’ll see the bootloaders are in the first 1M of disk space, or MBR if you will.

https://eewiki.net/display/linuxonarm/BeagleBone+Black#BeagleBoneBlack-SetupmicroSDcard

I have been pointed in the correct direction. Thank you all!

Ed

I have been pointed in the correct direction. Thank you all!

Ed

The link I have is a bit busted, didnt link to the correct spot, but if you click on the left side where it says “Setup MicroSD card” that’ll take you to the correct spot.

The easiest way, boot the bbb up, copy the MLO/u-boot.img over and do:

sudo dd if=./MLO of=/dev/mmcblk1 count=1 seek=1 bs=128k
sudo dd if=./u-boot.img of=/dev/mmcblk1 count=2 seek=1 bs=384k

This assumes /dev/mmcblk1 is currently the eMMC..

Regards,

OK - status:

  1. Compile - Good
  2. flash new MLO and u-boot.img - Good
  3. to check who booted i changed the hostnames on the eMMC (GEMMX) and SD cards (GEMM3)
  4. cycle power with SD inserted gives GEMMX (SD card)
  5. cycle power and remove SD card gives GEMM3 (eMMC)

Here’s a scrape from the am335x_evm.h file"

#define BOOTENV_DEV_NAND(devtypeu, devtypel, instance)
“bootcmd_” #devtypel “=”
“run nandboot\0”

#define BOOTENV_DEV_NAME_NAND(devtypeu, devtypel, instance)
#devtypel #instance " "

#define BOOT_TARGET_DEVICES(func)
func(LEGACY_MMC, legacy_mmc, 0)
func(MMC, mmc, 1)
func(LEGACY_MMC, legacy_mmc, 1)
func(NAND, nand, 0)
func(PXE, pxe, na)
func(DHCP, dhcp, na)

#define CONFIG_BOOTCOMMAND
"run findfdt; "
“run distro_bootcmd”

I simply deleted the line 87 - that’s what I assumed you meant by remove “mmc 0”. Do I need to blow away the legacy entry as well?

OK - status:
1) Compile - Good
2) flash new MLO and u-boot.img - Good
3) to check who booted i changed the hostnames on the eMMC (GEMMX) and SD
cards (GEMM3)
4) cycle power with SD inserted gives GEMMX (SD card)
5) cycle power and remove SD card gives GEMM3 (eMMC)

Here's a scrape from the am335x_evm.h file"

#define BOOTENV_DEV_NAND(devtypeu, devtypel, instance) \
"bootcmd_" #devtypel "=" \
"run nandboot\0"

#define BOOTENV_DEV_NAME_NAND(devtypeu, devtypel, instance) \
#devtypel #instance " "

#define BOOT_TARGET_DEVICES(func) \
func(LEGACY_MMC, legacy_mmc, 0) \

^ this is also microSD..

func(MMC, mmc, 1) \
func(LEGACY_MMC, legacy_mmc, 1) \
func(NAND, nand, 0) \
func(PXE, pxe, na) \
func(DHCP, dhcp, na)

#define CONFIG_BOOTCOMMAND \
"run findfdt; " \
"run distro_bootcmd"

I simply deleted the line 87 - that's what I assumed you meant by remove
"mmc 0". Do I need to blow away the legacy entry as well?

Regards,

And now it works!

  1. SD card in boots to GEMM3 (eMMC)
  2. SD card in and SW2 pressed gives GEMMX (SD card)

Thanks for all your help (everyone) and especially Robert! Now to write down all of this recipe.

Cheers,
Ed

This is just a summary of the above recipe for posterity (and search engines everywhere):

To make it so that the BBB will ignore the SD card unless SW2 is pressed requires a new u-boot on the eMMC.
the following recipe needs to be followed exactly (otherwise there will be errors in the compile of u-boot.

Steps:

  1. Make sure that you have a 64-bit Linux with git installed, and a BBB that can boot off the eMMC
  2. Rebuild u-boot:
    2.1) install the appropriate cross-compiler

wget -c https://releases.linaro.org/components/toolchain/binaries/5.3-2016.02/arm-linux-gnueabihf/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf.tar.xz
tar xf gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf.tar.xz
export CC=pwd/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-
${CC}gcc --version (** this tests to make sure CC is set correctly **)
2.2) Get u-boot from repository (~/)
git clone https://github.com/u-boot/u-boot
cd u-boot/
git checkout v2016.03 -b tmp
2.3) patch it (~/u-boot)
wget -c https://rcn-ee.com/repos/git/u-boot-patches/v2016.03/0001-am335x_evm-uEnv.txt-bootz-n-fixes.patch
patch -p1 < 0001-am335x_evm-uEnv.txt-bootz-n-fixes.patch
2.4) modify it
2.4.1) in the directory ~/u-boot/include/configs find the file am335x_evm.h
2.4.2) open it and search for the entry #define BOOT_TARGET_DEVICES
2.4.3) delete (comment out) the lines: (these are the lines that tell the bootloader to look at the SD card for a boot image)
func(MMC, mmc, 0)
func(LEGACY_MMC, legacy_mmc, 0)
2.4.4) save the file
2.5) build it (~/u-boot)
make ARCH=arm CROSS_COMPILE=${CC} distclean
make ARCH=arm CROSS_COMPILE=${CC} am335x_evm_defconfig
make ARCH=arm CROSS_COMPILE=${CC}

  1. There are two files that you are interested in - MLO and u-boot.img
  2. Boot the BBB off the uSD card (necessary since we are going to muck with the eMMC)
  3. Get the files MLO and u-boot.img to the BBB
    5.1) Use SmarTTY to SCP these files to the BBB - they will end up in /tmp
  4. Go to the directory where these files landed
  5. make sure that the eMMC is mounted as mmcblk1 - this should be the case if you coot off the uSD

lsblk
the eMMC on the Rev C BBB is the 3.6G disk/partition

  1. sudo dd if=./MLO of=/dev/mmcblk1 count=1 seek=1 bs=128k
  2. sudo dd if=./u-boot.img of=/dev/mmcblk1 count=2 seek=1 bs=384k
  3. reboot - will boot off the eMMC unless you hold down SW2 in which case it will boot off the uSD

Troubleshooting:

  1. If u-boot compilation kicks errors it is probably because the value of ${CC} is not set properly. This value is not permanent, you’ll need to export it every time unless you want to change your Linux PATH. It could also be a typo in the header you modified

  2. If you still boot off the uSD regardless of SW2 - check that you actually updated the MLO and u-boot.img files. Best to just try to flash them again since they are a direct write to the uSD card (not part of the file system). Remember - reflashing the eMMC will probably lose your modified u-boot.