Module Integration Guides
...
Linux
Device Setup

Linux Generic

8min

Overview

This guide shows how to setup a generic Linux device to connect to Bytebeam. We assume you are using u-boot for the bootloader. If you are using a different bootloader please get in touch with us at [email protected] and we would be happy to guide you through the process.

Partition Schema

Create the following partitions on the device

Partition 1 - Boot partition of size around 100MB. Partition 2 - Root partition 1 (contains rootfs of Linux distro). Partition 3 - Root partition 2 (of size same as Root partition 1). Partition 4 - Download partition (to store application data)



Raspberry Pi Partition Scheme
Raspberry Pi Partition Scheme


At any given point in time either "Partition 2" or "Partition 3" will be the active rootfs partition, and the other partition is referred to as the inactive partition. Data/Download partition is where the persistent files are stored. During kernel & rootfs updates, the contents of inactive partitions are replaced with the new rootfs.

To begin with setup your existing rootfs into root partition 1 and point u-boot to boot into this partition. Once you have booted into partition 1:

  1. Mount the boot partition at /uboot.
  2. Mount the root partition 2 at /mnt/next_root.
  3. Mount the download partition 2 at /mnt/download.

Customizing u-boot for OTAs

Bytebeam uses uboot as the bootloader in order to support rollback feature, during rootfs updates. U-boot can be configured with the help of a boot script called boot.scr.

Root Switch Logic

This section explains the workings of u-boot for choosing the right partition to boot from. Understanding this section is required to be able to troubleshoot any issues you may face.

At a high level, we configure u-boot to look for a specific file in the boot partition to know which partition to boot form. For example, if file "two" is present, uboot boots from partition 2, and if file "three" is present, uboot boots from partition 3. The following flowchart explains the Root Switch logic in detail.

Document image


Generate boot.scr

The above logic needs to be implemented in the boot.scr file. Follow the below steps:

Step 1: Download the u-boot source code.

Step 2: Create the config. file named boot-cmd.txt. With the help of the "Root Switch" logic in this file, uboot can boot to the desired root partition. Note that this file depends on the type of the Linux device. Example files(uEnv.txt, rpi-boot-cmd.txt) are provied in the Github page.

Step 3: From the config. file, boot script file boot.scr can be generated by:

Shell


Step 4: Place the u-boot binary and boot script in the boot partition of the device.

Step 5: Ensure that the fstab has the proper partition configuration.

Setup uplink and OTA scripts

Step 1: Depending on the architecture of the device, the appropriate uplink binary can be downloaded from this link. Place it in the download partition, rename the binary as uplink, and make it executable.

Step 2: Download the setup scripts

Shell


Step 3: Add services to systemd

Shell


Step 4: Depending on the root partition, create the file "two" or "three" in the boot partition and in the download partition as well.

Shell


Step 5: Install vim and netcat

Shell


Boot the device. Ensure that the device has a good internet connection and that the system time is set properly.