> ## Documentation Index
> Fetch the complete documentation index at: https://docs.t3gemstone.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Installation

> Installing the Camera ISP SDK package on the T3 Gemstone O1

> [!TIP]
>
> By the end of this section, you will have learned about the following topics.
>
> * Installing the Camera ISP SDK package on the board and patching TI's `tiovx` plugin
> * Enabling the sensor driver and the camera overlay
> * Checking the installation with `camera-isp-sdk doctor`

**1. Installing the Edge AI Packages**

The hardware ISP is reached through TI's Edge AI stack.

**2. Installing the Package**

The package built on the computer is unpacked into the board's root directory.

**3. Building the tiovx Plugin**

TI's GStreamer plugin is rebuilt once with descriptor support.

**4. Installing the Sensor Driver**

The camera's kernel driver is installed if the image does not have it.

**5. Adding the Overlay and Rebooting**

The overlay of the camera's port is added to `uEnv.txt`.

**6. Checking the Installation**

The camera is configured with `camera-isp-sdk setup` and the installation is checked with `camera-isp-sdk doctor`.

## 1. Installing the Edge AI Packages

The `tiovxisp` element and TIOVX, the software that drives the hardware accelerators (VPAC ISP, MSC, LDC), come
with the `t3-edgeai-dev` package. You can install it and enable the `k3-am67a-t3-gem-o1-edgeai-apps.dtbo` overlay
as described in [AI Installation](https://docs.t3gemstone.org/en/boards/o1/ai/installation.md).

```bash theme={"system"}
sudo apt install t3-edgeai-dev
```

The Camera ISP SDK commands on the board are run as `root` with the Edge AI environment loaded:

```bash theme={"system"}
sudo su
source /opt/t3-edgeai-env
```

> [!WARNING]
>
> You need to load the environment in every new shell, before `build.sh`, `camera-isp-sdk doctor`, `camera-isp-sdk setup` and
> `camera-isp-sdk pipeline`. Without the `t3-edgeai-dev` package and `/opt/t3-edgeai-env`, the hardware accelerators do not
> work.

## 2. Installing the Package

You can copy the package built in [Building](https://docs.t3gemstone.org/en/boards/o1/isp/build.md) to the board as shown below.

```bash theme={"system"}
scp build/camera-isp-sdk-0.1.0-t3-gem-o1.tar.gz gemstone@<board-ip-address>:
```

Then you can unpack it into the root directory on the board.

```bash theme={"system"}
sudo tar -C / -xzf camera-isp-sdk-0.1.0-t3-gem-o1.tar.gz
```

| Location | Contents |
| - | - |
| `/usr/bin/camera-isp-sdk` | Command line tool |
| `/usr/share/camera-isp-sdk/sensors/` | Sensor descriptors (read by `tiovxisp`) |
| `/usr/share/camera-isp-sdk/gst/` | Plugin patch, its sources and `build.sh` |
| `/opt/imaging/<sensor>/linear/` | ISP tuning (DCC) files |
| `/boot/overlays/` | Camera overlays |
| `/lib/modules/<kernel>/updates/` | Sensor drivers built with `task drivers` |

## 3. Building the tiovx Plugin

TI's `tiovxisp`/`tiovxldc` plugin is rebuilt once on the board with descriptor support. The script fetches TI's
`edgeai-gst-plugins` at the pinned commit, applies the patch, builds it and installs it, keeping a backup of the
stock plugin. You can run it as shown below, in the shell where the Edge AI environment is loaded
([1. Installing the Edge AI Packages](https://docs.t3gemstone.org/en/boards/o1/isp/installation.md#1-installing-the-edge-ai-packages)).

```bash theme={"system"}
/usr/share/camera-isp-sdk/gst/build.sh
```

> [!NOTE]
>
> The build needs `git`, `meson`, `ninja` and an internet connection on the board. To go back to the stock plugin,
> you can run `/usr/share/camera-isp-sdk/gst/build.sh --restore`. Adding a sensor later does not need this step again; a
> package with a new plugin patch does, and `camera-isp-sdk doctor` reports it.

## 4. Installing the Sensor Driver

| Sensor | Driver |
| - | - |
| `imx219` | On the image, nothing to do. |
| `ov5647` | Enabled in the kernel but not on the image: `sudo apt install kernel-module-ov5647-6.12.24-ti` |
| `imx477` | Ships with the Camera ISP SDK. |
| `imx230` | On the image (`arducam-pivariety`), nothing to do. |

The drivers built in [Building Sensor Drivers](https://docs.t3gemstone.org/en/boards/o1/isp/build.md#6-building-sensor-drivers) are installed
by the package under `/lib/modules/<kernel>/updates/`. You can register them with the kernel as shown below.

```bash theme={"system"}
sudo depmod -a
```

## 5. Adding the Overlay and Rebooting

Every sensor has two overlays: `k3-am67a-t3-gem-o1-csi0-<sensor>.dtbo` and `k3-am67a-t3-gem-o1-csi1-<sensor>.dtbo`.
You need to pick the one of the port the camera is connected to.

> [!NOTE]
>
> * The connector farther from the Ethernet jack is CSI0, the closer one is CSI1.
> * CSI1 shares its lanes with DSI0; a camera on CSI1 cannot be used together with a DSI0 panel overlay.
> * If another camera overlay of the same port is enabled (for example the kernel's own `csi0-imx219` overlay), you
>   need to remove it.

```bash theme={"system"}
sudo nano /boot/uEnv.txt
```

The `uEnv.txt` file contains definitions like these.

```
firstboot=0
overlays=k3-am67a-t3-gem-o1-spidev0-2cs.dtbo k3-am67a-t3-gem-o1-i2c1-400000.dtbo

bootpart=1:1
initrdaddr=0x90000000
fdtoverlayaddr=0x89000000
get_kern_mmc=load mmc ${bootpart} ${loadaddr} Image
get_fdt_mmc=load mmc ${bootpart} ${fdtaddr} k3-am67a-t3-gem-o1.dtb;fdt addr ${fdtaddr};fdt resize 8192
get_initrd_mmc=load mmc ${bootpart} ${initrdaddr} gemstone-image-rd-t3-gem-o1.cpio.gz
get_overlays=for o in ${overlays}; do load mmc ${bootpart} ${fdtoverlayaddr} overlays/${o};fdt apply ${fdtoverlayaddr}; done
args_mmc=setenv bootargs console=${console} ${optargs} root=/dev/mmcblk1p2 rw rootfstype=btrfs bootpart=/dev/mmcblk1p1 firstboot=${firstboot} init_fatal_sh=1
boot_mmc=run get_kern_mmc;run get_fdt_mmc;run get_overlays;run get_initrd_mmc;booti ${loadaddr} ${initrdaddr}:${filesize} ${fdtaddr}
distro_bootcmd=run args_mmc;run boot_mmc
```

You can add the overlay file name to the end of the `overlays=` line, separated by a space. For an OV5647 on the
CSI0 connector, for example, you can use `k3-am67a-t3-gem-o1-csi0-ov5647.dtbo`.

```
firstboot=0
overlays=k3-am67a-t3-gem-o1-spidev0-2cs.dtbo k3-am67a-t3-gem-o1-i2c1-400000.dtbo <file-name>

bootpart=1:1
initrdaddr=0x90000000
fdtoverlayaddr=0x89000000
get_kern_mmc=load mmc ${bootpart} ${loadaddr} Image
get_fdt_mmc=load mmc ${bootpart} ${fdtaddr} k3-am67a-t3-gem-o1.dtb;fdt addr ${fdtaddr};fdt resize 8192
get_initrd_mmc=load mmc ${bootpart} ${initrdaddr} gemstone-image-rd-t3-gem-o1.cpio.gz
get_overlays=for o in ${overlays}; do load mmc ${bootpart} ${fdtoverlayaddr} overlays/${o};fdt apply ${fdtoverlayaddr}; done
args_mmc=setenv bootargs console=${console} ${optargs} root=/dev/mmcblk1p2 rw rootfstype=btrfs bootpart=/dev/mmcblk1p1 firstboot=${firstboot} init_fatal_sh=1
boot_mmc=run get_kern_mmc;run get_fdt_mmc;run get_overlays;run get_initrd_mmc;booti ${loadaddr} ${initrdaddr}:${filesize} ${fdtaddr}
distro_bootcmd=run args_mmc;run boot_mmc
```

Then you need to reboot the board.

```bash theme={"system"}
sudo reboot
```

## 6. Checking the Installation

> [!WARNING]
>
> `tiovxisp` and TIOVX need access to `/dev/mem`, so `doctor`, `setup` and every command that uses the ISP must be
> run as `root`, in a shell where the Edge AI environment is loaded:
>
> ```bash theme={"system"}
> sudo su
> source /opt/t3-edgeai-env
> ```

`camera-isp-sdk setup` finds the cameras on the board, sets the descriptor's mode along sensor → CSI-2 bridge →
receiver, and creates the `/dev/video-<sensor>-cam0` and `/dev/v4l-<sensor>-subdev0` links.

```bash Terminal theme={"system"}
camera-isp-sdk setup
```

```bash Output theme={"system"}
OmniVision OV5647 (Raspberry Pi Camera v1.3): camera 0
    device    = /dev/video-ov5647-cam0 -> /dev/video2
    subdev    = /dev/v4l-ov5647-subdev0 -> /dev/v4l-subdev2
    format    = [fmt:SBGGR10_1X10/1920x1080 field:none]
    isp       = tiovxisp sensor-name=ov5647 (DCC ID 5647)
```

> [!NOTE]
>
> The links under `/dev` have to be created again after every boot. If you run the camera from a service, you can add
> `camera-isp-sdk setup` to its `ExecStartPre` line.

`camera-isp-sdk doctor` checks the overlay, the driver, the patched plugin and the IDs in the DCC files.

```bash Terminal theme={"system"}
camera-isp-sdk doctor
```

```bash Output theme={"system"}
[ok] SoC: obsidian,am67a-t3-gem-o1 ti,j722s
[ok] camera overlays loaded: k3-am67a-t3-gem-o1-csi0-ov5647.kernel
[ok] tiovxisp: patched for sensor descriptors
[ok] sensors in media graph: ov5647 (ov5647 5-0036)
[ok] ov5647: kernel module ov5647
[ok] ov5647: descriptor visible to tiovxisp (/usr/share/camera-isp-sdk/sensors/ov5647/sensor.conf)
[ok] ov5647: /opt/imaging/ov5647/linear/dcc_viss.bin camera module ID [5647]
[ok] ov5647: /opt/imaging/ov5647/linear/dcc_2a.bin camera module ID [5647]
[ok] ov5647: /dev/video-ov5647-cam0 (present)
```

Once the installation is complete, you can run the camera with the commands in [Usage](https://docs.t3gemstone.org/en/boards/o1/isp/usage.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.