2014年10月3日 星期五

{Banana Pi][Sunxi] U-boot Environment Variables and Something more...

===murmur begin===
not now ===murmur end===

Increase console I/O buffer size

(U-Boot 2014.04-10694)
In order to modify default environment variable, specifically 'loadkernel', I found that it's impossible to change the variable by 'env set' since the console cannot accept command line more than 256(?) characters.

console I/O buffer size is defined by CONFIG_SYS_CBSIZE at include/configs/sunxi-common.h

the changes are like:
#if 0 /* RR, increase console buffer size */
#define CONFIG_SYS_CBSIZE    256    /* Console I/O Buffer Size */
#define CONFIG_SYS_PBSIZE    384    /* Print Buffer Size */
#else

#define CONFIG_SYS_CBSIZE    512    /* Console I/O Buffer Size */
#define CONFIG_SYS_PBSIZE    (CONFIG_SYS_CBSIZE + 128)    /* Print Buffer Size */
#endif
Note: CONFIG_SYS_PBSIZE has better to be calculated by CONFIG_SYS_CBSIZE plus CONFIG_SYS_PROMPT and some bonus value, like 16 in this case.

Reset to default environment variables


to reset environment variables to default:
env default -f -a

 to modify default environment variables/parameters:


starts at ${uboot_dir}/include/env_default.h and
${uboot_dir}/include/configs/sunxi-common.h

look for CONFIG_EXTRA_ENV_SETTINGS.


Concise environment variables


default environment parameters are something like:
autoboot=run loadkernel && run setargs && true && bootm 0x48000000
baudrate=115200
boot_ram=saved_stdout=$stdout;setenv stdout nc;if iminfo 0x41000000; then true; setenv stdout $saved_stdout; source 0x41000000;else setenv stdout $saved_stdout;fi
bootcmd=if run loadbootenv; then echo Loaded environment from ${bootenv};env import -t ${scriptaddr} ${filesize};fi;if test -n "${uenvcmd}"; then echo Running uenvcmd ...;run uenvcmd;fi;if run loadbootscr; then echo Jumping to ${bootscr};source ${scriptaddr};fi;run autoboot;
bootdelay=2
bootenv=uEnv.txt
bootm_size=0x10000000
bootscr=boot.scr
console=ttyS0,115200
device=mmc
ethact=dwmac.1c50000
kernel=uImage
loadbootenv=fatload $device $partition $scriptaddr ${bootenv} || ext2load $device $partition $scriptaddr boot/${bootenv} || ext2load $device $partition $scriptaddr ${bootenv}
loadbootscr=fatload $device $partition $scriptaddr ${bootscr} || ext2load $device $partition $scriptaddr boot/${bootscr} ||ext2load $device $partition $scriptaddr ${bootscr}
loadkernel=if bootpath=/boot/ && ext2load $device $partition 0x43000000 ${bootpath}${script} && ext2load $device $partition 0x48000000 ${bootpath}${kernel};then true; elif bootpath=/ && fatload $device $partition 0x43000000 ${script} && fatload $device $partition 0x48000000 ${kernel};then true; elif bootpath=/ && ext2load $device $partition 0x43000000 ${bootpath}${script} && ext2load $device $partition 0x48000000 ${bootpath}${kernel};then true; else false;fi
loglevel=8
panicarg=panic=10
partition=0:1
script=script.bin
scriptaddr=0x44000000
setargs=if test -z \\"$root\\"; then if test \\"$bootpath\\" = "/boot/"; then root="/dev/mmcblk0p1 rootwait"; else root="/dev/mmcblk0p2 rootwait"; fi; fi; setenv bootargs console=${console} root=${root} loglevel=${loglevel} ${panicarg} ${extraargs}
stderr=serial
stdin=serial
stdout=serial
abviously, those are too much for studying. If using the image placed from lemark (pretty strange since I cannot find the link in www.bananapi.org), i.e. with files of script.bin, uEnv.txt, and uImage at 1st partition of SD card, you can use the simple version of environment settings as below:

baudrate=115200
bootcmd=if run loadbootenv; then echo Loaded environment from ${bootenv};env import -t ${scriptaddr} ${filesize};fi;if test -n "${uenvcmd}"; then echo Running uenvcmd ...;run uenvcmd;fi
bootdelay=2
bootenv=uEnv.txt
bootscr=boot.scr
console=ttys0,115200
device=mmc
ethact=dwmac.1c50000
ethaddr=02:8b:03:01:93:3e
filesize=158
kernel=uimage
loadbootenv=fatload $device $partition $scriptaddr ${bootenv} || ext2load $device $partition $scriptaddr boot/${bootenv} || ext2load $device $partition $scriptaddr ${bootenv}
loglevel=8
panicarg=panic=10
partition=0:1
script=script.bin
scriptaddr=0x44000000
stderr=serial
stdin=serial
stdout=serial
while the content of uEnv.txt is
aload_script=fatload $device $partition 0x43000000 /script.bin;
aload_kernel=fatload $device $partition 0x48000000 /uImage;bootm 0x48000000
uenvcmd=run aload_script aload_kernel
bootargs=console=ttyS0,115200 console=tty0 disp.screen0_output_mode=EDID:1280x720p60 hdmi.audio=EDID:0 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
Note that uEnv.txt is loaded to 0x44000000, script is loaded to 0x43000000, uImage is loaded to 0x48000000, as u-boot itself is running at 0x4a000000 base (see include/configs/sunxi-common.h)

TBD: need to trace FEL to u-boot procedure? seems FEL using cache as TEXT.



沒有留言:

張貼留言