# 【Doc】Yocto BSP - Custom
###### tags: `OS`,`BSP`
---
:::warning
解壓縮方式
$ unzstd **image**.wic.zst
$ zstd -d **image**.wic.zst
$ bunzip2 -dk -f **image** .wic.bz2
遠端傳輸檔案
$ scp -P 10001 -r weilly@10.20.7.3:/**image** .
遠端連線
$ ssh -p 10001 weilly@10.20.7.3
:::
:::info
SDK 編譯
$ bitbake -c populate_sdk imx-image-full
:::
---
<br>
||MachineName|
|---|---|
|i.MX8M Plus| imx8mpevk |
|i.MX8MQ| imx8mqevk |
|i.MX93| imx93evk |
|OP-Kiler|op-kiler|
</br>
**Environment**
|BSP Version|YOCTO name||
|---|---|---|
|L4.14.78|sumo|$ repo init -u https://github.com/nxp-imx/imx-manifest -b imx-linux-sumo -m imx-4.14.78-1.1.0.xml|
|L5.4.3 |zeus|$ repo init -u https://github.com/nxp-imx/imx-manifest -b imx-linux-zeus -m imx-5.4.24-2.1.0.xml|
|L5.4.24 |zeus|$ repo init -u https://github.com/nxp-imx/imx-manifest -b imx-linux-zeus -m imx-5.4.3-1.0.0.xml|
|L5.4.47 |zeus|$ repo init -u https://github.com/nxp-imx/imx-manifest -b imx-linux-zeus -m imx-5.4.47-2.2.0.xml|
|L5.4.70 |zeus|$ repo init -u https://github.com/nxp-imx/imx-manifest -b imx-linux-zeus -m imx-5.4.70-2.3.2.xml|
|L5.10.9|gatesgarth|$ repo init -u https://github.com/nxp-imx/imx-manifest -b imx-linux-gatesgarth -m imx-5.10.9-1.0.0.xml|
|L5.10.35|hardknott|$ repo init -u https://github.com/nxp-imx/imx-manifest -b imx-linux-hardknott -m imx-5.10.35-2.0.0.xml|
|L5.10.52|hardknott|$ repo init -u https://github.com/nxp-imx/imx-manifest -b imx-linux-hardknott -m imx-5.10.52-2.1.0.xml|
|L5.10.72|hardknott|$ repo init -u https://github.com/nxp-imx/imx-manifest -b imx-linux-hardknott -m imx-5.10.72-2.2.3.xml|
|L5.15.5|honister|$ repo init -u https://github.com/nxp-imx/imx-manifest -b imx-linux-honister -m imx-5.15.5-1.0.0.xml|
|L5.15.32|kirkstone|$ repo init -u https://github.com/nxp-imx/imx-manifest -b imx-linux-kirkstone -m imx-5.15.32-2.0.0.xml|
|L5.15.52|kirkstone|$ repo init -u https://github.com/nxp-imx/imx-manifest -b imx-linux-kirkstone -m imx-5.15.32-2.0.0.xml|
|L5.15.52|kirkstone|$ repo init -u https://github.com/nxp-imx/imx-manifest -b imx-linux-kirkstone -m imx-5.15.52-2.1.0.xml|
|L5.15.71|kirkstone|$ repo init -u https://github.com/nxp-imx/imx-manifest -b imx-linux-kirkstone -m imx-5.15.71-2.2.0.xml|
|6.1.1|langdale|$repo init -u https://github.com/nxp-imx/imx-manifest -b imx-linux-langdale -m imx-6.1.1-1.0.0.xml|
|6.1.22|mickledore|$repo init -u https://github.com/nxp-imx/imx-manifest -b imx-linux-mickledore -m imx-6.1.22-2.0.0.xml|
|6.1.36|mickledore|$repo init -u https://github.com/nxp-imx/imx-manifest -b imx-linux-mickledore -m imx-6.1.36-2.1.0.xml|
|6.1.55|mickledore|$repo init -u https://github.com/nxp-imx/imx-manifest -b imx-linux-mickledore -m imx-6.1.55-2.2.0.xml|
|6.6.3|nanbield|$repo init -u https://github.com/nxp-imx/imx-manifest -b imx-linux-nanbield -m imx-6.6.23-2.0.0.xml|
|6.6.23|scarthgap|$repo init -u https://github.com/nxp-imx/imx-manifest -b imx-linux-nanbield -m imx-6.6.36-2.1.0.xml|
|6.6.36|scarthgap|$repo init -u https://github.com/nxp-imx/imx-manifest -b imx-linux-nanbield -m imx-6.6.36-2.1.0.xml|
|6.6.52|scarthgap|$repo init -u https://github.com/nxp-imx/imx-manifest -b imx-linux-scarthgap -m imx-6.6.52-2.2.0.xml|
|6.12.3|styhead|$repo init -u https://github.com/nxp-imx/imx-manifest -b imx-linux-styhead -m imx-6.12.3-1.0.0.xml|
<br>
**Platform**
||TYPE|
|---|---|
|i.MX95|EULA=1 MACHINE=imx95-19x19-lpddr5-evk DISTRO=fsl-imx-xwayland source ./imx-setup-release.sh -b buildxwayland|
|i.MX93|EULA=1 MACHINE=imx93evk DISTRO=fsl-imx-xwayland source ./imx-setup-release.sh -b buildxwayland|
|i.MX8MP|EULA=1 MACHINE=imx8mpevk DISTRO=fsl-imx-xwayland source ./imx-setup-release.sh -b buildxwayland|
|OP-Killer| EULA=1 MACHINE=opkiler DISTRO=fsl-imx-xwayland source ./imx-setup-release.sh -b buildxwayland|
<br>
**Image**
|Version|TYPE|Image|
|---|---|---|
|L4.14.78|LINUX|bitbake fsl-image-qt5|
|L5.4.70|LINUX|bitbake imx-image-full|
|L5.10.72|LINUX|bitbake imx-image-full|
|L6.6.52|LINUX|bitbake imx-image-full|
|L5.15.32|Ubuntu|bitbake imx-image-desktop|
</br>
---
<br>
* **如何編譯公版 EVK 的 IMAGE**
* **LINUX**
* Download folder
```
$ repo init -u https://github.com/nxp-imx/imx-manifest -b imx-linux-sumo -m imx-4.14.78-1.1.0.xml
$ repo sync
```
* Build image
```
$ EULA=1 MACHINE=imx8mpevk DISTRO=fsl-imx-xwayland source ./imx-setup-release.sh -b buildxwayland
$ bitbake imx-image-ful
```
* **Ubuntu**
* Environment
```c
$ repo init -u https://github.com/nxp-imx/imx-manifest -b imx-linux-kirkstone -m imx-5.15.32-2.0.0_desktop.xml
$ repo sync
```
* Compile
```c
$ EULA=1 DISTRO=imx-desktop-xwayland MACHINE=imx8mpevk source imx-setup-desktop.sh -b buildxwayland
$ bitbake imx-image-desktop
```
</br>
</br>
</br>
---
### **如何編譯 OP-KILLER 的 IMAGE**
---
* OP-Killer
* **LINUX**
* Build MACHINE
```
$ cp /bsp/fsl-yocto-bsp-5.4.70/sources/meta-imx/meta-bsp/conf/machine/imx8mpevk.conf /bsp/fsl-yocto-bsp-5.4.70/sources/meta-imx/meta-bsp/conf/machine/op-kiler.conf
```
* Environment
```
$ EULA=1 MACHINE=opkiler DISTRO=fsl-imx-xwayland source ./imx-setup-release.sh -b buildxwayland
```
* Modify local.conf
```
MACHINE ??= 'op-kiler'
```
* Compile
```
$ bitbake imx-image-full
```
* Apply patch
* device tree
```
$ vi fsl-yocto-bsp-5.4.70/buildxwayland/tmp/work-shared/op-kiler/kernel-source/arch/arm64/boot/dts/freescale/imx8mp-evk.dts
5000 -> 20000
$ source-pdos = <PDO_FIXED(20000, 3000, PDO_FIXED_USB_COMM)>;
$ sink-pdos = <PDO_FIXED(20000, 3000, PDO_FIXED_USB_COMM)
```
* uboot
```
$ vi /bsp/fsl-yocto-bsp-5.4.70/buildxwayland/tmp/work/op_kiler-poky-linux/u-boot-imx/2022.04-r0/git/board/freescale/imx8mp_evk/imx8mp_evk.c
$ find "struct tcpc_port_config port1_config"
$ //.disable_pd = true
```
* re-Compile
```
$ bitbake -f -c compile u-boot-imx && bitbake -f -c deploy u-boot-imx
$ bitbake -f -c compile imx-boot && bitbake -f -c deploy imx-boot
$ bitbake -f -c compile linux-imx && bitbake -f -c deploy linux-imx
$ bitbake imx-image-full
```
* **Ubuntu**
* Build MACHINE
```c
$ cp /bsp/fsl-yocto-bsp-5.15.32-desktop/sources/meta-nxp-desktop/conf/machine/imx8mpevkdesktop.conf /bsp/fsl-yocto-bsp-5.15.32-desktop/sources/meta-nxp-desktop/conf/machine/op-killer-desktop.conf
```
* Environment
```c
$ EULA=1 DISTRO=imx-desktop-xwayland MACHINE=op-killer-desktop
$ source imx-setup-desktop.sh -b buildxwayland
```
* Modify local.conf
```c
MACHINE ??= 'op-killer-desktop'
```
* compile
```c
$ bitbake imx-image-desktop
$ bitbake -f -c compile u-boot-imx && bitbake -f -c deploy u-boot-imx
$ bitbake -f -c compile imx-boot && bitbake -f -c deploy imx-boot
$ bitbake -f -c compile linux-imx && bitbake -f -c deploy linux-imx
```
* Apply patch
* device tree
```
$ vi fsl-yocto-bsp-5.15.52/buildxwayland/tmp/work-shared/op-kiler/kernel-source/arch/arm64/boot/dts/freescale/imx8mp-evk.dts
5000 -> 20000
$ source-pdos = <PDO_FIXED(20000, 3000, PDO_FIXED_USB_COMM)>;
$ sink-pdos = <PDO_FIXED(20000, 3000, PDO_FIXED_USB_COMM)
```
* uboot
```
$ vi /bsp/fsl-yocto-bsp-5.15.52/buildxwayland/tmp/work/op_kiler-poky-linux/u-boot-imx/2022.04-r0/git/board/freescale/imx8mp_evk/imx8mp_evk.c
$ find "struct tcpc_port_config port1_config"
$ //.disable_pd = true
```
* re-Compile
```
$ bitbake -f -c compile u-boot-imx && bitbake -f -c deploy u-boot-imx
$ bitbake -f -c compile imx-boot && bitbake -f -c deploy imx-boot
$ bitbake -f -c compile linux-imx && bitbake -f -c deploy linux-imx
$ bitbake imx-image-desktop
```
</br>
</br>
</br>
---
### 疑難雜症
---
#### gcc 版本過低
Q : g++: error: unrecognized command line option ‘-std=gnu++20’; did you mean ‘-std=gnu++2a’?
A :
* 安裝 GCC 10
```
$ sudo add-apt-repository ppa:ubuntu-toolchain-r/test
$ sudo apt update
$ sudo apt install gcc-10 g++-10
```
* 建立替換機制
```
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 20
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 20
```
* 確認 gcc 版本
```
gcc --version
```
</br>
</br>
</br>
---
### 特別版版本
---
#### **i.MX8M Plus-Kivy**
* Base on BSP-L5.15.52
* Build MACHINE
```
$ cp /bsp/fsl-yocto-bsp-5.15.52/sources/meta-imx/meta-bsp/conf/machine/imx8mpevk.conf /bsp/fsl-yocto-bsp-5.15.52/sources/meta-imx/meta-bsp/conf/machine/imx8mpevk-kivy.conf
```
* Environment
```
$ EULA=1 MACHINE=imx8mpevk-kivy DISTRO=fsl-imx-xwayland
$ source ./imx-setup-release.sh -b buildxwayland
```
* Modify local.conf
```
MACHINE ??= 'imx8mpevk-kivy'
IMAGE_INSTALL:append = "python3-kivy packagegroup-core-buildessential opengl-es-cts libsdl2"
EXTRA_IMAGE_FEATURES:append = " dev-pkgs"
REQUIRED_DISTRO_FEATURES:remove = "x11"
```
* Compile
```
$ bitbake imx-image-full
```
</br>
</br>
#### **i.MX8M Plus-Kivy-ffmpeg**
* Base on BSP-L5.15.52
* Build MACHINE
```
$ cp /bsp/fsl-yocto-bsp-5.15.52/sources/meta-imx/meta-bsp/conf/machine/imx8mpevk.conf /bsp/fsl-yocto-bsp-5.15.52/sources/meta-imx/meta-bsp/conf/machine/imx8mpevk-kivy.conf
```
* Environment
```
$ EULA=1 MACHINE=imx8mpevk-kivy DISTRO=fsl-imx-xwayland
$ source ./imx-setup-release.sh -b buildxwayland
```
* Modify local.conf
```
MACHINE ??= 'imx8mpevk-kivy'
IMAGE_INSTALL:append = "python3-kivy packagegroup-core-buildessential opengl-es-cts libsdl2"
EXTRA_IMAGE_FEATURES:append = " dev-pkgs"
REQUIRED_DISTRO_FEATURES:remove = "x11"
GLIBC_GENERATE_LOCALES = "en_GB en_US en_GB.UTF-8 en_US.UTF-8"
LICENSE_FLAGS_ACCEPTED = "commercial"
IMAGE_INSTALL:append = "ffmpeg"
```
* Compile
```
$ bitbake imx-image-full
```
</br>
</br>
#### **i.MX8M Plus-Hailo**
* Base on BSP-L5.15.52
* Download Layer
```
$ cd <Yocto folder>/sources
$ git clone https://github.com/hailo-ai/meta-hailo
$ cd meta-hailo/
$ git checkout kirkstone
```
* Build MACHINE
```
$ cp /bsp/fsl-yocto-bsp-5.15.52/sources/meta-imx/meta-bsp/conf/machine/imx8mpevk.conf /bsp/fsl-yocto-bsp-5.15.52/sources/meta-imx/meta-bsp/conf/machine/imx8mpevk-hailo.conf
```
* Environment
```
$ EULA=1 MACHINE=imx8mpevk-hailo DISTRO=fsl-imx-xwayland
$ source ./imx-setup-release.sh -b buildxwayland
```
* Modify local.conf
```
MACHINE ??= 'imx8mpevk-hailo'
IMAGE_INSTALL:append = "libhailort hailortcli pyhailort libgsthailo hailo-pci hailo-firmware tappas-apps hailo-post-processes libgsthailotools "
```
* Modify bblayers.conf
```
BBLAYERS += "${BSPDIR}/sources/meta-hailo/meta-hailo-accelerator"
BBLAYERS += "${BSPDIR}/sources/meta-hailo/meta-hailo-libhailort"
BBLAYERS += "${BSPDIR}/sources/meta-hailo/meta-hailo-tappas"
```
* Compile
```
$ bitbake imx-image-full
```
</br>
</br>
#### **Asus PE100A-Hailo (i.MX8MQ)**
* Base on BSP-L5.15.52
* Environment
```c
$ repo init -u https://github.com/ASUS-IPC/manifest.git -m asus-pv100a-5.15.52.xml
$ repo sync
```
* Compile
```c
$ cd <folder>
$ ./docker_builder/docker-builder-run.sh
$ EULA=1 DISTRO=fsl-imx-xwayland MACHINE=imx8mq-pe100a
$ source asus-setup-release.sh -b buildxwayland
$ bitbake imx-image-full
```
* Modify local.conf
```
IMAGE_INSTALL:append = "libhailort hailortcli pyhailort libgsthailo hailo-pci hailo-firmware tappas-apps hailo-post-processes libgsthailotools "
```
* Modify bblayers.conf
```
BBLAYERS += "${BSPDIR}/sources/meta-hailo/meta-hailo-accelerator"
BBLAYERS += "${BSPDIR}/sources/meta-hailo/meta-hailo-libhailort"
BBLAYERS += "${BSPDIR}/sources/meta-hailo/meta-hailo-tappas"
```
* Modify devicetree
$ vi <Yocto>/tmp/work-shared/imx8mqevk/kernel-source/arch/arm64/boot/dts/freescale/imx8mq-evk.dts
```python
&pcie1 {
/*Add Here*/
hailo_host {
compatible = "hailo,hm218b1c2lae";
};
/*END*/
};
```
* Compile
```
$ bitbake linux-asus-imx -f -c compile && bitbake linux-asus-imx -f -c deploy
$ bitbake imx-image-full
```
</br>
</br>
#### **i.MX8QXP-chromium**
* BSP-L6.1.22 (mickledore)
* Build MACHINE
```
$ cp /bsp/fsl-yocto-bsp-6.1.22/sources/meta-imx/meta-bsp/conf/machine/imx8qxpc0mek.conf /bsp/fsl-yocto-bsp-6.1.22/sources/meta-imx/meta-bsp/conf/machine/imx8qxpc0mek-chrome.conf
```
* Environment
```
$ EULA=1 MACHINE=imx8qxpc0mek-chrome DISTRO=fsl-imx-xwayland
$ source ./imx-setup-release.sh -b buildxwayland
```
* Modify local.conf
```
MACHINE ??= 'imx8qxpc0mek-chrome'
CORE_IMAGE_EXTRA_INSTALL += "chromium-ozone-wayland"
```
* Compile
```
$ bitbake imx-image-full
```
```
</br>
</br>
#### **OP-Killer-Chrome**
* Base on BSP-L6.1.36
* Build MACHINE
```
$ cp /bsp/fsl-yocto-bsp-6.1.36/sources/meta-imx/meta-bsp/conf/machine/imx8mpevk.conf /bsp/fsl-yocto-bsp-6.1.36/sources/meta-imx/meta-bsp/conf/machine/opkiller-chrome.conf
```
* Environment
```
$ EULA=1 MACHINE=opkiller DISTRO=fsl-imx-xwayland
$ source ./imx-setup-release.sh -b buildxwayland
```
* Modify local.conf
```
MACHINE ??= 'opkiller-chrome'
CORE_IMAGE_EXTRA_INSTALL += "chromium-ozone-wayland python3-flask-pymongo python3-pymongo"
```
* Compile
```
$ bitbake imx-image-full
```
* Apply patch
* device tree
```
$ vi fsl-yocto-bsp-6.1.36/buildxwayland/tmp/work-shared/opkiller/kernel-source/arch/arm64/boot/dts/freescale/imx8mp-evk.dts
5000 -> 20000
$ source-pdos = <PDO_FIXED(20000, 3000, PDO_FIXED_USB_COMM)>;
$ sink-pdos = <PDO_FIXED(20000, 3000, PDO_FIXED_USB_COMM)
```
* uboot
```
$ /bsp/fsl-yocto-bsp-6.1.36/buildxwayland/tmp/work/opkiller-poky-linux/u-boot-imx/2022.04-r0/git/board/freescale/imx8mp_evk/imx8mp_evk.c
$ find "struct tcpc_port_config port1_config"
$ //.disable_pd = true
```
* re-Compile
```
$ bitbake -f -c compile u-boot-imx && bitbake -f -c deploy u-boot-imx
$ bitbake -f -c compile imx-boot && bitbake -f -c deploy imx-boot
$ bitbake -f -c compile linux-imx && bitbake -f -c deploy linux-imx
$ bitbake imx-image-full
```
</br>