Wednesday, January 27, 2016

Important Uboot Commands - Loady usage in Booting from RAM

The exact set of commands depends on the U-Boot configuration, however these are the important list of commands for reference. This also would be quite helpful for debugging Bootloader(Uboot) related issues :-

This post doesn't describe all the command in detail from usage wise however there has been two important example covered in the post.

  • help and help command
  • boot, runs the default boot command, stored in bootcmd
  • bootm / bootz  starts a kernel image loaded at the given address in RAM
  • ext2load, loads a file from an ext2 filesystem to RAM And also ext2ls to list files, ext2info for information
  • fatload, loads a file from a FAT filesystem to RAM and also fatls and fatinfo
  • tftp, loads a file from the network to RAM
  • ping, to test the network
  • loadb, loads, loady, load a file from the serial line to RAM
  • usb, to initialize and control the USB subsystem, mainly used for USB storage devices such as USB keys
  • mmc or mmc rescan , to initialize and control the MMC subsystem, used for SD and microSD cards
  • nand, to erase, read and write contents to NAND flash
  • erase, protect, cp, to erase, modify protection and write to NOR flash
  • md, displays memory contents. Can be useful to check the contents loaded in memory, or to look at hardware registers.
  • mm, modifies memory contents. Can be useful to modify directly hardware registers, for testing purposes.


Commands to manipulate environment variables:
  • printenv  [ Shows the value of a variable ]
  • setenv [ Changes the value of a variable, only in RAM ]
  • editenv [ Edits the value of a variable, only in RAM ]
  • saveenv  [ Saves the current state of the environment to flash ]

List of Important Environment variables :-

  • bootcmd, contains the command that U-Boot will automatically execute at boot time after a configurable delay(bootdelay), if the process is not interrupted.
  • bootargs, contains the arguments passed to the Linux kernel. 
  • serverip, the IP address of the server that U-Boot will contact for network related commands.
  • ipaddr, the IP address that U-Boot will use. 
  • netmask, the network mask to contact the server.
  • ethaddr, the MAC address, can only be set once. 
  • autostart, if yes, U-Boot starts automatically an image that has been loaded into memory.
  • filesize, the size of the latest copy to memory (from tftp, fat load, nand read...)


Example of Uboot commands to boot a Linux/Arm system from MMC (assuming that bootargs are not part of kernel configuration) :-

/* This commands is to set the bootargs */
setenv bootargs console=ttymxc1,115200 root=/dev/mmcblk0p7 ro rootwait rootfstype=ext4 earlyprintk no_console_suspend=1 consoleblank=0 init=/sbin/init log_buf_len=1M cma=128M mem=256M galcore.contiguousSize=67108864 lpj=3948544

Note an important configuration in bootargs is the "size of RAM"

The usual commands to boot into normal kernel from a MMC device :-

/* Select the MMC device */
mmc dev 2  

/* Read the MMC and keep the Linux kernel uImage(Assuming that DTB is already part of uImage) in 0x10500000 address in RAM */
mmc read 0x10500000 800 4000  

Note that 800 is the block number, 4000 number of blocks of MMC

/* The command to set the PC to 0x10500000 address and run */
bootm 0x10500000


Off Topic :-  the uImage for UBOOT is created in the two following steps :-

1. Copying the DTB to zImage(The Kernel Image) - This is optional as the uImage may or may not have the DTB.

2. Use the mkimage utility to create the uImage.

What If the DTB is not part of uImage?

Let have a look at these steps below which loads dtb into a particular address in the RAM and then boots the system,the DTB and uImage is loaded from USB to RAM. Below are the command to be run from Uboot prompt.

fatload usb 0 0x1070000 am335x-boneblack.dtb

fatload usb 0 0x1090000 uImage

bootm 0x1070000 - 0x1090000

How to boot Linux kernel image without flashing into EMMC or NAND and directly writing into RAM from the UBOOT prompt :-

1. loady 0x10500000 921600

2. Switch the baud rate for teraterm or console which your are using to 921600

3. Send kernel image over ymodem  : Go to File -> Transfer -> YMODEM -> Send -> browse and select the kernel image which you want to boot.

The pic below for reference.




4. Switch back to baud 115200 after the transfer is complete and press ESC to comeback to Uboot prompt.
5. bootm 0x10500000  // To Boot the Kernel (Assuming that DTB is already part of uImage)

Note that All UBOOT commands depends upon the overall porting and configuration of UBOOT which is beyond the scope of this blog post.

No comments:

Post a Comment