AM335X StarterWare Booting And Flashing

From Texas Instruments Wiki
Jump to: navigation, search

TIBanner.png

AM335X Flashing And Booting

This section describes the flashing and booting of TI AM335x EVM, EVM-SK and Beagle Bone from different media. The below table describes, whether a boot mode is supported for  the given board or not.


MMCSD UART
SPI
NAND
TI AM335x EVM
Yes
Yes
Yes
Yes
TI AM335x EVM-SK
Yes
Yes
No
No
Beagle Bone
Yes
Yes
No
No


The bootloader initializes the DDR and required peripherals. Once the bootloader and StarterWare application images are ready, they can be flashed/copied onto the media for standalone media booting. For information on the binaries supplied with the package and the steps to be followed to load them, please refer quick start guide. For information on host platform requirements and steps to build, please refer getting started guide.

Two types of images has to be flashed on to the media. A bootloader image and an application binary image. Both application and the bootstrap image are required to be in a special format containing a header including the size and load address of the binary image.

  • When a bootloader/application is built from any toolchain, bootloader/application binary image binary/armv7a/gcc/am335x/<EVM>/<bootloader/app_folder/<build-configuration>/<app_name>.bin is automatically converted to binary/armv7a/gcc/am335x/<EVM>/<bootloader/app_folder>/<build-configuration>/<app_name>_ti.bin.
  • Any binary image can be converted to this special format using the image converter application located at /tools/ti_image/. The Usage of the tool is described at usage of tiimage tool

Once both the bootloader and the StarterWare application images are ready in the special format, the images can be flashed/copied to the media as below.

Booting Via SD Card

Booting from SD Card involves two steps.

  1. Preparing the SD card.
  2. Booting the target.

Preparing the SD card

The SD card needs to be prepared, by FAT formatting it as follows.

  1. HP USB Disk Storage Format Tool v2.0.6 Portable has to be used to format the SD card. This tool can be downloaded from this link.
  2. Choose a SD card and a USB based or similar SD card reader/writer. Plug it to a Windows host system.
  3. Run the HP USB Disk Storage Format Tool v2.0.6 Portable executable. The executable should automatically detect the SD card plugged via reader. Else point it to the new disk.
  4. Choose FAT32 if the SD card size is greater that 4GB. Else FAT should be good to go.
  5. Click on 'Start'.
  6. After the formatting is complete, the card is ready to be populated with the files required.
  7. The converted bootloader binary image(Bootloader binary image(boot.bin) appended with the TI Image Header) has to be renamed to "MLO" from "boot_ti.bin". The boot_ti.bin is created by building the bootloader in MMC/SD boot mode.
  8. Similarly the converted application binary image has to be renamed to "app" from "<app_name>_ti.bin"
  9. Copy both the boot loader image "MLO" and the application image "app" to the SD card.
  10. Safely eject/remove the card from the host, unplug the card reader, remove the SD card. The SD card is ready for use on AM335x target.

NOTE:

  1. The above steps are applicable when formatting a microSD card also.


The below image gives the snap shot of SD card format tool:

HP USB SD Card Format Tool v2p0p6 Settings.jpg

              

 

Booting the target

  1. Insert the SD card into the SD slot (For GP EVM, the SD Card slot on baseboard). Connect a UART cable to a host running a serial terminal application (teraterm/hyperterminal) with 115200 baud, 8bit, No parity and 1 STOP bit configuration.
  2. Configure the board (Applicable for AM335X EVM only, there is no boot mode selection for Beaglebone) for SD Boot mode
    1. SD instance 0 (on base board) is available in all profiles (Applicable for AM335X EVM only). For more details refer to EVM reference manual.
    2. SD instance 0 boot mode needs to appropriately set (Applicable for AM335X EVM only). For booting out of SD card, SD boot should appear first in the boot device list. If any other boot mode is selected, even if a SD boot card is inserted, and does not appear first in the list, the first available valid boot image (from NAND or SPI etc) is booted and SD is not selected. Only if no valid boot image is found in the first devices, SD boot image will be selected.
  3. On power on, the MLO is first detected and copied and executed from the OCMC0 RAM. The MLO then copies the application image (app) from the card to the DDR and passes the control to the application. On Successful boot, following messages appear on the serial console.
   StarterWareAM335x Boot Loader
Copying application image from MMC/SD card to RAM
Jumping to StarterWare Application...


After this the application should take control and execute.

Booting Via UART

The ROM code and StarterWare Bootloader supports XMODEM protocol, and the images shall be the plain binary images, without header.

  1. Configure the board (Applicable for AM335X EVM only, there is no boot mode selection for Beaglebone) for UART Boot mode
  2. On power up, the ROM code will send "CC.." on UART console expecting StarterWare Bootloader via XMODEM
  3. On sending the bootloader image, boot.bin via XMODEM, following message appear on the serial console.
   StarterWareAM335x Boot Loader
CC

     4.  Now any application binary (without header) can be sent via XMODEM. The application will start executing.

Booting Via SPI

Booting from SPI involves two steps.

  1. Flashing bootloader and application to SPI Flash
  2. Booting the target.

