Build Linux Image for HDL Coder

34 views (last 30 days)
John
John on 24 Feb 2025
Commented: Kiran Kintali on 31 Dec 2025 at 8:11
I'm trying to follow along with the documentation here: https://www.mathworks.com/help/hdlcoder/ug/xilinx-zynq-linux-image-for-custom-boards.html for creating the Linux image using Mathwork's buildroot. Eventually I have a custom board that I need to create an image for but initially I was trying to build image for the Arrow SoC kit. I did a git clone https://github.com/mathworks/buildroot and I checked out the mathworks_socfpga_R23.2.0 tag. I ran the command:
python build.py -b sockit -p socfpga --brconfig BR2_TOOLCHAIN_EXTERNAL_PATH='/opt/linaro/aarch32-6.3.1-2017.02'
However, it keeps failing on:
Incorrect selection of kernel headers: expected 3.1.x, got 4.6.x
I'm not able to resolve this by changing the header selection in make menuconfig. I'd appreciate any suggestions on how to resolve this. Thank you.
  1 Comment
John
John on 24 Feb 2025
I got passed this error by editing the following lines of board/mathworks/socfpga/defconfig/linaro.defconfig:
BR2_TOOLCHAIN_EXTERNAL_GCC_6=y
BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_6=y
However, I am now getting the error:
freadahead.c: In function 'freadahead':
freadahead.c:92:3: error: #error "Please port gnulib freadahead.c to your platform! Look at the definition of fflush, fread, ungetc on your system, then report this to bug-gnulib."
92 | #error "Please port gnulib freadahead.c to your platform! Look at the definition of fflush, fread, ungetc on your system, then report this to bug-gnulib."
| ^~~~~
Thanks for any help.

Sign in to comment.

Accepted Answer

Kiran Kintali
Kiran Kintali on 20 Dec 2025 at 22:58
Edited: Kiran Kintali on 31 Dec 2025 at 8:10
Build Custom Linux Image for HDL Coder IP Core
This example shows how to build a custom Linux® image for an HDL Coder IP core by using the MathWorks® build system for the Digilent Zybo Z7-10 Zynq® board. The example also demonstrates how to set up the build environment and create a Linux image for the Digilent Zybo Z7-10 Zynq board. You can use the same process to create Linux image for other Zynq platforms.
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.
Requirements
For Altera Board Related workflow see the comment below (summarized here)
  1. Install the Debian-9 OS using link and complete the machine setup
  2. Download and Install the Intel SoC EDS to /opt/intelFPGA/17.0 path in your machine
  3. To avoid any compatibiliy issues and to install additional packages, run the commands: sudo dpkg --add-architecture i386, sudo apt-get update, sudo apt-get install libc6:i386 libstdc++6:i386 zlib1g:i386
  4. Whenever required, you may also need to install addidtional buildroot packages.
  5. Clone the buildroot repo and checkout the mathworks_buildroot branch.
  6. If it is a custom design (other than MathWorks supported design), you may need to copy bitstream files (.rbf) to buildroot/board/mathworks/socfpga/boards/<board_name>/boot folder. If required, copy the generated emif.xml, hps.xml hand-off files to the buildroot/board/mathworks/socfpga/boards/<board_name>/handoff/handoff folder. Based on your design, you should also modify the DTS files as well present in your buildroot directory
  7. Run the build command: ./build.py -p socfpga -b <board_name> --brconfig BR2_TOOLCHAIN_EXTERNAL_PATH='/opt/intelFPGA/17.0/embedded/ds-5/sw/gcc/' --brconfig BR2_PACKAGE_UBOOT_ALTERA_EDS_INSTALLATION='/opt/intelFPGA/17.0/embedded'
Once the build is successful, you can see the Linux image generated as a ZIP file <board_name>_sdcard_linux_<build_date>.zip under the /buildroot/output/<board_name>_linux_linaro/images folder. Extract the ZIP file to see .img file and use Win32DiskImager or balenaEtcher to flash the SD card with .img file.
  3 Comments
Sai
Sai on 31 Dec 2025 at 7:20
To summarize the workflow, below are the steps to follow to build the Linux Image for Altera boards:
  1. Install the Debian-9 OS using link and complete the machine setup
  2. Download and Install the Intel SoC EDS to /opt/intelFPGA/17.0 path in your machine
  3. To avoid any compatibiliy issues and to install additional packages, run the commands: sudo dpkg --add-architecture i386, sudo apt-get update, sudo apt-get install libc6:i386 libstdc++6:i386 zlib1g:i386
  4. Whenever required, you may also need to install addidtional buildroot packages.
  5. Clone the buildroot repo and checkout the mathworks_buildroot branch.
  6. If it is a custom design (other than MathWorks supported design), you may need to copy bitstream files (.rbf) to buildroot/board/mathworks/socfpga/boards/<board_name>/boot folder. If required, copy the generated emif.xml, hps.xml hand-off files to the buildroot/board/mathworks/socfpga/boards/<board_name>/handoff/handoff folder. Based on your design, you should also modify the DTS files as well present in your buildroot directory
  7. Run the build command: ./build.py -p socfpga -b <board_name> --brconfig BR2_TOOLCHAIN_EXTERNAL_PATH='/opt/intelFPGA/17.0/embedded/ds-5/sw/gcc/' --brconfig BR2_PACKAGE_UBOOT_ALTERA_EDS_INSTALLATION='/opt/intelFPGA/17.0/embedded'
Once the build is successful, you can see the Linux image generated as a ZIP file <board_name>_sdcard_linux_<build_date>.zip under the /buildroot/output/<board_name>_linux_linaro/images folder. Extract the ZIP file to see .img file and use Win32DiskImager or balenaEtcher to flash the SD card with .img file.
Kiran Kintali
Kiran Kintali on 31 Dec 2025 at 8:11
Thanks you, content now also repeated in the above answer.

Sign in to comment.

More Answers (0)

Tags

Products


Release

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!