Yocto Build Linux: Difference between revisions

From Variscite Wiki
No edit summary
(Fix Linux customization link for Debian)
 
(11 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<!-- Set release according to "release" parameter in URL and use MORTY_V1.0_DART-6UL as default
<!-- Set release according to "release" parameter in URL and use RELEASE_MORTY_V1.0_DART-6UL as default
--> {{#vardefine:RELEASE_PARAM|{{#urlget:release|RELEASE_MORTY_V1.0_DART-6UL}}}} <!--
--> {{INIT_RELEASE_PARAM|RELEASE_MORTY_V1.0_DART-6UL}}<!--
--> {{#lst:Yocto_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{#lst:Yocto_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{#lst:B2QT_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{#lst:B2QT_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
--> {{PageHeader|Build Linux from source code}} {{DocImage|category1=Yocto|category2={{#var:HARDWARE_NAME}}}} __toc__
--> {{#lst:Debian_Platform_Customization|{{#var:RELEASE_PARAM}}}} <!--
{{note|It is recommended to build the kernel image using Yocto (see the {{Varlink|Yocto Customizing the Linux kernel|{{#var:RELEASE_LINK}}|Customizing the Linux kernel}} page) instead of using the direct method described in this page.<br>
--> {{#vardefine:PLATFORM_OS|Yocto}}
This is because some of the Yocto packages may depend on the kernel, like the WiFi module that is built from outside of the kernel source tree on some of the Yocto releases.}}
    {{#vardefine:CUSTOMIZE_LINUX_KERNEL|Yocto Customizing the Linux kernel}} <!-- Default to Yocto
--> {{#varexists:DEBIAN_NAME |
    {{#vardefine:PLATFORM_OS|Debian}}
    {{#vardefine:CUSTOMIZE_LINUX_KERNEL|Debian Edit Modify Build and Flash Kernel}} }} <!-- Debian
--> {{PageHeader|Build Linux from source code}} {{DocImage|category1=Yocto|category2=Debian}} <!--
--> [[category:{{#var:HARDWARE_NAME}}]] __toc__
{{note|It is recommended to build the kernel image using {{#switch:{{#var:PLATFORM_OS}}|Debian=the Debian build script|#default=Yocto}} (see the {{Varlink|{{#var:CUSTOMIZE_LINUX_KERNEL}}|{{#var:RELEASE_LINK}}|Customizing the Linux kernel}} page) instead of using the direct method described in this page.<br>
This is because some of the {{#var:PLATFORM_OS}} packages may depend on the kernel, like the WiFi module that is built from outside of the kernel source tree on some of the {{#var:PLATFORM_OS}} releases.}}


= Toolchain installation for out of Yocto builds =
= Toolchain installation for out of {{#var:PLATFORM_OS}} builds =
To install the toolchain, follow the {{Varlink2|{{#var:PLATFORM_OS}} Toolchain installation|{{#var:RELEASE_LINK}}}} guide.


To install the toolchain, follow {{Varlink2|Yocto Toolchain installation|{{#var:RELEASE_LINK}}}}.
= Build Linux out of {{#var:PLATFORM_OS}} tree =
 
= Build Linux out of Yocto tree =


Get the Linux source code:  
Get the Linux source code:  
Line 19: Line 25:


Build the Linux kernel:
Build the Linux kernel:
  $ source {{#var:TOOLCHAIN_LOCATION}}{{#ifeq: {{#var:SOC_SERIES}}|imx8|<br>$ unset LDFLAGS|}}
{{#switch:{{#var:PLATFORM_OS}}
|Yocto=
<br>
  $ source {{#var:TOOLCHAIN_LOCATION}}{{#switch: {{#var:SOC_SERIES}}|imx8|mx93=<br>$ unset LDFLAGS|}}
|Debian=
<br>
$ export ARCH={{#var:ARCH}}
$ export CROSS_COMPILE={{#var:BUILD_FOLDER}}/toolchain/{{#var:TOOLCHAIN}}/{{#var:CROSS_COMPILE}}
}}


  $ make mrproper
  $ make mrproper
Line 39: Line 53:
  $ make -j4 dtbs
  $ make -j4 dtbs
<!-- Attach DTB section from specific release-->
<!-- Attach DTB section from specific release-->
{{#lst:Yocto_Platform_Customization|{{#var:KERNEL_DTB_SECTION}}}}
{{#lst:{{#var:PLATFORM_OS}}_Platform_Customization|{{#var:KERNEL_DTB_SECTION}}}}


Notes:<br>
Notes:<br>
Line 48: Line 62:


Copy the {{#var:KERNEL_IMAGE}} and device trees to the SD card boot partition, and install the modules in the SD card rootfs partition.<br>
Copy the {{#var:KERNEL_IMAGE}} and device trees to the SD card boot partition, and install the modules in the SD card rootfs partition.<br>
Assuming the {{#ifeq: {{#var:SOC_SERIES}}|imx8||boot partition is mounted on /media/user/{{#var:EMMC_FAT_PARTITION_NAME}} and the&nbsp;}}rootfs partition is mounted on /media/user/rootfs:
Assuming the {{#switch: {{#var:SOC_SERIES}}|imx8|imx9=|boot partition is mounted on /media/user/{{#var:EMMC_FAT_PARTITION_NAME}} and the&nbsp;}}rootfs partition is mounted on /media/user/rootfs:
{{#ifeq: {{#var:SOC_SERIES}}|imx8 |
{{#switch: {{#var:SOC_SERIES}}|imx8|imx9=
  <br>
  <br>
  Install the kernel image and modules:
  Install the kernel image and modules:
Line 59: Line 73:
  Install the device trees:
  Install the device trees:
  {{#ifeq: {{#var:YOCTO_NAME}}|Morty|$ for dtb in arch/arm64/boot/dts/variscite/*.dtb; do sudo cp $dtb /media/user/rootfs/boot/devicetree-Image.gz-$(basename $dtb); done | $ sudo cp arch/arm64/boot/dts/freescale/*imx*var*.dtb /media/user/rootfs/boot/}}
  {{#ifeq: {{#var:YOCTO_NAME}}|Morty|$ for dtb in arch/arm64/boot/dts/variscite/*.dtb; do sudo cp $dtb /media/user/rootfs/boot/devicetree-Image.gz-$(basename $dtb); done | $ sudo cp arch/arm64/boot/dts/freescale/*imx*var*.dtb /media/user/rootfs/boot/}}
|
|=
  <br>
  <br>
  Install the kernel image and modules:
  Install the kernel image and modules:
Line 71: Line 85:
  {{#ifeq: {{#var:HARDWARE_NAME}} | VAR-SOM-MX6 | $ cp arch/arm/boot/dts/imx6q*var*.dtb  /media/user/{{#var:EMMC_FAT_PARTITION_NAME}}<br>$ cp arch/arm/boot/dts/imx6dl*var*.dtb /media/user/{{#var:EMMC_FAT_PARTITION_NAME}}}}
  {{#ifeq: {{#var:HARDWARE_NAME}} | VAR-SOM-MX6 | $ cp arch/arm/boot/dts/imx6q*var*.dtb  /media/user/{{#var:EMMC_FAT_PARTITION_NAME}}<br>$ cp arch/arm/boot/dts/imx6dl*var*.dtb /media/user/{{#var:EMMC_FAT_PARTITION_NAME}}}}
Notes:<br>
Notes:<br>
* If you are using our {{Varlink2|Yocto Recovery SD card|{{#var:RELEASE_LINK}}}}, and you want the NAND flash/eMMC installation process to be updated as well as the SD card boot itself, you need to also update the /opt/images/Yocto directory.
* If you are using our {{Varlink2|{{#var:PLATFORM_OS}} Recovery SD card|{{#var:RELEASE_LINK}}}}, and you want the NAND flash/eMMC installation process to be updated as well as the SD card boot itself, you need to also update the /opt/images/{{#var:PLATFORM_OS}} directory.
* You should always properly unmount your SD card before physically removing it.
* You should always properly unmount your SD card before physically removing it.
}}
}}

Latest revision as of 19:21, 27 April 2023

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

This page is using the default release RELEASE_MORTY_V1.0_DART-6UL.
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
Build Linux from source code
It is recommended to build the kernel image using Yocto (see the Customizing the Linux kernel page) instead of using the direct method described in this page.
This is because some of the Yocto packages may depend on the kernel, like the WiFi module that is built from outside of the kernel source tree on some of the Yocto releases.

Toolchain installation for out of Yocto builds

To install the toolchain, follow the Yocto Toolchain installation guide.

Build Linux out of Yocto tree

Get the Linux source code:

$ git clone https://github.com/varigit/linux-2.6-imx.git
$ cd linux-2.6-imx
$ git checkout imx-rel_imx_4.1.15_2.0.0_ga-var02

Build the Linux kernel:

$ source /opt/fslc-x11/2.2.1/environment-setup-armv7at2hf-neon-fslc-linux-gnueabi
$ make mrproper
$ make imx6ul-var-dart_defconfig
Customize the kernel configuration (optional step):
$ make menuconfig
Build everything:
$ make -j4
Build zImage only:
$ make -j4  zImage

Build modules only:
$ make -j4  modules

Build device trees only:
$ make -j4 dtbs
Build only the device tree for DART-6UL with i.MX6UL SOC, eMMC and WiFi:
$ make -j4 imx6ul-var-dart-emmc_wifi.dtb

Build only the device tree for DART-6UL with i.MX6UL SOC, eMMC and SD card:
$ make -j4 imx6ul-var-dart-sd_emmc.dtb

Build only the device tree for DART-6UL with i.MX6UL SOC, NAND flash and WiFi:
$ make -j4 imx6ul-var-dart-nand_wifi.dtb

Build only the device tree for DART-6UL with i.MX6UL SOC, NAND flash and SD card:
$ make -j4 imx6ul-var-dart-sd_nand.dtb

Build only the device tree for DART-6UL with i.MX6ULL SOC, eMMC and WiFi:
$ make -j4 imx6ull-var-dart-emmc_wifi.dtb

Build only the device tree for DART-6UL with i.MX6ULL SOC, eMMC and SD card:
$ make -j4 imx6ull-var-dart-sd_emmc.dtb

Build only the device tree for DART-6UL with i.MX6ULL SOC, NAND flash and WiFi:
$ make -j4 imx6ull-var-dart-nand_wifi.dtb

Build only the device tree for DART-6UL with i.MX6ULL SOC, NAND flash and SD card:
$ make -j4 imx6ull-var-dart-sd_nand.dtb


Notes:

If you replace the kernel image (zImage) on your system, you also need to reinstall the kernel modules, and vice versa.
If you just want to make a change in the device tree, you can compile and replace it without replacing the kernel image and modules.

Install the built kernel on an SD card

Copy the zImage and device trees to the SD card boot partition, and install the modules in the SD card rootfs partition.
Assuming the boot partition is mounted on /media/user/BOOT-VAR6UL and the rootfs partition is mounted on /media/user/rootfs:

Install the kernel image and modules:
$ cp arch/arm/boot/zImage /media/user/BOOT-VAR6UL
$ sudo make ARCH=arm modules_install INSTALL_MOD_PATH=/media/user/rootfs


Install the device trees:
$ cp arch/arm/boot/dts/imx6ul*var*.dtb /media/user/BOOT-VAR6UL


Notes:

  • If you are using our Yocto Recovery SD card, and you want the NAND flash/eMMC installation process to be updated as well as the SD card boot itself, you need to also update the /opt/images/Yocto directory.
  • You should always properly unmount your SD card before physically removing it.