1.3. Simplified SDK Build using Top-Level Makefile¶
Inside of the Processor SDK Linux J7200 package, there is a top-level Makefile that can be used to build some of the sub-components found within the SDK. This Makefile uses the Rules.make file and gives an example of how the various components can be built and the parameters to use.
NOTE: You should not call this makefile with the environment-setup script sourced. The sub-component Makefiles will handle sourcing this script where appropriate, but some make targets such as the Linux kernel make target do not work properly when this script is already sourced.
The following sections cover the Rules.make file found in the top-level of the Processor SDK Linux J7200 package.
The Rules.make file in the top-level of the Processor SDK Linux J7200 package is used not only by the top-level Makefile, but also by many of the sub-component Makefiles to gain access to common shared variables and settings. The next section covers the main variables defined in the Rules.make file.
- PLATFORM - This represents the machine name of the device supported by the SDK. This machine name has a direct correlation to the machine definition in the Arago project build system. The PLATFORM variable can be used by component Makefiles to make decisions on a per-machine basis.
- ARCH - This represents the architecture family of the machine. This can be used by component Makefiles to change settings such as mtune values in CFLAGS based on the architecture of the PLATFORM.
- UBOOT_MACHINE - This us used when building u-boot to configure the u-boot sources for the correct device.
- TI_SDK_PATH - This points to the top-level of the SDK. This is the same directory where the Rules.make file itself is located.
- DESTDIR - This points to the base installation directory that applications/drivers should be installed to. This is usually the root of a target file system but can be changed to point anywhere.
- LINUX_DEVKIT_PATH - This points to the linux-devkit directory. This directory is the base directory containing the cross-compiler and cross-libraries as well as the environment-setup script used by many component Makefiles to source additional variable settings.
- CROSS_COMPILE - This setting represents the CROSS_COMPILE prefix to be used when invoking the cross-compiler. Many components such as the Linux kernel use the variable CROSS_COMPILE to prepend the proper prefix to commands such as gcc to invoke the ARM cross-compiler.
- ENV_SETUP - This points to the environment-setup script in the linux-devkit directory used by many components to configure for a cross-compilation build.
- LINUXKERNEL_INSTALL_DIR - This points to the location of the Linux kernel sources, which is used by components such as out-of-tree kernel drivers to find the Linux kernel Makefiles and headers.
- HS - By default the SDK builds for GP binaries. Set the HS flag to 1 if building for HS versions of the u-boot & linux kernel images.
The following sections cover the Makefile found in the top-level of the Processor SDK Linux J7200 package.
Required Host Packages
Please run the following command to install all packages required to by the makefile targets.
host# sudo apt-get install build-essential autoconf automake bison flex libssl-dev bc u-boot-tools
On the download page, you will find links to the recommended compiler toolchains. Download and extract them into your home directory. Note that you have to download both the toolchains for ARMv8 and ARMv7. Make sure to update your PATH to include the path to toolchain.
GCC92PATH=$HOME/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu/bin:$HOME/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/bin export PATH=$GCC92PATH:$PATH
For each of the targets discussed below the following target type are defined
- <target> - This is the build target which will compile the release version of the component.
- <target>_install - This target will install the component to the location pointed to by DESTDIR.
- <target>_clean - This target will clean the component.
The Processor SDK Linux J7200 package provides the following targets by default, which will invoke the corresponding component targets:
- all - This will call the build target for each component defined in the Makefile.
- install - This will call the install target for each component defined in the Makefile.
- clean - This will call the clean target for each component defined in the Makefile.
The following targets are common to all platforms in Processor SDK Linux J7200 package:
- linux - Compiles the Linux kernel using the default tisdk_<PLATFORM>_defconfig configuration.
- linux-dtbs - Compiles and creates the device tree blobs.
- am-benchmarks - Builds the ARM Benchmarks for the ARCH defined in Rules.make.
- am-sysinfo - Build the helper applications used by the system settings demos in Matrix.
Depending on the capabilities and software available for a given device additional targets may also be defined. You can find the list of all the targets by looking at the all target as described in the **Top-Level Targets** section above.
Following are some of the additionaly targets supported:
- u-boot - This target will build the u-boot binaries tiboot3.bin, tispl.bin & u-boot.img. It also triggers a build for the sysfw-image target.
- sysfw-image - As per the combined boot flow, this picks up the u-boot R5 SPL previously generated along with the system firmware release and board configs to produce the final tiboot3.bin binary.
Along with these targets, there might be additional targets for different external kernel modules. This list is different for each platform.
The following examples demonstrate how to use the top-level Makefile for some common tasks. All of the examples below assume that you are calling the Makefile from the top-level of the SDK.
- Build Everything
- Clean Everything
host# make clean
- Install Everything
host# make install
- Build the Linux kernel
host# make linux
- Install the Linux kernel modules
host# make linux_install
- Build the ARM Benchmarks
host# make am-benchmarks
- Clean the ARM Benchmarks
host# make am-benchmarks_clean
- Install the ARM Benchmarks
host# make am-benchmarks_install
Build the sysfw
By default, when building for HS device, sysfw is built for J7200 PG2.0 which will not work on a PG1.0 HS EVM. To build sysfw for J7200 PG1.0, modify the SYSFW_SOC_j7200-hs-evm variable in the Makefile to equal “j7200” and build.
host# make sysfw-image
- Clean the sysfw
host# make sysfw-image_clean
- Install the sysfw
host# make sysfw-image_install
- Build u-boot
host# make u-boot
- Clean u-boot
host# make u-boot_clean
Install u-boot to SD card
Set the BOOTFS variable in Rules.make to the location of the BOOT partition of the SD card. Then run the following
host# make u-boot_install
Installing to SD card
All the install targets copy the files in the rootfs pointed by the DESTDIR variable and the boot files into the location pointed by the BOOTFS variable. By default, Rules.make points the DESTDIR to the NFS path for filesystem. If you want to install the files to the SD card, you should be able to specify different path to DESTDIR & BOOTFS on commandline. e.g. run following for installing everything in the SD card.
host# sudo -E BOOTFS=/media/$USER/boot DESTDIR=/media/$USER/rootfs make install #Replace the path to SD card partitions as appropriate
A Note about Out-of-tree Kernel Modules
Some drivers like the GPU drivers are delivered as modules outside of the kernel tree. If you rebuild the kernel and install it using the “make linux_install” target you will also need to rebuild the out of tree modules and install them as well. The modules_install command used by the linux_install target will remove any existing drivers before installing the new ones. This means those drivers are no longer available until they have been rebuilt against the kernel and re-installed.
A Note about the Linux Kernel Version
To simplify and accelerate rebuilding and installing the linux kernel, the file .scmversion is included in the kernel source tree to pin down the version of the kernel provided in the SDK. If upgrading the kernel sources or adding new commits, this file should be removed so that the appropriate version is built into the kernel image.
A Note about building for HS devices
The PSDK Linux Images can be built for HS devices using the HS=1 flag and prebuilt binaries provided for system firmware, etc. However keep in mind that the HS=1 flag should be used with both build and install targets. For example,
make linux # Builds Linux Kernel Image, DTBs, Modules make linux_install # Installs all of the above HS=1 make linux # Same as above but also signs the Image and dtbs and produces the fitImage HS=1 make linux_install # Installs the fitImage and modules make u-boot # Builds GP u-boot binaries using unsigned images and GP system firmware binaries make u-boot_install # Installs GP u-boot binaries, if built previously HS=1 make u-boot # Builds HS u-boot binaries using signed images and HS system firmware binaries HS=1 make u-boot_install # Installs HS u-boot binaries, if built previously
To rebuild any of the prebuilt binaries for an HS device, please refer to the respective section under Foundational Components.