IMX8/Nitrogen8M/Yocto/Customizing Boot Sequence: Difference between revisions

From RidgeRun Developer Wiki
< IMX8‎ | Nitrogen8M‎ | Yocto
mNo edit summary
mNo edit summary
Line 7: Line 7:
== Modifying Bootscript ==
== Modifying Bootscript ==


Nitrogen8M U-Boot is made to look for and execute a bootscript named boot.src. This script will load the device tree, kernel and setup bootargs. When you are developing, you may need to modify this script, following instructions will show you how to modify it from your yocto enviroment.
Nitrogen8M U-Boot is made to look for and execute a bootscript named boot.src. This script will load the device tree, kernel, and setup bootargs. When you are developing, you may need to modify this script, the following instructions will show you how to modify it from your yocto environment.
   
   
=== Custom meta layer ===
=== Custom meta layer ===
You will need your own meta layer, if you already have one, skip this and follow to the next section.
You will need your own meta-layer, if you already have one, skip this and follow to the next section.


=== Adding U-Boot script recipe ===
=== Adding U-Boot script recipe ===
Line 35: Line 35:
</syntaxhighlight>
</syntaxhighlight>


This commands created an empty file u-boot-script-boundary_%.bbappend, the percentage allows the recipe to be used for the current package version. Open the file with your favorite editor and fill it as follows:
These commands created an empty file u-boot-script-boundary_%.bbappend, the percentage allows the recipe to be used for the current package version. Open the file with your favorite editor and fill it as follows:


<syntaxhighlight lang=makefile>
<syntaxhighlight lang=makefile>
Line 52: Line 52:


<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>
#Assuming your build directory name is build, otherwise you need to change the name "build" to your corresponding directory name
#Assuming your build directory name is build, otherwise, you need to change the name "build" to your corresponding directory name


cd $YOCTO_BUILD_DIR
cd $YOCTO_BUILD_DIR
Line 64: Line 64:
== Modifying Bootargs ==  
== Modifying Bootargs ==  


If you just need a temporal change to the bootargs and don't want to build your own bootscript, you can use the '''cmd_custom''' u-boot enviroment variable to set them as follows:
If you just need a temporal change to the bootargs and don't want to build your own bootscript, you can use the '''cmd_custom''' u-boot environment variable to set them as follows:


1. Power ON the Nitrogen8M board, and stop the boot up process on u-boot, (press a key during the boot up count down)
1. Power ON the Nitrogen8M board, and stop the bootup process on u-boot, (press a key during the bootup count down)


2. While in u-boot set the cmd_custom variable
2. While in u-boot set the cmd_custom variable

Revision as of 19:10, 15 December 2020




Previous: Nitrogen8M/Yocto/Advanced image loading Index Next: Nitrogen8M/Android






Modifying Bootscript

Nitrogen8M U-Boot is made to look for and execute a bootscript named boot.src. This script will load the device tree, kernel, and setup bootargs. When you are developing, you may need to modify this script, the following instructions will show you how to modify it from your yocto environment.

Custom meta layer

You will need your own meta-layer, if you already have one, skip this and follow to the next section.

Adding U-Boot script recipe

1. Create recipe directories

# You need to set YOCTO_BUILD_DIR and META_LAYER to match your setup
cd $YOCTO_BUILD_DIR/sources/$META_LAYER
mkdir -p recipes-bsp/u-boot/files

2. Download/Modify your boot script. You can download the Boundary bootscript text file bootscript-yocto.txt, found inside the U-Boot source code under the bootscripts folder (board/boundary/bootscripts/). Modify the file as you want and then copy it into the files directory:

# You need to set YOCTO_BUILD_DIR and META_LAYER to match your setup
cp bootscript-yocto.txt $YOCTO_BUILD_DIR/sources/$META_LAYER/recipes-bsp/u-boot/files

3. Create .bbappend for the uboot-script recipe.

# You need to set YOCTO_BUILD_DIR and META_LAYER to match your setup
cp bootscript-yocto.txt $YOCTO_BUILD_DIR/sources/$META_LAYER/recipes-bsp/u-boot/
touch u-boot-script-boundary_%.bbappend

These commands created an empty file u-boot-script-boundary_%.bbappend, the percentage allows the recipe to be used for the current package version. Open the file with your favorite editor and fill it as follows:

FILESEXTRAPATHS_prepend := "${THISDIR}/files:"

SRC_URI += "file://bootscript-yocto.txt"

BOOTSCRIPT = "${WORKDIR}/bootscript-yocto.txt"

This tells to the u-boot-script-boundary recipe where to find the bootscript text file.

Building Bootscript

Now that you have the append recipe in place pointing to your custom bootscript file you can create the binary boot.src

#Assuming your build directory name is build, otherwise, you need to change the name "build" to your corresponding directory name

cd $YOCTO_BUILD_DIR
source setup-environment build/
bitbake u-boot-script-boundary

The boot.src can be found on your yocto directory at $YOCTO_BUILD_DIR/build/tmp/work/nitrogen8m-fslc-linux/u-boot-script-boundary/$VERSION/image/, notice that $VERSION depends of your u-boot version, for example for u-boot 2018.07 the corresponding path is tmp/work/nitrogen8m-fslc-linux/u-boot-script-boundary/v2018.07+gitAUTOINC+f35ba6cfbe-r0/image/. Copy boot.src to your boot device at the boot partition.


Modifying Bootargs

If you just need a temporal change to the bootargs and don't want to build your own bootscript, you can use the cmd_custom u-boot environment variable to set them as follows:

1. Power ON the Nitrogen8M board, and stop the bootup process on u-boot, (press a key during the bootup count down)

2. While in u-boot set the cmd_custom variable

#Set <custom_bootargs> with your bootargs parameters

setenv cmd_custom 'setenv bootargs $bootargs <custom_bootargs>

Example:

# Add bootargs to keep serial console alive on power management for debugging purposes

setenv cmd_custom 'setenv bootargs $bootargs no_console_suspend=1


Previous: Nitrogen8M/Yocto/Advanced image loading Index Next: Nitrogen8M/Android