This demo gateway firmware is built on the Hopter embedded operating system, developed for the STM32F072B-Discovery board.
The gateway consists of a data plane and a control plane, as shown in the figure below. The data plane receives packets from the inbound connection through an interrupt-driven UART interface, and then forwards the packets to the outbound UART connection. As part of the data plane, the Gateway task verifies the integrity of received packets, updates runtime counters, and optionally modifies the packets according to the rules before forwarding them. The control plane establishes a text-based control session through another UART interface. Users can send commands to query the number of forwarded and corrupted packets, to query the number of occurrences of a specific byte pattern, to reset the counters, and to change forwarding rules. The rules currently allow users to set the bytes to be escaped before forwarding and to filter packets based on packet types. As part of the control plane, the Console task parses and executes the command, and then responds to the user.
First, follow the instructions provided by Hopter to install the custom Rust compiler toolchain.
Next, run cargo build --release
to build the program, and run cargo run --release
to flash the board.
We deliberately not include an explicit boundary check when parsing the packets. If the data array is accessed out-of-boundary, a Rust panic will occur. Hopter is able to recover from the panic.
Also, the use of Atomic*
types and Arc
in the firmware is enabled only by Hopter's patched compiler on thumbv6-none-eabi
targets (e.g., Cortex-M0).
The code is unable to compile with upstream Rust compilers.