TS-7600 kernel compile guide: Difference between revisions

From embeddedTS Manuals
No edit summary
m (Non-link text auto-updated for 2022 re-branding ( https://github.com/embeddedarm/linux-2.6.35.3-imx28.git →‎ https://github.com/embeddedTS/linux-2.6.35.3-imx28.git))
 
(3 intermediate revisions by one other user not shown)
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, the kernel can be customized and re-built. An x86 compatible Linux workstation that can handle cross compilation is required. We recommend using a Debian distribution. Compiling the kernel on the device is not supported or recommended. Before building the kernel, the necessary support libraries will need to be installed on the Linux workstation:


''' Prerequisites '''
''' Prerequisites '''
Line 8: Line 8:
yum groupinstall "Development Tools" "Development Libraries"
yum groupinstall "Development Tools" "Development Libraries"
</source>
</source>
Ubuntu/Debian:
Ubuntu/Debian:
<source lang=bash>
<source lang=bash>
sudo apt-get install build-essential libncurses5-dev libncursesw5-dev git
sudo apt-get install build-essential libncurses5-dev libncursesw5-dev git
## If you are on a 64-bit system then 32-bit libraries will be required for the toolchain
# sudo apt-get install ia32-libs
</source>
</source>
If using a 64-bit system, then 32-bit compatibility libraries will be required for the toolchain, for newer Debian and Ubuntu distributions with Multiarch support, use the command:
<source lang=bash>
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libc6-dev:i386 zlib1g-dev:i386
</source>
On older distributions:
<source lang=bash>
sudo apt-get install ia32-libs
</source>


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


''' Download sources and configure '''
''' Download sources and configure '''


<source lang=bash>
<source lang=bash>
git clone https://github.com/embeddedarm/linux-2.6.35.3-imx28.git
git clone https://github.com/embeddedTS/linux-2.6.35.3-imx28.git


# This sets up the default configuration that we ship with
# This sets up the default configuration that we ship with
Line 27: Line 42:
</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 configuration is loaded, any needed changes can be made to it. A common reason for recompiling is to add support that was not built into the standard image's kernel. An ncurses menu to browse available configuration options can be opened with:
<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.
The "/" key is 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.
Once any customization is completed, the kernel can be built. This usually takes about 5-10 minutes depending on workstation CPU speeds:
<source lang=bash>
<source lang=bash>
make
make
Line 43: Line 58:
'''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 an SPI device as well as an SD card:
The i.MX28 utilizes what NXP calls a <source inline>bootstream</source> This is a series of <source inline>bootlets</source> that are all put together in a binary blob that make up a bootloader for the whole system. The in-CPU ROM bootloader is very small and therefore uses the <source inline>bootstream</source> on the boot media to handle further loading. The default <source inline>bootstream</source> sets up RAM, power, and contains the kernel to be run. Every time the kernel is built, a new <source inline>bootstream</source> must be compiled containing the new kernel image. The following script is used to take the newly built kernel and output a <source inline>bootstream</source> for an SPI device as well as an SD card:
<source lang=bash>
<source lang=bash>
./build_bootstream
./build_bootstream
</source>
</source>


This will create two files in imx-bootlets-src-10.12.01/ imx28_ivt_linux.sb and imx28_ivt_linux.spi.  The .sb file is the standard image used for the SD card, while the .spi is meant to be imaged to the SPI flash device on the TS-7600.
This will create two files, <source inline>imx-bootlets-src-10.12.01/imx28_ivt_linux.sb</source> and <source inline>imx-bootlets-src-10.12.01/imx28_ivt_linux.spi</source>.  The <source inline>imx28_ivt_linux.sb</source> file is the standard image used for the SD card, while the <source inline>imx28_ivt_linux.spi</source> is meant to be imaged to the SPI flash device on the TS-7600.


'''Building External Wireless Modules'''
'''Building External Wireless Modules'''


In order to support the wide range of USB wifi modules that Technologic Systems has offered over the years, the compat-wireless project is used to build all compatible modules. A simple command is used to build them:
In order to support the wide range of USB WiFi modules that Technologic Systems has offered over the years, the <source inline>compat-wireless</source> project is used to build all compatible modules. A simple command is used to build them:
<source lang=bash>
<source lang=bash>
./build_wireless
./build_wireless
Line 59: Line 74:
'''Install the bootstream (kernel/initramfs) and Modules '''
'''Install the bootstream (kernel/initramfs) and Modules '''


Next you need to install the kernel and modules to the SD card. Freescale uses a specialized booting mechanism for their processor, so to simplify installation we provide two scripts to handle installation of the kernel+bootstream, kernel modules, headers, and compat-wireless modules.
Next, install the kernel and modules to the SD card. NXP uses a specialized booting mechanism for their processor, so to simplify installation we provide two scripts to handle installation of the kernel+bootstream, kernel modules, headers, and compat-wireless modules.


For example, if your workstation's SD card is /dev/mmcblk0:
For example, if your workstation's SD card is /dev/mmcblk0:
Line 66: Line 81:
./install_hdr_mod mmcblk0p2
./install_hdr_mod mmcblk0p2
</source>
</source>
{{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
<source lang=bash>
./install_bootstream: line 122: [: !=: unary operator expected
</source>
is printed, then a patch must be applied to address this issue.  Use the following command to apply the patch:
<source lang=bash>
patch -p1 < install_bootstream-newer-fdisk.patch
</source>}}


'''Install the bootstream (kernel/initramfs) to SPI flash'''
'''Install the bootstream (kernel/initramfs) to SPI flash'''


The `./build_bootstream` command creates the file "imx-bootlets-src-10.12.01/imx28_ivt_linux.spi" that can be used to program the SPI flash, see the [[#SPI Flash|SPI Flash]] section for more information.  The `./install_hdr_mod` command copies both the SPI bootstream and the stock bootstream to /lib/modules so they may be used to program SPI devices or NAND.
The <source inline>./build_bootstream</source> command creates the file <source inline>imx-bootlets-src-10.12.01/imx28_ivt_linux.spi</source> that can be used to program the SPI flash, see the [[#SPI Flash|SPI Flash]] section for more information.  The <source inline>./install_hdr_mod</source> command copies both the SPI bootstream and the stock bootstream to <source inline>/lib/modules</source> so they may be used to program SPI devices or NAND.


This bootstream is the exact same kernel/initramfs that is made for the SD card, it has the exact same init script..  Note that the SPI flash is bootable by itself, with or without an SD card.  However, if an SD card is not used, there will be no Debian libraries to use or a Debian filesystem to boot to, only the busybox/uclibc environment that is in the initramfs.
This bootstream is the exact same kernel/initramfs that is made for the SD card, it has the exact same init script.

Latest revision as of 14:30, 18 January 2022

For adding new support to the kernel, or recompiling with more specific options, the kernel can be customized and re-built. An x86 compatible Linux workstation that can handle cross compilation is required. We recommend using a Debian distribution. Compiling the kernel on the device is not supported or recommended. Before building the kernel, the necessary support libraries will need to be installed on the Linux workstation:

Prerequisites

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 using a 64-bit system, then 32-bit compatibility libraries will be required for the toolchain, for newer Debian and Ubuntu distributions 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-2.6.35.3-imx28.git

# This sets up the default configuration that we ship with
make ts7600_defconfig
ln -sf initramfs.cpio-ts7600 initramfs.cpio

Once the configuration is loaded, any needed changes can be made to it. A common reason for recompiling is to add support that was not built into the standard image's kernel. An ncurses menu to browse available configuration options can be opened with:

make menuconfig

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

Build the kernel

Once any customization is completed, the kernel can be built. This usually takes about 5-10 minutes depending on workstation CPU speeds:

make

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 that make up a bootloader for the whole system. The in-CPU ROM bootloader is very small and therefore uses the bootstream on the boot media to handle further loading. The default bootstream sets up RAM, power, and contains the kernel to be run. Every time the kernel is built, 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 an SPI device as well as an SD card:

./build_bootstream

This will create two files, imx-bootlets-src-10.12.01/imx28_ivt_linux.sb and imx-bootlets-src-10.12.01/imx28_ivt_linux.spi. The imx28_ivt_linux.sb file is the standard image used for the SD card, while the imx28_ivt_linux.spi is meant to be imaged to the SPI flash device on the TS-7600.

Building External Wireless Modules

In order to support the wide range of USB WiFi modules that Technologic Systems has offered over the years, the compat-wireless project is used to build all compatible modules. A simple command is used to build them:

./build_wireless

Install the bootstream (kernel/initramfs) and Modules

Next, install the kernel and modules to the SD card. NXP uses a specialized booting mechanism for their processor, so to simplify installation we provide two scripts to handle installation of the kernel+bootstream, kernel modules, headers, and compat-wireless modules.

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


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 must be applied to address this issue. Use the following command to apply the patch:

patch -p1 < install_bootstream-newer-fdisk.patch


Install the bootstream (kernel/initramfs) to SPI flash

The ./build_bootstream command creates the file imx-bootlets-src-10.12.01/imx28_ivt_linux.spi that can be used to program the SPI flash, see the SPI Flash section for more information. The ./install_hdr_mod command copies both the SPI bootstream and the stock bootstream to /lib/modules so they may be used to program SPI devices or NAND.

This bootstream is the exact same kernel/initramfs that is made for the SD card, it has the exact same init script.