Commit Graph

50 Commits

Author SHA1 Message Date
Frantisek Hrbata
9fe4ceafc7 fix: make idf_size.py compatible with python3.8
Previous 6caa4a17ac ("fix: display correct help in the idf_size.py wrapper")
introduced a regression, because it uses exit_on_error parameter for
argparse.ArgumentParser, which was added in python3.9, making
idf_size.py incompatible with idf.py minimal required python3.8.

The objective is to inspect the arguments of idf_size.py using a wrapper
argparse to determine whether the legacy or refactored version should be
initiated, while always displaying help for the underlying version. The
exit_on_error function was previously utilized to prevent argparse from
exiting and displaying help/usage. This replaces exit_on_error with a
workaround that makes the --format argument optional. Since this is the
sole instance where the wrapper argparse might fail, it achieves the
same outcome as using exit_on_error.

Fixes: 6caa4a17ac ("fix: display correct help in the idf_size.py wrapper")
Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2024-05-08 11:21:10 +02:00
Frantisek Hrbata
6caa4a17ac fix: display correct help in the idf_size.py wrapper
Currently the wrapper tries to figure out which version of
the esp-idf-size should be started. The legacy version is
used if explicitly requested by the -l/--legacy option or
if json format is specified. This works fine, but if help
is requested, it is printed for the wrapper as shown bellow

$ idf_size.py -h
usage: idf_size.py [-h] [--format FORMAT] [-l]

options:
  -h, --help       show this help message and exit
  --format FORMAT
  -l, --legacy

This is not convenient and the full help from the underlying
version should be displayed.

Fix this by only peeking into the args to figure out if legacy or
refactored version should be started and always spawn the underlying
esp_idf_size python module. This is done by using exit_on_error=False and
add_help=False for the ArgumentParser. When help for refactored version
is requested a note as following is printed to notify users that the
legacy version can still be used.

$ idf_size.py -h
Note: legacy esp_idf_size version can be invoked by specifying the -l/--legacy
option or by setting the ESP_IDF_SIZE_LEGACY environment variable.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2024-05-06 13:00:49 +02:00
Frantisek Hrbata
18334588bc feat(tools): esp_idf_size.ng integration
This integrates esp_idf_size.ng, refactored esp-idf-size version, into
esp-idf and enables it by default. The esp_idf_size.ng may be enabled
by using the --ng option, but also via ESP_IDF_SIZE_NG env. variable,
which is used in this integration.

New -l/--legacy option is added, which enforces usage of the old version.
This option can be also set via "ESP_IDF_SIZE_LEGACY" env. variable.
This should allow to easily switch back to old version if there is any
problem.

The new version is used by default for all formats, except for the "json".

Examples:
$ idf.py size                           # uses refactored version
$ idf.py size --legacy                  # uses legacy version
$ idf.py size --l                       # uses legacy version
$ idf.py size --format json             # uses legacy version
$ idf.py size --format json2            # uses refactored version
$ export ESP_IDF_SIZE_LEGACY="1"        # use legacy version only from now on

ESP_IDF_SIZE_FORCE_TERMINAL, which forces terminal control codes(colors), is also set
when running from idf.py, so the colors are propagated even if stdout
for esp_idf_size.ng is not attached to tty.

The same changes are applied also to the idf_size.py wrapper.

There is an import check if esp_idf_size.ng is available. If not,
we switch into the legacy mode. This should cover situation when the
esp-idf has support for refactored version, but it's not installed.
This should also allow users to bind to a legacy version(<1.0.0) and the
idf.py size and idf_size.py should still work. This also allow us to
restring the version in constraints file if we need to switch back to
legacy version globally.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2023-11-30 09:26:51 +01:00
Djordje Nedic
3e0f612a7e tools: Move out idf_size.py in favour of using the esp-idf-size package
This commit removes all idf_size.py files and references to them and adds esp-idf-size as a dependency and adequate wrappers to avoid breaking changes.
2023-03-27 19:40:33 +02:00
Djordje Nedic
7cf3e284f5 Fix idf_size.py archives diff display when using the CSV output mode
This commit fixes two issues:
1. Part of the header containing annotations for curr, reference and diff values for archive diffs wasn't formatted correctly
2. Only one third of the values in the table were displayed because of the wrong line format
2023-01-13 23:04:40 +01:00
Djordje Nedic
0810dd20e8 idf_size.py: Fix issue where diram size was halved in cases where iram was not fully filled with cache
This fixes an attempted fix for diram size calculation where it was counted twice, however the fix did not account for cases where iram was not fully filled with cache and therefore was of non 0 size.
Now the calculation should be correct regardless of the cache size.

