AM335 uboot启动参数

Posted xgbing

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了AM335 uboot启动参数相关的知识,希望对你有一定的参考价值。

include/env_default.h中:

#elif defined(DEFAULT_ENV_INSTANCE_STATIC)
static char default_environment[] = 
#else
const uchar default_environment[] = 
#endif
代码略
#ifdef	CONFIG_EXTRA_ENV_SETTINGS
	CONFIG_EXTRA_ENV_SETTINGS
#endif
代码略

CONFIG_EXTRA_ENV_SETTINGS定义在include/configs/am335x_evm.h中:

#define CONFIG_EXTRA_ENV_SETTINGS \\
	"loadaddr=0x80200000\\0" \\
	"kloadaddr=0x80007fc0\\0" \\
	"fdtaddr=0x80F80000\\0" \\
	"fdt_high=0xffffffff\\0" \\
	"rdaddr=0x81000000\\0" \\
	"bootfile=uImage\\0" \\
	"fdtfile=\\0" \\
	"console=ttyO0,115200n8\\0" \\
	"optargs=\\0" \\
	"mtdids=" MTDIDS_DEFAULT "\\0" \\
	"mtdparts=" MTDPARTS_DEFAULT "\\0" \\
	"dfu_alt_info_mmc=" DFU_ALT_INFO_MMC "\\0" \\
	"dfu_alt_info_emmc=rawemmc mmc 0 3751936\\0" \\
	"dfu_alt_info_nand=" DFU_ALT_INFO_NAND "\\0" \\
	"mmcdev=1\\0" \\
	"mmcroot=/dev/mmcblk0p4 rw\\0" \\
	"mmcrootfstype=ext4 rootwait\\0" \\
	"nandroot=ubi0:rootfs rw ubi.mtd=7,2048\\0" \\
	"nandrootfstype=ubifs rootwait=1\\0" \\
	"nandsrcaddr=0x280000\\0" \\
	"nandimgsize=0x500000\\0" \\
	"rootpath=/export/rootfs\\0" \\
	"nfsopts=nolock\\0" \\
	"static_ip=$ipaddr:$serverip:$gatewayip:$netmask:$hostname" \\
		"::off\\0" \\
	"ramroot=/dev/ram0 rw ramdisk_size=65536 initrd=$rdaddr,64M\\0" \\
	"ramrootfstype=ext2\\0" \\
	"ip_method=off\\0" \\
	"bootargs_defaults=setenv bootargs " \\
		"console=$console " \\
		"$optargs\\0" \\
	"mmcargs=run bootargs_defaults;" \\
		"setenv bootargs $bootargs " \\
		"androidboot.console=ttyO0 " \\
		"root=$mmcroot " \\
		"rootfstype=$mmcrootfstype emmcboot init=/init ip=$ip_method\\0" \\
	"nandargs=setenv bootargs console=$console " \\
		"$optargs " \\
		"root=$nandroot " \\
		"rootfstype=$nandrootfstype\\0" \\
	"spiroot=/dev/mtdblock4 rw\\0" \\
	"spirootfstype=jffs2\\0" \\
	"spisrcaddr=0xe0000\\0" \\
	"spiimgsize=0x362000\\0" \\
	"spibusno=0\\0" \\
	"spiargs=setenv bootargs console=$console " \\
		"$optargs " \\
		"root=$spiroot " \\
		"rootfstype=$spirootfstype\\0" \\
	"netargs=setenv bootargs console=$console " \\
		"$optargs " \\
		"root=/dev/nfs " \\
		"nfsroot=$serverip:$rootpath,$nfsopts rw " \\
		"ip=dhcp\\0" \\
	"bootenv=uEnv.txt\\0" \\
	"loadbootenv=fatload mmc $mmcdev:3 $loadaddr $bootenv\\0" \\
	"importbootenv=echo Importing environment from mmc ...; " \\
		"env import -t $loadaddr $filesize\\0" \\
	"ramargs=setenv bootargs console=$console " \\
		"$optargs " \\
		"root=$ramroot " \\
		"rootfstype=$ramrootfstype\\0" \\
	"loadramdisk=fatload mmc $mmcdev:4 $rdaddr ramdisk.gz\\0" \\
	"loaduimagefat=fatload mmc $mmcdev:3 $kloadaddr $bootfile\\0" \\
	"loaduimage=fatload mmc $mmcdev $kloadaddr $bootfile\\0" \\	
	"mmcboot=echo Booting from mmc ...; " \\
		"run mmcargs; " \\
		"bootm $kloadaddr\\0" \\
	"nandboot=echo Booting from nand ...; " \\
		"run nandargs; " \\
		"nand read $loadaddr $nandsrcaddr $nandimgsize; " \\
		"bootm $loadaddr\\0" \\
	"spiboot=echo Booting from spi ...; " \\
		"run spiargs; " \\
		"sf probe $spibusno:0; " \\
		"sf read $loadaddr $spisrcaddr $spiimgsize; " \\
		"bootm $loadaddr\\0" \\
	"netboot=echo Booting from network ...; " \\
		"setenv autoload no; " \\
		"dhcp; " \\
		"tftp $loadaddr $bootfile; " \\
		"run netargs; " \\
		"bootm $loadaddr\\0" \\
	"ramboot=echo Booting from ramdisk ...; " \\
		"run ramargs; " \\
		"bootm $loadaddr\\0" \\
	"findfdt="\\
		"if test $board_name = A335BONE; then " \\
			"setenv fdtfile am335x-bone.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\\0"

