OMAP-L138 Preparing SD Card for Boot

From Texas Instruments Wiki
Jump to: navigation, search

This document describes the boot process of the OMAP-L138 ARM+DSP SOC. The content also applies to AM1808 and C6748 devices unless otherwise specified.

Introduction

Starting with silicon revision 2.1, OMAP-L138 now supports SD/MMC boot directly from a card. This eliminates the need for a separate UBL that boots from on-board flash memory.

Formatting Requirements

The bootloader requires that the AIS boot image be placed within the first 2MB and sector-aligned. The image is read raw so the image must be in an unformatted partition of the card.

TI Tools

  • Serial Flashing Tools: The most recent version of the serial flashing tools now contains CCS3.3 ARM and DSP projects flashing a file to an SD/MMC card using the EVM. They may also be imported to CCS4 or CCS5.
  • Linux SDK: The Linux Software Development Kit (SDK) provides scripts for formatting SD/MMC cards for Linux kernels and file systems.

Procedures

Booting a Stand-Alone Image

When no other partitions or file systems are needed on the SD/MMC card, you can directly write an AIS-signed executable to the start of the SD/MMC card. This can be performed using CCS or Linux:

CCS

To flash a single AIS image, open SDMMCWriter_ARM.pjt (or DSP) located in the "OMAP-L138\CCS\SDMMCWriter\" directory of the serial flashing tools. For CCS4/5 it will need to be imported in order to rebuild the flashing tool.

Follow the following steps

  • Load the EVM GEL file
  • Connect to the ARM core (or DSP core)
  • Load the SDMMCWriter_ARM(DSP).out and run
  • Type "y" when asked if you will be writing a UBL image
  • Type the name of the AIS file to flash
  • Type "none" when asked to enter the application file name

The file should now be successfully flashed to the SD/MMC card. Change the boot switches to SDMMC0 boot mode and power cycle to verify.

Linux

  • Insert the SD/MMC card into a Linux host.
  • Type "dmesg". The SD/MMC card name should show up near the end, usually something like "SDC".
  • Type "sudo dd if=ais_file.bin of=/dev/sdx", where ais_file.bin is the file to flash and "sdx" is the name determined in the previous step.

The file should now be successfully flashed to the SD/MMC card. Change the boot switches to SDMMC0 boot mode and power cycle to verify.

Booting Linux

In order to boot Linux entirely off the SD/MMC card, there must be 3 separate partitions:

  1. Unformatted partition to flash AIS-signed U-Boot image
  2. FAT32 file system to store the Linux kernel for U-Boot to read
  3. EXT3 file system to store the file system Linux will mount

Perform the following steps to set up the card:

  • On a Windows machine, use AISgen to convert the U-Boot binary to a bootable AIS file.
    • You must specify the entry point as shown below in addition to the load address (adding @ to the application file). Be sure to do both. The ARM Application File defaults to @0x8000000 and will be loaded to the wrong address if you don't explicitly modify it!
    • Certain version of U-Boot do not enable the UART2 PSC, so select "Configure PSC" and in the PSC tab, type "13" in the "Enable LSPC" field for PSC1.

Uboot.jpg

  • On the Linux host, use the "mksdboot.sh" script found in the /bin/ directory of the SDK install as follows, where "sdx" is where the SD/MMC card is detected:

sudo mksdboot.sh --device /dev/sdx --sdk <base directory of SDK install>

  • After it has completed, remove and reinsert the card. You should see two partitions, one with uImage and another with the file system mounted.
  • Now write the AIS-signed U-Boot directly to the card. To prevent overwriting the boot table, write to offset 10 of the card as follows:

sudo dd in=u-boot.ais of=/dev/sdx seek=10

The SD card should now be successfully prepared. Change the boot switches to SDMMC0 boot mode and power cycle to verify.

A Complete procedure on How to boot Linux from SD/MMC card on OMAP138 SDI EVM

Formatting the SD/MMC card

In order to boot Linux entirely off from the SD/MMC card, there must be 4 separate partitions (The 4th partition is optional): In other ways, need to create SD card into 3 partitions with leaving atleast ~500K space before the first cylinder for keeping the u-boot binary.

   1. Unformatted partition to flash u-boot.bin image.
   2. FAT32 file system to store the Linux kernel for U-Boot to read.
   3. EXT3 file system to store the file system. Linux will mount.
   4. EXT3 file system to store the media files.

Format the SD/MMC card using Linux Host PC: Download the below script files to format the SD/MMC card.

File:Create-sdcard-omapl13x.zip

   1. Insert the SD/MMC card into a Linux host PC.
   2. Type "dmesg". The SD/MMC card name should show up something like "sdb" or “mmcblk0” .
   3. Type "'sudo sh create-sdcard-omapl13x.sh /dev/sdx'", where "sdx" is the name determined in the previous step.

Preparation of SPL and u-boot binaries

For SPL & u-boot,

   1. Change the working directory to uboot source folder.
   2. Build u-boot source for OMAPL138 SDI EVM board with mmc support.
   3. Convert the SPL bin to AIS signed format.

