Booting Linux kernel using U-Boot

From Texas Instruments Embedded Processors Wiki

Jump to: navigation, search
Translate this page to   

Contents

Setting up

Booting the kernel requires a valid kernel image (uImage) and a target filesystem.

U-Boot implements tftp command to download the kernel and filesystem (in case of ramdisk) images to SDRAM. You can then choose to directly boot the newly downloaded images or write them to non-volatile memory using U-Boot commands and then copy the the images to SDRAM from this memory for subsequent boots.

To use TFTP download, you must first set up the DUT IP parameters. The easiest way to do this is to use the DHCP server on your network.

  1. Connect the Ethernet cable to the board's PHY
  2. Copy the kernel Image (uImage) to the /tftpboot directory of your Linux host workstation. If you do not have a TFTP server configured please see the Setting up a TFTP Server.
  3. host$ cp <path to uImage file> /tftpboot
    
    
  4. Copy the file system image from the /tftpboot directory of your Linux host workstation.
  5. NOTE: For Community Linux based SDK, use the RAM disk filesystem arago-base-image-arago.ext2.gz from Arago project. The SDK download page for OMAP-L1 or AM18x has a filesystem tarball with demo which can be exported as NFS (Network Filesystem) or converted to a ramdisk and used as root filesystem in case there is enough RAM available.

    For Montavista Linux based releases for OMAP-L137, use the file /opt/mv_pro_5.0/montavista/pro/devkit/arm/v5t_le/images/ramdisk.gz from your MontaVista Linux installation.

    host$ cp <path to ramdisk file> /tftpboot
    
  6. Setup the EVM IP address. You have two ways of doing it
    • Use DHCP
    • U-Boot> setenv autoload no
      U-Boot> dhcp
      
    • Use static IP address
    • U-Boot> setenv ipaddr <static ip address>
      
  7. Get the IP address of your host Linux workstation as follows. Look for the IP address associated with the eth0 ethernet port.
  8. host /sbin/ifconfig
    
  9. Set the IP address of the server from what was obtained above (Note that this may also be obtained from DHCP)
  10. U-Boot> setenv serverip <ip addr of server>
    
  11. Set the name of the image to be downloaded (this may also be obtained from DHCP)
  12. U-Boot> setenv bootfile <Linux kernel image file name>
    

You can get help on U-Boot commands by using the U-Boot "help" command. Typing help at the U-Boot command prompt gives a list of commands supported. Typing help followed by a command name gives help regarding that particular command. Help on U-Boot commands is also available at http://www.denx.de/wiki/view/DULG/UBoot.

Default U-Boot comes with SPI flash support. To enable support for other flash types (NAND, NOR), you need to re-build U-Boot. Once you have a new U-Boot image, please flash the new U-Boot images. Here is the procedure for OMAP-L137 (or DA830, AM17xx) and OMAP-L138 (or DA850, AM18xx) EVMs.

NOTE: If you are trying to use the TFTP server on Windows host machine, you may observe Timeouts as the server is not able to get the ACK block from the target. Root cause of this issue is the inability of the Windows based TFTP server to handle large TFTP block size. To fix this, issue the following command:

U-Boot> setenv tftpblocksize 512

Other way of fixing this problem is to switch to Linux based TFTP servers.

Booting

Note that bootargs in these examples sets ip=dhcp. If your EVM is not connected to a network with a DHCP server, you will want to set ip=off. For booting with NFS as root file system, having a valid IP address is a must.

SDRAM

This method downloads the kernel and ramdisk image from ethernet using TFTP into SDRAM, then boots the kernel image from SDRAM. Use the following settings for U-Boot environment variables bootargs and bootcmd and reboot the DUT:

U-Boot> setenv bootargs mem=32M console=ttyS2,115200n8 root=/dev/ram0 rw initrd=0xc1180000,4M ip=dhcp eth=${ethaddr}
U-Boot> setenv bootcmd 'tftp 0xc0700000 uImage; tftp 0xc1180000 <ramdisk file name>; bootm 0xc0700000'

