Skip to content

POC: tests: e2e: Add a virtual Navigator target - #5014

Draft
joaoantoniocardoso wants to merge 19 commits into
bluerobotics:masterfrom
joaoantoniocardoso:vnav-e2e-poc
Draft

joaoantoniocardoso wants to merge 19 commits into
bluerobotics:masterfrom
joaoantoniocardoso:vnav-e2e-poc

Conversation

@joaoantoniocardoso

Copy link
Copy Markdown
Member

Note

This is a proof of concept. It holds all the changes in one PR so you can see the full result and give feedback. It is not meant to merge as it is. If the idea is valuable, it will be split into the PRs listed in "Proposed work".

Open questions for reviewers

  1. Is this valuable? Do we want vehicle e2e tests that run the real BlueOS core and the real ArduSub firmware against a simulated Navigator, in CI, on every PR?
  2. If yes, how do we deal with the ArduPilot patches, and where do they live? The chip models are 23 patches (3,649 lines) on ArduPilot 372f21f6f5. In this POC they live in this repository and CI builds the SITL from them. Some options:
    • Keep them in this repository, as in this POC.
    • Send them to ArduPilot upstream, then pin an upstream commit.
    • Keep them on a branch of a Blue Robotics ArduPilot fork, and pin a commit of that branch.

What this adds

This PR adds a new e2e target, vnav: a "virtual Navigator". BlueOS sees a Navigator board, picks the official ArduSub navigator firmware, and runs it unchanged. Behind the Linux I2C and SPI devices, a patched ArduPilot SITL simulates the vehicle and the sensor chips of the Navigator. So the vehicle tests run the real BlueOS core image and the real firmware binary on a GitHub ubuntu-24.04-arm runner, with no hardware.

flowchart LR
  FW["ArduSub navigator firmware<br/>(official binary, in blueos-core)"] -- "/dev/i2c-N, /dev/spidevB.C" --> FWD["vnav-forwarder<br/>(CUSE devices)"]
  FWD -- "TCP 127.0.0.1" --> BR["vnav bridge<br/>(in SITL)"]
  BR --> CHIPS["SITL chip models<br/>IMU, compass, baro, ADC, PWM, LED"]
  CHIPS --> PHYS["SITL vehicle physics"]
Loading

How it works

  • Devices: vnav-forwarder (tests/e2e/targets/vnav/native/vnav-forwarder.c) creates /dev/i2c-* and /dev/spidev* with CUSE. It sends each transfer over TCP to the SITL and returns the answer. It serves 64-bit and 32-bit clients.

  • Chip models: 23 patches on ArduPilot 372f21f6f5 (tests/e2e/targets/vnav/sitl/patches/) add a TCP bridge and models of every chip on the Navigator:

    • IMUs: ICM20602, LSM6DSV.
    • Compasses: MMC5983, AK09916, IIS2MDC.
    • Barometers: BMP280, BMP388, and an MS5837 depth sensor.
    • Others: ADS1115 ADC (battery voltage and current), PCA9685 PWM (the servo outputs drive the SITL motors), SK6812 LED.

    The env SITL_VNAV_CHIPS selects the chip set. Each model gives the chip ID, the register map and the mounting rotation of the real board. build.sh builds the SITL from the pinned commit and the patches. CI keeps the build in a cache.

  • Board detection: dtlink gives /proc/device-tree on the ACPI runner, so BlueOS detects a Navigator. A loop device holds the GPIO registers in place of /dev/mem, so the leak input and the PCA9685 output enable can be read and set.

  • Serial port: a pty, assigned with PUT /serials, carries an NMEA GPS stream.

  • Target: VnavTarget (tests/e2e/targets/vnav/target.py) starts the forwarder, the SITL, the bootstrap and the core container. It stops only the containers it created.

Tests

Vehicle scenarios in tests/e2e/scenarios/vehicle/. Each skips on a target that does not have the VirtualNavigator feature.

