]> granicus.if.org Git - esp-idf/commitdiff
tiny-test-fw: Detect either 'download.config' or 'flash_project_args'
authorRoland Dobai <dobai.roland@gmail.com>
Wed, 12 Sep 2018 11:30:36 +0000 (13:30 +0200)
committerbot <bot@espressif.com>
Thu, 20 Sep 2018 06:39:04 +0000 (06:39 +0000)
tools/tiny-test-fw/IDF/IDFApp.py

index b173aaf80f84abbe2da24e847ce0df317f713edf..54972137a2537342579a76b2201a7a60724cfa42 100644 (file)
@@ -26,18 +26,23 @@ class IDFApp(App.BaseApp):
     """
 
     IDF_DOWNLOAD_CONFIG_FILE = "download.config"
+    IDF_FLASH_ARGS_FILE = "flash_project_args"
 
     def __init__(self, app_path):
         super(IDFApp, self).__init__(app_path)
         self.idf_path = self.get_sdk_path()
         self.binary_path = self.get_binary_path(app_path)
         assert os.path.exists(self.binary_path)
-        try:
-            assert self.IDF_DOWNLOAD_CONFIG_FILE in os.listdir(self.binary_path)
-        except AssertionError as e:
-            e.args += ("{} doesn't exist. Try to run 'make print_flash_cmd | tail -n 1 > {}/{}' for resolving the issue"
-                       "".format(self.IDF_DOWNLOAD_CONFIG_FILE, self.binary_path, self.IDF_DOWNLOAD_CONFIG_FILE),)
-            raise
+        if self.IDF_DOWNLOAD_CONFIG_FILE not in os.listdir(self.binary_path):
+            if self.IDF_FLASH_ARGS_FILE not in os.listdir(self.binary_path):
+                msg = ("Neither {} nor {} exists. "
+                       "Try to run 'make print_flash_cmd | tail -n 1 > {}/{}' "
+                       "or 'idf.py build' "
+                       "for resolving the issue."
+                       "").format(self.IDF_DOWNLOAD_CONFIG_FILE, self.IDF_FLASH_ARGS_FILE,
+                             self.binary_path, self.IDF_DOWNLOAD_CONFIG_FILE)
+                raise AssertionError(msg)
+
         self.esptool, self.partition_tool = self.get_tools()
 
     @classmethod
@@ -85,8 +90,17 @@ class IDFApp(App.BaseApp):
 
         :return: download config, partition info
         """
-        with open(os.path.join(self.binary_path, self.IDF_DOWNLOAD_CONFIG_FILE), "r") as f:
-            configs = f.read().split(" ")
+
+        if self.IDF_FLASH_ARGS_FILE in os.listdir(self.binary_path):
+            with open(os.path.join(self.binary_path, self.IDF_FLASH_ARGS_FILE), "r") as f:
+                configs = []
+                for line in f:
+                    line = line.strip()
+                    if len(line) > 0:
+                        configs += line.split()
+        else:
+            with open(os.path.join(self.binary_path, self.IDF_DOWNLOAD_CONFIG_FILE), "r") as f:
+                configs = f.read().split(" ")
 
         download_configs = ["--chip", "auto", "--before", "default_reset",
                             "--after", "hard_reset", "write_flash", "-z"]