# Linux

This is written for debian, raspian or ubuntu. You'll have to make the usual adjustments if you're using something else.

## Update your OS

First, update and upgrade your OS

```
sudo apt update
sudo apt upgrade -y
```

## Access to USB Serial

Add your user to the dialout group, change `$USER` to your user name. This allows your user to access the USB serial device.

```
sudo usermod -a -G dialout $USER
```

You'll need to logout and back in again.

## Flash the companion

> [!NOTE]
> If you've already flashed your companion with the MeshCore firmware you can skip this step.

> [!IMPORTANT]
> Make sure you flash with "Companion USB" not "Companion Bluetooth"

> [!NOTE]
> TODO find out how to do this on the CLI

## Install needed software

Install pipx, make sure the bin dir is in the path, then install [[Meshcore-Cli|Meshcore/Meshcore-Cli]]

```
sudo apt install pipx
pipx ensurepath
pipx install meshcore-cli

or

sudo pipx install meshcore-cli --global
```

Logout and back in again.

## Find the USB device

```
meshcli -l
```

Output probably looks like this, you'll want to use the USB one:

```
BLE devices:
 No BLE HW

Serial ports:
 /dev/ttyS0         n/a [n/a]
 /dev/ttyUSB0       CP2102 USB to UART Bridge Controller - CP2102 USB to UART Bridge Controller [USB VID:PID=10C4:EA60 SER=0001 LOCATION=1-1]
```

## Create serial based symlink

This creates `/dev/meshcore0` using your devices serial number, which is much more reliable than `ttyUSB0` or `ttyACM0` which can change.

If you want to change to a different board, you'll have to create `meshcore1` or update these values.

```
sudo udevadm info -a -n /dev/ttyUSB0 | vi -
```

Look for ATTRS{serial} and ATTRS{idVendor}:

```
    ATTRS{idVendor}=="303a"
    ATTRS{serial}=="332AC33C8CDC"
```

Then open this file:

```
sudo vi /etc/udev/rules.d/99-meshcore.rules
```

put a line in similar to this:

```
SUBSYSTEM=="tty", ATTRS{idVendor}=="303a", ATTRS{serial}=="332AC33C8CDC", SYMLINK+="meshcore0"
```

run the following:

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

## Start MeshCLI

```
meshcli -s /dev/meshcore0
```

### Configure node

Do basic companion configuration. You should only need to do this once, unless you want to change these settings:

```
meshcore-cli -s /dev/meshcore0 set radio 915.800,250,11,5
or
meshcore-cli -s /dev/meshcore0 set radio 915.075,125,9,5

meshcore-cli -s /dev/meshcore0 set name "🦷 rdm cli 0"
meshcore-cli -s /dev/meshcore0 advert
```
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9