NAI ARM Linux Quick-Start Guide (PetaLinux 2018)

Overview

This document describes how to set up your environment and cross-compile NAI’s Software Support Kit (SSK) 2.x to be run on a PetaLinux 2018.2 target.

Environment Setup

Required Tools

  • Xilinx SDK 2018.2
  • NAI Library Package
  • Terminal Program (Teraterm)

Downloading Xilinx

  1. Head to the Xilinx website archive section.

  2. Click the 2018.2 tab to expand it.

  3. Select the All OS installer to begin download, then run the installer. The tool that will be used for development is Xilinx SDK 2018.2, which is included in the Vivado Design Suite installation.

Building and Running a Project

Importing and Building Sample Applications

  1. Run Xilinx SDK 2018.2 and select the following folder from the NAI library package as your workspace:
  • PACKAGE_LOCATION\petalinux-2018-2\petalinux-appsrc
  1. If there are already projects when you load the workspace, select them all, right-click, and Delete them. Do NOT select “Delete project contents on disk”.
  1. Import NAI projects by selecting FileImportExisting Projects into Workspace from the Xilinx SDK toolbar:
  1. Select Next and then select the workspace directory as the root directory:
  • PACKAGE_LOCATION\petalinux-2018-2\petalinux-appsrc
  1. Select finish to add NAI libraries and sample code projects to the workspace.
  • If you get this error, simply X it out and X out the Import window.
  • Your Project Explorer should now look similar to this:
  1. Navigate to Project at the top of Xilinx and make sure Build automatically is unchecked.

  2. Select WindowPreferences from the Xilinx toolbar and set the Indexer to “Use active build configuration” and select OK.

  1. Select all of the projects, right-click, click Build Configurations, Set Active, Debug-UltraScale/Zynq-********** (pick the configuration (Zynq/UltraScale) and the board you have, ex. NIU3A).
  1. Select all of the library projects (nai_bsp projects, nai_libs projects, naiapp_common) and right-click Clean Project then right-click Build Project.
  1. Select a module sample project to Clean then Build which will generate an elf executable that can be run on the processor board.

Creating a New Hello World Application

  1. Navigate to FileNewApplication Project to get to the New Project wizard and select XilinxApplication Project.
  1. Provide a name for the project, select linux as the OS Platform and select psu_cortexa53 as the processor type. Language should default to C and Compiler should default to 64-bit. Press next when complete.
  1. Select the type of application template you’d like to start with and click Finish when complete.
  1. A project with the name entered will appear in the project explorer, right-click the project and build to generate the executable ELF file.
  • If your projects appear to successfully build but the Project Explorer still shows a red X on them, trying clicking ProjectC/C++ IndexRebuild to rebuild your projects.

Creating Projects from Scratch

  • Projects can be created with their source code and library includes manually created/linked. This can be helpful if a sample app is having issues and you want to go step by step to make sure nothing is wrong.
  1. If you wish to create projects from scratch (starting from a blank slate, creating projects, and linking the source code manually) then navigate to FileSwitch Workpsace and set the path to ‘SSK_Template_FromScratch/Template-petalinux-2018-2/petalinux-appsrc’.
  • This directory is included with the package and has the same folder structure as the normal petalinux-2018-2 folder but the folders contain nothing so that projects can be made from a blank slate with nothing being detected by Xilinx.

Note

For Zynq, the workspace path would instead be “SSK_Template_FromScratch/Template-petalinux” and all subsequent path locations would follow this path rather than the aforementioned UltraScale one.

Creating an NAI Library Project from Scratch

  1. Navigate to FileNew…Project. Select Library Project under the Xilinx dropdown.
  1. Create a project named nai_bsp-naibsp. Uncheck ‘Use default location’ and change the location to ‘SSK_Template_FromScratch/Template-petalinux-2018-2\petalinux-appsrc\nai_bsp\naibsp’. Select the settings as shown in the screenshot and click Finish when done.

Note

If you use the Brose button to Brose to the location of ‘SSK_Template_FromScratch’ but can’t get to it because the C: drive doesn’t show up as an option to browse to, type ‘C:’ into the Location text box and then press Brose again, and you should be able to Brose into the C: drive.

  • Your workspace in the IDE should now have an ‘nai_bsp-naibsp’ project.
  1. Click the arrow to expand the project, then right-click on the src folder and click Delete. Press OK after it asks to confirm the deletion.
  1. Right-click the project and click Build ConfigurationsManage…
  1. Click New…
  1. Add Debug-UltraScale-68ARM2 as the Name with the Existing configuration based on Debug then press OK.

Note

Replace UltraScale with Zynq if your board is Zynq, and replace 68ARM2 with the board you have, ex. NIU3A, 64ARM1.

  1. Click on this new configuration and click Set Active.
  1. Right-click on the project and select ‘Properties’. Now, select ‘Path and Symbols’ and select the ‘Includes’ page. Click Add… and add the following directories. Press OK when done. If the program asks to rebuild then say no.
  • ${workspace_loc}/../../base/

  • ${workspace_loc}/../../base/nai_bsp

  • ${workspace_loc}/../../base/nai_bsp/naibsp_config_68arm2_petalinux

Note

Replace the 68arm2 in the config folder with your board, ex. NIU3A, 64ARM1.

  1. Right-click on the project and select NewFolder.
  1. Click Advanced to show more options then click ‘Link to alternate location (Linked Folder)‘. Write WORKSPACE_LOC…\base\nai_bsp\naibsp as the folder location. Click Finish.
  1. Add another folder with NewFolder. For the path write WORKSPACE_LOC…\base\nai_bsp\naibsp_config_68arm2_petalinux as the folder location. Click Finish.

Note

Replace the 68arm2 in the config file with your board.

  1. Right-click the project to Clean Project and then Build Project. The project should build and the progress will be displayed in the ‘Console’ tab. When finished, there will be a newly created ‘Debug-Zynq/UltraScale-XXXXXX’ folder with an archive file (static library) named ‘libnai_bsp-naibsp.a’.

Adding Additional Library Projects

  • If other libraries are needed, then the steps are the same except for differences in names and paths. The following is a list of the different library paths, debug configurations, and folder paths.

Note

