]> granicus.if.org Git - esp-idf/commitdiff
idf.py: Print flashing steps at the end of each build
authorAngus Gratton <angus@espressif.com>
Thu, 24 May 2018 06:05:31 +0000 (16:05 +1000)
committerAngus Gratton <gus@projectgus.com>
Tue, 29 May 2018 06:34:45 +0000 (16:34 +1000)
components/esptool_py/CMakeLists.txt
components/esptool_py/flash_app_args.in
components/esptool_py/flash_partition_table_args.in
components/esptool_py/flasher_args.json.in
docs/en/get-started/index.rst
tools/idf.py

index 0d62557c81c7834475eb0fe2090d6e2de74c2fef..690763934ed15ee7680b22dcc3bdec7d36659125 100644 (file)
@@ -1,7 +1,7 @@
 register_config_only_component()
 
 # Generate pre-canned flasher args files suitable for passing to esptool.py
-foreach(part project app bootloader)
+foreach(part project app bootloader partition_table)
     configure_file(
         "${CMAKE_CURRENT_LIST_DIR}/flash_${part}_args.in"
         "${CMAKE_BINARY_DIR}/flash_${part}_args"
index 7cc24a6381b9c6060a5f7af1a578a6d59d767f53..1e2fa31c23aa9baafcb77056ad906cdfbeb99271 100644 (file)
@@ -1,4 +1 @@
---flash_mode ${ESPFLASHMODE}
---flash_size ${ESPFLASHSIZE}
---flash_freq ${ESPFLASHFREQ}
 ${CONFIG_APP_OFFSET} ${PROJECT_NAME}.bin
index f5bbe084c2ec6b362311ff72416ecabb66212c79..0983e11c4baeb7213e4fad71aca7be0c48316aa4 100644 (file)
@@ -1,4 +1 @@
---flash_mode ${ESPFLASHMODE}
---flash_size ${ESPFLASHSIZE}
---flash_freq ${ESPFLASHFREQ}
 0x8000 partition_table/partition-table.bin
index 0266316ea463ec37645c4c9278d03846189f392d..55e3a93a5be8238c7c0051f865b153d1ee254004 100644 (file)
@@ -7,5 +7,11 @@
         "0x8000" : "partition_table/partition-table.bin",
         "${CONFIG_APP_OFFSET}" : "${PROJECT_NAME}.bin",
         "${PHY_PARTITION_OFFSET}" : "${PHY_PARTITION_BIN_FILE}"
-    }
+    },
+    "bootloader" :      { "offset" : "0x1000",
+                          "file" : "bootloader/bootloader.bin" },
+    "app" :             { "offset" : "${CONFIG_APP_OFFSET}",
+                          "file" : "${PROJECT_NAME}.bin" },
+    "partition_table" : { "offset" : "0x8000",
+                          "file" : "partition_table/partition-table.bin" }
 }
index 79ada71885207c94b17cb8b2fe61b3ed868a1add..8542bd37a4a13656c35a00e0bb1db2c2ff7728fd 100644 (file)
@@ -258,6 +258,29 @@ Now you can build the project. Run::
 \r
 This command will compile the application and all the ESP-IDF components, generate bootloader, partition table, and application binaries.\r
 \r
+.. highlight: none\r
+\r
+::\r
+   $ idf.py build\r
+   Running cmake in directory /path/to/hello_world/build\r
+   Executing "cmake -G Ninja --warn-uninitialized /path/to/hello_world"...\r
+   Warn about uninitialized values.\r
+   -- Found Git: /usr/bin/git (found version "2.17.0")\r
+   -- Building empty aws_iot component due to configuration\r
+   -- Component names: ...\r
+   -- Component paths: ...\r
+   \r
+   ... (more lines of build system output)\r
+   \r
+   [527/527] Generating hello-world.bin\r
+   esptool.py v2.3.1\r
+   \r
+   Project build complete. To flash, run this command:\r
+   ../../../components/esptool_py/esptool/esptool.py -p (PORT) -b 921600 write_flash --flash_mode dio --flash_size detect --flash_freq 40m 0x10000 build/hello-world.bin  build 0x1000 build/bootloader/bootloader.bin 0x8000 build/partition_table/partition-table.bin\r
+   or run 'idf.py flash'\r
+\r
+If there are no errors, the build will finish by generating the firmware binary .bin file.\r
+\r
 Flash To A Device\r
 =================\r
 \r
index bd7b9fe239425b30c2a6d7d44745dbae71aa5b9f..8b2c058fb40730115b733f26aacc5f780f0e4a10 100755 (executable)
@@ -309,6 +309,54 @@ def fullclean(action, args):
         else:
             os.remove(f)
 
+def print_closing_message(args):
+    # print a closing message of some kind
+    #
+
+    if "flash" in str(args.actions):
+        print("Done")
+        return
+
+    # Otherwise, if we built any binaries print a message about
+    # how to flash them
+    def print_flashing_message(title, key):
+        print("\n%s build complete. To flash, run this command:" % title)
+
+        with open(os.path.join(args.build_dir, "flasher_args.json")) as f:
+            flasher_args = json.load(f)
+
+        def flasher_path(f):
+            return os.path.relpath(os.path.join(args.build_dir, f))
+
+        if key != "project":
+            cmd = ""
+            if key == "bootloader":
+                cmd = " ".join(flasher_args["write_flash_args"]) + " "
+
+            cmd += flasher_args[key]["offset"] + " "
+            cmd += flasher_path(flasher_args[key]["file"])
+        else:
+            cmd = " ".join(flasher_args["write_flash_args"]) + " "
+            for o,f in flasher_args["flash_files"].items():
+                cmd += o + " " + flasher_path(f) + " "
+
+        print("%s -p %s -b %s write_flash %s" % (
+            os.path.relpath("%s/components/esptool_py/esptool/esptool.py" % os.environ["IDF_PATH"]),
+            args.port or "(PORT)",
+            args.baud,
+            cmd.strip()))
+        print("or run 'idf.py %s'" % (key + "-flash" if key != "project" else "flash",))
+
+    if "all" in args.actions or "build" in args.actions:
+        print_flashing_message("Project", "project")
+    else:
+        if "app" in args.actions:
+            print_flashing_message("App", "app")
+        if "partition_table" in args.actions:
+            print_flashing_message("Partition Table", "partition_table")
+        if "bootloader" in args.actions:
+            print_flashing_message("Bootloader", "bootloader")
+
 ACTIONS = {
     # action name : ( function (or alias), dependencies, order-only dependencies )
     "all" :                  ( build_target, [], [ "reconfigure", "menuconfig", "clean", "fullclean" ] ),
@@ -343,7 +391,6 @@ def get_commandline_options():
             result.append(a)
     return result
 
-
 def main():
     if sys.version_info[0] != 2 or sys.version_info[1] != 7:
         raise FatalError("ESP-IDF currently only supports Python 2.7, and this is Python %d.%d.%d. Search for 'Setting the Python Interpreter' in the ESP-IDF docs for some tips to handle this." % sys.version_info[:3])
@@ -394,10 +441,12 @@ def main():
 
         completed_actions.add(action)
 
-    while len(args.actions) > 0:
-        execute_action(args.actions[0], args.actions[1:])
-        args.actions.pop(0)
+    actions = list(args.actions)
+    while len(actions) > 0:
+        execute_action(actions[0], actions[1:])
+        actions.pop(0)
 
+    print_closing_message(args)
 
 if __name__ == "__main__":
     try: