记录一下如何在u-boot 添加一个自己想要的命令。

    首先来看一下宏,include/command.h
218 #define U_BOOT_CMD(_name, _maxargs, _rep, _cmd, _usage, _help) \
219 U_BOOT_CMD_COMPLETE(_name, _maxargs, _rep, _cmd, _usage, _help, NULL)
    U_BOOT_CMD 宏第一个参数是你的命令的名字。
第二个参数你最大参数个数
第三个参数是是否能复用。
第四个参数是实现的函数名
第五个简单说明。
后面是help
  • 举例:
    nandecc.c

    #include <common.h>
#include <linux/mtd/mtd.h>
#include <command.h>
#include <console.h>
#include <watchdog.h>
#include <malloc.h>
#include <asm/byteorder.h>
#include <jffs2/jffs2.h>
#include <nand.h>
#include <asm/io.h>
#include <asm/errno.h>
#if defined(CONFIG_SOC_KEYSTONE)
#include <asm/ti-common/ti-gpmc.h>
#else
#include <asm/arch/mem.h>
#endif
#include <linux/mtd/omap_gpmc.h>
#include <linux/mtd/nand_ecc.h>
#include <linux/bch.h>
#include <linux/compiler.h>
#include <nand.h>
#include <linux/mtd/omap_elm.h>
#include <dm.h> #ifdef CONFIG_CMD_NANDECC
extern void omap_nand_switch_ecc(nand_ecc_modes_t hardware, int32_t mode);
static int do_switch_ecc(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
{
int type = 1; if (argc < 2)
goto usage; if (strncmp(argv[1], "hw", 2) == 0) {
if (argc == 3)
type = simple_strtoul(argv[2], NULL, 10);
omap_nand_switch_ecc(NAND_ECC_HW, type);
}
else if (strncmp(argv[1], "sw", 2) == 0)
omap_nand_switch_ecc(NAND_ECC_NONE, 1);
else
goto usage; return 0; usage:
printf("Usage: nandecc %s\n", cmdtp->usage);
return 1;
} U_BOOT_CMD(
nandecc, 3, 1, do_switch_ecc,
"Switch NAND ECC calculation algorithm b/w hardware and software",
"[sw|hw <hw_type>] \n"
" [sw|hw]- Switch b/w hardware(hw) & software(sw) ecc algorithm\n"
" hw_type- 0 for Hamming code\n"
" 4 for bch4\n"
" 8 for bch8\n"
" 16 for bch16\n"
);
#endif
  • 将该文件添加进所属文件的Makefile,上述例子所在目录是cmd 目录。

    我将在该目录里面加入如下选项:
    cat cmd/Makefile

    //...
98 obj-$(CONFIG_CMD_NANDECC) += nandecc.o
//...
  • 然后在你的config.h 里面添加相关宏定义开关:
    cat include/configs/am335x_sbc7109.h

    //...
343 #define CONFIG_CMD_NANDECC
//...
  • 然后启动u-boot ,看是否有nandecc 这条命令。有即成功加入。

u-boot 2016.05 添加u-boot cmd的更多相关文章

  1. u-boot 2016.05 添加自己的board 以及config.h

    拿到一个uboot 后,我都想添加一个属于自己的board文件以及include/configs/*.h 文件. 如何添加这个些文件,今天来记录一下. 复制一份你所参考的板级文件,比如说board/v ...

  2. 黑马_13 Spring Boot:05.spring boot 整合其他技术

    13 Spring Boot: 01.spring boot 介绍&&02.spring boot 入门 04.spring boot 配置文件 05.spring boot 整合其他 ...

  3. step6----->往工程中添加spring boot项目------->修改pom.xml使得我的project是基于spring boot的,而非直接基于spring framework

    文章内容概述: spring项目组其实有多个projects,如spring IO platform用于管理external dependencies的版本,通过定义BOM(bill of mater ...

  4. eclipse添加spring boot 插件

    在使用eclipse开发时,一般需要添加spring boot的管理插件,这样更方便我们开发,在写application.yml或properties配置的时候,也有相关的提示,而且还可以从配置文件中 ...

  5. (转)Spring Boot 2 (八):Spring Boot 集成 Memcached

    http://www.ityouknow.com/springboot/2018/09/01/spring-boot-memcached.html Memcached 介绍 Memcached 是一个 ...

  6. (转)Spring Boot 2 (二):Spring Boot 2 尝鲜-动态 Banner

    http://www.ityouknow.com/springboot/2018/03/03/spring-boot-banner.html Spring Boot 2.0 提供了很多新特性,其中就有 ...

  7. Spring Boot 2 (八):Spring Boot 集成 Memcached

    Spring Boot 2 (八):Spring Boot 集成 Memcached 一.Memcached 介绍 Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数 ...

  8. Spring Boot 2 (七):Spring Boot 如何解决项目启动时初始化资源

    Spring Boot 2 (七):Spring Boot 如何解决项目启动时初始化资源 在项目启动的时候需要做一些初始化的操作,比如初始化线程池,提前加载好加密证书等.今天就给大家介绍一个 Spri ...

  9. Spring Boot 2 (二):Spring Boot 2 动态 Banner

    Spring Boot 2 (二):Spring Boot 2 动态 Banner Spring Boot 2.0 提供了很多新特性,其中就有一个小彩蛋:动态 Banner. 一.配置依赖 使用 Sp ...

随机推荐

  1. mysql中的慢查询日志

    首先我们看一下关于mysql中的日志,主要包含:错误日志.查询日志.慢查询日志.事务日志.二进制日志: 日志是mysql数据库的重要组成部分.日志文件中记录着mysql数据库运行期间发生的变化:也就是 ...

  2. MySQL5.7 二进制源码包安装

    一般平时安装MySQL都是源码包安装的,但是由于它的编译需要很长的时间,所以建议安装二进制免编译包.可以到MySQL官方网站去下载,也可以到comsenz官方网站下载,还有各大镜像站下载. 下载安装包 ...

  3. 路径,通过navigation可以查看 *.class文件

    ?.class文件内的代码所在的文件的路径默认 举例1:读取项目根目录下的数据. private static void readRoot() throws FileNotFoundException ...

  4. zookeeper与kafka安装部署及java环境搭建(发布订阅模式)

    1. ZooKeeper安装部署 本文在一台机器上模拟3个zk server的集群安装. 1.1. 创建目录.解压 cd /usr/ #创建项目目录 mkdir zookeeper cd zookee ...

  5. 两个有序数组求中位数log(m+n)复杂度

    leetcode 第4题 中位数技巧: 对于长度为L的有序数组,它的中位数是(a[ceil((L+1)/2)]+a[floor((L+1)/2)])/2 算法原理: 类似三分法求极值 两个人都前进,谁 ...

  6. Lucene的索引不跨平台

    在windows上使用Lucene生成索引文件,将索引文件复制到Linux服务器上,报错"校验错误,可能是硬件问题". 所以,Lucene的跨平台只是代码跨平台,生成的索引不跨平台 ...

  7. C# MediaPlayer的详细用法

    AxWindowsMediaPlayer的详细用法 作者:龙昊雪 AxWindowsMediaPlayer的详细用法收藏 function StorePage(){d=document;t=d.sel ...

  8. 在python3.x下使用如下代码: import cPickle as pk 报错

    在python3.x下使用如下代码: import cPickle as pk会报如下错误:ImportError: No module named 'cPickle' 原因:python2有cPic ...

  9. Latex文件如何拆分进行独立编译?

    Latex文件如何拆分并进行独立编译? --latex源文件分批独立编译     最近使用Latex编写长文档,对于文件的组织有些困扰.   如果LaTeX文档比较大,可以考虑拆分为几个部分.比如编辑 ...

  10. es6编写generator报错

    首先babel基础包(不安装额外东西)并不是支持完整的es6语言 自己写的如下代码 let generator = function* () { ; ,,]; ; }; var gen = gener ...