From f9f374d8999436be8820988ba0d9765913dbf7bc Mon Sep 17 00:00:00 2001 From: DocKenny Date: Thu, 18 Jul 2024 16:34:56 +0200 Subject: [PATCH] fix: change SystemExit to warning in _check_if_can_reset --- esptool/targets/esp32s2.py | 7 ++++--- esptool/targets/esp32s3.py | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/esptool/targets/esp32s2.py b/esptool/targets/esp32s2.py index 6af2842f7..6eed426e4 100644 --- a/esptool/targets/esp32s2.py +++ b/esptool/targets/esp32s2.py @@ -5,6 +5,7 @@ import os import struct +import warnings from typing import Dict from .esp32 import ESP32ROM @@ -296,15 +297,15 @@ def _check_if_can_reset(self): strap_reg & self.GPIO_STRAP_SPI_BOOT_MASK == 0 and force_dl_reg & self.RTC_CNTL_FORCE_DOWNLOAD_BOOT_MASK == 0 ): - print( + warnings.warn( "WARNING: {} chip was placed into download mode using GPIO0.\n" "esptool.py can not exit the download mode over USB. " "To run the app, reset the chip manually.\n" "To suppress this note, set --after option to 'no_reset'.".format( self.get_chip_description() - ) + ), + UserWarning ) - raise SystemExit(1) def hard_reset(self): uses_usb_otg = self.uses_usb_otg() diff --git a/esptool/targets/esp32s3.py b/esptool/targets/esp32s3.py index 06fb129eb..37b6efc3b 100644 --- a/esptool/targets/esp32s3.py +++ b/esptool/targets/esp32s3.py @@ -5,6 +5,7 @@ import os import struct +import warnings from typing import Dict from .esp32 import ESP32ROM @@ -358,15 +359,15 @@ def _check_if_can_reset(self): strap_reg & self.GPIO_STRAP_SPI_BOOT_MASK == 0 and force_dl_reg & self.RTC_CNTL_FORCE_DOWNLOAD_BOOT_MASK == 0 ): - print( + warnings.warn( "WARNING: {} chip was placed into download mode using GPIO0.\n" "esptool.py can not exit the download mode over USB. " "To run the app, reset the chip manually.\n" "To suppress this note, set --after option to 'no_reset'.".format( self.get_chip_description() - ) + ), + UserWarning ) - raise SystemExit(1) def hard_reset(self): uses_usb_otg = self.uses_usb_otg()