Running a Script in U-boot

Showing results for 
Search instead for 
Did you mean: 

Running a Script in U-boot

No ratings

Running a Script in U-boot


  • An TFTP server
  • U-boot with TFTP capabilities

If you need to run a script (for example, running multiple setenv's commands) in U-boot for many boards, you can instead create a U-boot script (called script image), place it into your tftp folder, then ask U-boot to fetch it and run it. For example, you want to run the following setenv instructions

setenv loadaddr 0x10800000

setenv bootargs_base 'setenv bootargs console=ttymxc0,115200'

setenv bootargs_mmc 'setenv bootargs ${bootargs} root=/dev/mmcblk0p1 rootwait rw video=mxcfb0:dev=ldb,LDB-XGA,if=RGB666'

setenv bootcmd_mmc 'run bootargs_base bootargs_mmc;mmc dev 3;mmc read ${loadaddr} 0x800 0x2000;bootm'

run bootcmd_mmc

save it into a file, I choose the name 'myscript'; under your <U-boot folder>/tools, execute

$ mkimage -T script -C none -n 'My Script' -d myscript myscript.img

and copy myscript.img file into your TFTP folder.

On the target, set the following two variables (serverip and bootcmd)

# Set the Server IP, where the TFTP server is running

setenv serverip <the server IP> # In case the server IP is static, you can place this line into the U-boot script

setenv scriptaddr 0x10700000

setenv scriptname myscript.img

# You can use either TFTP or DHCP

setenv tftpcmd tftp # or 'dhcp'  in case you want to use dhcp U-boot command

# Not needed for dhcp

setenv ipaddr <the target IP> # needed in case the command tftp is used

setenv gatewayip <the Gateway IP> # needed in case the command tftp is used

setenv bootcmd '${tftpcmd} ${scriptaddr} ${scriptname}; source ${scriptaddr}'



That is all you need to do.

Enjoy U-booting!


I have a custom made board of i.MX6, i have to add a script which test RAM working, for that i have to copy my script in SD/MMC(8GB) card,this testing will be done in uboot, now i need some help on this i have  created script file using mkimage. for this where i can copy and how to run that script at what address location. NOTE: i can't use tftp/dhcp because this board doesn't have tftp/dhcp support.

Version history
Revision #:
1 of 1
Last update:
‎10-15-2012 12:25 PM
Updated by: