Yocto Build U-Boot: Difference between revisions

From Variscite Wiki
No edit summary
No edit summary
Line 1: Line 1:
<!-- Set release according to "release" parameter in URL and use RELEASE_MORTY_V1.0_VAR-SOM-MX6 as default
<!-- Set release according to "release" parameter in URL and use RELEASE_MORTY_V1.0_VAR-SOM-MX6 as default
--> {{#vardefine:RELEASE_PARAM|{{#urlget:release}}}} <!--
--> {{#vardefine:RELEASE_PARAM|{{#urlget:release}}}} <!--
--> {{#lst:Yocto_Platform_Customization|{{#var:RELEASE_PARAM|RELEASE_MORTY_V1.0_VAR-SOM-MX6}}}} <!--
--> {{#lst:Yocto_Platform_Customization|{{#var:RELEASE_PARAM|RELEASE_SUMO_V1.0_VAR-SOM-MX8X}}}} <!--
--> {{PageHeader|Yocto Build U-Boot from source code}} {{DocImage|category1=Yocto|category2={{#var:HARDWARE_NAME}}}} __toc__
--> {{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 =
Line 44: Line 44:
The final boot image contains multiple firmware files. The following procedure builds the final image.
The final boot image contains multiple firmware files. The following procedure builds the final image.


Create imx-boot-tools directory
Create imx-boot-tools directory:
  $ mkdir imx-boot-tools
  $ mkdir imx-boot-tools
  $ cd imx-boot-tools
  $ cd imx-boot-tools
Line 50: Line 50:
{{#ifeq: {{#var:SOC_FAMILY}} | imx8 |
{{#ifeq: {{#var:SOC_FAMILY}} | imx8 |


Download SC firmware
Obtain SC firmware:<br>
  $ git clone {{#var:META_VARISCITE_GIT}} -b {{#var:META_VARISCITE_BRANCH}}
Either build it by following the {{Varlink|Yocto_Build_SCFW|{{#var:RELEASE_LINK}}|Build SCFW from source code}} page, or just download the pre-built binary by running:
$ cp meta-variscite-imx/recipes-bsp/imx-sc-firmware/imx-sc-firmware/{{#var:SC_FIRMWARE}} scfw_tcm.bin
  $ 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


Download SECO firmware
Download SECO firmware:
  $ wget {{#var:NXP_FIRMWARE_URL}}/{{#var:NXP_FIRMWARE}}.bin
  $ wget {{#var:NXP_FIRMWARE_URL}}/{{#var:NXP_FIRMWARE}}.bin
  $ chmod +x {{#var:NXP_FIRMWARE}}.bin
  $ chmod +x {{#var:NXP_FIRMWARE}}.bin
Line 60: Line 60:
  $ cp {{#var:NXP_FIRMWARE}}/firmware/seco/{{#var:SECO_FIRMWARE}} .
  $ cp {{#var:NXP_FIRMWARE}}/firmware/seco/{{#var:SECO_FIRMWARE}} .
|
|
Download DDR and HDMI firmware
Download DDR and HDMI firmware:
  $ wget {{#var:NXP_FIRMWARE_URL}}/{{#var:NXP_FIRMWARE}}.bin
  $ wget {{#var:NXP_FIRMWARE_URL}}/{{#var:NXP_FIRMWARE}}.bin
  $ chmod +x {{#var:NXP_FIRMWARE}}.bin
  $ chmod +x {{#var:NXP_FIRMWARE}}.bin
Line 69: Line 69:


{{#ifeq: {{#var:SOC_FAMILY}}|imx8|
{{#ifeq: {{#var:SOC_FAMILY}}|imx8|
Download and build imx_mkimage
Download and build imx_mkimage:
  $ git clone {{#var:NXP_IMX_GIT}}/imx-mkimage -b {{#var:NXP_IMX_BRANCH}}
  $ git clone {{#var:NXP_IMX_GIT}}/imx-mkimage -b {{#var:NXP_IMX_BRANCH}}
  $ cd imx-mkimage
  $ cd imx-mkimage
Line 76: Line 76:
  $ cd ..
  $ cd ..
|
|
Download imx_mkimage
Download imx_mkimage:
  $ git clone {{#var:NXP_IMX_GIT}}/imx-mkimage -b {{#var:NXP_IMX_BRANCH}}
  $ git clone {{#var:NXP_IMX_GIT}}/imx-mkimage -b {{#var:NXP_IMX_BRANCH}}
  $ cp imx-mkimage/iMX8M/*.c imx-mkimage/iMX8M/*.sh imx-mkimage/iMX8M/soc.mak {{#ifeq: {{#var:YOCTO_NAME}}|Morty||imx-mkimage/scripts/pad_image.sh}} .
  $ cp imx-mkimage/iMX8M/*.c imx-mkimage/iMX8M/*.sh imx-mkimage/iMX8M/soc.mak {{#ifeq: {{#var:YOCTO_NAME}}|Morty||imx-mkimage/scripts/pad_image.sh}} .
}}
}}


Download and build ATF
Download and build ATF:
  $ git clone {{#var:NXP_IMX_GIT}}/imx-atf -b {{#var:NXP_IMX_BRANCH}}
  $ git clone {{#var:NXP_IMX_GIT}}/imx-atf -b {{#var:NXP_IMX_BRANCH}}
  {{#ifeq: {{#var:SOC_FAMILY}}|imx8m|$ git clone {{#var:META_VARISCITE_GIT}} -b {{#var:META_VARISCITE_BRANCH}}|}}
  {{#ifeq: {{#var:SOC_FAMILY}}|imx8m|$ git clone {{#var:META_VARISCITE_GIT}} -b {{#var:META_VARISCITE_BRANCH}}|}}
Line 92: Line 92:
  $ cd ..
  $ cd ..


Copy U-Boot binaries
Copy U-Boot binaries:
  $ cp ../tools/mkimage mkimage_uboot
  $ cp ../tools/mkimage mkimage_uboot
  $ cp ../u-boot.bin .
  $ cp ../u-boot.bin .
Line 98: Line 98:
   
   
{{#ifeq: {{#var:SOC_FAMILY}}|imx8|
{{#ifeq: {{#var:SOC_FAMILY}}|imx8|
Build boot image
Build boot image:
  $ make -f soc.mak clean
  $ make -f soc.mak clean
  $ make -f soc.mak SOC={{#var:IMX_MKIMAGE_SOC}} MKIMG=./mkimage_imx8 PAD_IMAGE=./pad_image.sh flash
  $ make -f soc.mak SOC={{#var:IMX_MKIMAGE_SOC}} MKIMG=./mkimage_imx8 PAD_IMAGE=./pad_image.sh flash
  $ mv flash.bin {{#var:U-BOOT_SD_IMAGE_NAME}}
  $ mv flash.bin {{#var:U-BOOT_SD_IMAGE_NAME}}
|
|
Build boot image
Build boot image:
  $ make -f soc.mak clean  
  $ 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
  $ 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

Revision as of 10:16, 28 August 2019

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_v2018.03_4.14.98_2.0.0_ga_var01
$ cd uboot-imx

Configure compilation environment:

$ source /opt/fsl-imx-xwayland/4.14-sumo/environment-setup-aarch64-poky-linux

Cleanup everything:

$ make mrproper


Select configuration:

$ make imx8qxp_var_som_defconfig

Build U-Boot:

$ make -j4

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

Obtain SC firmware:
Either build it by following the Build SCFW from source code page, or just download the pre-built binary by running:

$ wget https://github.com/varigit/meta-variscite-imx/raw/sumo-imx-4.14.98-var01/recipes-bsp/imx-sc-firmware/imx-sc-firmware/mx8qx-var-som-scfw-tcm.bin -O scfw_tcm.bin

Download SECO firmware:

$ wget https://www.nxp.com/lgfiles/NMG/MAD/YOCTO/firmware-imx-8.1.1.bin
$ chmod +x firmware-imx-8.1.1.bin
$ ./firmware-imx-8.1.1.bin --auto-accept --force
$ cp firmware-imx-8.1.1/firmware/seco/mx8qx-ahab-container.img .

Download and build imx_mkimage:

$ git clone https://github.com/nxp-imx/imx-mkimage -b imx_4.14.98_2.0.0_ga
$ cd imx-mkimage
$ make 
$ cp mkimage_imx8 iMX8QX/soc.mak iMX8QX/*.sh scripts/pad_image.sh ..
$ cd ..

Download and build ATF:

$ git clone https://github.com/nxp-imx/imx-atf -b imx_4.14.98_2.0.0_ga

$ cd imx-atf
$ source /opt/fsl-imx-xwayland/4.14-sumo/environment-setup-aarch64-poky-linux
$ export LDFLAGS=

$ make PLAT=imx8qx bl31
$ cp build/imx8qx/release/bl31.bin ..
$ cd ..

Copy U-Boot binaries:

$ cp ../tools/mkimage mkimage_uboot
$ cp ../u-boot.bin .


Build boot image:

$ make -f soc.mak clean
$ make -f soc.mak SOC=iMX8QX MKIMG=./mkimage_imx8 PAD_IMAGE=./pad_image.sh flash
$ mv flash.bin imx-boot-sd.bin

Install the built U-Boot on an SD card


$ sudo dd if=imx-boot-sd.bin of=/dev/sdX bs=1K seek=32 conv=fsync

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 imx-boot-sd.bin /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