导航:首页 > 程序命令 > uboot命令的添加

uboot命令的添加

发布时间:2024-06-12 08:31:26

㈠ uboot 命令具体是如何实现的,我看了一部分,现在卡住了;求高人指点; 我的QQ:436035433

那u-boot的那些个关于命令的结构体到底从何而来呢?在include/command.h里定义了这样的宏:

#define Struct_Section __attribute__ ((unused,section (".u_boot_cmd")))

... ... ... ...

#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}


二个宏展开便定义了一个代表u-boot命令的结构体。也就是说定义了一个变量,并赋与其初值。关键在于Struc_Section,它被展开后成了
__attribute__
((unused,section(".u_boot_cmd")))。也就是说,每个变量(占内存!)都放在.u_boot_cmd段里。它们还被加上
了unused的属性,应该是为了平息编译器的警告。确实,没有任何代码引用过它们!!如果这些变量被放在一个显示声明的数组里,那么,每增加一个命令都
得去更改数组的定义。然后,通过这种方法,各人想要增加新的命令时,只需用上面的这个宏即可。这些表示命令的结构体被统一放在.u_boot_cmd段
里,链接脚本里又有:

__u_boot_cmd_start = .;

.u_boot_cmd : { *(.u_boot_cmd) }

__u_boot_cmd_end = .;

即,
把所有待链接文件里u_boot_cmd段合并在一起生成一个大的.u_boot_cmd段,并且用__u_boot_cmd_start与
__u_boot_cmd_end两个符号标识这块内存的首尾边界。这样,不用大家去修改某一文件的代码(为了改变数组的定义),而是像数据库一样,各个
提供自己的信息。借由编译器与链接器生成这个“数据库”,操作数据时对“数据库”进行查询即可。正是一个月前看《计算机程序构造与解释》时看到的
“Data Direct”(好像是这么说)。在Grub及内核里也用了这样机制。

参考:http://blog.163.com/lijiji_1515/blog/static/12687744620114522449739/

㈡ 濡备綍鍦╱boot涓娣诲姞椹卞姩绋嫔簭

Author锛氭潹姝date锛2016.9.21
鐩镄
鍦╱-boot涓娣诲姞椹卞姩绋嫔簭銆

璇︾粏涓句緥浠嬬粛
鍦╱boot涓镎崭綔瀵勫瓨鍣锛屽疄鐜板筭pio鍙婂栧洿璁惧囩殑鎺у埗链変袱绉嶆柟娉曪纴涓绉嶆槸鐩存帴鍦╝rch/arm/lib/board.c涓娣诲姞瀵瑰瘎瀛桦櫒镄勬搷浣滀唬镰侊纴濡傦细
#define muxctrl_reg5 0x200f0014#define GPIO6_DIR 0x201a0400#define GPIO6_1_DATA 0x201a0008 #define GPIO6_1 (1 << 1)#define readl(addr) (*(volatile unsigned int*)(addr))#define writel(val, addr) ((*(volatile unsigned int *) (addr)) = (val)) int clear_irled(void){ unsigned int reg_val; reg_val = writel(0, muxctrl_reg5); // set gpio mode reg_val = readl(GPIO6_DIR); reg_val |= GPIO6_1; writel(reg_val, GPIO6_DIR); reg_val = readl(GPIO6_1_DATA); reg_val &= ~GPIO6_1; writel(reg_val, GPIO6_1_DATA); return 0;}void start_armboot (void){ init_fnc_t **init_fnc_ptr; char *s;#ifdef CONFIG_HAS_SLAVE char *e;#endif#if defined(CONFIG_VFD) || defined(CONFIG_LCD) unsigned long addr;#endif #ifdef CONFIG_HI3516A // defined in the include/configs/hi3516a.h clear_irled(); // clear ir led, add by yangzheng 2016.9.21#endif

𨱒ヨ嚜CODE镄勪唬镰佺墖
snippet_file_0.txt

鍙︿竴绉嶆柟娉曪细
1銆佸湪driver/涓嬫柊寤篽i_gpio鐩褰曪纴濡傦细
[yangzheng@centos6 hi_gpio]$ ls
hi_gpio.c Makefile

