记录一下如何在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. java中static、this、super、final用途、用法及实例

    一.static 请先看下面这段程序: public class Hello { public static void main(String[] args){ //(1) System.out.pr ...

  2. Linux 查看登录日志及登录失败用户的ip-lastb

    Linux 查看登录成功的用户信息 命令: last 最新的登录记录在最前面,所以可以用 一下命令来查看. last | less 查看登录失败的用户信息 命令: lastb 查看登录日志 命令:  ...

  3. windows平台下压缩tar.gz

    windows平台下很多压缩软件(如360压缩)都支持tar.gz的解压,但不支持压缩 推荐一款支持tar.gz压缩的软件7zip 下面介绍可视化和命令行两种操作方式将文件压缩为tar.gz 可视化操 ...

  4. Hadoop Archives

    原文地址:http://hadoop.apache.org/docs/r1.0.4/cn/hadoop_archives.html 什么是Hadoop archives? 如何创建archive? 如 ...

  5. C# 采用钩子捕获键盘和鼠标事件-验证是否处于无人操作状态

    原文地址:https://www.cnblogs.com/gc2013/p/4036414.html 全局抽象类定义 using System; using System.Collections.Ge ...

  6. 跨域在嵌入页面iframe中设置cookie

    在IIS  HTTP响应头 中 添加: 名称:p3p 值:CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"

  7. 记录一次条件比较多的SQL查询语句

    本人目前遇到一个比较长的查询语句: (个人觉得越是复杂的查询越有可能意味着数据库设计的不太合理,非数据领域专业人士,仅个人感觉)

  8. Vim进阶技术:搜索和替换

    行内搜索 行内搜索,也就是在当前行内进行搜索和移动,通常都与编辑命令一起使用. fx -- 移动到下一个字符x的位置,光标停留在x字符上面 tx -- 移动到下一个字符x的位置,光标停留在x前一个字符 ...

  9. 用 Qt 中的 QDomDocument类 处理 XML 文件

    XML,全称为 “可扩展标记语言”(extensible markup language).是一种非常方便的数据交换与数据存储的工具. 我们在取得一个XML格式的文件后,需要作句法分析去提取发布方提供 ...

  10. IE下JS读取xml文件示例代码

    JS读取xml文件具体步骤为:创建DOM对象.加载xml文件(仅适用于IE)附示例代码,感兴趣的朋友可以参考下,希望对大家有所帮助使用javascript脚本读取xml文件,这里暂只考虑IE浏览器st ...