> ## 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 DX-M1 Module on the Board

This section explains the steps of installing the DeepX DX-M1 accelerator module on the T3 Gemstone O1
development board, installing the driver and runtime packages, and verifying the installation.

<Steps>
  <Step title="Hardware Assembly">
    <Warning>
      Disconnect the power of the board before starting the assembly. Inserting or removing the M.2 module
      while the board is powered on may cause permanent damage to both the module and the board.
    </Warning>

    Insert the DX-M1 module into the M.2 2280 slot on the board at an angle of approximately 30 degrees,
    then bring the module into a horizontal position and tighten the retaining screw.

    <Note>
      The module draws up to 5W under full load and heats up. Using the module together with a heatsink is
      recommended for continuously running applications.
    </Note>
  </Step>

  <Step title="Adding the Overlay">
    In order for the DX-M1 module to be recognized properly over the PCIe bus, the
    `k3-am67a-t3-gem-o1-pcie-link-speed-2.dtbo` overlay file, which sets the link speed, must be
    activated.

    Open the `uEnv.txt` file located in the boot directory using the text editor named `nano` from the
    terminal interface.

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

    <Tip>
      Since we are using the command with sudo, it will ask for a password. If you have not changed it, you
      must use the password you set while writing the image with Gem-Imager.
    </Tip>

    The `uEnv.txt` file will contain definitions such as 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
    ```

    Add the `k3-am67a-t3-gem-o1-pcie-link-speed-2.dtbo` file name to the end of the `overlays=` line,
    leaving a space.

    The final state of the `uEnv.txt` file will be like this. You need to place the appropriate file name in
    the `<file-name>` section.

    ```
    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
    ```

    After defining the overlay file, the board must be restarted so that the changes can be applied by the
    system.

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

    <Note>
      Do not delete the other overlay files on the `overlays=` line. Otherwise the interfaces that were
      activated earlier will become unusable.
    </Note>
  </Step>

  <Step title="Verifying the PCIe Connection">
    After restarting the board, check that the module is detected on the PCIe bus.

    ```bash theme={"system"}
    sudo apt install pciutils
    ```

    <CodeGroup>
      ```bash Terminal theme={"system"}
      lspci
      ```

      ```bash Output theme={"system"}
      00:00.0 PCI bridge: Texas Instruments Device b010
      01:00.0 Processing accelerators: Device 1ff4:0000 (rev 01)
      ```
    </CodeGroup>

    The `Processing accelerators` line appearing in the output indicates that the module is recognized at
    the hardware level.

    <Tip>
      If the module is not listed, you can review the **Module is not listed in the lspci output** heading
      in the [Troubleshooting](/en/boards/o1/ai/deepx/troubleshooting) section.
    </Tip>
  </Step>

  <Step title="Installing the Driver and Runtime">
    After updating the package list, install the DeepX driver and runtime package.

    ```bash theme={"system"}
    sudo apt update
    sudo apt install dxrt dx-stream
    ```

    This package installs the PCIe kernel driver (`dxrt_driver`, `dx_dma`), the DX-RT runtime and helper
    tools such as `dxrt-cli`.

    Restart the board so that the driver can be loaded into the kernel.

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

    <Tip>
      If you would like to build the SDK from source, you can use the
      [deepx-npu-deepx](https://github.com/t3gemstone/deepx-npu-sdk) repository published by us.
    </Tip>
  </Step>

  <Step title="Checking That the Driver Is Loaded">
    Load the kernel modules and then restart the service.

    ```bash theme={"system"}
    sudo modprobe dxrt_driver
    sudo systemctl restart dxrt.service
    ```

    The `modprobe` command above loads the module only for the current session. In order for the driver to
    be loaded automatically on every boot, add the module to the `systemd-modules-load` configuration.

    ```bash theme={"system"}
    echo dxrt_driver | sudo tee /etc/modules-load.d/dxrt.conf
    ```

    You can check whether the kernel module was loaded successfully with the command below.

    <CodeGroup>
      ```bash Terminal theme={"system"}
      lsmod | grep dx
      ```

      ```bash Output theme={"system"}
      dxrt_driver            45056  2
      dx_dma                483328  9 dxrt_driver
      ```
    </CodeGroup>

    You can also check the device files created by the driver.

    ```bash theme={"system"}
    ls /dev/dxrt*
    ```
  </Step>

  <Step title="Verifying the Device Status">
    Verify with the `dxrt-cli` tool that the module is accessible by the runtime. An output similar to the
    following is expected. The version and temperature values will differ depending on the hardware you are
    using.

    <CodeGroup>
      ```bash Terminal theme={"system"}
      dxrt-cli --status
      ```

      ```bash Output theme={"system"}
      DXRT v3.1.0
      =======================================================
      * Device 0: M1, Accelerator type
      ---------------- Version --------------------
       * RT Driver version   : v1.8.0
       * PCIe Driver version : v1.6.0
       * FW version          : v2.4.0
      ---------------- Memory ---------------------
       * Type    : LPDDR5
       * Size    : 3.92 GiB
      ---------------- NPU ------------------------
       * NPU 0: voltage 730 mV, clock 1000 MHz, temperature 48 C
       * NPU 1: voltage 730 mV, clock 1000 MHz, temperature 47 C
       * NPU 2: voltage 730 mV, clock 1000 MHz, temperature 48 C
      =======================================================
      ```
    </CodeGroup>
  </Step>

  <Step title="Installing the Python Package">
    The inference interface on the Python side is provided by the `dx_engine` package. Install the package
    with `pip3`.

    ```bash theme={"system"}
    pip3 install dx_engine
    ```
  </Step>

  <Step title="Verifying the Python Package">
    In order to run inference with Python, the `dx_engine` package must be available.

    ```bash theme={"system"}
    python3 -c "from dx_engine import InferenceEngine; print('dx_engine is ready')"
    ```

    If the command ran without an error, the development environment is ready to use.
  </Step>
</Steps>