Flashing bootloader and application to SPI Flash

  • Configure the EVM in profile 2 (SW8[1] = OFF, SW8[2] = ON, SW8[3:4] = OFF).For more details refer to EVM reference manual.
  • Configure the BOOT pins for SPI Boot mode
  • Connect the target.
  • Load the GEL file /tools/gel/AM335X.gel.
  • Load the spi_flash_writer_AM335X.out onto the EVM.
  • It will prompt for binary file name. Update the file with the path.
  • It will prompt again for load address in flash. If bootloader is to be flashed, provide 0x00000. For StarterWare application provide 0x20000.
  • Once SPI flash writing completes, disconnect from CCS.

Booting the target

  • Connect a UART cable to a host running a serial terminal application (teraterm/hyperterminal) with 115200 baud, 8bit, No parity and 1 STOP bit configuration.
  • Configure the board for SPI boot mode
  • SPI is available in profile 2 (SW8[1] = OFF, SW8[2] = ON, SW8[3:4] = OFF). For more details refer to EVM reference manual.
  • Once the SPI boot mode is chosen, the bootloader is first detected and copied and executed from the OCMC0 RAM. The bootloader then copies the application image from the SPI to the SDRAM and passed the control to the application. If the process is succesful, following messages appear on the serial console.
   StarterWareAM335x Boot Loader
Copying application image to RAM
Jumping to StarterWare Application...

After this the application should take control and execute.

Booting Via NAND

Booting from NAND involves two steps.

  1. Flashing bootloader and application to NAND Flash
  2. Booting the target.

Flashing bootloader and application to NAND Flash

  • Configure the EVM in profile 0 (SW8[1:4] = OFF). For more details refer to EVM reference manual.
  • Configure the BOOT pins for NAND Boot mode
  • Connect the target.
  • Load the GEL file /tools/gel/AM335X.gel.
  • Load the nand_flash_writer_AM335X.out onto the EVM and Run. The flash writer will output messages on the CCS console. When it prompts for inputs, proper inputs shall be given via CCS console.
  • When prompted for binary file name, update the file with the proper path.
  • Select option for flashing.
Choose your operation
Enter 1 ---> To Flash an Image
Enter 2 ---> To ERASE the whole NAND
Enter 3 ---> To EXIT

    Select option 1 when prompted. Select option 2 in case if you want to erase the whole NAND.

  • Enter the image path to flash when prompted as shown below.
Enter image file path

    Provide the complete path (e.g.c:\images\boot_ti.bin)

  • Enter the offset when prompted as shown below.
Enter offset (in hex):

    This offset is the start location from where the image should be flashed.
NOTE:

  1. Use hex format
  2. If bootloader is to be flashed, provide 0x00000. For StarterWare application, provide 0x80000.
  • Select ECC for flashing.
Choose the ECC scheme from given options
Enter 1 ---> BCH 8 bit
Enter 2 ---> HAM
Enter 3 ---> T0 EXIT
Please enter ECC scheme type:

    Always select BCH8 for bootloader and application as the ROM code and bootloader uses the BCH8 ECC scheme. Enter 1 for u-boot.min.nand.

  • Ensure that the flash info displayed by the tool matches the NAND flash in the EVM.
  • After this the tool should first erase the required region in flash and then start flashing the new image.
  • Finally you should see the following message.
Application is successfully flashed
NAND boot preparation was successful!
  • Once NAND flash writing completes, disconnect from CCS.

Booting the target

  • Connect a UART cable to a host running a serial terminal application (teraterm/hyperterminal) with 115200 baud, 8bit, No parity and 1 STOP bit configuration.
  • Configure the board for NAND boot mode
  • NAND is available in profile 0 (SW8[1:4] = OFF). For more details refer to EVM reference manual.
  • Once the NAND boot mode is chosen, the bootloader is first detected and copied and executed from the OCMC0 RAM. The bootloader then copies the application image from the NAND to the SDRAM and passed the control to the application. If the process is succesful, following messages appear on the serial console.
   StarterWareAM335x Boot Loader
Copying application image from NAND to RAM
Jumping to StarterWare Application...

After this the application should take control and execute.

Boot Modes

This section is applicable for AM335X EVM only.

The device supports variety of boot modes through the ROM Code. Boot mode selection is determined by the state of the SYSBOOT configuration pins.

Switch SW3 is for selecting the boot modes and device selection depends on the DIP switches intended for profile selection on EVMs.

1. Make sure that the EVM boot switch settings are set to required boot mode and then power on the board. The picture below shows the boot mode configuration switch SW3 on the AM335X EVM.

Note

  • The bootmode setting in this picture is for NAND boot.Nand boot corresponds to(SW3 5:1) 10010


         Bootmodeswitches.jpg

 
RED: circle shows OFF and GREEN circles shows ON switches.

Note: ON is labeled on the wrong side of SW3 boot mode switch.


2. Due to heavy pin-muxing, boot device is selectively available on selected AM335x EVMs & profiles. Ensure that boot device is available in EVM/profile before setting the boot mode.

3. Refer the following table which explains the boot mode settings for different media.

BootMode.JPG

Bootloader

StarterWare AM335X provides a simple bootloader, which can be flashed to the media, which after a power-on-reset can bootstrap the board. Additionally it can load an application from the media to DDR and transfer the control to the application. This can be used for out-of-box experience.

Upon board power on, the ROM Code, residing in the ROM of the AM335X kickstarts. ROM Code checks the boot mode setting (which should be SPI mode in case of StarterWare bootloading) and depending upon the boot mode setting it copies boot loader from the respective flash device. ROM Code requires boot loader to be in a special format with a header appended to the binary image. The header shall contain the load address of the bootloader and the size of the bootloader image. The ROM Code copies the boot loader to onchip OCMC RAM located at 0x402F0400 and gives control to it.

The boot loader initializes the PLLs and enables peripheral clocks and then it initializes the DDR. The configurations will set the processor core operating frequency to 720MHz. Once all the initialization is done, it copies the application from flash to the DDR and transfers the control to the application. The application starts to execute from DDR.

NOTE: The application binary has to be converted to a special format for NAND, SPI and MMCSD boot modes. This is required by the bootloader to read the size of the application and the address where it has to be loaded in DDR. The special format will contain the load address and the size of the application binary.

NOTE: This is not required for booting via UART.

Please following the steps mentioned above to convert a binary to special format.


Stages in SPI Booting

The different stages in standalone booting of StarterWare applications from the SPI flash is described in the below diagram

AM335x Boot.JPG

Stages in NAND Booting

NAND boot follows same steps as SPI Boot but application offset for NAND boot is at 0x80000.

Stages in SD Booting

  • Stage 1 : On System reset, the ROM Code copies the bootloader by reading the MLO file from the SD to the address embedded on its header, Then ROM Code handsover the execution control to Bootloader.
  • Stage 2 : The Bootloader copies the StarterWare application by reading the file named app to the addresss embedded on its header. After copying, the bootloader jumps to start address of the application to handover the control to the application.
  • Stage 3 : StarterWare application executes.

Stages in UART Booting

  • Stage 1: On System reset, the ROM Code expects the StarterWare Bootloader via XMODEM from the UART console. (prints CCC.. on the UART console)
  • Stage 2: The StarterWare Bootloader image compiled for UART boot mode, boot.bin (without header) can be sent via XMODEM protocol. the ROM code copies the bootloader image onto OCMC RAM, hands over the execution control to StarterWare Bootloader.
  • Stage 3: The StarterWare Bootloader will expect an application image to be sent through UART console via XMODEM. (prints CCC.. on the UART console)
  • Stage 4: The StarterWare application image (<image>.bin, without header), can be sent via XMODEM through UART console. The StarterWare Bootloader copies this application image to DDR and the application starts execution.

Bootloader Execution Flow

  1. Entry point to the bootloader is the function Entry() which is inside the file bl_init.s (src/gcc). This function initializes stack and bss.
  2. Invokes bl_start(), which is in the file bl_main.c.
    1. This invokes DeviceConfig(), an EVM dependent function, for AM335x, function will be present in the file bl_am335x.c.This calls PLL and DDR initialization functions.
    2. PLLInit() Initializes PLL0 and PLL1.
    3. DDRInit() function initializes the DDR.
  3. Initializes the UART by calling UartConfigure().
  4. Executes Imagecopy() function which is present in the device independent file bl_copy.c .Depending upon the defined boot mode it calls one of the SPIBootcopy()/ NANDBootcopy() function. This function copies the application to the DDR.
  5. Transfer execution control to the application. The application now starts executing.

Usage of ti_image Tool

TI image tool, available in "tools" directory of the package can be used to add the header information to the boot loader or application binary images. It has separate executable for Windows and Linux.

Usage of the same is explained below.

For Windows

  1. Open command prompt
  2. Go to /tools/ti_image
  3. If the tiimage.exe is not available, generate one with Cygwin or MingW environvment using the command "gcc tiimage.c -o tiimage"
  4. Execute the image converter by giving proper inputs in the format, tiimage.exe <load address> <boot mode> <input image path/name> <output image path/name>
  • Examples
    • tiimage.exe 0x402F0400 MMCSD boot.bin MLO
    • tiimage.exe 0x80000000 NONE uartEcho.bin app

For Linux

  1. Go to /tools/ti_image
  2. If the tiimage binary is not available, generate one with GCC using the command "gcc tiimage.c -o tiimage".
  3. Execute the image converter by giving proper inputs in the format, ./tiimage <load address> <boot mode> <input image path/name> <output image path/name>
  • Examples
    • ./tiimage 0x402F0400 MMCSD boot.bin MLO
    • ./tiimage 0x80000000 NONE uartEcho.bin app


NOTE

  • For bootloader, value of <boot mode> should be corresponding bootmedia name i,e NAND/SPI/MMCSD/UART.
  • For application, value of <boot mode> should be NONE.
  • While building bootloader the binary image is automatically converted to special format and placed in binary/armv7a/gcc/am335x/<EVM>/bootloader/boot_ti.bin. And While building application the binary image is automatically converted to special format and placed in binary/armv7a/gcc/am335x/<EVM>/<application>/<application>_ti.bin.