├── .dockerignore ├── .gitignore ├── Dockerfile ├── LICENSE ├── README.md ├── docker_build.sh ├── etc └── petalin.sh └── petalin.sh /.dockerignore: -------------------------------------------------------------------------------- 1 | resources/** 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | resources/*.run 2 | resources/*.bin 3 | resources/*.tar 4 | resources/*.tgz 5 | resources/*.tar.gz 6 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:18.04 2 | 3 | # The Xilinx toolchain version 4 | ARG XILVER=2022.2 5 | 6 | # The PetaLinux base. We expect ${PETALINUX_BASE}-installer.run to be the patched installer. 7 | # PetaLinux will be installed in /opt/${PETALINX_BASE} 8 | # File is expected in the "resources" subdirectory 9 | ARG PETALINUX_BASE=petalinux-v${XILVER}-final 10 | 11 | # The PetaLinux runnable installer 12 | ARG PETALINUX_INSTALLER=${PETALINUX_BASE}-installer.run 13 | 14 | # The HTTP server to retrieve the files from. It should be accessible by the Docker daemon as ${HTTP_SERV}/${SDK_INSTALLER} 15 | ARG HTTP_SERV=http://172.17.0.1:8000/resources 16 | 17 | # Make tzdata package install non interactive. See https://serverfault.com/a/1016972/308291 18 | ARG DEBIAN_FRONTEND=noninteractive 19 | ENV TZ=Etc/UTC 20 | 21 | RUN dpkg --add-architecture i386 && apt-get update && apt-get install -y \ 22 | python3 \ 23 | bc \ 24 | rsync \ 25 | apt-utils \ 26 | tofrodos \ 27 | iproute2 \ 28 | gawk \ 29 | xvfb \ 30 | gcc-4.8 \ 31 | git \ 32 | make \ 33 | net-tools \ 34 | libncurses5-dev \ 35 | tftpd \ 36 | tftp-hpa \ 37 | zlib1g-dev:i386 \ 38 | libssl-dev \ 39 | flex \ 40 | bison \ 41 | libselinux1 \ 42 | gnupg \ 43 | wget \ 44 | diffstat \ 45 | chrpath \ 46 | socat \ 47 | xterm \ 48 | autoconf \ 49 | libtool \ 50 | tar \ 51 | unzip \ 52 | texinfo \ 53 | zlib1g-dev \ 54 | gcc-multilib \ 55 | build-essential \ 56 | libsdl1.2-dev \ 57 | libglib2.0-dev \ 58 | screen \ 59 | expect \ 60 | locales \ 61 | cpio \ 62 | sudo \ 63 | software-properties-common \ 64 | pax \ 65 | gzip \ 66 | vim \ 67 | libgtk2.0-0 \ 68 | && apt-get autoremove --purge && apt-get autoclean 69 | 70 | RUN echo "%sudo ALL=(ALL:ALL) ALL" >> /etc/sudoers \ 71 | && echo "%sudo ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers \ 72 | && ln -fs /bin/bash /bin/sh 73 | 74 | # Set locale 75 | RUN locale-gen en_US.UTF-8 76 | ENV LANG en_US.UTF-8 77 | ENV LANGUAGE en_US:en 78 | ENV LC_ALL en_US.UTF-8 79 | 80 | # Add user 'petalinux' with password 'petalinux' and give it access to install directory /opt 81 | RUN useradd -m -G dialout,sudo -p '$6$wiu9XEXx$ITRrMySAw1SXesQcP.Bm3Su2CuaByujc6Pb7Ztf4M9ES2ES7laSRwdcbgG96if4slduUxyjqvpEq2I0OhxKCa1' petalinux \ 82 | && chmod +w /opt \ 83 | && chown -R petalinux:petalinux /opt \ 84 | && mkdir /opt/${PETALINUX_BASE} \ 85 | && chmod 755 /opt/${PETALINUX_BASE} \ 86 | && chown petalinux:petalinux /opt/${PETALINUX_BASE} 87 | 88 | # Install under /opt, with user petalinux 89 | WORKDIR /opt 90 | USER petalinux 91 | 92 | # Install PetaLinux 93 | RUN chown -R petalinux:petalinux . \ 94 | && wget -q ${HTTP_SERV}/${PETALINUX_INSTALLER} \ 95 | && chmod a+x ${PETALINUX_INSTALLER} \ 96 | && SKIP_LICENSE=y ./${PETALINUX_FILE}${PETALINUX_INSTALLER} --skip_license --dir /opt/${PETALINUX_BASE} \ 97 | && rm -f ./${PETALINUX_INSTALLER} \ 98 | && rm -f petalinux_installation_log 99 | 100 | # Source settings at login 101 | USER root 102 | RUN echo "source /opt/${PETALINUX_BASE}/settings.sh" >> /etc/bash.bashrc 103 | 104 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Copyright (c) 2018, Matthieu Labas 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Generic Petalinux Dockerfile 2 | 3 | A somehow generic Xilinx PetaLinux 2020+ docker file, using Ubuntu (though some tweaks might be possible for Windows). 4 | 5 | It was successfully tested with version `2022.2`. 6 | 7 | >Inspired by [docker-xilinx-petalinux-desktop](https://github.com/JamesAnthonyLow/docker-xilinx-petalinux-desktop) (and some of [petalinux-docker](https://github.com/xaljer/petalinux-docker)). 8 | 9 | ## Petalinux installer 10 | 11 | Download PetaLinux installer from [Xilinx/AMD website](https://www.xilinx.com/support/download/index.html/content/xilinx/en/downloadNav/embedded-design-tools.html). 12 | 13 | > N.B. Petalinux 2022.2 installer is named `petalinux-v2022.2-10141622-installer.run` so you want to either rename it to `petalinux-v2022.2-final-installer.run` or create a link. 14 | 15 | ## Build the image 16 | 17 | Building the image requires a local HTTP server to serve big resources instead of pushing them to the Docker daemon so make sure the firewall is configured appropriately to allow incoming connections on docker network link tcp:172.17.0.1:8000, e.g.: 18 | 19 | sudo ufw allow from 172.17.0.0/16 to 172.17.0.1 20 | 21 | Run: 22 | 23 | ./docker_build.sh 24 | 25 | > `` can be `2022.2`, ... 26 | > Corresponding petalinux and SDK files are expected to be found in `resources` directory. 27 | 28 | The `docker_build.sh` will automatically spawn a simple HTTP server to serve the installers instead of copying them to the docker images (especially pushing them to the Docker daemon. Big space/time saver). 29 | 30 | The image takes a some time to build, but should succeed. 31 | 32 | It weighs around 12 GB. 33 | 34 | ### Parameters 35 | 36 | Several arguments can be provided to customize the build, with `--build-arg`: 37 | 38 | * `XILVER` for the Xilinx version to install. The `Dockerfile` expects to find `${HTTP_SERVER}/petalinux-v${XILVER}-final-installer.run` for the PetaLinux installer (unless `PETALINUX_INSTALLER` is given). 39 |
Defaults to `2022.2`. 40 | 41 | * `PETALINUX_BASE` is the name of the PetaLinux base. Petalinux will be installed in `/opt/${PETALINUX_BASE}` and the installer is expected to be sourced from `resources/${PETALINUX_BASE}-installer.run`. 42 |
Defaults to `petalinux-v${XILVER}-final`. 43 | 44 | * `PETALINUX_INSTALLER` is the PetaLinux installer file. 45 |
Defaults to `${PETALINUX_BASE}-installer.run` 46 | 47 | * `HTTP_SERV` is the HTTP server serving both SDK and PetaLinux installer. 48 |
Defaults to `http://172.17.0.1:8000/resources`. 49 | 50 | You can fully customize the installation by manually running e.g.: 51 | 52 | docker build . -t petalinux:2022.2 \ 53 | --build-arg XILVER=2022.2 \ 54 | --build-arg PETALINUX_INSTALLER=petalinux/petalinux-v2022.2-10141622-installer.run \ 55 | --build-arg HTTP_SERV=https://local.company.com/dockers/petalinux/2022.2/resources 56 | 57 | Petalinux at `https://local.company.com/dockers/petalinux/2022.2/resources/petalinux/petalinux-v2022.2-10141622-patched.run` 58 | 59 | ## Work with a PetaLinux project 60 | 61 | A helper script `petalin.sh` is provided that should be run *inside* a petalinux project directory. It basically is a shortcut to: 62 | 63 | docker run -ti -v "$PWD":"$PWD" -w "$PWD" --rm -u petalinux petalinux: $@ 64 | 65 | When run without arguments, a shell will spawn, *with PetaLinux and SDK `settings.sh` already sourced*, so you can directly execute `petalinux-*` commands. 66 | 67 | user@host:/path/to/petalinux_project$ /path/to/petalin.sh 68 | petalinux@a3ce6f8c:/path/to/petalinux_project$ petalinux-create -t project --template zynq -n 69 | petalinux@a3ce6f8c:/path/to/petalinux_project$ petalinux-config --get-hw-description <...> 70 | petalinux@a3ce6f8c:/path/to/petalinux_project$ petalinux-build 71 | 72 | Otherwise, the arguments will be executed as a command. 73 | 74 | > N.B. the SDK and PetaLinux `settings.sh` will not be sourced when running commands: 75 | 76 | user@host:/path/to/petalinux_project$ /path/to/petalin.sh petalinux-build 77 | 78 | will fail because `petalinux-build` is not part of the path. But you can create your own script and start it instead: 79 | 80 | # mbuild.sh 81 | . /opt/petalinux-v2018.2-final/settings.sh 82 | petalinux-build 83 | 84 | then: 85 | 86 | user@host:/path/to/petalinux_project$ /path/to/petalin.sh ./mbuild.sh 87 | -------------------------------------------------------------------------------- /docker_build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Default version 2022.2 4 | XILVER=${1:-2022.2} 5 | 6 | # Check SDK and petalinux installers exists 7 | PLNX="resources/petalinux-v${XILVER}-final-installer.run" 8 | if [ ! -f "$PLNX" ] ; then 9 | echo "$PLNX installers not found" 10 | exit 1 11 | fi 12 | 13 | # Check HTTP server is running 14 | if ! ps -fC python3 | grep http.server > /dev/null ; then 15 | python3 -m http.server & 16 | HTTPID=$! 17 | echo "HTTP Server started as PID $HTTPID" 18 | trap "kill $HTTPID" EXIT KILL QUIT SEGV INT HUP TERM ERR 19 | fi 20 | 21 | echo "Creating Docker image petalinux:$XILVER..." 22 | time docker build . -t petalinux:$XILVER --build-arg XILVER=${XILVER} 23 | [ -n "$HTTPID" ] && kill $HTTPID && echo "Killed HTTP Server" 24 | -------------------------------------------------------------------------------- /etc/petalin.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Run from a PetaLinux project directory 3 | latest=$(docker image list | grep ^petalinux | awk '{ print $2 }' | sort | tail -1) 4 | echo "Starting petalinux:$latest" 5 | docker run -ti -v "$PWD":"$PWD" -w "$PWD" --rm -u petalinux petalinux:$latest $@ 6 | -------------------------------------------------------------------------------- /petalin.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Run from a PetaLinux project directory 3 | latest=$(docker image list | grep ^petalinux | awk '{ print $2 }' | sort | tail -1) 4 | echo "Starting petalinux:$latest" 5 | docker run -ti -v "$PWD":"$PWD" -w "$PWD" -p 2222:2222 --rm -u petalinux petalinux:$latest $@ 6 | --------------------------------------------------------------------------------