hi_gpio.c鍐呭瑰备笅锛

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
[yangzheng@centos6 hi_gpio]$ cat hi_gpio.c/********************************************************************************** Copyright: (C) 2016 Yang Zheng<[email protected]> * All rights reserved.** Filename: hi_gpio.c* Description: This file* * Version: 1.0.0(09/21/2016~)* Author: Yang Zheng <[email protected]>* ChangeLog: 1, Release initial version on "09/21/2016 05:41:41 PM"* ********************************************************************************/#include<common.h> #define readl(addr) (*(volatile unsigned int *) (addr))#define writel(val, addr) (*(volatile unsigned int *) (addr) = (val)) #define muxctrl_reg5 0x200f0014#define GPIO6_DIR 0x201a0400#define GPIO6_1_DATA 0x201a0008#define GPIO6_1 1 << 1#define REG_SET 1#define REG_CLR 0 #ifdef DEBUG#define DPRINTF(args...) printf(args)#else#define DPRINTF(args...)#endif int clear_irled(void){ unsigned int reg_val; reg_val = writel(REG_CLR, muxctrl_reg5); // set gpio mode reg_val = readl(GPIO6_DIR); reg_val |= GPIO6_1; writel(reg_val, GPIO6_DIR); writel(REG_CLR, GPIO6_1_DATA); DPRINTF("clear ir led...\n"); return 0;}

𨱒ヨ嚜CODE镄勪唬镰佺墖
snippet_file_0.txt

Makefile濡备笅锛埚彲浠ユ嫹璐漝river鐩褰曚笅镄勫悇妯″潡妯℃澘锛夛细

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
[yangzheng@centos6 hi_gpio]$ cat Makefile## Copyright 2000-2008# Wolfgang Denk, DENX Software Engineering, [email protected].## See file CREDITS for list of people who contributed to this# project.## This program is free software; you can redistribute it and/or# modify it under the terms of the GNU General Public License as# published by the Free Software Foundation; either version 2 of# the License, or (at your option) any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.## You should have received a of the GNU General Public License# along with this program; if not, write to the Free Software# Foundation, Inc., 59 Temple Place, Suite 330, Boston,# MA 02111-1307 USA# include $(TOPDIR)/config.mk LIB := $(obj)libhi_gpio.a COBJS-$(CONFIG_HI3516A_GPIO) += hi_gpio.o COBJS := $(COBJS-y)SRCS := $(COBJS:.o=.c)OBJS := $(addprefix $(obj),$(COBJS)) all: $(LIB) $(LIB): $(obj).depend $(OBJS) $(AR) $(ARFLAGS) $@ $(OBJS) ######################################################################### # defines $(obj).depend targetinclude $(SRCTREE)/rules.mk sinclude $(obj).depend ########################################################################

𨱒ヨ嚜CODE镄勪唬镰佺墖
snippet_file_0.txt

2銆佸湪椤跺眰Makefile娣诲姞濡备笅浠g爜锛
LIBS += drivers/hi_gpio/libhi_gpio.a

3銆佸湪include/configs/hi3516a.h涓娣诲姞濡备笅浠g爜锛
#define CONFIG_HI3516A_GPIO

鍦╥nclude涓嫔炲姞hi_gpio.h鏂囦欢锛屽唴瀹瑰备笅锛

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[yangzheng@centos6 u-boot-2010.06]$ cat include/hi_gpio.h/******************************************************************************** * Copyright: (C) 2016 Yang Zheng<[email protected]> * All rights reserved. * * Filename: hi_gpio.h * Description: This head file is control hisi gpio * * Version: 1.0.0(09/21/2016~) * Author: Yang Zheng <[email protected]> * ChangeLog: 1, Release initial version on "09/21/2016 06:09:49 PM" * ********************************************************************************/#ifndef __HI_GPIO_H__#define __HI_GPIO_H__ extern int clear_irled(void);#endif

𨱒ヨ嚜CODE镄勪唬镰佺墖
snippet_file_0.txt

