-
Notifications
You must be signed in to change notification settings - Fork 3
Fixing Bad U Boot Environment Variables
Rick edited this page Sep 23, 2015
·
7 revisions
Tonight I typed a bad uname_r
for my Beaglebone Black’s /boot/uEnv.txt
parameters, and it took me a long while to figure out how to fix it. These steps seem like ridiculous overkill, so there’s probably an easier way, but I’m writing these down so I don’t forget. (Note: this is with U-Boot 2015.10-rc3-00001-gfb375b5 (Sep 10 2015 - 10:07:48 -0500)).
Boot the BBB, stop in U-Boot.
=> printenv bootcmd
bootcmd=setenv umsmedia 0; gpio set 53; run findfdt; setenv mmcdev 0; setenv bootpart 0:1; run mmcboot;gpio clear 56; gpio clear 55; gpio clear 54; setenv mmcdev 1; setenv bootpart 1:1; run mmcboot;run failumsboot;
=> setenv umsmedia 0; gpio set 53; run findfdt; setenv mmcdev 0; setenv bootpart 0:1; run mmcboot;gpio clear 56; gpio clear 55; gpio clear 54; setenv mmcdev 1; setenv bootpart 1:1; run mmcboot
...bunch of stuff...
Running uname_boot ...
** Invalid partition 2 **
** Invalid partition 3 **
** Invalid partition 4 **
** Invalid partition 5 **
** Invalid partition 6 **
** Invalid partition 7 **
=> printenv
...bunch of stuff...
uname_r=4.1.4-ti-r15
...
=> set uname_r 4.1.6-ti-r16 // or whatever you need it to be
=> set mmcpart 1 // Might be something different in your case
=> setenv bootpart ${mmcdev}:${mmcpart};
=> setenv mmcroot /dev/mmcblk${mmcdev}p${mmcpart} ro
=> run uname_boot
The full mmcboot command is this:
mmc dev ${mmcdev};
if mmc rescan;
then gpio set 54;
setenv bootpart ${mmcdev}:1;
if test -e mmc ${bootpart} /etc/fstab;
then setenv mmcpart 1;
fi;
echo Checking for: /uEnv.txt ...;
if test -e mmc ${bootpart} /uEnv.txt;
then if run loadbootenv;
then gpio set 55;
echo Loaded environment from ${bootenv};
run importbootenv;
fi;
if test -n ${cape};
then if test -e mmc ${bootpart} ${fdtdir}/${fdtbase}-${cape}.dtb;
then setenv fdtfile ${fdtbase}-${cape}.dtb;
fi;
echo using: $fdtfile...;
fi;
echo Checking if uenvcmd is set ...;
if test -n ${uenvcmd};
then gpio set 56;
echo Running uenvcmd ...;
run uenvcmd;
fi;
echo Checking if client_ip is set ...;
if test -n ${client_ip};
then if test -n ${dtb};
then setenv fdtfile ${dtb};
echo using ${fdtfile} ...;
fi;
gpio set 56;
if test -n ${uname_r};
then echo Running nfsboot_uname_r ...;
run nfsboot_uname_r;
fi;
echo Running nfsboot ...;
run nfsboot;
fi;
fi;
echo Checking for: /${script} ...;
if test -e mmc ${bootpart} /${script};
then gpio set 55;
setenv scriptfile ${script};
run loadbootscript;
echo Loaded script from ${scriptfile};
gpio set 56;
run bootscript;
fi;
echo Checking for: /boot/${script} ...;
if test -e mmc ${bootpart} /boot/${script};
then gpio set 55;
setenv scriptfile /boot/${script};
run loadbootscript;
echo Loaded script from ${scriptfile};
gpio set 56;
run bootscript;
fi;
echo Checking for: /boot/uEnv.txt ...;
for i in 1 2 3 4 5 6 7 ;
do setenv mmcpart ${i};
setenv bootpart ${mmcdev}:${mmcpart};
if test -e mmc ${bootpart} /boot/uEnv.txt;
then gpio set 55;
load mmc ${bootpart} ${loadaddr} /boot/uEnv.txt;
env import -t ${loadaddr} ${filesize};
echo Loaded environment from /boot/uEnv.txt;
if test -n ${dtb};
then setenv fdtfile ${dtb};
echo Using: dtb=${fdtfile} ...;
fi;
echo Checking if uname_r is set in /boot/uEnv.txt...;
if test -n ${uname_r};
then gpio set 56;
echo Running uname_boot ...;
setenv mmcroot /dev/mmcblk${mmcdev}p${mmcpart} ro;
run uname_boot;
fi;
fi;
done;
fi;