Hackster is hosting Hackster Holidays, Finale: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Tuesday!Stream Hackster Holidays, Finale on Tuesday!
Flint Weller
Published © GPL3+

Build Linux using Yocto Honister for the NXP i. MX 8M Plus

Build Linux 5.15.5_1.0.0 for the MX8MPlus SoC using Yocto v3.4 "Honister" within a Docker container built with a Dockerfile

BeginnerFull instructions provided1 hour1,297
Build Linux using Yocto Honister for the NXP i. MX 8M Plus

Things used in this project

Hardware components

NXP 8MPLUSLPD4-EVK
Not Required
×1
NXP 8MPLUSLPD4-PEVK
Not Required
×1

Software apps and online services

NXP "i.MX Yocto Project User’s Guide" for version 5.15.5_1.0.0 released March 2022

Story

Read more

Code

dockerfile-yocto20

Dockerfile
Dockerfile to build Ubuntu 20.04 "Focal" for Yocto Project 3.4 "Honister"
# dockerfile-yocto20
# Building NXP i.MX Linux using Yocto Project Honister on Ubuntu 20.04 LTS "Focal"
# Flint Weller
# 20220520

# INSTRUCTIONS
# Create Docker image from this dockerfile with command:
#   docker build --file ~/.dockerfile/dockerfile-yocto20 --tag yocto20 .
# Deploy a container with the working directory mounted
# SYNTAX:
#   docker run -dit -P --name DockerContainerName -v WorkstationDirectory:DockerDirectory DockerImageName
# EXAMPLES:
#   docker run -dit -P --name imx8-honister -v /work/docker/honister:/home/build yocto20

# Ubuntu LTS release version numbers with code names
# Ubuntu 22.04 LTS = Jammy Jellyfish
# Ubuntu 20.04 LTS = Focal Fossa
# Ubuntu 18.04 LTS = Bionic Beaver
# Ubuntu 16.04 LTS = Xenial Xerus
# Ubuntu 14.04 LTS = Trusty Tahr

# NXP now has instructions on building a dockerfile
# https://source.codeaurora.org/external/imx/imx-docker/tree/Dockerfile-Ubuntu-20.04


# ----------------------------------------------------------------------
# FROM must be the first command in a dockerfile
# Specify Ubuntu digest to pull from
FROM ubuntu:focal
# Could instead use FROM ubuntu:20.04


# ----------------------------------------------------------------------
# Use DEBIAN_FRONTEND=noninteractive to avoid image build hang waiting
# for a default confirmation [Y/n] at some configurations.
ENV DEBIAN_FRONTEND=noninteractive


# ----------------------------------------------------------------------
# Install dependencies
RUN apt update && apt upgrade -y


# ----------------------------------------------------------------------
# Handle the tzdata prompt
RUN ln -fs /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
RUN DEBIAN_FRONTEND=noninteractive apt install -y --no-install-recommends tzdata


# ----------------------------------------------------------------------
# Put everything we want to install here
RUN DEBIAN_FRONTEND=noninteractive apt install -y --no-install-recommends \
  openssh-client gawk wget git diffstat unzip texinfo file tar \
  gcc-multilib build-essential chrpath socat cpio python \
  python3 python3-pip python3-pexpect xz-utils debianutils \
  iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev \
  pylint3 xterm rsync curl locales apt-utils sudo vim bash-completion screen \
  python3-subunit mesa-common-dev zstd liblz4-tool zstd net-tools \
  ca-certificates
# Notes
#   git-core is a dummy package that calls git
#   zstd provides pzstd
#   liblz4-tool provides lz4c and lz4


# ----------------------------------------------------------------------
# Clean up after the installs
RUN DEBIAN_FRONTEND=noninteractive apt clean -y --no-install-recommends \
  && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*


# ----------------------------------------------------------------------
# Set up locales
RUN locale-gen en_US.UTF-8 \
  && update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LC_ALL en_US.UTF-8


# ----------------------------------------------------------------------
# Yocto requires the source command for setting up the build environment, so
# Replace dash with bash (Ubuntu uses dash as /bin/sh for system shells)
# https://wiki.ubuntu.com/DashAsBinSh
# Note that using && below to chain commands is essential to avoid failure
RUN rm /bin/sh && ln -s bash /bin/sh


# ----------------------------------------------------------------------
# Install the google repo utility
RUN curl -o /usr/local/bin/repo https://storage.googleapis.com/git-repo-downloads/repo 
RUN chmod a+x /usr/local/bin/repo


# ----------------------------------------------------------------------
# Create user called build (because we can not run Yocto Project as root)
# Change uid and gid, to match my account on my workstation
# Username is not all that important
ENV UID=1000
ENV GID=1000
ENV USER=build
RUN groupadd -g $GID $USER && \
useradd -u $UID -g $GID -ms /bin/bash $USER && \
usermod -a -G sudo $USER && \
usermod -a -G users $USER 


# ----------------------------------------------------------------------
# Change username and work directory
USER $USER
WORKDIR /home/$USER


# ----------------------------------------------------------------------
# Create the docker directory
# RUN mkdir /home/$USER/docker


# ----------------------------------------------------------------------
# Configure git
RUN git config --global user.name "Flint Weller"
RUN git config --global user.email "flint.weller@hackster.io"
RUN git config --global color.ui true
RUN git config --list

# ----------------------------------------------------------------------
# End

Credits

Flint Weller
24 projects • 21 followers
NXP Dedicated Applications Processor FAE

Comments