Linux Commands

    host# cd DaVinci-PSP-SDK-03.22.00.06/src/u-boot/u-boot-davinci
    DaVinci-PSP-SDK-03.22.00.06/src/u-boot/u-boot-davinci# make distclean CROSS_COMPILE=arm-none-linux-gnueabi-
    DaVinci-PSP-SDK-03.22.00.06/src/u-boot/u-boot-davinci# make da850sdi_mmc_config CROSS_COMPILE=arm-none-linux-gnueabi-
    DaVinci-PSP-SDK-03.22.00.06/src/u-boot/u-boot-davinci# make
all CROSS_COMPILE=arm-none-linux-gnueabi-
    DaVinci-PSP-SDK-03.22.00.06/src/u-boot/u-boot-davinci# tools/mkimage -s -n
/dev/null -T aisimage -e 0x80000000 -d spl/u-boot-spl.bin spl/u-boot-spl.ais

Flash the SPL AIS file into SPI flash

1. DIP switch settings for UART boot mode.

Pin# 1 2 3 4 5 6 7 8
Position OFF OFF OFF OFF OFF ON OFF OFF

2. Flash the SPL AIS signed binary into SPI flash through serial flasher tools.

3. Type "./sfh_OMAP-L138.exe -flash_noubl u-boot-spl.ais -targetType OMAPL138_LCDK -flashType SPI_MEM" to flash SPL ais signed binary to SPI flash. Please note, here the target type is given as "OMAPL138_LCDK" instead of "OMAPL138". Click here for more information on serial flasher utility.

Flash the U-Boot file built for SPI flash into SD’s unformatted partition

   1. Insert the formatted SD/MMC card into a Linux host PC.
   2. Flash the u-boot binary into unformatted SD card partition.
   3. Change the working directory to uboot source folder.
   4. Type "tools/uflash/uflash -d /dev/sdb -b u-boot.bin -p OMAPL138 -vv" to flash SPL binary to SPI flash.

Successful sample Log:

ti-e2e/OMAPL138_SDI_EVM/DaVinci-PSP-SDK-03.22.00.06/src/u-boot/u-boot-davinci# sudo tools/uflash/uflash -d /dev/sdb -b u-boot.bin -p OMAPL138 -vv

OMAPL138
U-Boot Size 186595
First partition starts at 32130(16450560)
U-Boot Magic Number     : a1aced66
U-Boot Entry Point      : c1080000
U-Boot Number of Blocks : 0000016d
U-Boot Starting Block   : 00000075
Load U-Boot Address     : c1080000
Writing U-Boot Signature
Writing U-Boot
Done...

Preparation of kernel image

   1. Change the directory to kernel source folder.
   2. Export your tool chain path.
   3. Configure and build the kernel for OMAPL138 SDI EVM board.
   4. Copy the kernel image into 1st FAT partition (boot) of SD/MMC card.

Linux Commands:

    host# cd DaVinci-PSP-SDK-03.22.00.06/src/kernel/linux-davinci
    DaVinci-PSP-SDK-03.22.00.06/src/kernel/linux-davinci# export ARCH=arm
    DaVinci-PSP-SDK-03.22.00.06/src/kernel/linux-davinci# export CROSS_COMPILE=arm-arago-linux-gnueabi-
    DaVinci-PSP-SDK-03.22.00.06/src/kernel/linux-davinci# make da850_sdi_defconfig
    DaVinci-PSP-SDK-03.22.00.06/src/kernel/linux-davinci# make uImage
    DaVinci-PSP-SDK-03.22.00.06/src/kernel/linux-davinci# cp -r arch/arm/boot/uImage /media/boot

Preparation of file system

   1. Copy the OMAPL138 LCDK's linux SDK file system to "rootfs" partition.
   2. Untar the file system tar ball into 2nd partition (rootfs) of SD/MMC card.
   2. Do safe remove the SD/MMC card from host PC.

Example:

   1. cd /media/rootfs
   2. /media/rootfs# cp -rf /home/<user>/ti-sdk-omapl138-lcdk-01.00.00/filesystem/omapl138-lcdk-fs.tar.gz .
   3. /media/rootfs# tar -zxvf omapl138-lcdk-fs.tar.gz
   4. /media/rootfs# cd /
   5. # sync
   6. # umount /media/rootfs

SD/MMC boot

   1.	Settings DIP switch to SPI boot mode.
Pin# 1 2 3 4 5 6 7 8
Position OFF OFF OFF OFF OFF ON ON OFF
   2. Hit any key to stop the auto boot of u-boot.
   3. Provide the bootcmd and bootargs to boot the kernel image from SD/MMC 1st partition

and mount the ext3 file system on SD/MMC's 2nd partition.

   4. Now,the OMAPL138 SDI EVM board will boot SPL code from SPI flash and take u-boot from SD/MMC card.

Setting bootargs and bootcmd

Bootcmd should be set to copy and boot uImage from the first partition of the micro-SD card. The bootargs should be set to take root file system from the second partition of the micro-SD card.

setenv bootargs 'mem=32M console=ttyS2,115200n8 root=/dev/mmcblk0p2 rw rootwait ip=off'
setenv bootcmd 'mmc rescan 0;fatload mmc 0 0xc0700000 uImage; bootm c0700000;'