简体   繁体   English

从 Yocto build 手动构建内核源代码

[英]Manually building a Kernel source from Yocto build

I have a Yocto build for i.mx6 and I want to modify its Kernel.我有一个用于 i.mx6 的 Yocto 构建,我想修改它的内核。 I figured that if I copy Kernel source outside the Yocto project and make my modifications without dealing with patches, I can speed things up significantly.我想如果我在 Yocto 项目之外复制内核源代码并在不处理补丁的情况下进行修改,我可以显着加快速度。 But the thing is, the Kernel source I have to use is already patched and I want to fetch and continue working from there.但问题是,我必须使用的内核源代码已经打好补丁,我想从那里获取并继续工作。 I will work on the already-patched source files and re-arranging them is a painful process.我将处理已经打过补丁的源文件,重新排列它们是一个痛苦的过程。

For starting point, my patches work fine, and I can get a working image using bitbake fsl-image-multimedia-full command.首先,我的补丁工作正常,我可以使用bitbake fsl-image-multimedia-full命令获取工作图像。 The Kernel source I want to use is created after this process.我要使用的内核源代码是在此过程之后创建的。

I have tried copying the source under ..../tmp/work-shared/imx6qsabresd/kernel-source .我试过在..../tmp/work-shared/imx6qsabresd/kernel-source下复制源..../tmp/work-shared/imx6qsabresd/kernel-source Although make zImage and make modules finished without any trouble, manual building was not successful with an error in a dtsi file (Unable to parse...).尽管make zImagemake modules顺利完成,但手动构建没有成功,dtsi 文件中出现错误(无法解析...)。 Of course, I have checked the file and there was no syntax error.当然,我已经检查过文件,没有语法错误。

Also, I checked the kernel source files I copied and it seems that the patches are successfully implemented.另外,我检查了我复制的内核源文件,似乎补丁已成功实施。

Am I doing something wrong with the patches?我的补丁有问题吗? With my manual build routine, I can build unpatched kernel source with no errors.使用我的手动构建例程,我可以构建未打补丁的内核源代码而不会出错。 I am sure that there are experienced Yocto users here that have their own workarounds to make this process shorter.我相信这里有经验丰富的 Yocto 用户,他们有自己的解决方法来缩短这个过程。 So, any help is appreciated.因此,任何帮助表示赞赏。 Thanks in advance.提前致谢。

My favorite method of doing kernel development in a Yocto project is to create an SDK and build the kernel outside of the Yocto system.我最喜欢在 Yocto 项目中进行内核开发的方法是创建一个 SDK 并在 Yocto 系统之外构建内核。 This allows more rapid builds because make will only build new changes, whereas a kernel build within Yocto always starts from scratch.这允许更快的构建,因为make只会构建新的更改,而 Yocto 中的内核构建总是从头开始。

Here are some of my notes on compiling the Linux kernel outside of the Yocto system.以下是我在 Yocto 系统之外编译 Linux 内核的一些笔记。 The exact paths for this will depend on your exact configuration and software versions.此操作的确切路径将取决于您的确切配置和软件版本。 In your case, IMAGE_NAME=fsl-image-multimedia-full在你的情况下, IMAGE_NAME=fsl-image-multimedia-full

  1. Run bitbake -c populate_sdk ${IMAGE_NAME} .运行bitbake -c populate_sdk ${IMAGE_NAME} You will get a self-extracting and self-installing shell script.您将获得一个自解压和自安装的 shell 脚本。

  2. Run the shell script (for me it was tmp/deploy/sdk/${NAME}-glibc-i686-${IMAGE_NAME}-cortexa9hf-neon-toolchain-1.0.0.sh ), and agree to the default SDK location (for me it was usr/local/oecore-i686 ).运行 shell 脚本(对我来说是tmp/deploy/sdk/${NAME}-glibc-i686-${IMAGE_NAME}-cortexa9hf-neon-toolchain-1.0.0.sh ),并同意默认的 SDK 位置(对我来说是usr/local/oecore-i686 )。

  3. Source the scripts generated by the install script.源安装脚本生成的脚本。 I use the following helper script to load the SDK so I don't have to keep track of the paths involved.我使用以下帮助程序脚本来加载 SDK,因此我不必跟踪所涉及的路径。 You need to source this in each time you want to use the SDK.每次要使用 SDK 时都需要提供此源。

enable_sdk.sh : enable_sdk.sh :

#!/bin/bash
if [[ "$0" = "$BASH_SOURCE" ]]
then
    echo "Error: you must source this script."
    exit 1
