Tuesday 3 April 2012

HowToUbootScriptcmd

U-boot is a very versatile universal opensource bootloader, a customized version of which is used in VT8500 and WM8505-based devices. It has a built-in mini-shell with some handy commands that can be accessed through a [[serial console]]. Alternatively, required command sequences to e.g. redefine boot parameters and load a custom OS (like the Linux kernel) can be put into a so-called scriptcmd file. This is basically just a plain text script for the U-boot’s shell with just some binary header added to it.
The useful fact is that by default VT8500/WM8505 versions of U-boot will happily execute a scriptcmd file put into a script/ folder on the first partition (FAT) of an SD card, which allows for a simple and non-destructive redefinition of the boot sequence.
Below are the simple steps to take to create your own scriptcmd file (assuming that you have the mkimage program from U-boot tools package installed already).
  • Create a plain text file with the commands you need and call it, for example, script.txt. In the simplest case its contents may be something like this:
setenv bootargs rootwait root=/dev/sda1
fatload mmc 0 0 /script/uImage
bootm 0
The first statement redefines the kernel command line to allow the first partition on a USB drive (/dev/sda1) to be used as a root filesystem. The second one loads /script/uImage from the first partition of the SD card to a memory address 0. The third one executes the Linux kernel uImage that we've just loaded into memory.
  • Generate the final scriptcmd file (the one with a binary header) by issuing a command like this:
mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n “My scriptcmd” -d script.txt scriptcmd
  • Put the scriptcmd file together with your kernel uImage to a script/ folder on the first (FAT) partition on an SD card and turn your device on with this card inserted. If everything is OK, your kernel should boot up.

No comments:

Post a Comment