Test file What it checks
test_detection.py BlueOS detects a Navigator and runs ArduSub.
test_health.py All sensors are present and healthy. Attitude matches the simulator. Pressure is sane.
test_motion.py Motor commands change the PWM outputs and move the vehicle. Depth changes in a dive.
test_gpio.py The firmware enables the PCA9685 outputs. The leak input reaches the firmware.
test_serial.py A GPS on a serial port gives a fix at the expected position.
test_reboot.py Sensors are healthy and the simulator still drives the firmware after a firmware restart.
test_timing.py A 45 s armed flight logs no firmware internal error (ErrL), the loop rate stays above 50 % of 200 Hz, and the barometers stay healthy. The other loop values are logged only.

Target tests in tests/e2e/targets/vnav/: the forwarder ioctls for 64-bit and 32-bit clients, and the bus round trip. tests/e2e/targets/test_docker.py is a unit test of the shared has_platform.

CI

  • New workflow: .github/workflows/e2e-vnav.yml runs 3 entries on ubuntu-24.04-arm:
    • default: the arm64 core and the stable firmware that BlueOS picks.
    • default-32bit: the arm/v7 core. BlueOS then picks the armhf navigator firmware.
    • alternative: the other chip set (LSM6DSV, IIS2MDC, BMP388), with ArduSub 4.7.2, because Navigator support for the LSM6DSV starts at 4.7.0.
  • Main CI: test-and-deploy.yml calls it as job e2e-vnav-tests. The job uses the core image that deploy-docker-images built for the commit, from the build artifacts.
  • Run time: each entry takes about 4 to 5 min when the SITL build is in the cache.

Changes to existing code

  • tests/e2e/targets/sil/docker.py moves to tests/e2e/targets/docker.py. The image pull and the bootstrap start are split into shared functions, which the SIL and vnav targets both use. A real SIL run of scenarios/core/test_boot.py passed after the move.
  • tests/e2e/conftest.py selects the target with E2E_TARGET (default sil).
  • .github/workflows/test-and-deploy.yml: on a repository that does not belong to bluerobotics and has no DOCKER_USERNAME secret, the Docker Hub login, push and inspect steps skip. The build and artifact steps still run, so the e2e jobs work on forks. On bluerobotics repositories these steps run as before.

Known limits

  • About 1 runner in 6 of ubuntu-24.04-arm (Neoverse-V3) cannot run 32-bit programs. There, the default-32bit entry skips its tests, prints a warning, and stays green. A re-run gets a real run.
  • The runner always has a 64-bit kernel. A 32-bit kernel (armv7l) is not tested.
  • The ArduPilot changes live as patches in this repository. They are not in ArduPilot upstream.
  • I2C_SMBUS block transfers are not served. ArduPilot and i2c-tools do not use them.

Evidence (fork runs)

  • e2e-vnav.yml: 3 entries green in 3 runs on the final code: 47559164072, 47559203591, 47559206104.
  • Full main CI with e2e-vnav-tests: 47551743679 (all jobs green; the 32-bit entry loaded the arm/v7 core from the artifact). Run 47556169867 (code before the last test-file move): all jobs green, 25 passed per entry.

Proposed work

If the answer to question 1 is yes, this POC becomes a chain of PRs. Sizes are lines added and removed. "To review" leaves out the ArduPilot patches and uv.lock.

# PR Size To review Depends on
1 CI: skip the Docker Hub push when there is no login +3 −3, 1 file 6 none
2 e2e harness: prepare for a second target (skip the tests of a feature the target lacks, shared targets/docker.py, E2E_TARGET) +71 −12, 6 files ~80 none
3 e2e: add the virtual Navigator target (dependency group, feature, clients, target, forwarder, SITL patches, vehicle tests, e2e-vnav.yml) +5,537 −3, 50 files ~1,570 2
4 e2e vnav: GPIO, serial port and restart tests +320 −2, 10 files ~320 3
5 CI: run the vnav e2e tests in the main CI on the core image of the commit +35 −11, 3 files ~45 4
6 e2e vnav: 32-bit core (compat ioctls, GPIO registers on a loop device, third CI entry) +214 −51, 10 files ~265 5

