TS-7600 3.14 kernel compile guide: Difference between revisions

From embeddedTS Manuals
m (Non-link text auto-updated for 2022 re-branding ( https://github.com/embeddedarm/linux-3.14.28-imx28.git →‎ https://github.com/embeddedTS/linux-3.14.28-imx28.git ftp://ftp.embeddedarm.com/ts-arm-sbc/ts-7680-linux/cross-toolchains/imx28-cross-glibc.tar.bz2 →‎ ftp://ftp.embeddedTS.com/ts-arm-sbc/ts-7680-linux/cross-toolchains/imx28-cross-glibc.tar.bz2))
(Migrate to NXP from Freescale, remove use of You)
Line 1: Line 1:
For adding new support to the kernel, or recompiling with more specific options you will need to have an x86 compatible Linux host available that can handle the cross compiling. Compiling the kernel on the board is not supported or recommended. Before building the kernel you will need to install a few support libraries on your workstation:
For adding new support to the kernel, or recompiling with more specific options, an x86 compatible Linux host that can handle the cross compiling will be needed. Compiling the kernel on the device is not supported or recommended. Some support libraries are required on the workstation before a kernel can be built:


''' Prerequisites '''
''' Prerequisites '''
Line 7: Line 7:
Be sure to [[#MicroSD_Card|Create an SD card]] with the latest image available before running through this process.
Be sure to [[#MicroSD_Card|Create an SD card]] with the latest image available before running through this process.


Note that some of the scripts below use pre-compiled binaries for x86 linux, if you are compiling on another platform, including x86_64, you may have issues. Be sure to install compat libraries if applicable.
Note that some of the scripts below use pre-compiled binaries for x86 Linux. If compiling on another platform, including x86_64, there may be compatibility issues. Be sure to install compat libraries if applicable.




Line 15: Line 15:
tar xvf imx28-cross-glibc.tar.bz2 -C /path/to/folder/
tar xvf imx28-cross-glibc.tar.bz2 -C /path/to/folder/
</source>
</source>
/path/to/folder can be any directory so long as the current user has permissions to write to it. Remember this path as its used later during the kernel build procedure.
/path/to/folder can be any directory so long as the current user has permissions to write to it. Remember this path as its used later during the kernel build procedure.




Line 31: Line 31:




If you are on a 64-bit system, then 32-bit libraries will be required for the toolchain, for newer Debian and Ubuntu distrubutions with Multiarch support, use the command:
If building on a 64-bit system, then 32-bit libraries will be required for the toolchain. For newer Debian and Ubuntu distrubutions with Multiarch support, use the command:
<source lang=bash>
<source lang=bash>
sudo dpkg --add-architecture i386
sudo dpkg --add-architecture i386
Line 71: Line 71:
</source>
</source>


Once you have the configuration ready you can make your changes to the kernel. Commonly a reason for recompiling is to add support that was not built into the standard image's kernel. You can get a menu to browse available options by running:
Once the default configuration is set up, changes can be made to it before building. A common reason for recompiling is to add support that was not built into the standard image's kernel. An interactive menu of options is available by running:
<source lang=bash>
<source lang=bash>
make menuconfig
make menuconfig
</source>
</source>


You can use the "/" key to search for specific terms through the kernel.
Use the "/" key to search for specific terms through the kernel.


'''Build the kernel'''
'''Build the kernel'''


Once you have it configured you can begin building the kernel.  This usually takes about 5-10 minutes.  Since 3.14 uses Device Tree, and the Freescale bootloader is not set up to handle that, an additional preparation step is needed as well to append the binary device tree to the end of the kernel binary.
Once configured, the kernel can be built.  Since Linux 3.14 uses Device Tree, and the NXP bootloader is not set up to handle that, an additional preparation step is needed as well to append the binary device tree to the end of the kernel binary.
<source lang=bash>
<source lang=bash>
make && make zImage && make modules
make && make zImage && make modules
Line 86: Line 86:
We recommend running 'make' with the -jX argument, where X is the number of CPU cores+1 present on the build machine.  This will greatly increase build speed.
We recommend running 'make' with the -jX argument, where X is the number of CPU cores+1 present on the build machine.  This will greatly increase build speed.


Next, the correct DTB needs to be appended to the zImage binary. However, because of the way the Freescale bootloader detects and passes RAM, it is not compatible with the kernel Device Tree.  Therefore, there are two DTB files, one to specify 128 MB of RAM, and the other for 256 MB. The 128 MB variant will boot on both, however on a system with an actual 256 MB of RAM, only 128 MB of that will be accessible.  On the other hand, the 256 MB DTB is only compatible with a TS-7600 that has 256 MB of RAM; it will not boot on a unit with 128 MB.
Next, the correct DTB needs to be appended to the zImage binary. However, because of the way the NXP bootloader detects and passes RAM, it is not compatible with the kernel Device Tree.  Therefore, there are two DTB files, one to specify 128 MB of RAM, and the other for 256 MB. The 128 MB variant will boot on both, however on a system with an actual 256 MB of RAM, only 128 MB of that will be accessible.  On the other hand, the 256 MB DTB is only compatible with a TS-7600 that has 256 MB of RAM; it will not boot on a unit with 128 MB.
<source lang=bash>
<source lang=bash>
cat arch/arm/boot/zImage arch/arm/boot/dts/imx28-ts7600-128M.dtb > zImage
cat arch/arm/boot/zImage arch/arm/boot/dts/imx28-ts7600-128M.dtb > zImage
Line 103: Line 103:
'''Build bootstream'''
'''Build bootstream'''


The i.MX28 utilizes what Freescale calls a "bootstream," this is a series of "bootlets" that are all put together in a binary blob.  The default bootstream sets up RAM, power, and contains the kernel to be run.  Every time a kernel is rebuilt, a new bootstream must be compiled containing the new kernel image. The following script is used to take the newly built kernel and output a bootstream for the SD card:
The i.MX28 utilizes what NXP calls a "bootstream," this is a series of "bootlets" that are all put together in a binary blob.  The default bootstream sets up RAM, power, and contains the kernel to be run.  Every time a kernel is rebuilt, a new bootstream must be compiled containing the new kernel image. The following script is used to take the newly built kernel and output a bootstream for the SD card:
<source lang=bash>
<source lang=bash>
./build_bootstream
./build_bootstream
Line 112: Line 112:
'''Install the bootstream (kernel/initramfs), headers, and modules '''
'''Install the bootstream (kernel/initramfs), headers, and modules '''


Next you need to install the kernel and modules to the SD card.  We provide a simple script to copy the kernel uImage file, kernel modules, and headers to the SD card to update everything at once.
Next, install the kernel and modules to the SD card.  We provide a simple script to copy the kernel uImage file, kernel modules, and headers to the SD card to update everything at once.


For example, if your workstation's SD card is /dev/mmcblk0:
For example, if your workstation's SD card is /dev/mmcblk0:
Line 132: Line 132:
./install_bootstream: line 122: [: !=: unary operator expected
./install_bootstream: line 122: [: !=: unary operator expected
</source>
</source>
is printed, then you need to apply the patch to fix this.  Use the following command to apply the patch:
is printed, then a patch needs to be applied to fix this.  Use the following command to apply the patch:
<source lang=bash>
<source lang=bash>
patch -p1 < install_bootstream-newer-fdisk.patch
patch -p1 < install_bootstream-newer-fdisk.patch
</source>}}
</source>}}

Revision as of 14:29, 1 July 2022

For adding new support to the kernel, or recompiling with more specific options, an x86 compatible Linux host that can handle the cross compiling will be needed. Compiling the kernel on the device is not supported or recommended. Some support libraries are required on the workstation before a kernel can be built:

Prerequisites

All systems:

Be sure to Create an SD card with the latest image available before running through this process.

Note that some of the scripts below use pre-compiled binaries for x86 Linux. If compiling on another platform, including x86_64, there may be compatibility issues. Be sure to install compat libraries if applicable.


Download and unpack the cross compiler

wget ftp://ftp.embeddedTS.com/ts-arm-sbc/ts-7680-linux/cross-toolchains/imx28-cross-glibc.tar.bz2
tar xvf imx28-cross-glibc.tar.bz2 -C /path/to/folder/

/path/to/folder can be any directory so long as the current user has permissions to write to it. Remember this path as its used later during the kernel build procedure.


RHEL/Fedora/CentOS:

yum install ncurses-devel ncurses
yum groupinstall "Development Tools" "Development Libraries"


Ubuntu/Debian:

sudo apt-get install build-essential libncurses5-dev libncursesw5-dev git


If building on a 64-bit system, then 32-bit libraries will be required for the toolchain. For newer Debian and Ubuntu distrubutions with Multiarch support, use the command:

sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libc6-dev:i386 zlib1g-dev:i386

On older distributions:

sudo apt-get install ia32-libs


For other distributions, please refer to their documentation to find equivalent tools.


Download sources and configure

git clone https://github.com/embeddedTS/linux-3.14.28-imx28.git
cd linux-3.14.28-imx28/

# Switch to the branch specific for this SBC
git checkout 7600-4600

# Note that there is another compatible branch that has community applied patches.
# This includes an update to kernel version 3.14.79, as well as AUFS support.
# AUFS is a unification filesystem, similar to UnionFS.
# By setting soft jumper 4 when using this branch, the root filsystem is unified with a RAM based tmpfs.
git checkout linux-3.14.79-7600-4600

# These next commands set up some necessary environment variables
export ARCH=arm
export CROSS_COMPILE=/path/to/folder/arm-fsl-linux-gnueabi/bin/arm-linux-
export LOADADDR=0x40008000

# This sets up the default configuration
make ts7600_defconfig

Once the default configuration is set up, changes can be made to it before building. A common reason for recompiling is to add support that was not built into the standard image's kernel. An interactive menu of options is available by running:

make menuconfig

Use the "/" key to search for specific terms through the kernel.

Build the kernel

Once configured, the kernel can be built. Since Linux 3.14 uses Device Tree, and the NXP bootloader is not set up to handle that, an additional preparation step is needed as well to append the binary device tree to the end of the kernel binary.

make && make zImage && make modules

We recommend running 'make' with the -jX argument, where X is the number of CPU cores+1 present on the build machine. This will greatly increase build speed.

Next, the correct DTB needs to be appended to the zImage binary. However, because of the way the NXP bootloader detects and passes RAM, it is not compatible with the kernel Device Tree. Therefore, there are two DTB files, one to specify 128 MB of RAM, and the other for 256 MB. The 128 MB variant will boot on both, however on a system with an actual 256 MB of RAM, only 128 MB of that will be accessible. On the other hand, the 256 MB DTB is only compatible with a TS-7600 that has 256 MB of RAM; it will not boot on a unit with 128 MB.

cat arch/arm/boot/zImage arch/arm/boot/dts/imx28-ts7600-128M.dtb > zImage

Or:

cat arch/arm/boot/zImage arch/arm/boot/dts/imx28-ts7600-256M.dtb > zImage

And now, move the zImage back to its expected location:

mv zImage arch/arm/boot/


Build bootstream

The i.MX28 utilizes what NXP calls a "bootstream," this is a series of "bootlets" that are all put together in a binary blob. The default bootstream sets up RAM, power, and contains the kernel to be run. Every time a kernel is rebuilt, a new bootstream must be compiled containing the new kernel image. The following script is used to take the newly built kernel and output a bootstream for the SD card:

./build_bootstream

This will create imx-bootlets-src-10.12.01/imx28_ivt_linux.sb The .sb file is the standard image used for the SD card.

Install the bootstream (kernel/initramfs), headers, and modules

Next, install the kernel and modules to the SD card. We provide a simple script to copy the kernel uImage file, kernel modules, and headers to the SD card to update everything at once.

For example, if your workstation's SD card is /dev/mmcblk0:

./install_bootstream imx-bootlets-src-10.12.01/imx28_ivt_linux.sb mmcblk0 p1
./install_hdr_mod mmcblk0p2


If your workstation's SD card is /dev/sdc:

./install_bootstream imx-bootlets-src-10.12.01/imx28_ivt_linux.sb sdc 1
./install_hdr_mod sdc2


Note: On newer linux distributions, the output of 'fdisk' has changed. If the unit fails to boot after a compile, take a look at the output of the './install_bootstream ... ' command. If the line
./install_bootstream: line 122: [: !=: unary operator expected

is printed, then a patch needs to be applied to fix this. Use the following command to apply the patch:

patch -p1 < install_bootstream-newer-fdisk.patch