© 2025 The Johns Hopkins University Applied Physics Laboratory LLC
This repository contains the firmware for the DCMini board, a miniaturized biopotential amplifier and multisensor suite. The firmware is implemented using Rust and follows a modular approach with multiple crates for different components.
The dc-mini-bsp crate is the Board Support Package (BSP) for the DCMini board. It implements drivers for various peripherals available on the board, including GPIO pins, SPI interface for ADS1299 EEG amplifiers, I2C interface for the accelerometer and ambient light sensor, as well as control for the neopixel LED and speaker. The BSP provides a hardware abstraction layer to simplify interaction with the board's peripherals.
The dc-mini-boot crate is the boot manager for the DCMini firmware. It supports firmware upgrades and ensures automatic firmware fallback in case the watchdog timer expires. The boot manager handles the firmware update process and maintains a reliable firmware execution environment, enhancing the reliability and robustness of the device.
The dc-mini-app crate contains the application logic for the DCMini firmware. It is responsible for polling and processing data from various sensors, including the ADS1299 EEG amplifiers, accelerometer, ambient light sensor, and microphone. The crate also includes logic to control the neopixel LED and speaker, allowing for customizable feedback and notification features.
To set up the development environment and build the firmware, follow these steps:
-
Make sure the Nix package manager is installed on your host machine. If Nix is not installed, you can follow the installation instructions for your operating system from the official Nix website.
-
Open a terminal and navigate to the root directory of this project.
-
Run the following command to set up the toolchain environment using Nix:
nix developThis command initializes the development environment with all the necessary dependencies and configurations required for building the firmware.
-
After running
nix develop, you will be inside a shell environment with the toolchain set up. From here, you can execute build commands and interact with the firmware project.
By following these steps, the toolchain environment will be properly set up using the Nix package manager. This ensures a consistent and reproducible development environment across different machines.
Please note that if you encounter any issues during the toolchain setup process, refer to the documentation or support resources for the Nix package manager for further assistance.
To build the firmware with USB support:
cargo xbuild --features "defmt,usb"To build with SoftDevice support:
cargo xbuild --features "defmt,softdevice"To build with both USB and SoftDevice:
cargo xbuild --features "defmt,usb,softdevice"Add --release flag for release builds.
To flash the firmware with USB support:
cargo xflash --features "defmt,usb"To flash with SoftDevice support:
cargo xflash --features "defmt,softdevice"To flash with both USB and SoftDevice:
cargo xflash --features "defmt,usb,softdevice"Add --release flag for release builds.
Add --force flag to force flash even if the binary hasn't changed.
Note: xflash automatically builds the firmware before flashing.
To build, flash and run with RTT logging (USB support):
cargo xrun --features "defmt,usb"To run with SoftDevice support:
cargo xrun --features "defmt,softdevice"To run with both USB and SoftDevice:
cargo xrun --features "defmt,usb,softdevice"Add --release flag for release builds.
Note: xrun automatically builds and flashes the firmware before attaching RTT.
To attach RTT to a running target:
cargo xattachAdd --release flag if connecting to a release build.
If this is your first time flashing the board:
- Erase the current settings:
probe-rs erase --chip nRF52840_xxAANOTE: You may need to add the --allow-erase-all flag to the above command if this is your first time flashing the board. This is due to Access Port Protection on the NRF MCU.
- Flash the firmware with your desired features:
cargo xflash --features "defmt,usb,softdevice" --force # Example with both USB and SoftDevice supportThe xtask system will automatically handle flashing the bootloader, softdevice (if enabled), and application in the correct order.
This work was supported in part by intramural research funding from Johns Hopkins University Applied Physics Lab (JHU APL).
- Griffin Milsap: Hardware design
- Preston Peranich: Firmware implementation
- Will Coon: Device validation
If you use this hardware in a project or publication, we’d love to hear about it! Additionally, please consider citing:
Coon, W. G., Peranich, P., & Milsap, G. (2025). StARS DCM: A Sleep Stage-Decoding Forehead EEG Patch for Real-time Modulation of Sleep Physiology. arXiv preprint arXiv:2506.03442.
Dual licensed under your choice of either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.