1.0.1 • Published 2 years ago

zephyr-dts v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

zephyr-dts test

license issues stars commits

A library for parsing DeviceTree from Zephyr.

Install

npm install zephyr-dts --save

Usage

This library loads DTS from Zephyr's build directory:

import { loadDT } from 'zephyr-dts';

const dt = await loadDT('/path/to/zephyr/build');

const flash = dt.choose('zephyr,flash');
if (flash) {
  for (const part of dt.under(`${flash.path}/partitions`)) {
    const reg = part.reg![0]!;
    console.log(`part ${part.label} - addr: ${reg.addr}, size: ${reg.size}`);
  }
}

APIs

function loadDT(buildDir: string): Promise<DeviceTreeParser>;

interface DeviceTreeParser {
  choose(name: string): Node | null;
  label(label: string): Node | null;
  node(path: NodePath): Node | null;
  under(parent: NodePath): Node[];
}

interface Node {
  path: string;
  compatible?: string[];
  label?: string;
  reg?: Register[];
  status?: 'okay' | 'disabled';
  interrupts?: number[];
  properties: Record<string, string>;
}

type NodePath = string;

interface Register {
  addr?: number;
  size?: number;
}

License

MIT License