Multiple ``idf.py`` commands can be combined into one. For example, ``idf.py -p COM4 clean flash monitor`` will clean the source tree, then build the project and flash it to the ESP32 before running the serial monitor.
+.. note:: The environment variables ``ESPPORT`` and ``ESPBAUD`` can be used to set default values for the ``-p`` and ``-b`` options, respectively. Providing these options on the command line overrides the default.
+
Advanced Commands
^^^^^^^^^^^^^^^^^
- CMake based: ``idf.py -p (port) flash``
- GNU Make based: ``make flash ESPPORT=/dev/ttyUSB0``, or set in ``menuconfig``.
+(Note: ``idf.py`` will also use the ``ESPPORT`` environment variable for a default serial port, if no ``-p`` argument is provided.)
+
To set the baud rate for flashing:
- CMake based: ``idf.py -b 921600 flash``
- GNU Make based: ``make flash ESPBAUD=921600``, or set in ``menuconfig``.
+(Note: ``idf.py`` will also use the ``ESPBAUD`` environment variable for a default baud rate, if no ``-b`` argument is provided.)
+
Porting GNU Make Based Components to CMake
==========================================
def main():
parser = argparse.ArgumentParser(description='ESP-IDF build management tool')
- parser.add_argument('-p', '--port', help="Serial port", default=None)
- parser.add_argument('-b', '--baud', help="Baud rate", default=460800)
+ parser.add_argument('-p', '--port', help="Serial port",
+ default=os.environ.get('ESPPORT', None))
+ parser.add_argument('-b', '--baud', help="Baud rate",
+ default=os.environ.get('ESPBAUD', 460800))
parser.add_argument('-C', '--project-dir', help="Project directory", default=os.getcwd())
parser.add_argument('-B', '--build-dir', help="Build directory", default=None)
parser.add_argument('-G', '--generator', help="Cmake generator", choices=GENERATOR_CMDS.keys())