PR 3 is large because of the ArduPilot patches (3,649 lines) and uv.lock (322 lines). If the patches move out of this repository (question 2), PR 3 drops to about 1,900 lines.

Other points for reviewers

  • The Docker Hub guard in test-and-deploy.yml is independent of the vnav target. It can move to its own PR (PR 1 above).
  • e2e-vnav-tests runs on every PR, push and scheduled run. The timing checks are loose on purpose, so runner noise does not make a PR red.

…bootstrap

The module moves from targets/sil to targets, because a target that
runs Docker on its own host uses it too. pull_if_missing takes a
platform, and run_bootstrap takes the function that runs a command.
… calls

The vehicle tests need to set the serial ports through ardupilot_manager,
read and set the flight mode, and restart the autopilot and wait for the new
firmware.
…virtual Navigator

The GPIO registers are the file the firmware maps as /dev/mem, so the target
drives an input pin and reads what the firmware did to an output pin. A serial
port is a pseudo terminal that the test owns.
… tests

The leak input triggers the leak failsafe, the firmware enables the PCA9685
outputs, a GPS stream on a port set in ardupilot_manager gives a fix, and the
firmware comes back after a restart with the simulator still driving it.
The CI builds the arm64 core image of the commit under test and loads it into
docker. No registry has that tag.
…ere is no login

A fork has no Docker Hub secrets. The login step fails there, and the
jobs that need the core image artifacts do not start. The steps that
log in, push and inspect the pushed image now run only on a fork with
no DOCKER_USERNAME. In the bluerobotics organization they always run,
so a missing secret still fails the job. The steps that build and
upload the artifacts run as before.
…ommit

The test-and-deploy workflow builds an arm64 core image and uploads it as an
artifact. The vnav job loads that image. The standalone runs of the vnav
workflow keep the registry image.
A 32-bit client on a 64-bit kernel sends the compat ioctls. Their structs
have 32-bit pointers, and I2C_FUNCS has a 4 byte answer. The forwarder
decodes both layouts.

ArduPilot sign extends the 32-bit pointers it puts in the 64-bit fields
of spi_ioc_transfer. The kernel truncates them for a compat client, so
the forwarder does the same.

Add "bench check". It calls each ioctl a client uses and checks the
answers. build.sh also builds it as a static 32-bit program, when a
32-bit compiler is there.
A 32-bit process cannot open the regular file that was bound to
/dev/mem. The file is longer than 2 GiB, so open fails with EOVERFLOW.
A block device has no such limit.

Use a loop device on a sparse file. Its node is in /var/lib/vnav and
not in /dev, because devtmpfs is mounted noexec and the firmware maps
the memory with PROT_EXEC.
E2E_CORE_PLATFORM=linux/arm/v7 pulls the 32-bit core image. Its userland
is 32-bit on the 64-bit kernel of the host, which is what BlueOS sees on
a Raspberry Pi with a 64-bit kernel and 32-bit Raspberry Pi OS. Then
ardupilot_manager reports "navigator" and runs the armhf firmware.

The detection test expects the platform of the userland. A new test
runs the bus ioctls as a 64-bit and as a 32-bit client. It skips when
the host cannot run 32-bit programs.
Add a matrix entry that uses the arm-v7 core image. The ubuntu-24.04-arm
runners do not all have a 32-bit mode: Neoverse-N2 CPUs have it and
Neoverse-V3 CPUs do not. On a runner without it the entry skips its
steps and prints a warning, because a job cannot choose its CPU.
@joaoantoniocardoso
joaoantoniocardoso requested a review from a team December 5, 2026 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant