def _lookup_baud_rate(cls, options): # TODO(mehrdadh): remove this hack once dtlib.py is a standalone project # https://github.com/zephyrproject-rtos/zephyr/blob/v2.7-branch/scripts/dts/README.txt sys.path.insert( 0, os.path.join( get_zephyr_base(options), "scripts", "dts", "python-devicetree", "src", "devicetree" ), ) try: import dtlib # pylint: disable=import-outside-toplevel finally: sys.path.pop(0) dt_inst = dtlib.DT(BUILD_DIR / "zephyr" / "zephyr.dts") uart_baud = ( dt_inst.get_node("/chosen") .props["zephyr,console"] .to_path() .props["current-speed"] .to_num() ) _LOG.debug("zephyr transport: found UART baudrate from devicetree: %d", uart_baud) return uart_baud
def _lookup_baud_rate(cls, options): sys.path.insert( 0, os.path.join(get_zephyr_base(options), "scripts", "dts")) try: import dtlib # pylint: disable=import-outside-toplevel finally: sys.path.pop(0) dt_inst = dtlib.DT(BUILD_DIR / "zephyr" / "zephyr.dts") uart_baud = (dt_inst.get_node("/chosen").props["zephyr,console"]. to_path().props["current-speed"].to_num()) _LOG.debug("zephyr transport: found UART baudrate from devicetree: %d", uart_baud) return uart_baud
def parse(dts, include_path=()): open(".tmp.dts", "w").write(dts) return dtlib.DT(".tmp.dts", include_path)