6200 uboot 測試版分析(二)

2021-09-08 08:20:57 字數 3098 閱讀 2801

6200uboot啟動過程

注:pc此時跳到0x42800000處開始執行。

在這啟動過程中主要包括系統資訊採集(cpu資訊、mac、外設資訊),配置一些系統模組正常工作,ddr2位址重對映(由0x40000000對映到0x00000000),今天閱讀的uboot_6200**沒有做pc重置,原來在uboot_1.3.3版的**會涉及到中斷向量表搬移(從norflash搬至esram,以及pc重置)。

主要記錄下今天閱讀的uboot自啟動下遇到的乙個問題)。在void start_unicoreboot(void)最後會執行main_loop(),進入函式後,獲取預設啟動過程,同時延遲一段時間,除錯人員按鍵以執行部分除錯功能,該boot設定時間為3秒左右。當沒有按鍵觸發時,將繼續執行。今天閱讀的主要問題出在獲取預設啟動引數:

s 為char型指標,通過char *getenv(char *name)傳入」bootcmd」字串來獲取引數並賦予s。內部呼叫env_get_char(nxt)來檢測引數是否已存在,以及引數個數是否在範圍內。確定一般要求後,檢測引數開頭是否匹配,匹配後返回引數位址。而後在呼叫其他引數進行引數解析,

由解析出的第乙個引數(即命令名)來獲取所在結構體位址,而該結構體cmd_tbl_t則預設了對於該命令即其他解析出來的引數做出適當的處理(該boot中引數為」bootcmd=bootm 0x40000000,注意該一定是不對的,因為pc起始為0x42800000……我沒有獲得完整的版本,但是通過對0x40000000修改及連線指令碼和./board/prochip/sep611/config.mk中的text_base的修改是可以改正的)。問題在於那個引數所在的陣列使我從開始做了錯誤的分析,

uchar default_environment =

#ifdef        config_bootargs

"bootargs="     config_bootargs                           "\0"

#endif

#ifdef        config_bootcommand

"bootcmd="     config_bootcommand               "\0"

#endif

犯了乙個非常低階的錯誤,沒有看型別宣告。

其次這個**風格還行,但是如果自己寫一定要加上顯著說明,以防再次犯錯。

字串定義可以加上括號,這個有點遺忘了,也造成了我的誤解。

對於uboot_cmd_cfg的嵌入還有一點不理解,

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

以及cmd_tbl_t的構成。

做下整理

section定義了:

__u_boot_cmd_start=.;

.u_boot_cmd:

__u_boot_cmd_end=.;

這說明編譯的u_boot_cmd段被存放於該處(由__u_boot_cmd_start及__u_boot_cmd_end界定)

宣告型別:

struct cmd_tbl_s

char    *name;      /* command name         */

int     maxargs;    /* maximum number of arguments  */

int     repeatable; /* autorepeat allowed?      */

/* implementation function  */

int     (*cmd)(struct cmd_tbl_s *, int, int, char *);

char    *usage;     /* usage message    (short) */

#ifdef  cfg_longhelp

char    *help;      /* help  message    (long)  */

#endif

#ifdef config_auto_complete

/* do auto completion on the arguments */

int (*complete)(int argc, char *ar**, char last_char, int maxv, char *cm

dv);

#endif

typedef struct cmd_tbl_s    cmd_tbl_t;

重要的是下面的巨集定義

#define  struct_section  __attribute__ ((unused,section,」u_boot_cmd」)).

該段存放於u_boot_cmd段處,且其他部分不得占用該空間。

#define u_boot_cmd(name,maxargs,rep,cmd,usage,help)\

cmd_tbl_t __u_boot_cmd_##name struct_section =

這是乙個巨集定義,涉及到##和#運算子。

u_boot_cmd(

bootm,  cfg_maxargs,    1,  do_bootm,

"\tpassing arguments 'arg ...'; when booting a linux kernel,\n"

"\t'arg' can be the address of an initrd image\n"

函式定義:

int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *ar**)

120 {

121     ulong       iflag;

122     const char  *type_name;

123     uint        unc_len = cfg_bootm_len;

124     uint8_t     comp, type, os;

下面就開始涉及到搬運即解壓核心了(bootm 0x40000000)

6200 uboot測試版分析 四)

include autoconf.mk中cofig load addr 0x40008000 common do boom.c 中潛入了u boot cmd bootm,config sys maxargs,1,do bootm 因此在default environment中將會找到的bootm最終...

SQLRecovery測試版介紹

以下是sqlrecovery1.0測試版本的簡要說明 支援資料庫版本 sqlserver2005 支援字段型別 bigint,bit,char,datetime,decimal,float,int,money,nchar,numeric,nvarchar,real,smalldatetime,sma...

插入排序(測試版

遞增一趟直接插入排序 將記錄 iarr i 的關鍵字從右向左依次與有序記錄 iarr j j i 1,i 1,1 關鍵字比較,若iarr i 關鍵字小於 iarr j 先將 iarr i 放在 iarr 0 儲存,然後將 iarr j j i 1,i 1,1 後移一位,直至iarr j 不大於 ia...