在openPOWERLINK v2.4.1源码上编译 “Zynq SoC non-OS FPGA systems”项目

文档:http://openpowerlink.sourceforge.net/doc/2.4/2.4.1/page_platform_zynq.html

开发板:ZC702 REV1.1 + AES-FMC-ISMNET2-G(扩展卡,卡上有两个10/100M的PHY)

步骤如下:

Ⅰ,Building the Hardware Platform(Target Xilinx Microblaze)

Execute the following steps below to generate the FPGA configuration and all hardware-dependent drivers.

  1. Open a shell where the Xilinx ISE 14.7 Toolchain is configured:
    • On a Windows host platform open the ISE Design Suite [64,32] Bit Command Prompt.
    • On a Linux host platform execute the script <ISE_ROOT_DIR>/settings[32,64].sh> to configure your current shell.(例如: >source /opt/Xilinx/14.7/ISE_DS/settings64.sh)
  2. Initialize the hardware platform build system

     > cd openPOWERLINK/hardware/build/xilinx-microblaze
     > cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=../../../cmake/toolchain-xilinx-microblaze-gnu.cmake ../..
    

    After this command CMake will search for available hardware platforms and report all found platforms by the following messages:

      Found hardware platform: DEMO_S6PLKEB_CN_SINGLE_GPIO set to OFF!
      Found hardware platform: DEMO_[BOARD_NAME]_[DEMO_NAME] set to OFF!
    
  3. Build hardware platform with all driver libraries set to debug

     > cmake ../.. -DCMAKE_BUILD_TYPE=Debug -DDEMO_[BOARD_NAME]_[DEMO_NAME]=ON
     > make
     > make install
    

    This will build the hardware platform for the demo DEMO_[BOARD_NAME]_[DEMO_NAME]. Multiple platforms can be built together by passing each platform define to CMake.

  4. Build hardware platforms with all driver libraries set to release
     > cmake ../.. -DCMAKE_BUILD_TYPE=Release -DDEMO_[BOARD_NAME]_[DEMO_NAME]=ON
     > make
     > make install
    

The default hardware platform installation path is: <openPOWERLINK_DIR>/hardware/lib/generic/<CMAKE_SYSTEM_PROCESSOR>/<BOARD_NAME>/<DEMO_NAME>

这里:BOARD_NAME = Z702

    DEMO_NAME = MN_DUAL_SHMEM_GPIO

这一步生成:libmb-uart.a、libomethlib.a、libdualprocshm-pcp、system.bit,用于生成oplkdrv-daemon.elf(运行在Microblaze上)

Ⅱ,Building Stack library for Microblaze(no os)

Follow the steps below to build the stack library on your host platform:

  • Open a shell where the Xilinx ISE 14.7 Toolchain is configured.
    • On a Windows host platform open the ISE Design Suite [64,32] Bit Command Prompt.
    • On a Linux host platform execute the script <ISE_ROOT_DIR>/settings[32,64].sh> to configure your current shell.(例如: >source /opt/Xilinx/14.7/ISE_DS/settings64.sh)
  • Create debug libraries

    > cd <openPOWERLINK_directory>\stack\build\xilinx-microblaze
    > cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=../../../cmake/toolchain-xilinx-microblaze-gnu.cmake ../.. -DCMAKE_BUILD_TYPE=Debug -DCFG_COMPILE_LIB_[LIB_NAME]=ON 
    > make install
    

    This will create the [LIB_NAME] stack library (debug) for the hardware library in [PATH_TO_HW_LIB]. Multiple stack libraries can be built together by passing the define pairs (CFG_COMPILE_LIB_[LIB_NAME] and CFG_COMPILE_LIB_[LIB_NAME]_LIB_DIR) for each stack library to CMake. Refer to Microblaze Configuration Options for details!

  • Create release libraries

  • > cd <openPOWERLINK_directory>\stack\build\xilinx-microblaze
    > cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=../../../cmake/toolchain-xilinx-microblaze-gnu.cmake ../.. -DCMAKE_BUILD_TYPE=Release -DCFG_COMPILE_LIB_[LIB_NAME]=ON 
    > make all
    > make install
    

    This will create the [LIB_NAME] stack library for the hardware library in [PATH_TO_HW_LIB]. Multiple stack libraries can be built together by passing the define pairs (CFG_COMPILE_LIB_[LIB_NAME] and CFG_COMPILE_LIB_[LIB_NAME]_LIB_DIR) for each stack library to CMake. Refer to Microblaze Configuration Options for details!

