AN 709: HPS SoC Boot Guide - Cyclone V SoC Development Kit

ID 683265
Date 1/27/2016
Public

1.5.3. Booting from SD/MMC – FAT Partition

This example demonstrates how to boot from the SD card, with the bare-metal image stored on the FAT partition on the SD card.
Note: The Preloader is still stored on the custom partition.
To prevent the "Device Open Failed!" error message, ensure that you are operating in the following user modes:
  • Windows — "Administrator mode user"
  • Linux — "sudo mode"

The steps required to run this scenario are:

  1. Build the sample bare-metal application or simply use the provided file hello-mkimage.bin directly.
  2. Generate a Preloader based on the GHRD provided with SoC EDS. Make sure to select the following options:
    • Check the option spl.boot.BOOT_FROM_SDMMC
    • Uncheck the other boot options (spl.boot.BOOT_FROM_RAM, spl.boot.BOOT_FROM_QSPI, spl.boot.BOOT_FROM_NAND)
    • Check the option spl.boot.FAT_SUPPORT. This tells the Preloader to load the bare-metal application from the FAT partition.
    • Edit the field spl.boot.FAT_LOAD_PAYLOAD_NAME to contain the name of the bare-metal image: hello-mkimage.bin
    • Check the option spl.boot.SDRAM_SCRUBBING and spl.boot.SDRAM_SCRUB_REMAIN_REGION. This zeroes out the SDRAM, preventing any ECC errors to occur during bare-metal program execution.
    • Uncheck the option spl.boot.WATCHDOG_ENABLE. This is because we are not kicking the watchdog in our bare-metal application.
  3. Compile the Preloader. This creates the file preloader-mkpimage.bin.
  4. Manually create an SD card with a custom partition with id=A2 using fdisk, or use the example SD card image that comes with SoC EDS:
    • Unzip the SD Card Image provided in the <SoCEDS installation folder>:\embedded\embeddedsw\socfpga\prebuilt_images\sd_card_linux_boot_image.tar.gz by using the command ‘tar -xzf <filename>’ from the Embedded Command Shell. This creates the file sd_card_linux_boot_image.img.
    • Use the free Win32DiskImager tool to write the file sd_card_linux_boot_image.img to an SD card.
  5. Write both the Preloader image and the Bare-metal application images to the SD card custom partition, using the SD card boot utility that is part of SoC EDS:
    • Start an Embedded Command Shell.
    • Run the command “alt-boot-disk-util -a write -p preloader-mkpimage.bin -d <sd_card_drive_letter
  6. Write the bare-metal application image to the SD card FAT partition, using for example drag and drop in Windows Explorer.
  7. Set the board to boot from SD card by configuring the BOOTSEL jumpers like this:
    • BOOTSEL0 (J28): left
    • BOOTSEL1 (J29): right
    • BOOTSEL2 (J30): left
  8. Connect the board to the PC using the USB serial connection, and start a serial terminal on the PC, using 115,200-8-N-1.
  9. Insert the SD card on the board socket and power-cycle the board or reset the HPS by pressing the COLD reset button (S7).
    The board boots, Preloader messages are displayed, then “Hello World” is displayed by the bare-metal application.
    Figure 10. FAT Partition