###### tags: `TSC` `Nxp` IMX Yocto Usage Record ==== # Pre Setup :::danger 注意事項: 1. 編譯Yocto Project 官方文件提到 Linux Host 機器,硬碟空間至少要 ==120 GB== 2. 使用虛擬機(VM)建構硬碟/linux Host時,建議使用==固定大小==,不要使用動態分配 3. 建議使用 Ubuntu 18.04 or 相同的host linux 版本 ref: ![](https://i.imgur.com/PtaEt9K.png) ::: # install host packages ```bash= sudo apt-get install gawk wget git-core diffstat unzip texinfo 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 ``` # Set up Git ```bash= git config --global user.name "<Your Name>" git config --global user.email "<Your Email>" git config --list ``` # Setting up the repo utility - Create a bin folder in the home directory. ```bash= mkdir ~/bin curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo chmod a+x ~/bin/repo ``` - Add the following line to the .bashrc file to ensure that the ~/bin folder is in your PATH variable. ```bash= export PATH=~/bin:$PATH > ~/.bashrc source ~/.bashrc ``` :::info :spiral_note_pad: Repo is a tool built on top of Git. Repo helps manage many Git repositories, does the uploads to revision control systems, and automates parts of the development workflow. Repo is not meant to replace Git, only to make it easier to work with Git. The repo command is an executable Python script that you can put anywhere in your path. ::: # Use Yocto Project to Build imx-linux ## Download resource (Use repo utility) ```bash= mkdir imx-yocto-bsp cd imx-yocto-bsp repo init -u https://source.codeaurora.org/external/imx/imx-manifest -b imx-linux-hardknott -m imx-5.10.52-2.1.0.xml repo sync ``` ## To create one new build environment :::success Syntax: ```shell DISTRO=<distro name> MACHINE=<machine name> source imx-setup-release.sh -b <build dir> ``` ::: - imx8mp-lpddr4-evk setting ```bash= DISTRO=fsl-imx-xwayland MACHINE=imx8mp-lpddr4-evk source imx-setup-release.sh -b imx8mp_build_xwayland ``` - imx8mmevk setting ```bash= DISTRO=fsl-imx-xwayland MACHINE=imx8mmevk source imx-setup-release.sh -b imx8mmevk_build_xwayland ``` :::info First run you need to read and accept the EULA. ![](https://i.imgur.com/P8vsaOI.png) ### distro name: * fsl-imx-wayland : Wayland weston graphics. * fsl-imx-xwayland : Wayland graphics and X11. X11 applications using EGL are not supported. * fsl-imx-fb : Frame Buffer graphics - no X11 or Wayland. Frame Buffer is not supported on i.MX 8. ### machine name: i.MX 8 * imx8qmmek * imx8qxpc0mek * imx8mqevk * imx8mm-lpddr4-evk * imx8mm-ddr4-evk * imx8mn-lpddr4-evk * imx8mn-ddr4-evk - [x] ==imx8mp-lpddr4-evk== * imx8mp-ddr4-evk * imx8dxl-lpddr4-evk * imx8mnddr3levk * imx8ulp-lpddr4-evk > other config define to xxx.conf in "source/meta-xxx/conf/machine" > example: > imx8mmddr3lval in "/sources/meta-imx/meta-bsp/conf/machine" ::: # To continue an exist build environment > If a new terminal window is opened or the machine is rebooted after a build directory is set up, the setup environment script should be used to set up the environment variables and run a build again. The full imx-setup-release.sh is not needed. ```shell= cd ${BSP_HOME} source setup-environment ${build-dir} ``` # Use bitbake :::success Syntax: ```bitbake <parameter> <component>``` ::: ## Useful commands - help bitbake -h - list all package bitbake -s - list package source code path bitbake -e imx-atf | grep "^S=" - list installed package bitbake -g imx-image-core && cat pn-buildlist | grep -ve "native" | sort | uniq - list package task bitbake imx-atf -f -c listtasks - force run compile task on package bitbake linux-imx -c compile -f - force run deploy task on package bitbake linux-imx -c deploy -f ## Build image ![](https://i.imgur.com/jBpRcPW.png) Perform the following command in terminal console example: use imx-image-core ```shell= bitbake imx-image-core ``` > image file Path : ./tmp/deploy/images/___/ *.wic.bz2 ## Build bootloader bootloader is include: - SECO (Security Controller) - ATF (ARM Trusted FW) - U-BOOT Perform the following command in terminal console to build bootloader image ```shell= bitbake imx-boot ``` > image file Path : ./tmp/deploy/images/___/imx-boot Perform the following command in terminal console to find Source code path ```shell= bitbake -e imx-boot | grep ^S= ``` ![](https://i.imgur.com/8kGZLkW.png) ### Build atf to build u-boot image ```shell= bitbake imx-atf -c compile -f -v ``` Perform the following command in terminal console to find Source code path ```shell= bitbake -e imx-atf | grep "^S=" ``` ### Build U-boot Perform the following command in terminal console to build bootloader image to build u-boot image ```shell= bitbake u-boot-imx -c compile -f -v ``` to deploy u-boot image ```shell= bitbake u-boot-imx -c deploy -f -v ``` > file Path : ./tmp/deploy/images/___/uboot.bin Perform the following command in terminal console to find Source code path ```shell= bitbake -e u-boot-imx | grep ^S= ``` ## Build linux kernel Perform the following command in terminal console to show up menuconfig ```shell= bitbake linux-imx -c menuconfig ``` to build kernel image ```shell= bitbake linux-imx -c compile -f -v ``` to deploy kernel image ```shell= bitbake linux-imx -c deploy -f -v ``` > image file Path : ./tmp/deploy/images/___/Image Perform the following command in terminal console to find Source code path ```shell= bitbake -e linux-imx | grep ^S= ``` ![](https://i.imgur.com/VBlKTDw.png) ## Build optee-os bitbake optee-os -f -c compile -v ## Build toolchain installer Perform the following command in terminal console ```shell= bitbake meta-toolchain ``` or ```shell= bitbake core-image-minimal -c populate_sdk ``` nxp Yocto guide example include env var: ```shell= DISTRO=fsl-imx-xwayland MACHINE=imx8mmevk bitbake core-image-minimal -c populate_sdk ``` The below installer will be located in the directory =="./tmp/deploy/sdk"==. fsl-imx-xwayland-glibc-x86_64-meta-toolchain-aarch64-toolchain.sh ## reference [bitbake 使用指南](/-wkrIZhPTCSy9RsIr9Djow) https://community.nxp.com/t5/i-MX-Processors-Knowledge-Base/Useful-bitbake-commands/ta-p/1128559