> ## Documentation Index
> Fetch the complete documentation index at: https://bytebeam.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# App Update

> Learn how to update an application binary on a remote device using Bytebeam cloud with this comprehensive guide. It covers essential steps such as setting the application path, incorporating the application into systemd, and creating an update tar file.

This guide talks about how to update an application binary of the remote device from the Bytebeam cloud. App update replaces the existing binary on the system with the binary uploaded on the Bytebeam cloud. We have provided an example application on our [Github](https://github.com/bytebeamio/uplink/tree/main/examples/rpi/updates/app_update) page. There are four files in the example.

* **hello\_app** - Prints "Hello from Bytebeam" every 3 seconds.
* **app\_update.sh** - This script replaces the old application with new application.
* **update.sh** - This is a wrapper script for app\_update.sh script.
* **make\_firmware\_update.sh** - It creates the update tar file.

## Step1: Prepare update tar

Firstly on your Linux system, we need to create an update tar file for Raspberry Pi. For that, Download all the files mentioned above from GitHub. Next, we need to change the permissions for all these files using `chmod` command

```shell theme={null}
chmod a+x hello_app
chmod a+x app_update.sh
chmod a+x update.sh
chmod a+x make_firmware_update.sh 
```

Next run **make\_firmware\_update.sh** to create a tar.gz file.

```shell theme={null}
./make_firmware_update.sh
```

## Step 2: upload update Tar

Next, we need to upload the tar to [bytebeam cloud.](https://cloud.bytebeam.io/) For that go to device management panel and click on the **Firmware Versions** tab.&#x20;

<img src="https://mintcdn.com/bytebeamio/FMXgxOtBRa9JcG8R/assets/Sj5Ohn7jStYGBTur5AE4C_linuxdocsupdaterollback2.png?fit=max&auto=format&n=FMXgxOtBRa9JcG8R&q=85&s=77e3550663178ed4684b4397e577afe7" alt="" width="1641" height="520" data-path="assets/Sj5Ohn7jStYGBTur5AE4C_linuxdocsupdaterollback2.png" />

Under the Firmware version tab, you will find an option to create a firmware version number and upload your updated tar file.

Enter the new **Firmware version number** and click on **choose file** to upload tar file. Then click on **Create.**&#x20;

<img src="https://mintcdn.com/bytebeamio/1h3XTf0vWTDRsKc2/assets/ErrnlVBZhXUFEt7LRoMpI_linuxdocsupdaterollback6.png?fit=max&auto=format&n=1h3XTf0vWTDRsKc2&q=85&s=399f9c89ee1de828a26f0125e5fb1da6" alt="" width="1102" height="481" data-path="assets/ErrnlVBZhXUFEt7LRoMpI_linuxdocsupdaterollback6.png" />

## Step 3: Set the application path

In **step 1** we have already assumed that you want to update\*\* **the** hello\_app\*\* that exists on your remote device and we created an update tar accordingly. On the remote device, the app is expected to be in **/usr/local/bin** location. If it's not there then create a new **hello\_app** in **/usr/local/bin.**

```shell theme={null}
#!/bin/bash

while [ 1 ]
        do
                sleep 3
                echo "Hi from Bytebeam"
        done
```

If the application location and app name are different, set the path in app\_update.sh script in **Step 1**.&#x20;

```shell theme={null}
APP_NAME=hello_app
APP_BIN_PATH=/usr/local/bin
```

## Step 4: Create systemctl service to debug update changes

To debug your changes after the app update, Let's create a service that runs hello\_app. So, create this service named **\<App Name>.service** and place it in **/etc/systemd/system**.

```none theme={null}
[Unit]
Description=Simple Application service
After=network.target auditd.service

[Service]
ExecStart=/usr/bin/bash /usr/local/bin/hello_app
KillMode=process
Restart=on-failure
Type=simple

[Install]
WantedBy=multi-user.target
```

Reload systemctl daemon and start the service.

```shell theme={null}
sudo systemctl daemon-reload 
sudo systemctl enable hello_app.service
sudo systemctl start hello_app  
```

## Step 5: Trigger "update firmware" action from bytebeam cloud&#x20;

Now let's proceed with our OTA update. For that, Go to the **Device Management** panel and select the device

Next, Click on the **update firmware**

<img src="https://mintcdn.com/bytebeamio/cbGbxWM_WJ5eoYoh/assets/2tkbu4SMPqYerxEHmsKID_linuxdocsupdate12.png?fit=max&auto=format&n=cbGbxWM_WJ5eoYoh&q=85&s=7cff5ba8b9efa2356e19060c79c90af2" alt="" width="1191" height="542" data-path="assets/2tkbu4SMPqYerxEHmsKID_linuxdocsupdate12.png" />

In the next prompt choose the **firmware version** and click on **next**

<img src="https://mintcdn.com/bytebeamio/YHzSdxshzM_D0J4F/assets/bpMRDzWv9gLhZ0UFeiiXx_linuxdocsupdate14.png?fit=max&auto=format&n=YHzSdxshzM_D0J4F&q=85&s=ee06abd7f9320d5edf3fa9f1c2979b27" alt="" width="728" height="333" data-path="assets/bpMRDzWv9gLhZ0UFeiiXx_linuxdocsupdate14.png" />

Monitor the progress of firmware updates in the action panel. and on your remote device, you can see  updated **hello\_app**

<img src="https://mintcdn.com/bytebeamio/ZdhGbGJHpHWsN9k0/assets/8oTRDd3EnhmvIwOwD-HZG_linuxdocsupdate16.png?fit=max&auto=format&n=ZdhGbGJHpHWsN9k0&q=85&s=455d841e84837552552792f995faa549" alt="" width="737" height="575" data-path="assets/8oTRDd3EnhmvIwOwD-HZG_linuxdocsupdate16.png" />

<img src="https://mintcdn.com/bytebeamio/qFHdi6YCHCT3kYFV/assets/VvD4ILamsTOWJHwAnkZnv_linuxdocsupdate17.png?fit=max&auto=format&n=qFHdi6YCHCT3kYFV&q=85&s=df4d88a62aa73345e5621b6afb33ce24" alt="" width="872" height="410" data-path="assets/VvD4ILamsTOWJHwAnkZnv_linuxdocsupdate17.png" />

## Update uplink

Using these steps we can update the uplink as well.&#x20;

### Steps to follow

**Step 1:** In the example, replace the hello\_app with the uplink binary.&#x20;

**Step 2:** Change the uplink path and application name in app\_update.sh

**Step 3:**  Run make\_firmware\_update.sh.&#x20;

**Step 4:** Upload the generated update tar file to Bytebeam cloud.
