網(wǎng)站首頁(yè) 編程語(yǔ)言 正文
uboot簡(jiǎn)介
uboot 屬于bootloader的一種,是用來(lái)引導(dǎo)啟動(dòng)內(nèi)核的,它的最終目的就是:從flash中讀出內(nèi)核,放到內(nèi)存中,啟動(dòng)內(nèi)核。
它剛開(kāi)始被放到flash上,然后上電以后先執(zhí)行它,它會(huì)完成硬件初始化,設(shè)置處理器模式,關(guān)閉看門(mén)狗,屏蔽中斷,初始化sdram,設(shè)置棧,設(shè)置時(shí)鐘,從flash引導(dǎo)內(nèi)核到內(nèi)存,就好像我們PC上的BIOS一樣。最終將系統(tǒng)的軟硬件帶到一個(gè)合適的狀態(tài)。
實(shí)現(xiàn)步驟:
- 1.uboot源碼下新建cmd/cmd_xx.c
- 2.添加基本的命令和函數(shù)
- 3.cmd下makefile添加 obj-y += cmd_update.o
頭文件:
#include <common.h>
#include <command.h>
函數(shù):
/*
第一個(gè)參數(shù):添加的命令的名字
第二個(gè)參數(shù):添加的命令最多有幾個(gè)參數(shù)(注意,假如你設(shè)置的參數(shù)個(gè)數(shù)是3,
而實(shí)際的參數(shù)個(gè)數(shù)是4,那么執(zhí)行命令會(huì)輸出幫助信息的)
第三個(gè)參數(shù):是否重復(fù)(1重復(fù),0不重復(fù))(即按下Enter鍵的時(shí)候,
自動(dòng)執(zhí)行上次的命令)
第四個(gè)參數(shù):執(zhí)行函數(shù),即運(yùn)行了命令具體做啥會(huì)在這個(gè)函數(shù)中體現(xiàn)出來(lái)
第五個(gè)參數(shù):幫助信息(short)
第六個(gè)參數(shù):幫助信息(long)
*/
static int do_update(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
return 0;
}
添加命令update:
// U_BOOT_CMD(_name, _maxargs, _rep, _cmd, _usage, _help)
U_BOOT_CMD(update, 4, 0, do_update,
"update command",
" - check boot progress and timing\n"
"update all\n"
"update uboot \n"
"update image \n"
"update rootfs \n"
);
/*
* @Author: error: git config user.name && git config user.email & please set dead value or install git
* @Date: 2022-11-15 23:26:50
* @LastEditors: error: git config user.name && git config user.email & please set dead value or install git
* @LastEditTime: 2022-11-16 21:38:40
* @FilePath: \uboot\cmd\cmd_update.c
* @Description: 這是默認(rèn)設(shè)置,請(qǐng)?jiān)O(shè)置`customMade`, 打開(kāi)koroFileHeader查看配置 進(jìn)行設(shè)置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
#include <common.h>
#include <command.h>
/*
第一個(gè)參數(shù):添加的命令的名字
第二個(gè)參數(shù):添加的命令最多有幾個(gè)參數(shù)(注意,假如你設(shè)置的參數(shù)個(gè)數(shù)是3,而實(shí)際的參數(shù)個(gè)數(shù)是4,那么執(zhí)行命令會(huì)輸出幫助信息的)
第三個(gè)參數(shù):是否重復(fù)(1重復(fù),0不重復(fù))(即按下Enter鍵的時(shí)候,自動(dòng)執(zhí)行上次的命令)
第四個(gè)參數(shù):執(zhí)行函數(shù),即運(yùn)行了命令具體做啥會(huì)在這個(gè)函數(shù)中體現(xiàn)出來(lái)
第五個(gè)參數(shù):幫助信息(short)
第六個(gè)參數(shù):幫助信息(long)
*/
static int do_update(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
/* 判斷參數(shù)個(gè)數(shù) */
if (argc != 2)
{
printf("update params num err\n");
return 1;
}
if (0 == strncmp("uboot", argv[0], sizeof("uboot")))
{
printf("update uboot success\n");
}
else if (0 == strncmp("image", argv[0], sizeof("image")))
{
printf("update image success\n");
}
else if (0 == strncmp("rootfs", argv[0], sizeof("rootfs")))
{
printf("update rootfs success\n");
}
return 0;
}
/*
U_BOOT_CMD(_name, _maxargs, _rep, _cmd, _usage, _help)
*/
U_BOOT_CMD(update, 4, 0, do_update,
"update command",
" - check boot progress and timing\n"
"update all\n"
"update uboot \n"
"update image \n"
"update rootfs \n"
);
原文鏈接:https://blog.csdn.net/qq_20017379/article/details/127894303
相關(guān)推薦
- 2022-03-20 Entity?Framework?Core關(guān)聯(lián)刪除_實(shí)用技巧
- 2022-11-23 Python多線(xiàn)程使用方法詳細(xì)講解_python
- 2022-08-16 Hive常用日期格式轉(zhuǎn)換語(yǔ)法_數(shù)據(jù)庫(kù)其它
- 2022-09-04 ffmpeg網(wǎng)頁(yè)視頻流m3u8?ts實(shí)現(xiàn)視頻下載_相關(guān)技巧
- 2022-06-22 C語(yǔ)言詳解判斷相同樹(shù)案例分析_C 語(yǔ)言
- 2022-09-06 python實(shí)現(xiàn)plt?x軸坐標(biāo)按1刻度顯示_python
- 2022-04-19 一起來(lái)了解c語(yǔ)言的str函數(shù)_C 語(yǔ)言
- 2022-04-12 利用python?OpenCV去除視頻水印_python
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運(yùn)行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲(chǔ)小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運(yùn)算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過(guò)濾器
- Spring Security概述快速入門(mén)
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯(cuò)誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實(shí)現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡(jiǎn)單動(dòng)態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對(duì)象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊(duì)列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支