SPI Flash

The SPI flash on the OMAP-L137 (or DA830, AM17xx) EVM board is 4 MBytes and that on OMAP-L138 (or DA850, AM18xx) EVM board is 8 MBytes in size. Depending on the size of the kernel and filesystem, you may not be able to fit both of them on the SPI flash. If both of them do not fit, we recommend that you keep the kernel image on SPI flash and use another medium to the store the filesystem.

In the example below, both kernel and filesystem reside on the SPI flash. While booting, U-Boot copies both kernel and filesystem from SPI flash to external RAM and boots the kernel which later mounts the filesystem as a ramdisk.

  1. Select the serial flash device:
  2. U-Boot> sf probe 0
    
  3. Download uImage and copy it to the SPI flash partition:
  4. U-Boot> tftp 0xc0700000 uImage
    U-Boot> sf erase 0x80000 0x200000
    U-Boot> sf write 0xc0700000 0x80000 0x200000
    
  5. Download ramdisk and copy it to the SPI flash partition:
  6. U-Boot> tftp 0xc1180000 <ramdisk file name>
    U-Boot> sf erase 0x280000 0x400000
    U-Boot> sf write 0xc1180000 0x280000 0x400000
    
  7. Set up the bootargs and bootcmd environment variables to boot from SPI flash:
  8. U-Boot> setenv bootargs mem=32M console=ttyS2,115200n8 root=/dev/ram0 rw initrd=0xc1180000,4M ip=dhcp eth=${ethaddr}
    U-Boot> setenv bootcmd 'sf probe 0;sf read 0xc0700000 0x80000 0x200000;sf read 0xc1180000 0x280000 0x400000;bootm 0xc0700000'
    

All these steps can be made a part of the bootcmd environment variable.

U-Boot> setenv bootcmd 'sf probe 0; sf read 0xc0700000 0x1E0000 0x220000; bootm 0xc0700000'

NOTE: You can also probe 1 if the flash is connected to SPI1.

NOTE: The value 0x220000 is a byte count denoting the size of uImage and may need to be modified if the size of the Linux kernel increases.

NAND Flash (ramdisk as rootfs)

  1. Download uImage and copy it to the NAND partition:
  2. U-Boot> tftp 0xc0700000 uImage
    U-Boot> nand erase 0x200000 0x200000
    U-Boot> nand write.e 0xc0700000 0x200000 0x200000
    
  3. Download ramdisk, and copy it to NAND flash:
  4. U-Boot> tftp 0xc1180000 <ramdisk file name>
    U-Boot> nand erase 0x400000 0x400000
    U-Boot> nand write.e 0xc1180000 0x400000 0x400000
    
  5. Set up the bootargs and bootcmd environment variables to boot from NAND flash:
  6. U-Boot> setenv bootcmd 'nand read.e 0xc1180000 0x400000 0x400000; nboot.e 0xc0700000 0 0x200000; bootm'
    U-Boot> setenv bootargs mem=32M console=ttyS2,115200n8 root=/dev/ram0 rw initrd=0xc1180000,4M ip=dhcp eth=${ethaddr}
    

NAND Flash (jffs2 image as rootfs)

  1. Download uImage and copy it to the NAND partition:
  2. U-Boot> tftp 0xc0700000 uImage
    U-Boot> nand erase 0x200000 0x200000
    U-Boot> nand write.e 0xc0700000 0x200000 0x200000
    
  3. Boot Linux using NFS, Download the jffs2 image, erase the NAND partition and write the jffs2 file system image to the NAND partition
  4. target$ tftp -r rootfs-base.jffs2 -g <ip_address_of_tftp_server>
    target$ flash_eraseall /dev/mtdX
    target$ nandwrite -p /dev/mtdX <jffs2_file_system_image>
    
  5. Reset the board, Set up the bootargs and bootcmd environment variables to boot from NAND flash:
  6. U-Boot> setenv bootcmd 'nand read.e 0xc1180000 0x400000 0x400000; nboot.e 0xc0700000 0 0x200000; bootm'
    U-Boot> setenv bootargs mem=32M console=ttyS2,115200n8 root=/dev/mtdblockX rw rootfstype=jffs2 ip=dhcp eth=${ethaddr}
    

Note: In the above commands 'X' in '/dev/mtdX' and '/dev/mtdblockX' refer to the NAND partition which is reserved for file system.

NOR Flash

Note: Currently, booting from NOR is supported only on OMAP-L138 (or DA850, AM18xx).

The NOR flash on the EVM boards is 8 MBytes in size. Depending on the size of the kernel and filesystem, you may not be able to fit both of them on the NOR flash. If both of them do not fit, we recommend that you keep the kernel image on NOR flash and use another medium to the store the file system.

In the example below, both kernel and filesystem reside on the NOR flash. While booting, U-Boot copies both kernel and filesystem from NOR flash to external RAM and boots the kernel which later mounts the filesystem as a ramdisk.

  1. Download uImage and copy it to NOR flash partition
  2. U-Boot> tftp 0xc0700000 uImage
    U-Boot> erase 60080000 +200000
    U-Boot> cp.b c0700000 60080000 200000
    
  3. Download ramdisk and copy it to NOR flash partition
  4. U-Boot> tftp 0xc1180000 <ramdisk file name>
    U-Boot> erase 60280000 +400000
    U-Boot> cp.b c1180000 60280000 400000
    
  5. Setup the bootargs and bootcmd environment variables to boot from SPI flash
  6. U-Boot> setenv bootargs mem=32M console=ttyS2,115200n8 root=/dev/ram0 rw initrd=0xc1180000,4M ip=dhcp
    U-Boot> setenv bootcmd 'cp.b 60080000 c0700000 200000;cp.b 60280000 c1180000 400000;bootm 0xc0700000'
    

USB Storage

U-boot includes support for loading files from USB mass storage devices into memory. This section explains steps for configuring U-Boot to enable USB and mass storage support in U-Boot. It also shows U-Boot commands used for initializing and loading files from mass storage devices connected to USB 2.0 port on the EVM.

The default U-Boot image provided in the with PSP installation has USB MSC support enabled.

Use the following sequence of U-Boot commands to load the Linux kernel image from the USB mass storage device. The files need to be loaded onto the USB disk by mounting it on a host machine first. Note: that the USB device should be connected to the EVM before running these commands.

U-Boot> usb reset
U-Boot> fatload usb 0:1 0xC0700000 uImage

You can use the following additional commands to identify the device attached:

U-Boot> fatls usb 0:1

All these steps can be made a part of the bootcmd environment variable.

U-Boot> setenv bootcmd 'usb start; fatload usb 0:1 0xC0700000 uImage; bootm 0xc0700000'
E2e.jpg For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article Booting Linux kernel using U-Boot here.
Hyperlink blue.png Links
ARM Microcontroller MCU ARM Processor Digital Media Processor Digital Signal Processing Microcontroller MCU Multi Core Processor
Ultra Low Power DSP 8 bit Microcontroller MCU 16 bit Microcontroller MCU 32 bit Microcontroller MCU

Leave a Comment

Comments

Comments on Booting Linux kernel using U-Boot


Scraimer said ...

I spent a lot of time trying to fix intermittent TFTP timeouts while downloading the linux kernel. It turned out that the network I was on had a huge number of Bonjour ("Rendezvous Browser") clients which kept spamming the network with packets. Although this didn't cause congestion, my board still had to handle each and every Ethernet packet, which made it miss out on a few of the TFTP packets.

The solution was to connect the board to my computer directly. I installed another Ethernet card, and used a cross-over cable to make a mini-network of only my computer and the board.

--Scraimer 00:36, 4 December 2011 (CST)

Personal tools
Namespaces
Variants
Actions
Navigation
Print/export
Toolbox