u-boot 2016.05 添加u-boot cmd
记录一下如何在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的更多相关文章
- u-boot 2016.05 添加自己的board 以及config.h
拿到一个uboot 后,我都想添加一个属于自己的board文件以及include/configs/*.h 文件. 如何添加这个些文件,今天来记录一下. 复制一份你所参考的板级文件,比如说board/v ...
- 黑马_13 Spring Boot:05.spring boot 整合其他技术
13 Spring Boot: 01.spring boot 介绍&&02.spring boot 入门 04.spring boot 配置文件 05.spring boot 整合其他 ...
- step6----->往工程中添加spring boot项目------->修改pom.xml使得我的project是基于spring boot的,而非直接基于spring framework
文章内容概述: spring项目组其实有多个projects,如spring IO platform用于管理external dependencies的版本,通过定义BOM(bill of mater ...
- eclipse添加spring boot 插件
在使用eclipse开发时,一般需要添加spring boot的管理插件,这样更方便我们开发,在写application.yml或properties配置的时候,也有相关的提示,而且还可以从配置文件中 ...
- (转)Spring Boot 2 (八):Spring Boot 集成 Memcached
http://www.ityouknow.com/springboot/2018/09/01/spring-boot-memcached.html Memcached 介绍 Memcached 是一个 ...
- (转)Spring Boot 2 (二):Spring Boot 2 尝鲜-动态 Banner
http://www.ityouknow.com/springboot/2018/03/03/spring-boot-banner.html Spring Boot 2.0 提供了很多新特性,其中就有 ...
- Spring Boot 2 (八):Spring Boot 集成 Memcached
Spring Boot 2 (八):Spring Boot 集成 Memcached 一.Memcached 介绍 Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数 ...
- Spring Boot 2 (七):Spring Boot 如何解决项目启动时初始化资源
Spring Boot 2 (七):Spring Boot 如何解决项目启动时初始化资源 在项目启动的时候需要做一些初始化的操作,比如初始化线程池,提前加载好加密证书等.今天就给大家介绍一个 Spri ...
- Spring Boot 2 (二):Spring Boot 2 动态 Banner
Spring Boot 2 (二):Spring Boot 2 动态 Banner Spring Boot 2.0 提供了很多新特性,其中就有一个小彩蛋:动态 Banner. 一.配置依赖 使用 Sp ...
随机推荐
- Android网络开发之Socket通信
HTTP通信中Client发送的每次请求都需要Server回送响应,在请求结束后,Client会主动释放连接.从建立连接到隔壁连接的过程成为一次连接.要保持Client程序的在线状态,需要不断地向Se ...
- 微信小程序的POST和GET请求方式的header区别
1.post请求: wx.request({ url: 'https://m.***.com/index.php/Home/Xiaoxxf/make_order', header: { "C ...
- C# MediaPlayer的详细用法
AxWindowsMediaPlayer的详细用法 作者:龙昊雪 AxWindowsMediaPlayer的详细用法收藏 function StorePage(){d=document;t=d.sel ...
- jquery中 $ 和 jQuery 及 $() 的区别
用过jquery的人都知道,jquery有两种用法,一种是$,还有一种是jQuery,那么这两种方式在使用上有什么区别呢? 答案是这两种用法没什么区别,只是别名而已,用$要比jQuery简短一些.方便 ...
- duplicate files during packaging of apk
OSChina Android APP 导入到Android Studio中不能运行,发现一小插曲. 主要实现了开源中国社区 OSC Android 客户端项目源码通过Gradle方式编译 在 And ...
- Service和广播联合更新UI的例子
sa111111 于 2010-11-19 10:56 发表在 [Android实例] [复制链接] [只看楼主] [上一主题] [下一主题] 在Android中,异步更新UI,通常我们会选用Ha ...
- Concurrency Managed Workqueue(一)workqueue基本概念
一.前言 workqueue是一个驱动工程师常用的工具,在旧的内核中(指2.6.36之前的内核版本)workqueue代码比较简单(大概800行),在2.6.36内核版本中引入了CMWQ(Concur ...
- MySql(七):MySQL性能调优——锁定机制与锁优化分析
针对多线程的并发访问,任何一个数据库都有其锁定机制,它的优劣直接关系着数据的一致完整性与数据库系统的高并发处理性能.锁定机制也因此成了各种数据库的核心技术之一.不同数据库存储引擎的锁定机制是不同的,本 ...
- [Python]南邮OJ代码备份爬虫
之前看过Python学习的经验,说以project为导向学习. 自己分析了一下,一般接触Python的都有一定的其它语言基础,对于程序设计的基本逻辑,语法都有一个大概的了解.而Python这样的脚本语 ...
- [Jobdu] 题目1391:顺时针打印矩阵
题目描述: 输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字,例如,如果输入如下矩阵: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 则依次打印出数字1,2 ...