4銆佸湪arch/arm/lib/board.c 閲岄溃璋幂敤鍗冲彲锛屽傦细

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[yangzheng@centos6 u-boot-2010.06]$ vim arch/arm/lib/board.c void start_armboot (void){ init_fnc_t **init_fnc_ptr; char *s;#ifdef CONFIG_HAS_SLAVE char *e;#endif#if defined(CONFIG_VFD) || defined(CONFIG_LCD) unsigned long addr;#endif #ifdef CONFIG_HI3516A_GPIO clear_irled(); // clear ir led, add by yangzheng 2016.9.21#endif钬︹

𨱒ヨ嚜CODE镄勪唬镰佺墖
snippet_file_0.txt

閲嶆柊缂栬疟鍗冲彲锛岃皟璇晆boot镄勬柟娉曪细
濡傛灉璁惧囨湁缃戝彛锛屽彲鐢╰ftp链嶅姟涓嬭浇锛
sf probe 0
mw.b 82000000 ff 0x80000
tftp 82000000 u-boot.bin
Go 82000000

濡傛灉娌℃湁缃戝彛锛屽彲鐢ㄤ覆鍙d笅杞斤细
sf probe 0
mw.b 82000000 ff 0x80000
loady 82000000 u-boot.bin
go 82000000

㈢ 如何设置uboot命令让板子从emmc启动

Arm板系统文件一般有三个——bootloader(uboot)、kernel(uImage)及根文件系统(rootfs)。在arm板上电后,按uboot->kernel->rootfs的顺序依次启动。由于开发板上有多种存储介质,三个文件可以放在任何可以存储的介质上,因此也就导致文件的多种启...

㈣ 如何在自己的uboot中实现命令

你这个问题专业性太强了,还好你遇到了我,我11年的时候参加过一个嵌入式的培训,当初我们是做一个数码相框的项目,就是要把已经编写好的程序移植到ARM2440板上面运行。整个过程非常的繁琐复杂,我真的无法口述清楚。你想把linux中的命令移植到uboot代码中,应该也是想在你的ARM上面编译你的程序然后运行,你可以进我的CSDN的博客,博客地址:http://blog.csdn.net/coolboyli520,然后打开那个《Linux移植课实验指导书》,这里有详细的记录,如果对你有帮助,还望采纳!

㈤ openwrt sdk下编译uboot(添加usb端口功能)

在ehci-ra.c的ehci_hcd_init中加入MT7620_ASIC_BOARD定义:

MT7620#usbreset
(Re)startUSB...
USB:inusb_lowlevel_init
Mediatek/_length16
Register1111NbrPorts1
USBEHCI1.00
scanningbusfordevices...2USBDevice(s)found
scanningbusforstoragedevices...1StorageDevice(s)found
MT7620#usbinfo
1:Hub,USBRevision0.2
-u-bootEHCIHostController
-Class:Hub
-PacketSize:64Configurations:1
-Vendor:0x0000Proct0x0000Version0.1
Configuration:1
-Interfaces:1SelfPowered0mA
Interface:0
-AlternateSettings0,Endpoints:1
-ClassHub
-

2:MassStorage,USBRevision2.0
-HPUSB2.0Flash00CCCBB99999
-Class:(fromInterface)MassStorage
-PacketSize:64Configurations:1
-Vendor:0x0204Proct0x6025Version1.0
Configuration:1
-Interfaces:1BusPowered100mA
Interface:0
-AlternateSettings0,Endpoints:2
-ClassMassStorage,Transp.SCSI,Bulkonly
-Endpoint1OutBulkMaxPacket512
-Endpoint1InBulkMaxPacket512
阅读全文

与uboot命令的添加相关的资料

热点内容
加密的视频不小心删除怎么恢复 浏览:464
安卓游戏充钱充错帐号怎么办 浏览:203
有什么是绑定手机号的app 浏览:496
phpredis事务 浏览:935
阴阳师pad怎么登录安卓账号 浏览:734
bitlocker加密后读取不了 浏览:176
算法设计是指流程图吗 浏览:168
javaboot如何防止反编译 浏览:118
python复合数据结构视频 浏览:146
培训学校需要用什么云服务器 浏览:721
卫星锅加密卡那里收购 浏览:58
小米工具文件夹选项在哪里 浏览:55
md5磁盘加密 浏览:642
单片机x地址 浏览:208
回车键失灵运行命令如何使用 浏览:984
电脑一键解压缩的软件 浏览:171
怎么关闭手机通讯录对外app 浏览:370
我的世界如何强行进入一个满人的服务器 浏览:653
什么app可以查询会考成绩 浏览:389
程序员能创造的价值 浏览:261