Commit Graph

241 Commits

Author SHA1 Message Date
Frantisek Hrbata
00d77e7a75 fix(hints): properly identify source component
If there is a component(child) within a component(parent), like for test_apps, the parent
component may be wrongly identified as source component for the failed include. This may
lead to a false bug report if the parent component has component, which provides the missing
header, in requirements.

Fix this by looking for the longest matching source component directory.

Suggested-by: Ivan Grokhotkov <ivan@espressif.com>
Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2023-09-27 12:50:25 +02:00
Peter Dragun
0a8a5c0e7a fix(tools): fix autocomplete for --port option
Closes https://github.com/espressif/esp-idf/issues/7970
2023-09-06 14:32:48 +02:00
Michal Jenikovsky
e9bb33624b idf.py: gdb action incorrectly generated EOL gdbinit scripts
GDB on Windows incorrectly reads EOL in the script files causing 'gdb'
action to fail.

(gdb) source .../build/gdbinit/py_extensions
(gdb) source .../build\gdbinit\symbols
add symbol table from file "...\build\bootloader\bootloader.elf"
.../build\gdbinit\symbols:6: Error in sourced command file:
Undefined command: "".  Try "help".

Forcing line separator to '\n' resolved the issue

Signed-off-by: Michal Jenikovsky <jendo@jmsystems.sk>
2023-08-11 12:37:29 +02:00
Ivan Grokhotkov
6878ddaa4a feat(tools): idf.py: implement hints for component reqs
Implementation of hint module for component dependency. It can provide
hint about missing header directory in component's INCLUDE_DIRS or
about missing component dependency in REQUIRES or PRIV_REQUIRES.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2023-08-05 20:13:28 +02:00
Ivan Grokhotkov
54d4662107 feat(tools): idf_monitor: support for loadable hint provider modules
Currently hints are supported based on hints.yml only, which may be
limiting for some use cases. This introduces a generic plugin approach,
which allows to implement hint module that doesn't require entry in hints.yml.
Such module has the full command output available and it is not limited to
a single regex in hints.yml.

Note that regex in hint.yml expects the output concatenated into a single line,
but hint modules are getting the output unchanged.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2023-08-05 20:13:28 +02:00
Frantisek Hrbata
ed35c3a94a feat(tools): add global build context
Introduces get_build_context() helper, which allows to get build context, e.g.
project description, at places where this info is not available. The
build context is set within ensure_build_directory.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2023-08-05 20:13:28 +02:00
Ivan Grokhotkov
cfa1896780 Merge branch 'contrib/github_pr_11535' into 'master'
Replace deprecated flushregs alias with full gdb command (GitHub PR)

Closes IDFGH-10272

See merge request espressif/esp-idf!24752
2023-07-28 22:40:22 +08:00
Aleksei Apaseev
6532076ad6 coredump: added the chip_rev field into the coredump header 2023-07-26 10:53:28 +08:00
Aleksei Apaseev
ba51b09cb2 coredump: added the chip_rev field into the coredump header 2023-07-26 10:53:28 +08:00
Roland Dobai
f4a1567474 Merge branch 'bugfix/debug_ext_ctrl_c' into 'master'
tools: fix waiting on gdb process when interrupted with CTRL+C

Closes IDFGH-10638

See merge request espressif/esp-idf!24836
2023-07-20 23:05:53 +08:00
Ivan Grokhotkov
0ebe2cecfa
feat(system): add an error log and a hint on failed interrupt alloc
When interrupt allocation fails, esp_intr_alloc will now print a
message telling that no free interrupt was found. This message is
then checked in hints.yml, to give a link to the troubleshooting
guide.
2023-07-19 16:47:41 +02:00
Ryan Yin
354e2c4673 feat: fix: create-project & create_component with proper file permission 2023-07-17 19:32:30 +08:00
Frantisek Hrbata
ff1ce54869 fix(debug_ext): CTRL+C handling while waiting on gdb process
idf.py spawns gdb process within a thread and uses Thread.join() to wait
for the gdb process to finish. As CTRL+C(SIGINT) is used by gdb to interrupt the
running program, we catch the SIGINT while waiting on the gdb to finish,
and try Thread.join() again.

With cpython's commit

	commit a22be4943c119fecf5433d999227ff78fc2e5741
	Author: Victor Stinner <vstinner@python.org>
	Date:   Mon Sep 27 14:20:31 2021 +0200

	    bpo-45274: Fix Thread._wait_for_tstate_lock() race condition (GH-28532)

this logic doesn't work anymore, because cpython internally marks the
thread as stopped when join() is interrupted with an exception. IMHO
this is broken in cpython and there is a bug report about this
https://github.com/python/cpython/issues/90882. Problem is that
waiting on a thread to finish is based on acquiring a lock. Meaning
join() is waiting on _tstate_lock. If this wait is interrupted, the
above referenced commit adds a logic that checks if the lock is help,
meaning the thread is done and marks the thread as stopped. But there is
no way to tell if the lock was acquired by us running join() or if it's
held by someone else e.g. still by the thread bootstrap code. Meaning
the thread is still running.

I may be missing something, but I don't see any reason why to spawn gdb
process within a thread. This change removes the thread and spawns gdb
directly. Instead waiting on a thread, we wait on the process to finish,
replacing join() with wait() and avoiding this problem.

Closes https://github.com/espressif/esp-idf/issues/11871

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2023-07-17 08:00:23 +02:00
Daniel Mangum
647e7a2a71
fix: Replace deprecated flushregs alias with full gdb command
Usage of `flushregs` in gdb will result in the following warning:

```
Warning: 'flushregs', an alias for the command 'maintenance flush register-cache', is deprecated.
Use 'maintenance flush register-cache'.
```

This patch updates to use the recommend command.

Signed-off-by: Daniel Mangum <georgedanielmangum@gmail.com>
Merges https://github.com/espressif/esp-idf/pull/11535
2023-07-13 09:26:47 +02:00
Marek Fiala
206c46325a fix(tools): Tool curses import check
Verify that curses tool can be successfully imported on unix systems

When detected:
- installing esp-idf -> reinstall python environment
- using idf.py menuconfig -> raise error with hint message

Closes https://github.com/espressif/esp-idf/issues/11643
2023-07-12 13:23:06 +00:00
Wu Zheng Hui
4c713227ae Merge branch 'bugfix/fix_idf_monitor_parsing_pc_with_wrong_rom_elf' into 'master'
bugfix: fix idf passing wrong chip revision to idf_monitor

See merge request espressif/esp-idf!24609
2023-07-11 17:14:10 +08:00
Roland Dobai
15c4b93893 Merge branch 'asyncio_error' into 'master'
[Tools] hints: add guide to fix error with unsupported asyncio

Closes IDFGH-10485

See merge request espressif/esp-idf!24528
2023-07-11 17:05:11 +08:00
Peter Dragun
58c467f3aa fix(tools/coredump-info): pass non-default partition table offset to esp-coredump
Closes https://github.com/espressif/esp-idf/issues/11564
2023-07-10 10:42:06 +02:00
wuzhenghui
78c959b13e fix: fix idf passing wrong chip revision to idf_monitor 2023-07-05 17:30:12 +08:00
Peter Dragun
341390f928 fix(tools/hints): add guide to fix error with unsupported asyncio
Closes https://github.com/espressif/esp-idf/issues/11732
2023-07-03 10:26:26 +02:00
Armando (Dou Yiwen)
17d6768e65 Merge branch 'feature/add_target_esp32p4' into 'master'
esp32p4: introduce the target

See merge request espressif/esp-idf!24155
2023-06-14 10:16:44 +08:00
Armando
101e6a18eb esp32p4: introduce the target
Add esp32p4 target to tools and Kconfig
Create directories and files that are essential for `idf.py --preview set-target esp32p4`
2023-06-13 15:16:11 +08:00
Alexey Lapshin
07c7fe929b tools: process progression for flash action output 2023-06-12 13:56:59 +04:00
Alexey Lapshin
59206e39a0 tools: fix control characters print if hints enabled
Closes https://github.com/espressif/esp-idf/issues/11351
2023-05-22 20:18:02 +08:00
Frantisek Hrbata
a5d3c2d443 tools: fix hints processing in interactive mode
Currently hints are processed only once the process is finished and
exits with non-error exit code. In interactive mode, e.g. for monitor,
we want to process ouput lines for hints right away.

This adds a simple buffer, which keeps the last line and once EOL is
reached, it is processed for hints.

Since the original hints processing was file based, a new helper
function was added to allow processing hints in string.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2023-05-09 14:35:04 +02:00
laokaiyao
bf2a7b2df6 esp32h4: removed esp32h4 related codes 2023-04-23 12:03:07 +00:00
Roland Dobai
1bf382a3e1 Merge branch 'monitor_win_color' into 'master'
bug(idf_monitor, hints): fix monitor colors on windows with hints

Closes IDF-5863

