# Quick Porting of PYNQ using Pre-built Images

**URL:** <https://discuss.pynq.io/t/quick-porting-of-pynq-using-pre-built-images/1075>\
**Category:** Learn\
**Created:** [March 30, 2020, 1:43pm UTC](https://discuss.pynq.io/t/quick-porting-of-pynq-using-pre-built-images/1075 "2020-03-30T13:43:27Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![PeterOgden](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/peterogden/32/55_2.png) [@PeterOgden](https://discuss.pynq.io/u/PeterOgden)\
**Post date:** [March 30, 2020, 1:43pm UTC](https://discuss.pynq.io/t/quick-porting-of-pynq-using-pre-built-images/1075/1 "2020-03-30T13:43:27Z")

</div>

This is a quick post showing how to use the pre-built images we ship with each PYNQ release to quickly get PYNQ up and running on a new board. The starting point for porting PYNQ is to have a working Petalinux BSP for the board - for details on creating a BSP for a custom board please refer to the [Petalinux documentation](https://www.xilinx.com/support/documentation/sw_manuals/xilinx2019_2/ug1144-petalinux-tools-reference-guide.pdf). For this example we’ll use the [ZC706 BSP](https://www.xilinx.com/member/forms/download/xef.html?filename=xilinx-zc706-v2019.1-final.bsp).

## Quickstart

To begin with we need the following requirements

1. Ubuntu instance (preferable a virutal machine)
2. Correct version of Petalinux installed and on the PATH (See the [documentation](https://pynq.readthedocs.io/en/latest/pynq_sd_card.html) - for 2.5 use Petalinux 2019.1)
3. `kpartx` and `zerofree` packages installed
4. Most recent board agnostic image from [pynq.io](http://www.pynq.io/board.html) listed under _Other boards_
5. Clone of PYNQ repository at the release version corresponding to the pre-built - v2.5 at the time of writing
6. BSP file for the correct version of Petalinux. Xilinx BSPs are available from [downloads section of Xilinx.com](https://www.xilinx.com/support/download/index.html/content/xilinx/en/downloadNav/embedded-design-tools.html)
7. Optionally sudo set up for passwordless operation

With the prerequistes in place we can go to the `PYNQ/sdbuild` folder and run the `scripts/image_from_prebuilt.sh` script using bash. Running it with no arguments shows what’s expected

```auto
$ bash scripts/image_from_prebuilt.sh

scripts/image_from_prebuilt.sh board bsp_file arch prebuilt

Script for generating a board-specific image from a board agnostic prebuilt image

board : The name of the board
bsp_file : The BSP file to use
arch : The architecture of the system - either arm or aarch64
prebuilt : The image to use as a base

```

Most of the arguments are self-explanatory except possibly for the `board` arguments. This is the name of the resulting image and will also appear in the `BOARD` environment variable once the image is booted.

Placing the BSP and prebuilt image in the `sdbuild` folder means that the full command for generating the ZC706 image is

```auto
$ bash scripts/image_from_prebuilt.sh ZC706 xilinx-zc706-v2019.1-final.bsp arm bionic.arm.2.5.img

```

Once the script has finished the image will be in the `outputs` folder ready to be burned to an SD card.

## Customising the image

As our pre-built images are designed to be completely generic they do not configure Ethernet. The drivers will still be present but the Ethernet port will need to be configured manually. To create an image with Ethernet preconfigured we need to create a _board repository_ for the board in question where we can add the `ethernet` package that is provided by the sdbuild flow to set up the Ethernet port. For full details on creating a board repository see the [PYNQ documentation](https://pynq.readthedocs.io/en/latest/pynq_sd_card.html#retargeting-to-a-different-board).

For the purposes of this example we are going to create a ZC706.spec file containing the following:

```Makefile
ARCH_ZC706 = arm
BSP_ZC706 = xilinx-zc706-v2019.1-final.bsp
STAGE4_PACKAGES_ZC706 = ethernet

```

This file is going to live in a folder structure of `test_repo/ZC706` along with the BSP file.

To build our more customised SD card image while still using the pre-built we can run

```auto
$ make BOARDDIR=test_repo PREBUILT=bionic.arm.2.5.img

```

## 

To avoid checking all of the dependencies that are not required for building from a prebuilt we can instead use the `nocheck_images` target

```auto
$ make BOARDDIR=test_repo PREBUILT=bionic.arm.2.5.img nocheck_images

```

Again the resulting image will appear in the `output` folder.

---

_[View the full topic](https://discuss.pynq.io/t/quick-porting-of-pynq-using-pre-built-images/1075)._
