Phytec中国的wiki
support@phytec.cn
热线:0755-61802110-803
新增layer“meta-hello”,执行以下命令
Host
phytec@ubuntu:~$ cd BSP/BSP-Yocto-NXP-i.MX8MP-PD22.1.0/ phytec@ubuntu:~/BSP/BSP-Yocto-NXP-i.MX8MP-PD22.1.0$ source sources/poky/oe-init-build-env phytec@ubuntu:~/BSP/BSP-Yocto-NXP-i.MX8MP-PD22.1.0/build$ bitbake-layers create-layer ~/BSP/BSP-Yocto-NXP-i.MX8MP-PD22.1.0/sources/meta-hello
新建成功后,在 ~/BSP/BSP-Yocto-NXP-i.MX8MP-PD22.1.0/sources/meta-hello中内容如下
. ├── conf │ └── layer.conf ├── COPYING.MIT ├── README └── recipes-example └── example └── example_0.1.bb 3 directories, 4 files
修改recipe,加入hello-mod内容
Host
phytec@ubuntu:~/BSP/BSP-Yocto-NXP-i.MX8MP-PD22.1.0/sources/meta-hello$ rm -rf recipes-example/ phytec@ubuntu:~/BSP/BSP-Yocto-NXP-i.MX8MP-PD22.1.0/sources/meta-hello$ mkdir recipes-hello phytec@ubuntu:~/BSP/BSP-Yocto-NXP-i.MX8MP-PD22.1.0/sources/meta-hello$ cd recipes-hello phytec@ubuntu:~/BSP/BSP-Yocto-NXP-i.MX8MP-PD22.1.0/sources/meta-hello/recipes-hello$ cp -fvR ~/BSP/BSP-Yocto-NXP-i.MX8MP-PD22.1.0/sources/poky/meta-skeleton/recipes-kernel/hello-mod .
hello-mod内容如下
. └── hello-mod ├── files │ ├── COPYING │ ├── hello.c │ └── Makefile └── hello-mod_0.1.bb 2 directories, 4 files
修改hello-mod_0.1.bb中md5值
hello-mod_0.1.bb
SUMMARY = "Example of how to build an external Linux kernel module" DESCRIPTION = "${SUMMARY}" LICENSE = "GPL-2.0-only" LIC_FILES_CHKSUM = "file://COPYING;md5=3c9619114e53c55367ac534556c93943" inherit module SRC_URI = "file://Makefile \ file://hello.c \ file://COPYING \ " S = "${WORKDIR}" # The inherit of module.bbclass will automatically name module packages with # "kernel-module-" prefix as required by the oe-core build environment. RPROVIDES_${PN} += "kernel-module-hello"
在bblayer.conf中加入新建layer:meta-hello
Host
phytec@ubuntu:~/BSP/BSP-Yocto-NXP-i.MX8MP-PD22.1.0/build$ vim conf/bblayers.conf
bblayer.conf
# POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf # changes incompatibly POKY_BBLAYERS_CONF_VERSION = "2" BBPATH = "${TOPDIR}" BBFILES ?= "" OEROOT := "${@os.path.abspath(os.path.dirname(d.getVar('FILE', True)) + '/../../sources/poky')}" # add BSPDIR variable, as it is needed by recipes of NXP BSPDIR := "${OEROOT}/../.." # In our BSPs active layers are defined by the manifest.xml for all BSPs. The # bblayers.conf gets created by the init_bblayers.py script. BBLAYERS ?= "" BBLAYERS += "\ ${OEROOT}/../poky/meta \ ${OEROOT}/../poky/meta-poky \ ${OEROOT}/../meta-openembedded/meta-oe \ ${OEROOT}/../meta-openembedded/meta-networking \ ${OEROOT}/../meta-openembedded/meta-python \ ${OEROOT}/../meta-openembedded/meta-multimedia \ ${OEROOT}/../meta-openembedded/meta-filesystems \ ${OEROOT}/../meta-openembedded/meta-perl \ ${OEROOT}/../meta-openembedded/meta-gnome \ ${OEROOT}/../meta-imx/meta-bsp \ ${OEROOT}/../meta-imx/meta-sdk \ ${OEROOT}/../meta-imx/meta-ml \ ${OEROOT}/../meta-browser/meta-chromium \ ${OEROOT}/../meta-clang \ ${OEROOT}/../meta-freescale \ ${OEROOT}/../meta-freescale-3rdparty \ ${OEROOT}/../meta-freescale-distro \ ${OEROOT}/../meta-nxp-demo-experience \ ${OEROOT}/../meta-python2 \ ${OEROOT}/../meta-qt5 \ ${OEROOT}/../meta-virtualization \ ${OEROOT}/../meta-rauc \ ${OEROOT}/../meta-phytec \ ${OEROOT}/../meta-ampliphy \ ${OEROOT}/../meta-security \ ${OEROOT}/../meta-security/meta-tpm \ ${OEROOT}/../meta-hello \
在local.conf中添加recipe
Host
phytec@ubuntu:~/BSP/BSP-Yocto-NXP-i.MX8MP-PD22.1.0/build$ vim conf/local.conf
local.conf
#把这一行加在文件末尾 IMAGE_INSTALL_append = " hello-mod"
编译hello-mod
Host
phytec@ubuntu:~/BSP/BSP-Yocto-NXP-i.MX8MP-PD22.1.0/build$ bitbake phytec-qt5demo-image
编译结果
Host
pphytec@ubuntu:~/BSP/BSP-Yocto-NXP-i.MX8MP-PD22.1.0/build/deploy/images/phyboard-pollux-imx8mp-2$ ls | grep sdcard phytec-qt5demo-image-phyboard-pollux-imx8mp-2-20230314035419.rootfs.sdcard phytec-qt5demo-image-phyboard-pollux-imx8mp-2.sdcard
烧写SDCARD镜像后上电
Target
root@phyboard-pollux-imx8mp-2:~# modprobe hello [ 82.822420] hello: loading out-of-tree module taints kernel. [ 82.829151] Hello World! root@phyboard-pollux-imx8mp-2:~# lsmod Module Size Used by hello 16384 0 crct10dif_ce 20480 1 flexcan 32768 0 fuse 131072 1
hello.ko路径如下
Target
root@phyboard-pollux-imx8mp-2:extra# pwd /lib/modules/5.10.72-bsp-yocto-nxp-i.mx8mp-pd22.1.0/extra root@phyboard-pollux-imx8mp-2:extra# ls cryptodev.ko hello.ko
Overview
Content Tools
Activity
Tasks