undo boot from sdcard? need to boot from emmc while an sdcard is inserted

I booted an image on sdcard by pressing the user/boot button. I then flashed the image to the emmc, which works fine. The system boots properly from emmc when there is no sdcard inserted, but if I insert an sdcard I can no longer boot from emmc.

I have insterted an sdcard without boot flag and it wont boot, I have inserted one that was bootable and it boots the sdcard.

Is there a way to disable the boot from sdcard?

Assuming that you have a microSD card with the /dev/sd1 partition formatted as vfat,
Copy a file with the following contents to /dev/sd1/uEnv.txt

     mmcdev=1
     bootpart=1:2
     mmcroot=/dev/mmcblk1p2 ro

- and when you reboot, the microSD should not cause a hang, but appear in the file system.

At least this works for me.

Chad, it’s not working for me but I don’t have a micro adapter so I’ve been working on mmcblk1

so I found a usb adapter. I made a bootable primary partition, 64MB, formatted vfat, and made a file uEnv.txt, no go. Still hangs at boot.

mmcdev=1
bootpart=1:2
mmcroot=/dev/mmcblk1p2 ro

What does your second partition look like?
I formatted my microSD with

     mkfs -t vfat -F 32 -n BoneBoot /dev/sda1
     mkfs -V -t ext4 -j -L BoneData /dev/sda2

no go, I mirrored your example exactly.

no go, I mirrored your example exactly.

Why don’t you enter the commands manually in u-boot? Do the following:

U-Boot# printenv

Scroll up and look at the “bootcmd” line. Each command is separated by a “;”. Use “echo $” to see the contents of any variable. This will help you understand what is going wrong.

BTW, if you want to boot from eMMC, you can simply modify the uEnv.txt on your eMMC so that it does not query the SDCard. Just remove the part that does “setenv mmcdev 0"

Regards,
John

If I do this, can I still boot from sdcard by holding the user boot button?

also, I dont have this: “setenv mmcdev 0"

also, I dont have this: “setenv mmcdev 0"

The boot button controls the SYS_BOOT2 pin on the processor which is normally high (boot button not pressed) and loads u-boot from the eMMC. Then, u-boot runs the scripts defined in it’s environment. Use printenv to see the env settings. If you are using minicom, for your console, press ctrl a w to enable line wrap (or the equivalent command for putty, etc). enter the printenv command and then scroll up to see the bootcmd which should look something like this:

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 55; if run loaduimage; then gpio set 56; run loadfdt;run mmcboot;fi;fi;

While this looks complicated, it really isn’t. It starts of by turning on an LED, runs a command findfdt which is defined as:

findfdt=if test $board_name = A335BONE; then setenv fdtfile am335x-bone.dtb; fi; if test $board_name = A335BNLT; then setenv fdtfile am335x-boneblack.dtb; fi; if test $board_name = A33515BB; then setenv fdtfile am335x-evm.dtb; fi; if test $board_name = A335X_SK; then setenv fdtfile am335x-evmsk.dtb; fi

Which just sets a variable “fdtfile” to " am335x-boneblack.dtb”

To prove this, enter these commands in u-boot:

run findfdt
echo $findfdt

Continuing with bootcmd, it test to see if the SDCard is installed (if mmc rescan) and if it is, “mmcdev” is set to “0” (BTW, eMMC is mmcdev 1).

Reading further, the script then runs loadbootenv, which loads the uEnv.txt, which it loads from SDCard if one is installed ($mmcdev = 0) or it loads from eMMC if no SDCard is installed ($mmcdev = 1).

I’ll leave your to read the remainder of the bootcmd script.

BTW, I believe this behavior is baked into u-boot and you have to change u-boot source code to change this behavior. You can only modify u-boot behavior after uEnv.txt is loaded.

Also, when you press the load button, u-boot is read from the SDCard. When the load button isn’t pressed, u-boot is read from the eMMC. So, to answer your question, if you press the boot button, it will always boot from the SDCard.

Regards,
John