Build Custom Linux Image for HDL Coder IP Core - MATLAB & Simulink (original) (raw)

This example shows how to build a custom Zynq® Linux® image for a Digilent™ Zybo™ Z7-10 Zynq board by using the MathWorks® build system. The example demonstrates how to set up the build environment and build the Linux image for Digilent Zybo Z7-10 Zynq board. You can use same process to create Linux image for the Digilent Zybo Z7-20 Zynq board or other Zynq platforms. You can load this Linux image to the SD card and boot your hardware board from the SD card.

The MathWorks Build System is a tool that generates custom Linux images through cross-compilation. The MathWorks build system wraps the buildroot in pre- and post-processing scripts to automate the generation of system images for various platforms. The build system uses scripts that take the target board, platform, or image description file as an input and output a complete system image, including the boot loaders, kernel, and user space.

Install Debian-9 Linux Operating System

To run this example, you require a Debian-9 Linux operating system. If you already have Debian-9 Linux OS installed, skip this step.

To install Debian-9 OS:

  1. Download the Debian-9 CD image ISO file. To download a CD image from Debian website, see Debian-9 Download on the Debian website. Download debian-9.13.0-amd64-netinst.iso file.
  2. Install Debian-9 by using the ISO file. During installation, in the Configure the package manager step, set the Debian archive mirror country option to enter information manually to enter archive mirror manually. Click Continue.
  3. Next, set the Debian archive mirror hostname option to archive.debian.org and Debian archive mirror directory option to /debian/. Click Continue to complete installation process.
  4. Complete the Debian-9 installation. Ignore the error message that says "security.debian.org could not be accessed as there are no security updates for debian Lenny".

Debian-9 installation step to configure Debian archive mirror country. Configure Debian archive mirror hostname and mirror directory

Generate Hand-off Files by Using Xilinx Vivado

Before you begin the build process, you must generate hand-off files by using the Xilinx Vivado and AMD Vitis® tools.

To generate the hand-off files, create a reference design using the Xilinx Vivado project. To create a reference design, follow the steps in the Create and Export a Custom Reference Design by Using Xilinx Vivado section in Define Custom Board and Reference Design for AMD Workflow. When creating a reference design, Xilinx Vivado project exports the settings for the Zynq processing system IP, such as the address mapping of memory and peripherals.

After you create the reference design, export the hardware platform from the Vivado block design and extract the header files from Xilinx source archive (XSA) file.

  1. In the Vivado tool, open the block design in Vivado. On the File tab, select Export > Export Hardware. The Export Hardware Platform window opens.
  2. In the Export Hardware Platform window, enter the XSA file name and export path. Click Next.
  3. Xilinx Vivado tool populates the export path with XSA File Name.xsa.
  4. Extract the processor configured header files from the XSA file. To extract header files, navigate to the exported XSA file path in MATLAB®, and enter unzip command with your XSA file name. For example:

unzip design_led_wrapper.xsa

Generated handoff files

Build Zynq Linux Image by Using MathWorks Build System

The MathWorks Buildroot repository on the GitHub® hosts the buildroot framework that creates the Xilinx Zynq platform and Altera® SoC SD card images for MathWorks tools. The build process involves setting up the necessary tools, loading handoff files to the Buildroot directory, build image using script and loading image to SD card.

Build the Zynq Linux image by using the MathWorks build system:

Setup Cross Compiler

To set up the cross compiler, install the Linaro ARM toolchain on your Linux machine. To download the Linaro Toolchain tarball file from the Linaro repository, see Linaro Binaries and download gcc-linaro-6.3.1-2017.02-x86_64_arm-linux-gnueabihf.tar.xz file. Unzip the tarball file and copy the contents to the /opt/linaro/aarch32-6.3.1-2017.02 folder on your Linux machine.

Clone MathWorks Buildroot from GitHub

Clone the buildroot GitHub repository from the MathWorks Buildroot.

git clone https://github.com/MathWorks/buildroot.git

Check out the git branch.

git checkout xilinx-next

Transfer Generated Hand-Off Files into Buildroot Directory

Copy the generated ps7_init_gpl.c, ps7_init_gpl.h files to the buildroot/board/MathWorks/boards/zynq/zyboz710/handoff folder in the zyboz710 buildroot directory on your Debian-9 Linux machine.

Run Build Script

Build Linux SD card image for the specific board by using this Python® build script command:

./build.py -c board/MathWorks/zynq/boards/zyboz710/catalog.xml

Ensure that you install additional packages like gcc, make, or g++ by using sudo commands, when required.

To provide a different path for the toolchain, use this build command:

./build.py -p zynq -b zyboz710 --brconfig BR2_TOOLCHAIN_EXTERNAL_PATH='/opt/linaro/aarch32-6.3.1-2017.02'

When the Linux image builds, the generated image is a ZIP file with name <board_name>_sdcard_hdlcoder_<build_date>.zip under the /buildroot/output/<board_name>_linux_linaro/images folder. To view the content of the image file, extract the <board_name>_sdcard_hdlcoder_<build_date>.zip file.

Load the Linux Image into SD Card

Copy the contents of the ZIP folder into the SD card and insert the SD card into the Zybo Z7-10 board. Ensure that you put the board in SD boot mode by using JP5 jumper switch. For more information about board connections, see Define Custom Board and Reference Design for AMD Workflow.

When you turn on the board, the external console in the PuTTY™ software displays a successful boot login. This ensures that the Linux image loaded on the hardware board.

Putty console

See Also

HDL Language Support and Supported Third-Party Tools and Hardware

Topics

External Websites