OK335xS U-boot 环境变量解析

/**************************************************************************************************
 *                                      OK335xS U-boot 环境变量解析
 * 声明:
 *     本文主要是为了知道OK335xS U-boot环境变量设置、如何选择启动方式等等内容。
 *
 *                                                2015-9-28 晴 深圳 南山平山村 曾剑锋
 *************************************************************************************************/
#ifdef CONFIG_ANDROID
#define CON         /**
      * console: kernel终端输出设置为ttyO0、115200n8
      */
    "console=ttyO0,115200n8 earlyprintk androidboot.console=ttyO0\0"     /**
      * In all cases we make use of optargs to control passing in of additional arguments and ip_method to determine how the kernel will deal with networking PRIOR to userspace spawning init.
      */
    "optargs=init=/init\0"     /**
      * 文件系统存放的位置,文进系统存放在emmc中
      */
    "mmcroot=/dev/mmcblk0p2 rw\0"     /**
      * 文件系统的类型是ext4
      */
    "mmcrootfstype=ext4 rootwait\0"     /**
      * 文件系统存放的位置,文进系统存放在nand中
      */
    "nandroot=ubi0:rootfs rw ubi.mtd=7,2048\0"     /**
      * 文件系统的类型是ubifs
      */
    "nandrootfstype=ubifs rootwait=1\0"
#else
    /*"console=ttyO0,115200n8\0" \ */
#define CON         /**
      * console: kernel终端输出设置为ttyO0、115200n8
      */
    "console=ttyO0,115200n8\0"     "optargs=\0"     "mmcroot=/dev/mmcblk0p2 ro\0"     /**
      * 文件系统的类型是ext3
      */
    "mmcrootfstype=ext3 rootwait\0"     "nandroot=ubi0:rootfs rw ubi.mtd=7,2048\0"     "nandrootfstype=ubifs rootwait=1\0"
#endif

#if 1
#define CONFIG_EXTRA_ENV_SETTINGS \
    CON     /**
      * printf("current screen type is `%s`\n",getenv("screentype"));
      * printf("R means Resistor screen,C means Capacitor screen\n");
      * printf("---------------------screen type----------------------\n");
      * printf("0 -- exit to upper menu\n");
      * printf("1 -- Resistor screen\n");
      * printf("2 -- Capacitor screen\n");
      * printf("------------------------------------------------------\n");
      *
      */
    "screentype=R\0"    /**
      * printf("current screen size is `%s`\n",getenv("screensize"));
      * printf("AAAxAAA-B means Binch screen with AAAxAAA pixels\n");
      * printf("---------------------screen type----------------------\n");
      * printf("0 -- exit to upper menu\n");
      * printf("1 -- 480x272-4\n");
      * printf("2 -- 800x480-5\n");
      * printf("3 -- 800x480-7\n");
      * printf("4 -- 800x600-8\n");
      * printf("5 -- 800x600-10\n");
      * printf("------------------------------------------------------\n");
      */
    "screensize=800x600-10\0"    /**
      * load address
      */
    "loadaddr=0x80200000\0"     /**
      * kernel load address
      */
    "kloadaddr=0x80007fc0\0"     "fdtaddr=0x80F80000\0"     "fdt_high=0xffffffff\0"     /**
      * ramdisk address
      */
    "rdaddr=0x81000000\0"     /**
      * boot device
      */
    "bootdev=MMC\0"    /**
      * boot file name
      */
    "bootfile=uImage\0"     "fdtfile=\0"     /**
      * mmc设备可能有几个,选择第0个
      */
    "mmcdev=0\0"     /**
      * nand中内核保存的其实地址,这个需要看nand分区设置,kernel中有一个分区表,下面的update也有对应的值
      */
    "nandsrcaddr=0x280000\0"     /**
      * nand中的kernel的大小
      */
    "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 to determine how the kernel will deal with networking PRIOR to userspace spawning init
      */
    "ip_method=none\0"     "bootargs_defaults=setenv bootargs "         "console=${console} "         "${optargs}\0"     "mmcargs=run bootargs_defaults;"         "setenv bootargs ${bootargs} "         "root=${mmcroot} "         "rootfstype=${mmcrootfstype} ip=${ip_method} screentype=${screentype} screensize=${screensize}\0"     "nandargs=setenv bootargs console=${console} "         "${optargs} "         "root=${nandroot} "         "rootfstype=${nandrootfstype} screentype=${screentype} screensize=${screensize}\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} ${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} ${rdaddr} ramdisk.gz\0"     "loaduimagefat=fatload mmc ${mmcdev} ${kloadaddr} ${bootfile}\0"     "loaduimage=ext2load mmc ${mmcdev}:2 ${kloadaddr} /boot/${bootfile}\0"     "mmcboot=echo Booting from mmc ...; "         "run mmcargs; "         "bootm ${kloadaddr}\0"     "nandboot=echo Booting from nand ...; "         "run nandargs; "         "nandecc hw 2;"        "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"     /**
      * cat drivers/video/cfb_console.c
      *
      * env = getenv("TYPE");
      * if(env)
      *     type = (*env)-‘0‘;
      * else
      *     type = 9;
      *
      * switch(type)
      * {
      * case 0:
      *     title = "Erasing nand chip............";
      *     break;
      * case 1:
      *     title = "Reading MLO from MMC.........";
      *     break;
      * case 2:
      *     title = "Burning MLO to nand..........";
      *     break;
      * case 3:
      *     title = "Reading u-boot.img from MMC..";
      *     break;
      * case 4:
      *     title = "Burning u-boot.img to nand...";
      *     break;
      * case 5:
      *     title = "Reading uImage from MMC......";
      *     break;
      * case 6:
      *     title = "Burning uImage to nand.......";
      *     break;
      * case 7:
      *     title = "Reading ubi.img from MMC.....";
      *     break;
      * case 8:
      *     title = "Burning ubi.img to nand......";
      *     break;
      * default:
      *     title = "env is null..................";
      *     break;
      * }
      */
    /**
      * 这一部分写到nand中的内容,需要和kernel对nand的分区进行对应,貌似这样就可以直接对u-boot、kernel进行更新了
      */
    "auto_update_nand=  echo ---------------Begin update system to Nand---------------;led all on;"                "setenv TYPE 0;nand erase.chip;mmc rescan; "                "setenv TYPE 1;fatload mmc 0 80A00000 nand_MLO;      setenv TYPE 2;nandecc hw 2;nand write.i 80A00000 0 ${filesize}; "                "setenv TYPE 3;fatload mmc 0 80A00000 nand_u-boot.img;setenv TYPE 4;nandecc hw 2;nand write.i 80A00000 80000 ${filesize}; "                "setenv TYPE 5;fatload mmc 0 80A00000 uImage;    setenv TYPE 6;nandecc hw 2;nand write.i 80A00000 280000 ${filesize}; "                "setenv TYPE 7;fatload mmc 0 80A00000 ubi.img;   setenv TYPE 8;nandecc sw;nand write.i 80A00000 780000 ${filesize};"                "echo ;"                "echo --------------Update system to Nand success--------------;led flash all;\0"    "update_nand=  echo ---------------Begin update system to Nand---------------;led all on;"                "setenv TYPE 0;nand erase.chip;mmc rescan; "                "setenv TYPE 1;fatload mmc 0 80A00000 MLO;       setenv TYPE 2;nandecc hw 2;nand write.i 80A00000 0 ${filesize}; "                "setenv TYPE 3;fatload mmc 0 80A00000 u-boot.img;setenv TYPE 4;nandecc hw 2;nand write.i 80A00000 80000 ${filesize}; "                "setenv TYPE 3;fatload mmc 0 80A00000 u-boot.img;setenv TYPE 4;nandecc hw 2;nand write.i 80A00000 80000 ${filesize}; "                "setenv TYPE 5;fatload mmc 0 80A00000 uImage;    setenv TYPE 6;nandecc hw 2;nand write.i 80A00000 280000 ${filesize}; "                "setenv TYPE 7;fatload mmc 0 80A00000 ubi.img;   setenv TYPE 8;nandecc sw;nand write.i 80A00000 780000 ${filesize};"                "echo ;"                "echo --------------Update system to Nand success--------------;led all off;"
