Skip to main content.
Navigation:
DENX
>
DULG
>
UBootScripts
Translations:
Edit
|
Attach
|
Raw
|
Ref-By
|
Printable
|
More
DULG
Sections of this site:
DENX Home
|
DULG
|
ELDK-5
|
Know
|
Training
|
U-Boot
|
U-Bootdoc
Topics
DULG Home
BoardSelect
Manual
FAQ
Application Notes
Changes
Index
List of pages in DULG
Search
%SECTION0{name=UBootScripts}% U-Boot Scripting Capabilities U-Boot allows to store commands or command sequences in a plain text file. Using the =mkimage= tool you can then convert this file into a *script image* which can be executed using U-Boot's =source= command. For example, assume that you will have to run the following sequence of commands on many boards, so you store them in a text file, say ="setenv-commands"=: <verbatim> bash$ cat setenv-commands setenv loadaddr 00200000 echo ===== U-Boot settings ===== setenv u-boot /tftpboot/TQM860L/u-boot.bin setenv u-boot_addr 40000000 setenv load_u-boot 'tftp ${loadaddr} ${u-boot}' setenv install_u-boot 'protect off ${u-boot_addr} +${filesize};era ${u-boot_addr} +${filesize};cp.b ${loadaddr} ${u-boot_addr} ${filesize};saveenv' setenv update_u-boot run load_u-boot install_u-boot echo ===== Linux Kernel settings ===== setenv bootfile /tftpboot/TQM860L/uImage setenv kernel_addr 40040000 setenv load_kernel 'tftp ${loadaddr} ${bootfile};' setenv install_kernel 'era ${kernel_addr} +${filesize};cp.b ${loadaddr} ${kernel_addr} ${filesize}' setenv update_kernel run load_kernel install_kernel echo ===== Ramdisk settings ===== setenv ramdisk /tftpboot/TQM860L/uRamdisk setenv ramdisk_addr 40100000 setenv load_ramdisk 'tftp ${loadaddr} ${ramdisk};' setenv install_ramdisk 'era ${ramdisk_addr} +${filesize};cp.b ${loadaddr} ${ramdisk_addr} ${filesize}' setenv update_ramdisk run load_ramdisk install_ramdisk echo ===== Save new definitions ===== saveenv bash$ </verbatim> To convert the text file into a script image for U-Boot, you have to use the =mkimage= tool as follows: <verbatim> bash$ mkimage -T script -C none -n 'Demo Script File' -d setenv-commands setenv.img Image Name: Demo Script File Created: Mon Jun 6 13:33:14 2005 Image Type: PowerPC Linux Script (uncompressed) Data Size: 1147 Bytes = 1.12 kB = 0.00 MB Load Address: 0x00000000 Entry Point: 0x00000000 Contents: Image 0: 1139 Bytes = 1 kB = 0 MB bash$ </verbatim> On the target, you can download this image as usual (for example, using the ="tftp"= command). Use the ="source"= command to execute it: <verbatim> => tftp 100000 /tftpboot/TQM860L/setenv.img Using FEC ETHERNET device TFTP from server 192.168.3.1; our IP address is 192.168.3.80 Filename '/tftpboot/TQM860L/setenv.img'. Load address: 0x100000 Loading: # done Bytes transferred = 1211 (4bb hex) => imi 100000 ## Checking Image at 00100000 ... Image Name: Demo Script File Created: 2005-06-06 11:33:14 UTC Image Type: PowerPC Linux Script (uncompressed) Data Size: 1147 Bytes = 1.1 kB Load Address: 00000000 Entry Point: 00000000 Verifying Checksum ... OK => source 100000 ## Executing script at 00100000 ===== U-Boot settings ===== ===== Linux Kernel settings ===== ===== Ramdisk settings ===== ===== Save new definitions ===== Saving Environment to Flash... Un-Protected 1 sectors Un-Protected 1 sectors Erasing Flash... . done Erased 1 sectors Writing to Flash... done Protected 1 sectors Protected 1 sectors => </verbatim> %T% Hint: maximum flexibility can be achieved if you are using the Hush shell as command interpreter in U-Boot; see section %REF{type=Section,topic=CommandLineParsing,name=CommandLineParsing}%
5.10. U-Boot Environment Variables
1. Abstract
5.12. U-Boot Standalone Applications
Prev
Home
Next