world leader in high performance signal processing
Trace: » boot

ADSP-BF548 EZ-KIT Quick Start: Booting uClinux

www.analog.com_static_imported-files_images_product_descriptions_680755565image1a.jpg

Installing Bootloader

A boot loader is a program that will run before the operating system is running. It is used to boot the main operating system, in this case uClinux.

The recommended boot loader for the BF548-EZKIT is Das U-Boot, and there are several ways to install and run it on the BF548 EZ-KIT. This guide will show you how to install Das U-Boot to the BF548, and set its default boot configuration to load vmImage (a bare bones kernel) using the SD card as the root file system.

The first thing to do in this section is to see if your board already has the boot loader installed. Do the following:

  • Connect the BF548 EZ-KIT to your development PC via the serial cable
  • Open a new terminal (Ctrl+Alt+T)
  • In that terminal, start kermit:
    $ kermit -l /dev/ttyUSB0 -b 57600 -C connect

  • Set blue rotary encoder to 3 and reboot board
  • Hit the enter key several times in the terminal
    • If there is any response (eg. bfin>), the bootloader is already installed and you can continue to the next section: Preloading uClinux on SD Card
  • Set blue rotary encoder to 1 and reboot board
  • Hit the enter key several times in the terminal
    • If there is any response (eg. bfin>), the bootloader is already installed and you can continue to the next section: Preloading uClinux on SD Card

If there was no response in kermit, please make sure you have the correct device opened (/dev/ttyUSB0 is only a best guess depending on your set up being a serial→USB converter, you will need to investigate yourself what device is definitely in use). If the correct device is in use, then most likely there is no boot loader installed and you can follow the instructions below to install one.

A good way to determine which device you need to use is to run this command:

$ ll /sys/class/tty/*/device/driver

You can already read the serial cable page serial_cable for troubleshooting information.

There are two phases to loading on the boot loader on the ADSP-BF548 EZKIT. The first stage involves sending the UART bootloader via the serial connection. Ensure that the board is in the default configuration as specified in the previous sections prior to beginning this section.

Make sure you have the precompiled DAS u-boot loaders. You can download them (u-boot-R1.tar.gz) from Das U-Boot Files

Next ensure your toolchain is correctly configured by entering the following command:

$ bfin-uclinux-ldr 

Usage: ldr [options] <-s|-d|-l|-c> [subcommand options] 

Options: -[fvqhVsdlcT:f] ...

If the response shown above does not occur, then your development environment is not correctly set up and you need to refer back to those sections to make sure the toolchains are correctly installed.

Format your SD card to be in ext2 format using the Disk Utility. Follow the instructions below.

  • Empty your SD Card.
  • Open the Disks application.

  • Find your SD Card you wish to use in the device list.
  • Stop it using the Square button (do this for all partitions available).

  • Enter the user password and press 'Authenticate' (uclinux on the live-DVD).
  • Select the cogs button in the top right hand corner and select 'Format Disk…'.

  • Change Partitioning setting to 'Compatible with all systems and devices (MBR / DOS)'.

  • Click 'Format'.
  • Click 'Format' again.

  • Enter the user password and press 'Authenticate' (uclinux on the live-DVD).
  • Create a new partition using the plus button.

  • Set the partition size to any size (as long as it's large enough to store the boot loader files).

  • Set the type to “Custom”.

  • Under Filesystem enter “ext2”.

  • Click 'create'.
  • Click the play button (arrow) to mount the partition for use.

Copy the u-boot loader files onto the SD card in preparation for the second phase. Plug the memory card into the BF548 EZ-KIT's memory card slot above the LCD.

It's preferable to also restart your development machine prior to continuing as there have been issues with Ubuntu not properly communicating with the board when performing this section if it has already connected previously. Also disconnect the power to the board until it is time to start loading the first boot loader.

Open a terminal and navigate to where the u-boot files are on the development machine and make sure the serial cable is connected and the board is turned on. Enter the following command:

  • Reboot your development PC and unplug your Blackfin board from power
  • Set blue rotary encoder to 7 and plug board into power

  • Open a new terminal

  • In that terminal, start the bfin-uclinux-ldr: “bfin-uclinux-ldr -l Documents/u-boot-uart.ldr /dev/ttyUSB0”

    $ bfin-uclinux-ldr -l Documents/u-boot-uart.ldr /dev/ttyUSB0
    Loading LDR u-boot-uart.ldr ... OK! 
    Opening /dev/ttyUSB0 ... OK! 
    Configuring terminal I/O ... OK! 
    Trying to send autobaud ... OK! 
    Trying to read autobaud ... OK! 
    Checking autobaud ... OK! 
    Autobaud result: 115200bps 49.766mhz (header:0xBF DLL:0x1B DLH:0x00 fin:0x00) 
    Sending blocks of DXE 1 ... [3/13] (23%)

    This shows the boot loader being transferred via RS232, if successful the board will respond with miscellaneous characters. This is the first stage boot loader succesfully loaded via UART. Next we will need to access the boards terminal via RS232 and set it to load the second stage boot loader from the memory card and into the serial flash memory.

  • In the same terminal as before, enter the following command to access the boards bootloader and press enter again afterwards: “kermit -l /dev/ttyUSB0 -b 57600 -C connect”

    $ kermit -l /dev/ttyUSB0 -b 57600 -C connect
    Connecting to /dev/ttyUSB0, speed 57600 
    Escape character: Ctrl-\ (ASCII 28, FS): enabled 
    Type the escape character followed by C to get back, 
    or followed by ? to see other options. 
    ---------------------------------------------------- 
    
    bfin>

    If you see the bfin prompt, then you have succesfully accessed the blackfin terminal. If not, than you may have to repeat the steps to reload the first stage boot loader.

  • Now to load the second stage boot loader. Make sure the memory card is plugged into the Blackfin and the appropriate boot loader files are on it. Enter the following commands prefixed with “bfin>”:

    bfin> mmc rescan
    bfin> ext2load mmc 0 0x1000000 u-boot-para.ldr
    bfin> protect off all
    bfin> erase 0x20000000 +$(filesize) 
    
    ... done 
    Erased 3 sectors 
    bfin> cp.b 0x1000000 0x20000000 $(filesize) 
    Copy to Flash... 9....8....7....6....5....4....3....2....1....done
    bfin> cmp.b 0x1000000 0x20000000 $(filesize) 
    Total of 307392 bytes were the same 
    bfin> protect on all
  • Now rotate the DSP BOOT rotary encoder (SW1) to the 1 position. This will set it to load the boot loader from parallel flash memory. Reboot the board and the following should appear in your terminal:

    U-Boot 2011.09 (ADI-2011R1) (Nov 21 2012 - 16:06:27) 
    
    CPU: ADSP bf548-0.0 (Detected Rev: 0.4) (parallel flash boot) 
    Board: ADI BF548 EZ-Kit board 
    Support: http://blackfin.uclinux.org/ 
    Clock: VCO: 525 MHz, Core: 525 MHz, System: 131.250 MHz 
    RAM: 64 MiB 
    Flash: 16 MiB 
    NAND: 256 MiB 
    MMC: Blackfin SDH: 0 
    SF: Detected M25P16 with page size 64 KiB, total 2 MiB 
    In: serial 
    Out: serial 
    Err: serial 
    KGDB: [on serial] ready 
    Net: smc911x-0Warning: failed to set MAC address 
    
    bfin>

    This indicates that the boot loaders are succesfully loaded onto the board. It is now ready to run uClinux.

This is all you require to load the boot loaders, to investigate further how to compile DAS u-boot for yourself and toggle other options such as environment variables, look at Compiling U-Boot and Das U-Boot Bootloader for further information.

Preloading uClinux on SD Card

This guide approaches uClinux development by using an SD Card to store the file system of uClinux so it is portable, easy to modify elsewhere, and changes to the installation are permanent (compared to booting from ram).

This is just one of many approaches; including booting from the inbuilt hard disk, booting from RAM, and booting from a Network File Storage. Further information about these other approaches can be found on the wiki at the following page: Bootable U-Boot Images. These other methods have their pros and cons (for example, the NFS method is a very easy and efficient way to quickly develop programs however it requires a fair amount of setting up that can be complex and very situation dependent).

This guide comes with a bootable uClinux SD card image. You can download this demo image (demo-uclinux.img) from http://blackfin.uclinux.org/gf/project/stamp/frs/?action=FrsReleaseView&release_id=594 under the files tab. All you need to do to set it up is follow the steps below with an empty SD card.

  • Empty your SD Card.
  • Open the Disks application.

  • Find your SD Card you wish to use in the device list.
  • Stop it using the Square button (do this for all partitions available).

  • Enter the user password and press 'Authenticate' (uclinux on the live-DVD).
  • Select the cogs button in the top right hand corner and select 'Format Disk…'.

  • Change Partitioning setting to 'Compatible with all systems and devices (MBR / DOS)'.

  • Click 'Format'.
  • Click 'Format' again.

  • Enter the user password and press 'Authenticate' (uclinux on the live-DVD).
  • Create a new partition using the plus button.

  • Set the partition size to 135mb and set it for FAT and any volume name.

  • Click 'create'.
  • Select the cogs button and select 'Restore Disk Image…'.

  • Enter the user password and press 'Authenticate' (uclinux on the live-DVD).
  • Select the card image to restore (demo-uclinux.img).

  • Click 'Start Restoring'.

  • Click 'Restore'.

Once the process finishes, you should now have an SD card which holds the file system of uClinux. We can use this to boot all the demo applications in the next section, and in the compiling uClinux section, you will learn how to custom modify the libraries included in the kernel and build the applications for yourself.

Just a reminder that this boot process is the non-standard approach, and that you should visit the main pages of the wiki to learn the standard approach as well.

Starting uClinux

Now that you have U-Boot set up and the uClinux file system ready on an SD card, you are ready to begin actually booting it.

This requires modifying the U-Boot environment variables to set kernel boot options to have the root file system be the SD card; and also reconfiguring the boot command to do a non-default boot method involving the steps:

  1. Initiate and scan the memory card
  2. Loading the file vmImage on the SD card into RAM
  3. Boot vmImage

You can follow the steps below to boot uClinux:

  • Insert SD Card into slot above LCD screen on the board.

  • Open Kermit and connect to the Blackfin board

    $ kermit -l /dev/ttyUSB0 -b 57600 -C connect
    Connecting to /dev/ttyUSB0, speed 57600
    Escape character: Ctrl-\ (ASCII 28, FS): enabled
    Type the escape character followed by C to get back,
    or followed by ? to see other options.
    ----------------------------------------------------
    
    bfin> 
  • Set bootargs to have root file system on mmc device

    bfin> setenv bootargs 'root=/dev/mmcblk0p1 rootwait rw clkin_hz=25000000 earlyprintk=serial,uart1,57600 console=tty0 console=ttyBF1,57600'
    bfin> 

    Note: setenv command is one line, recommend copy + paste

  • Set boot command to boot vmImage from mmc

    bfin> setenv bootcmd 'mmc rescan; ext2load mmc 0 0x1000000 vmImage; bootm'
    bfin> 
  • It is also advisable to save the environment variables to flash so it persists for multiple boots. Although you should only do this after first testing the variables at least once.

    bfin> saveenv
    Saving Environment to Flash...
    . done
    Un-Protected 1 sectors
    Erasing Flash...
    . done
    Erased 1 sectors
    Writing to Flash... 9....8....7....6....5....4....3....2....1....done
    . done
    Protected 1 sectors
    
    bfin> 
  • Assuming you have set those variables correctly, and that the correct SD card image is loaded up, you should be able to now boot uClinux. Just run the boot command.

    bfin> boot
    Loading file "vmImage" from mmc device 0:1 (xxa1)
    1626019 bytes read
    ## Booting kernel from Legacy Image at 01000000 ...
    Image Name: bf548-0.2-3.0.8-ADI-2011R1
    Created: 2012-12-09 23:10:33 UTC
    Image Type: Blackfin Linux Kernel Image (gzip compressed)
    Data Size: 1625955 Bytes = 1.6 MiB
    Load Address: 00001000
    Entry Point: 002d0b38
    Verifying Checksum ... OK
    Uncompressing Kernel Image ... OK
    Starting Kernel at = 002d0b38
    [snip...]
    
    VFS: Mounted root (ext2 filesystem) on device 179:1.
                               _____________________________________
            a8888b.           / Welcome to the uClinux distribution \
           d888888b.         /       _     _                         \
           8P"YP"Y88        /       | |   |_|            __  __ (TM)  |
           8|o||o|88  _____/        | |    _ ____  _   _ \ \/ /       |
           8'    .88       \        | |   | |  _ \| | | | \  /        |
           8`._.' Y8.       \       | |__ | | | | | |_| | /  \        |
          d/      `8b.       \      \____||_|_| |_|\____|/_/\_\   
         dP   .    Y8b.       \   For embedded processors including   |
        d8:'  "  `::88b        \    the Analog Devices Blackfin      /
       d8"         'Y88b        \___________________________________/
      :8P    '      :888
       8a.   :     _a88P         For further information, check out:
     ._/"Yaa_:   .| 88P|            - http://blackfin.uclinux.org/
     \    YP"    `| 8P  `.          - http://docs.blackfin.uclinux.org/
     /     \.___.d|    .'           - http://www.uclinux.org/
     `--..__)8888P`._.'  jgs/a:f    - http://www.analog.com/blackfin
    
    Have a lot of fun...
    
    BusyBox v1.18.4 (2012-11-29 12:10:12 EST) hush - the humble shell
    
    root:/> 

If you see the above response, than uClinux has booted! If you are familiar with Linux platform feel free to investigate, otherwise you can move onto the demo section to see some premade programs and introduce some concepts such as running programs in uClinux.

Further Reading

One of the things mentioned was how you can boot the file system from various different methods, just to highlight an example, booting from the hdd.

You can boot from the hdd (assuming there is a uClinux file system there) by changing the root variable in the bootargs to point to the hdd partition (/dev/sda1).

The rootwait in the bootargs command is a flag that tells the kernel to wait to load the root file system if it cannot be found at first. This is vital to booting from an SD card as the MMC block driver doesn't initiate until the end of the boot sequence, meaning sometimes the SD card is not ready for booting from when it comes time to load the root file system.

You can also boot a ram file system image (uImage) which is faster and cheaper to do so however changes made in the environment will not persist and also you will be very limited by file sizes. Booting from a uImage is actually the default manner most developers use to boot uClinux, however this guide uses a persistent file system to ease the reader in and not have them worry about file sizes. After becoming comfortable with using uClinux, the reader should investigate uImages here Bootable U-Boot Images and begin considering space saving measures.

There is also a good example process of booting uClinux covered on the Creating the BF548 EZKit Media Demo page.