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

ID 683265
Date 1/27/2016
Public

1.5.2. Booting from SD/MMC – Custom Partition

This example demonstrates how to boot from the SD card, with the bare-metal image stored on the same SD card custom partition as the Preloader.
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)
      Note: spl.boot.SDMMC_NEXT_BOOT_IMAGE = 0x40000. This is the location where the bare-metal application image is stored.
    • 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 only the Preloader image 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 -b hello-mkimage.bin -d <sd_card_drive_letter>
  6. Set the board to boot from SD card by configuring the BOOTSEL jumpers like this:
    • BOOTSEL0 (J28): left
    • BOOTSEL1 (J29): right
    • BOOTSEL2 (J30): left
  7. 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.
  8. 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 9. Custom Partition