找回密码
 注册
关于网站域名变更的通知
查看: 645|回复: 1
打印 上一主题 下一主题

从FPGA启动系统

[复制链接]
  • TA的每日心情
    开心
    2019-11-20 15:00
  • 签到天数: 2 天

    [LV.1]初来乍到

    跳转到指定楼层
    1#
    发表于 2019-4-18 09:34 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

    EDA365欢迎您登录!

    您需要 登录 才可以下载或查看,没有帐号?注册

    x
    FPGA启动系统SocBootFromFPGA
    ' E+ f. ]1 y3 }1 J! `( r- L; u! N0 p# I. Q3 K# {
    Contents [hide]

    ' S" A4 E* [; f
    • 1 Introduction
    • 2 Prerequisites
    • 3 Overview
      • 3.1 Boot Flow
      • 3.2 FPGA Build Flow
        1 Q# ?/ e; k0 n0 @+ d6 R) [4 I
    • 4 Hardware Design
    • 5 Preloader
    • 6 Bare-metal Application
    • 7 Running the Example
    • 8 Files
    • 9 References1 F) H/ e) @8 J' s
    Introduction
    The HPS (Hardened Processor System) from the Altera Cyclone V and Arria V SoCs supports several different boot scenarios:
    • Boot from SD/MMC card,
    • Boot from QSPI,
    • Boot from NAND,
    • RAM Boot - on WARM Reset only,
    • Boot from FPGA,
    • FPGA Fallback boot.
      ) Z0 U. _/ k; O: ~( p
    This page presents a complete example of how to boot from FPGA on a Cyclone V SoC Development Kit.
    For more information about booting refer to Booting and Configuration chapters from:
    • Cylone V Documentation: http://www.altera.com/literature/lit-cyclone-v.jsp
    • Arria V Documentation: http://www.altera.com/literature/lit-arria-v.jsp5 O3 l2 O4 E+ X' ?' W: R
    Prerequisites
    The following are required in order to compile and run this example:
    • Host PC running Windows 7 (Linux will also work),
    • Altera Cyclone V SoC Development Kit ver D or newer,
    • Altera Quartus II v14.0 or newer,
    • Altera SoC EDS v14.0 or newer.+ E# J: `: @$ f1 n: S) a) L
    Overview
    In order to achieve booting from FPGA the following are required:
    • BSEL needs to be set to 0x1 - Boot from FPGA
    • FPGA image needs to have an on-chip memory instantiated, mapped at offset 0x0 behind the HPS2FPGA bridge. The memory needs to be loaded with Preloader executable binary.
    • FPGA image needs to drive the value of the following two signals to HPS, since they are required by BootROM:
      • f2h_boot_from_fpga_ready - indicates that the BootROM can boot from FPGA if BSEL = 0x1
      • f2h_boot_from_fpga_on_failure - indicates that the BootROM can boot from FPGA as a fallback, if it failed booting from the selected BSEL.  p5 L% ]2 h! z$ d& z: d5 {
    • Preloader executable .text section needs to be linked to address 0xC000_0000 (equivalent of offset 0x0 behind the HPS2FPGA bridge)
    • Preloader executable .data sections need to be linked to address 0xFFFF_0000 (the HPS OCRAM)
      ' L" }9 q& d2 e+ x# t8 F* ?( P  R7 ?
    Boot Flow
    The following picture presents the boot flow used for this example:
    Note that the Preloader is executed directly from the FPGA memory, while the bare-metal is first copied from the SD/MMC to SDRAM then executed.
    It is possible to also store the bare-metal application in the FPGA image, but that memory is expensive and its usage should be minimized.
    The bare-metal application is very simple, it just prints the message "Hello World" to confirm that the boot process executed correctly.
    FPGA Build Flow
    The complete flow for creating the appropriate FPGA image is described in the following diagram:
    Note that the design needs to be compiled two times:
    • First in order to obtain the handoff folder, which is used to generate the Preloader.
    • Then, after the Preloader hex file is obtained you can update the on chip ram from Quartus: you can either do a full recompile or run the update memory initialization file (see below)/ r  X& b% x9 n, J9 t, z: B5 b! e
          Processing->Update Memory Initialization File      This will update the programming/sof file with the new hex file information for the on chip ram.      This is a handy way to update software for nios as well without doing a full recompile.Hardware Design
    The hardware design is provided as an attachment to this page. It was derived from the GHRD provided with SoC EDS 14.0 with the following modifications:
    • The HPS component was changed to enable boot from FPGA signals
    • The FPGA On-Chip memory data width was reduced from 64bit to 8bit
    • The FPGA On-Chip memory was changed to be initialized with the hex file software/spl_bsp/preloader.hex
    • The top level Verilog file was changed to tie off the HPS boot from FPGA signals accordingly.
      3 ~+ V& c; V% H8 Z# R
    The complete instructions for deriving the current design from the GHRD are:
    1. Unzip the provided file cv_soc_devkit_boot_fpga.tgz
    2. Start Quartus II, and open the project file cv_soc_devkit_boot_fpga/soc_system.qpf
    3. From Quartus II, open Qsys and load the file cv_soc_devkit_boot_fpga/soc_system.qsys
    4. In Qsys, click on the HPS component and check thee "Enable boot from FPGA signals" box.
    5. In Qsys, click on the FPGA On-Chip Memory, and:
    • Change its "Data Width" to 8bit
    • Check the "Enable non-default initialization file" box
    • Type in the path to the hex initialization file that will be built later: "software/spl_bsp/preloader.hex".
      + A2 w2 \# `8 `& w
    6. In Qsys, double-click on the HPS's "f2h_boot_from_fpga" signal to have it exported.
    7. Generate the system, in Qsys. Exit Qsys.
    8. In Quartus, open the top level file cv_soc_devkit_boot_fpga/ghrd_top.v and tie off the boot from FPGA signals:
    • f2h_boot_from_fpga_ready = 1 - indicates that the BootROM can boot from FPGA if BSEL = 0x1
    • f2h_boot_from_fpga_on_failure = 0 - indicates that the BootROM cannot boot from FPGA as a fallback& ?1 O+ t0 |1 A4 E5 k8 L+ l' G
    7. Compile the hardware design, in Quartus. This will generate the handoff folder based on which we will generate the Preloader.
    Preloader
    This section presents how to:
    • Generate the Preloader based on the hardware design,
    • Compile the Preloader,
    • Convert the Preloader executable to a hex file that can be used to initialize the On-Chip memory in the FPGA fabric.
      " ?" B( K5 o( T% f1 V3 f+ w
    The required steps are:
    1. Open an Embedded Command Shell (on Windows, go to Start -> All Programs -> Altera 14.0 -> SoC EDS -> SoC EDS Embedded Command Shell
    2. Start the Preloader Generator by running the command "bsp-editor&".
    3. In the Preloader Generator, go to File -> New BSP ... to open the New BSP window.
    4. In the New BSP window, browse the Preloader settings directory to point to the handoff folder from the hardware design. Then click OK to close the window.
    5. In the Preloader Generator window, peRForm the following:
    • Uncheck WATCHDOG_ENABLE to disable the watchdog (it is not serviced by the bare-metal application)
    • Check EXE_ON_FPGA. This instructs the Preloader to put the program in the FPGA address space, and use HPS OCRAM for rw data.
    • Check the SDRAM_SCRUBBING and SDRAM_SCRUBBING_REMAIN_REGION. This will clear out the SDRAM before the application is ran
    • Check BOOT_FROM_SDMMC and uncheck the other BOOT_FROM_ options
    • Make note of the SDMMC_NEXT_BOOT_IMAGE, which defaults to 0x40000. This is the offset in the custom partition where the Preloader will get the application image from.7 J# k+ e1 t, a& }% `
    6. Click Generate in the Preloader Generator window. Then click Exit to close the window.
    7. In the Embedded Command Shell, change current folder to the location where the Preloader was generated cv_soc_devkit_boot_fpga/software/spl_bsp
    8. In the Embedded Command Shell, run the "make" command to build the Preloader.
    9. Run the following command to convert the Preloader ELF file to HEX:
    arm-altera-eabi-objcopy -O ihex --adjust-vma -0xc0000000 uboot-socfpga/spl/u-boot-spl preloader.hex
    Note that the hardware design needs to now be recompiled or just update the RAM (see below), to make use of the above hex file to initialize the FPGA On-Chip memory used to boot.
         Update the on chip ram from Quartus:     Processing->Update Memory Initialization File     This will update the programming/sof file with the new hex file information for the on chip ram.     This is a handy way to update software for nios as well without doing a full recompile.Bare-metal Application
    The bare-metal application simply displays the message "Hello World" over the serial port.
    The application can be downloaded from the SoC Examples page at http://www.altera.com/support/examples/soc/soc.html. Select the "Unhosted" example, CV Version.
    The direct link is http://www.altera.com/support/examples/soc/Altera-SoCFPGA-HardwareLib-Unhosted-CV-GNU.tar.gz
    The application can be imported and built in the ARM DS-5 Altera Edition, or from the Embedded Command Shell prompt by invoking "make". This will create the image file hello-mkimage.bin.
    Alternatively, the pre-compiled image is also attached to this page, so that the bare-metal project does not need to be re-compiled.
    Running the Example
    1. 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 commandtar -xzf <filename>from the Embedded Command Shell. This will create 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.3 V6 ?/ I2 R; {& C
    2. Write the Bare-metal application 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 following commandalt-boot-disk-util -a write -b hello-mkimage.bin -d <sd_card_drive_letter>6 ~3 F; M8 ]% R& ?2 i2 G$ S
    3. Configure the Cyclone V board to boot from FPGA by setting the BOOTSEL jumpers like this:
    • BOOTSEL0 (J28): left
    • BOOTSEL1 (J29): right
    • BOOTSEL2 (J30): right
      3 z  p3 e2 O. O; F
    4. 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.
    5. Insert the SD card on the board
    6. Power up the board. There should be nothing coming from the board on the serial terminal, since the FPGA is not configured, so the Boot ROM will not jump to FPGA yet.
    7. Configure the FPGA by using the Quartus Programmer, with the cv_soc_devkit_boot_fpga/output_files/soc_system.sof file.
    8. Press the HPS Cold Reset button (S7)
    9. The serial console will show the Preloader being run from FPGA, then the bare-metal application being run from the SD card.
    Files
    This example is delivered as an archive: File:Cv soc devkit boot fpga.zip.
    The most relevant files and folders that compose the archive are presented below:
    cv_soc_devkit_boot_fpga    output_files        soc_system.sof         - Precompiled FPGA image file    software        spl_bsp            preloader.hex      - Precompiled Preloader hex file        hello-mkimage.bin      - Precompiled bare-metal application    soc_system.qpf             - FPGA project fileReferences
    • Quartus II Download: http://dl.altera.com/
    • SoC EDS Download: http://dl.altera.com/soceds/
    • Cyclone V Documentation: http://www.altera.com/literature/lit-cyclone-v.jsp
    • SoC EDS User Guide: http://www.altera.com/literature/ug/ug_soc_eds.pdf
    • SoC Hardware Libs Examples: http://www.altera.com/support/examples/soc/soc.html
    • Win32DiskImager: http://sourceforge.net/projects/win32diskimager/; ?- T- O( b9 u1 t

    & o3 G8 b1 H# h7 @: ^0 U5 X# y6 P, x% l

    $ e: V' p$ T( R7 X& |# K5 D8 I$ T* i! L4 M8 S* n

    该用户从未签到

    2#
    发表于 2019-4-18 17:28 | 只看该作者
    这....英文版看的脑壳疼啊
    您需要登录后才可以回帖 登录 | 注册

    本版积分规则

    关闭

    推荐内容上一条 /1 下一条

    EDA365公众号

    关于我们|手机版|EDA365电子论坛网 ( 粤ICP备18020198号-1 )

    GMT+8, 2025-7-30 21:48 , Processed in 0.125000 second(s), 23 queries , Gzip On.

    深圳市墨知创新科技有限公司

    地址:深圳市南山区科技生态园2栋A座805 电话:19926409050

    快速回复 返回顶部 返回列表