# Updating a device

> Install a signed X-Edge Vision update on site in about two minutes, and read the result.

For the person on site. An update takes about two minutes. If anything below is
unclear, stop and contact support before you start.

## What you need

- The two update files, with the same name and one ending in `.sig`:
  `edgevision-<version>-tx2-arm64.tar.gz` and
  `edgevision-<version>-tx2-arm64.tar.gz.sig`. Both are needed. The second proves
  the first came from Xisom and was not changed.
- A laptop on the same network as the device, the device's address, and its
  login name.

Do not switch the device off or unplug it from the moment you press Enter in
step 3 until you see the last line.

## Steps

1. **Copy the two files to the device**, into one folder (here `incoming`), from
   the laptop. If the folder does not exist yet, make it first with
   `ssh <login>@<address> mkdir -p incoming`.

   ```bash
   scp edgevision-<version>-tx2-arm64.tar.gz edgevision-<version>-tx2-arm64.tar.gz.sig <login>@<address>:incoming/
   ```

2. **Log in to the device:**

   ```bash
   ssh <login>@<address>
   ```

3. **Run the update** with the name of the first file, as yourself and not with `sudo`:

   ```bash
   edgevision-install incoming/edgevision-<version>-tx2-arm64.tar.gz
   ```

   It prints what it is doing. Wait until it returns to the prompt, then read the
   last lines.

## What the last line means

| It says | What it means | What you do |
|---|---|---|
| `Installed <version>.` | The device runs the new version and the video part is running. | Open `http://<address>:5080/` and check the version at the bottom of the page. |
| `Installed <version>, but the relay is NOT running: ...` | The device runs the new version, but cameras show no video until the video part is fixed. | Do not try again. Send the log to support and say the device shows no video. |
| `Not installed: ...` and `The device is still running <old version>.` | Nothing was changed. The line before says why. | See the reasons below. |
| `Not installed: the new version did not start.` and `The previous version is running again.` | The new version did not work and the device put the old one back by itself. | Send the log to support. Do not try the same files again. |
| `THE DEVICE IS NOT RUNNING. Do not switch it off.` | The device could not recover on its own. | Do not switch it off. Send the log to support now. |

### Reasons after "Not installed"

| The reason starts | Usually | What to do |
|---|---|---|
| `there is no signature file beside the bundle` | The `.sig` file is missing or named differently. | Copy the `.sig` file with the same name into the same folder and repeat step 3. |
| `the signature does not match` | The file was damaged while copying, or it is the wrong file for this device. | Copy both files again from the original source and repeat step 3. If it happens again, send the log to support. |
| `a file in the bundle does not match its checksum` | The same, or the update itself is wrong. | Copy again. If it happens again, send the log to support. |
| `version ... is already installed` | This update is already on the device. | Nothing to do. |
| `version ... is older than the installed ...` | You have an older update than the one on the device. | Nothing was changed. Ask support for the right file. |
| `not enough free space` | The device is full. | Send the log to support. |
| `this bundle is for a Jetson TX2` | You are logged in to a different machine. | Log out, check the address and start again from step 2. |
| `this must not be run as root` | The command was run with `sudo` or as the administrator. | Run it again as the normal login, without `sudo`. |
| `this bundle needs a newer device setup` | The device needs a setup step that only support can do. | Send the log to support. |

## What to send back when something goes wrong

Send two things to support:

1. The log, from the laptop:

   ```bash
   scp <login>@<address>:edgevision/install.log .
   ```

2. The version the device runs, from the device: `cat edgevision/VERSION`.

Also say which file name you used and what the last line said.

## What the installer protects

Before anything changes, the installer checks the signature against the public key
that was installed on the device when it was set up, and every file against the
bundle's checksums. It always refuses an older version, because database
migrations only run forward. It takes a database snapshot and, if the new version
does not answer, puts back the previous program, console, inference code and
database.

Copying the files by USB stick has not been tried, so it is not described here.
