Yocto Customizing U-Boot AM62: Difference between revisions

From Variscite Wiki
No edit summary
(RND-2134: am62: kirkstone: wiki: align Yocto Customize U-Boot with i.MX8 guide)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
<!-- Set release according to "release" parameter in URL and use am62-yocto-dunfell-5.10.168_08.06.00.42-v1.0 as default
<!-- Set release according to the "release" parameter in URL and use am62-yocto-dunfell-5.10.168_08.06.00.42-v1.0 as default
--> {{INIT_RELEASE_PARAM|am62-yocto-kirkstone-6.1.46_09.01.00.08-v1.0}}<!--
--> {{INIT_RELEASE_PARAM|am62-yocto-kirkstone-6.1.46_09.01.00.08-v1.0}}<!--
--> {{#lst:Yocto_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{#lst:Yocto_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{COMMON_YOCTO_VARS}} <!-- Include common yocto variables
--> {{#vardefine:WORKDIR|~/{{#var:MACHINE_NAME}}-u-boot}} <!--
--> {{#vardefine:WORKDIR|~/{{#var:MACHINE_NAME}}-u-boot}} <!--
--> {{#vardefine:WORKDIR_ENV|$WORKDIR}} <!--
--> {{#vardefine:WORKDIR_ENV|$WORKDIR}} <!--
--> {{PageHeader|Yocto Customize from source code}} {{DocImage|category1=Yocto|category2={{#var:HARDWARE_NAME}}}} __toc__
--> {{PageHeader|{{#var:HARDWARE_NAME}} - Yocto Customize from source code}} {{DocImage|category1=Yocto|category2={{#var:HARDWARE_NAME}}}} __toc__


= Introduction =
= Introduction =
Line 14: Line 16:
= Before Starting =
= Before Starting =


Before starting this guide, you must have the Yocto environment setup and be able to build images for the VAR-SOM-AM62.
Before starting this guide, you must have the Yocto environment set and be able to build images for the VAR-SOM-AM62.


Please see: {{Varlink|Yocto_Build_Release|{{#var:RELEASE_LINK}}|'''Build Yocto from source code'''}}.
Please see: {{Varlink|Yocto_Build_Release|{{#var:RELEASE_LINK}}|'''Build Yocto from source code'''}}.
Line 20: Line 22:
The remainder of the guide assumes the Yocto working directory is '''~/var-ti-yocto'''
The remainder of the guide assumes the Yocto working directory is '''~/var-ti-yocto'''


= Patching Yocto =
= Making changes in the source code =
Choose one of the following three methods to customize the U-Boot source code and build it using Yocto:
 
== Add your patches on top of the Variscite source code ==
 
Fetch the U-Boot source:
$ MACHINE={{#var:MACHINE_NAME}} bitbake -c unpack virtual/bootloader
$ mkdir -p ../local_repos/{{#var:U-BOOT_REPO}}
$ cp -a arago-tmp-default-glibc/work/{{#var:MACHINE_NAME_}}-oe-linux/u-boot-variscite/<uboot version>/git/. ../local_repos/{{#var:U-BOOT_REPO}}
$ cd ../local_repos/{{#var:U-BOOT_REPO}}
$ git reset --hard
$ git clean -fdx
 
Next, make the desired changes to the U-Boot source code. After changing the source code, create a diff file:
 
$ git diff > ~/var-ti-yocto/tisdk/sources/meta-variscite-bsp-ti/recipes-bsp/u-boot/u-boot-variscite/uboot.diff


Fetch the U-Boot source:
Finally, configure <code>~/var-ti-yocto/tisdk/sources/meta-variscite-bsp-ti/recipes-bsp/u-boot/u-boot-variscite_<u-boot version>.bb</code> to apply the patch by appending:
{{GIT_FETCH|NAME=U-BOOT|WORKDIR={{#var:WORKDIR_ENV}}}}


Checkout the version of U-Boot that is aligned with '''SRCREV''' in '''~/var-ti-yocto/tisdk/sources/meta-variscite-bsp-ti/recipes-bsp/u-boot/u-boot-variscite_<u-boot version>.bb'''
SRC_URI += "file://uboot.diff"


For example, if:
== Use a local repository ==


  SRCREV = "fbbe3117f5daa78d6df922b4f2d33154de1495b1"
Fetch the U-Boot source:
  $ MACHINE={{#var:MACHINE_NAME}} bitbake -c unpack virtual/bootloader
$ mkdir -p ../local_repos/{{#var:U-BOOT_REPO}}
$ cp -a arago-tmp-default-glibc/work/{{#var:MACHINE_NAME_}}-oe-linux/u-boot-variscite/<uboot version>/git/. ../local_repos/{{#var:U-BOOT_REPO}}
$ cd ../local_repos/{{#var:U-BOOT_REPO}}
$ git reset --hard
$ git clean -fdx


Then run:
Next, make the desired changes to the U-Boot source code. After making changes in the source code ''you need to commit them''.<br>
For example:
$ cd {{#var:BUILD_FOLDER}}/local_repos/{{#var:U-BOOT_REPO}}
$ vim board/variscite/{{#var:MACHINE_NAME_}}/{{#var:MACHINE_NAME_}}.c
$ vim include/configs/{{#var:MACHINE_NAME_}}.h
edit and save
$ git commit -a -m "my_{{#var:MACHINE_NAME_}}_changes"


  $ cd ti-u-boot
  To list all of the commits:
  $ git checkout fbbe3117f5daa78d6df922b4f2d33154de1495b1
  $ git log


Next, make the desired changes to the U-Boot source code. After changing the source code, create a diff file:
Get the latest commit ID:
$ git rev-parse HEAD
<br>
Update the recipe to use the local repository instead of the default one:
$ cd {{#var:BUILD_FOLDER}}/sources/{{#var:META_VARISCITE_REPO}}/recipes-bsp/u-boot/
 
Create a u-boot-variscite.bbappend file:
$ vim u-boot-variscite_%.bbappend
 
Append the following lines to it (see the previous section for listing the commits or getting the latest commit ID):
UBOOT_SRC = "git://<var-ti-yocto_directory_path>/local_repos/{{#var:U-BOOT_REPO}};protocol=file"
SRCBRANCH{{#var:YOCTO_OVERRIDE_PREFIX}}{{#var:MACHINE_NAME}} = "{{#var:U-BOOT_BRANCH}}" ''(or your own created branch)''
SRCREV{{#var:YOCTO_OVERRIDE_PREFIX}}{{#var:MACHINE_NAME}} = "''The commit id you'd like to use''"
 
{{#ifexpr:{{#var:YOCTO_VERSION}}<3.1|
Also, update the u-boot-fw-utils recipe:
$ cp u-boot-variscite.bbappend u-boot-fw-utils.bbappend
|}}
{{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/bootloader" before rebuilding U-Boot)}}
 
== Use your remote repository on GitHub ==
Using this method Yocto will fetch the source code from your remote repository on GitHub.<br>
 
Create a GitHub account and upload your proprietary U-Boot to a new repository:
You can fork our repository to your account by visiting the following link and clicking on "Fork" at the top right of the screen:
https://github.com/varigit/{{#var:U-BOOT_REPO}}/tree/{{#var:U-BOOT_BRANCH}}
 
Alternatively, you can clone the repository to your local machine, and push it later to your account.<br>
 
<br>
Update the recipes to use your remote repository instead of the default one:
$ cd {{#var:BUILD_FOLDER}}/sources/{{#var:META_VARISCITE_REPO}}/recipes-bsp/u-boot/
 
Create a u-boot-variscite.bbappend file:
$ vim u-boot-variscite_%.bbappend


$ git diff > ~/var-ti-yocto/tisdk/sources/meta-variscite-bsp-ti/recipes-bsp/u-boot/u-boot-variscite/uboot.diff
and append the following lines to it (see the previous section for listing the commits or getting the latest commit ID):


Finally, configure '''~/var-ti-yocto/tisdk/sources/meta-variscite-bsp-ti/recipes-bsp/u-boot/u-boot-variscite_<u-boot version>.bb''' to apply the patch by appending:
UBOOT_SRC = <nowiki>"git://github.com/<your_account>/</nowiki>{{#var:U-BOOT_REPO}}.git;protocol=git"
SRCBRANCH = "{{#var:U-BOOT_BRANCH}}" ''(or your own created branch)''
SRCREV = "''The commit id you'd like to use''"


  SRC_URI += "file://uboot.diff"
{{#ifexpr:{{#var:YOCTO_VERSION}}<3.1|
Also, update the u-boot-fw-utils recipe:
  $ cp u-boot-variscite.bbappend u-boot-fw-utils.bbappend
|}}
{{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/bootloader" before rebuilding U-Boot)}}


= Building U-Boot using Yocto =
= Building U-Boot using Yocto =


Build the U-Boot images by running:
After making the desired changes to the source code following one of the methods described in the [[#Making changes in the source code|Making changes in the source code]], you can build the U-Boot images by running:


  $ cd ~/var-ti-yocto/tisdk/build
  $ cd ~/var-ti-yocto/tisdk/build

Latest revision as of 18:32, 1 August 2024

Warning: This page is designed to be used with a 'release' URL parameter.

This page is using the default release am62-yocto-kirkstone-6.1.46_09.01.00.08-v1.0.
To view this page for a specific Variscite SoM and software release, please follow these steps:

  1. Visit variwiki.com
  2. Select your SoM
  3. Select the software release
VAR-SOM-AM62 - Yocto Customize from source code

Introduction

This guide demonstrates how to patch and rebuild the VAR-SOM-AM62 U-Boot images using Yocto.

To learn how to build the U-Boot images outside of Yocto, see: Build U-Boot from source code

Before Starting

Before starting this guide, you must have the Yocto environment set and be able to build images for the VAR-SOM-AM62.

Please see: Build Yocto from source code.

The remainder of the guide assumes the Yocto working directory is ~/var-ti-yocto

Making changes in the source code

Choose one of the following three methods to customize the U-Boot source code and build it using Yocto:

Add your patches on top of the Variscite source code

Fetch the U-Boot source:

$ MACHINE=am62x-var-som bitbake -c unpack virtual/bootloader
$ mkdir -p ../local_repos/ti-u-boot
$ cp -a arago-tmp-default-glibc/work/am62x_var_som-oe-linux/u-boot-variscite/<uboot version>/git/. ../local_repos/ti-u-boot
$ cd ../local_repos/ti-u-boot
$ git reset --hard
$ git clean -fdx

Next, make the desired changes to the U-Boot source code. After changing the source code, create a diff file:

$ git diff > ~/var-ti-yocto/tisdk/sources/meta-variscite-bsp-ti/recipes-bsp/u-boot/u-boot-variscite/uboot.diff

Finally, configure ~/var-ti-yocto/tisdk/sources/meta-variscite-bsp-ti/recipes-bsp/u-boot/u-boot-variscite_<u-boot version>.bb to apply the patch by appending:

SRC_URI += "file://uboot.diff"

Use a local repository

Fetch the U-Boot source:

$ MACHINE=am62x-var-som bitbake -c unpack virtual/bootloader
$ mkdir -p ../local_repos/ti-u-boot
$ cp -a arago-tmp-default-glibc/work/am62x_var_som-oe-linux/u-boot-variscite/<uboot version>/git/. ../local_repos/ti-u-boot
$ cd ../local_repos/ti-u-boot
$ git reset --hard
$ git clean -fdx

Next, make the desired changes to the U-Boot source code. After making changes in the source code you need to commit them.
For example:

$ cd ~/var-ti-yocto/local_repos/ti-u-boot
$ vim board/variscite/am62x_var_som/am62x_var_som.c
$ vim include/configs/am62x_var_som.h
edit and save

$ git commit -a -m "my_am62x_var_som_changes"
To list all of the commits:
$ git log
Get the latest commit ID:
$ git rev-parse HEAD


Update the recipe to use the local repository instead of the default one:

$ cd ~/var-ti-yocto/sources/meta-variscite-bsp-ti/recipes-bsp/u-boot/

Create a u-boot-variscite.bbappend file:

$ vim u-boot-variscite_%.bbappend

Append the following lines to it (see the previous section for listing the commits or getting the latest commit ID):

UBOOT_SRC = "git://<var-ti-yocto_directory_path>/local_repos/ti-u-boot;protocol=file"
SRCBRANCH:am62x-var-som = "ti-u-boot-2023.04_var01" (or your own created branch)
SRCREV:am62x-var-som = "The commit id you'd like to use"


For the SRCREV value you can also use "${AUTOREV}" during development to get the latest commit of the branch
(If you do so, make sure to run "MACHINE=am62x-var-som bitbake -c cleansstate virtual/bootloader" before rebuilding U-Boot)

Use your remote repository on GitHub

Using this method Yocto will fetch the source code from your remote repository on GitHub.

Create a GitHub account and upload your proprietary U-Boot to a new repository: You can fork our repository to your account by visiting the following link and clicking on "Fork" at the top right of the screen: https://github.com/varigit/ti-u-boot/tree/ti-u-boot-2023.04_var01

Alternatively, you can clone the repository to your local machine, and push it later to your account.


Update the recipes to use your remote repository instead of the default one:

$ cd ~/var-ti-yocto/sources/meta-variscite-bsp-ti/recipes-bsp/u-boot/

Create a u-boot-variscite.bbappend file:

$ vim u-boot-variscite_%.bbappend

and append the following lines to it (see the previous section for listing the commits or getting the latest commit ID):

UBOOT_SRC = "git://github.com/<your_account>/ti-u-boot.git;protocol=git"
SRCBRANCH = "ti-u-boot-2023.04_var01" (or your own created branch)
SRCREV = "The commit id you'd like to use"


For the SRCREV value you can also use "${AUTOREV}" during development to get the latest commit of the branch
(If you do so, make sure to run "MACHINE=am62x-var-som bitbake -c cleansstate virtual/bootloader" before rebuilding U-Boot)

Building U-Boot using Yocto

After making the desired changes to the source code following one of the methods described in the Making changes in the source code, you can build the U-Boot images by running:

$ cd ~/var-ti-yocto/tisdk/build
$ . conf/setenv

# Build only the U-Boot images:
$ MACHINE=am62x-var-som bitbake -c deploy u-boot-variscite                    # tispl.bin and u-boot.img
$ MACHINE=am62x-var-som bitbake -c deploy mc:k3r5:u-boot-variscite            # tiboot3.bin

# Optionally, you may skip building U-Boot and just build your image:
$ MACHINE=am62x-var-som bitbake <image name>

The relevant output files are:

deploy-ti/images/am62x-var-som/u-boot.img
deploy-ti/images/am62x-var-som/tispl.bin
deploy-ti/images/am62x-var-som/tiboot3.bin

see: Build U-Boot from source code to learn how to update a running board with these images.