/**
  * 虽然这部分代码确认是可运行的,但是感觉真的不合理,后面的源代码貌似更为合理一点
  */
#define CONFIG_BOOTCOMMAND     " if test $bootdev = MMC; then " \                      // bootdev = MMC
        "mmc dev ${mmcdev}; mmc rescan;"\                   // mmcdev = 0, 设置0为当前设备
        "echo SD/MMC found on device ${mmcdev};"         /**
          * loadaddr = 0x80200000
          * bootenv = uEnv.txt
          * loadbootenv = fatload mmc ${mmcdev} ${loadaddr} ${bootenv}
          * importbootenv = echo Importing environment from mmc ...;env import -t $loadaddr $filesize
          */
        "if run loadbootenv; then " \
            "echo Loaded environment from ${bootenv};"             "run importbootenv;"         "fi;"         /**
          * test -n: 字符串的长度非零
          * uenvcmd: 不存在,不用解析
          */
        "if test -n $uenvcmd; then "             "echo Running uenvcmd ...;"             "run uenvcmd;"         "fi;"         /**
          * kloadaddr = 0x80007fc0
          * bootfile = uImage
          * loaduimagefat = fatload mmc ${mmcdev} ${kloadaddr} ${bootfile}
          *
          * mmcboot = echo Booting from mmc ...;run mmcargs;bootm ${kloadaddr}
          * mmcroot = /dev/mmcblk0p2 ro
          * mmcrootfstype = ext3 rootwait
          * ip_method = none
          * screentype = R
          * screensize = 800x600-10
          * mmcargs = run bootargs_defaults;setenv bootargs ${bootargs} root=${mmcroot} rootfstype=${mmcrootfstype} ip=${ip_method} screentype=${screentype} screensize=${screensize}
          */
        "if run loaduimagefat; then "             "run mmcboot;"         /**
          * kloadaddr = 0x80007fc0
          * bootfile = uImage
          * loaduimage = ext2load mmc ${mmcdev}:2 ${kloadaddr} /boot/${bootfile}
          */
        "elif run loaduimage; then "             "run mmcboot;"         "else "             "echo Could not find ${bootfile} ;"         "fi;"     "else "         "run nandboot;"     "fi;" 