See merge request espressif/esp-idf!22070
2023-04-21 20:15:38 +08:00
Peter Dragun
faa82b060c feat(esptool): allow to set force for write_flash 2023-04-17 12:53:01 +02:00
Peter Dragun
bebd2cec4a bug(idf_monitor): fix color on windows with hints
Closes https://github.com/espressif/esp-idf/issues/9610
2023-04-17 11:18:42 +02:00
Roland Dobai
f57e8eed78 Merge branch 'feature/hfp_ag_hints' into 'master'
tools: Update idf-py hints with Bluedriod HFP AG info

Closes IDF-5671

See merge request espressif/esp-idf!23089
2023-04-11 13:48:15 +08:00
Roland Dobai
05a8d0b58a Merge branch 'bugfix/asyncio_progress_term_width' into 'master'
tools: fix progress output in asyncio.run with zero terminal width

Closes IDF-6646

See merge request espressif/esp-idf!22986
2023-04-06 15:23:39 +08:00
liqigan
fcc6ea1336 tools: Update idf-py hints with Bluedroid HFP AG info 2023-04-06 14:18:27 +08:00
Roland Dobai
775f8e7a49 Merge branch 'bugfix/set_target_with_stale_config' into 'master'
tools: fix set-target if IDF_TARGET env is set and stale sdkconfig exists

Closes IDF-7154

See merge request espressif/esp-idf!22950
2023-03-31 17:31:59 +08:00
Frantisek Hrbata
84deb34035 tools: fix progress output in asyncio.run with zero terminal width
Currently the forced progress in RunTool is trying to fit the output
line into a terminal width, but it doesn't take into an account a
situation when the terminal width is reported as zero. This manifests
when running in docker image with redirected output and can be seen
in the github workflow output for esp-idf-ci-action.

docker run --rm -t my_ubuntu_esp python3 -c 'import os,sys; print(os.get_terminal_size(), sys.stdout.isatty())'
os.terminal_size(columns=238, lines=59) True

vs

docker run --rm -t my_ubuntu_esp python3 -c 'import os,sys; print(os.get_terminal_size(), sys.stdout.isatty())' | tee
os.terminal_size(columns=0, lines=0) True

Since the output is reported as tty and the terminal width as 0, the
fit_text_in_terminal() function returns empty string. I also verified this
by running idf.py build inside a testing docker image.

This fix adjusts the fit_text_in_terminal() function to return original
line if the terminal width is zero.

Also simplify the progress print and use same approach as ninja
https://github.com/ninja-build/ninja/blob/master/src/line_printer.cc#L66

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2023-03-29 17:12:36 +02:00
Frantisek Hrbata
9b731e5e35 tools: fix set-target if IDF_TARGET env is set and stale sdkconfig exists
Currently if the IDF_TARGET env is set, and old sdkconfig exists with
different target value in CONFIG_IDF_TARGET, the set-target action fails
complaining about the IDF_TARGET env and value in sdkconfig being different.
We should ignore IDF_TARGET value from sdkconfig, because we are
actually setting new target and the old sdkconfig is renamed in cmake.

This can be easily reproduced with

---8<---
$ IDF_TARGET=esp32 idf.py set-target esp32
$ IDF_TARGET=esp32s3 idf.py set-target esp32s3

Project sdkconfig '/home/fhrbata/work/hello_world/sdkconfig' was generated
for target 'esp32s3', but environment variable IDF_TARGET is set to 'esp32'.
Run 'idf.py set-target esp32' to generate new sdkconfig file for target esp32.
---8<---

This also adds test for this use case to test_non_default_target.py.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2023-03-28 11:18:04 +02:00
Roland Dobai
51772f4fb5 Merge branch 'feature/update_rom_elfs' into 'master'
tools: update esp-rom-elf to version 20230320

See merge request espressif/esp-idf!22838
2023-03-28 17:10:44 +08:00
Ivan Grokhotkov
77541faa14
tools: idf.py: remove esp32c6 and esp32h2 from preview targets list 2023-03-21 20:41:44 +01:00
Alexey Lapshin
12ab3625ca tools: update esp-rom-elf to version 20230320 2023-03-20 19:20:34 +08:00
Frantisek Hrbata
a558ad506e tools: fix custom sdkconfig renaming in set-target
Currently the set-target has sdkconfig file name hardcoded to the
default one and doesn't honor custom config paths or names.
IMHO the only place where we can really now the config file name
is in cmake. But also the config should be really renamed only if
the set-target action is running.

This moves the config file renaming into cmake and it's performed only
when _IDF_PY_SET_TARGET_ACTION env. var. is set to 'ON'. This should
hopefully guarantee that it's really renamed only while set-target is
running.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2023-03-08 16:45:55 +01:00
Frantisek Hrbata
8e912faad1 tools: add target consistency checks for target specified with -D option
Extend existing target consistency checks for the two following cases.
1. Target does not match currently used toolchain
   $ IDF_TARGET=esp32s2 idf.py reconfigure
   $ idf.py -DIDF_TARGET=esp32c3 build

2. Target is ambiguous, because it's specified also as env. var.
   IDF_TARGET=esp32s3 idf.py set-target esp32c2

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2023-03-08 16:43:42 +01:00
Frantisek Hrbata
0d859f2786 tools: move target guessing into cmake
The _guess_or_check_idf_target() function has sdkconfig and sdkconfig.defaults
file names hardcoded. Since config file names may be specified with SDKCONFIG
or SDKCONFIG_DEFAULTS cmake vars, directly in CMakeLists.txt or passed in with
the -D cmake option, they are not respected.

Problem is when SDKCONFIG or SDKCONFIG_DEFAULTS is set in
CMakeLists.txt. While idf can detect cmake vars passed through it
to cmake via the -D option, detecting SDKCONFIG and SDKCONFIG_DEFAULTS
vars settings in CMakeLists.txt would require to parse it. This seems
like error prone approach. Also if the vars defined by the -D option
are passed directly to cmake, not via idf, they will not be visible to idf.

It seems reasonable to move the logic into cmake, where we know the correct
SDKCONFIG and SDKCONFIG_DEFAULTS values. So the IDF_TARGET detection/guessing
is moved into targets.cmake, where the IDF_TARGET is actually set. The target
is guessed based on the following precendence.

1) $ENV{IDF_TARGET}
2) IDF_TARGET
3) SDKCONFIG
4) sdkconfig
5) SDKCONFIG_DEFAULTS if non-empty or
   $ENV{SDKCONFIG_DEFAULTS} if non-empty or
   sdkconfig.defaults
6) esp32

All config files referred in $ENV{SDKCONFIG_DEFAULTS} and SDKCONFIG_DEFAULTS
are searched, compared to the current behaviour. First target found in the
above chain is used.

The original _guess_or_check_idf_target() is renamed to _check_idf_target() and
used for the target consistency checks only.

The get_sdkconfig_filename() helper is now used to get the sdkconfig file
for consistency checks. It looks in SDKCONFIG specified with the -D
option and project_description.json.

With this change config full paths are reported in messages, so it's clear
e.g. from which config the target was guessed from or which config has
consistency problem. test_non_default_target.py was adjusted to this
change and also new test for testing the IDF_TARGET guessing was added.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2023-03-08 16:37:58 +01:00
Frantisek Hrbata
a8a4d7c66d tools: add get_sdkconfig_filename() helper
Get project's current sdkconfig file name. It looks in SDKCONFIG cmake var
defined by the -D option and project_description.json. If not found return
default sdkconfig.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2023-03-08 16:37:58 +01:00
Frantisek Hrbata
e89f980193 tools: add _parse_cmdl_cmakecache() helper
This parses cmakes cache vars defined on command line with -D options
into dictionary. It allows to simplify the check for new cache entries
and also can be re-used for other checks.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2023-03-08 16:37:58 +01:00
Alexey Lapshin
0da15a7a19 build: add option COMPILER_DISABLE_GCC12_WARNINGS 2023-02-22 05:33:03 +00:00
Martin Vychodil
c58a84f893 Merge branch 'feature/fatfs_format_api' into 'master'
fatfs: added APIs to format a FAT filesystem

Closes IDF-6046

See merge request espressif/esp-idf!21845
2023-02-16 19:59:31 +08:00
Armando
d59fd3e529 fatfs: deprecate esp_vfs_fat_sdmmc_unmount
This API was deprecated before, but without deprecation warning and
migration doc. This commit added deprecation warning and migration doc
to it.
2023-02-16 14:17:51 +08:00
Erhan Kurubas
69b1d1786c docs: JTAG debugging update for ESP32-H2 2023-02-13 22:49:00 +01:00
Roland Dobai
648b1a41c6 Merge branch 'bugfix/dbg_target_hints' into 'master'
tools: enable hints for debug targets

Closes IDF-5795

See merge request espressif/esp-idf!22198
2023-02-10 17:25:27 +08:00
Frantisek Hrbata
dc580bdc97 tools: add hints for openocd
This moves one hint, which was hardcoded in debug_ext.py to
hints.yml and adds a new one when openocd process does not have
permissions to the USB JTAG/serial device.

Also hint replacing the original 'Please check JTAG connection!'
hardcoded message is added.

Suggested-by: Alexey Lapshin <alexey.lapshin@espressif.com>
Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2023-02-03 14:56:14 +01:00
Peter Dragun
3e3533f918 feat(idf_monitor): move idf_monitor to separate repo 2023-02-03 11:20:15 +01:00