日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

u-boot内核启动分析

發(fā)布時(shí)間:2025/3/15 编程问答 16 豆豆
生活随笔 收集整理的這篇文章主要介紹了 u-boot内核启动分析 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

菜單的實(shí)現(xiàn)函數(shù) - cmd_menu.c

pc機(jī)上都有分區(qū),但是在嵌入式設(shè)備中的flash沒有分區(qū)
所謂的嵌入式中的分區(qū)就是使用代碼進(jìn)行寫死

sourceinsight 中搜索函數(shù)的快捷鍵是: Alt + G 或者 F7
搜索文件的快捷鍵是  Ctrl + O

u-boot 與內(nèi)核的參數(shù)交互,u-boot將參數(shù)信息存在一個(gè)指定的地址(和內(nèi)核約定好的,按照雙方約定好的格式進(jìn)行);
定義的格式是tag,地址是30000100

/********************************************************************************/ u-boot命令尋找分析 /**************************************************************************** find command table entry for a command*/ cmd_tbl_t *find_cmd (const char *cmd) {cmd_tbl_t *cmdtp;cmd_tbl_t *cmdtp_temp = &__u_boot_cmd_start; /*Init value */const char *p;int len;int n_found = 0;/** Some commands allow length modifiers (like "cp.b");* compare command name only until first dot.*/len = ((p = strchr(cmd, '.')) == NULL) ? strlen (cmd) : (p - cmd);for (cmdtp = &__u_boot_cmd_start;cmdtp != &__u_boot_cmd_end;cmdtp++) {if (strncmp (cmd, cmdtp->name, len) == 0) {if (len == strlen (cmdtp->name))return cmdtp; /* full match */cmdtp_temp = cmdtp; /* abbreviated command ? */n_found++;}}if (n_found == 1) { /* exactly one match */return cmdtp_temp;}return NULL; /* not found or ambiguous command */ }for (cmdtp = &__u_boot_cmd_start;cmdtp != &__u_boot_cmd_end;cmdtp++)u-boot.lds的鏈接腳本之中也能傳遞變量 SECTIONS {. = 0x00000000;. = ALIGN(4);.text :{cpu/arm920t/start.o (.text)board/100ask24x0/boot_init.o (.text)*(.text)}. = ALIGN(4);.rodata : { *(.rodata) }. = ALIGN(4);.data : { *(.data) }. = ALIGN(4);.got : { *(.got) }. = .;__u_boot_cmd_start = .;.u_boot_cmd : { *(.u_boot_cmd) }__u_boot_cmd_end = .;. = ALIGN(4);__bss_start = .;.bss : { *(.bss) }_end = .; }#define Struct_Section __attribute__ ((unused,section (".u_boot_cmd")))#ifdef CFG_LONGHELP#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}#else /* no long help info */rep命令代表的是命令是否可重復(fù) #define U_BOOT_CMD(name,maxargs,rep,cmd,usage,help) \ cmd_tbl_t __u_boot_cmd_##name Struct_Section = {#name, maxargs, rep, cmd, usage} nand read.jffs2 0x30007FC0 kernel; bootm 0x30007FC0 U_BOOT_CMD(bootm, CFG_MAXARGS, 1, do_bootm,"bootm - boot application image from memory\n","[addr [arg ...]]\n - boot application image stored in memory\n""\tpassing arguments 'arg ...'; when booting a Linux kernel,\n""\t'arg' can be the address of an initrd image\n" #ifdef CONFIG_OF_FLAT_TREE"\tWhen booting a Linux kernel which requires a flat device-tree\n""\ta third argument is required which is the address of the of the\n""\tdevice-tree blob. To boot that kernel without an initrd image,\n""\tuse a '-' for the second argument. If you do not pass a third\n""\ta bd_info struct will be passed instead\n" #endif );cmd_tbl_t __u_boot_cmd_bootm __attribute__ ((unused,section (".u_boot_cmd"))) = {"bootm", CFG_MAXARGS, 1, do_bootm, \ "bootm - boot application image from memory\n", \"[addr [arg ...]]\n - boot application image stored in memory\n""\tpassing arguments 'arg ...'; when booting a Linux kernel,\n""\t'arg' can be the address of an initrd image\n"} 在宏定義中 #是轉(zhuǎn)化為字符串的意思 下面這句的意思是設(shè)置該結(jié)構(gòu)體段屬性為.u_boot_cmd cmd_tbl_t __u_boot_cmd_bootm __attribute__ ((unused,section (".u_boot_cmd"))) 因此只要是定義為 U_BOOT_CMD 類型的結(jié)構(gòu)體都將被強(qiáng)制轉(zhuǎn)化為 段的屬性為 .u_boot_cmd 該屬性在鏈接腳本中定義了 因此在find_cmd中能夠使用 for (cmdtp = &__u_boot_cmd_start;cmdtp != &__u_boot_cmd_end;cmdtp++) 將明令挨個(gè)找出來

總結(jié)

以上是生活随笔為你收集整理的u-boot内核启动分析的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。