Replace UltraScale with Zynq if your configuration requires Zynq instead, and replace the 68ARM2 in the Debug Configuration with your board, ex. NIU3A, 64ARM1.

  • nai_bsp

    • nai_bsp-naibsp (explained in the above tutorial)

    • nai_bsp-naibsp_sys

      • NewProject step
        • Name:nai_bsp-naibsp_sys
        • Path: ‘PACKAGE_LOC\Template-petalinux-2018-2\petalinux-appsrc\nai_bsp\naibsp_sys’
      • Debug Configuration Name
        • Debug-UltraScale-68ARM2
      • NewFolder step
        • WORKSPACE_LOC…\base\nai_bsp\naibsp_sys
    • nai_bsp-naibsp_sbit

      • NewProject
        • Name:nai_bsp-naibsp_sbit
        • Path: ‘PACKAGE_LOC\Template-petalinux-2018-2\petalinux-appsrc\nai_bsp\naibsp_sbit’
      • Debug Configuration Name
        • Debug-UltraScale-68ARM2
      • NewFolder step
        • WORKSPACE_LOC…\base\nai_bsp\naibsp_sbit
    • nai_bsp-naibsp_dev

      • NewProject
        • Name:nai_bsp-naibsp_dev
        • Path: ‘PACKAGE_LOC\Template-petalinux-2018-2\petalinux-appsrc\nai_bsp\naibsp_dev’
      • Debug Configuration Name
        • Debug-UltraScale-68ARM2
      • NewFolder step
        • WORKSPACE_LOC…\base\nai_bsp\naibsp_dev
  • nai_libs

    • nai_libs-naibrd

      • NewProject
        • Name:nai_libs-naibrd
        • Path: ‘PACKAGE_LOC\Template-petalinux-2018-2\petalinux-appsrc\nai_libs\nai_libs-naibrd’
      • Debug Configuration Name
        • Debug-UltraScale-68ARM2
      • NewFolder step
        • WORKSPACE_LOC…\base\nai_libs\naibrd\src
        • WORKSPACE_LOC…\base\nai_libs\naibrd\include
    • nai_libs-naiether

      • NewProject
        • Name:nai_libs-naiether
        • Path: ‘PACKAGE_LOC\Template-petalinux-2018-2\petalinux-appsrc\nai_libs\nai_libs-naiether’
      • Debug Configuration Name
        • Debug-UltraScale-68ARM2
      • NewFolder step
        • WORKSPACE_LOC…\base\nai_libs\naiether\src
        • WORKSPACE_LOC…\base\nai_libs\naiether\include
    • nai_libs-naiif

      • NewProject
        • Name:nai_libs-naiif
        • Path: ‘PACKAGE_LOC\Template-petalinux-2018-2\petalinux-appsrc\nai_libs\nai_libs-naiif’
      • Debug Configuration Name
        • Debug-UltraScale-68ARM2
      • NewFolder step
        • WORKSPACE_LOC…\base\nai_libs\naiif\src
        • WORKSPACE_LOC…\base\nai_libs\naiif\include
    • nai_libs-nailib

      • NewProject
        • Name:nai_libs-nailib
        • Path: ‘PACKAGE_LOC\Template-petalinux-2018-2\petalinux-appsrc\nai_libs\nai_libs-nailib’
      • Debug Configuration Name
        • Debug-UltraScale-68ARM2
      • NewFolder step
        • WORKSPACE_LOC…\base\nai_libs\nailib\src
        • WORKSPACE_LOC…\base\nai_libs\nailib\include
    • naiapp_common

      • NewProject
        • Name:naiapp_common
        • Path: ‘PACKAGE_LOC\Template-petalinux-2018-2\petalinux-appsrc\nai_sample_apps\naiapp_common’
      • Debug Configuration Name
        • Debug-UltraScale-68ARM2
      • NewFolder step
        • WORKSPACE_LOC…\base\nai_sample_apps\naiapp_common\src
        • WORKSPACE_LOC…\base\nai_sample_apps\naiapp_common\include

Creating an NAI Sample Project from Scratch

  • All library projects must be created or imported as described previously in order for the sample apps to build.
  1. Navigate to FileNewApplication Project to get to the New Project wizard and select XilinxApplication Project, then click Next.
  1. Set the project name; in this example, we use naiapp_mod_ad_basic_ops.

  2. Uncheck the use default location check box, and set the location to C:\SSK_Template_FromScratch\Template-petalinux-2018-2\petalinux-appsrc\nai_sample_apps\naiapp_src\board_modules\ad\ad_basic_ops

Note

For Zynq, the workspace path would instead be “SSK_Template_FromScratch/Template-petalinux”, and all subsequent path locations would follow this path rather than the aforementioned UltraScale one.

  1. Change the OS Platform to linux and select psu_cortexa53 as the processor type for UltraScale or ps7_cortexa9 for Zynq. Language should default to C and Compiler should default to 64-bit or 32-bit for Zynq. Press Next when complete.
  1. Under “Available Templates”, select the Linux Empty Application and click the Finish button.
  1. The project “naiapp_mod_ad_basic_ops” should now be added to the Workspace and listed under the Project Explorer. Expand the “naiapp_mod_ad_basic_ops” project and “src” folder and right-click the readme.txt file. Select Delete to remove the readme.txt file from the project. Press OK on the confirmation prompt.
  1. Right-click on the “naiapp_mod_ad_basic_ops” folder and select properties. Select C/C++ General Paths and Symbols and click the Manage Configurations button.
  1. Click the New button to create a new Configuration.
  1. Enter the name as “Debug-UltraScale-68ARM2” or “Debug-Zynq-68ARM2” with the Existing configuration set to Debug and click the OK button. Replace 68ARM2 with the board you want to use.

  2. Select Debug-Zynq/UltraScale-XXXXX and click on the Set Active button to make it the active configuration and click OK to close the window.

  3. In the Configuration drop down box, select the Debug-Zynq/UltraScale-XXXXX configuration if it’s not already selected.

  4. If not already in the Properties window, right-click the project and click PropertiesC/C++ GeneralPaths and Symbols. Under the includes tab, add the following paths:

  • ${workspace_loc}/../../base
  • ${workspace_loc}/../../base/nai_bsp
  • ${workspace_loc}/../../base/nai_bsp/naibsp_config_68arm2_petalinux

