Skip to content

Internal

Minkyu Lee edited this page Mar 15, 2022 · 6 revisions

Project Internal

Overall architecture

Kaluma has a layered architecture as below:

+----------------------------------+
| Builtin JS Modules               | # event, i2c, pwm, spi, uart, ... (src/modules/*)
+----------------------------------+
| Core Runtime                     | # Event I/O, JavaScript Engine, REPL, ... (src/*.c)
+----------------------------------+
| Hardware Neutral Interface       | # system.h, gpio.h, uart.h, ... (include/port/*.h)
+----------------------------------+
| Hardware Specific Implementation | # system.c, gpio.c, uart.c, ... (targets/*)
+----------------------------------+

Repository structure

lib/                 # External libraries
include/             # C headers
  └─ port            # Hardware neutral interfaces
src/                 # C implementations
  ├─ gen             # Generated source files (DOT NOT EDIT)
  └─ modules         # JavaScript builtin modules
     └─ <module>     
targets/             # Target implementations
  └─ <target>/       # A specific target (e.g. rp2, stm32, esp32, ...)
    ├─ include/      # header files
    ├─ src/          # Implementations of include/port/*.h
    ├─ boards/       # Supported boards of the target
    │  └─ <board>/   # A specific board (e.g. pico)
    └─ target.cmake  # CMake for the target
tools/               # Build tools

Porting to a new hardware

To port to a new hardware, HNI (Hardware neutral interfaces - /include/port/*.h) should be implemented.

  1. Create a folder in targets/<target-name> (e.g. targets/esp32).
  2. Implement all header files in include/port/*.h into targets/<target-name>/src/*.c.
  3. Create a board folder in targets/<target-name>/boards/<board-name>.
  4. Add board.h and board.js into the board folder.
  5. Create a CMAKE file target.cmake for the target.
  6. Put required libraries in lib if any.

Entry point

src/main.c is the entry point.

Clone this wiki locally