1#!/usr/bin/env python 2# 3# SPDX-FileCopyrightText: 2014-2022 Fredrik Ahlberg, Angus Gratton, 4# Espressif Systems (Shanghai) CO LTD, other contributors as noted. 5# 6# SPDX-License-Identifier: GPL-2.0-or-later 7# 8# Trivial wrapper program to run esptool.py using the just-compiled 9# flasher stub in the build/ subdirectory 10# 11# For use when developing new flasher_stubs, not important otherwise. 12 13import os.path 14import sys 15 16THIS_DIR = os.path.dirname(__file__) 17STUBS_BUILD_DIR = os.path.join(THIS_DIR, "build/") 18 19sys.path.append("..") 20import esptool # noqa: E402 21 22# Python hackiness: change the path to stub json files in the context of the esptool 23# module, so it edits the esptool's global variables 24exec( 25 "loader.STUBS_DIR = '{}'".format(STUBS_BUILD_DIR), 26 esptool.__dict__, 27 esptool.__dict__, 28) 29 30 31if __name__ == "__main__": 32 try: 33 esptool.main() 34 except esptool.FatalError as e: 35 print("\nA fatal error occurred: %s" % e) 36 sys.exit(2) 37