2021-02-19 23:19:40 -04:00
The installation consists on creating a build area locatated at:
2021-01-25 17:27:45 -04:00
2021-02-19 23:19:40 -04:00
```bash
Linux_for_Tegra/builds/build_< spiri >
```
From this directory you might call the targets ```tegra_defconfig, dtbs, Image, modules``` to compile the Kernel. Please, add your projects under builds/.
The Make targets gets sourced from the ```source/``` directory on the Jetpack workspace root, which is where this project Kernel sources are installed.
* The ```-C``` flag for the make allows to change the directory where the Kernel source is.
* The ```-O``` stands for the output of the build process files.
* CROSS_COMPILE=${CROSS_COMPILE}, passes the C cross compiler. The recomended for this CTI release it's ```/opt/gcc-linaro-7.3.1/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-```.
* The ```-jN```is the flag for the parallel jobs to build with. You can find it out at your host with the command `nproc` .
2021-01-25 17:27:45 -04:00
2021-02-19 23:19:40 -04:00
### 1. Download the Toolchain for crosscompiling
```bash
wget http://releases.linaro.org/components/toolchain/binaries/7.3-2018.05/aarch64-linux-gnu/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz
sudo tar xf gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz -C /opt/gcc-linaro-7.3.1/
echo "export CROSS_COMPILE=/opt/gcc-linaro-7.3.1/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-" >> ~/.bashrc
source ~/.bashrc
```
### 2. Clone recursively the repository to the workspace's root to add the Jetpack+CTI 4.4.1 and Drivers MT9M021 and EG25-G
2021-01-25 17:27:45 -04:00
```bash
LINUX_FOR_TEGRA=< Linux_for_Tegra / path >
2021-03-17 20:43:06 -03:00
KERNEL_LOCATION_FROM_BUILD_DIR=../../spiri-project/source/Jetpack/kernel/kernel-4.9/
KERNEL_LOCATION=$KERNEL_LOCATION_FROM_BUILD_DIR
2021-01-25 17:27:45 -04:00
cd $LINUX_FOR_TEGRA
git clone --recurse-submodules https://git.spirirobotics.com/dchvs/spiri-project.git
cd spiri-project
2021-03-17 20:43:06 -03:00
2021-02-19 23:19:40 -04:00
git checkout master
2021-01-25 17:27:45 -04:00
git submodule update --init --recursive --remote
2021-02-19 23:19:40 -04:00
```
2021-01-25 17:27:45 -04:00
2021-02-19 23:19:40 -04:00
### 3. Install the CTI BSP
```bash
2021-01-25 17:27:45 -04:00
cd CTI-L4T/
sudo ./install.sh
2021-02-19 23:19:40 -04:00
```
2021-01-25 17:27:45 -04:00
2021-02-19 23:19:40 -04:00
### 4. Build the Spiri cameras project Kernel
```bash
cd $LINUX_FOR_TEGRA/
2021-01-25 17:27:45 -04:00
mkdir -p builds/build_< this build name > & & cd builds/build_< this build name >
2021-03-17 20:43:06 -03:00
mkdir build
2021-02-19 23:19:40 -04:00
# Create the Kernel configuration file
2021-03-17 20:43:06 -03:00
make -C $KERNEL_LOCATION ARCH=arm64 O=$PWD/build/ tegra_defconfig
2021-02-19 23:19:40 -04:00
```
```bash
# Check for the Drivers with the "spiri" keyword
2021-03-17 20:43:06 -03:00
make -C $KERNEL_LOCATION ARCH=arm64 O=$PWD/build/ menuconfig
2021-02-19 23:19:40 -04:00
```
By default the Drivers are installed, the tegra_defconfig include them as:
```CONFIG_VIDEO_I2C_SPIRI_CAM=y```
```CONFIG_VIDEO_I2C_SPIRI_GSM=y```
You can review it on the Kernel Menuconfig, and find it out in the following paths:
```bash
+----------------+ +--------------------+ +-------------------------------------------------------------------+ +-------------------------------------+
| Device Drivers | --> | Multimedia support | --> | NVIDIA overlay Encoders, decoders, sensors and other helper chips | --> | Spiri MT9M021 camera sensor support |
+----------------+ +--------------------+ +-------------------------------------------------------------------+ +-------------------------------------+
+----------------+ +------------------------+ +----------------------+ +----------------------+
| Device Drivers | --> | Network device support | --> | USB Network Adapters | --> | USB Network Adapters |
+----------------+ +------------------------+ +----------------------+ +----------------------+
```
```bash
# Build the Kernel, DTBs and modules
2021-03-17 20:43:06 -03:00
make -C $KERNEL_LOCATION ARCH=arm64 O=$PWD/build/ CROSS_COMPILE=${CROSS_COMPILE} -j8 --output-sync=target zImage dtbs modules
2021-01-25 17:27:45 -04:00
```
2021-02-19 23:19:40 -04:00
The deployed Kernel binaries after compilation could check if it has the Drivers in it, inspecting on it with rgrep:
2021-01-25 17:27:45 -04:00
```bash
2021-02-19 23:19:40 -04:00
rgrep mt9m021 build/arch/arm64/boot/Image
rgrep eg25-g build/arch/arm64/boot/Image
```
### 5. Flash the Spiri Mu
Once the Kernel it's compiled, the output binaries should get installed on the Jetpack workspace, letting the flash scripts deploy them into the target device. The update for the flash scripts deployment it's ilustrated as follows:
```bash
# Location for the Kernel files to be found by Tegra flash.sh script in full image installation
2021-03-17 20:43:06 -03:00
+------------------------------------+ +---------------------+
| build/arch/arm64/boot/Image | --> | kernel/Image |
+------------------------------------+ +---------------------+
+------------------------------------+ +---------------------+
| build/arch/arm64/boot/dts/* | --> | kernel/dtb/ |
+------------------------------------+ +---------------------+
2021-02-19 23:19:40 -04:00
+------------------------------------+ +---------------------+
| modules/lib/modules/4.9.140-tegra/ | --> | rootfs/lib/modules/ |
+------------------------------------+ +---------------------+
```
```
# Add the Kernel files for full image installation
2021-03-17 20:43:06 -03:00
2021-03-04 05:01:05 -04:00
# Install the Kernel Image and DTBs
2021-03-17 20:43:06 -03:00
make -C $KERNEL_LOCATION ARCH=arm64 O=$PWD/build/ kernel_install INSTALL_PATH=$PWD/../../kernel/
2021-03-04 05:01:05 -04:00
# Install the Drivers modules
2021-03-17 20:43:06 -03:00
sudo make -C $KERNEL_LOCATION ARCH=arm64 O=$PWD/build/ modules_install INSTALL_MOD_PATH=$PWD/../../rootfs/
2021-01-25 17:27:45 -04:00
```
2021-02-19 23:19:40 -04:00
In order to flash the target device, do the following commands from the workspace's root:
2021-01-25 17:27:45 -04:00
```bash
2021-02-19 23:19:40 -04:00
cd $LINUX_FOR_TEGRA/
# Full OS installation
sudo ./flash.sh jetson-tx2 mmcblk0p1
# Device tree installation
sudo ./flash.sh -r -k kernel-dtb -d kernel/dtb/tegra186-tx2-spiri-revF+.dtb jetson-tx2 mmcblk0p1
# Kernel image installation
sudo ./flash.sh -r -k kernel -K kernel/Image jetson-tx2 mmcblk0p1
2021-01-25 17:27:45 -04:00
```