最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

uboot添加自定義命令的實現(xiàn)步驟

 更新時間:2022年11月18日 16:19:27   作者:IT小生lkc  
uboot 屬于bootloader的一種,是用來引導(dǎo)啟動內(nèi)核的,它的最終目的就是從flash中讀出內(nèi)核,放到內(nèi)存中,啟動內(nèi)核,這篇文章主要介紹了uboot添加自定義命令的實現(xiàn)步驟,需要的朋友可以參考下

uboot簡介

uboot 屬于bootloader的一種,是用來引導(dǎo)啟動內(nèi)核的,它的最終目的就是:從flash中讀出內(nèi)核,放到內(nèi)存中,啟動內(nèi)核。
它剛開始被放到flash上,然后上電以后先執(zhí)行它,它會完成硬件初始化,設(shè)置處理器模式,關(guān)閉看門狗,屏蔽中斷,初始化sdram,設(shè)置棧,設(shè)置時鐘,從flash引導(dǎo)內(nèi)核到內(nèi)存,就好像我們PC上的BIOS一樣。最終將系統(tǒng)的軟硬件帶到一個合適的狀態(tài)。

實現(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ù):

/*

    第一個參數(shù):添加的命令的名字

    第二個參數(shù):添加的命令最多有幾個參數(shù)(注意,假如你設(shè)置的參數(shù)個數(shù)是3,

              而實際的參數(shù)個數(shù)是4,那么執(zhí)行命令會輸出幫助信息的)

    第三個參數(shù):是否重復(fù)(1重復(fù),0不重復(fù))(即按下Enter鍵的時候,

              自動執(zhí)行上次的命令)

    第四個參數(shù):執(zhí)行函數(shù),即運行了命令具體做啥會在這個函數(shù)中體現(xiàn)出來

    第五個參數(shù):幫助信息(short)

    第六個參數(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: 這是默認設(shè)置,請設(shè)置`customMade`, 打開koroFileHeader查看配置 進行設(shè)置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include <common.h>
#include <command.h>
 
 
/*
    第一個參數(shù):添加的命令的名字
    第二個參數(shù):添加的命令最多有幾個參數(shù)(注意,假如你設(shè)置的參數(shù)個數(shù)是3,而實際的參數(shù)個數(shù)是4,那么執(zhí)行命令會輸出幫助信息的)
    第三個參數(shù):是否重復(fù)(1重復(fù),0不重復(fù))(即按下Enter鍵的時候,自動執(zhí)行上次的命令)
    第四個參數(shù):執(zhí)行函數(shù),即運行了命令具體做啥會在這個函數(shù)中體現(xiàn)出來
    第五個參數(shù):幫助信息(short)
    第六個參數(shù):幫助信息(long)
*/
static int do_update(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
    /* 判斷參數(shù)個數(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"
);

到此這篇關(guān)于uboot添加自定義命令的實現(xiàn)步驟的文章就介紹到這了,更多相關(guān)uboot添加自定義命令內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

您可能感興趣的文章:

相關(guān)文章

最新評論

阜南县| 新蔡县| 遂平县| 阿克陶县| 平顺县| 泾源县| 平利县| 犍为县| 陵水| 蚌埠市| 靖远县| 奉贤区| 理塘县| 城固县| 临城县| 岢岚县| 浦北县| 延长县| 台中市| 长兴县| 湛江市| 贺兰县| 宁化县| 黎平县| 尚志市| 河南省| 丹寨县| 洪湖市| 婺源县| 常宁市| 孟津县| 乌拉特前旗| 稻城县| 永福县| 临桂县| 东台市| 北川| 雅安市| 常山县| 敦化市| 堆龙德庆县|