網站首頁 編程語言 正文
uboot簡介
uboot 屬于bootloader的一種,是用來引導啟動內核的,它的最終目的就是:從flash中讀出內核,放到內存中,啟動內核。
它剛開始被放到flash上,然后上電以后先執行它,它會完成硬件初始化,設置處理器模式,關閉看門狗,屏蔽中斷,初始化sdram,設置棧,設置時鐘,從flash引導內核到內存,就好像我們PC上的BIOS一樣。最終將系統的軟硬件帶到一個合適的狀態。
實現步驟:
- 1.uboot源碼下新建cmd/cmd_xx.c
- 2.添加基本的命令和函數
- 3.cmd下makefile添加 obj-y += cmd_update.o
頭文件:
#include <common.h>
#include <command.h>
函數:
/*
第一個參數:添加的命令的名字
第二個參數:添加的命令最多有幾個參數(注意,假如你設置的參數個數是3,
而實際的參數個數是4,那么執行命令會輸出幫助信息的)
第三個參數:是否重復(1重復,0不重復)(即按下Enter鍵的時候,
自動執行上次的命令)
第四個參數:執行函數,即運行了命令具體做啥會在這個函數中體現出來
第五個參數:幫助信息(short)
第六個參數:幫助信息(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: 這是默認設置,請設置`customMade`, 打開koroFileHeader查看配置 進行設置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
#include <common.h>
#include <command.h>
/*
第一個參數:添加的命令的名字
第二個參數:添加的命令最多有幾個參數(注意,假如你設置的參數個數是3,而實際的參數個數是4,那么執行命令會輸出幫助信息的)
第三個參數:是否重復(1重復,0不重復)(即按下Enter鍵的時候,自動執行上次的命令)
第四個參數:執行函數,即運行了命令具體做啥會在這個函數中體現出來
第五個參數:幫助信息(short)
第六個參數:幫助信息(long)
*/
static int do_update(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
/* 判斷參數個數 */
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
相關推薦
- 2022-06-12 C#集合之有序列表的用法_C#教程
- 2022-05-09 Python?matplotlib繪制實時數據動畫_python
- 2024-02-28 UNI-APP,設置某個頁面橫屏后,恢復豎屏,返回再次進入其他頁面時,頁面內容放大錯亂
- 2022-10-22 如何在Go中使用Casbin進行訪問控制_Golang
- 2022-11-05 Nginx配置文件nginx.conf的基本配置實例詳解_nginx
- 2022-10-20 Android開發使用RecyclerView添加點擊事件實例詳解_Android
- 2023-02-23 Redis的setNX分布式鎖超時時間失效?-1問題及解決_Redis
- 2022-06-10 AJAX原理以及axios、fetch區別實例詳解_AJAX相關
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支