Closes https://github.com/espressif/esp-idf/issues/9960
2022-11-28 10:47:32 +01:00
Djordje Nedic
5ee663d592 tools: Add CSV support to idf_size.py
This adds CSV support to idf_size.py and idf.py size actions and using the --format argument which accepts 'text', 'json' or 'csv' as input.

idf_size.py --json argument is deprecated but left to avoid a breaking change.

For idf.py size actions OUTPUT_JSON environment variable set at configuration time is overriden at target build time if --format is used.

Additionally, this commit refactors big parts of code, unified usage of json_dict and manually generated dictionaries for textual output and improves code quality in many parts.
2022-08-26 15:34:21 +02:00
simon.chupin
35dda59209 tools: remove the dependency on the future package 2022-08-09 16:46:58 +02:00
Anton Maklakov
51c22d3b8b tools: GCC 11 uses both '.debug_line_str' and '.debug_str' sections 2022-05-27 15:06:56 +07:00
Roland Dobai
f1f0bd34b9 Tools/idf_size.py: Support .noinit sections
Closes https://github.com/espressif/esp-idf/issues/8428
2022-03-01 18:58:20 +01:00
Roland Dobai
ad59ef3893 tools/idf_size.py: Identify objects without extension in MAP files 2022-03-01 18:11:36 +01:00
simon.chupin
38ba3d16ff add test for checking memory segments with esptool.py 2022-01-17 20:47:35 +08:00
simon.chupin
a520bad2f3 tools/idf_size: Fixed bug with wrong memory calculation 2022-01-17 20:47:35 +08:00
simon.chupin
cd5e830445 tools: add json schema for idf_size 2021-11-10 16:21:50 +01:00
simon.chupin
bca79c75d5 tools: Improve chip target detection 2021-11-03 15:36:56 +01:00
simon.chupin
8cff2a27e6 change --archive_details output 2021-11-01 17:43:31 +01:00
simon.chupin
f82309b1df tools: fix bug with idf_size argument archive_details 2021-10-27 16:18:35 +02:00
Jakob Hasse
81e9266204 [examples]: removed hyphens
Replaced hyphens with underscores in examples
project definition for all examples which had
hyphens in their project name. dpp-enrollee is
an exceptions because the name matches the
project directory name while the project
directory also contains hyphens.
2021-10-09 13:58:24 +08:00
simon.chupin
57d1e6157b tools/idf_size: improve readability 2021-10-06 15:28:05 +02:00
Simon Chupin
8d74bf87ec Merge branch 'bugfix/idf_size_nan_in_json' into 'master'
Tools: fix appearing NaN value when calling idf_size.py --json

Closes IDF-3951

See merge request espressif/esp-idf!15245
2021-09-24 13:11:01 +00:00
simon.chupin
a7be2cb9bb Tools: update idf_size.py types to pep-484 format 2021-09-24 15:42:36 +08:00
simon.chupin
bfd8e0eac6 Tools: fix appearing NaN value when calling idf_size.py --json 2021-09-21 16:12:42 +02:00
simon.chupin
844dd5075f Tools: make idf_size work with overflow
Closes https://github.com/espressif/esp-idf/issues/6914
closes https://github.com/espressif/esp-idf/issues/4234
2021-09-16 14:12:46 +02:00
simon.chupin
294f9783fc Tools: Fix memory calculations of idf_size.py 2021-08-11 17:51:51 +02:00
Michael (XIAO Xufeng)
064f12cb90 idf_size.py: fixed diram counted twice issue, and improve display
Currently static RAM usage are listed under corresponding physical
memory.

ld: fix linker script for C3 and S3
2021-08-11 17:51:50 +02:00
Shu Chen
ee23a489b9 esp32h2: code clean up 2021-07-01 19:53:50 +08:00
Shu Chen
2b9e8fed71 esp32h2: add esp32h2 build target
Add esp32h2 support in the following components:
 * Kconfig
 * components/esptool_py
 * components/riscv
 * components/xtensa
 * tools
