Git Product home page Git Product logo

cortex-demos's Introduction

demOS (demo-OS) {#mainpage}

This project is a microcontroller operating system that focuses heavily on testability.

Essentially, this is a research project, trying to figure out how far the concept can be taken, without using real hardware. The idea of being testable is what drives most of the design choices.

The OS is actually just a driver model, it uses FreeRTOS for scheduling and IPC.

** This is not an officially supported Google product **

Design for Test

The project focuses on tests from the very beginning. This means that even very simple code, even the smallest driver must be tested and in true TDD tradition, it must be possible to write test first.

If you look at the firmware that is running on a typical ARM32 microcontroller, from the perspective of the firmware (software), the hardware is simply a set of registers, accessible through memory IO operations, plus interrupts.

Let's say you have a simple GPIO module. To set particular line high, you set the value of a corresponding bit in a 32 bit register.

const uint32_t gpio_reg_addr = 0x50000508;
const unsigned gpio_line = 8;

/* Setting the line high */
*((volatile uint32_t*)gpio_reg_addr) = (1 << gpio_line);

Unfortunately, if we want to test this code off the hardware, i.e. on regular desktop computer, that memory write operation is kind of hard to mock.

The solution this project uses is very simple and is summed up in memio.h. All memory IO operations are defined as a function-like macros, for example:

#define raw_write32(addr, value)     *((volatile uint32_t*)(addr)) = (value)

When certain preprocessor option is given during compilation (TEST_MEMIO), this function-like macro becomes a real function:

void raw_write32(uint32_t addr, uint32_t value);

For tests this function simply delegates to a method of a global object:

mock::Memory g_memory;

extern "C" void raw_write32(uint32_t addr, uint32_t value) {
    g_memory.write32(addr, value);
}

This object is essentially a std::map, that maps from virtual, microcontroller's memory address to the value in that memory location.

It has more features, of course, but this is the basic idea.

cortex-demos's People

Contributors

maksymko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cortex-demos's Issues

Unified OS Timer configuration

Implement driver for SysTick and make OS Timer configurable in OS configuration file, so that the timer, be it SysTick or some other SoC timer, can be picked in the same manner.

Simplify App Initialization

Right now every application needs to implement a main() function that does all the initialization and all main() functions are very similar (yet different).

Ideally, the application should just create threads and somehow register them. However, this is probably too optimistic. There should be a few standard hooks, similar to U-Boot's list of initialization functions, each with very specific purpose. Right now I can get away with just two:

  • Clock Initialization
  • Watchdog Initialization

Two register threads there should be a macro, something like:

REGISTER_THREAD(ClassName, ConstructorArg0, ConstructorArg1, ... ConstructorArgN);
REGISTER_THREAD_STATIC(variable);

At OS startup all these threads will be initialized and started. In case of static initialization, just initialized and started.

Add new category of tests: library tests.

Right now the tests for mock, for example, are executed once for each target, even thought there is no target specific code there and the code itself is never actually compiled for the target.

Tests like that need to be build and executed once.

Support firmware build on travis-ci

Currently Travis-CI only build and executes tests. It would be better if it would also build firmware, just to verify that it is buildable.

Support building applications outside of main repository

Right now all applications (admittedly, very simple ones) are bundled with the main OS and there is no simple way to develop application externally and build it with the library.

There needs to be a process in place to do just that.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.