documents

Yocto Project 2.7 (Warrior) for TPC71WN21PA


Introduction


Build Image

Prerequisite

$ 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

Step 1. Clone image builder from Github

$ git clone https://github.com/advantechralph/yocto-local.git -b tpc71wn21pa-warrior
$ cd tpc71wn21pa-warrior
$ git checkout meta/tpc71wn21pa-warrior
$ git checkout project/tpc71wn21pa-warrior

Step 2. Prepare Yocto building enviroment

$ make yocto

Step 3. Build QT5 image

$ make imageqt5

Write Image into SD card

Insert the SD card into the build code Ubuntu Host.

$ make writesdcard

Then, follow the prompt to write the image into sdcard.


Build toolchain

$ make toolchain

For the toolchian self-installation script, please refer to the sdk in Path information as below.


Path information

$ make info

# fsl-image-qt5   : qt5 image
# ...
# sdk             : sdk file
# ...

Install SDK toolchain

After use make info, you will get the sdk location. You can execute this script to install toolchain on another Ubuntu host environment.

$ apt-get install xz-utils build-essential python python3 
$ ~/Download/fsl-imx-x11-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-neon-toolchain-4.19-warrior.sh

Follow the prompt, we install toolchian in the default location /opt/fsl-imx-x11/4.19-warrior. For using toolchian, use the command as below to setup compiling environment.

$ . /opt/fsl-imx-x11/4.19-warrior/environment-setup-cortexa9hf-neon-poky-linux-gnueabi

Check the $CC variable.

$ echo $CC
arm-poky-linux-gnueabi-gcc -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 --sysroot=/opt/fsl-imx-x11/4.19-warrior/sysroots/cortexa9hf-neon-poky-linux-gnueabi

Write a hello.c and test to compile it.

#include <stdio.h>
int main(int argc, char *argv[]){
  printf("%s, %d:  hello\n", __FUNCTION__, __LINE__);
  return 0; 
}
$ $CC -Wall -o hello hello.c

Then, upload hello to your tpc71wn21pa and execute it to test, ex: scp.

root@imx6qtpc71wn21pa:~# ./test 
main, 3: hello

References


Advanced


Rules and process control makefiles

$ ls include/
bsp.mk  builddir.mk  build.mk  clean.mk  color.mk  gitserver.mk  image.mk  info.mk  prepare.mk  repo.mk  sdcard.mk  toolchain.mk  usage.mk  yocto.mk

Use Yocto project tools - bitbake, devtool…

After done for “make yocto” or “make imageqt5”, follow the commands as below to setup yocto env.

$ cd build/yocto
$ source setup-environment build.imx6qtpc71wn21pa/
ERROR: do not use the BSP as root. Exiting...

Welcome to Freescale Community BSP

The Yocto Project has extensive documentation about OE including a
reference manual which can be found at:
    http://yoctoproject.org/documentation

(...)

$ bitbake --help

...

$ devtool --help

...


Modify package source workflow

Manual setup yocto env

From source package root directory.

$ cd build/yocto
$ source setup-environment build.imx6qtpc71wn21pa

Then, you will be in build.imx6qtpc71wn21pa.

If you want to edit kernel source,
use devtool and commands as below to put source code into workspace.

$ devtool modify linux-imx

After fetch code done, enter the kernel source workspace.

$ cd workspace/sources/linux-imx

Check git hash with commands as below.

git log --oneline --decorate 
80bfc285af33 (HEAD -> devtool, tag: list, tag: devtool-patched) fix mcu reboot unstable
fde0496926dc enable pci controller
fe8cf7e978cf io reset
00c32ddd4862 mcu reboot
abdd4541e9df fine tune realtek phy
672ecff90190 clock for rgmii
aa3b53191219 update for mcu watchdog
2cafae0f6a57 config and dts for tpc71wn21pa
8507afc3a397 (tag: devtool-base, origin/imx_4.19.35_1.1.0, imx_4.19.35_1.1.0) MLK-23846 ARM64: dts: freescale: fsl-imx8mn-ddr4-evk: correct bd71847 device node

Modify the kernel source and re-build kernel image with bitbake linux-imx command.

Commit the source code by git commit command.

After you commit the code, the devtool branch will move forward.

git log --branches="*devtool*" --oneline --decorate 
84e43b1bc090 (HEAD -> devtool) add dummy file
80bfc285af33 (tag: list, tag: devtool-patched) fix mcu reboot unstable
fde0496926dc enable pci controller
fe8cf7e978cf io reset
00c32ddd4862 mcu reboot
abdd4541e9df fine tune realtek phy
672ecff90190 clock for rgmii
aa3b53191219 update for mcu watchdog
2cafae0f6a57 config and dts for tpc71wn21pa
8507afc3a397 (tag: devtool-base, origin/imx_4.19.35_1.1.0, imx_4.19.35_1.1.0) MLK-23846 ARM64: dts: freescale: fsl-imx8mn-ddr4-evk: correct bd71847 device node

The devtool branch will be ahead of devbtool-patched. Then, you can use devtool update-recipe command to create patches.

Before updating, it is recommended to create a working layer instead to create patches directly to the original meta/recipe.

Create a dummy meta layer.

$ bitbake-layers create-layer -p 15 meta-dummy 

Create patches into this dummy meta.

$ devtool update-recipe -a meta-dummy linux-imx 

Check the files structure of the dummy layer.

tree meta-dummy/
meta-dummy/
├── conf
│   └── layer.conf
├── COPYING.MIT
├── README
├── recipes-example
│   └── example
│       └── example_0.1.bb
└── recipes-kernel
    └── linux
        ├── linux-imx
        │   └── 0001-add-dummy-file.patch
        └── linux-imx_4.19.35.bbappend

The patch 0001-add-dummy-file.patch is created, and you can add this patch into original location of kernel recipe.

$ mv 0001-add-dummy-file.patch ${yocto pacakge rootdir}/build/yocto/sources/meta-advantech/meta-bsp-patch/recipes-kernel/linux/linux-imx

Append patch file into SRC_URI this variable in the linux-imx_4.19.35.bbappend.

${yocto pacakge rootdir}/build/yocto/sources/meta-advantech/meta-bsp-patch/recipes-kernel/linux/linux-imx_4.19.35.bbappend:

ILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"

SRC_URI += "file://0001-config-and-dts.patch \
            file://0002-mcu-watchdog.patch \
            file://0003-fec-clock.patch \
            file://0004-rtl8211f.patch \
            file://0005-mcu-reboot.patch \
            file://0006-io-reset.patch \
            file://0001-enable-pci-controller.patch \
            file://0001-fix-mcu-reboot-unstable.patch \
            file://0001-add-dummy-file.patch \
            "
LOCALVERSION = ""

After update recipe and patches, do not forget to make package leave workspace.

$ devtool reset linux-imx

tags: tpc71wn21pa yocto