# Peripherals

## Peripherals block diagram

![](/files/B8vj6oaXrVxx2b82yrEB)

[PDF FORMAT](https://github.com/airvolute/DroneCore.Suite/blob/main/DroneCore.Suite/Docs/DroneCore.Pilot_v1.2_block_diagram%20.pdf)

## Nvidia Jetson peripherals

This section describes Nvidia Jetson peripherals with their minimal usage examples. For detailed connectors pinouts see [Connectors and pinouts section](/autopilots/dronecore-1/pilot-boards/dcs1.pilot-v1.2/dronecore.pilot-connector-description-and-pins-assignment-1.md).

### **GPIOs**

**Setup rules to be able to control gpios from terminal:**

```
   $ sudo groupadd -f -r gpio
   $ sudo usermod -a -G gpio $USER
```

You may either need to reboot or reload the udev rules :

```
sudo udevadm control --reload-rules && sudo udevadm trigger
```

**Example code: Set gpio64 logic level to LOW and then to HIGH**

```
cat /sys/kernel/debug/gpio

root@ubuntu:/home/user_name# echo 64 > /sys/class/gpio/export
root@ubuntu:/home/user_name# echo out > /sys/class/gpio/gpio64/direction
root@ubuntu:/home/user_name# echo 0 > /sys/class/gpio/gpio64/value
root@ubuntu:/home/user_name# echo 1 > /sys/class/gpio/gpio64/value
```

**User controllable GPIOs with their kernel mapping numbers (NANO)**

| Signal Name | Kernel mapping number | usage          |
| ----------- | :-------------------: | -------------- |
| Gpio4       |           65          | 5V\_AP\_SWITCH |
| Gpio6       |           64          | HUB\_ENABLE    |
| Gpio11      |          200          | CAM\_MCLK3     |
| Gpio12      |          194          | 3V3\_IO\_PG    |
| Gpio13      |           38          | Free gpio      |
| GPIO\_EXP1  |          502          | Free gpio      |
| GPIO\_EXP2  |          503          | Free gpio      |
| CAM0\_PWDN  |          412          | IMU DRDY       |
| CAM1\_PWDN  |          413          | AP DRDY        |

**User controllable GPIOs with their kernel mapping numbers (Xavier NX):**

| Signal Name | Kernel mapping number | usage          |
| ----------- | :-------------------: | -------------- |
| Gpio4       |          265          | 5V\_AP\_SWITCH |
| Gpio6       |          267          | USB HUB ENABLE |
| Gpio11      |          422          | CAM\_MCLK3     |
| Gpio12      |          268          | 3V3\_IO\_PG    |
| Gpio13      |          393          | Free gpio      |
| GPIO\_EXP1  |          246          | Free gpio      |
| GPIO\_EXP2  |          247          | Free gpio      |
| CAM0\_PWDN  |                       | IMU DRDY       |
| CAM1\_PWDN  |                       | AP DRDY        |

**User controllable GPIOs with their kernel mapping numbers (Orin NX):**

| Signal Name | Kernel mapping number | usage          |
| ----------- | :-------------------: | -------------- |
| Gpio4       |   gpio-329 (PCC.01)   | 5V\_AP\_SWITCH |
| Gpio6       |   gpio-331 (PCC.03)   | USB HUB ENABLE |
| Gpio11      |    gpio-454 (PQ.06)   | CAM\_MCLK3     |
| Gpio12      |    gpio-433 (PN.01)   | 3V3\_IO\_PG    |
| Gpio13      |    gpio-391 (PH.00)   | Free gpio      |
| GPIO\_EXP1  |        gpio-314       | Free gpio      |
| GPIO\_EXP2  |        gpio-315       | Free gpio      |
| CAM0\_PWDN  |    gpio-397 (PH.06)   | IMU DRDY       |
| CAM1\_PWDN  |   gpio-486 (PAC.00)   | AP DRDY        |

### **Serial ports**

{% tabs %}
{% tab title="Nano" %}

* ttyTHS1 = uart to autopilot
* ttyTHS2 = uart to 'GPS\_Jetson' connector
* ttyS0 = uart to GPIO pin header
  {% endtab %}

{% tab title="Xavier NX" %}

* ttyTHS0 = uart to autopilot
* ttyTHS1 = uart to 'GPS\_Jetson' connector
* ttyTCU0 = debug uart (GPIO pin header)
  {% endtab %}

{% tab title="Orin NX" %}

* ttyTHS0 = uart to autopilot
* ttyTHS1 = uart to 'GPS\_Jetson' connector
  {% endtab %}
  {% endtabs %}

**Example code:** [link to git](https://github.com/airvolute/DroneCore.Suite/tree/main/DroneCore.Suite/DroneCore.Pilot/jetson_peripheral_example_codes/uart_bus_example)

### **SPI ports**

{% tabs %}
{% tab title="Nano" %}

* spidev0.0 = SPI0 (Jetson) connector
* spidev0.1 = SPI0 (Jetson) connector
* spidev1.0 = accelerometer
* spidev1.1 = gyroscope
* spidev1.2 = barometer
  {% endtab %}

{% tab title="Xavier NX" %}

* spidev0.0 = SPI0 (Jetson) connector
* spidev0.1 = SPI0 (Jetson) connector
* spidev2.0 = accelerometer
* spidev2.1 = gyroscope
* spidev2.2 = barometer
  {% endtab %}

{% tab title="Orin NX" %}

* spidev0.0 = SPI0 (Jetson) connector
* spidev0.1 = SPI0 (Jetson) connector
* spidev2.0 = accelerometer
* spidev2.1 = gyroscope
* spidev2.2 = barometer
  {% endtab %}
  {% endtabs %}

**Example code:** [link to git](https://github.com/airvolute/DroneCore.Suite/tree/main/DroneCore.Suite/DroneCore.Pilot/jetson_peripheral_example_codes/spi_bus_example)

### **I2C**

* common
  * i2c-30 = CSIA connector
  * i2c-32 = CSIB connector
  * i2c-31 = CSIC connector
  * i2c-33 = CSID connector
  * i2c-35 = CSIE connector
  * i2c-34 = CSIF connector

{% tabs %}
{% tab title="Nano" %}

* i2c-1 = B2B connector (power board)
* i2c-0 = GPS(Jetson) connector
  {% endtab %}

{% tab title="Xavier NX" %}

* i2c-8 = B2B connector (power board)
* i2c-1 = GPS(Jetson) connector
  {% endtab %}

{% tab title="Orin NX" %}

* i2c-7 = B2B connector (power board)
* i2c-1 = GPS(Jetson) connector
  {% endtab %}
  {% endtabs %}

**Example code:** [link to git](https://github.com/airvolute/DroneCore.Suite/tree/main/DroneCore.Suite/DroneCore.Pilot/jetson_peripheral_example_codes/i2c_bus_example)

### **CSI CAMERAS**

{% hint style="warning" %}
Standard camera configuration is based on the usage of Xavier NX. Not all Jetson modules supports the same camera configuration. Please verify the possibilities of the specific module in the module's datasheet.
{% endhint %}

* CSI cameras natively supported on DroneCore.Pilot board (installed with our provided system image): OV9281, IMX219, IMX477, [Arducam Jetson cameras series](https://www.arducam.com/docs/camera-for-jetson-nano/introduction-to-arducam-cameras-for-jetson-nano/)
* default camera configuration (with provided system image) is IMX477 on CSIB,CSID,CSIF and IMX219 on CSIA, CSIC, CSIE
* for different configuration of supported cameras feel free to contact us
* to support custom camera on CSI port the one needs to develop specific v4l2 camera driver with custom device tree. Instructions to do that: [CSI camera customizaton](/autopilots/common-features/nvidia-jetson-kernel-customization/csi-cameras-customization.md).

### **SD card**

Xavier nx supports addressing larger capacity SD 3.0 or SD-XC cards up to 2 TB. Recommended filesystem format is Ext4. Ext4 formatted SD card is automatically mounted after system boot with Airvolute provided system image.

{% hint style="warning" %}
SD card interface has no hot-plug feature, so SD card must be inserted before system boot.
{% endhint %}

#### **Instructions how to format SD card to Ext4 on Jetson:**

* Create a GPT partition table by issuing:

`sudo parted /dev/mmcblk1 --script -- mklabel gpt`

* Run the following command to create a EXT4 partition that takes the whole space:

`sudo parted /dev/mmcblk1 --script -- mkpart primary ext4 0% 100%`

* Format the partition to ext4:

`sudo mkfs.ext4 -F /dev/mmcblk1p1`

```
Example output : 
mke2fs 1.44.1 (23-Feb-2022)
/dev/mmcblk1 contains a vfat file system
Creating filesystem with 3777024 4k blocks and 944704 inodes
Filesystem UUID: 72231e0b-ddef-44c9-a35b-20e2fb655b1c
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done 
```

* Verify it by printing the partition table:

`sudo parted /dev/mmcblk1p1 --script print`

## The Cube peripherals

Signal names of all peripherals related to flight controller corresponds with ardupilot naming conventions. For more information about peripherals usage search on [ardupilot wiki page](https://ardupilot.org/ardupilot/index.html). For detailed connector pinouts see [Connectors and pinouts section](/autopilots/dronecore-1/pilot-boards/dcs1.pilot-v1.2/dronecore.pilot-connector-description-and-pins-assignment-1.md#the-cube-connectors).

### Interconnection Jetson <--> Flight controller unit

Nvidia Jetson is interconnected with flight controller by serial line (UART1(Jetson) <-> SERIAL2(f.c.)) and USB2.0 line. USB2.0 interconnection between Jetson and Cube is active by default, but it is possible to disable it using uhubctl tool.

{% hint style="danger" %}
If USB path interconnecting Jetson and Cube is not disabled in Jetson, it causes USB malfunctions when one needs to connect to Cube by external cable from host PC.
{% endhint %}

{% hint style="info" %}
Instructions to disable USB port to Cube:

**Install uhubctl:**

* git clone <https://github.com/mvp/uhubctl>
* cd uhubctl
* make
* sudo make install

**Execute commad in Jetson console:**

* uhubctl -a off -p 6
  {% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.airvolute.com/autopilots/dronecore-1/pilot-boards/dcs1.pilot-v1.2/dronecore.pilot-peripherals-1.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