The default library installation path is: <openPOWERLINK_DIR>/stack/lib/generic/microblaze/<BOARD_NAME>/<DEMO_NAME>这里命令行中LIB_NAME=MNDRV_DUALPROCSHM

生成liboplkmndrv-dualprocshm.a,用于生成oplkdrv_aemon.elf

Ⅲ,Build library for Xilinx Zynq ARM(no os)

Follow the steps below to build the stack library on your host platform:

  • Open a shell where the Xilinx ISE 14.7 Toolchain is configured.
    • On a Windows host platform open the ISE Design Suite [64,32] Bit Command Prompt.
    • On a Linux host platform execute the script <ISE_ROOT_DIR>/settings[32,64].sh> to configure your current shell.(例如: >source /opt/Xilinx/14.7/ISE_DS/settings64.sh)
  • Create debug libraries

    > cd <openPOWERLINK_directory>\stack\build\xilinx-zynqarm
    > cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=../../../cmake/toolchain-xilinx-zynqarm-eabi-gnu.cmake ../.. -DCMAKE_BUILD_TYPE=Debug -DCFG_COMPILE_LIB_[LIB_NAME]=ON -DCFG_COMPILE_LIB_[LIB_NAME]_LIB_DIR=[PATH_TO_HW_LIB]
    > make all
    > make install
    

    This will create the [LIB_NAME] stack library (debug) for the hardware library in [PATH_TO_HW_LIB]. Multiple stack libraries can be built together by passing the define pairs (CFG_COMPILE_LIB_[LIB_NAME] and CFG_COMPILE_LIB_[LIB_NAME]_LIB_DIR) for each stack library to CMake. Refer to Xilinx Zynq ARM Configuration Options for details!

  • Create release libraries

    > cd <openPOWERLINK_directory>\stack\build\xilinx-zynqarm
    > cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=../../toolchain-xilinx-zynqarm-eabi-gnu.cmake ../.. -DCMAKE_BUILD_TYPE=Release -DCFG_COMPILE_LIB_[LIB_NAME]=ON -DCFG_COMPILE_LIB_[LIB_NAME]_LIB_DIR=[PATH_TO_HW_LIB]
    > make all
    > make install
    

    This will create the [LIB_NAME] stack library for the hardware library in [PATH_TO_HW_LIB]. Multiple stack libraries can be built together by passing the define pairs (CFG_COMPILE_LIB_[LIB_NAME] and CFG_COMPILE_LIB_[LIB_NAME]_LIB_DIR) for each stack library to CMake. Refer to Xilinx Zynq ARM Configuration Options for details!

The default library installation path is: <openPOWERLINK_DIR>/stack/lib/generic/xilinx-zynqarm/<BOARD_NAME>/<DEMO_NAME>

这里LIB_NAME=MNAPP_DUALPROC

PATH_TO_HW_LIB=xilinx-z702/mn-dual-shmem-gpio

生成liboplkmnapp-dualprocshm.a,用于生成demo_mn_embedded.elf(运行在ps7_cortexa9_0上)

Ⅳ,Building a PCP daemon for Microblaze

This section will explain the steps to build the PCP daemon for a Microblaze softcore processor in a dual processor design. The PCP daemon uses the driver library for the dual processor shared memory interface (liboplkmndrv-dualprocshm).

