BBB no autoboot of uSD

Hi,
I have installed Ubuntu on my new BBB.
It boots fine to the uSD card if i press and hald the BOOT button for a few seconds.
It also boots to the uSD card if i issue a reboot from the Ubuntu system.

If i do a shutdown -h now from Ubuntu, it doesn’t boot. It also doesn’t boot if i remove power to the board and add power again.

I have disabled eMMC and HDMI/HDMIN, which is disabled when Ubuntu boots.

All i want is for Ubuntu to boot from uSD card without pressing the BOOT button.
What should i do?

Kind Regards

Well, you could just install an version of ubuntu that is 100%
compatible with the "factory" u-boot... Thus allowing you to boot
without holding down the push button..

http://elinux.org/BeagleBoardUbuntu

3 versions are listed there, create microSD from script, "flasher" and
a "dd" image..

Regards,

Hi,
I just formatted the eMMC instead.
But why is it that BBB isn’t first trying to boot from uSD instead of eMMC?
Is it not more logical that if the board detects an uSD card, it first tries to boot from that, and if there is no mbr on that card it tries the eMMC?

Kind Regards

Hi,
I just formatted the eMMC instead.
But why is it that BBB isn't first trying to boot from uSD instead of eMMC?

Because that was the boot order selected by default.. The push button
changes that..

Is it not more logical that if the board detects an uSD card, it first tries
to boot from that, and if there is no mbr on that card it tries the eMMC?

It does that... "if" you correctly setup the uEnv.txt file.. Which my
images do.. It's not my fault the image you first flashed doesn't
accomplish this..

Regards,

Hi,
Thank you for that clarification.
Does the boot modes (if altered) survive if the power is removed and reapplied?

The uEnv.txt is located in the boot partition, on both eMMC and uSD card.
What line specifies in wich order to boot?

I was wondering why the default is to first try eMMC even when an uSD card is detected.

Kind Regards

Hi,
Thank you for that clarification.
Does the boot modes (if altered) survive if the power is removed and
reapplied?

Well they go back to factory default..

This is why every "flashing" guide says pull the power.. As weird
things happen when you "soft" reboot after flashing the eMMC...

The uEnv.txt is located in the boot partition, on both eMMC and uSD card.
What line specifies in wich order to boot?

In most cases it's more then just "one" line..

I was wondering why the default is to first try eMMC even when an uSD card
is detected.

Because you are over thinking it. The bootrom is "simple" and it is
setup to read the eMMC first.

Here's the boot order:

bootrom loads MLO from eMMC (if that fails it moves to microSD (hence
dd if=/dev/zero to eMMC makes booting from microSD work..)
MLO loads u-boot.img from eMMC
u-boot.img first looks at microSD for uEnv.txt, reads that file in.

Regards,

Hi,
Thank you for that clarification.
Does the boot modes (if altered) survive if the power is removed and
reapplied?

Well they go back to factory default..

This is why every "flashing" guide says pull the power.. As weird
things happen when you "soft" reboot after flashing the eMMC...

The uEnv.txt is located in the boot partition, on both eMMC and uSD
card.
What line specifies in wich order to boot?

In most cases it's more then just "one" line..

I was wondering why the default is to first try eMMC even when an uSD
card
is detected.

Because you are over thinking it. The bootrom is "simple" and it is
setup to read the eMMC first.

Here's the boot order:

bootrom loads MLO from eMMC (if that fails it moves to microSD (hence
dd if=/dev/zero to eMMC makes booting from microSD work..)
MLO loads u-boot.img from eMMC
u-boot.img first looks at microSD for uEnv.txt, reads that file in.

Hey Robert,

Now you have confused me and I thought I understood how the boot process
worked.

If the boot button isn¹t pressed, bootrom loads MLO from eMMC and this
loads u-boot from eMMC. I¹m unaware of bootrom loading MLO from SDCard if
MLO is missing from eMMC. Do you have a reference for this? Also, I¹m
unaware of MLO loading u-boot from SDCard if u-boot is missing from eMMC.
Do you have a reference for this? The only option to load from SDCard if
it exists is in the u-boot environment bootcmd which is here:

bootcmd=gpio set 53; i2c mw 0x24 1 0x3e; run findfdt; mmc dev 0; if mmc
rescan ;then echo micro SD card found;setenv mmcdev 0;else echo No micro
SD card found,
setting mmcdev to 1;setenv mmcdev 1;fi;setenv bootpart ${mmcdev}:2;mmc
dev ${mmcdev}; if mmc rescan; then gpio set 54; echo SD/MMC found on
device ${mmcdev};if
run loadbootenv; then echo Loaded environment from ${bootenv};run
importbootenv;fi;if test -n $uenvcmd; then echo Running uenvcmd ...;run
uenvcmd;fi;gpio set 5
5; if run loaduimage; then gpio set 56; run loadfdt;run mmcboot;fi;fi;

So mmcdev=0 if the SDCard is installed and mmcdev=1 if the SDCard in
missing, so bootpart=0:2 if the SDCard is installed and bootpart=1:2 if
the SDCard is missing. If the SDCard is installed, uEnv.txt is loaded from
the SDCard, which is where all the customization takes place.

What am I missing?

Regards,
John

Section 5.3.5 (Boot Modes) of the Beaglebone Black SRM documents this
behavior. It's a feature of the ROM bootloader peripheral search order.

-Matt

Hi,
Thank you for that clarification.
Does the boot modes (if altered) survive if the power is removed and
reapplied?

Well they go back to factory default..

This is why every "flashing" guide says pull the power.. As weird
things happen when you "soft" reboot after flashing the eMMC...

The uEnv.txt is located in the boot partition, on both eMMC and uSD
card.
What line specifies in wich order to boot?

In most cases it's more then just "one" line..

I was wondering why the default is to first try eMMC even when an uSD
card
is detected.

Because you are over thinking it. The bootrom is "simple" and it is
setup to read the eMMC first.

Here's the boot order:

bootrom loads MLO from eMMC (if that fails it moves to microSD (hence
dd if=/dev/zero to eMMC makes booting from microSD work..)
MLO loads u-boot.img from eMMC
u-boot.img first looks at microSD for uEnv.txt, reads that file in.

Hey Robert,

Now you have confused me and I thought I understood how the boot process
worked.

If the boot button isn¹t pressed, bootrom loads MLO from eMMC and this
loads u-boot from eMMC. I¹m unaware of bootrom loading MLO from SDCard if

> MLO is missing from eMMC. Do you have a reference for this? Also, I¹m

unaware of MLO loading u-boot from SDCard if u-boot is missing from eMMC.
Do you have a reference for this?

This why when you dd if=/dev/zero of=/(eMMC) it will always boot from microSD..

Page 6:
https://github.com/CircuitCo/BeagleBone-Black/blob/master/BBB_SCH.pdf

uSD Boot grounds SYS_BOOT3:

SYSBOOT:
11100b : MMC1, MMC0, UART0, USB0
11000b : SPI0, MMC0, USB0, UART0

where: MMC1 = eMMC & MMC0 = microSD

If the bootloader doesn't find the magic header in MLO, it moves on to
the next boot device..

it's old, but they talk about it here too:
http://omappedia.org/wiki/Bootloader_Project#First_Stage_Boot

The only option to load from SDCard if
it exists is in the u-boot environment bootcmd which is here:

bootcmd=gpio set 53; i2c mw 0x24 1 0x3e; run findfdt; mmc dev 0; if mmc
rescan ;then echo micro SD card found;setenv mmcdev 0;else echo No micro
SD card found,
setting mmcdev to 1;setenv mmcdev 1;fi;setenv bootpart ${mmcdev}:2;mmc
dev ${mmcdev}; if mmc rescan; then gpio set 54; echo SD/MMC found on
device ${mmcdev};if
run loadbootenv; then echo Loaded environment from ${bootenv};run
importbootenv;fi;if test -n $uenvcmd; then echo Running uenvcmd ...;run
uenvcmd;fi;gpio set 5
5; if run loaduimage; then gpio set 56; run loadfdt;run mmcboot;fi;fi;

So mmcdev=0 if the SDCard is installed and mmcdev=1 if the SDCard in
missing, so bootpart=0:2 if the SDCard is installed and bootpart=1:2 if
the SDCard is missing. If the SDCard is installed, uEnv.txt is loaded from
the SDCard, which is where all the customization takes place.

Look closely, there's actually an annoying bug in that... it's only
checking for the existence of mmcdev 0, so if you have a blank card it
gets stuck...

I have mine setup as the following..

+ "mmc dev 0; if mmc rescan ; then " \
+ "gpio set 54; " \
+ "setenv mmcdev 0; " \
+ "echo SD/MMC found on device ${mmcdev}; " \
+ "if run loadbootenv; then " \
+ "run importbootenv; " \
+ "fi; " \
+ "gpio set 55; " \
+ "echo Checking if uenvcmd is set ...;" \
+ "if test -n $uenvcmd; then " \
+ "gpio set 56; " \
+ "echo Running uenvcmd ...; " \
+ "run uenvcmd;" \
+ "fi; " \
+ "echo; echo uenvcmd was not defined in uEnv.txt ...;
echo trying eMMC (BeagleBone Black) ...; echo;" \
+ "fi;" \
+ "mmc dev 1; if mmc rescan ; then " \
+ "gpio set 54; " \
+ "setenv mmcdev 1; " \
+ "echo SD/MMC found on device ${mmcdev}; " \
+ "if run loadbootenv; then " \
+ "run importbootenv; " \
+ "fi; " \
+ "gpio set 55; " \
+ "echo Checking if uenvcmd is set ...;" \
+ "if test -n $uenvcmd; then " \
+ "gpio set 56; " \
+ "echo Running uenvcmd ...; " \
+ "run uenvcmd;" \
+ "fi; " \
+ "echo; echo uenvcmd was not defined in uEnv.txt ...;
echo halting ...; echo;" \
+ "fi;" \

This way you can have a card in the microSD (blank/formated/etc..) and
the only way to boot it is with "uenvcmd" set somewhere.. Of course it
can still lockup if the eMMC's uenvcmd is also not set..

Regards,

Hey Robert,

Now you have confused me and I thought I understood how the boot process
worked.

If the boot button isn¹t pressed, bootrom loads MLO from eMMC and this
loads u-boot from eMMC. I¹m unaware of bootrom loading MLO from SDCard
if

> MLO is missing from eMMC. Do you have a reference for this? Also, I¹m

unaware of MLO loading u-boot from SDCard if u-boot is missing from
eMMC.
Do you have a reference for this?

This why when you dd if=/dev/zero of=/(eMMC) it will always boot from
microSD..

Page 6:
https://github.com/CircuitCo/BeagleBone-Black/blob/master/BBB_SCH.pdf

uSD Boot grounds SYS_BOOT3:

SYSBOOT:
11100b : MMC1, MMC0, UART0, USB0
11000b : SPI0, MMC0, USB0, UART0

where: MMC1 = eMMC & MMC0 = microSD

If the bootloader doesn't find the magic header in MLO, it moves on to
the next boot device..

it's old, but they talk about it here too:
http://omappedia.org/wiki/Bootloader_Project#First_Stage_Boot

The only option to load from SDCard if
it exists is in the u-boot environment bootcmd which is here:

bootcmd=gpio set 53; i2c mw 0x24 1 0x3e; run findfdt; mmc dev 0; if mmc
rescan ;then echo micro SD card found;setenv mmcdev 0;else echo No micro
SD card found,
setting mmcdev to 1;setenv mmcdev 1;fi;setenv bootpart ${mmcdev}:2;mmc
dev ${mmcdev}; if mmc rescan; then gpio set 54; echo SD/MMC found on
device ${mmcdev};if
run loadbootenv; then echo Loaded environment from ${bootenv};run
importbootenv;fi;if test -n $uenvcmd; then echo Running uenvcmd ...;run
uenvcmd;fi;gpio set 5
5; if run loaduimage; then gpio set 56; run loadfdt;run mmcboot;fi;fi;

So mmcdev=0 if the SDCard is installed and mmcdev=1 if the SDCard in
missing, so bootpart=0:2 if the SDCard is installed and bootpart=1:2 if
the SDCard is missing. If the SDCard is installed, uEnv.txt is loaded
from
the SDCard, which is where all the customization takes place.

Look closely, there's actually an annoying bug in that... it's only
checking for the existence of mmcdev 0, so if you have a blank card it
gets stuck...

I have mine setup as the following..

+ "mmc dev 0; if mmc rescan ; then " \
+ "gpio set 54; " \
+ "setenv mmcdev 0; " \
+ "echo SD/MMC found on device ${mmcdev}; " \
+ "if run loadbootenv; then " \
+ "run importbootenv; " \
+ "fi; " \
+ "gpio set 55; " \
+ "echo Checking if uenvcmd is set ...;" \
+ "if test -n $uenvcmd; then " \
+ "gpio set 56; " \
+ "echo Running uenvcmd ...; " \
+ "run uenvcmd;" \
+ "fi; " \
+ "echo; echo uenvcmd was not defined in uEnv.txt ...;
echo trying eMMC (BeagleBone Black) ...; echo;" \
+ "fi;" \
+ "mmc dev 1; if mmc rescan ; then " \
+ "gpio set 54; " \
+ "setenv mmcdev 1; " \
+ "echo SD/MMC found on device ${mmcdev}; " \
+ "if run loadbootenv; then " \
+ "run importbootenv; " \
+ "fi; " \
+ "gpio set 55; " \
+ "echo Checking if uenvcmd is set ...;" \
+ "if test -n $uenvcmd; then " \
+ "gpio set 56; " \
+ "echo Running uenvcmd ...; " \
+ "run uenvcmd;" \
+ "fi; " \
+ "echo; echo uenvcmd was not defined in uEnv.txt ...;
echo halting ...; echo;" \
+ "fi;" \

This way you can have a card in the microSD (blank/formated/etc..) and
the only way to boot it is with "uenvcmd" set somewhere.. Of course it
can still lockup if the eMMC's uenvcmd is also not set..

Again, Robert saves the day. Thanks for the help.

Robert,

My BBB absolutely must default to booting from the uSD. I know I could short the boot switch, or move pull-up/down resistors, or create a hardware switch gated from reset, but I don’t want to lose hardware compatibility with other BBB boards, or give up the option of manually booting from eMMC occasionally. The code you suggest here sounds perfect - but I’m not positive what to do with it. From the formatting of the text, I suspect it is intended to be compiled into a new u-boot.img and MLO image, but I’m not sure how to do that.

Before I spend hours learning how, is there a chance I could just insert the basic ideas into my uEnv.txt as “mmcboot=mmc dev 0; if mmc rescan ; then …”? It does look like uEnv.txt is read before the mmcboot command runs…

If so, does it have to be run together into a single ‘;’ separated line, or can I leave the ‘’ line continuations in to make it more readable?

I suspect uEnv.txt would not want the double-quotes? Or Windows line endings…

If that is totally hopeless, can you suggest a tutorial on building a new u-boot.img and MLO with this code?

Thank you for any clues,

Loren

I can address only the part about the Windows line endings. U-boot only works with Unix line endings.
I had edited my uEnv.txt file on my Windows box and couldn’t understand why it was complaining
about a variable; eventually I guessed that it was because of the carriage return. As soon as I opened
the file with vi on linux I could see them. The u-boot documentation does caution the reader about
its fussiness.

Robert,

My BBB absolutely must default to booting from the uSD. I know I could short the boot switch, or move pull-up/down resistors, or create a hardware switch gated from reset, but I don’t want to lose hardware compatibility with other BBB boards, or give up the option of manually booting from eMMC occasionally. The code you suggest here sounds perfect - but I’m not positive what to do with it. From the formatting of the text, I suspect it is intended to be compiled into a new u-boot.img and MLO image, but I’m not sure how to do that.

Before I spend hours learning how, is there a chance I could just insert the basic ideas into my uEnv.txt as “mmcboot=mmc dev 0; if mmc rescan ; then …”? It does look like uEnv.txt is read before the mmcboot command runs…

If so, does it have to be run together into a single ‘;’ separated line, or can I leave the ‘’ line continuations in to make it more readable?

I suspect uEnv.txt would not want the double-quotes? Or Windows line endings…

If that is totally hopeless, can you suggest a tutorial on building a new u-boot.img and MLO with this code?

Thank you for any clues,

See if this helps:

http://processors.wiki.ti.com/index.php/AM335x_U-Boot_User’s_Guide

Otherwise, read the u-boot manual.

Regards,
John

My long but successful “learning experience” is reported in:
https://groups.google.com/forum/#!topic/beagleboard/zNtdwtPf2Q8

Definitely not simple, but possible… Without making any changes to the eMMC installation!

Jumping in a little late perhaps but my concern is slightly relevant to the discussion here.

Nelson desribes the boot order:

bootrom loads MLO from eMMC (if that fails it moves to microSD)
MLO loads u-boot.img from eMMC
u-boot.img first looks at microSD for uEnv.txt, reads that file in.

I’d like to reverse that last step and make it to default to uEnv.txt from the eMMC.

But I have no idea how to modify u-boot.img. What should I be reading?

Or is there a u-boot.img that exists already that will allow me to boot off of the eMMC even if the flasher uSD is present (which I understand is the HW default)?

Thanks,
Louis

Ah finally got my toolchain to work with these instructions: http://eewiki.net/display/linuxonarm/BeagleBone+Black#BeagleBoneBlack-Bootloader:U-Boot

The u-boot.img I compiled out of there works just fine - so now let’s see what happens when I hack it :smiley:

So it ended up being ridiculously easy- thank you for all your work, Robert!

I just switched the two if statements in the CONFIG_BOOTCOMMAND definition in am335x_evm.h (u-boot/include/configs) so that mmc dev 1 was attempted first. Now I have this u-boot.img on my eMMC and the original on the SD card. Now I can leave the SD card in there and only boot from it when I hold down S2 :slight_smile:

Best,
Louis