====== Yocto Project Customization Guide for TQ Systems Modules ======
This guide provides instructions on how to customize U-Boot and the Linux kernel within the Yocto Project build system. It also covers creating patches and simple BitBake recipes. This is essential for adapting the system to specific hardware or software requirements for your TQ modules.
We assume you have a working Yocto Project build environment set up and are familiar with basic BitBake commands.
For TQ-specific layers, please refer to our official repositories:
* [[https://github.com/tq-systems/meta-tq|meta-tq]]
* [[https://github.com/tq-systems/ci-meta-tq|ci-meta-tq]]
===== Prerequisites =====
Before you begin, ensure you have:
* A configured Yocto Project build environment for your target TQ module.
* The `devtool` utility, which is part of Yocto Project (often included in `poky/scripts` and added to `PATH` when sourcing the build environment script like `oe-init-build-env`).
* Your TQ-specific meta-layer (e.g., `meta-tq`) added to your `bblayers.conf` file.
Source your build environment:
source poky/oe-init-build-env
===== 1. Customizing U-Boot =====
U-Boot (Das U-Boot Universal Boot Loader) is often the first piece of software that runs on your embedded device. Customizations might include changing boot commands, enabling/disabling drivers, or adjusting hardware initialization.
=== 1.1. Setting up the U-Boot Source for Development ===
To modify U-Boot, use `devtool` to extract and prepare the source code. Replace `u-boot-tq` (or the specific U-Boot recipe name for your platform, often found in `meta-tq`) if it differs. You can find the recipe name by looking into your machine configuration file or by searching in your layers.
devtool modify u-boot-tq
This command will:
* Fetch the U-Boot source code.
* Unpack it into your `/workspace/sources/u-boot-tq`.
* Create a new Git repository there for your changes.
* Create an append file (`.bbappend`) in your workspace layer to point the build system to this local source.
**Tip:** If you don't know the exact recipe name for U-Boot, you can try a more generic name often used if a specific `u-boot-tq` doesn't exist, like `u-boot-imx` for i.MX platforms, or check your machine's configuration file for `PREFERRED_PROVIDER_virtual/bootloader`.
=== 1.2. Making Changes to U-Boot ===
Navigate to the U-Boot source directory:
cd /workspace/sources/u-boot-tq
You can now make your changes. Common modifications include:
* **Environment Variables:** Edit files like `include/configs/.h` or `env/common.c`.
* **Board Configuration:** Modify `configs/` or related board files in `board/tq//`.
* **Device Tree:** For U-Boot specific device tree files (if used), these are typically in `arch//dts/`.
After making your changes, commit them using Git:
git add
git commit -m "My U-Boot customization: "
=== 1.3. Building and Testing U-Boot ===
Build U-Boot with your changes:
bitbake u-boot-tq
Or, if you want to build only U-Boot and deploy it to your image for faster testing (this might skip some image generation steps):
devtool build u-boot-tq
Then, deploy the image containing your U-Boot to your target hardware and test thoroughly.
The resulting U-Boot binary (e.g., `u-boot.imx`, `u-boot.bin`, `u-boot.img` depending on the platform) will be in `/tmp/deploy/images//`.
=== 1.4. Creating a Patch for U-Boot ===
Once you are satisfied with your changes, create a patch. Ensure you are in the U-Boot source directory (`/workspace/sources/u-boot-tq`).
If you have one commit:
git format-patch -1 -o /recipes-bsp/u-boot/files/
If you have multiple commits, you might want to squash them or create multiple patches:
git format-patch HEAD~N -o /recipes-bsp/u-boot/files/
(Replace `N` with the number of commits).
Name your patch descriptively, e.g., `0001-my-custom-u-boot-feature.patch`.
=== 1.5. Updating the U-Boot Recipe ===
Create or edit the U-Boot append file (`.bbappend`) in your custom layer. This is typically located at `/recipes-bsp/u-boot/u-boot-tq_%.bbappend` or a similar path.
Add your patch to `SRC_URI`:
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
SRC_URI += " \
file://0001-my-custom-u-boot-feature.patch \
"
**Important:** After creating the patch and updating the `.bbappend` file, you should tell `devtool` that you are done with the source:
devtool reset u-boot-tq
This will remove the workspace version and the build system will use your patched recipe from your meta-layer.
===== 2. Customizing the Linux Kernel =====
Kernel customization allows you to change device drivers, enable kernel features, modify the device tree, and more.
=== 2.1. Setting up the Kernel Source for Development ===
Use `devtool` to prepare the kernel source. The recipe name is usually `virtual/kernel`.
devtool modify virtual/kernel
This command works similarly to the U-Boot one:
* Fetches the kernel source code.
* Unpacks it into `/workspace/sources/linux`. (The directory name might vary, e.g., `linux-imx`, `linux-yocto`).
* Creates a Git repository for your changes.
* Creates an append file in your workspace layer.
=== 2.2. Making Changes to the Kernel ===
Navigate to the kernel source directory:
cd /workspace/sources/linux
Common kernel modifications:
* **Kernel Configuration:**
To change kernel configuration options (`.config`), use `menuconfig`:
bitbake virtual/kernel -c menuconfig
Or, using `devtool`:
devtool menuconfig virtual/kernel
Save your changes. This will typically create a `defconfig` file or a configuration fragment.
* **Device Tree Files (.dts, .dtsi):**
These are usually located in `arch//boot/dts/`. For TQ modules, you might find them under a vendor-specific path (e.g., `arch/arm64/boot/dts/freescale/` for NXP i.MX based modules or `arch/arm64/boot/dts/st/` for STM32MP1 based modules). Edit the relevant device tree source file for your board.
* **Driver Code:** Modify existing drivers or add new ones in the `drivers/` directory.
Commit your changes using Git:
git add
git commit -m "My kernel customization: "
=== 2.3. Building and Testing the Kernel ===
Build the kernel with your changes:
bitbake virtual/kernel
Or:
devtool build virtual/kernel
The kernel image (e.g., `zImage`, `uImage`, `Image`) and device tree blobs (`.dtb`) will be in `/tmp/deploy/images//`. Deploy and test on your hardware.
=== 2.4. Creating a Kernel Patch ===
In the kernel source directory (`/workspace/sources/linux`):
* **For code changes (drivers, dts):**
git format-patch HEAD~N -o /recipes-kernel/linux/files/
(Replace `N` with the number of commits). Name it descriptively, e.g., `0001-my-kernel-driver-fix.patch`.
* **For kernel configuration changes:**
After running `menuconfig` and saving, `devtool` often helps manage configuration fragments. Alternatively, you can generate a configuration fragment:
bitbake virtual/kernel -c savedefconfig
This will create a `defconfig` file in `/tmp/work/-poky-linux-gnueabi/linux-yocto//linux--standard-build/`. Rename this to something like `my_custom_config.cfg` and copy it to your layer: `/recipes-kernel/linux/files/`.
=== 2.5. Updating the Kernel Recipe ===
Create or edit the kernel append file (`.bbappend`) in your layer. This is often `/recipes-kernel/linux/linux-yocto_%.bbappend` or specific to the kernel version/type (e.g., `linux-imx_%.bbappend`).
Add your patch(es) and/or configuration fragment to `SRC_URI`:
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
SRC_URI += " \
file://0001-my-kernel-driver-fix.patch \
file://my_custom_config.cfg \
"
**Important:** After creating patches/config fragments and updating the `.bbappend`, reset the `devtool` workspace:
devtool reset virtual/kernel
===== 3. Creating Patches and Simple Recipes =====
=== 3.1. General Patch Creation ===
The process described for U-Boot and Kernel (using `git format-patch`) is the standard way to create patches for any software component modified via `devtool modify `.
Key steps:
1. `devtool modify `
2. Make changes in `/workspace/sources/`
3. Commit changes with `git`.
4. Generate patch(es) with `git format-patch`.
5. Copy patch(es) to your layer, typically under `///files/`.
6. Add `file://.patch` to `SRC_URI` in the recipe's `.bbappend` file.
7. `devtool reset `
=== 3.2. Creating a Simple Recipe ===
Let's say you want to add a custom script or a small, pre-compiled binary to your image.
==== 3.2.1. Recipe File Structure ====
Create a directory structure in your meta-layer:
/
recipes-custom/
my-custom-app/
files/
my_script.sh # Your script or binary
my-custom-app_0.1.bb # Your recipe file
==== 3.2.2. Example: Recipe for a Shell Script ====
**1. Create your script:** `/recipes-custom/my-custom-app/files/my_script.sh`
#!/bin/sh
echo "Hello from TQ Custom App!"
Make sure it's executable: `chmod +x my_script.sh`.
**2. Create the recipe file:** `/recipes-custom/my-custom-app/my-custom-app_0.1.bb`
SUMMARY = "My Custom Application"
DESCRIPTION = "A simple shell script example for TQ."
LICENSE = "MIT" # Or your preferred license
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
# Point to the files directory within this recipe
SRC_URI = "file://my_script.sh"
# Source directory (where files from SRC_URI are unpacked)
S = "${WORKDIR}"
# Installation: Copy the script to /usr/bin in the target image
do_install() {
install -d ${D}${bindir}
install -m 0755 ${S}/my_script.sh ${D}${bindir}/
}
# If you have other files, like service files for systemd:
# SRC_URI += " file://my-custom-app.service"
# FILES_${PN} += "${systemd_system_unitdir}/my-custom-app.service"
# SYSTEMD_SERVICE_${PN} = "my-custom-app.service" (if it's a systemd service)
**Explanation of terms:**
* `SUMMARY`, `DESCRIPTION`: Basic information about the package.
* `LICENSE`, `LIC_FILES_CHKSUM`: Crucial for licensing compliance.
* `SRC_URI`: Points to the source files. `file://` indicates files local to the recipe.
* `S`: Specifies the source directory after unpacking. For simple file additions, `${WORKDIR}` is common.
* `do_install()`: This function defines how to install files into the target image's filesystem (`${D}` is the destination directory for staging). `${bindir}` usually resolves to `/usr/bin`.
==== 3.2.3. Adding the Recipe to Your Image ====
To include `my-custom-app` in your image, add it to your image recipe (e.g., `core-image-minimal.bbappend` or your custom image recipe):
IMAGE_INSTALL_append = " my-custom-app"
Or, for testing, you can build it directly:
bitbake my-custom-app
Then, build your full image:
bitbake
After deploying and booting the image, `/usr/bin/my_script.sh` should be present.
===== 4. Further Information =====
* **Layer Organization:** Keep your custom patches and recipes in a dedicated meta-layer (like `meta-tq` or a customer-specific layer).
* **Commit Messages:** Write clear and descriptive commit messages when making changes with `devtool`. These messages often become the description in your patch files.
* **Testing:** Thoroughly test all changes on target hardware.
* **Upstream Sources:** When possible, try to contribute generic changes back to the upstream projects (U-Boot, Kernel, etc.).
* **Yocto Project Documentation:** The official Yocto Project Mega-Manual and Development Tasks Manual are invaluable resources.
* [[https://docs.yoctoproject.org/mega-manual/index.html|Yocto Project Mega-Manual]]
* [[https://docs.yoctoproject.org/dev-manual/index.html|Yocto Project Development Tasks Manual]]
This guide provides a starting point. The Yocto Project is powerful and flexible, and there are many ways to achieve specific customizations. Always refer to official documentation and the specifics of your TQ module's BSP.
===== Accordion =====
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
===== Alerts without Icons =====
Well done! You successfully read this important alert message.Heads up! This alert needs your attention, but it's not super important.Warning! Better check yourself, you're not looking too good.Oh snap! Change a few things up and try submitting again.
===== Dismissable Alerts without Icons =====
Well done! You successfully read this important alert message.Heads up! This alert needs your attention, but it's not super important.Warning! Better check yourself, you're not looking too good.Oh snap! Change a few things up and try submitting again.
===== Dismissable Alerts with Icons =====
Well done! You successfully read this important alert message.Heads up! This alert needs your attention, but it's not super important.Warning! Better check yourself, you're not looking too good.Oh snap! Change a few things up and try submitting again.
===== Callouts =====
=== Default Callout ===
This is a default callout.
=== Primary Callout ===
This is a primary callout with icon.
=== Success Callout ===
This is a Success callout with icon.
=== Info Callout ===
This is a info callout with icon.
=== Warning Callout ===
This is a warning callout with icon.
=== Danger Callout ===
This is a danger callout with icon.
=== Question Callout ===
This is a question callout with icon.
=== Tip Callout ===
This is a Tip callout with icon.
===== Form with Captcha =====
===== Badges =====
===== Badges with icons =====
===== List Groups =====
* Cras justo odio
* Dapibus ac facilisis in
* Morbi leo risus
* Porta ac consectetur ac
* Vestibulum at eros
* Cras justo odio 14
* Dapibus ac facilisis in 2
* Morbi leo risus 1
* [[:start]]
* [[:wiki:welcome]]
* [[:wiki:syntax]]
* [[:start]] \\ Homepage \\ Test
* [[:wiki:welcome]] \\ DokuWiki Welcome
* [[:wiki:syntax]] \\ DokuWiki Syntax
* {{fa>home}} [[:start|Home-Page]]
===== Nav Tabs and Nav Pills =====
\\
\\
\\
\\
\\
* [[#tab-foo|Foo]]
* [[#tab-bar|Bar]]
=== Foo ===
Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
=== Bar ===
Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
===== Panels =====
Basic panel example
Panel content
Panel content
Panel content
Panel content
Panel content
Panel content
Panel content
Some default panel content here. Nulla vitae elit libero, a pharetra augue. Aenean lacinia bibendum nulla sed consectetur. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Nullam id dolor id nibh ultricies vehicula ut id elit.
^ # ^ First Name ^ Last Name ^ Username ^
^ 1 | Mark | Otto | @mdo |
^ 2 | Jacob | Thornton | @fat |
^ 3 | Larry | the Bird | @twitter |
^ # ^ First Name ^ Last Name ^ Username ^
^ 1 | Mark | Otto | @mdo |
^ 2 | Jacob | Thornton | @fat |
^ 3 | Larry | the Bird | @twitter |
===== Tooltip =====
Lorem ipsum dolor sit amet...
\\
Lorem ipsum dolor sit amet...
\\
Lorem ipsum dolor sit amet...
\\
Lorem ipsum dolor sit amet...
\\
===== Buttons =====
DefaultPrimarySuccessInfoWarningDangerLink
===== Images (in grid) =====
{{https://via.placeholder.com/400x400?.png?}}
{{https://via.placeholder.com/400x400?.png?}}
{{https://via.placeholder.com/400x400?.png?}}
Scroll the page!