Skip to content

HAL contract: relay owns the peripheral-abstraction seams + protocol/CAN components; jess binds them to i.MX RT1176 silicon (Pixhawk 6X-RT, on-FMU first) #62

Description

@avrabe

Synchronization issue between relay (verified flight software) and jess (hardware integration) for getting the proven cascade onto the Pixhawk 6X-RT (NXP i.MX RT1176, dual Cortex-M7+M4).

The contract (agreed split)

  • relay owns the hardware ABSTRACTION: the bus/peripheral seam traits (SPI/I2C/UART/PWM/ADC/CAN), the verified protocol bodies on top of them (sensor register maps, UBX, DShot, DroneCAN message/node codecs), the driver traits, and the component-model (WIT) wiring. Portable, no_std, verification-carrying.
  • jess owns the BINDING to real silicon: concrete impls of those seams over the i.MX RT1176 peripherals (register/DMA/pinmux/clock/IRQ), the board BSP, and on-silicon validation (timing, error handling, FIFO/data-ready). Board-specific bytes.

Seam in the middle = the thin agreed interface. relay can't break it without telling jess; jess can swap silicon under it without touching the flight stack. (Same pattern as relay#177 / relay-bus for the inter-core carrier.)

Seam inventory — what exists, what relay adds, what jess binds

Seam (relay trait) Status on relay side i.MX RT1176 peripheral (jess binds) On-FMU 6X-RT users
RegBus (read_reg/write_reg/read_burst) ✅ exists — but duplicated in falcon-imu-icm42688 + falcon-baromag; relay will consolidate into one shared seam crate LPSPI (IMUs) + LPI2C (baro/mag/FRAM) — DMA, CS, timing 3× IMU, baro, mag, FRAM
AdcIn (channel → raw count) ❌ relay to ADD (battery body consumes counts today) LPADC battery V + current sense
PwmOut / actuator-frame sink (incl. DShot bit-timing) ❌ relay to ADD (DShot frame encoding exists) eFlexPWM / FlexIO+eDMA (DShot) main ESC outputs
SerialBus (byte source/sink) ❌ relay to ADD (UBX + MAVLink consume byte streams today) LPUART — DMA RX/TX GPS, telemetry radio
CanBus (frame tx/rx) + DroneCAN node/message components ❌ relay to ADD — both the seam and the protocol components (analogous to relay-ccsds/relay-mavlink) FlexCAN (CAN-FD) external ESC/battery/airspeed/rangefinder

Verified protocol bodies that already sit on these seams (relay-side, stay as-is): falcon-imu-icm42688 (ICM-42688-P, SPI), falcon-baromag (IST8310 mag + BMP388 baro), falcon-gnss-ubx (u-blox UBX), falcon-esc-dshot (DShot frame + CRC), battery ADC→volts. All carry Kani totality harnesses.

Driver-trait layer (relay falcon-core): FlightBackend + ImuDriver/PositionDriver/MagDriver/MotorDriver/BatteryDriver — jess's bound peripherals get composed into a HardwareBackend that satisfies these.

Sequencing — on-FMU first, then outward (per the agreed plan)

Phase 1 — on-board Pixhawk 6X-RT peripherals (already on the FMU):

  • SPI IMUs + I2C/SPI baro/mag via consolidated RegBus ← jess: LPSPI/LPI2C bindings + pinmux + which-chip-on-which-bus topology
  • battery/current via AdcIn ← jess: LPADC binding
  • main ESC outputs via PwmOut/DShot ← jess: eFlexPWM / FlexIO+eDMA binding
  • sensor calibration + mounting remap (currently hardcoded identity on relay side; relay exposes the cal seam, jess supplies the per-board values)

Phase 2 — external peripherals (via connectors):

  • GPS/compass + telemetry radio via SerialBus ← jess: LPUART DMA bindings
  • CAN/DroneCAN devices (external ESCs, smart batteries, airspeed, rangefinder) — relay builds the DroneCAN message/node components on the CanBus seam; jess binds FlexCAN.

What relay (I) will deliver — my commitments

  1. Consolidated relay-hal bus-seam crate — one RegBus (kill the duplication), plus new SerialBus, PwmOut, AdcIn, CanBus traits. no_std, forbid(unsafe_code) where possible, Kani-totality on the protocol consumers.
  2. DroneCAN/UAVCAN message + node components on CanBus (protocol layer — the relay-ccsds/relay-mavlink pattern).
  3. WIT wiring so each driver plugs into the stream/component graph (meld-fusable).
  4. The meld→synth→gale path that lands the verified cascade as a runnable i.MX RT1176 ELF, and the on-silicon WCET measurement harness to validate the 1 kHz loop (closes the one soft spot in the Lean timing proof).
  5. Keep the inter-core (M7↔M4) carrier (relay#177 / relay-bus) ready so jess can run sensor I/O on M4, flight stack on M7.

What jess provides — please confirm/track on your side

  1. i.MX RT1176 BSP: clock tree, pinmux, the 6X-RT bus topology (which sensor on which LPSPI/LPI2C).
  2. embedded-hal-grade impls of each seam over LPSPI/LPI2C/LPUART/LPADC/eFlexPWM/FlexCAN (DMA + IRQ + error handling).
  3. Per-board calibration values (accel/gyro/mag mounting, baro NVM trim).
  4. On-silicon validation: timing, FIFO/data-ready IRQs, bus error recovery — the things the protocol-only Kani harnesses can't prove.
  5. First HIL bring-up (relay sim → HIL → real drone).

Open questions to sync on

  • Core split: do we run sensor I/O on M4 and flight stack on M7 (inter-core via relay#177), or single-core M7 first? Affects whether the seams need to be inter-core-transparent from day one.
  • DShot path: eFlexPWM vs FlexIO+eDMA on the RT1176 — which gives cleaner bit-timing? (Affects whether PwmOut is duty-based or frame-based.)
  • Trait shape: should the seams be sync blocking, or async (P3 stream) from the start? relay's stack is P3-async; the embedded path is meld-lowered. Want to agree before I freeze the traits.

Cross-refs: relay#177 (inter-core carrier), relay readiness dossier §3 (hardware gaps 1–7), relay-bus (verified ring seam). I'll open the matching relay-side tracking issue for the relay-hal seam crate once we agree the trait shapes here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions