Merge branch 'bugfix/monitor_baud_rate' into 'master'

Tools: Rename the monitor's baud argument for consistency and use the global baud if not defined

Closes IDFGH-6686

See merge request espressif/esp-idf!17065
This commit is contained in:
Roland Dobai 2022-02-16 18:13:50 +00:00
commit 03fb3fd25b
2 changed files with 15 additions and 7 deletions

View File

@ -4,4 +4,4 @@ Migrate Tools to ESP-IDF 5.0
IDF Monitor 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 <baud>`` 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 <baud>`` 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 <baud>``. Run ``idf.py monitor --help`` for more information.

View File

@ -97,10 +97,18 @@ def action_extensions(base_actions, project_path):
esp_port = args.port or _get_default_serial_port(args) esp_port = args.port or _get_default_serial_port(args)
monitor_args += ['-p', esp_port] monitor_args += ['-p', esp_port]
if not monitor_baud: baud = monitor_baud or os.getenv('IDF_MONITOR_BAUD') or os.getenv('MONITORBAUD')
monitor_baud = os.getenv('IDF_MONITOR_BAUD') or os.getenv('MONITORBAUD') or project_desc['monitor_baud']
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']] monitor_args += ['--toolchain-prefix', project_desc['monitor_toolprefix']]
@ -166,7 +174,7 @@ def action_extensions(base_actions, project_path):
baud_rate = { baud_rate = {
'names': ['-b', '--baud'], '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', 'scope': 'global',
'envvar': 'ESPBAUD', 'envvar': 'ESPBAUD',
'default': 460800, 'default': 460800,
@ -225,12 +233,12 @@ def action_extensions(base_actions, project_path):
'default': 'default':
None, None,
}, { }, {
'names': ['--monitor-baud', '-B'], 'names': ['--monitor-baud', '-b'],
'type': 'type':
click.INT, click.INT,
'help': ('Baud rate for monitor. ' 'help': ('Baud rate for monitor. '
'If this option is not provided IDF_MONITOR_BAUD and MONITORBAUD ' '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) " "(generated by CMake from project's sdkconfig) "
'will be checked for default value.'), 'will be checked for default value.'),
}, { }, {