在uboot裡面加入環境變數使用run來執行

2021-09-07 05:42:02 字數 4539 閱讀 5995

author

:楊正date

:2014.11.11   email

[email protected]

在移植uboot的時候,能夠在uboot裡面加入定義一些自己的環境變數,這些環境變數能夠大大提高以後的工作效率,比方我在uboot裡面加入例如以下環境變數:

bbl=sf probe 0;mw.b 82000000 ff 80000;loady0x82000000 uboot_logo.bin;sf erase 0 80000;sf write 82000000 0 80000

然後使用run命令來執行:

hisilicon #run bbl

16384 kib hi_sfc at 0:0 is now currentdevice

## ready for binary (ymodem) download to0x82000000 at 115200 bps...

cccstarting ymodem transfer.  press ctrl+c to cancel.

100%     222 kb    6 kb/s 00:00:36       1 errors

## total size      = 0x000379ec = 227820 bytes

erasing at 0x80000 -- 100% complete.

writing at 0x80000 -- 100% complete.

那麼這樣就不用每次都輸入非常長的一串字串,如:

hisilicon # sf probe 0;mw.b 82000000 ff80000;loady 0x82000000 uboot_logo.bin;sf erase 0 80000;sf write 82000000 080000

那麼方法例如以下:

一、            在uboot裡面加入環境變數

1、  在u-boot-2010.06/include/configs資料夾下的***.h(***是board,如hi3520d.h)裡面定義環境變數:

/* burn bootloader, linux kernel and rootfscommand */

#define config_burnbl       "sf probe 0;mw.b 82000000 ff80000;loady 0x82000000 uboot_logo.bin;sf erase 0 80000;sf write 82000000 0 8

0000"

#define config_burnkernel"sf probe 0;mw.b 82000000 ff 480000;loady 82000000 root_cramfs.img;sferase 80000 0x480000;sf write 8200000

0 80000 480000"

500000 0xa00000"

#define config_burn_flash"sf probe 0;mw.b 82000000 ff 1000000;loady 0x82000000zmd-programming-flash.binl;sf erase 0 1000000;sf writ

e 82000000 0 1000000"

2、  然後在u-boot-2010.06/common資料夾下的evn_common.c裡面加入例如以下**:

#ifdef config_burnbl       /* burn bootloader image to spiflash*/

"bbl=" config_burnbl "\0"

#endif             

#ifdef config_burnkernel    /* burn kernel image to spiflash*/

"blx="config_burnkernel   "\0"

#endif

#endif

"bfl="config_burn_flash  "\0"

#endif

3、  又一次編譯uboot,並燒錄到單板,用printenv或pri能夠看到已定義的環境變數:

二、            在uboot裡面加入run命令

1、  在u-boot-2010.06/common資料夾下加入乙個檔案cmd_run.c,**例如以下:

*      filename:  cmd_run.c

*   description:  this file

*       version:  1.0.0(11/11/2014~)

*        author:  yang zheng

*     changelog:  1, release initialversion on "11/11/2014 09:05:08 pm"

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

int do_run(int argc, char **argv)

if (argc < 2)

cmd_usage(cmdtp);

return 1;

if (cmd_tbl_t * cmdtp, int flag, 

run_command (getenv (argv[1]), flag)

< 0)

return -1;

return 0;

u_boot_cmd(

boot,   1,  1, do_run

"boot default, i.e., run 'bootcmd'",

2、  然後在u-boot-2010.06/include/configs資料夾的***.h(***是board。如hi3520d.h)裡面加入例如以下巨集定義:

#define config_cmd_run

3、在u-boot-2010.06/common資料夾的makefile中加入例如以下**:

cobjs-$(config_cmd_run) += cmd_run.o

4、  又一次編譯uboot,並燒錄到單板

三、            執行

hisilicon #run bbl

16384 kib hi_sfc at 0:0 is now current device

## ready for binary (ymodem) download to0x82000000 at 115200 bps...

c

uboot 環境變數設定研究

首先要知道uboot的第二個階段是從libarm board.c開始的,void start armboot void 這個函式是檢查flash上的環境變數是否有效,下面的 中的init sequence就是初始化列表 for init fnc ptr init sequence init fnc ...

uboot常用的環境變數

環境變數 相當於程式中的全域性變數,但是這裡不同的時在 uboot 雲翔的過程中,這個環境變數始終都是存在的。並且不會消失。環境變數 含義ipaddr 開發板本地的 ip位址 serverip 開發板通過 tftp 指令去tftp tftp 伺服器的 ip位址 gatewayip 開發板的本地閘道器...

Uboot中的環境變數

環境變數其實在uboot中就是一些全域性變數,用來修改uboot執行時的一些特徵,其外在表現為乙個個字串。環境變數的作用 能夠在不用重新編譯的前提下改變uboot執行時所表現出來的特徵,這樣當要調整uboot執行時特性就不用重新修改 編譯 執行uboot了。正常情況下環境變數應該同uboot ker...