这么多参数不是所有的都是有用的。

当uboot自动启动内核时,调用的命令是bootcmd,内核参数是bootargs

先看bootcmd,在include/env_default.h中:

#ifdef	CONFIG_BOOTCOMMAND
	"bootcmd="	CONFIG_BOOTCOMMAND		"\\0"
#endif

CONFIG_BOOTCOMMAND的定义在am335x_evm.h中:

#define CONFIG_BOOTCOMMAND \\
	"mmc dev $mmcdev; if mmc rescan; then " \\
		"echo SD/MMC found on device $mmcdev;" \\
		"if run loadbootenv; then " \\    看上面loadbootenv的定义,会发现这条命令会启动失败
			"echo Loaded environment from $bootenv;" \\
			"run importbootenv;" \\
		"fi;" \\
		"if test -n $uenvcmd; then " \\
			"echo Running uenvcmd ...;" \\
			"run uenvcmd;" \\
		"fi;" \\
		"if run loaduimagefat; then " \\     这条会启动成功,看这条
			"run mmcboot;" \\          这条命令会执行
		"elif run loaduimage; then " \\
			"run mmcboot;" \\
		"else " \\
			"echo Could not find $bootfile ;" \\
		"fi;" \\
	"else " \\
		"run nandboot;" \\
	"fi;" \\

loaduimagefat的定义:

loaduimagefat=fatload mmc $mmcdev:3 $kloadaddr $bootfile

当命令执行run mmcboot时,

	"mmcboot=echo Booting from mmc ...; " \\
		"run mmcargs; " \\
		"bootm $kloadaddr\\0" \\

当执行run mmcargs,

	"mmcargs=run bootargs_defaults;" \\
		"setenv bootargs $bootargs " \\
		"androidboot.console=ttyO0 " \\
		"root=$mmcroot " \\
		"rootfstype=$mmcrootfstype emmcboot init=/init ip=$ip_method\\0" \\

这里使用setenv bootargs设置了内核启动参数。

启动参数是:

console=ttyO0,115200n8 androidboot.console=ttyO0 root=/dev/mmcblk0p4 rw rootfstype=ext4 rootwait emmcboot init=/init ip=off

以上是关于AM335 uboot启动参数的主要内容,如果未能解决你的问题,请参考以下文章

am335x uboot启动流程分析

am335x uboot 点亮LED

am335x uboot2016.05 (MLO u-boot.img)执行流程(转)

am335x uboot, kernel 编译

AM335x移植linux内核_转

使用CCS调试基于AM335X的SPLUboot(原创)