OpenEMC: open embedded management controller

Overview

OpenEMC

OpenEMC is an open-source firmware implementing an embedded management controller (EMC) on an STM32F1 microcontroller. It consists of a bootloader and firmware (both written in Rust) and Linux kernel driver modules (written in C).

Build

Features

The following features are implemented:

  • communication with the host over I2C and one interrupt line
  • field-upgradable firmware
  • power control: system on/off and restart
  • watchdog
  • real-time clock (RTC) with alarm and system wake-up
  • GPIO with interrupts
  • pin control
  • analog digital converter (ADC)
  • full devicetree integration

Due to its open-source nature, modular design and usage of the Rust programming language, OpenEMC is easy to extend and adapt to a wide variety of boards and applications.

Evaluation and development

The easiest method to evaluate and hack on OpenEMC is to get an STM32F103 Nucleo-64 board (NUCLEO-F103RB) and connect its I2C bus (SCL, SDA) and D12 pin (IRQ) to a Raspberry Pi or similar board.

Bootloader flashing can be performed using the STLink embedded on the board and requires no additional hardware.

Linux drivers have been tested with Linux v5.19.

Building

Requirements

For building the firmware your machine must have the following things installed:

  • a recent enough stable Rust toolchain (install from https://rustup.rs),
  • Rust target thumbv7m-none-eabi (rustup target add thumbv7m-none-eabi),
  • Rust LLVM utils (rustup component add llvm-tools-preview),
  • Cargo binutils (cargo install cargo-binutils),
  • STLINK tools (from https://github.com/stlink-org/stlink or your Linux distribution),
  • for development: probe-run (cargo install probe-run).

For building the Linux kernel drivers the kernel headers and gcc are required. The kernel must have support for devicetree enabled.

Building the firmware image

To build both the bootloader and main firmware, run:

cargo xtask <BOARD_NAME>

They will be placed into the image directory. Here <BOARD_NAME> specifies the name of the board; see openemc-bootloader/src/boards for a list of supported boards. If no board is specified a generic board image will be generated.

This crates two files:

  • openemc_bootloader_*.bin is the bootloader image and should be flashed onto the device,
  • openemc_*.emc is the main firmware and should be placed into the /lib/firmware directory on the target device, where it will be picked up by the driver and sent to the device.

Flashing the bootloader image

Connect the STM32 to your computer using an (integrated) STLink USB adapter. Use st-flash from STLINK tools to flash the bootloader image:

st-flash --connect-under-reset write image/openemc_bootloader_*.bin 0x8000000

Building the kernel driver

Run scripts/driver-build.sh to build the drivers as kernel modules. You can install them using scripts/driver-install.sh.

Devicetree

The driver will only be loaded if it is referenced in the system's devicetree. Examples are provided in the devicetree directory. Use scripts/devicetree-build.sh to build them and scripts/devicetree-load.sh to dynamically load a devicetree overlay into a running system.

Development and testing

For development and testing, both the bootloader and main firmware can be flashed and executed directly by invoking

OPENEMC_BOARD=<BOARD_NAME> DEFMT_LOG=info cargo run --release -- --connect-under-reset

from the respective directory. Set the environment variable DEFMT_LOG your desired log level.

License

The OpenEMC firmware is released under the GNU GPL version 3, meaning that you must release the full source code of your modifications if you adapt OpenEMC to your application and/or board.

The OpenEMC drivers are released under the GNU GPL version 2 or later, following the standard license of the Linux kernel. This also requires you to publish all changes you make to the OpenEMC drivers.

Commercial licensing options without these restrictions are available. Please contact us for licensing details..

You might also like...
Rust embedded-HAL driver for the AHT20 temperature and humidity sensor.
Rust embedded-HAL driver for the AHT20 temperature and humidity sensor.

AHT20-driver Rust embedded-HAL driver for the AHT20 temperature and humidity sensor. You can read my blog post AHT20 thermometer driver which details

Embedded demo based on esp32-c3

wot-esp-demo Demo Hygro-Thermometer based on the esp-rust-board. http version based on std-training Deploy Rust prerequisites Install espflash, ldprox

MeiliSearch is a powerful, fast, open-source, easy to use and deploy search engine
MeiliSearch is a powerful, fast, open-source, easy to use and deploy search engine

MeiliSearch is a powerful, fast, open-source, easy to use and deploy search engine. Both searching and indexing are highly customizable. Features such as typo-tolerance, filters, and synonyms are provided out-of-the-box. For more information about features go to our documentation.

An open source virtual tabletop that is currently purely a concept.

An open source virtual tabletop that is currently purely a concept.

Blueboat is an open-source alternative to Cloudflare Workers. The monolithic engine for serverless web apps.

Blueboat Blueboat is an open-source alternative to Cloudflare Workers. Blueboat aims to be a developer-friendly, multi-tenant platform for serverless

Download Apple's open source code from opensource.apple.com

Apple Open Source Downloader This repository defines a Rust crate and CLI program to automate the downloading of Apple's open source code from https:/

Turbo Resin: open-source firmware for resin printers
Turbo Resin: open-source firmware for resin printers

Turbo Resin: open-source firmware for resin printers Turbo Resin is an open-source firmware for chitu based controller board printers. It currently su

A Rust client for the NOAA Weather Wire Service Open Interface.

nwws-oi A Rust client for the NOAA Weather Wire Service Open Interface. NWWS-OI is one of several platforms through which the National Weather Service

Polydrive an experimental open source alternative to Google Drive

Polydrive is an experimental open source alternative to Google Drive. It allows users to synchronize their files on multiple devices.

Releases(v0.4.0)
  • v0.4.0(Jan 4, 2023)

    0.4.0 - 2023-01-04

    Added

    • support for BQ25713 battery charger
    • Linux drivers for battery and external power supply
    • support for firmware-generated interrupts

    Changed

    • reset STUSB4500 if PD contract fails
    Source code(tar.gz)
    Source code(zip)
  • v0.3.0(Nov 30, 2022)

    0.3.0 - 2022-11-30

    Added

    • support for I2C bus 2 master
    • support for STUSB4500 USB PD controller

    0.2.2 - 2022-11-17

    Fixed

    • inconsistent logic levels on complementary PWM outputs if a channel on timer 1 is disabled

    0.2.1 - 2022-11-16

    Changed

    • use internal oscillator for system clock

    0.2.0 - 2022-11-16

    Added

    • PWM output support
    Source code(tar.gz)
    Source code(zip)
  • v0.1.0(Sep 30, 2022)

Owner
Sebastian Urban
Sebastian Urban
Software adapter for various Chunithm slider controllers with a built-in Brokenithm web controller

slidershim Software adapter for various Chunithm slider controllers with a built-in Brokenithm web controller. Has support for keyboard/gamepad output

Si Yuan 45 Dec 17, 2022
xrd a next-gen server controller for TrackMania Forever and Nations ESWC

xrd is a next-gen server controller for TrackMania Forever and Nations ESWC that is designed to be hassle-free and easily updatable (with a bus factor of 0).

Autumn Leaf 6 Mar 26, 2022
A Rust driver for the Arm Generic Interrupt Controller version 3 or 4 (GICv3 and GICv4).

Arm Generic Interrupt Controller driver This crate provides a Rust driver for the Arm Generic Interrupt Controller version 3 or 4 (GICv3 and GICv4). C

Google 7 Apr 17, 2023
This is a cosmwasm implementation of an interchain accounts controller.

CosmWasm ICA Controller Contract This is a CosmWasm smart contract that communicates with the golang ica/host module on the host chain to create and m

null 7 Jul 2, 2023
A Discord bot for control and decentralization of threads management

Threadripper-bot A Discord bot for control and decentralization of threads management About Threadripper aims to serve some extra utilities to take be

S0ra 15 Dec 27, 2022
An ability / resource / cooldown management library for Bevy.

About leafwing-abilities is an opinionated, ready-to-use Bevy library and plugin for handling abilities. It features: cooldown tracking resource manag

null 2 Mar 30, 2022
Runit service management wrappers

void-svtools Basic wrappers for managing services for runit,

Isaac Hung 1 Aug 3, 2022
Simplify temporary email management and interaction, including message retrieval and attachment downloads, using Rust.

Tempmail The Tempmail simplifies temporary email management and interaction, including message retrieval and attachment downloads, using the Rust prog

Dilshad 6 Sep 21, 2023
`fugit` provides a comprehensive library of `Duration` and `Instant` for the handling of time in embedded systems, doing all it can at compile time.

fugit fugit provides a comprehensive library of Duration and Instant for the handling of time in embedded systems, doing all it can at compile time. T

Emil Fresk 40 Oct 2, 2022
cargo extension for flashing embedded rust programs via dfu based on jacobrosenthals cargo-hf2

cargo-dfu This crate provides a cargo subcommand to flash ELF binaries via dfu Most STM chips will probably work with this, although you might need to

Roman Kretschmer 0 Feb 6, 2022