/**
  * 个人认为更合理的bootcmd
  */
#define CONFIG_BOOTCOMMAND     /**
      * mmcdev = 0, 设置0为当前设备
      */
    "mmc dev ${mmcdev}; "     /**
      * 重新搜索mmc设备,如果不存在mmc设备,自然就是nand启动了
      */
    "if mmc rescan; then "         "echo SD/MMC found on device ${mmcdev};"         "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 loaduimagefat; then "             "run mmcboot;"         "elif run loaduimage; then "             "run mmcboot;"         "else "             "echo Could not find ${bootfile} ;"         "fi;"     "else "         "run nandboot;"     "fi;" #else
时间: 2024-10-26 12:09:47

OK335xS U-boot 环境变量解析的相关文章

I.MX6 Linux U-boot 环境变量解析

/********************************************************************************** * I.MX6 Linux U-boot 环境变量解析 * 声明: * 在分析完I.MX6 Manufacturing Tool V2 (MFGTool2)中一些内容之后,这里仅仅是 * 为了验证其中的一些想法: * 1. 如何读取不在分区中的uImage,而是在emmc中1M地址上的uImage: * 2. U-boot的loa

新手理解的bash环境变量解析漏洞

p{ line-height:150%; font-size:18px; font-family:fangsong; margin-top:20px; } pre {font-size:15px; background-color:black; color: white;font-family: sans-serif } #refer{background-color:gray;} h1 {font-family:simhei;} 1 环境变量是什么 无论是Windows程序还是Linux程序,

Spring Boot 环境变量读取 和 属性对象的绑定

凡是被Spring管理的类,实现接口 EnvironmentAware 重写方法 setEnvironment 可以在工程启动时,获取到系统环境变量和application配置文件中的变量. 如: @Configuration public class MyWebAppConfigurer implements EnvironmentAware { private static final Logger logger = LoggerFactory.getLogger(MyWebAppConfi

十五、Spring Boot 环境变量读取 和 属性对象的绑定

凡是被spring管理的类,实现接口 EnvironmentAware 重写方法 setEnvironment 可以在工程启动时,获取到系统环境变量和application配置文件中的变量. 如: @Configuration public class MyWebAppConfigurer implements EnvironmentAware { private static final Logger logger = LoggerFactory.getLogger(MyWebAppConfi

JDK环境变量解析

设置环境变量 在java 中需要设置三个环境变量(1.5之后不用再设置classpath了,但个人强烈建议继续设置以保证向下兼用问题)JDK安装完成之后我们来设置环境变量:右击“我的电脑”,选择“属性”,选择“高级”标签,进入环境变量设置,分别设置如下三个环境变量: (1)配置path变量: 为什么要配置path变量?因为电脑系统将根据该变量的值找到java编程中需要的一些程序,比如javac.exe.java.exe.javah.exe等等,其中javac.exe程序是用于编译java源代码,

进程状态与环境变量的解析

主要内容 : 1.main函数下的命令行參数 2.环境变量的获取: 3.验证进程中环境变量的存储位置 4.进程执行的状态 1.命令行參数 在学习C语言的时候,我们已经大致了解到了命令行參数的使用: 今天我们在Linux系统下.来看看这些參数的使用; 我们都知道main函数是有參数的: main函数的格式: int main(intargc ,char  *  argv[],char*  env) 当中參数env表示的进程的环境变量 . .. 前两个表示的就是 argc  表示的命令的个数 arg

您真的明白java环境变量的配置吗?

首先,我们来看一看当我们用命令执行javac和java的时候,系统做了些什么工作,假如我们现在有一个文件夹如下图1所示,有两个java文件. 图1:文件目录示意图 其中,Main.java的内容非常简单: public class Main {          public static void main(String[] args)          {              System.out.println("hello world");          } } 我们

8.6 管道符和作业控制 8.7/8.8 shell变量 8.9 环境变量配置文件

8.6 管道符和作业控制 8.7/8.8 shell变量 8.9 环境变量配置文件 扩展 bashrc和bash_profile的区别 http://ask.apelearn.com/question/7719 # 8.6 管道符和作业控制 ![mark](http://oqxf7c508.bkt.clouddn.com/blog/20170816/214503952.png?imageslim) - 管道符的命令就是把前面输出的结果交给后面的命令 ``` [[email protected] 

环境变量LD_LIBRARY_PATH的传递

http://bbs.chinaunix.net/thread-3680861-1-1.html execv明显没有传环境变量,execle或execve才会带在启动shell设置的LD_LIBRARY_PATH根本传不到b程序 http://bbs.pediy.com/thread-217130.htm 为了使 Set-UID 程序更加安全,不受LD_LIBRARY_PATH环境变量的影响, 运行时的链接器或加载器(ld.so)会忽略环境变量,如果程序是个 Set-UID 程序. http:/