本帖最后由 xble 于 2021-8-11 08:59 编辑
- 构建myir镜像
1.1编译环境搭建
尝试过ubuntu20.04,但是编译不通过,现在想想可能是git的设置不对,后面有时间验证一下。
目前可用编译环境,ubuntu18.04,
安装编译yocto必要组件:
- 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
复制代码
1.2源代码下载
参考米尔提供的文档下载即可,百度网盘也好,github也好,各种慢,最终购买百度会员,才算彻底解决下载问题。
1.3编译过程
进入mys-8mmx-yocto目录,执行如下命令,可以从github下载,编译。
- DISTRO=fsl-imx-xwaylandMACHINE=mys-8mmxsourcesources/meta-myir/tools/myir-setup-release.sh-bbuild-xwayland
- bitbakemyir-image-full--runall=fetch
复制代码
也可以先下载downloads压缩包,然后在执行命令:
- bitbakemyir-image-full
- bitbakemyir-image-core
复制代码
1.4TF卡方式运行
烧录可以直接启动的TF卡,要求至少8G,使用DiskGenius工具初始化TF卡;使用Win32DiskImager工具烧录,烧录img:myir-image-core-mys-8mmx-20210810013041.rootfs.sdcard.bz2(例子)。
将开发板拨码开关设置为TF卡启动模式:
1.5运行结果
这是我编译后的一个版本的运行log,注意字符串“42412ab2f9dc ”,她代表kernel的git commit ID,也是yocto编译linux kernel的唯一标志。
- Linux version 5.4.3-2.0.0+g42412ab2f9dc (oe-user@oe-host) (gcc version 9.2.0 (GCC)) #1 SMP PREEMPT Mon Aug 9 09:39:13 UTC 2021
- .....
[ 0.932372] [drm] [drivers/gpu/drm/drm_drv.c 1142] drm_core_init
复制代码
- 编译kernel源代码
2.0编译kernel安装必要组件
- sudo apt-get install git fakeroot build-essential ncurses-dev xz-utils libssl-dev bc flex libelf-dev bison
复制代码
2.1kernel源代码下载
git clone https://github.com/MYiR-Dev/myir-imx-linux.git -b develop
2.2修改kernel编译开关
vim sources/meta-myir/meta-bsp/recipes-kernel/linux/linux-imx_5.4.bb
2.3drm驱动源代码修改
vim drivers/gpu/drm/drm_drv.c
- static int __init drm_core_init(void)
- {
- int ret;
- DRM_INFO("[%s %d] drm_core_initn", __FILE__, __LINE__);
- drm_connector_ida_init();
- DRM_INFO("[%s %d] drm_core_initn", __FILE__, __LINE__);
- idr_init(&drm_minors_idr);
- DRM_INFO("[%s %d] drm_core_initn", __FILE__, __LINE__);
- ret = drm_sysfs_init();
- if (ret < 0) {
- DRM_ERROR("Cannot create DRM class: %dn", ret);
- goto error;
- }
- DRM_INFO("[%s %d] drm_core_initn", __FILE__, __LINE__);
- drm_debugfs_root = debugfs_create_dir("dri", NULL);
- ret = register_chrdev(DRM_MAJOR, "drm", &drm_stub_fops);
- if (ret < 0)
- goto error;
- DRM_INFO("[%s %d] drm_core_initn", __FILE__, __LINE__);
- drm_core_init_complete = true;
- DRM_INFO("[%s %d] drm_core_initn", __FILE__, __LINE__);
- DRM_DEBUG("Initializedn");
- return 0;
- error:
- drm_core_exit();
- return ret;
- }
复制代码
注意每次修改kernel代码后需要git commit提交,git commit ID需要写入上述 linux-imx_5.4.bb文件相应位置。
2.4kernel源代码编译
bitbake -c cleansstate virtual/kernel
bitbake virtual/kernel
2.5kernel源代码运行
查看运行log,与源代码对比一下,看看代码是否成功运行。 - 编译libdrm源代码
3.1修改libdrm编译开关
vim meta-myir/meta-bsp/recipes-graphics/drm/libdrm_2.4.99.imx.bb
- require recipes-graphics/drm/libdrm_2.4.91.imx.bb
- #FILESEXTRAPATHS_prepend := "${BSPDIR}/sources/meta-freescale/recipes-graphics/drm/${BPN}:"
- #LIC_FILES_CHKSUM = "file://xf86drm.c;beginline=9;endline=32;md5=c8a3b961af7667c530816761e949dc71"
- #IMX_LIBDRM_BRANCH = "libdrm-imx-2.4.99"
- #SRC_URI_remove = "file://installtests.patch"
- #SRCREV = "f421c9c8c4b8fe48d9e6ef43910e98569c94a4b2"
复制代码
vim sources/meta-freescale/recipes-graphics/drm/libdrm_2.4.91.imx.bb
- "Direct Rendering Infrastructure" (DRI). DRI is required for many hardware
- accelerated OpenGL drivers."
- HOMEPAGE = "http://dri.freedesktop.org"
- SECTION = "x11/base"
- LICENSE = "MIT"
- LIC_FILES_CHKSUM = "file://xf86drm.c;beginline=9;endline=32;md5=c8a3b961af7667c530816761e949dc71"
- PROVIDES = "drm"
- DEPENDS = "libpthread-stubs libpciaccess"
- IMX_LIBDRM_SRC ?= "git://///home/xble/imx8mm/libdrm-2.4.100;protocol=file"
- IMX_LIBDRM_BRANCH = "libdrm-2.4.100"
- SRC_URI = "${IMX_LIBDRM_SRC};branch=${IMX_LIBDRM_BRANCH}
- "
- SRCREV = "7fc860214f1915807162ae3082449f60826f3cf3"
- S = "${WORKDIR}/git"
- DEFAULT_PREFERENCE = "-1"
- inherit autotools pkgconfig manpages
- EXTRA_OECONF += "--disable-cairo-tests
- --enable-omap-experimental-api
- --enable-etnaviv-experimental-api
- --enable-install-test-programs
- --disable-valgrind
- "
- PACKAGECONFIG[manpages] = "--enable-manpages, --disable-manpages, libxslt-native xmlto-native"
- ALLOW_EMPTY_${PN}-drivers = "1"
- PACKAGES =+ "${PN}-tests ${PN}-drivers ${PN}-radeon ${PN}-nouveau ${PN}-omap
- ${PN}-intel ${PN}-exynos ${PN}-kms ${PN}-freedreno ${PN}-amdgpu
- ${PN}-etnaviv"
- RRECOMMENDS_${PN}-drivers = "${PN}-radeon ${PN}-nouveau ${PN}-omap ${PN}-intel
- ${PN}-exynos ${PN}-freedreno ${PN}-amdgpu
- ${PN}-etnaviv"
- FILES_${PN}-tests = "${bindir}/*"
- FILES_${PN}-radeon = "${libdir}/libdrm_radeon.so.*"
- FILES_${PN}-nouveau = "${libdir}/libdrm_nouveau.so.*"
- FILES_${PN}-omap = "${libdir}/libdrm_omap.so.*"
- FILES_${PN}-intel = "${libdir}/libdrm_intel.so.*"
- FILES_${PN}-exynos = "${libdir}/libdrm_exynos.so.*"
- FILES_${PN}-kms = "${libdir}/libkms*.so.*"
- FILES_${PN}-freedreno = "${libdir}/libdrm_freedreno.so.*"
- FILES_${PN}-amdgpu = "${libdir}/libdrm_amdgpu.so.*"
- FILES_${PN}-etnaviv = "${libdir}/libdrm_etnaviv.so.*"
- PACKAGES_prepend_imxgpu = "${PN}-vivante "
- RRECOMMENDS_${PN}-drivers_append_imxgpu = " ${PN}-vivante"
- FILES_${PN}-vivante = "${libdir}/libdrm_vivante.so.*"
- PACKAGE_ARCH = "${MACHINE_SOCARCH}"
复制代码
3.2源代码修改
libdrm/tests/modetest/modetest.c中2012行添加如下代码,行号与运行log对应,以源代码中的行号为准。修改太多不一一列出。
- fprintf(stderr, "[%s %d] device[0]=%s module[imx-drm]=%sn", __FILE__, __LINE__, device, module);
复制代码
3.3libdrm源代码编译
bitbake -c cleansstate drm;bitbake drm
3.4modetest测试程序运行
将编译好的bin文件等其他文件一起拷贝到tf卡对应位置。如果接入HMDI则可以看到如下类似图形,彩色渐变斜条纹。
也可以直接看到log,如下:
- modetest -M imx-drm -D 0 -s 35@33:1920x1080 -P 31@33:1920x1080 -Ftiles
- plane->format_str=XR24
- [../../../git/tests/modetest/modetest.c 2012] device[0]=0 module[imx-drm]=imx-drm
- [ 52.186489] lt8912 1-0048: failed to get display timings from EDID
- [../../../git/tests/modetest/modetest.c 2065]dev.use_atomic=0
- [../../../git/tests/modetest/modetest.c 2144] [count==1] count=1
- [../../../git/tests/modetest/modetest.c 1482]setting mode 1920x1080-60Hz@XR24 on connectors 35, crtc 33
- failed to set gamma: Function not implemented
- [../../../git/tests/modetest/modetest.c 2148] [plane_count==1] plane_count=1
- testing 1920x1080@XR24 overlay plane 31
- testing 1920x1080@XR24 overlay plane 31
- [../../../git/tests/modetest/modetest.c 2152] [test_cursor==0] test_cursor=0
- [../../../git/tests/modetest/modetest.c 2156] [test_vsync==0] test_vsync=0
- [../../../git/tests/modetest/modetest.c 2160] [drop_master==0] drop_master=0
复制代码
记得git提交和git commit ID修改到编译开关设置中。 - 修改uboot编译
米尔默认uboot源代码有问题,无法启动,需要进行如下修改:
vim sources/meta-myir/meta-bsp/recipes-bsp/u-boot/u-boot-common.inc
- UBOOT_SRC ?= "git:////home/xble/imx8mm/myir-imx-uboot;protocol=file"
- SRCBRANCH = "develop"
- SRC_URI = "${UBOOT_SRC};branch=${SRCBRANCH}
- "
- SRCREV = "8098fd617e45c05773bc7c554ee4169fdec29b1b"
复制代码
- 总结
原来计划这个章节放到drm框架里面,但是后面才慢慢意识到yocto框架的“限制”,当然这种限制其实就是不能熟练使用yocto而已,如果熟悉了应该也比较简单,我这里把这些编译方法单列一章。
0
|
|
|
|