zephyr-dts
v1.0.1
Published
A library for parsing DeviceTree from Zephyr
Downloads
6
Readme
zephyr-dts
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;
}