To build the PCP daemon (e.g. for Microblaze in Zynq SoC's programming logic (PL) using shared memory interface):

  > cd <openPOWERLINK_dir>/drivers/xilinx-microblaze/drv_daemon/build
  > cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=../../../cmake/toolchain-xilinx-microblaze-gnu.cmake ../.. -DCMAKE_BUILD_TYPE=Release ..
  > make
  > make install

Ⅴ,Building openPOWERLINK Demo Applications(Building for target Xilinx Zynq ARM)

Follow the steps below to cross compile your demo application for Zynq ARM:

  • Open a shell where the Xilinx ISE 14.7 Toolchain is configured.
    • On a Windows host platform open the ISE Design Suite [64,32] Bit Command Prompt.
    • On a Linux host platform execute the script <ISE_ROOT_DIR>/settings[32,64].sh> to configure your current shell.(例如: >source /opt/Xilinx/14.7/ISE_DS/settings64.sh)
  • Create the executable
    > cd <openPOWERLINK_dir>/apps/<demo_dir>/build/xilinx-zynqarm(这里的demo_dir = demo_mn_embedded)
    > cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=../../../../cmake/toolchain-xilinx-zynqarm-eabi-gnu.cmake ../.. -DCMAKE_BUILD_TYPE=[Debug,Release]
    > make all
    > make install

Ⅵ,Bootloader

FPGA based non-OS systems on a Zynq SoC require a First Stage Bootloader (FSBL). The FSBL configures the FPGA with a HW bit stream (if it exists) and loads the Operating System (OS) Image or Standalone (SA) Image or 2nd Stage Boot Loader image from the non-volatile memory (NAND/NOR/QSPI) to RAM (DDR) and starts executing it. It supports multiple partitions, and each partition can be a code image or a bit stream.

The FSBL for the openPOWERLINK demo on Zynq is compiled by importing the project files from the Xilinx installation directory into the bootloader project directory and setting up the necessary configuration to build the bootloader using CMake configuration files. Follow the steps below to compile Zynq FSBL for demos:

  • Open a shell where the Xilinx ISE 14.7 Toolchain is configured.
    • On a Windows host platform open the ISE Design Suite [64,32] Bit Command Prompt.
    • On a Linux host platform execute the script <ISE_ROOT_DIR>/settings[32,64].sh> to configure your current shell.(例如: >source /opt/Xilinx/14.7/ISE_DS/settings64.sh)
  • Creating the executable
    > cd <openPOWERLINK_dir>/contrib/bootloader/xilinx-arm/fsbl/build
    > cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=../../../../../cmake/toolchain-xilinx-zynqarm-eabi-gnu.cmake .. -DCMAKE_BUILD_TYPE=[Debug,Release]
    > make all
    > make install

Ⅶ,Running openPOWERLINK

This section will explain the steps required to run openPOWERLINK demos on a FPGA based non-OS system on a Zynq SoC.

MN embedded demo

In order to debug and run the Zynq MN demo with Xilinx SDK refer to xapp1093 (Debugging the Design, page 22).

The MN embedded demo can be started on the Zynq board using the SD card boot mode. Follow the steps below to start the MN demo on the board:(以上各步骤完成后生成的目标文件都已经cp到openPOWERLINK_directory/bin/generic/zynqarm/xilinx-z702/mn-dual-shm-gpio)

  • Open the ISE Design Suite Command Prompt and execute the following commands:
    > cd <openPOWERLINK_directory>/bin/generic/zynqarm/[BOARD_NAME]/[DEMO_NAME]
    > make all (这里生成BOOT.BIN,运行时需要将ZC702开发板的SW12[NODE SWITCH]设置成00,00表示主站)
    
  • Copy the generated BOOT.BIN file to the SD card.
  • Copy the configuration file (mnobd.cdc) in case the demo is configured to use CDC_ON_SD.(这个选项是自动就有的,不必关心)
  • Use a terminal program to see the debug output (Only possible if the application is compiled in debug mode)
    • Baud rate: 115200
    • Data Bits: 8
    • Stop Bits: 1
    • Parity: none
    • Flow control: none
    • 这样ZC702开发板就可作为主站与从站通信了(可用pc机作为从站,linux命令行运行:$sudo demo_cn_console)
    • 一直以为oplkdrv_daemon.elf是运行在PS端的DDR3上的,其实是通过以下方法将oplkdrv_daemon.elf里的关键函数(都设置成__attributr((section(.local_memory))))放到了连接在Microblaze上的local BRAM里了(放到了download.bit里的local BRAM里):
    • 1,>data2mem -bm system_bd.bmm -bt system.bit -bd oplkdrv_daemon.elf tag pcp -o b download.bit 
    • 2,>arm-xilinx-eabi-objcopy -I elf32-little -O binary -R .local_memory -R .vectors.* oplkdrv_daemon.elf oplkdrv_daemon.bin 
    • 3,>bootgen -image bootimage.bif -o i BOOT.BIN -w on


猜你喜欢

转载自blog.csdn.net/liuzq/article/details/79844789