This repository serves as a hands-on guide for debugging recipes in the Yocto Project. It includes a comprehensive video tutorial and accompanying slides derived from the Bootlin tutorial for Yocto, aimed at helping developers effectively troubleshoot and resolve issues during the build process.
The slides attached in this repository are sourced from the Bootlin tutorial for Yocto. We extend our gratitude to Bootlin for their valuable resources that facilitate learning and development in the Yocto ecosystem.
Debugging is a crucial aspect of software development, especially in complex build systems like Yocto. This repository aims to equip developers with practical knowledge and techniques for efficiently debugging recipes, improving build reliability and performance.
Watch the Video Tutorial This video provides a step-by-step walkthrough of various debugging techniques in Yocto.
You can locate the log for a specific task in the file ${WORKDIR}/temp/log.do_<taskname>. For instance, if you are examining the do_compile task for the QEMU minimal image targeting the x86 machine (referred to as qemux86), the log file would typically be found at tmp/work/qemux86-poky-linux/core-image-minimal/1.0-r0/temp/log.do_compile.
To view the commands that BitBake executed to generate this log, refer to the corresponding run.do_<taskname> file in the same directory.
Both log.do_<taskname> and run.do_<taskname> are symbolic links to log.do_<taskname>.<pid> and log.run_<taskname>.<pid>, where <pid> represents the process ID of the task during its execution. These symlinks always direct you to the files from the most recent run of the task.
Benefits of Using Logs
- Help identify problems quickly.
- Provide insights into build processes.
- Improve recipe reliability by allowing developers to debug and optimize.
To view the log files generated during the build process, follow these steps:
-
Navigate to the Build Directory: Change to the
builddirectory where your Yocto project is located -
Enter the Temporary Directory: Access the
tmpdirectory, which contains all the build-related data -
Go to the Work Directory: Enter the
workdirectory to find the logs for specific recipes -
Select the Target Architecture: Choose the appropriate architecture directory, for example,
qemux86_64-poky-linux -
Access the Recipe Directory: Navigate to the specific recipe directory you want to inspect. For example, for
base-files -
Go to the Temp Directory: Inside the recipe directory, enter the
tempdirectory -
List Available Log Files: List the contents of the
tempdirectory to find relevant log files
log.do_compile: Contains logs related to the compilation process of the recipe.run.do_compile: Shows the script that was executed during the compilation.
- View the Log Files:
Use
catorlessto read the contents of the desired log files, such aslog.do_compile:
Here’s an example of how to access the run and log files using my own terminal:
The following files are generated during the build process and provide valuable insights for debugging and optimizing your Yocto recipes:
-
log.do_cleanall: This log contains the output from thedo_cleanalltask, which is responsible for cleaning all output files for the recipe. It provides information on what was removed and any errors encountered during the cleaning process. -
log.do_cleanall.<pid>: Similar tolog.do_cleanall, this file captures the log output for a specific run of thedo_cleanalltask, identified by the process ID (PID). It is useful for tracking specific executions. -
log.do_cleansstate: This log file records the output of thedo_cleansstatetask, which cleans the shared state cache for a recipe. It details the files that were cleaned and any issues that arose. -
log.do_cleansstate.<pid>: This is the log for a specific execution of thedo_cleansstatetask. It helps you understand the context of that particular run. -
log.task_order: This file outlines the order in which tasks are executed. It provides a comprehensive view of task dependencies and execution flow, helping to identify bottlenecks or conflicts.
-
run.do_cleanall: This is the script generated for thedo_cleanalltask. It contains the commands executed during the cleaning process. By inspecting this file, you can understand how the clean operation is performed. -
run.do_cleanall.<pid>: This file is similar torun.do_cleanall, but it corresponds to a specific run identified by the PID. It’s useful for debugging specific cleaning scenarios. -
run.do_cleansstate: This script outlines the commands executed during thedo_cleansstatetask. Reviewing this file can help you see what actions are taken to clean the shared state. -
run.do_cleansstate.<pid>: This file corresponds to a specific run of thedo_cleansstatetask, providing context for that execution.
-
Debugging: When tasks fail or produce unexpected results, these logs can help pinpoint the cause by providing detailed error messages and execution flow.
-
Optimization: Understanding the commands in the run files allows you to refine your recipes for better performance and reliability.
-
Task Flow Analysis: The
log.task_orderfile helps visualize the dependencies and order of task execution, making it easier to optimize the build process. -
Error Tracking: By reviewing specific log files for failed tasks, you can identify recurring issues and address them systematically.
To utilize these files effectively:
- Inspect Logs: Start with the log files to get an overview of what happened during task execution.
- Review Run Scripts: Check the corresponding run scripts for detailed command sequences.
- Trace Execution: Use the
log.task_orderfile to understand how tasks relate to each other and where improvements can be made.
By leveraging these resources, you can enhance your debugging capabilities and improve the overall reliability of your Yocto builds.
Understanding how variables are assigned and modified in Yocto recipes is crucial for effective debugging and optimization. The following tools and techniques can help you inspect and troubleshoot variable assignments:
-
bitbake -e <recipe-name>- Purpose: Outputs the complete environment for a specific recipe after parsing, showing all variable assignments.
- Usage: Use this command to see how variables are set, inherited, and influenced by the various layers and configurations.
- Output: The output includes all variable values, providing insights into any changes that may have occurred during parsing.
-
bitbake-getvar -r <variable-name>- Purpose: Retrieves the value of a specific variable as it applies to a recipe.
- Usage: This command is particularly useful for inspecting variables without triggering task execution.
- Example: Run
bitbake-getvar -r LDFLAGS <recipe-name>to see how theLDFLAGSvariable is set for the specified recipe.
DEPENDS: Lists dependencies required for building the recipe. Understanding this variable can help resolve build order issues.LDFLAGS: Contains flags used during the linking phase. Inspecting this can provide insights into linking errors or optimization settings.CFLAGS: Compiler flags that affect the compilation process. Analyzing this can help diagnose compilation issues.
- Check Variable Precedence: Variables can be overridden or modified at different layers. Use
bitbake -eto trace variable changes throughout the build. - Use Logging: Consider adding
bb.debuglogging statements in your recipe to print variable values during execution for better visibility. - Compare Builds: If you suspect a variable is affecting the build outcome, compare logs and variable values from successful and failed builds.
- Identify the Problem: If a recipe fails, start by identifying which variable might be causing the issue.
- Inspect Variables: Use
bitbake -e <recipe-name>to get a full list of variable assignments. - Refine Assignments: Modify your recipe or configuration files as necessary based on your findings.
- Test Changes: Re-run the build to see if your adjustments resolve the issue.
By effectively debugging variable assignments, you can enhance the reliability and performance of your Yocto recipes, ensuring a smoother development process.
For more information on debugging in Yocto, please refer to the Yocto Project Debugging Manual.
For any questions or feedback, feel free to reach out via email: baselinux2024@gmail.com


