|
|
Line 3: |
Line 3: |
| --> {{#lst:Debian_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!-- | | --> {{#lst:Debian_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!-- |
|
| |
|
| --> {{#vardefine:BUILD_PAGE|Yocto_Build_Release}} {{#vardefine:PLATFORM_OS|Yocto}} <!-- Default to Yocto | | --> {{PageHeader|{{#var:HARDWARE_NAME}} - Debian Customize from source code}} {{DocImage|category1=Debian|category2={{#var:HARDWARE_NAME}}}} __toc__ |
| --> {{#vardefine:CONFIG_PATH|{{#var:BUILD_FOLDER}}/build/arago-tmp-default-glibc/work/{{#var:MACHINE_NAME_}}-oe-linux/linux-variscite/<kernel-version>/build/.config}} <!--
| |
| --> {{#vardefine:DEFCONFIG_PATH|{{#var:BUILD_FOLDER}}/build/arago-tmp-default-glibc/work/{{#var:MACHINE_NAME_}}-oe-linux/linux-variscite/<kernel-version>/build/defconfig}} <!--
| |
| --> {{#vardefine:DTS_FILE|arch/arm64/boot/dts/ti/k3-am625-var-som-symphony.dts}} <!--
| |
|
| |
|
| If >= Dunfell, KBUILD_DEFCONFIG is used, and using an out of tree defconfig is slightly different.
| | = Introduction = |
| --> {{#vardefine:EXTERNAL_DEFCONFIG | {{#ifexpr: {{#var:YOCTO_VERSION}} < 3.1 | my_defconfig | defconfig }} }} <!--
| |
| --> {{#vardefine:KERNEL_RECIPE_NAME | linux-variscite_% }} <!--
| |
| --> {{#vardefine:WORKDIR|~/{{#var:MACHINE_NAME}}-linux-kernel}} <!--
| |
| --> {{#vardefine:WORKDIR_ENV|$WORKDIR}} <!--
| |
|
| |
|
| --> {{PageHeader|{{#var:HARDWARE_NAME}} - Yocto Customize from source code}} {{DocImage|category1=Yocto|category2={{#var:HARDWARE_NAME}}}} __toc__
| | The kernel is deployed as a Debian package during the build process. If there are changes to the kernel source code or configurations, the kernel must be recompiled with the updated changes using the ti-debian repository. Once recompiled, the updated Debian package for the kernel should be uploaded to the Debian package server. |
| | |
| | |
| | |
| <br>
| |
| After customizing the Linux kernel by following the below instructions, you can either bitbake your complete image (e.g. {{#var:DEFAULT_IMAGE_BB_NAME}}) and the updated kernel that will be used, or you can bitbake the kernel alone by running <code>{{#var:BB_ENV}} bitbake virtual/kernel</code> (see the {{Varlink|{{#var:BUILD_PAGE}}|{{#var:RELEASE_LINK}}|Build {{#var:PLATFORM_OS}} from source code}} page for the initial setup and for more info on using bitbake).
| |
| | |
| = Configuring the kernel =
| |
| | |
| The default kernel configuration file used by Yocto is part of the kernel source tree and is located at: | |
| arch/arm64/configs/{{#var:KERNEL_DEFCONFIG}}
| |
| | |
| <br>
| |
| To configure the kernel using Yocto:
| |
| * Follow steps 1-3 of the {{Varlink|{{#var:BUILD_PAGE}}|{{#var:RELEASE_LINK}}|Build {{#var:PLATFORM_OS}} from source code}} page.
| |
| * Run the script to set up the environment (stop after that - don't build any image). E.g.:{{AM62_SETUP_ENV_RETURN_YOCTO_TOOLCHAIN}}
| |
| | |
| * Run menuconfig and configure the kernel:
| |
| {{#ifeq: {{#var:OS}} | Boot2Qt | {{#ifexpr: {{#var:YOCTO_VERSION}} >= 3.3 |
| |
| {{Note|'''Note:''' Starting from the B2Qt Hardknott release, the B2Qt standard toolchain's linker is now the gold linker, which is incompatible with the Linux kernel, causing menuconfig to fail when run from bitbake. Add the following line to <code>conf/local.conf</code> to run menuconfig:<br>
| |
| <pre>DISTRO_FEATURES:remove = "ld-is-gold"</pre> }} | }} | }}
| |
| $ {{#var:BB_ENV}} bitbake -c menuconfig virtual/kernel
| |
| When finished, save and exit.
| |
| | |
| The .config file is saved to <code>{{#var:CONFIG_PATH}}</code><br>
| |
| <br>
| |
| * At this point, you can continue following the rest of step 4 of the {{Varlink|{{#var:BUILD_PAGE}}|{{#var:RELEASE_LINK}}|Build {{#var:PLATFORM_OS}} from source code}} page to build your image with the newly configured kernel, or just build the kernel by running <code>{{#var:BB_ENV}} bitbake virtual/kernel</code>, or, you can follow the next steps to use this configuration permanently.
| |
| <br>
| |
| To save the configuration in a defconfig format:
| |
| $ {{#var:BB_ENV}} bitbake -c savedefconfig virtual/kernel
| |
| The defconfig file is saved to <code>{{#var:DEFCONFIG_PATH}}</code><br>
| |
| <br>
| |
| To make the kernel recipe use this configuration permanently, you can do either of the following:<br>
| |
| * Use any of the three methods described in the [[#Making changes in the source code|Making changes in the source code]] section below to overwrite the default configuration file in the source tree, arch/{{#switch: {{#var:SOC_SERIES}}|imx8|imx9=arm64|arm}}/configs/{{#var:KERNEL_DEFCONFIG}}, and replace it with the above defconfig.
| |
| | |
| * Make the kernel recipe use the defconfig from outside of the source tree:
| |
| Copy your defconfig:
| |
| $ cd {{#var:BUILD_FOLDER}}/sources/{{#var:META_VARISCITE_REPO}}/recipes-kernel/linux/
| |
| $ mkdir -p files
| |
| $ cp {{#var:DEFCONFIG_PATH}} files/{{#var:EXTERNAL_DEFCONFIG}}
| |
| | |
| Create a {{#var:KERNEL_RECIPE_NAME}}.bbappend file:
| |
| $ vim {{#var:KERNEL_RECIPE_NAME}}.bbappend
| |
| | |
| and append the following to it:
| |
| {{#ifexpr: {{#var:YOCTO_VERSION}} < 3.1 |
| |
| SRC_URI += "file://{{#var:EXTERNAL_DEFCONFIG}}"
| |
| KERNEL_DEFCONFIG{{#var:YOCTO_OVERRIDE_PREFIX}}{{#var:MACHINE_NAME}} = "${WORKDIR}/{{#var:EXTERNAL_DEFCONFIG}}"
| |
| |
| |
| SRC_URI += "file://{{#var:EXTERNAL_DEFCONFIG}}"
| |
| KBUILD_DEFCONFIG{{#var:YOCTO_OVERRIDE_PREFIX}}{{#var:MACHINE_NAME}} = ""
| |
| }}
| |
|
| |
|
| = Making changes in the source code = | | = Making changes in the source code = |
| '''Choose one of the following three methods to customize the Linux kernel and build it using Yocto:'''
| |
|
| |
| == Add your own patches on top of our source code ==
| |
| Using this method Yocto will take the source code from our default remote repository, and apply your patches to it before building it:<br>
| |
| <br>
| |
| '''Setup Yocto''':<br>
| |
| To configure the kernel using Yocto:
| |
| * Follow steps 1-3 of the {{Varlink|{{#var:BUILD_PAGE}}|{{#var:RELEASE_LINK}}|Build {{#var:PLATFORM_OS}} from source code}} page.
| |
| * Run the script to set up the environment (stop after that - don't build any image). E.g.:{{AM62_SETUP_ENV_RETURN_YOCTO_TOOLCHAIN}}
| |
| <br>
| |
| '''Get the source code''':<br>
| |
| $ {{#var:BB_ENV}} bitbake -c patch virtual/kernel
| |
| $ mkdir -p ../local_repos/{{#var:KERNEL_REPO}}
| |
| $ cp -a arago-tmp-default-glibc/work-shared/{{#var:MACHINE_NAME}}/kernel-source/. ../local_repos/{{#var:KERNEL_REPO}}
| |
| $ cd ../local_repos/{{#var:KERNEL_REPO}}
| |
| $ git reset --hard
| |
| $ git clean -fdx
| |
| <br>
| |
| '''Make your changes in the source code and create a patch''':<br>
| |
| You can use either diff or patch file types.<br>
| |
| For example:
| |
| $ cd {{#var:BUILD_FOLDER}}/local_repos/{{#var:KERNEL_REPO}}
| |
| $ vim {{#var:DTS_DIR}}{{#var:DTS_FILE}}
| |
| edit and save
| |
|
| |
| $ git diff > my_device_tree_changes.patch
| |
| <br>
| |
| '''Update the recipes to use your patch''':<br>
| |
| Copy your patch:
| |
| $ cd {{#var:BUILD_FOLDER}}/sources/{{#var:META_VARISCITE_REPO}}/recipes-kernel/linux/
| |
| $ mkdir -p files
| |
| $ cp {{#var:BUILD_FOLDER}}/local_repos/{{#var:KERNEL_REPO}}/my_device_tree_changes.patch files/
| |
|
| |
| Create a {{#var:KERNEL_RECIPE_NAME}}.bbappend file:
| |
| $ vim {{#var:KERNEL_RECIPE_NAME}}.bbappend
| |
|
| |
| and append the following line to it:
| |
| SRC_URI += "file://my_device_tree_changes.patch"
| |
|
| |
| == Use a local repository ==
| |
| Using this method Yocto will take the kernel source from a local repository instead of our remote ones on GitHub:<br>
| |
| <br>
| |
| '''Setup Yocto''':<br>
| |
| To configure the kernel using Yocto:
| |
| * Follow steps 1-3 of the {{Varlink|{{#var:BUILD_PAGE}}|{{#var:RELEASE_LINK}}|Build {{#var:PLATFORM_OS}} from source code}} page.
| |
| * Run the script to set up the environment (stop after that - don't build any image). E.g.:{{AM62_SETUP_ENV_RETURN_YOCTO_TOOLCHAIN}}
| |
| <br>
| |
| '''Get the source code''':<br>
| |
| $ {{#var:BB_ENV}} bitbake -c patch virtual/kernel
| |
| $ mkdir -p ../local_repos/{{#var:KERNEL_REPO}}
| |
| $ cp -a arago-tmp-default-glibc/work-shared/{{#var:MACHINE_NAME}}/kernel-source/. ../local_repos/{{#var:KERNEL_REPO}}
| |
| $ cd ../local_repos/{{#var:KERNEL_REPO}}
| |
| $ git reset --hard
| |
| $ git clean -fdx
| |
| <br>
| |
| '''Make your changes in the source code and commit them:'''<br>
| |
| After making changes in the source code ''you need to commit them''.<br>
| |
| For example:
| |
| $ cd {{#var:BUILD_FOLDER}}/local_repos/{{#var:KERNEL_REPO}}
| |
| $ vim {{#var:DTS_DIR}}{{#var:DTS_FILE}}
| |
| edit and save
| |
|
| |
| $ git commit -a -m "my device tree changes"
| |
|
| |
| To list all of the commits:
| |
| $ git log
| |
|
| |
| Get the latest commit id:
| |
| $ git rev-parse HEAD
| |
| <br>
| |
| '''Update the recipes to use the local repository instead of the default one:'''<br>
| |
| $ cd {{#var:BUILD_FOLDER}}/sources/{{#var:META_VARISCITE_REPO}}/recipes-kernel/linux/
| |
|
| |
| Create a {{#var:KERNEL_RECIPE_NAME}}.bbappend file:
| |
| $ vim {{#var:KERNEL_RECIPE_NAME}}.bbappend
| |
|
| |
| and append the following lines to it (see the previous section for listing the commits or getting the latest commit ID):
| |
|
| |
|
| KERNEL_SRC = <nowiki>"git://<var-ti-yocto_directory>/local_repos/</nowiki>{{#var:KERNEL_REPO}}<nowiki>;protocol=file"</nowiki>
| |
| SRCBRANCH{{#var:YOCTO_OVERRIDE_PREFIX}}{{#var:MACHINE_NAME}} = "{{#var:KERNEL_BRANCH}}" ''(or your own created branch)''
| |
| SRCREV{{#var:YOCTO_OVERRIDE_PREFIX}}{{#var:MACHINE_NAME}} = "''The commit id you'd like to use''"
| |
| <br>
| |
| {{note|For the SRCREV value you can also use "${AUTOREV}" during development to get the latest commit of the branch<br>
| |
| (If you do so, make sure to run "{{#var:BB_ENV}} bitbake -c cleansstate virtual/kernel" before rebuilding the kernel)}}
| |
|
| |
|
| == Use your own remote repository on GitHub == | | == Use your own remote repository on GitHub == |