Booting Linux kernel using U-Boot
http://processors.wiki.ti.com/index.php/Booting_Linux_kernel_using_U-Boot#SDRAMBooting Linux kernel using U-BootTranslate this page to cs - Česky de - Deutsch es - Español fi -
http://processors.wiki.ti.com/index.php/Booting_Linux_kernel_using_U-Boot#SDRAM
Booting Linux kernel using U-Boot
Contents[hide] |
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.
- Connect the Ethernet cable to the board's PHY
- 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.
host$ cp <path to uImage file> /tftpboot
- Copy the file system image from the /tftpboot directory of your Linux host workstation.
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
- 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>
- Use DHCP
- Get the IP address of your host Linux workstation as follows. Look for the IP address associated with the eth0 ethernet port.
host /sbin/ifconfig
- Set the IP address of the server from what was obtained above (Note that this may also be obtained from DHCP)
U-Boot> setenv serverip <ip addr of server>
- Set the name of the image to be downloaded (this may also be obtained from DHCP)
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.
- Select the serial flash device:
U-Boot> sf probe 0
- Download uImage and copy it to the SPI flash partition:
IMPORTANT
The size and offset values given below are to be considered representative only. To know the exact value of offset, please refer to the SPI flash partition information from Kernel bootlog. Size parameter depends on the actual size of respective images.U-Boot> tftp 0xc0700000 uImage U-Boot> sf erase 0x80000 0x200000 U-Boot> sf write 0xc0700000 0x80000 0x200000
- Download ramdisk and copy it to the SPI flash partition:
U-Boot> tftp 0xc1180000 <ramdisk file name> U-Boot> sf erase 0x280000 0x400000 U-Boot> sf write 0xc1180000 0x280000 0x400000
- Set up the bootargs and bootcmd environment variables to boot from SPI flash:
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)
IMPORTANT
The size and offset values given below are to be considered representative only. To know the exact value of offset, please refer to the NAND flash partition information from Kernel bootlog. Size parameter depends on the actual size of respective images.- Download uImage and copy it to the NAND partition:
U-Boot> tftp 0xc0700000 uImage U-Boot> nand erase 0x200000 0x200000 U-Boot> nand write.e 0xc0700000 0x200000 0x200000
- Download ramdisk, and copy it to NAND flash:
U-Boot> tftp 0xc1180000 <ramdisk file name> U-Boot> nand erase 0x400000 0x400000 U-Boot> nand write.e 0xc1180000 0x400000 0x400000
- Set up the bootargs and bootcmd environment variables to boot from NAND flash:
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)
- Download uImage and copy it to the NAND partition:
IMPORTANT
The size and offset values given below are to be considered representative only. To know the exact value of offset, please refer to the NAND flash partition information from Kernel bootlog. Size parameter depends on the actual size of respective images.U-Boot> tftp 0xc0700000 uImage U-Boot> nand erase 0x200000 0x200000 U-Boot> nand write.e 0xc0700000 0x200000 0x200000
- Boot Linux using NFS, Download the jffs2 image, erase the NAND partition and write the jffs2 file system image to the NAND partition
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>
- Reset the board, Set up the bootargs and bootcmd environment variables to boot from NAND flash:
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.
NAND Flash (UBIFS image as rootfs)
- Download uImage and copy it to the NAND partition:
IMPORTANT
The size and offset values given below are to be considered representative only. To know the exact value of offset, please refer to the NAND flash partition information from Kernel bootlog. Size parameter depends on the actual size of respective images.U-Boot> tftp 0xc0700000 uImage U-Boot> nand erase 0x400000 0x400000 U-Boot> nand write.e 0xc0700000 0x400000 0x400000
- Create an UBIFS file system image.
- Boot Linux using NFS, Download the UBIFS image, erase the NAND partition and write the UBIFS file system image to the NAND partition
target$ tftp -r ubi.img -g <ip_address_of_tftp_server> target$ flash_eraseall /dev/mtdX target$ ubiformat /dev/mtdX -f ubi.img -s 512 -O 2048
UBIFS Image can also be flashed from U-Boot.
- Reset the board, Set up the bootargs and bootcmd environment variables to boot from NAND flash:
U-Boot> setenv bootcmd 'nand read.e 0xc1180000 0x400000 0x400000; nboot.e 0xc0700000 0 0x400000; bootm' U-Boot> setenv bootargs mem=32M console=ttyS2,115200n8 root=ubi0:rootfs rw rootfstype=ubifs ubi.mtd=X,2048 ip=dhcp
Note: In the above commands 'X' in '/dev/mtdX' 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.
- Download uImage and copy it to NOR flash partition
IMPORTANT
The size and offset values given below are to be considered representative only. To know the exact value of offset, please refer to the NOR flash partition information from Kernel bootlog. Size parameter depends on the actual size of respective images.U-Boot> tftp 0xc0700000 uImage U-Boot> erase 60080000 +200000 U-Boot> cp.b c0700000 60080000 200000
- Download ramdisk and copy it to NOR flash partition
U-Boot> tftp 0xc1180000 <ramdisk file name> U-Boot> erase 60280000 +400000 U-Boot> cp.b c1180000 60280000 400000
- Setup the bootargs and bootcmd environment variables to boot from SPI flash
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.
- usb reset This command initiates the USB enumeration process to identify all the devices connected to the USB 2.0 port. U-Boot supports devices directly connected to the USB port or via high/full speed hubs. After the command executes, the number of USB devices found on the bus and the number of storage devices detected is displayed. The command usb start also is equivalent to usb reset. For example, the following command initiates USB enumeration and identifies the storage devices attached to USB.
U-Boot> usb reset
- fatload usb dev[:part] address filename This command loads a file from a mass storage device. For the dev parameter you should specify the number of the storage device found on the USB bus by the usb reset command. The usb storage devices are number sequentially from zero onwards. For part specify the partition number on the mass storage device. For address specify the starting address in memory where the file has to be loaded. For filename specify the file to be loaded from the mass storage device. For example, the following command loads the Linux kernel image from USB storage device 0 partition 1 to SDRAM.
U-Boot> fatload usb 0:1 0xC0700000 uImage
You can use the following additional commands to identify the device attached:
- fatls usb dev[:part][directory] This command lists the files on a USB mass storage device. The dev and part parameters are the same as for the fatload command. For the optionaldirectory parameter you can specify the directory from which the contents have to be listed. For example, the following command lists the contents of the first partition on the first USB storage device.
U-Boot> fatls usb 0:1
- usb tree This command displays a tree of all usb devices enumerated during the usb reset command execution.
- usb info This command displays device information of all usb devices enumerated during the usb reset command execution.
- usb read <addr> <startblock> <numblocks> This command reads the contents of the logical sectors in the mass storage device to memory.
- usb stop This command disables the USB module and the USB phy.
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'
更多推荐
所有评论(0)