Note

Replace the 68arm2 in the config file with the board that you have.

  1. Under the Libraries tab click Add… and add the following (ORDER MATTERS):
  • m
  • pthread
  • naiapp_common
  • nai_libs-naibrd
  • nai_bsp-naibsp_sys
  • nai_libs-naiif
  • nai_libs-naiether
  • nai_libs-nailib
  • nai_bsp-naibsp
  1. Under the Library Paths tab click Add…, add the following and check “Is a workspace path” (ORDER MATTERS):

Note

Replace UltraScale with Zynq if your configuration requires Zynq and 68ARM2 with your board, ex. NIU3A, 64ARM1

  • /nai_bsp-naibsp/Debug-UltraScale-68ARM2
  • /nai_bsp-naibsp_sys/Debug-UltraScale-68ARM2
  • /naiapp_common/Debug-UltraScale-68ARM2
  • /nai_libs-naibrd/Debug-UltraScale-68ARM2
  • /nai_libs-naiether/Debug-UltraScale-68ARM2
  • /nai_libs-naiif/Debug-UltraScale-68ARM2
  • /nai_libs-nailib/Debug-UltraScale-68ARM2
  1. Click OK on the Properties window to save the settings.

  2. In the Project Explorer, right-click on the “naiapp_mod_ad_basic_ops” project and select Build ConfigurationsSet ActiveDebug-Zynq/UltraScale-XXXXX.

  3. To add the source file to the project, right-click on the “src” folder inside the “naiapp_mod_ad_basic_ops” project folder, and select New File. Click the Advanced button followed by the Link to file in the file system check box.

  4. Click the browse button and add the file path SSK_Template_FromScratch\base\nai_sample_apps\naiapp_src\board_modules\ad\ad_basic_ops\src\ad_basic_ops.c. Change the path to WORKSPACE_LOC…\base\nai_sample_apps\naiapp_src\board_modules\ad\ad_basic_ops\src\ad_basic_ops.c if you want the path to be relative to the workspace location. Click the finish button to add the file to the project.

  1. The project is now ready to build by right-clicking the project and clicking Clean Project then right-clicking and clicking Build Project. Once the build completes, an naiapp_mod_ad_basic_ops.elf file will be created in the Debug-UltraScale folder.

Adding Additional NAI Sample App Projects

  • The steps for adding new sample app projects from scratch are the same steps as stated above but the folder paths depend on the sample app.

  • The project will be created in a path that starts as SSK_Template_FromScratch\Template-petalinux-2018-2\petalinux-appsrc\nai_sample_apps-naiapp_src\board_modules. The next folder is the module family, followed by the name of the sample app (ex. ad for ad_basic_ops, dt for dt_basic_ops).

  • Some sample apps include a utils folder which will be seen within the module’s folder. To add these, you right-click the project, click NewFolderAdvancedLink to alternate location (Linked folder) and Browse… for it.

  • The source code will be in a path that starts as SSK_Template_FromScratch\base\nai_sample_apps\naiapp_src\board_modules, again followed by the module family, then a folder with the name of the sample app which contains the necessary .c file.