OK335xS U-boot 环境变量解析

本文涉及的产品
云解析 DNS,旗舰版 1个月
全局流量管理 GTM,标准版 1个月
公共DNS(含HTTPDNS解析),每月1000万次HTTP解析
简介: /************************************************************************************************** * OK335xS U-boot 环境变量解析 * 声明: * 本文主要是为了知道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

 

目录
相关文章
|
JSON 网络协议 开发工具
对已有的docker容器添加新的目录映射, 端口映射,环境变量,dns等
docker容器已经建立并运行, 需要在已有容器上添加新的目录映射,端口映射,环境变量等
2507 0
|
15天前
|
负载均衡 网络协议 算法
Docker容器环境中服务发现与负载均衡的技术与方法,涵盖环境变量、DNS、集中式服务发现系统等方式
本文探讨了Docker容器环境中服务发现与负载均衡的技术与方法,涵盖环境变量、DNS、集中式服务发现系统等方式,以及软件负载均衡器、云服务负载均衡、容器编排工具等实现手段,强调两者结合的重要性及面临挑战的应对措施。
40 3
|
6月前
|
Linux Shell 数据处理
深入了解Linux的printenv命令:环境变量的查看与解析
`printenv`命令在Linux中用于查看环境变量,它显示所有或特定变量及其值。该命令简单易用,可结合参数实现过滤和筛选,如 `-0` 用于null分隔,`-n` 只列名称,`-u` 查找未设置的变量。通过与`grep`等结合,能进行复杂查询。在使用时要注意保护敏感信息,并理解变量对系统和程序的影响。定期检查和管理环境变量能提升系统效能和安全性。
|
Shell Linux C++
【Linux取经路】解析环境变量,提升系统控制力(二)
【Linux取经路】解析环境变量,提升系统控制力(二)
57 0
|
存储 算法 Linux
【Linux取经路】解析环境变量,提升系统控制力(一)
【Linux取经路】解析环境变量,提升系统控制力(一)
97 0
|
JSON Shell 测试技术
gookit/config - Go应用配置管理,支持多种格式,多文件加载,支持数据合并,解析环境变量名等等
gookit/config - Go应用配置管理,支持多种格式,多文件加载,支持数据合并,解析环境变量名,绑定数据到结构体等等
200 0
gookit/config - Go应用配置管理,支持多种格式,多文件加载,支持数据合并,解析环境变量名等等
OK335xS 系统启动配置解析
OK335xS 系统启动配置解析 一、参考文档: AM335x ARM® Cortex™-A8 Microprocessors (MPUs) Technical Reference Manual 二、SYSBOOT Configuration Pins Notes(page 4111): 1.
1034 0
|
Linux 网络协议
I.MX6 Linux U-boot 环境变量解析
/********************************************************************************** * I.
921 0
|
28天前
|
监控 Java 应用服务中间件
高级java面试---spring.factories文件的解析源码API机制
【11月更文挑战第20天】Spring Boot是一个用于快速构建基于Spring框架的应用程序的开源框架。它通过自动配置、起步依赖和内嵌服务器等特性,极大地简化了Spring应用的开发和部署过程。本文将深入探讨Spring Boot的背景历史、业务场景、功能点以及底层原理,并通过Java代码手写模拟Spring Boot的启动过程,特别是spring.factories文件的解析源码API机制。
65 2

推荐镜像

更多