Fake Devices
Dawn ships a small collection of fake NuttX drivers under
boards/common/ (sources in boards/common/src/, header in
boards/common/include/fake_drivers.h). These plug into the standard
NuttX driver interfaces (ADC, DAC, PWM, sensors, GPIO, LEDs, buttons,
etc.) but contain no real hardware access - they are minimal stubs that
let Dawn run on targets without those peripherals.
Purpose
The fake drivers exist to make Dawn usable on targets that have no real peripherals: the NuttX simulator and QEMU targets. With the fake drivers enabled, the same descriptor-driven IO/PROG/PROTO pipeline that normally talks to hardware can be exercised entirely on the host.
This is useful for:
Local development of Dawn itself without a board flashed and wired up.
Running examples and demos on a Linux machine.
Driving the QA pipeline (
dawnpy-tests) - both unit tests and the NTFC integration suites depend on the simulator and QEMU configs that enable these drivers.
The current implementations are deliberately simple. They satisfy the driver interface and return plausible (often constant or trivially generated) data so that higher layers behave normally. They are not yet attempting to model the timing, noise, or behavioural quirks of real silicon. Improving fidelity is on the roadmap; for now treat them as behavioural stubs, not simulation models.
Enabling
The fake drivers are gated by Kconfig options under
boards/common/Kconfig. Any board (in-tree or out-of-tree) that
wants to use them sources that file:
source "$(DAWN_BOARDS_COMMON)/Kconfig"
The DAWN_BOARDS_COMMON environment variable is exported by Dawn’s
build system so the same line works from in-tree and OOT boards alike.
Once sourced, enable the master switch and any drivers you need in your
board defconfig.dawn:
CONFIG_DAWN_FAKE_DRIVERS=y
CONFIG_DAWN_FAKE_ADC=y
CONFIG_DAWN_FAKE_SENSORS=y
# ... etc
Each fake driver depends on the corresponding NuttX subsystem
(CONFIG_ADC, CONFIG_DAC, CONFIG_PWM, CONFIG_SENSORS,
…) being enabled.
Boards then call the matching fake_*_initialize() from their bringup
code (see boards/sim/sim/sim/src/sim_bringup.c for a worked
example).
Supported fake drivers
Kconfig option |
Device node |
Behaviour |
|---|---|---|
|
|
32-channel ADC. A background kthread feeds a fixed sample buffer
through the standard upper-half callback at a configurable
interval; supports |
|
|
DAC sink that accepts writes and logs them via |
|
|
PWM lower-half stub. Accepts |
|
|
Quadrature encoder with software-maintained position. Supports
position read, position-max set, reset, and index set via the
standard |
|
|
Wraps NuttX’s |
|
|
Registers UORB sensor nodes (accelerometer, magnetometer,
gyroscope; GNSS variants supported by |
|
|
User-LED lower-half. Tracks per-LED state in memory; reports the supported LED set based on the requested LED count. |
|
|
NuttX RGBLED upper-half driver backed by one fake multi-channel PWM
lower half. Accepts standard |
|
|
Button input lower-half. Tracks per-button state in memory; press/release callbacks can be installed but are not driven by any real input source yet. |
|
boardctl |
Provides a constant 16-byte unique-ID returned by
|
|
boardctl |
Implements |
|
boardctl |
Implements |
Roadmap
The current implementations are minimal stubs aimed at “make the upper layers happy”. Planned improvements include:
Configurable sample/value generators (waveforms, noise, scripted sequences) instead of constant or fixed-array data.
Loopback wiring between DAC and ADC, PWM and encoder, GPIO outputs and inputs, so PROG pipelines can be exercised end-to-end on the host.
Optional host-side control hooks (driving values from a test runner) so NTFC suites can validate behaviour beyond the current driver stub.
See QA for how the QA pipeline already exercises these drivers via the simulator and QEMU configs, and Host-based Development for the broader picture of host-based Dawn development.