Yocto Build U-Boot: Difference between revisions

From Variscite Wiki
(Created page with "{{PageHeader|Yocto Build U-Boot from source code}} {{DocImage|category1=Yocto|category2={{#var:HARDWARE_NAME|DART-6UL}}}} __toc__ = Toolchain installation for out of Yocto bui...")
 
(Build U-Boot out of Yocto tree: fix "make: ./../scripts/dtb_check.sh: Command not found" when building the boot image)
(137 intermediate revisions by 9 users not shown)
Line 1: Line 1:
{{PageHeader|Yocto Build U-Boot from source code}} {{DocImage|category1=Yocto|category2={{#var:HARDWARE_NAME|DART-6UL}}}} __toc__
<!-- Set release according to "release" parameter in URL and use RELEASE_MORTY_V1.0_VAR-SOM-MX6 as default
--> {{#vardefine:RELEASE_PARAM|{{#urlget:release|RELEASE_MORTY_V1.0_VAR-SOM-MX6}}}} <!--
--> {{#lst:Yocto_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{#lst:B2QT_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{PageHeader|Yocto Build U-Boot from source code}} {{DocImage|category1=Yocto|category2={{#var:HARDWARE_NAME}}}} __toc__
= Toolchain installation for out of Yocto builds =
= Toolchain installation for out of Yocto builds =


To install the toolchain, follow [[{{#var:HARDWARE_NAME|DART-6UL}} {{#var:YOCTO_NAME|Morty}} Yocto Toolchain installation]].
To install the toolchain, follow {{Varlink2|Yocto Toolchain installation|{{#var:RELEASE_LINK}}}}.
 
Reply to all defaults 'y'<br>
The toolchain name depend on your build machine and may change.


= Build U-Boot out of Yocto tree =
= Build U-Boot out of Yocto tree =
Obtain sources:  
Obtain sources:  


  $ cd {{#var:BUILD_FOLDER|~/var-fslc-yocto}}
  $ git clone {{#var:U-BOOT_GIT}} -b {{#var:U-BOOT_BRANCH}}
$ git clone https://github.com/varigit/uboot-imx.git
$ cd uboot-imx
$ git checkout -b {{#var:U-BOOT_BRANCH|imx_v2015.10_dart_6ul_var1}} origin/{{#var:U-BOOT_BRANCH|imx_v2015.10_dart_6ul_var1}}


Configure compilation environment:
$ source {{#var:TOOLCHAIN_LOCATION}}
Cleanup everything:
$ make mrproper
{{#ifeq: {{#var:SOC_SERIES}} | imx8 |
<br>
Select configuration:
$ make {{#var:U-BOOT_SD_DEFCONFIG}}


* follow above procedure for installing the toolchain
Build U-Boot:
Build U-Boot:
  $ source {{#var:TOOLCHAIN_LOCATION|/opt/fsl-imx-x11/4.1.15-2.0.1/environment-setup-cortexa7hf-neon-poky-linux-gnueabi}}
  $ make -j$(nproc)
|
Select one of the following configurations:
For booting from SD card/eMMC:
$ make {{#var:U-BOOT_SD_DEFCONFIG}}
For booting from NAND flash:
$ make {{#var:U-BOOT_NAND_DEFCONFIG}}
 
Build U-Boot:
 
$ make -j$(nproc)
}}
 
{{#ifeq: {{#var:SOC_SERIES}} | imx8 |
= Build boot image =
The final boot image contains multiple firmware files. The following procedure builds the final image.
 
Create imx-boot-tools directory:
$ mkdir imx-boot-tools
$ cd imx-boot-tools
 
{{#ifeq: {{#var:SOC_FAMILY}} | imx8 |


Obtain SC firmware:<br>
{{#ifexpr: {{#var:YOCTO_VERSION}} < 3.1 |Either build|Build}} SCFW by following the {{Varlink|Yocto_Build_SCFW|{{#var:RELEASE_LINK}}|Build SCFW from source code}} page and copy the SCFW image to the imx-boot-tools directory{{#ifexpr: {{#var:YOCTO_VERSION}} < 3.1 |, or download the pre-built binary by running:<br>
$ wget {{#var:META_VARISCITE_GIT}}/raw/{{#var:META_VARISCITE_BRANCH}}/recipes-bsp/imx-sc-firmware/imx-sc-firmware/{{#var:SC_FIRMWARE}} -O scfw_tcm.bin|
.<br><br>}}


  $ cd {{#var:BUILD_FOLDER|~/var-fslc-yocto}}/uboot-imx/
{{#ifexpr: {{#rpos: {{#var:NXP_FIRMWARE}} | firmware-imx-8.1.1}} >= 0
  $ make mrproper
| <!-- SECO is in NXP_FIRMWARE for original Sumo release -->&nbsp;
  Choose build for SD card or NAND flash:
Download SECO firmware:
  $ make {{#var:U-BOOT_SD_DEFCONFIG|make mx6ul_var_dart_mmc_defconfig}}
$ wget {{#var:NXP_FIRMWARE_URL}}/{{#var:NXP_FIRMWARE}}.bin
  or
$ chmod +x {{#var:NXP_FIRMWARE}}.bin
  $ make {{#var:U-BOOT_NAND_DEFCONFIG|make mx6ul_var_dart_nand_defconfig}}
$ ./{{#var:NXP_FIRMWARE}}.bin
  $ make -j4
$ cp {{#var:NXP_FIRMWARE}}/firmware/seco/{{#var:SECO_FIRMWARE}} .
| <!-- SECO is in SECO_FIRMWARE for other releases --> &nbsp;
Download SECO firmware:
$ wget {{#var:SECO_FIRMWARE_URL}}/{{#var:SECO_FIRMWARE}}.bin
$ chmod +x {{#var:SECO_FIRMWARE}}.bin
$ ./{{#var:SECO_FIRMWARE}}.bin
$ cp {{#var:SECO_FIRMWARE}}/firmware/seco/mx8q*-ahab-container.img .
}}
|
Download DDR {{#ifeq: {{#var:SOC}}|mx8mq|and HDMI|}} firmware:
$ wget {{#var:NXP_FIRMWARE_URL}}/{{#var:NXP_FIRMWARE}}.bin
$ chmod +x {{#var:NXP_FIRMWARE}}.bin
$ ./{{#var:NXP_FIRMWARE}}.bin
$ cp {{#var:NXP_FIRMWARE}}/firmware/ddr/synopsys/* .
{{#ifeq: {{#var:SOC}}|mx8mq|$ cp {{#var:NXP_FIRMWARE}}/firmware/hdmi/cadence/signed_* .|}}
}}
 
{{#ifeq: {{#var:SOC_FAMILY}}|imx8|
Download and build imx_mkimage:
$ git clone {{#var:NXP_IMX_GIT}}/imx-mkimage -b {{#var:NXP_IMX_BRANCH}}
  $ cd imx-mkimage
$ make
$ cp mkimage_imx8 {{#var:IMX_MKIMAGE_SOC}}/soc.mak {{#var:IMX_MKIMAGE_SOC}}/*.sh scripts/pad_image.sh ..
$ cd ..
|
Download imx_mkimage:
$ git clone {{#var:NXP_IMX_GIT}}/imx-mkimage -b {{#var:NXP_IMX_BRANCH}}
$ cp imx-mkimage/iMX8M/*.c imx-mkimage/iMX8M/*.sh {{#ifeq: {{#var:FSL_BSP_VERSION}}|L4.14.78-1.0.0_ga|imx-mkimage/iMX8M/soc.mak|}} {{#ifeq: {{#var:YOCTO_NAME}}|Morty||imx-mkimage/scripts/*.sh}} .
}}
 
Download and build ATF:<!--  
Use VARISCITE_ATF_GIT from yocto platform customization if exists for Variscite hosted repo, else default to NXP:
-->
$ git clone {{#var:VARISCITE_ATF_GIT | {{#var:NXP_IMX_GIT}}/imx-atf}} -b {{#var:VARISCITE_ATF_BRANCH | {{#var:NXP_IMX_BRANCH}}}}
{{#ifeq: {{#var:SOC_FAMILY}}|imx8m|
$ git clone {{#var:META_VARISCITE_GIT}} -b {{#var:META_VARISCITE_BRANCH}}
{{#ifeq: {{#var:FSL_BSP_VERSION}}|L4.14.78-1.0.0_ga||
{{#if: {{#var:IMX_MKIMAGE_SOC_PATCH}}|
$ cd imx-mkimage
$ git apply ../{{#var:META_VARISCITE_REPO}}/{{#var:IMX_MKIMAGE_SOC_PATCH}}<!--
  -->{{#varexists:IMX_MKIMAGE_SOC_PATCH_1 |
<br>$ git apply ../{{#var:META_VARISCITE_REPO}}/{{#var:IMX_MKIMAGE_SOC_PATCH_1}}
}}<!--
  -->{{#varexists:IMX_MKIMAGE_SOC_PATCH_2 |
<br>$ git apply ../{{#var:META_VARISCITE_REPO}}/{{#var:IMX_MKIMAGE_SOC_PATCH_2}}
}}
$ cp iMX8M/soc.mak ..
$ cd ..
|
$ cp {{#var:META_VARISCITE_REPO}}/recipes-bsp/imx-mkimage/files/soc.mak .}}
}}
|
}}
$ cd imx-atf {{#if: {{#var:VARISCITE_ATF_GIT}}||&nbsp;
{{#ifeq: {{#var:SOC_FAMILY}}| imx8m |
{{#ifeq: {{#var:FSL_BSP_VERSION}}| L4.14.78-1.0.0_ga | $ git apply ../{{#var:META_VARISCITE_REPO}}/recipes-bsp/imx-atf/imx-atf/* |
{{#ifeq: {{#var:SOC}}|mx8mn| $ git apply ../{{#var:META_VARISCITE_REPO}}/recipes-bsp/imx-atf/imx-atf/* |
{{#ifeq: {{#var:SOC}}|mx8mp| $ git apply ../{{#var:META_VARISCITE_REPO}}/recipes-bsp/imx-atf/imx-atf/* |
{{#ifeq: {{#var:SOC}}|mx8mm| $ git apply ../{{#var:META_VARISCITE_REPO}}/recipes-bsp/imx-atf/imx-atf/imx8mm* ../{{#var:META_VARISCITE_REPO}}/recipes-bsp/imx-atf/imx-atf/imx8m-* |
{{#ifeq: {{#var:SOC}}|mx8mq| $ git apply ../{{#var:META_VARISCITE_REPO}}/recipes-bsp/imx-atf/imx-atf/imx8m-*|}} }} }} }} }} }} }}
$ source {{#var:TOOLCHAIN_LOCATION}}
$ unset LDFLAGS
  $ make PLAT={{#var:IMX_ATF_PLAT}} bl31
  $ cp build/{{#var:IMX_ATF_PLAT}}/release/bl31.bin ..
$ cd ..
 
Copy U-Boot binaries:
$ cp ../tools/mkimage mkimage_uboot
$ cp ../u-boot.bin .
{{#ifeq: {{#var:SOC_FAMILY}}|imx8m|
{{#ifeq: {{#var:FSL_BSP_VERSION}}| L4.14.78-1.0.0_ga |
$ cp ../u-boot-nodtb.bin ../spl/u-boot-spl.bin ../arch/arm/dts/{{#var:U-BOOT_DTB_FILE|{{#var:DEFAULT_DTB}}}} .
|
{{#ifeq: {{#var:SOC}}|mx8mm|
  $ cp ../u-boot-nodtb.bin ../spl/u-boot-spl.bin ../arch/arm/dts/{{#var:U-BOOT_DTB_DART}} ../arch/arm/dts/{{#var:U-BOOT_DTB_SOM}} {{#varexists:U-BOOT_DTB_SOM_10 | ../arch/arm/dts/{{#var:U-BOOT_DTB_SOM_10}} |}} .
  |
{{#ifeq: {{#var:SOC}}|mx8mn|
  $ cp ../u-boot-nodtb.bin ../spl/u-boot-spl.bin ../arch/arm/dts/{{#var:U-BOOT_DTB_SOM}} .
|
{{#ifeq: {{#var:SOC}}|mx8mp|
  $ cp ../u-boot-nodtb.bin ../spl/u-boot-spl.bin ../arch/arm/dts/{{#var:U-BOOT_DTB_DART}} ../arch/arm/dts/{{#var:U-BOOT_DTB_SOM}} .
|


$ cp ../u-boot-nodtb.bin ../spl/u-boot-spl.bin ../arch/arm/dts/{{#var:U-BOOT_DTB_FILE|{{#var:DEFAULT_DTB}}}} .
}} }} }} }}
|
$ cp ../spl/u-boot-spl.bin .
}}


Flash U-Boot to the SD card:  
{{#ifeq: {{#var:SOC_FAMILY}}|imx8|
<pre>
{{#ifeq: {{#var:SOC}}|mx8qxp|
$ sudo dd if=SPL of=/dev/sdX bs=1K seek=1; sync
Depending on i.MX8QXP SOC revision different instructions should be used to build boot image.<br>
$ sudo dd if=u-boot.img of=/dev/sdX bs=1K seek=69; sync
The SOC revision is printed by u-boot as follows
(Replace /dev/sdX with the correct device)
CPU:  Freescale i.MX8QXP revB A35 at 1200 MHz at 36C
</pre>
or
CPU:  Freescale i.MX8QXP revC A35 at 1200 MHz at 36C


In case of UBI copy it to the SD card (assuming you are using our recovery SD card):  
Build boot image for SOC revision B:
<pre>
$ make -f soc.mak clean
$ sudo cp SPL /media/rootfs/opt/images/Yocto/SPL-nand
$ make -f soc.mak SOC={{#var:IMX_MKIMAGE_SOC}} REV=B0 MKIMG=./mkimage_imx8 PAD_IMAGE=./pad_image.sh flash_spl
$ sudo cp u-boot.img /media/rootfs/opt/images/Yocto/u-boot-nand-2015.04-r0.img
$ mv flash.bin {{#var:U-BOOT_SD_IMAGE_NAME}}
or (depend on your build):
$ sudo cp SPL /media/rootfs/opt/images/Yocto/SPL-sd
$ sudo cp u-boot.img /media/rootfs/opt/images/Yocto/u-boot-sd-2015.04-r0.img
</pre>
<br>
<br>
Build boot image for SOC revision C:
$ make -f soc.mak clean
$ make -f soc.mak SOC={{#var:IMX_MKIMAGE_SOC}} REV=C0 MKIMG=./mkimage_imx8 PAD_IMAGE=./pad_image.sh flash_spl
$ mv flash.bin {{#var:U-BOOT_SD_IMAGE_NAME}}
|
Build boot image:
$ make -f soc.mak clean
$ make -f soc.mak SOC={{#var:IMX_MKIMAGE_SOC}} MKIMG=./mkimage_imx8 PAD_IMAGE=./pad_image.sh flash_spl
$ mv flash.bin {{#var:U-BOOT_SD_IMAGE_NAME}}
}}
|
{{#ifeq: {{#var:SOC}}|mx8mq|
Build boot image:
$ make -f soc.mak clean
$ make -f soc.mak SOC={{#var:IMX_MKIMAGE_SOC}} dtbs={{#var:U-BOOT_DTB_FILE|{{#var:DEFAULT_DTB}}}} MKIMG=./mkimage_imx8 PAD_IMAGE=./pad_image.sh CC=gcc OUTIMG={{#var:U-BOOT_SD_IMAGE_NAME}} flash_evk
|
{{#ifeq: {{#var:SOC}}|mx8mm|
{{#ifeq: {{#var:FSL_BSP_VERSION}}| L4.14.78-1.0.0_ga |
Build boot image:
$ make -f soc.mak clean
$ make -f soc.mak SOC={{#var:IMX_MKIMAGE_SOC}} dtbs={{#var:DEFAULT_DTB}} MKIMG=./mkimage_imx8 PAD_IMAGE=./pad_image.sh CC=gcc OUTIMG={{#var:U-BOOT_SD_IMAGE_NAME}} flash_evk
|
Build boot image:
$ make -f soc.mak clean
$ make -f soc.mak SOC={{#var:IMX_MKIMAGE_SOC}} dtbs="{{#var:U-BOOT_DTB_DART}} {{#var:U-BOOT_DTB_SOM}} {{#var:U-BOOT_DTB_SOM_10}}" MKIMG=./mkimage_imx8 PAD_IMAGE=./pad_image.sh CC=gcc OUTIMG={{#var:U-BOOT_SD_IMAGE_NAME}} flash_lpddr4_ddr4_evk
}}
|
{{#ifeq: {{#var:SOC}}|mx8mn|
Build boot image:
$ make -f soc.mak clean
$ make -f  soc.mak  SOC={{#var:IMX_MKIMAGE_SOC}}  dtbs="{{#var:U-BOOT_DTB_SOM}}  {{#var:U-BOOT_DTB_SOM_10}}" MKIMG=./mkimage_imx8 PAD_IMAGE=./pad_image.sh CC=gcc OUTIMG={{#var:U-BOOT_SD_IMAGE_NAME}} flash_ddr4_evk
|
{{#ifeq: {{#var:SOC}}|mx8mp|
Build boot image:
$ make -f soc.mak clean
$ make  -f soc.mak  SOC={{#var:IMX_MKIMAGE_SOC}}  dtbs="{{#var:U-BOOT_DTB_DART}}  {{#var:U-BOOT_DTB_SOM}}"  MKIMG=./mkimage_imx8 PAD_IMAGE=./pad_image.sh  CC=gcc OUTIMG={{#var:U-BOOT_SD_IMAGE_NAME}} flash_evk
|}} }} }} }} }} }}
= Install the built U-Boot on an SD card =
{{#ifeq: {{#var:SOC_SERIES}}|imx8|
<br>
$ sudo dd if={{#var:U-BOOT_SD_IMAGE_NAME}} of=/dev/sdX bs=1K seek={{#var:U-BOOT_OFFSET}} conv=fsync
|
{{#ifeq: {{#var:SPL_SD_IMAGE_NAME}} | N/A
|<br>
$ sudo dd if={{#var:U-BOOT_IMAGE_NAME}} of=/dev/sdX bs=1K seek=1; sync
|<br>
$ sudo dd if=SPL of=/dev/sdX bs=1K seek=1; sync
$ sudo dd if=u-boot.img of=/dev/sdX bs=1K seek=69; sync
}}
}}
(Replace /dev/sdX with the correct device)
If you want to use our recovery SD card to flash the built U-Boot to NAND flash/eMMC, then copy it to the appropriate location in the SD card:
{{#ifeq: {{#var:SPL_SD_IMAGE_NAME}} | N/A
|<br>
$ sudo cp {{#var:U-BOOT_IMAGE_NAME}} /media/rootfs/opt/images/…
|<br>
$ sudo cp SPL /media/rootfs/opt/images/…
$ sudo cp u-boot.img /media/rootfs/opt/images/…
}}
And eject the SD card gracefully from host machine.
And eject the SD card gracefully from host machine.
{{Note|Note: If you manually upgrade an existing U-Boot, and you have an old environment saved, it is a good idea to reset your environment to the new default (see [[U-Boot 4.1.15 features#Environment handling commands|Environment handling commands]])}}


= Update your U-Boot out of Yocto tree =
= Update your U-Boot out of Yocto tree =
<pre>
<pre>
$ git fetch origin
$ git pull
$ git pull
</pre>
</pre>

Revision as of 11:49, 24 July 2022

Yocto Build U-Boot from source code

Toolchain installation for out of Yocto builds

To install the toolchain, follow Yocto Toolchain installation.

Build U-Boot out of Yocto tree

Obtain sources:

$ git clone https://github.com/varigit/uboot-imx.git -b imx_v2015.04_4.1.15_1.1.0_ga_var03
$ cd uboot-imx

Configure compilation environment:

$ source /opt/fslc-x11/2.2.1/environment-setup-armv7at2hf-neon-fslc-linux-gnueabi

Cleanup everything:

$ make mrproper

Select one of the following configurations:

For booting from SD card/eMMC:
$ make mx6var_som_sd_defconfig

For booting from NAND flash:
$ make mx6var_som_nand_defconfig

Build U-Boot:

$ make -j$(nproc)


Install the built U-Boot on an SD card


$ sudo dd if=SPL of=/dev/sdX bs=1K seek=1; sync
$ sudo dd if=u-boot.img of=/dev/sdX bs=1K seek=69; sync

(Replace /dev/sdX with the correct device)

If you want to use our recovery SD card to flash the built U-Boot to NAND flash/eMMC, then copy it to the appropriate location in the SD card:

$ sudo cp SPL /media/rootfs/opt/images/…
$ sudo cp u-boot.img /media/rootfs/opt/images/…

And eject the SD card gracefully from host machine.


Note: If you manually upgrade an existing U-Boot, and you have an old environment saved, it is a good idea to reset your environment to the new default (see Environment handling commands)

Update your U-Boot out of Yocto tree

$ git pull