How to prevent booting from SD Card?

I have a Debian image loaded on my BBB’s eMMC, and I would like to prevent it booting from the SD Card if it is present even if the SD Card has a valid system installed on it, UNLESS I press the User Boot (S2) switch. As I understand it, S2 only controls which U-Boot (uEnv.txt) is initially loaded, but by default U-Boot will always then proceed to boot from the SD Card if it has a valid image (regardless of the state of S2). Is there something I can add to my eMMC’s uEnv.txt that will override this default U-Boot behavior and force it to continue loading from eMMC unless the S2 switch is still being held?

Nope, nothing out of the box, just take the u-boot patch and rebuild
it with your modifications.

Right now, the only way it will ignore a "valid" microSD card is if
you remove the "uenvcmd" variable define from your uEnv.txt on the
microSD card.

Regards,

Thank you for the fast response, Robert.

I have not built U-Boot before. Can you please point me to any documentation on getting/building the source and the patch you referred to?

Thank you!

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

The patch linked there is the same one you will find stored under
/opt/source/ in the debian image.

Regards,