STM32MP157基于Yocto构建Qt镜像和SDK工具链
作者:zzssdd2
E-mail:zzssdd2@foxmail.com
記錄下整個過程以及在該過程中遇到的問題和解決方法。
一、獲取軟件倉庫
$ mkdir -p openstlinux-5.4-dunfell-mp1-21-12-22 $ cd openstlinux-5.4-dunfell-mp1-21-12-22 $ repo init -u https://github.com/STMicroelectronics/oe-manifest.git -b refs/tags/openstlinux-5.4-dunfell-mp1-21-12-22執(zhí)行第3條命令時報錯如下:
$ repo init -u https://github.com/STMicroelectronics/oe-manifest.git -b refs/tags/openstlinux-5.4-dunfell-mp1-21-12-22 Command 'repo' not found, but can be installed with:sudo snap install git-repo按照提示安裝git-repo后重新執(zhí)行命令,報錯如下:
$ repo init -u https://github.com/STMicroelectronics/oe-manifest.git -b refs/tags/openstlinux-5.4-dunfell-mp1-21-12-22 warning: gpg (GnuPG) is not available. warning: Installing it is strongly encouraged. warning: templates not found /build/git-repo-publish/parts/git/install/usr/share/git-core/templates ......File "/home/admin/samba/stm32mp157/STM32MP15-Ecosystem-v2.1.0/Distribution-Package/openstlinux-5.4-dunfell-mp1-21-12-22/.repo/repo/main.py", line 79file=sys.stderr)^ SyntaxError: invalid syntax按照如下步驟解決上述錯誤:
$ sudo apt-get install gpg $ rm -rf ~/.repoconfig $ mkdir -p ~/bin $ curl https://storage.googleapis.com/git-repo-downloads/repo-1 > ~/bin/repo $ chmod a+x ~/bin/repo然后執(zhí)行如下命令獲取倉庫:
$ python3 ~/bin/repo init -u https://github.com/STMicroelectronics/oe-manifest.git -b refs/tags/openstlinux-5.4-dunfell-mp1-21-12-22如果出現(xiàn)如下警告,按照提示執(zhí)行命令即可:
... A new version of repo (2.21) is available. ... You should upgrade soon:cp /home/admin/samba/stm32mp157/STM32MP15-Ecosystem-v2.1.0/Distribution-Package/openstlinux-5.4-dunfell-mp1-21-12-22/.repo/repo/repo /home/admin/bin/repo如果執(zhí)行命令出現(xiàn)如下錯誤提示:
Downloading Repo source from https://gerrit.googlesource.com/git-repo fatal: Cannot get https://gerrit.googlesource.com/git-repo/clone.bundle fatal: error [Errno 110] Connection timed out fatal: double check your --repo-rev setting. fatal: cloning the git-repo repository failed, will remove '.repo/repo'執(zhí)行如下命令使用國內(nèi)鏡像源:
$ export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'然后再重新執(zhí)行命令。成功執(zhí)行命令的話提示如下:
$ python3 ~/bin/repo init -u https://github.com/STMicroelectronics/oe-manifest.git -b refs/tags/openstlinux-5.4-dunfell-mp1-21-12-22Downloading Repo source from https://mirrors.tuna.tsinghua.edu.cn/git/git-repo remote: Enumerating objects: 7259, done. remote: Counting objects: 100% (7259/7259), done. remote: Compressing objects: 100% (3847/3847), done. remote: Total 7259 (delta 4683), reused 5526 (delta 3338) 接收對象中: 100% (7259/7259), 3.21 MiB | 3.41 MiB/s, 完成. 處理 delta 中: 100% (4683/4683), 完成. Downloading manifest from https://github.com/STMicroelectronics/oe-manifest.git remote: Enumerating objects: 61, done. remote: Counting objects: 100% (27/27), done. remote: Compressing objects: 100% (18/18), done. remote: Total 61 (delta 15), reused 20 (delta 9), pack-reused 34 展開對象中: 100% (61/61), 9.76 KiB | 713.00 KiB/s, 完成.Your identity is: zzssdd2 <zzssdd2@foxmail.com> If you want to change this, please re-run 'repo init' with --config-namerepo has been initialized in /home/admin/samba/stm32mp157/STM32MP15-Ecosystem-v2.1.0/Distribution-Package/openstlinux-5.4-dunfell-mp1-21-12-22接著執(zhí)行同步倉庫的命令:
$ python3 ~/bin/repo sync Fetching: 100% (9/9), done in 3m27.864s Garbage collecting: 100% (9/9), done in 0.040s repo sync has finished successfully.執(zhí)行完上面命令后倉庫就同步完成了,如果在同步過程中由于下載出錯等原因?qū)е轮袛?#xff0c;重新執(zhí)行同步命令即可。同步完成后目錄結(jié)構如下所示:
openstlinux-5.4-dunfell-mp1-21-12-22 ├── .repo │ ├── copy-link-files.json │ ├── manifests │ ├── manifests.git │ ├── manifest.xml │ ├── project.list │ ├── project-objects │ ├── projects │ └── repo └── layers├── meta-openembedded├── meta-qt5├── meta-st├── meta-timesys└── openembedded-core接下來進行構建環(huán)境的初始化。
二、初始化構建環(huán)境
我選擇的鏡像是QT image and SDK with weston/wayland,因此執(zhí)行如下命令來初始化構建環(huán)境:
$ DISTRO=openstlinux-weston MACHINE=stm32mp1 source layers/meta-st/scripts/envsetup.sh由于我的主機缺少相關軟件包提示如下:
[HOST DISTRIB check] Linux Distrib: Ubuntu Linux Release: 20.04Required packages for Linux Distrib: build-essential chrpath cpio debianutils diffstat gawk gcc-multilib git iputils-ping libegl1-mesa libsdl1.2-dev libssl-dev pylint python3 python3-git python3-jinja2 python3-pexpect python3-pip socat texinfo unzip wget xterm xz-utilsMissing required packages detected: chrpath diffstat gawk gcc-multilib libegl1-mesa libsdl1.2-dev pylint python3-git python3-jinja2 python3-pip socat texinfo xtermTo update your Linux Distribution packages, two proposals:1) run again envsetup.sh script with '--pkg-update' optionOR2) before running envsetup.sh script, launch first in your Linux console: sudo apt-get update sudo apt-get install chrpath diffstat gawk gcc-multilib libegl1-mesa libsdl1.2-dev pylint python3-git python3-jinja2 python3-pip socat texinfo xtermCheck aborted: exiting now...根據(jù)提示執(zhí)行如下命令:
$ sudo apt-get update $ sudo apt-get install chrpath diffstat gawk gcc-multilib libegl1-mesa libsdl1.2-dev pylint python3-git python3-jinja2 python3-pip socat texinfo xterm然后在我的主機上會出現(xiàn)如下錯誤:
下列軟件包有未滿足的依賴關系:libsdl1.2-dev : 依賴: libglu1-mesa-dev 但是它將不會被安裝 或libglu-dev依賴: libx11-dev 但是它將不會被安裝依賴: libxext-dev 但是它將不會被安裝 E: 無法修正錯誤,因為您要求某些軟件包保持現(xiàn)狀,就是它們破壞了軟件包間的依賴關系。解決錯誤過程如下:
$ sudo apt install aptitude $ sudo aptitude install libsdl1.2-dev ......libx11-dev : 依賴: libx11-6 (= 2:1.6.9-2ubuntu1.2) 但是 2:1.6.9-2ubuntu1.3 已安裝 下列動作將解決這些依賴關系:保持 下列軟件包于其當前版本: 1) libegl-dev [未安裝的] 2) libgl-dev [未安裝的] 3) libgl1-mesa-dev [未安裝的] 4) libgles-dev [未安裝的] 5) libglu1-mesa-dev [未安裝的] 6) libglvnd-dev [未安裝的] 7) libglx-dev [未安裝的] 8) libsdl1.2-dev [未安裝的] 9) libx11-dev [未安裝的] 10) libxext-dev [未安裝的] 是否接受該解決方案?[Y/n/q/?] n 下列動作將解決這些依賴關系:降級 下列軟件包: 1) libx11-6 [2:1.6.9-2ubuntu1.3 (now) -> 2:1.6.9-2ubuntu1.2 (focal-security,是否接受該解決方案?[Y/n/q/?] Y ......解決該錯誤后重新執(zhí)行安裝所缺少軟件包的那條命令即可。安裝完成后再次執(zhí)行初始化構建環(huán)境的命令,如下:
$ DISTRO=openstlinux-weston MACHINE=stm32mp1 source layers/meta-st/scripts/envsetup.sh[HOST DISTRIB check] Linux Distrib: Ubuntu Linux Release: 20.04Required packages for Linux Distrib: build-essential chrpath cpio debianutils diffstat gawk gcc-multilib git iputils-ping libegl1-mesa libsdl1.2-dev libssl-dev pylint python3 python3-git python3-jinja2 python3-pexpect python3-pip socat texinfo unzip wget xterm xz-utilsCheck OK: all required packages are installed on host.[source layers/openembedded-core/oe-init-build-env][from nothing][EULA configuration][Configure *.conf files] [INFO] No 'site.conf.sample' file available at /home/admin/samba/stm32mp157/STM32MP15-Ecosystem-v2.1.0/Distribution-Package/openstlinux-5.4-dunfell-mp1-21-12-22/layers/meta-st/scripts. Create default one...=========================================================================== Configuration files have been created for the following configuration:DISTRO : openstlinux-westonDISTRO_CODENAME : dunfellMACHINE : stm32mp1BB_NUMBER_THREADS : <no-custom-config-set>PARALLEL_MAKE : <no-custom-config-set>BUILDDIR : build-openstlinuxweston-stm32mp1DOWNLOAD_DIR : <disable>SSTATE_DIR : <disable>SOURCE_MIRROR_URL : <no-custom-config-set>SSTATE_MIRRORS : <disable>WITH_EULA_ACCEPTED: YES===========================================================================Available images for OpenSTLinux layers are:- Official OpenSTLinux images:st-image-weston - OpenSTLinux weston image with basic Wayland support (if enable in distro)- Other OpenSTLinux images:- Supported images:st-image-core - OpenSTLinux core imageYou can now run 'bitbake <image>'-
The OpenEmbedded environment setup script must be run once in each new working terminal in which you use the BitBake or devtool tools
-
The BSP for STM32MP1 depends on packages and firmwares which are covered by a software license agreement (SLA). You will be asked to read and to accept this EULA.
至此,構建環(huán)境初始化完成,接下來開始構建鏡像和SDK。
三、構建鏡像和SDK
溫馨提示:在執(zhí)行下面的構建命令前建議查看下磁盤容量以確保有足夠的磁盤空間,否則在構建過程中因磁盤空間不足也會導致失敗,如果磁盤空間不夠需要先進行擴容再來進行構建工作。
鏡像和SDK構建完成后的磁盤占用情況如下:
$ du -h -d 1 134M ./layers 330M ./.repo 70G ./build-openstlinuxweston-stm32mp1執(zhí)行如下命令開始構建鏡像:
$ bitbake st-example-image-qtwayland然后就是耐心等待構建完成。如果在該過程中由于下載出錯等原因?qū)е轮袛?#xff0c;重新執(zhí)行構建命令即可。
################################### 2000 years later… ################################################
構建成功后如下所示:
NOTE: Started PRServer with DBfile: /home/admin/samba/stm32mp157/STM32MP15-Ecosystem-v2.1.0/Distribution-Package/openstlinux-5.4-dunfell-mp1-21-12-22/build-openstlinuxweston-stm32mp1/cache/prserv.sqlite3, IP: 127.0.0.1, PORT: 42375, PID: 502452 Loading cache: 100% |#############################################################################| Time: 0:00:02 Loaded 3751 entries from dependency cache. NOTE: Resolving any missing task queue dependenciesBuild Configuration: BB_VERSION = "1.46.0" BUILD_SYS = "x86_64-linux" NATIVELSBSTRING = "universal" TARGET_SYS = "arm-ostl-linux-gnueabi" MACHINE = "stm32mp1" DISTRO = "openstlinux-weston" DISTRO_VERSION = "3.1.11-snapshot-20220507" TUNE_FEATURES = "arm vfp cortexa7 neon vfpv4 thumb callconvention-hard" TARGET_FPU = "hard" DISTRO_CODENAME = "dunfell" ACCEPT_EULA_stm32mp1 = "1" GCCVERSION = "9.%" PREFERRED_PROVIDER_virtual/kernel = "linux-stm32mp" meta-python meta-oe meta-gnome meta-initramfs meta-multimedia meta-networking meta-webserver meta-filesystems meta-perl = "HEAD:2e7e98cd0cb82db214b13224c71134b9335a719b" meta-st-stm32mp = "HEAD:bd643ba8654010628fbcf093666fe3d184a9df34" meta-qt5 = "HEAD:b4d24d70aca75791902df5cd59a4f4a54aa4a125" meta-st-openstlinux = "HEAD:2dc988821b19d2eb75cfad4d543b674cdadd77bb" meta = "HEAD:c7d2281eb6cda9c1637c20b3540b142073bca235"Initialising tasks: 100% |########################################################################| Time: 0:00:28 Sstate summary: Wanted 432 Found 432 Missed 0 Current 2996 (100% match, 100% complete) NOTE: Executing Tasks NOTE: Tasks Summary: Attempted 9391 tasks of which 9373 didn't need to be rerun and all succeeded. NOTE: Writing buildhistory NOTE: Writing buildhistory took: 2 seconds接下來構建SDK,執(zhí)行如下命令:
$ bitbake st-example-image-qtwayland -c populate_sdk如果在該過程中因為出錯導致中斷,重新執(zhí)行構建命令即可。構建完成后如下所示:
NOTE: Started PRServer with DBfile: /home/admin/samba/stm32mp157/STM32MP15-Ecosystem-v2.1.0/Distribution-Package/openstlinux-5.4-dunfell-mp1-21-12-22/build-openstlinuxweston-stm32mp1/cache/prserv.sqlite3, IP: 127.0.0.1, PORT: 46791, PID: 1730318 Loading cache: 100% |#############################################################################| Time: 0:02:32 Loaded 3751 entries from dependency cache. NOTE: Resolving any missing task queue dependenciesBuild Configuration: BB_VERSION = "1.46.0" BUILD_SYS = "x86_64-linux" NATIVELSBSTRING = "universal" TARGET_SYS = "arm-ostl-linux-gnueabi" MACHINE = "stm32mp1" DISTRO = "openstlinux-weston" DISTRO_VERSION = "3.1.11-snapshot-20220507" TUNE_FEATURES = "arm vfp cortexa7 neon vfpv4 thumb callconvention-hard" TARGET_FPU = "hard" DISTRO_CODENAME = "dunfell" ACCEPT_EULA_stm32mp1 = "1" GCCVERSION = "9.%" PREFERRED_PROVIDER_virtual/kernel = "linux-stm32mp" meta-python meta-oe meta-gnome meta-initramfs meta-multimedia meta-networking meta-webserver meta-filesystems meta-perl = "HEAD:2e7e98cd0cb82db214b13224c71134b9335a719b" meta-st-stm32mp = "HEAD:bd643ba8654010628fbcf093666fe3d184a9df34" meta-qt5 = "HEAD:b4d24d70aca75791902df5cd59a4f4a54aa4a125" meta-st-openstlinux = "HEAD:2dc988821b19d2eb75cfad4d543b674cdadd77bb" meta = "HEAD:c7d2281eb6cda9c1637c20b3540b142073bca235"Initialising tasks: 100% |########################################################################| Time: 0:00:21 Sstate summary: Wanted 405 Found 405 Missed 0 Current 2363 (100% match, 100% complete) NOTE: Executing Tasks NOTE: Tasks Summary: Attempted 7689 tasks of which 7689 didn't need to be rerun and all succeeded. NOTE: Writing buildhistory NOTE: Writing buildhistory took: 2 seconds鏡像和SDK構建完成后分別存放在目錄openstlinux-5.4-dunfell-mp1-21-12-22/build-openstlinuxweston-stm32mp1/tmp-glibc/deploy下的images和sdk目錄下。
補充: OpenSTLinux提供了兩種基于QT的鏡像和SDK,這兩種鏡像和SDK的構建命令如下:
-
QT image and SDK with EGLFS
# Initialize the OpenEmbedded build environment for the openstlinux-eglfs distro: $ DISTRO=openstlinux-eglfs MACHINE=stm32mp1 source layers/meta-st/scripts/envsetup.sh # Build the image and the SDK: $ bitbake st-example-image-qt $ bitbake st-example-image-qt -c populate_sdk -
QT image and SDK with weston/wayland
# Initialize the OpenEmbedded build environment for the openstlinux-weston distro: $ DISTRO=openstlinux-weston MACHINE=stm32mp1 source layers/meta-st/scripts/envsetup.sh # Build the image and the SDK: $ bitbake st-example-image-qtwayland $ bitbake st-example-image-qtwayland -c populate_sdk
四、適配開發(fā)板
前面已經(jīng)編譯完成鏡像和SDK,已經(jīng)確保整個過程是沒有問題的。接下來就可以修改tf-a、u-boot和linux適配自己的開發(fā)板了,這些工作均在編譯目錄openstlinux-5.4-dunfell-mp1-21-12-22/build-openstlinuxweston-stm32mp1進行。
4.1 修改TF-A
執(zhí)行如下命令查找TF-A recipe:
$ devtool search tf-a*結(jié)果如下:
NOTE: Starting bitbake server... NOTE: Reconnecting to bitbake server... NOTE: Retrying server connection (#1)... NOTE: Started PRServer with DBfile: /home/admin/samba/stm32mp157/Distribution-Package/openstlinux-5.4-dunfell-mp1-21-12-22/build-openstlinuxweston-stm32mp1/cache/prserv.sqlite3, IP: 127.0.0.1, PORT: 34083, PID: 252954 Loading cache: 100% |#############################################################################| Time: 0:00:01 Loaded 3751 entries from dependency cache. ...... tf-a-stm32mp Trusted Firmware-A for STM32MP1 ...... tf-a-stm32mp-serialboot Trusted Firmware-A for STM32MP1 as serial boot loader ...... tf-a-stm32mp-ssp Trusted Firmware-A SSP for STM32MP1 ......如果出現(xiàn)如下錯誤:
ERROR: Unable to start bitbake server (None) ERROR: Server log for this session ...... ERROR: The following layer directories do not exist ...... ERROR: Please check BBLAYERS in ......解決方法:
$ source ../layers/openembedded-core/oe-init-build-env然后根據(jù)查找到的recipe名稱執(zhí)行如下命令:
$ devtool modify tf-a-stm32mp命令執(zhí)行完成后會生成workspace目錄,然后進入目錄workspace/sources/tf-a-stm32mp對tf-a源碼進行修改,參考STM32MP157系統(tǒng)移植(TF-A,U-Boot,Linux)文章的TF-A移植部分。
這里需要注意的是,如果是要創(chuàng)建自己的開發(fā)板設備樹文件則需要修改配置文件,否則無法編譯出對應的固件。例如我需要添加自己的開發(fā)板stm32mp157d-custom,需要做如下修改:
修改openstlinux-5.4-dunfell-mp1-21-12-22/layers/meta-st/meta-st-stm32mp/conf/machine/stm32mp1.conf文件如下內(nèi)容,在其中添加自己的開發(fā)板:
# ========================================================================= # Machine settings # ========================================================================= # Define list of devicetree per board STM32MP_DT_FILES_DK += "stm32mp157a-dk1 stm32mp157d-dk1" STM32MP_DT_FILES_DK += "stm32mp157c-dk2 stm32mp157f-dk2" STM32MP_DT_FILES_ED += "stm32mp157c-ed1 stm32mp157f-ed1" STM32MP_DT_FILES_EV += "stm32mp157a-ev1 stm32mp157c-ev1 stm32mp157d-ev1 stm32mp157f-ev1 stm32mp157d-custom"當然直接修改源碼中現(xiàn)有的設備樹文件是最方便的,就無需再去修改配置文件了。例如我手中的開發(fā)板是參考stm32mp157d-ev1設計,那就直接修改源碼中stm32mp157d-ev1.dts及其相關文件就行了(個人更推薦這種做法,維持非自己創(chuàng)建的layer完整性)。
修改完成后執(zhí)行如下命令進行編譯:
$ devtool build tf-a-stm32mp編譯成功后在目錄workspace/sources/tf-a-stm32mp/oe-workdir/deploy-tf-a-stm32mp下就是編譯出的固件。然后執(zhí)行如下命令部署:
$ bitbake tf-a-stm32mp -c deploy部署后在/openstlinux-5.4-dunfell-mp1-21-12-22/build-openstlinuxweston-stm32mp1/tmp-glibc/deploy/images/stm32mp1/arm-trusted-firmware目錄下可以看到更新固件。
接下來對tf-a-stm32mp-serialboot進行修改,和上面步驟一樣:
$ devtool modify tf-a-stm32mp-serialboot $ devtool build tf-a-stm32mp-serialboot $ bitbake tf-a-stm32mp-serialboot -c deploy4.2 修改U-Boot
執(zhí)行如下命令查找U-boot recipe:
$ devtool search u-boot*結(jié)果如下:
NOTE: Starting bitbake server... NOTE: Reconnecting to bitbake server... NOTE: Retrying server connection (#1)... NOTE: Started PRServer with DBfile: /home/admin/samba/stm32mp157/Distribution-Package/openstlinux-5.4-dunfell-mp1-21-12-22/build-openstlinuxweston-stm32mp1/cache/prserv.sqlite3, IP: 127.0.0.1, PORT: 36991, PID: 371338 Loading cache: 100% |#############################################################################| Time: 0:00:01 Loaded 3749 entries from dependency cache. Parsing recipes: 100% |###########################################################################| Time: 0:00:01 Parsing of 2546 .bb files complete (2544 cached, 2 parsed). 3751 targets, 107 skipped, 0 masked, 0 errors. u-boot-stm32mp-extlinux Provide 'extlinux.conf' file for U-Boot u-boot-stm32mp Universal Boot Loader for embedded devices for stm32mp u-boot-stm32mp-splash Universal Boot Loader Splash Screen for stm32mp embedded devices u-boot-fw-config-stm32mp U-Boot bootloader fw_printenv/setenv utilities ......然后根據(jù)查找到的recipe名稱執(zhí)行如下命令:
$ devtool modify u-boot-stm32mp命令執(zhí)行完成后進入目錄workspace/sources/u-boot-stm32mp對u-boot源碼進行修改,參考STM32MP157系統(tǒng)移植(TF-A,U-Boot,Linux)文章的U-BOOT移植部分。
注意:《STM32MP157系統(tǒng)移植(TF-A,U-Boot,Linux)》文章的u-boot代碼和本文并非完全一樣,本文修改ðernet0節(jié)點不同之處如下所示:
ðernet0 {......pinctrl-1 = <ðernet0_rgmii_pins_sleep_a>;...... };修改完成后執(zhí)行如下命令進行編譯:
$ devtool build u-boot-stm32mp如果編譯報錯就看下輸出日志里面有沒如下提示文本:
/home/admin/samba/stm32mp157/Distribution-Package/openstlinux-5.4-dunfell-mp1-21-12-22/build-openstlinuxweston-stm32mp1/workspace/sources/u-boot-stm32mp is not clean, please run 'make mrproper' in the '/home/admin/samba/stm32mp157/Distribution-Package/openstlinux-5.4-dunfell-mp1-21-12-22/build-openstlinuxweston-stm32mp1/workspace/sources/u-boot-stm32mp' directory.若有就按提示進入u-boot-stm32mp目錄下執(zhí)行 make mrproper命令:
$ make mrproper CLEAN u-boot.cfg.tmp CLEAN scripts/basic CLEAN scripts/kconfig CLEAN include/config include/generated然后回到build-openstlinuxweston-stm32mp1目錄重新執(zhí)行編譯指令。
同樣,若重新構建image過程中遇到uboot報錯在openstlinux-5.4-dunfell-mp1-21-12-22/build-openstlinuxweston-stm32mp1/tmp-glibc/work-shared/stm32mp1/uboot-source目錄執(zhí)行make mrproper命令然后回到build-openstlinuxweston-stm32mp1目錄重新執(zhí)行構建指令
編譯成功后在目錄workspace/sources/u-boot-stm32mp/oe-workdir/deploy-u-boot-stm32mp下就是編譯出的固件。然后執(zhí)行如下命令部署:
$ bitbake u-boot-stm32mp -c deploy部署后在/openstlinux-5.4-dunfell-mp1-21-12-22/build-openstlinuxweston-stm32mp1/tmp-glibc/deploy/images/stm32mp1/bootloader目錄下可以看到更新固件。
4.3 修改Linux
首先執(zhí)行如下命令進行初始化:
$ devtool modify virtual/kernel提示如下所示:
NOTE: Starting bitbake server... NOTE: Reconnecting to bitbake server... NOTE: Retrying server connection (#1)... NOTE: Started PRServer with DBfile: /home/admin/samba/stm32mp157/Distribution-Package/openstlinux-5.4-dunfell-mp1-21-12-22/build-openstlinuxweston-stm32mp1/cache/prserv.sqlite3, IP: 127.0.0.1, PORT: 33507, PID: 1054423 Loading cache: 100% |############################################| Time: 0:00:01 Loaded 3748 entries from dependency cache. Parsing recipes: 100% |##########################################| Time: 0:00:01 Parsing of 2546 .bb files complete (2543 cached, 3 parsed). 3751 targets, 107 skipped, 0 masked, 0 errors. INFO: Mapping virtual/kernel to linux-stm32mp NOTE: Resolving any missing task queue dependenciesBuild Configuration: BB_VERSION = "1.46.0" BUILD_SYS = "x86_64-linux" NATIVELSBSTRING = "universal" TARGET_SYS = "arm-ostl-linux-gnueabi" MACHINE = "stm32mp1" DISTRO = "openstlinux-weston" DISTRO_VERSION = "3.1.11-snapshot-20220512" TUNE_FEATURES = "arm vfp cortexa7 neon vfpv4 thumb callconvention-hard" TARGET_FPU = "hard" DISTRO_CODENAME = "dunfell" ACCEPT_EULA_stm32mp1 = "1" GCCVERSION = "9.%" PREFERRED_PROVIDER_virtual/kernel = "linux-stm32mp" meta-python meta-oe meta-gnome meta-initramfs meta-multimedia meta-networking meta-webserver meta-filesystems meta-perl = "HEAD:2e7e98cd0cb82db214b13224c71134b9335a719b" meta-st-stm32mp = "HEAD:bd643ba8654010628fbcf093666fe3d184a9df34" meta-qt5 = "HEAD:b4d24d70aca75791902df5cd59a4f4a54aa4a125" meta-st-openstlinux = "HEAD:2dc988821b19d2eb75cfad4d543b674cdadd77bb" meta = "HEAD:c7d2281eb6cda9c1637c20b3540b142073bca235" workspace = "<unknown>:<unknown>"Initialising tasks: 100% |#######################################| Time: 0:00:05 Sstate summary: Wanted 0 Found 0 Missed 0 Current 22 (0% match, 100% complete) NOTE: Executing Tasks NOTE: Tasks Summary: Attempted 102 tasks of which 99 didn't need to be rerun and all succeeded. NOTE: Writing buildhistory NOTE: Writing buildhistory took: 2 seconds INFO: Adding local source files to srctree... INFO: Source tree extracted to /home/admin/samba/stm32mp157/Distribution-Package/openstlinux-5.4-dunfell-mp1-21-12-22/build-openstlinuxweston-stm32mp1/workspace/sources/linux-stm32mp INFO: Recipe linux-stm32mp now set up to build from /home/admin/samba/stm32mp157/Distribution-Package/openstlinux-5.4-dunfell-mp1-21-12-22/build-openstlinuxweston-stm32mp1/workspace/sources/linux-stm32mp命令執(zhí)行完成后進入目錄workspace/sources/linux-stm32mp對linux源碼進行修改,參考STM32MP157系統(tǒng)移植(TF-A,U-Boot,Linux)文章的LINUX移植部分。
如果需要執(zhí)行menuconfig對內(nèi)核配置進行更改則執(zhí)行如下命令:
$ bitbake virtual/kernel -c menuconfig修改完成后執(zhí)行如下命令進行編譯:
# devtool build linux-stm32mp # bitbake linux-stm32mp -c deploy $ bitbake virtual/kernel -C compile編譯完成后在/openstlinux-5.4-dunfell-mp1-21-12-22/build-openstlinuxweston-stm32mp1/tmp-glibc/deploy/images/stm32mp1/kernel目錄下可以看到新的固件。
上面命令會執(zhí)行configure、compile、package、deploy等一系列命令,比較耗時間,如果只是想單純編譯可以執(zhí)行如下命令:
$ bitbake virtual/kernel -c compile編譯后固件在openstlinux-5.4-dunfell-mp1-21-12-22/build-openstlinuxweston-stm32mp1/workspace/sources/linux-stm32mp/oe-workdir/build目錄。
最后,將這些固件更新到開發(fā)板后就可以搭配編譯出來的帶Qt的文件系統(tǒng)進行驗證3D-GPU等功能了。
五、補充
5.1 關于SDMMC3
The SDMMC instances are ordered by address in the device tree arch/arm/boot/dts/stm32mp151.dtsi file:
sdmmc3: sdmmc@48004000 { ... sdmmc1: sdmmc@58005000 { ... sdmmc2: sdmmc@58007000 {By default, in OpenSTLinux distribution, sdmmc3 is disabled so the sdmmc1 (SD card on Evaluation boards and Discovery kits) and sdmmc2 (eMMC on Evaluation boards and Wifi on Discovery kits) are respectively aliased to mmc0 and mmc1.
If you enable sdmmc3, it will take the mmc0 alias and the aliases above will shift, so don’t forget to update the Linux kernel boot command accordingly!
For instance, ‘root=/dev/mmcblk0p6’ will become ‘root=/dev/mmcblk1p6’ to mount the rootfs from the sdmmc1 (SD card) when sdmmc3 is enabled.
STM32MP157擁有三個SDMMC接口,在芯片中的內(nèi)存映射地址如下:
| SDMMC1 | 0x58005000 - 0x58005FFF | 4 KB |
| SDMMC2 | 0x58007000 - 0x58007FFF | 4 KB |
| SDMMC3 | 0x48004000 - 0x480043FF | 1 KB |
根據(jù)地址分配可知它們的初始化順序是SDMMC3 --> SDMMC1 --> SDMMC2。
三個接口都啟用后在Linux中對應的操作文件如下:
| /dev/mmcblk1 | /dev/mmcblk2 | /dev/mmcblk0 |
我手上的開發(fā)板對這3個接口分配如下:
| SD卡 | EMMC | WIFI |
在Linux設備樹中啟用sdmmc3接口前后sd卡和emmc設備號的變化如下:
| SD卡 | mmc0 | mmc1 |
| EMMC | mmc1 | mmc2 |
st提供的yocto源碼中沒有使用sdmmc3,所以啟用了sdmmc3接口后需要修改一些配置文件,系統(tǒng)啟動后才能正常掛載文件系統(tǒng)。需要修改如下幾個文件:
mount-partitions.sh
OpenSTLinux源碼中的位置:openstlinux-5.4-dunfell-mp1-21-12-22/layers/meta-st/meta-st-openstlinux/recipes-core/systemd/systemd-mount-partitions/mount-partitions.sh
燒錄后在文件系統(tǒng)中的位置:/sbin/mount-partitions.sh
修改后內(nèi)容如下,主要增加了mmcblk2的內(nèi)容:
#!/bin/sh - #=============================================================================== # # FILE: mount-partitions.sh # # USAGE: ./mount-partitions.sh [start|stop] # # DESCRIPTION: mount partitions# ORGANIZATION: STMicroelectronics # COPYRIGHT: Copyright (C) 2018, STMicroelectronics - All Rights Reserved # CREATED: 01/09/2018 13:36 # REVISION: --- #===============================================================================MOUNT_PARTITIONS_LIST=""get_type() {local __resultvar=$1ROOT_TYPE="unknown"if [ -f /usr/bin/findmnt ];thenROOT_DEVICE=$(findmnt --noheadings --output=SOURCE / | cut -d'[' -f1)case $ROOT_DEVICE inubi*)ROOT_TYPE="nand";;/dev/mmcblk0*)ROOT_TYPE="sdmmc";;/dev/mmcblk1*)ROOT_TYPE="mmc";;/dev/mmcblk2*)ROOT_TYPE="mmc";;/dev/disk/by-*)LINK=$(/usr/bin/readlink $ROOT_DEVICE | tr '/' ' ' | tr '.' ' ' | sed "s/ //g")case $LINK inubi*)ROOT_TYPE="nand";;mmcblk0*)ROOT_TYPE="sdmmc";;mmcblk1*)ROOT_TYPE="mmc";;mmcblk2*)ROOT_TYPE="mmc";;esac;;esacelseif [ `cat /proc/cmdline | sed "s/.*mmcblk0.*/mmcblk0/" ` == "mmcblk0" ]; thenROOT_TYPE="sdmmc"elif [ `cat /proc/cmdline | sed "s/.*mmcblk1.*/mmcblk1/" ` == "mmcblk1" ]; thenROOT_TYPE="mmc"elif [ `cat /proc/cmdline | sed "s/.*mmcblk2.*/mmcblk2/" ` == "mmcblk2" ]; thenROOT_TYPE="mmc"elif [ `cat /proc/cmdline | sed "s/.*ubi0.*/ubi0/" ` == "ubi0" ]; thenROOT_TYPE="nand"fifieval $__resultvar="'$ROOT_TYPE'" }found_devices() {local __resultvar=$1local __resultopt=$2local _type=$3local _search=$4local _device="unknown"local _option=" "case $_type innand)local ubi_volumes=$(ls -1 -d /sys/class/ubi/ubi0_*)for f in $ubi_volumes;doif [ -r $f/name ];thencat $f/name | grep -sq "^${_search}"if [ "$?" -eq 0 ];then_device="/dev/$(basename $f)"_option="-t ubifs"break;fifidone;;sdmmc)local sdmmc_parts=$(ls -1 -d /sys/block/mmcblk0/mmcblk0p*)for f in $sdmmc_parts;doif [ -r $f/uevent ];thencat $f/uevent | grep PARTNAME | sed "s/PARTNAME=//" | grep -sq "^${_search}"if [ "$?" -eq 0 ];then_device="/dev/$(basename $f)"break;fifidone;;mmc)local mmc_parts=$(ls -1 -d /sys/block/mmcblk1/mmcblk1p*)if [ ! $mmc_parts]; thenmmc_parts=$(ls -1 -d /sys/block/mmcblk2/mmcblk2p*)fifor f in $mmc_parts;doif [ -r $f/uevent ];thencat $f/uevent | grep PARTNAME | sed "s/PARTNAME=//" | grep -sq "^${_search}"if [ "$?" -eq 0 ];then_device="/dev/$(basename $f)"break;fifidone;;esaceval $__resultvar="'$_device'"eval $__resultopt="'$_option'" }case "$1" instart)# mount partitionsecho "mount-partitions start!"get_type TYPEecho "TYPE of support detected: $TYPE"for part in $MOUNT_PARTITIONS_LISTdopart_label=$(echo $part | cut -d',' -f1)mountpoint=$(echo $part | cut -d',' -f2)found_devices DEVICE DEVICE_OPTION $TYPE $part_labelecho "$part_label device: $DEVICE"[ -d $mountpoint ] || mkdir -p $mountpoint[ -e $DEVICE ] && mount $DEVICE_OPTION $DEVICE $mountpointdone;;stop)# umount partitionsecho "mount-partitions stop!"for part in $MOUNT_PARTITIONS_LISTdomountpoint=$(echo $part | cut -d',' -f2)umount $mountpointdone;;*)echo "Usage: $0 [start|stop]";; esacuserfs-cleanup-package.sh
OpenSTLinux源碼中的位置:openstlinux-5.4-dunfell-mp1-21-12-22/layers/meta-st/meta-st-openstlinux/recipes-support/userfs/userfs-cleanup-package/userfs-cleanup-package.sh
燒錄后在文件系統(tǒng)中的位置:/sbin/userfs-cleanup-package.sh
修改后內(nèi)容如下,主要增加了mmcblk2的內(nèi)容:
#! /bin/sh ### BEGIN INIT INFO # remove package which are present on the database but not present on userfs ### END INIT INFODESC="cleanup apt database"get_type() {local __resultvar=$1ROOT_TYPE="unknown"if [ -f /usr/bin/findmnt ];thenROOT_DEVICE=$(findmnt --noheadings --output=SOURCE / | cut -d'[' -f1)case $ROOT_DEVICE inubi*)ROOT_TYPE="nand";;/dev/mmcblk0*)ROOT_TYPE="sdmmc";;/dev/mmcblk1*)ROOT_TYPE="mmc";;/dev/mmcblk2*)ROOT_TYPE="mmc";;/dev/disk/by-*)LINK=$(/usr/bin/readlink $ROOT_DEVICE | tr '/' ' ' | tr '.' ' ' | sed "s/ //g")case $LINK inubi*)ROOT_TYPE="nand";;mmcblk0*)ROOT_TYPE="sdmmc";;mmcblk1*)ROOT_TYPE="mmc";;mmcblk2*)ROOT_TYPE="mmc";;esac;;esacelseif [ `cat /proc/cmdline | sed "s/.*mmcblk0.*/mmcblk0/" ` == "mmcblk0" ]; thenROOT_TYPE="sdmmc"elif [ `cat /proc/cmdline | sed "s/.*mmcblk1.*/mmcblk1/" ` == "mmcblk1" ]; thenROOT_TYPE="mmc"elif [ `cat /proc/cmdline | sed "s/.*mmcblk2.*/mmcblk2/" ` == "mmcblk2" ]; thenROOT_TYPE="mmc"elif [ `cat /proc/cmdline | sed "s/.*ubi0.*/ubi0/" ` == "ubi0" ]; thenROOT_TYPE="nand"elif [ `cat /proc/cmdline | sed "s/.*nfsroot.*/nfs/" ` == "nfs" ]; thenROOT_TYPE="nfs"fifieval $__resultvar="'$ROOT_TYPE'" }found_devices() {local __resultvar=$1local __resultopt=$2local _type=$3local _search=$4local _device="unknown"local _option=" "case $_type innand)local ubi_volumes=$(ls -1 -d /sys/class/ubi/ubi0_*)for f in $ubi_volumes;doif [ -r $f/name ];thencat $f/name | grep -sq "^${_search}"if [ "$?" -eq 0 ];then_device="/dev/$(basename $f)"_option="-t ubifs"break;fifidone;;sdmmc)local sdmmc_parts=$(ls -1 -d /sys/block/mmcblk0/mmcblk0p*)for f in $sdmmc_parts;doif [ -r $f/uevent ];thencat $f/uevent | grep PARTNAME | sed "s/PARTNAME=//" | grep -sq "^${_search}"if [ "$?" -eq 0 ];then_device="/dev/$(basename $f)"break;fifidone;;mmc)local mmc_parts=$(ls -1 -d /sys/block/mmcblk1/mmcblk1p*)if [ ! $mmc_parts]; thenmmc_parts=$(ls -1 -d /sys/block/mmcblk2/mmcblk2p*)fifor f in $mmc_parts;doif [ -r $f/uevent ];thencat $f/uevent | grep PARTNAME | sed "s/PARTNAME=//" | grep -sq "^${_search}"if [ "$?" -eq 0 ];then_device="/dev/$(basename $f)"break;fifidone;;nfs)$_device="/dev/nfs";;esaceval $__resultvar="'$_device'"eval $__resultopt="'$_option'" }case $1 instart)echo "Starting $DESC"get_type TYPEfound_devices DEVICE DEVICE_OPTION $TYPE userfsif [ "$DEVICE" = "/dev/null" ];then# nfs file system, do nothingexit 0ficase $DEVICE inunknown)# userfs partition are not present# we need to cleanup apt databasegrep -l "^/usr/local/" /var/lib/dpkg/info/* | sed -e "s|/var/lib/dpkg/info/\(.*\).list|\1|" | xargs apt-get purge -yecho "USERFS NOT PRESENT: CLEAN DPKG DATABASE" > /dev/kmsg;;/dev/nfs)# nfs file system, do nothingexit 0;;/dev/*)# userfs are present, do nothing;;esac;;*)echo "Usage: @sysconfdir@/init.d/userfs-cleanup-package.sh {start}" >&2exit 1;; esacexit 0# vim:noetinit-resize.sh
OpenSTLinux源碼中的位置:openstlinux-5.4-dunfell-mp1-21-12-22/layers/meta-st/meta-st-openstlinux/recipes-st/initrd/files/init-resize.sh
燒錄后在文件系統(tǒng)中的位置:/boot/uInitrd/init.d/95-resize
修改后內(nèi)容如下,主要增加了mmcblk2的內(nèi)容:
#!/bin/shPATH=/sbin:/bin:/usr/sbin:/usr/binresize_enabled() {return 0 }resize_run() {ln -s /proc/mounts /etc/mtabif [ -n "$ROOTFS_DIR" ]; thenif [ ! -e $ROOTFS_DIR/etc/.resized ]then# sdmmc0/1/2for j in 0 1 2;dofor i in 4 5 6 7 8 9 10;doDEVICE="/dev/mmcblk"$j"p"$iif [ -e $DEVICE ]; thenlabel=$(/sbin/e2label $DEVICE 2> /dev/null)if [ $? -eq 0 ]; thencase $label inuser*)echo "RESIZE USERFS [$DEVICE]"/sbin/e2fsck -f -y -c -C 0 $DEVICE && /sbin/resize2fs $DEVICE;;root*)echo "RESIZE ROOTFS [$DEVICE]"/sbin/resize2fs $DEVICE;;vendor*)echo "RESIZE VENDORFS [$DEVICE]"/sbin/e2fsck -f -y -c -C 0 $DEVICE && /sbin/resize2fs $DEVICE;;boot*)echo "RESIZE BOOTFS [$DEVICE]"/sbin/e2fsck -f -y -c -C 0 $DEVICE && /sbin/resize2fs $DEVICE;;*);;esacfifidonedonetouch $ROOTFS_DIR/etc/.resizedfifi }5.2 關于bootfs
st-image-bootfs-openstlinux-weston-stm32mp1.ext4鏡像內(nèi)容如下:
. ├── boot.scr.uimg ├── lost+found [error opening dir] ├── mmc0_extlinux │ └── stm32mp157d-custom_extlinux.conf ├── mmc1_extlinux │ └── stm32mp157d-custom_extlinux.conf ├── splash.bmp ├── stm32mp157d-custom.dtb ├── uImage └── uInitrdstm32mp157d-custom_extlinux.conf文件內(nèi)容如下:
$ cat mmc0_extlinux/stm32mp157d-custom_extlinux.conf # Generic Distro Configuration file generated by OpenEmbedded menu title Select the boot mode MENU BACKGROUND /splash.bmp TIMEOUT 20 DEFAULT stm32mp157d-custom LABEL stm32mp157d-customKERNEL /uImageFDT /stm32mp157d-custom.dtbINITRD /uInitrdAPPEND root=PARTUUID=e91c4e10-16e6-4c0e-bd0e-77becf4a3582 rootwait rw console=ttySTM0,115200$ cat mmc1_extlinux/stm32mp157d-custom_extlinux.conf # Generic Distro Configuration file generated by OpenEmbedded menu title Select the boot mode MENU BACKGROUND /splash.bmp TIMEOUT 20 DEFAULT stm32mp157d-custom LABEL stm32mp157d-customKERNEL /uImageFDT /stm32mp157d-custom.dtbINITRD /uInitrdAPPEND root=PARTUUID=491f6117-415d-4f53-88c9-6e0de54deac6 rootwait rw console=ttySTM0,115200總結(jié)
以上是生活随笔為你收集整理的STM32MP157基于Yocto构建Qt镜像和SDK工具链的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 开发微领地小秘系统的公司
- 下一篇: 阿里云 SLB证书记录