Skip to content

Instantly share code, notes, and snippets.

@17twenty
Created May 17, 2012 12:33
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save 17twenty/2718613 to your computer and use it in GitHub Desktop.
Save 17twenty/2718613 to your computer and use it in GitHub Desktop.
Force Beaglebone to boot your settings on powerup from uEnv.txt
So the Beaglebone uses the file uEnv.txt to store settings as it doesn't have any NAND allocated to do it with, by
default the file is pretty empty save from the line:
optargs=run_hardware_tests quiet
You may have read a number of things about boot.scr etc - ignore it, it's not correct.
The bootcmd is hardwired in uboot to do the following (i've seperated it all out to make things clearer) - you can see it by
interrupting the bootsequence and performing a 'printenv'.
bootcmd=
if mmc rescan;
then echo SD/MMC found on device ${mmc_dev};
if run loadbootenv;
then echo Loaded environment from ${bootenv};
run importbootenv;
fi;
if test -n $uenvcmd;
then echo Running uenvcmd ...;
run uenvcmd;
fi;
if run mmc_load_uimage_ext4;
then run mmc_args;
bootm 0x80007fc0;
fi;
fi;
run nand_boot;
The thing we're interested is where it detects an SD card (which it should do). I've seen a lot of posts where people
have overridden variables including bootcmd, this is redherring. You can't do that here as bootcmd is already in
process by the time you're uEnv.txt is read in. The lines of interest to us are:
if test -n $uenvcmd;
then echo Running uenvcmd ...;
run uenvcmd;
fi;
This shows a test for the variable uenvcmd and that it is executed if found. So we can simply override that for our
purposes. My uEnv.txt ended up looking as follows:
autoload=no
serverip=10.0.0.1
ipaddr=10.0.0.3
bootargs=console=ttyO0,115200n8 root=/dev/nfs rw nfsroot=10.0.0.1:/home/nick/Documents/BeagleBone/git-rootfs ip=10.0.0.3:::::eth0
uenvcmd=echo "Booting from Network"; dcache off; tftp ${loadaddr}; bootm ${loadaddr}
It's worth noting that this can cause you to lose access to your SD card (I'm not sure why yet but it doesn't show up
anymore with the kernel and rootfs I'm using). If that's the case, simply interrupt u-boot and enter the commands:
mmc rescan
run loadbootenv
run importbootenv;
run mmc_load_uimage_ext4;
run mmc_args;
bootm 0x80007fc0;
Which you'll recognise from the previous bootcmd. That's it, you'll be back to using the default kernel on the SD
card which will get exported to as a USB drive at which point you can mess with the uEnv.txt again.
@grissiom
Copy link

Thank you very much for your Gist. It is the only material that help me with the meaning of uEnv.txt

However, the bootargs in your uEnv.txt does not work for me. After many trials and errors, I found this uEnv.txt works for me:

ethaddr=C8:A0:30:AD:55:BF
ipaddr=192.168.7.2
serverip=192.168.7.1
rootpath=/srv/rootfs
nfsargs=setenv bootargs console=${console} root=/dev/nfs nfsroot=${serverip}:${rootpath} rw ip=192.168.7.2:192.168.7.1:192.168.7.1:255.255.255.0::eth0:off
uenvcmd=echo "Booting from Network"; run nfsargs; echo ${bootargs}; nfs ${loadaddr} ${rootpath}/boot/uImage; nfs ${fdtaddr} ${rootpath}/boot/${fdtfile}; bootm ${loadaddr} - ${fdtaddr}

My U-Boot version is 2013.04-dirty. I hope that could help.

@jesperhn
Copy link

jesperhn commented Nov 6, 2013

Hi. Thanks alot! Make it a lot clearer with uEnv.txt with your help.
I am still struggling with my bootargs tho, my file looks as follows:

bootfile=uImage-dtb.am335x-boneblack
autoload=no
serverip=192.168.0.10
ipaddr=192.168.0.20
netmask=255.255.255.0
static_ip=${ipaddr}:${serverip}:${netmask}:${hostname}::off
rootpath=/home/exports/cloud9
nfsopts=nolock
nfsargs=setenv bootargs console=${console} root=/dev/nfs nfsroot=${serverip}:${rootpath} rw ip=192.168.0.20:::::eth0
uenvcmd=echo "Booting from Network"; dcache off; tftp ${loadaddr}; bootm ${loadaddr}

Any help or hints would be appriciated

@georgecatalin
Copy link

You are great, man. Thank you.
Excellent piece of article,a fantastic all-through understanding about uEnv.txt.

Keep it up.

All the best to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment