㈠ 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