2021-07-01 19:51:33 +08:00
Roland Dobai
7be1d2287c tools: Don't count BSS into the total image size 2021-02-26 06:49:35 +00:00
Fu Hanxi
0146f258d7 style: format python files with isort and double-quote-string-fixer 2021-01-26 10:49:01 +08:00
Michael (XIAO Xufeng)
b52c764bf3 idf_size.py: add support for esp32c3 and risc-v 2020-11-13 07:49:11 +11:00
morris
9fa06719fa global: enable build uinit test for esp32-s3 2020-09-22 15:15:03 +08:00
Roland Dobai
511135989c tools: Autodetect the target of MAP files in idf_size.py 2020-04-22 13:12:56 +02:00
Roland Dobai
66271f7a86 tools: Support showing differences of MAP files in JSON format 2020-03-23 12:04:07 +01:00
Roland Dobai
c81243b92b tools: Add option to show differences between MAP files with idf_size.py 2020-03-23 12:04:07 +01:00
Roland Dobai
f6e1414ba6 tools: Remove unused toolchain-prefix argument from idf_size.py 2020-03-23 12:04:07 +01:00
Roland Dobai
2816c3c536 tools: Fix idf_size.py 2020-02-28 11:55:53 +01:00
Roland Dobai
1821ee8851 tools: Add proper multi-chip support for idf_size.py 2020-02-27 19:50:05 +01:00
Jakob Hasse
53aadafac8 idf_size.py: can alternatively write data to file
* Also Changed json separators - no spaces at eol
2020-01-02 09:33:51 +08:00
Anthony Casagrande
874cfda54c idf_size.py: Major performance improvements
Merges https://github.com/espressif/esp-idf/pull/4518
2019-12-30 17:14:49 +11:00
Angus Gratton
05be37c87c idf_size: Support JSON output
Pass -DOUTPUT_JSON=1 to get JSON formatted output from CMake targets
2019-05-29 17:11:53 +10:00
Roland Dobai
bfa9610f58 tools: Fix the Python coding style 2018-12-19 11:56:24 +01:00
Angus Gratton
5fbfd20f10 Merge branch 'master' into feature/cmake 2018-08-30 18:52:31 +08:00
Roland Dobai
5cdff46370 tools: Support Python 3 in idf_size.py 2018-08-27 13:39:07 +02:00
Angus Gratton
9ec14decce cmake: Fix idf_size.py merge errors 2018-05-01 17:27:39 +10:00
Angus Gratton
0bdc12256e cmake: Add "size" target, update idf_size.py for different linker behaviour 2018-04-30 09:59:20 +10:00
Ivan Grokhotkov
4e982d4b18 Merge branch 'feature/idf_size_report_symbols' into 'master'
Feature/idf-size: report per-archive symbols and their sizes

See merge request idf/esp-idf!1956
2018-04-20 23:55:19 +08:00
Kedar Sovani
c8ef747c0a idf_size: Report per-symbol size from the map file
Report as per the relevant sections output in the 'archives' output
2018-02-19 17:13:56 +05:30
Kedar Sovani
c9e6ed7d60 idf_size: Sort output on total-size instead of filename 2018-02-19 11:50:46 +05:30
Angus Gratton
a8f08dc5da make size: Fix map file parsing error on Windows
Closes https://github.com/espressif/esp-idf/issues/739
2017-06-29 12:54:13 +10:00
Angus Gratton
5055290baf build system: Add idf_size.py tool for better "make size" output & analysis
Add new "make size_components" and "make size_files" targets for analysing makeup of the ELF file.

Plain "make size" output now looks like this:

Total sizes:
 DRAM .data size:   11156 bytes
 DRAM .bss  size:   22304 bytes
Used static DRAM:   33460 bytes ( 294220 available, 10.2% used)
Used static IRAM:   80480 bytes (  50592 available, 61.4% used)
      Flash code:  421463 bytes
    Flash rodata:  103824 bytes
Total image size:~ 616923 bytes (.bin may be padded larger)
2017-06-21 15:43:22 +10:00