u_boot添加命令(NOR Flash中uboot的烧写代码)
来源:互联网 发布:赵泓霖的网络课100节 编辑:程序博客网 时间:2024/06/17 01:48
关于命令的几个文件:
include /command.h
common/command.c
include/cmd_confdefs.h
common/cmd_*.c
先看一下添加命令的宏:
U_BOOT_CMD
定义在include/command.h中
#define U_BOOT_CMD(name,maxargs,rep,cmd,usage,help) \
cmd_tbl_t __u_boot_cmd_##name Struct_Section = {#name, maxargs, rep, cmd, usage, help}
可以看到每一个命令定义一个cmd_tbl_t结构体,该结构体也定义在同个头文件中。
CFG_CMD_* 等的命令的配置定义在:
Include/cmd_confdefs.h中
只有定义了相关的配置,在common/cmd_*.c命令函数才会有效
我们现在不创建一个新的cmd_*.c,而是在原来的基础上添加一个命令
例如:添加flash的强制写命令
添加在common/cmd_bootc文件中
添加在u-boot的common/cmd_boot.c中
typedef unsigned short FLASH_PORT_WIDTH;
typedef volatile unsigned short FLASH_PORT_WIDTHV;
#define FLASH_ID_MASK 0xFF
#define FPW FLASH_PORT_WIDTH
#define FPWV FLASH_PORT_WIDTHV
#define AMDNORADDRBASE 0x2000000
#define AMDNORSIZE 0x10000
extern int flash_sect_protect (int p, ulong addr_first, ulong addr_last);
int do_writeuboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
int rcode = 0;
ulong addr, dest, count;
ulong noradd,endaddr,seccount;
flash_info_t *info;
int rc;
printf("Add by jk for test the writeboot\n");
if (argc < 4) {
printf ("Usage:\n%s\n", cmdtp->usage);
return 1;
}
//将输入的命令中的参数转化
//./writeboot 80000000 2000000 186bc
//./writeboot 源拷贝 目的NORflash 大小
addr = simple_strtoul(argv[1], NULL, 16);
dest = simple_strtoul(argv[2], NULL, 16);
count = simple_strtoul(argv[3], NULL, 16);
if (count == 0) {
puts ("Zero length ???\n");
return 1;
}
noradd=AMDNORADDRBASE;
seccount=count/AMDNORSIZE;
if((count%AMDNORSIZE)!=0)
seccount++;
endaddr=noradd+0x1FFFF;
这两个地址很重要,一定要是sector的边界,否则就出错,这里硬性定义了从2000000 ----201FFFF
printf("writeboot the noradd=%8lx, endaddr=%8lx\n",noradd,endaddr);
//原先这里设置了sector保护,因此要去掉
flash_sect_protect(0,noradd,endaddr);
//info=flash_info;
info=flash_get_info(noradd);
//大小是8M, sector_count是135
printf("the flash_info.size=%x,flash_sector=%d\n",info.size, info.sector_count);
if(noradd==info->start[0])
printf("find the u-boot address\n");
puts("Erasing Flash...");
//这里擦除的变量是sector,不是地址
flash_erase(info,0,9);
//这里的函数是将addr源,拷贝到dest地址, 大小是coun
puts ("Copy to Flash... ");
rc = flash_write ((uchar *)addr, dest, count);
if (rc != 0) {
flash_perror (rc);
return (1);
}
puts ("done\n");
flash_sect_protect(1,noradd,endaddr);
return 0;
}
//这里最大的参数为 CFG_MAXARGS=16
U_BOOT_CMD(
writeboot, CFG_MAXARGS, 1, do_writeuboot,
"writeuboot - update the davinci u-boot.bin in NOR flash\n"
"argv[1] --start the Memory Address'\n"
"argv[2] --start the NOR Flash Address'\n"
"argv[3] --the u-boot.bin hex size'\n",
);
- u_boot添加命令(NOR Flash中uboot的烧写代码)
- QQ2440的NOR FLASH烧写方法
- NOR Flash的烧写方式
- NOR Flash 烧写说明
- vivi中基于NOR FLASH的相关代码
- Nor-Flash烧写工具SJF的改造
- JLink烧写Nor Flash出错的解决方案
- am3359 uboot nor flash支持
- 在uboot中添加新的命令
- uboot 中添加自己的命令
- 在uboot中添加自己的命令
- 在uboot中添加自己的命令
- uboot中添加自己的命令
- 在uboot中添加自己的命令
- uboot中常见烧写命令总结
- Uboot下的Nor Flash的驱动以及使用
- 使用jlink烧写micro2440 nor flash
- jlink烧写mini2440 nor flash
- 重温数据结构:哈希 哈希函数 哈希表
- dubbo源码 学习笔记(一)
- 创建指定路径文件
- 2.4、元组
- 阿里Java开发手册之编程规约
- u_boot添加命令(NOR Flash中uboot的烧写代码)
- PHP扩展pcntl(进程控制以及信号处理)中文文档
- 2.5、集
- json字符串转换为JSONObject和JSONArray
- Spring-MockMvc
- 10月25日 c语言 打印所有水仙花数
- Codeforces 877 D Olya and Energy Drinks
- 深入学习c#(2)
- java 中 new 关键字