BBB Rev C uBoot order

424 views
Skip to first unread message

Edwin Maynard

unread,
Apr 27, 2016, 11:52:30 AM4/27/16
to BeagleBoard
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

Robert Nelson

unread,
Apr 27, 2016, 11:58:36 AM4/27/16
to Beagle Board, edwin....@gmail.com
Rebuild u-boot:


after you've patched above,

find this and remove "mmc 0"


87         func(MMC, mmc, 0) \
88         func(LEGACY_MMC, legacy_mmc, 0) \

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

Regards,

--
Robert Nelson
https://rcn-ee.com/

Edwin Maynard

unread,
Apr 27, 2016, 2:29:36 PM4/27/16
to BeagleBoard
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

William Hermans

unread,
Apr 27, 2016, 2:38:14 PM4/27/16
to beagl...@googlegroups.com
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

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/57cb8fac-f7e5-4336-8941-932697d2fa08%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Edwin Maynard

unread,
Apr 27, 2016, 2:40:21 PM4/27/16
to BeagleBoard
I have been pointed in the correct direction. Thank you all!

Ed

William Hermans

unread,
Apr 27, 2016, 2:42:38 PM4/27/16
to beagl...@googlegroups.com
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.

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.

Robert Nelson

unread,
Apr 27, 2016, 2:44:37 PM4/27/16
to Beagle Board
On Wed, Apr 27, 2016 at 1:29 PM, Edwin Maynard <edwin....@gmail.com> wrote:
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!

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,

Edwin Maynard

unread,
Apr 27, 2016, 4:00:00 PM4/27/16
to BeagleBoard
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?

Robert Nelson

unread,
Apr 27, 2016, 4:01:42 PM4/27/16
to Beagle Board
On Wed, Apr 27, 2016 at 3:00 PM, Edwin Maynard <edwin....@gmail.com> wrote:
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,

Edwin Maynard

unread,
Apr 27, 2016, 4:16:30 PM4/27/16
to BeagleBoard
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

Edwin Maynard

unread,
Apr 27, 2016, 4:42:40 PM4/27/16
to beagl...@googlegroups.com
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
>> 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 (~/)
>> cd u-boot/
>> git checkout v2016.03 -b tmp
2.3) patch it (~/u-boot)
>> 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}
3) There are two files that you are interested in - MLO and u-boot.img
4) Boot the BBB off the uSD card (necessary since we are going to muck with the eMMC)
5) 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
6) Go to the directory where these files landed
7) 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
8) sudo dd if=./MLO of=/dev/mmcblk1 count=1 seek=1 bs=128k
9) sudo dd if=./u-boot.img of=/dev/mmcblk1 count=2 seek=1 bs=384k
10) 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.


Reply all
Reply to author
Forward
0 new messages