diff --git a/docs/en/migration-guides/tools.rst b/docs/en/migration-guides/tools.rst index 880ac373b4..70ffceeab0 100644 --- a/docs/en/migration-guides/tools.rst +++ b/docs/en/migration-guides/tools.rst @@ -4,4 +4,4 @@ Migrate Tools to ESP-IDF 5.0 IDF Monitor ----------- -IDF Monitor follows the custom console baud-rate (:ref:`CONFIG_ESP_CONSOLE_UART_BAUDRATE`) by default instead of 115200. Setting a custom baud rate is not supported from menuconfig anymore. A custom baud-rate can be specified from command line with the ``idf.py monitor -B `` command or through setting environment variables. Run ``idf.py monitor --help`` for more information. +IDF Monitor follows the custom console baud-rate (:ref:`CONFIG_ESP_CONSOLE_UART_BAUDRATE`) by default instead of 115200. Setting a custom baud rate is not supported from menuconfig anymore. A custom baud-rate can be specified from command line with the ``idf.py monitor -b `` command or through setting environment variables. Please note that the baud-rate argument has been renamed from ``-B`` to ``-b`` in order to be consistent with the global baud-rate ``idf.py -b ``. Run ``idf.py monitor --help`` for more information. diff --git a/tools/idf_py_actions/serial_ext.py b/tools/idf_py_actions/serial_ext.py index 9d14761e65..21298598f4 100644 --- a/tools/idf_py_actions/serial_ext.py +++ b/tools/idf_py_actions/serial_ext.py @@ -97,10 +97,18 @@ def action_extensions(base_actions, project_path): esp_port = args.port or _get_default_serial_port(args) monitor_args += ['-p', esp_port] - if not monitor_baud: - monitor_baud = os.getenv('IDF_MONITOR_BAUD') or os.getenv('MONITORBAUD') or project_desc['monitor_baud'] + baud = monitor_baud or os.getenv('IDF_MONITOR_BAUD') or os.getenv('MONITORBAUD') - monitor_args += ['-b', monitor_baud] + if baud is None: + # Baud hasn't been changed locally (by local baud argument nor by environment variables) + # + # Use the global baud rate if it has been changed by the command line. + # Use project_desc['monitor_baud'] as the last option. + + global_baud_defined = ctx._parameter_source['baud'] == click.core.ParameterSource.COMMANDLINE + baud = args.baud if global_baud_defined else project_desc['monitor_baud'] + + monitor_args += ['-b', baud] monitor_args += ['--toolchain-prefix', project_desc['monitor_toolprefix']] @@ -166,7 +174,7 @@ def action_extensions(base_actions, project_path): baud_rate = { 'names': ['-b', '--baud'], - 'help': 'Baud rate for flashing.', + 'help': 'Baud rate for flashing. It can imply monitor baud rate as well if it hasn\'t been defined locally.', 'scope': 'global', 'envvar': 'ESPBAUD', 'default': 460800, @@ -225,12 +233,12 @@ def action_extensions(base_actions, project_path): 'default': None, }, { - 'names': ['--monitor-baud', '-B'], + 'names': ['--monitor-baud', '-b'], 'type': click.INT, 'help': ('Baud rate for monitor. ' 'If this option is not provided IDF_MONITOR_BAUD and MONITORBAUD ' - 'environment variables and project_description.json in build directory ' + 'environment variables, global baud rate and project_description.json in build directory ' "(generated by CMake from project's sdkconfig) " 'will be checked for default value.'), }, {