# R- Group Software Setup Guide

## Flashing to SD-Card

Before using the Rxx you will need to prepare a micro SD card for the Raspberry Pi Zero. Start by flashing your micro SD using any flashing tool like the '[Raspberry Pi Imager](https://www.raspberrypi.com/software/)' (available for Linux, Windows and macOS) and select any 32-bit OS – e.g. "Raspberry Pi OS (Legacy) Lite" from 2023-12-05.

<figure><img src="/files/dOzflIiwP6aFQas1tlyJ" alt=""><figcaption></figcaption></figure>

### Pre-boot Configuration

After your flashing tool is done writing the RPi OS, the config file in the micro SD card's "`bootfs`" (or "`boot`" in older releases) partition needs to be edited before putting it into the RPi Zero – this step is important because otherwise the Pi (depending on the chosen OS version) may not be able to boot. Navigate into the "`bootfs`" partition, open "`config.txt`" and append the following in a new line:

```bash
gpio=21=op,dl
```

<figure><img src="/files/vRBkN0jdd1lNrkR4WM9F" alt=""><figcaption></figcaption></figure>

Now you can put the micro SD card into the Pi Zero and power on the R21.

## Enable I2C

Several resources on the carrier board are linked to the Cam I²C, which is hidden by default.

```bash
sudo raspi-config
```

`3 Interface Options` → `I5 I2C` → Press Tab, select and to reboot

<figure><img src="/files/5t22ryKkEv7epevMb30B" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/gRw1qLXJwCZNfsSvnrDH" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/6qvPyxipgs3xlPXnb3ve" alt=""><figcaption></figcaption></figure>

## Accessing carrier board EEPROM

Write protection is activated by default. To deactivate it temporarily, short the pins located 1 CM above the Pi Zero's SD card slot during the writing process.

`i2c-tools` are used in this example to read and write data to the EEPROM. This library can be installed with the following commands:&#x20;

```bash
sudo apt update
sudo apt install i2c-tools
```

<figure><img src="/files/fVOLCG0nw4LaxLqSpSm9" alt=""><figcaption></figcaption></figure>

Read or writing to an I²C device is performed with   `i2cset` , `i2cget`or `i2ctransfer` on the device address `0x50` and I²C bus  `1`

More Information about I²C can be found in our [I2C - Guide](https://auvidea.gitbook.io/i2c/)

```bash
sudo i2cdetect -y -r 1
```

<figure><img src="/files/PmvFoPIfdwZI0O0F0Io7" alt=""><figcaption><p>I²C device list on bus 1</p></figcaption></figure>

```bash
sudo i2cdump -y 1 0x50
```

<figure><img src="/files/tsS37X1r8kQxSBlhXIY7" alt=""><figcaption><p>Contents of EEPROM using i2cdump</p></figcaption></figure>

```bash
sudo i2ctransfer -y 1 w5@0x50 0x00 0x54 0x45 0x53 0x54
sudo i2cdump -y 1 0x50
```

<figure><img src="/files/vkifx64Jy5PlxsEbv1Tp" alt=""><figcaption><p>Example write to EEPROM and dump of changed content</p></figcaption></figure>

The following example tries to overwrite the written data in the previous step without the write protect pin shorted.

```bash
sudo i2ctransfer -y 1 w5@0x50 0x00 0xff 0xff 0xff 0xff
sudo i2cdump -y 1 0x50
```

<figure><img src="/files/Z2E7ML9F2D1X9ZrRHRd4" alt=""><figcaption><p>Write with write protect enabled</p></figcaption></figure>

## GPIO Functions

### Command cheat sheet

```bash
echo [GPIO_NR] > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio[GPIO_NR]/direction
echo [0/1] > /sys/class/gpio/gpio[GPIO_NR]/value
```

A more detailed description on how to use GPIO's are described in our [GPIO - Guide](https://auvidea.gitbook.io/gpio/)

<table><thead><tr><th width="118.33333333333331">Functjion</th><th width="176">Default state</th><th>Description</th></tr></thead><tbody><tr><td>RGB LED</td><td>Low</td><td>GPIO19 = R, GPIO13 = G, GPIO26 = B; high active</td></tr><tr><td>USB Hub</td><td>High</td><td>GPIO16; high active</td></tr><tr><td>M.2 LTE</td><td>High</td><td>GPIO17; high active</td></tr><tr><td>M.2 SSD</td><td>High</td><td>GPIO21; ;disabled by previous modification in "/boot/config.txt"</td></tr></tbody></table>

<figure><img src="/files/ys0dBG6gQJxeWm9dPimC" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/3wfzdHiohDF3E4a8Lgun" alt=""><figcaption></figcaption></figure>

### Enable/Disable M.2 SSD

```bash
echo 21 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio21/direction
echo 1 > /sys/class/gpio/gpio21/value # Set GPIO to 1 -> Enable SSD Slot
```

After the enable signal is activated, the USB to PCIe converter is detected as a `JMicron Technology Corp.` device when using the `lsusb` command.

<figure><img src="/files/xaBldyqmFB2BG9qFCNjH" alt=""><figcaption><p>lsusb output before and after enable signal</p></figcaption></figure>

When using `lsblk` the connected SSD should be identifiable as an `sdx` device. In the following example visible as `/dev/sda`.

<figure><img src="/files/PzJ8emufn4rfLghmWpOc" alt=""><figcaption><p>lsblk output &#x26; example mount</p></figcaption></figure>

### Enabling/Disable M.2 LTE module

```bash
echo 17 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio17/direction
echo 1 > /sys/class/gpio/gpio17/value # Set GPIO to 1 -> Enable M.2 LTE Slot
```

After the enable signal is activated, the LTE Module used in the following example is detected as `Sierra Wireless Inc.` device when using the `lsusb` command.

<figure><img src="/files/mDLW8ITIbp8nbu2mKgCW" alt=""><figcaption><p>lsusb output for M.2 LTE Module</p></figcaption></figure>


---

# 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://auvidea.gitbook.io/r20.1-r21-r22-software-setup-guide/guide/r-group-software-setup-guide.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.