fi
source /usr/local/oecore-i686/environment-setup-corei7-32-${NAME}-linux
source /usr/local/oecore-i686/environment-setup-cortexa9hf-neon-${NAME}-linux-gnueabi
  1. Copy the defconfig file from your Yocto directory to your kernel directory (checked out somewhere outside of the Yocto tree) as .config .defconfig文件从您的 Yocto 目录复制到您的内核目录(在 Yocto 树之外的某个地方检出)作为.config

  2. Run make oldconfig in your kernel directory so that the Linux kernel build system picks up the existing .config .在内核目录中运行make oldconfig ,以便 Linux 内核构建系统选择现有的.config

    Note: you may have to answer questions about config options that are not set in the .config file.注意:您可能需要回答有关未在.config文件中设置的配置选项的问题。

    Note: running make menuconfig will fail when the SDK is enabled, because the SDK does not have the ncurses libraries set up correctly.注意:启用 SDK 时,运行make menuconfig将失败,因为 SDK 没有正确设置ncurses库。 For this command, run it in a new terminal that has not enabled the SDK so that it uses the local ncurses-dev packages you have installed.对于此命令,请在未启用 SDK 的新终端中运行它,以便它使用您已安装的本地 ncurses-dev 包。

  3. Run make -jN to build the kernel.运行make -jN来构建内核。

  4. To run the new kernel, copy the zImage and ${NAME}.dtb files to your NFS/TFTP share or boot device.要运行新内核,请将zImage${NAME}.dtb文件复制到 NFS/TFTP 共享或引导设备。 I use another script to speed up the process.我使用另一个脚本来加速这个过程。

update_kernel.sh : update_kernel.sh :

#!/bin/bash
set -x
sudo cp /path-to-linux-source/arch/arm/boot/dts/${NAME}.dtb /srv/nfs/${DEVICE}/boot/
sudo cp /path-to-linux-source/arch/arm/boot/zImage /srv/nfs/${DEVICE}/boot/
set +x
  1. You can also point Yocto to your local Linux repo in your .bb file.您还可以将 Yocto 指向.bb文件中的本地 Linux .bb库。 This is useful for making sure your kernel changes still build correctly within Yocto.这对于确保您的内核更改仍然在 Yocto 中正确构建很有用。

    SRC_URI = "git:///path-to-linux-source/.git/;branch=${KBRANCH};protocol=file"

UPDATE: Over a year later, I realize that I completely missed the question about broken patches.更新:一年多后,我意识到我完全错过了有关损坏补丁的问题。 Without more information, I can't be sure what went wrong copying the kernel source from Yocto to an external build.没有更多信息,我无法确定将内核源代码从 Yocto 复制到外部构建时出了什么问题。 I'd suggest opening a Bitbake devshell for the kernel and doing a diff with the external directory after manually applying patches to see what went wrong, or just copy the source from inside the devshell to your external directory.我建议为内核打开一个 Bitbake devshell 并在手动应用补丁后与外部目录做一个 diff 以查看出了什么问题,或者只是将 devshell 内部的源代码复制到您的外部目录。 https://www.yoctoproject.org/docs/1.4.2/dev-manual/dev-manual.html#platdev-appdev-devshell https://www.yoctoproject.org/docs/1.4.2/dev-manual/dev-manual.html#platdev-appdev-devshell

When debugging certain commands or even when just editing packages, devshell can be a useful tool.在调试某些命令甚至只是编辑包时,devshell 可能是一个有用的工具。 When you invoke devshell , source files are extracted into your working directory and patches are applied .当您调用 devshell 时,源文件被提取到您的工作目录中并应用补丁

您还可以编辑tmp/work-shared/<machine>/kernel-source然后使用bitbake -C compile virtual/kernel编译修改后的bitbake -C compile virtual/kernel

Since it can't parse it, there seems to be a problem with patch.既然解析不出来,看来是patch有问题。 How do you patch the device tree?你如何修补设备树? Are you patching it in the .bb file?你是在 .bb 文件中修补它吗?

If so, check your patch for possible syntax errors, it's very easy to overlook the syntax errors in device tree.如果是这样,请检查您的补丁是否存在语法错误,很容易忽略设备树中的语法错误。 You can remove the patch and do it manually from bitbake -c devshell <kernel-name>您可以删除补丁并通过bitbake -c devshell <kernel-name>手动完成

If not, please try to do it there and check again.如果没有,请尝试在那里执行并再次检查。 Please share results if any of these helps you.如果其中任何一项对您有帮助,请分享结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM