idf.py: Print flashing steps at the end of each build

This commit is contained in:
Angus Gratton 2018-05-24 16:05:31 +10:00 committed by Angus Gratton
parent 955e84a3bc
commit 580cfeaaae
6 changed files with 84 additions and 12 deletions

View 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"

View file

@ -1,4 +1 @@
--flash_mode ${ESPFLASHMODE}
--flash_size ${ESPFLASHSIZE}
--flash_freq ${ESPFLASHFREQ}
${CONFIG_APP_OFFSET} ${PROJECT_NAME}.bin

View file

@ -1,4 +1 @@
--flash_mode ${ESPFLASHMODE}
--flash_size ${ESPFLASHSIZE}
--flash_freq ${ESPFLASHFREQ}
0x8000 partition_table/partition-table.bin

View 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" }
}

View file

@ -258,6 +258,29 @@ Now you can build the project. Run::
This command will compile the application and all the ESP-IDF components, generate bootloader, partition table, and application binaries.
.. highlight: none
::
$ idf.py build
Running cmake in directory /path/to/hello_world/build
Executing "cmake -G Ninja --warn-uninitialized /path/to/hello_world"...
Warn about uninitialized values.
-- Found Git: /usr/bin/git (found version "2.17.0")
-- Building empty aws_iot component due to configuration
-- Component names: ...
-- Component paths: ...
... (more lines of build system output)
[527/527] Generating hello-world.bin
esptool.py v2.3.1
Project build complete. To flash, run this command:
../../../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
or run 'idf.py flash'
If there are no errors, the build will finish by generating the firmware binary .bin file.
Flash To A Device
=================

View file

@ -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: