Skip to content

Store sensor pins per device and accept pin commands from the host - #7

Open
ShivtejG236 wants to merge 1 commit into
feat/pin-rulesfrom
feat/device-config
Open

ShivtejG236 wants to merge 1 commit into
feat/pin-rulesfrom
feat/device-config

Conversation

@ShivtejG236

Copy link
Copy Markdown
Member

Stacked on #6; retarget to main after it merges.

What

  • Device id. HELLO now carries id (the chip's factory MAC address), pins (the GPIOs in use) and pin_src (default or stored).
  • Commands. The host can send SET_PINS (0x10) and RESET_PINS (0x11) with the existing framing. The firmware answers each with an ACK (0x05) and, on success, restarts to apply the change.
  • On-device check. scripts/boards.py turns the pin rules into two allowed-pin masks that are compiled in. pincfg_check() (include/pin_config.h) rejects a GPIO that does not exist, is blocked or reserved, is input-only for a driven signal, or is used twice. A rejected assignment is never stored.
  • Storage. Pins are kept per chip in NVS (src/device_config.cpp). Stored pins are checked again at boot, so a build with stricter rules falls back to the board defaults.
  • Release manifest. Each board entry gains pins and pin_rules for host tools.

Protocol version

Unchanged (1). The spec already says new frame types and new HELLO keys do not change it; existing hosts ignore both.

Tests

  • tools/host/test_pins.cpp: command receiving (round trip, every single-byte corruption, oversized frames, noise) and the pin check. Added to CI.
  • tools/test_pin_rules.py: the compiled masks allow exactly what pin_errors() allows, for every GPIO on every board.

Not verified

Nothing here has run on a board. The firmware is compiled only by CI. NVS storage, the restart after an accepted command and the MAC byte order need a hardware check.

Each physical board can now keep its own pin assignment in non-volatile storage. The host sends SET_PINS or RESET_PINS using the existing framing; the firmware checks the request against allowed-pin masks generated from the pin rules, stores it, answers with an ACK frame and restarts to apply it. An assignment that fails the check is never stored, and the UART0 pins are always blocked, so the host link cannot be cut.

HELLO gains id (the chip's factory MAC), pins and pin_src. These are new keys and new frame types, so the protocol version stays 1.

The release manifest now carries each board's default pins and pin rules for host tools.
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