### Summary
Adds a user-definable VTX band table (up to 12 bands x 8 channels),… persisted in storage and read/written over MAVLink FTP as `@VTX/vtxtable.dat`.
This builds on #34379 by @ccc321q, whose user-definable power table this depends on; thanks to them for that work. The first five commits here are theirs, unchanged, and this PR should be reviewed after (or merged together with) #34379. Power levels stay in its `VTX_PWRTBL*` parameters; this adds the band/frequency side.
### Classification & Testing (check all that apply and add your own)
- [x] Checked by a human programmer
- [ ] Non-functional change
- [ ] No-binary change
- [x] Infrastructure change (e.g. unit tests, helper scripts)
- [x] Automated test(s) verify changes (e.g. unit test, autotest)
- [x] Tested manually, description below (e.g. SITL)
- [x] Tested on hardware
- [ ] Logs attached
- [ ] Logs available on request
**Unit tests**: new GTest suite `libraries/AP_VideoTX/tests/test_vtx_table.cpp` (18 tests): the default table reproduces the historical band grid exactly (all 88 frequencies, same band order), out-of-range lookups, first-match reverse lookup, serialized defaults validate, blob rejection for a bad CRC, truncation, wrong magic/version, empty or oversized dimensions, refusal of an upload when the board has no storage region, and placing VTX reports in the table: factory reports unchanged, a custom band settling on its configured slot, a custom-band channel change still pending until the VTX reports it, factory indices decoded on the factory grid when the user table changes that band, a custom band that shares a factory frequency, a factory band with edited frequencies settling when commanded by index but still being retuned when commanded by frequency, disabled entries not being selectable, and a VTX commanded by frequency that is first seen on a factory frequency the table has edited still being retuned after first contact. Mutation checks confirmed the report-placement tests fail if the configured-slot placement, the factory-grid decoding or the disabled-entry check is removed. The SmartAudio and CRSF drivers themselves cannot be exercised in SITL. All pass, alongside the 7 existing `test_vtx_power` tests from #34379.
**Autotest**: new `test.Copter.VTXTable` over MAVLink FTP: the default table's header, CRC and band grid, and that an upload is refused with an FTP error on SITL (which emulates 16 KB flash storage and so has no table region), leaving the table unchanged. Passes. A mutation check confirmed the test fails when the storage guards are removed. Existing tests that exercise the affected code also pass: `MSPVTXConfig` and `MSPDisplayPortVTXConfig` (band/channel lookups now go through the table) and the Plane `MAVFTP` tests (`@VTX` is a new FTP root entry).
**FTP bounds**: SITL refuses uploads (no storage region), so `write()` and `lseek()` cannot be reached by an autotest. Their offset checks were exercised in an AddressSanitizer harness: the previous logic crashes on a write at offset `0xFFFFFFF0`, and the new logic rejects it and handles the boundary cases (writes ending exactly at and one byte past the largest table, chunked uploads, seek overflow and invalid whence).
**Build**: SITL builds for every vehicle, with `AP_VIDEOTX_TABLE_ENABLED` both on and off; with it off, the three lookup tests pass and no FTP or persistence code is linked. Each commit builds on its own. Locally ran the CI board builds most likely to be affected: `fmuv2` plane, `Durandal` debug, `MatekF405-Wing`, `revo-mini` and `fmuv3`, plus `test_build_options.py` defaults and all/none, all passing.
**Flash cost**: see the size report below. On boards with less than 32 KB of storage the user-definable part is not built.
**Hardware**: tested at the head of this PR on a BrotherHobby H743 (32 KB storage) with an IRC Tramp VTX, driven over MAVLink, 15/15 checks passing:
- the default table over `@VTX` FTP, and a factory band (R1) settling
- uploading a table with a custom band and an edited factory band; the table persisted across a reboot, and a table with a bad CRC was rejected, leaving it unchanged
- custom band channels settling, including ones sharing a factory frequency
- selecting a disabled channel sending nothing
- an edited factory band retuned to the table's frequency
- a frequency the VTX refuses: warned, the selection returned to the VTX's frequency, and the next change went through
- a refused frequency while the VTX is on a frequency the table no longer has: one warning, `VTX_FREQ` back on the VTX's frequency, and a power change then went through (before the fix: 713 warnings in 20 s and no power change)
This VTX only accepts the frequencies of its own channels, which is what found the Tramp recovery bug fixed in the last commit. SmartAudio and CRSF custom-band commanding has not been tested on a VTX.
### Description
**Band table** — `AP_VideoTX_Table` replaces the hardcoded `VIDEO_CHANNELS` grid. Each band has a name, letter, factory flag and a frequency per channel (0 = disabled). The compiled-in defaults are the historical 11 bands in the same order with identical frequencies, so `VTX_BAND` indices and behaviour are unchanged out of the box. The VTX status message now shows the band letter (e.g. `U3` rather than `1G3_A3`).
As in Betaflight, factory bands are commanded on SmartAudio and CRSF by band/channel index, and the VTX tunes them from its own band map; custom bands are commanded by their frequency, since the VTX's map does not know them. Tramp is always set by frequency. When a VTX reports its state, its own band/channel indices are read against the factory band map, and a custom band is recognised from the reported frequency (staying on the configured custom slot if it shares a frequency with a factory channel), so a custom band settles instead of being re-sent. Selecting a disabled (0 MHz) channel sends nothing, including a change still pending when a table upload disables it. A VTX commanded by frequency (Tramp, SmartAudio in frequency mode) that is first seen on a factory frequency the table no longer has keeps that frequency, so it is retuned rather than shown as already on the table's frequency. When a new table is accepted, `VTX_FREQ` is re-derived from `VTX_BAND`/`VTX_CHANNEL` so the VTX is retuned. The table is guarded by a semaphore, since it is replaced from the FTP thread while other threads (e.g. CRSF telemetry) look up frequencies.
**Tramp frequency refusal** (last commit) — many VTXs only accept the frequencies of their own channels. When a Tramp VTX did not take a requested frequency, `VTX_FREQ` stayed on it once the retries ran out and re-derived `VTX_BAND`/`VTX_CHANNEL` from it on every later change, undoing it, so the VTX could only be retuned by setting `VTX_FREQ` directly or rebooting. This was already reachable on master, but custom frequencies make it much easier to hit. Now the refused frequency is reported once (`VTX: rejected frequency`) and dropped, following `VTX_BAND`/`VTX_CHANNEL` if they have moved on, or returning to the frequency the VTX is on and to its slot if the table has one. Without a slot (e.g. the VTX is on a factory frequency the table has edited away), `VTX_BAND`/`VTX_CHANNEL` go back to the last slot the VTX was on, since re-deriving `VTX_FREQ` from the refused slot would bring the refused frequency straight back. (That last part could not be re-tested on the VTX, which was no longer available.)
**Tramp pit mode while disabled** (last commit) — the pit mode retry from #34379 kept sending `I` every second after `VTX_ENABLE` was set to 0 on a running VTX; it now stops, as every other command already does.
**MSP** — MSP VTX control (digital systems) is unchanged and always sends the band/channel index, so custom bands and disabled channels are not supported there; the README and wiki say so.
**Transport** — a virtual `@VTX` filesystem (modelled on `AP_Filesystem_Mission`) serves the table as one CRC-checked blob. On a board without a table storage region, opening the file for writing fails with `EROFS`, so the refusal is reported by every FTP client. Otherwise the upload is validated and persisted on close, or rejected wholesale, leaving the existing table untouched. Write and seek offsets are bounds-checked against the largest valid table, and only one upload can be in progress at a time.
**Storage** — a user table is stored in a new 384-byte `StorageVTXTable` region on the 32 KB storage tier, taken from the tail of the last mission area:
- Mission capacity on 32 KB boards drops from 1306 to 1280 items on Copter and from 1312 to 1286 on Plane and Rover; a stored mission larger than the new limit is not loaded after upgrading. All other offsets, including ParamBak, are unchanged.
- The defaults are never written to storage, so a firmware update does not overwrite existing storage contents; the region is only written when a table is uploaded.
- Boards with less storage (most F405s) have no region and do not build the user-definable part, so they always use the defaults. If it is enabled on such a board anyway, an upload is refused rather than accepted and lost on reboot.
**Build option** — the band model is always built with VTX support; the user-definable part (validation, persistence, `@VTX` FTP) is under `AP_VIDEOTX_TABLE_ENABLED`, which defaults on only for boards with 32 KB of storage (and SITL, for testing), and is added to `build_options.py`. The `@VTX` mount is not built into AP_Periph.
**Relationship to #34379** — stacked on #34379 without changing its power table or parameters. The two are complementary: parameters for power levels (available on every board), storage for the band plan.
Wiki: ArduPilot/ardupilot_wiki#8101
This contribution was AI-assisted (Claude Code): code changes, tests and documentation were produced with AI assistance and reviewed by the author.
🤖 Generated with [Claude Code](https://claude.com/claude-code)