Yocto Build U-Boot: Difference between revisions

From Variscite Wiki
No edit summary
No edit summary
Line 42: Line 42:
{{#ifeq: {{#var:SOC_SERIES}} | imx8 |
{{#ifeq: {{#var:SOC_SERIES}} | imx8 |
= Build boot image =
= Build boot image =
The final boot image contains multiple firmware files. All of them are created during the Yocto build. The following procedure builds final image:
The final boot image contains multiple firmware files. The following procedure builds the final image.


  # Copy imx-boot-tools
  # Create imx-boot-tools directory
  $ cp -a {{#var:BUILD_FOLDER}}/{{#var:BUILD_FOLDER_XWAYLAND}}/tmp/deploy/images/{{#var:MACHINE_NAME}}/imx-boot-tools .
  $ mkdir imx-boot-tools
$ cd imx-boot-tools


  # Copy u-boot, SPL and DTB
  # Download DDR and HDMI firmware
  $ cd imx-boot-tools
  $ wget {{#var:NXP_FIRMWARE_URL}}/{{#var:NXP_FIRMWARE}}.bin
  $ rm -f u-boot* *.dtb
  $ chmod +x {{#var:NXP_FIRMWARE}}.bin
  $ cp ../u-boot.bin ../u-boot-nodtb.bin ../spl/u-boot-spl.bin ../arch/arm/dts/imx8m-var-dart.dtb .
  $ ./{{#var:NXP_FIRMWARE}}.bin --auto-accept --force
$ cp {{#var:NXP_FIRMWARE}}/firmware/ddr/synopsys/lpddr4_pmu_train_* .
$ cp {{#var:NXP_FIRMWARE}}/firmware/hdmi/cadence/signed_* .
   
   
  # Build SPL+DDR firmware image: u-boot-spl-ddr.bin
  # Download imx_mkimage
  $ objcopy -I binary -O binary --pad-to 0x8000 --gap-fill=0x0 lpddr4_pmu_train_1d_imem.bin lpddr4_pmu_train_1d_imem_pad.bin
  $ git clone {{#var:NXP_IMX_GIT}}/imx-mkimage -b {{#var:NXP_IMX_BRANCH}}
  $ objcopy -I binary -O binary --pad-to 0x4000 --gap-fill=0x0 lpddr4_pmu_train_1d_dmem.bin lpddr4_pmu_train_1d_dmem_pad.bin
  $ cp imx-mkimage/iMX8M/*.c imx-mkimage/iMX8M/*.sh imx-mkimage/iMX8M/soc.mak .
$ objcopy -I binary -O binary --pad-to 0x8000 --gap-fill=0x0 lpddr4_pmu_train_2d_imem.bin lpddr4_pmu_train_2d_imem_pad.bin
  $ if [ -f imx-mkimage/scripts/pad_image.sh ]; then cp imx-mkimage/scripts/pad_image.sh .; fi
  $ cat lpddr4_pmu_train_1d_imem_pad.bin lpddr4_pmu_train_1d_dmem_pad.bin > lpddr4_pmu_train_1d_fw.bin
$ cat lpddr4_pmu_train_2d_imem_pad.bin lpddr4_pmu_train_2d_dmem.bin > lpddr4_pmu_train_2d_fw.bin
$ cat u-boot-spl.bin lpddr4_pmu_train_1d_fw.bin lpddr4_pmu_train_2d_fw.bin > u-boot-spl-ddr.bin
$ rm -f lpddr4_pmu_train_1d_fw.bin lpddr4_pmu_train_2d_fw.bin lpddr4_pmu_train_1d_imem_pad.bin lpddr4_pmu_train_1d_dmem_pad.bin lpddr4_pmu_train_2d_imem_pad.bin


  # Build u-boot+ATF firmware image: u-boot-atf.bin
  # Download and build ATF
  $ mv bl31-imx8mq.bin bl31.bin
$ git clone {{#var:NXP_IMX_GIT}}/imx-atf -b {{#var:NXP_BRANCH}}
  $ cp bl31.bin u-boot-atf.bin
$ git clone ({#var:META_VARISCITE_GIT}} -b {{#var:META_VARISCITE_BRANCH}}
  $ dd if=u-boot.bin of=u-boot-atf.bin bs=1K seek=128
$ cd imx-atf
$ source {{#var:TOOLCHAIN_LOCATION}}
$ export LDFLAGS=
$ git apply ../meta-variscite-imx/recipes-bsp/imx-atf/imx-atf/*
  $ make PLAT={{#var:IMX_ATF_PLAT}} bl31
  $ cp build/{{#var:IMX_ATF_PLAT}}/release/bl31.bin ..
  $ cd ..


  # Build u-boot+DTB+ATF+HDMI firmware FIT image
  # Copy u-boot binaries
  $ ./mkimage_fit_atf.sh imx8m-var-dart.dtb > u-boot.its
  $ cp ../u-boot.bin .
  $ ./mkimage_uboot -E -p 0x3000 -f u-boot.its u-boot.itb
  $ cp ../u-boot-nodtb.bin .
  $ rm -f u-boot.its
$ cp ../spl/u-boot-spl.bin .
  $ cp ../arch/arm/dts/{{#var:DEFAULT_DTB}} .
$ cp ../tools/mkimage mkimage_uboot


  # Build final image
  # Build boot image
  $ ./mkimage_imx8 -fit -signed_hdmi signed_hdmi_imx8m.bin -loader u-boot-spl-ddr.bin 0x7E1000 -second_loader u-boot.itb 0x40200000 0x60000 -out {{#var:U-BOOT_SD_IMAGE_NAME}}
  $ make -f soc.mak clean
$ make -f soc.mak SOC={{#var:IMX_MKIMAGE_SOC}} dtbs={{#var:DEFAULT_DTB}} PAD_IMAGE=./pad_image.sh CC=gcc OUTIMG={{#var:U-BOOT_SD_IMAGE_NAME}} flash_evk
}}
}}



Revision as of 09:21, 28 May 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_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 -j4
-b morty
$ cd imx-atf
$ source /opt/fslc-x11/2.2.1/environment-setup-armv7at2hf-neon-fslc-linux-gnueabi
$ export LDFLAGS=
$ git apply ../meta-variscite-imx/recipes-bsp/imx-atf/imx-atf/*
$ make PLAT= bl31
$ cp build//release/bl31.bin ..
$ cd ..
# Copy u-boot binaries
$ cp ../u-boot.bin .
$ cp ../u-boot-nodtb.bin .
$ cp ../spl/u-boot-spl.bin .
$ cp ../arch/arm/dts/ .
$ cp ../tools/mkimage mkimage_uboot
# Build boot image
$ make -f soc.mak clean
$ make -f soc.mak SOC= dtbs= PAD_IMAGE=./pad_image.sh CC=gcc OUTIMG=u-boot.img-sd flash_evk

}}

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