Skip to content

OTA Framework and Implementation#3

Open
nfreq wants to merge 60 commits intozeroth-robotics:developfrom
nfreq:ota
Open

OTA Framework and Implementation#3
nfreq wants to merge 60 commits intozeroth-robotics:developfrom
nfreq:ota

Conversation

@nfreq
Copy link

@nfreq nfreq commented Jan 28, 2025


Build ZBot OTA System

source device/milkv-duos-ota-sd/boardconfig.sh 
source build/milkvsetup-ota.sh 
defconfig cv1813h_milkv_duos_ota_sd
clean_all
build_all

# generate three blank ext4 filesystems
------
dd if=/dev/zero of=install/soc_cv1813h_milkv_duos_ota_sd/env.ext4 bs=1k count=256
mkfs.ext4 install/soc_cv1813h_milkv_duos_ota_sd/env.ext4 

dd if=/dev/zero of=install/soc_cv1813h_milkv_duos_ota_sd/placeholder_staging.ext4 bs=1k count=300000
mkfs.ext4 install/soc_cv1813h_milkv_duos_ota_sd/placeholder_staging.ext4 

dd if=/dev/zero of=install/soc_cv1813h_milkv_duos_ota_sd/placeholder_data.ext4 bs=1k count=50000
mkfs.ext4 install/soc_cv1813h_milkv_duos_ota_sd/placeholder_data.ext4 

# should now have the following:
./install/soc_cv1813h_milkv_duos_ota_sd/env.ext4
./install/soc_cv1813h_milkv_duos_ota_sd/placeholder_data.ext4
./install/soc_cv1813h_milkv_duos_ota_sd/placeholder_staging.ext4
----

# generate the sd image file
pack_sd_image

# alternatively generate compressed image file for distribution
pack_sd_image_gz

# burn image to sd
Add wpa_supplicant.conf to boot parition

Build ZBot Main OS and perform OTA Updates

source device/milkv-duos-sd/boardconfig.sh 
source build/milkvsetup.sh 
defconfig cv1813h_milkv_duos_sd
clean_all
build_all
pack_sd_image
gen_swu_ota <version>
tools/zbot_updater.py update 192.168.42.1 install/<board>/zbot.swu

Parition Table
GPT/MBR Hybrid (Boot Partition UUID Set such that Mac/Windows will mount)

Upgraded Genimage to v18 (Support UUID Partition Types and Improved Hybrid Support)
(GPT Partition Table)
├── /dev/mmcblk0p1 (boot) [EFI System Partition, FAT32, 128M, Bootable]
├── /dev/mmcblk0p2 (env) [Linux, 256K]
├── /dev/mmcblk0p3 (otafs) [Linux, EXT4, 125M]
├── /dev/mmcblk0p4 (rootfs) [Linux, 275M]
├── /dev/mmcblk0p5 (data) [Linux, 50M]
└── /dev/mmcblk0p6 (staging) [Linux, 300M]

U-Boot Configured to Support Persistent Environment (ext4 backend via env partition)

Added data parition to seperate from rootfs. (config, weights, data)


OTA Environment Mechanics

Key Variables
---
rootfs=root=/dev/mmcblk0p4 rootwait rw   -- default rootfs location
otafs=root=/dev/mmcblk0p3 rootwait rw    -- default otafs location
root=root=/dev/mmcblk0p4 rootwait rw     -- booted partition

(this is the control variable)
next_boot = {otafs, rootfs}              -- next boot location

# example (boot into otafs)
fw_setenv next_boot otafs
reboot

boot-ota
boot-zbot

OTA Updater

# OTA CLI Tool
tools/zbot_updater.py update <host> <swu file>

SWUpdate Backend (Updated to v2022.12)

  • listens on port 10000 (via websocket and http)
  • stages firmware, writes raw image to partition, writes files, updates microcontrollers
  • handles hw compatibility, sw version rules, hash validation and compressed images.

sw-description (generated via gen_swu_ota)

software = {
    version = "1.01";
    description = "Zeroth01 v1.01 Update";
    hardware_compatibility = ["1.0", "1.1"];
    images = (
        {
          filename = "rootfs.ext4.gz";
          device = "/dev/mmcblk0p4";
          type = "raw";
          sha256 = "2a603bae7d73c95f4bff20f775a487c1e336430a21e525777a2516c7f73d5a5f";
          compressed = "zlib";
        }
    );
}

Work in progress

  • Update utility triggers rootfs to reboot into otafs for updates
  • LCD / Local UI for update process (show progress, ask confirm to update etc.)
  • Checking/Downloading update from github/gitlab (Zeroth team feedback)
  • Move this to BR_EXTERNAL (shouldn't be entangled in buildroot source tree direclty)
  • Add redundancy (u-boot env, otafs a/b, u-boot a/b) (ordered for priority)
  • Security

nfreq and others added 30 commits January 24, 2025 00:58
…console from getting wrecked at u-boot reloc)
first_boot flag gets set after first run (forces saveenv to populate ext4 part)
next_boot determines which parition u-boot points to

next_boot = rootfs, recovery_primary, recovery_secondary
…0 to become available, then starts the service) wrote an if statement to jump out the auto.sh section
@jingxiangmo jingxiangmo marked this pull request as draft January 28, 2025 04:04
@nfreq
Copy link
Author

nfreq commented Feb 11, 2025

This PR is ready for internal team to start using. I will revisit with a new PR when we iron out the cloud based portion of the update mechanism

@nfreq nfreq marked this pull request as ready for review February 11, 2025 03:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant