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.
This commit is contained in:
Djordje Nedic 2023-03-27 19:40:33 +02:00
parent 39087f3157
commit 3e0f612a7e
41 changed files with 20 additions and 549665 deletions

View File

@ -187,7 +187,6 @@
/tools/ci/ @esp-idf-codeowners/ci
/tools/cmake/ @esp-idf-codeowners/build-config
/tools/esp_prov/ @esp-idf-codeowners/app-utilities
/tools/idf_size_yaml/ @esp-idf-codeowners/peripherals
/tools/kconfig*/ @esp-idf-codeowners/build-config
/tools/ldgen/ @esp-idf-codeowners/build-config
/tools/mass_mfg/ @esp-idf-codeowners/app-utilities

View File

@ -109,18 +109,6 @@ test_certificate_bundle_on_host:
- ./test_gen_crt_bundle.py
test_idf_size:
extends: .host_test_template
artifacts:
when: on_failure
paths:
- tools/test_idf_size/output
- tools/test_idf_size/.coverage
expire_in: 1 week
script:
- cd ${IDF_PATH}/tools/test_idf_size
- ./test.sh
test_idf_py:
extends: .host_test_template
variables:

View File

@ -139,8 +139,6 @@
- "tools/test_idf_py/**/*"
- "tools/idf_size.py"
- "tools/idf_size_yaml/*"
- "tools/test_idf_size/**/*"
- "tools/tools.json"
- "tools/tools_schema.json"

View File

@ -191,9 +191,9 @@ Comparing Two Binaries
If making some changes that affect binary size, it's possible to use an ESP-IDF tool to break down the exact differences in size.
This operation isn't part of ``idf.py``, it's necessary to run the ``idf_size.py`` Python tool directly.
This operation isn't part of ``idf.py``, it's necessary to run the `esp_idf_size <https://github.com/espressif/esp-idf-size>`_ Python tool directly.
To do so, first locate the linker map file in the build directory. It will have the name ``PROJECTNAME.map``. The ``idf_size.py`` tool performs its analysis based on the output of the linker map file.
To do so, first locate the linker map file in the build directory. It will have the name ``PROJECTNAME.map``. The ``esp_idf_size`` tool performs its analysis based on the output of the linker map file.
To compare with another binary, you will also need its corresponding ``.map`` file saved from the build directory.
@ -201,7 +201,7 @@ For example, to compare two builds: one with the default :ref:`CONFIG_COMPILER_O
.. code-block:: bash
$ $IDF_PATH/tools/idf_size.py --diff build_Og/https_request.map build_Os/https_request.map
$ python -m esp_idf_size --diff build_Og/https_request.map build_Os/https_request.map
<CURRENT> MAP file: build_Os/https_request.map
<REFERENCE> MAP file: build_Og/https_request.map
Difference is counted as <CURRENT> - <REFERENCE>, i.e. a positive number means that <CURRENT> is larger.
@ -219,17 +219,17 @@ We can see from the "Difference" column that changing this one setting caused th
It's also possible to use the "diff" mode to output a table of component-level (static library archive) differences:
.. note::
To get the output in JSON or CSV format using ``idf_size.py`` it is possible to use the ``--format`` option.
To get the output in JSON or CSV format using ``esp_idf_size`` it is possible to use the ``--format`` option.
.. code-block:: bash
$IDF_PATH/tools/idf_size.py --archives --diff build_Og/https_request.map build_Oshttps_request.map
python -m esp_idf_size --archives --diff build_Og/https_request.map build_Oshttps_request.map
Also at the individual source file level:
.. code-block:: bash
$IDF_PATH/tools/idf_size.py --files --diff build_Og/https_request.map build_Oshttps_request.map
python -m esp_idf_size --files --diff build_Og/https_request.map build_Oshttps_request.map
Other options (like writing the output to a file) are available, pass ``--help`` to see the full list.
@ -240,20 +240,20 @@ Showing Size When Linker Fails
If too much static memory is used, then the linker will fail with an error such as ``DRAM segment data does not fit``, ``region `iram0_0_seg' overflowed by 44 bytes``, or similar.
In these cases, ``idf.py size`` will not succeed either. However it is possible to run ``idf_size.py`` manually in order to view the *partial static memory usage* (the memory usage will miss the variables which could not be linked, so there still appears to be some free space.)
In these cases, ``idf.py size`` will not succeed either. However it is possible to run ``esp_idf_size`` manually in order to view the *partial static memory usage* (the memory usage will miss the variables which could not be linked, so there still appears to be some free space.)
The map file argument is ``<projectname>.map`` in the build directory
.. code-block:: bash
$IDF_PATH/tools/idf_size.py build/project_name.map
python -m esp_idf_size build/project_name.map
It is also possible to view the equivalent of ``size-components`` or ``size-files`` output:
.. code-block:: bash
$IDF_PATH/tools/idf_size.py --archives build/project_name.map
$IDF_PATH/tools/idf_size.py --files build/project_name.map
python -m esp_idf_size --archives build/project_name.map
python -m esp_idf_size --files build/project_name.map
.. _linker-map-file:

View File

@ -62,7 +62,7 @@ def get_pytest_apps(
default_size_json_path = 'size.json'
build_dir = 'build_@t_@w'
if target == 'linux': # no idf_size.py for linux target
if target == 'linux': # no esp_idf_size for linux target
default_size_json_path = None # type: ignore
# IDF-6644
# hard-coded in components/esp_partition/partition_linux.c

View File

@ -112,7 +112,6 @@ tools/set-submodules-to-github.sh
tools/test_apps/system/no_embedded_paths/check_for_file_paths.py
tools/test_idf_py/test_hints.py
tools/test_idf_py/test_idf_py.py
tools/test_idf_size/test.sh
tools/test_idf_tools/test_idf_tools.py
tools/test_mkdfu/test_mkdfu.py
tools/test_mkuf2/test_mkuf2.py

View File

@ -501,7 +501,7 @@ macro(project project_name)
set(project_elf ${CMAKE_PROJECT_NAME}.elf)
# Create a dummy file to work around CMake requirement of having a source file while adding an
# executable. This is also used by idf_size.py to detect the target
# executable. This is also used by esp_idf_size to detect the target
set(project_elf_src ${CMAKE_BINARY_DIR}/project_elf_src_${IDF_TARGET}.c)
add_custom_command(OUTPUT ${project_elf_src}
COMMAND ${CMAKE_COMMAND} -E touch ${project_elf_src}
@ -566,7 +566,7 @@ macro(project project_name)
string(TOUPPER ${idf_target} idf_target)
# Add cross-reference table to the map file
target_link_options(${project_elf} PRIVATE "-Wl,--cref")
# Add this symbol as a hint for idf_size.py to guess the target name
# Add this symbol as a hint for esp_idf_size to guess the target name
target_link_options(${project_elf} PRIVATE "-Wl,--defsym=IDF_TARGET_${idf_target}=0")
# Enable map file output
target_link_options(${project_elf} PRIVATE "-Wl,--Map=${mapfile}")
@ -589,9 +589,9 @@ macro(project project_name)
idf_build_get_property(idf_path IDF_PATH)
idf_build_get_property(python PYTHON)
set(idf_size ${python} ${idf_path}/tools/idf_size.py)
set(idf_size ${python} -m esp_idf_size)
# Add size targets, depend on map file, run idf_size.py
# Add size targets, depend on map file, run esp_idf_size
# OUTPUT_JSON is passed for compatibility reasons, SIZE_OUTPUT_FORMAT
# environment variable is recommended and has higher priority
add_custom_target(size

File diff suppressed because it is too large Load Diff

View File

@ -1,26 +0,0 @@
# Data_type:
# primary_address: value
# length: value or equation
# secondary_address: value if exist
DRAM:
primary_address: 0x3FFAE000
length: 17 * 0x2000 + 4 * 0x8000 + 4 * 0x4000
IRAM:
primary_address: 0x40070000
length: 2 * 0x8000 + 16 * 0x2000
CACHE_I:
primary_address: 0x400C2000
length: 0xB3E000
CACHE_D_1:
primary_address: 0x3F400000
length: 0x400000
CACHE_D_2:
primary_address: 0x3F800000
length: 0x400000
RTC_FAST_D:
primary_address: 0x3FF80000
length: 0x2000
secondary_address: 0x400C0000
RTC_SLOW_D:
primary_address: 0x50000000
length: 0x2000

View File

@ -1,17 +0,0 @@
# Data_type:
# primary_address: value
# length: value or equation
# secondary_address: value if exist
DRAM:
primary_address: 0x3FCA0000
length: 0x40000
secondary_address: 0x40380000
IRAM:
primary_address: 0x4037C000
length: 0x4000
CACHE_I:
primary_address: 0x42000000
length: 0x400000
CACHE_D:
primary_address: 0x3C000000
length: 0x400000

View File

@ -1,20 +0,0 @@
# Data_type:
# primary_address: value
# length: value or equation
# secondary_address: value if exist
DRAM:
primary_address: 0x3FC80000
length: 0x60000
secondary_address: 0x40380000
IRAM:
primary_address: 0x4037C000
length: 0x4000
CACHE_I:
primary_address: 0x42000000
length: 0x800000
CACHE_D:
primary_address: 0x3C000000
length: 0x800000
RTC_SLOW_D:
primary_address: 0x50000000
length: 0x2000

View File

@ -1,17 +0,0 @@
# Data_type:
# primary_address: value
# length: value or equation
# secondary_address: value if exist
DRAM:
primary_address: 0x40800000
length: 0x80000
secondary_address: 0x40800000
CACHE_I:
primary_address: 0x42000000
length: 0x1000000
CACHE_D:
primary_address: 0x42000000
length: 0x1000000
RTC_SLOW_D: # TODO: IDF-5667 Better to rename to LP_RAM
primary_address: 0x50000000
length: 0x4000

View File

@ -1,17 +0,0 @@
# Data_type:
# primary_address: value
# length: value or equation
# secondary_address: value if exist
DRAM:
primary_address: 0x40800000
length: 0x50000
secondary_address: 0x40800000
CACHE_I:
primary_address: 0x42000000
length: 0x800000
CACHE_D:
primary_address: 0x42000000
length: 0x800000
RTC_SLOW_D: # TODO: IDF-5667 Better to rename to LP_RAM
primary_address: 0x50000000
length: 0x4000

View File

@ -1,20 +0,0 @@
# Data_type:
# primary_address: value
# length: value or equation
# secondary_address: value if exist
DRAM:
primary_address: 0x3FC80000
length: 0x60000
secondary_address: 0x40380000
IRAM:
primary_address: 0x4037C000
length: 0x4000
CACHE_I:
primary_address: 0x42000000
length: 0x800000
CACHE_D:
primary_address: 0x3C000000
length: 0x800000
RTC_SLOW_D:
primary_address: 0x50000000
length: 0x2000

View File

@ -1,24 +0,0 @@
# Data_type:
# primary_address: value
# length: value or equation
# secondary_address: value if exist
DRAM:
primary_address: 0x3FFB2000
length: 3 * 0x2000 + 18 * 0x4000
secondary_address: 0x40022000
CACHE_I_1:
primary_address: 0x3F000000
length: 0x400000
CACHE_D:
primary_address: 0x3F500000
length: 0xA80000
CACHE_I_2:
primary_address: 0x40080000
length: 0x780000
RTC_FAST_D:
primary_address: 0x40070000
length: 0x2000
secondary_address: 0x3FF9E000
RTC_SLOW_D:
primary_address: 0x50000000
length: 0x2000

View File

@ -1,27 +0,0 @@
# Data_type:
# primary_address: value
# length: value or equation
# secondary_address: value if exist
IRAM:
primary_address: 0x40370000
length: 0x8000
DRAM_1:
primary_address: 0x3FC88000
length: 0x8000 + 6 * 0x10000
secondary_address: 0x40378000
DRAM_2:
primary_address: 0x3FCF0000
length: 0x10000
CACHE_I:
primary_address: 0x42000000
length: 0x2000000
CACHE_D:
primary_address: 0x3C000000
length: 0x2000000
RTC_FAST_D:
primary_address: 0x3ff80000
length: 0x2000
secondary_address: 0x600FE000
RTC_SLOW_D:
primary_address: 0x50000000
length: 0x2000

View File

@ -11,6 +11,7 @@ esp-coredump
esptool
esp-idf-kconfig
esp-idf-monitor
esp-idf-size
# gdb extensions dependencies
freertos_gdb

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +0,0 @@
Total sizes:,,,
Used static DRAM,17620 bytes (163116 remain 9.7% used),,,
.data size,9324 bytes,,,
.bss size,8296 bytes,,,
Used static IRAM,38932 bytes (92140 remain 29.7% used),,,
.text size,37908 bytes,,,
.vectors size,1024 bytes,,,
Used Flash size ,186524 bytes,,,
.text,146944 bytes,,,
.rodata,39580 bytes,,,
Total image size,234780 bytes (.bin may be padded larger),,,
1 Total sizes:,,,
2 Used static DRAM,17620 bytes (163116 remain 9.7% used),,,
3 .data size,9324 bytes,,,
4 .bss size,8296 bytes,,,
5 Used static IRAM,38932 bytes (92140 remain 29.7% used),,,
6 .text size,37908 bytes,,,
7 .vectors size,1024 bytes,,,
8 Used Flash size ,186524 bytes,,,
9 .text,146944 bytes,,,
10 .rodata,39580 bytes,,,
11 Total image size,234780 bytes (.bin may be padded larger),,,

View File

@ -1,32 +0,0 @@
{
"dram_data": 9324,
"dram_bss": 8296,
"dram_rodata": 0,
"dram_other": 0,
"used_dram": 17620,
"dram_total": 180736,
"used_dram_ratio": 0.09749026203966006,
"dram_remain": 163116,
"iram_vectors": 1024,
"iram_text": 37908,
"iram_other": 0,
"used_iram": 38932,
"iram_total": 131072,
"used_iram_ratio": 0.297027587890625,
"iram_remain": 92140,
"diram_data": 0,
"diram_bss": 0,
"diram_text": 0,
"diram_vectors": 0,
"diram_rodata": 0,
"diram_other": 0,
"diram_total": 0,
"used_diram": 0,
"used_diram_ratio": 0,
"diram_remain": 0,
"flash_code": 146944,
"flash_rodata": 39580,
"flash_other": 0,
"used_flash_non_ram": 186524,
"total_size": 234780
}

View File

@ -1,11 +0,0 @@
Total sizes:
Used static DRAM: 17620 bytes ( 163116 remain, 9.7% used)
.data size: 9324 bytes
.bss size: 8296 bytes
Used static IRAM: 38932 bytes ( 92140 remain, 29.7% used)
.text size: 37908 bytes
.vectors size: 1024 bytes
Used Flash size : 186524 bytes
.text: 146944 bytes
.rodata: 39580 bytes
Total image size: 234780 bytes (.bin may be padded larger)

View File

@ -1,22 +0,0 @@
#!/usr/bin/env python
#
# SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
#
import json
import os
from sys import stdin
try:
import jsonschema
except ImportError:
raise RuntimeError('You need to install jsonschema package to use validate command')
input_json = ''
for line in stdin:
input_json += line
size_json = json.loads(input_json)
with open(os.path.join(os.path.dirname(__file__), 'size_schema.json'), 'r') as schema_file:
schema_json = json.load(schema_file)
jsonschema.validate(size_json, schema_json)
print(input_json.strip('\n'))

View File

@ -1,52 +0,0 @@
#!/usr/bin/env python
#
# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
#
import argparse
import json
import os
import re
from typing import Dict
IDF_PATH = os.environ['IDF_PATH']
MAX_SIZE_DIFF = 50
def mem_test(size_json: dict, esptool_output: list) -> None:
seg_len = {} # type: Dict[str, int]
for i in esptool_output:
tmp = i.split(' ')
if tmp[0] == 'Segment':
# tmp look like ['Segment', '2:', 'len', '0x02780', 'load', '0x3fc90610', 'file_offs', '0x00007ab0', '[BYTE_ACCESSIBLE,MEM_INTERNAL,DRAM]']
# tmp[3] contains the size of the segment and tmp[8] contains the name of the memory segment
esptool_mem = {'mem_type':tmp[8], 'size':tmp[3]}
seg = re.sub(r'MEM_INTERNAL|,|BYTE_ACCESSIBLE|\n|\[|\]', '', esptool_mem['mem_type'])
# If there are two IRAMs in esptool output it will compute these two IRAM lengths in a seg_len['IRAM']
seg_len[seg] = int(esptool_mem['size'], 16) if seg not in seg_len else seg_len[seg] + int(esptool_mem['size'], 16)
# including flash_other to DROM because flash_other contain .flash.appdesc that includes in DROM that produced by esptool
size_from_map = [('IROM', size_json['flash_code']), ('IRAM', size_json['iram_text'] + size_json['iram_vectors'] + size_json['diram_text']
+ size_json['diram_vectors']), ('DROM', size_json['flash_rodata'] + size_json['flash_other']), ('DRAM', size_json
['dram_data'] + size_json['diram_data'])]
for mem_type, size in size_from_map:
if abs(size - seg_len[mem_type]) > MAX_SIZE_DIFF:
raise RuntimeError(mem_type + " segment in idf_size isn't correct regarding esptool")
print('Test complete without errors')
def main() -> None:
parser = argparse.ArgumentParser(description='mem_test.py - a tool to test accuracy of the sizes of the memory segments regarding idf.py size by esptool')
parser.add_argument(
'size_json', help='JSON file with the output of the idf.py size',
type=argparse.FileType('r'))
parser.add_argument(
'esptool_output', help='File with the output of the esptool',
type=argparse.FileType('r'))
args = parser.parse_args()
mem_test(json.loads(args.size_json.read()), args.esptool_output.read().split('\n'))
if __name__ == '__main__':
main()

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,167 +0,0 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://github.com/espressif/esp-idf/blob/master/tools/size-schema.json",
"type": "object",
"oneOf": [
{
"patternProperties": {
"^dram_(data|bss|rodata|other|remain|total)$": {
"type": "integer"
},
"^used_(dram|iram|diram|flash_non_ram)$": {
"type": "integer"
},
"^used_(dram|iram|diram)_ratio$": {
"type": "number"
},
"^iram_(vectors|text|other|remain|total)$": {
"type": "integer"
},
"^diram_(data|bss|rodata|vectors|text|other|remain|total)$": {
"type": "integer"
},
"^flash_(code|rodata|other)$": {
"type": "integer"
},
"^total_size$": {
"type": "integer"
}
},
"additionalProperties": false,
"required": [
"dram_data",
"dram_bss",
"dram_rodata",
"dram_other",
"used_dram",
"dram_total",
"used_dram_ratio",
"dram_remain",
"iram_vectors",
"iram_text",
"iram_other",
"used_iram",
"iram_total",
"used_iram_ratio",
"iram_remain",
"diram_data",
"diram_bss",
"diram_text",
"diram_vectors",
"diram_rodata",
"diram_other",
"diram_total",
"used_diram",
"used_diram_ratio",
"diram_remain",
"flash_code",
"flash_rodata",
"flash_other",
"used_flash_non_ram",
"total_size"
]
},
{
"patternProperties": {
"(\\.a$|\\.o$|\\.obj$|exe)": {
"$ref": "#/$defs/memory_components"
}
},
"additionalProperties": false
},
{
"patternProperties": {
"(^\\.dram0\\.(bss|data)$)": {
"$ref": "#/$defs/archive_details"
},
"(^\\.flash\\.(rodata|text|appdesc|rodata_noload)$)": {
"$ref": "#/$defs/archive_details"
},
"(^\\.iram0\\.(text|vectors|bss|data)$)": {
"$ref": "#/$defs/archive_details"
},
"(^\\.rtc\\.(bss|data|text)$)": {
"$ref": "#/$defs/archive_details"
},
"(^\\.noinit$)": {
"$ref": "#/$defs/archive_details"
},
"(^\\.rtc_noinit$)": {
"$ref": "#/$defs/archive_details"
}
},
"additionalProperties": false,
"required": [
".dram0.bss",
".dram0.data",
".flash.rodata",
".flash.text",
".iram0.text",
".noinit",
".rtc.bss",
".rtc.data",
".rtc.text",
".rtc_noinit"
]
},
{
"patternProperties": {
"(^diff$|^reference$|^current$)": {
"$ref": "#"
}
},
"additionalProperties": false
}
],
"$defs": {
"memory_components": {
"type": "object",
"properties": {
".dram0.bss": {
"type": "integer"
},
".dram0.data": {
"type": "integer"
},
".flash.rodata": {
"type": "integer"
},
".flash.text": {
"type": "integer"
},
".flash.appdesc": {
"type": "integer"
},
".iram0.text": {
"type": "integer"
},
".iram0.vectors": {
"type": "integer"
},
".rtc.data": {
"type": "integer"
},
".rtc_noinit": {
"type": "integer"
},
"flash_total": {
"type": "integer"
},
"ram_st_total": {
"type": "integer"
}
},
"additionalProperties": false,
"required": [
"flash_total",
"ram_st_total"
]
},
"archive_details": {
"type": "object",
"additionalProperties": {
"type": "integer"
}
}
}
}

View File

@ -1,199 +0,0 @@
#!/usr/bin/env bash
memory_test () {
pushd $IDF_PATH/examples/get-started/hello_world \
&& echo -e "\n***\nBuilding project for $1..." &>> $IDF_PATH/tools/test_idf_size/output \
&& idf.py set-target $1 \
&& idf.py build \
&& echo -e "\n***\nRunning mem_test.py for $1..." &>> $IDF_PATH/tools/test_idf_size/output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --format=json build/hello_world.map > size_output.json \
&& python $IDF_PATH/components/esptool_py/esptool/esptool.py --chip $1 image_info build/hello_world.bin > esptool_output \
&& python -m coverage run -a $IDF_PATH/tools/test_idf_size/mem_test.py size_output.json esptool_output &>> $IDF_PATH/tools/test_idf_size/output \
&& popd
}
json_test() {
echo -e "\n***\nProducing JSON output for $1..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --format=json app_$1.map | python $IDF_PATH/tools/test_idf_size/json_validate_test.py &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --format=json --archives app_$1.map | python $IDF_PATH/tools/test_idf_size/json_validate_test.py &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --format=json --files app_$1.map | python $IDF_PATH/tools/test_idf_size/json_validate_test.py &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --format=json --archive_details libdriver.a app_$1.map | python $IDF_PATH/tools/test_idf_size/json_validate_test.py &>> output
}
csv_test() {
echo -e "\n***\nProducing CSV output for $1..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --format=csv app_$1.map &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --format=csv --archives app_$1.map &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --format=csv --files app_$1.map &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --format=csv --archive_details libdriver.a app_$1.map &>> output
}
{ python -m coverage debug sys \
&& python -m coverage erase &> output \
&& memory_test esp32 \
&& memory_test esp32s2 \
&& memory_test esp32s3 \
&& memory_test esp32c3 \
&& echo -e "\n***\nRunning idf_size.py..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py app.map &>> output \
&& echo -e "\n***\nRunning idf_size.py on bootloader..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py bootloader.map &>> output \
&& echo -e "\n***\nRunning idf_size.py with overflow..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py overflow.map &>> output \
&& echo -e "\n***\nRunning idf_size.py --archives..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --archives app.map &>> output \
&& echo -e "\n***\nRunning idf_size.py --files..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --files app.map &>> output \
&& echo -e "\n***\nRunning idf_size.py --archive_details..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --archive_details libdriver.a app.map &>> output \
&& echo -e "\n***\nRunning idf_size.py diff with bootloader..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py app.map --diff bootloader.map &>> output \
&& echo -e "\n***\nRunning idf_size.py diff with itself..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py app.map --diff app.map &>> output \
&& echo -e "\n***\nRunning idf_size.py diff with another app..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py app.map --diff app2.map &>> output \
&& echo -e "\n***\nRunning idf_size.py diff with app in reverse order..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py app2.map --diff app.map &>> output \
&& echo -e "\n***\nRunning idf_size.py diff --archives with bootloader..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py app.map --archives --diff bootloader.map &>> output \
&& echo -e "\n***\nRunning idf_size.py diff --archives with itself..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py app.map --archives --diff app.map &>> output \
&& echo -e "\n***\nRunning idf_size.py diff --archives with another app..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py app.map --archives --diff app2.map &>> output \
&& echo -e "\n***\nRunning idf_size.py diff --archives with app in reverse order..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py app2.map --archives --diff app.map &>> output \
&& echo -e "\n***\nRunning idf_size.py diff --files with bootloader..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py app.map --files --diff bootloader.map &>> output \
&& echo -e "\n***\nRunning idf_size.py diff --files with itself..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py app.map --files --diff app.map &>> output \
&& echo -e "\n***\nRunning idf_size.py diff --files with another app..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py app.map --files --diff app2.map &>> output \
&& echo -e "\n***\nRunning idf_size.py diff --files with app in reverse order..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py app2.map --files --diff app.map &>> output \
&& echo -e "\n***\nRunning idf_size.py diff --archive_details with bootloader..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py app.map --archive_details libdriver.a --diff bootloader.map &>> output \
&& echo -e "\n***\nRunning idf_size.py diff --archive_details with bootloader..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py app.map --archive_details libc.a --diff bootloader.map &>> output \
&& echo -e "\n***\nRunning idf_size.py diff --archive_details with itself..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py app.map --archive_details libdriver.a --diff app.map &>> output \
&& echo -e "\n***\nRunning idf_size.py diff --archive_details with another app..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py app.map --archive_details libdriver.a --diff app2.map &>> output \
&& echo -e "\n***\nRunning idf_size.py diff --archive_details with app in reverse order..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py app2.map --archive_details libdriver.a --diff app.map &>> output \
&& echo -e "\n***\nRunning idf_size.py diff --archive_details with another app..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py app.map --archive_details libfreertos.a --diff app2.map &>> output \
&& echo -e "\n***\nRunning idf_size.py for esp32s2..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --target esp32s2 app_esp32s2.map &>> output \
&& echo -e "\n***\nRunning idf_size.py for esp32s2 with overflow..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --target esp32s2 overflow_esp32s2.map &>> output \
&& echo -e "\n***\nRunning idf_size.py for esp32s2 (target autodetected)..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py app_esp32s2.map &>> output \
&& echo -e "\n***\nRunning idf_size.py on bootloader for esp32s2..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --target esp32s2 bootloader_esp32s2.map &>> output \
&& echo -e "\n***\nRunning idf_size.py on bootloader for esp32s2 (target autodetected)..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py bootloader_esp32s2.map &>> output \
&& echo -e "\n***\nRunning idf_size.py --archives for esp32s2..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --target esp32s2 --archives app_esp32s2.map &>> output \
&& echo -e "\n***\nRunning idf_size.py --files for esp32s2..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --target esp32s2 --files app_esp32s2.map &>> output \
&& echo -e "\n***\nRunning idf_size.py --archive_details for esp32s2..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --target esp32s2 --archive_details libdriver.a app_esp32s2.map &>> output \
&& echo -e "\n***\nRunning idf_size.py diff with another app (different target)..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py app.map --diff app_esp32s2.map &>> output \
&& echo -e "\n***\nRunning idf_size.py for esp32h4..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --target esp32h4 app_esp32h4.map &>> output \
&& echo -e "\n***\nRunning idf_size.py for esp32h4 (target autodetected)..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py app_esp32h4.map &>> output \
&& echo -e "\n***\nRunning idf_size.py --archives for esp32h4..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --target esp32h4 --archives app_esp32h4.map &>> output \
&& echo -e "\n***\nRunning idf_size.py --files for esp32h4..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --target esp32h4 --files app_esp32h4.map &>> output \
&& echo -e "\n***\nRunning idf_size.py --archive_details for esp32h4..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --target esp32h4 --archive_details libdriver.a app_esp32h4.map &>> output \
&& echo -e "\n***\nRunning idf_size.py for esp32c3..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --target esp32c3 app_esp32c3.map &>> output \
&& echo -e "\n***\nRunning idf_size.py for esp32c3 with overflow..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --target esp32c3 overflow_esp32c3.map &>> output \
&& echo -e "\n***\nRunning idf_size.py for esp32c3 (target autodetected)..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py app_esp32c3.map &>> output \
&& echo -e "\n***\nRunning idf_size.py --archives for esp32c3..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --target esp32c3 --archives app_esp32c3.map &>> output \
&& echo -e "\n***\nRunning idf_size.py --files for esp32c3..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --target esp32c3 --files app_esp32c3.map &>> output \
&& echo -e "\n***\nRunning idf_size.py --archive_details for esp32c3..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --target esp32c3 --archive_details libdriver.a app_esp32c3.map &>> output \
&& echo -e "\n***\nRunning idf_size.py for esp32s3..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --target esp32s3 app_esp32s3.map &>> output \
&& echo -e "\n***\nRunning idf_size.py for esp32s3 configured with 32KB of icache..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --target esp32s3 app_esp32s3_32k_icache.map &>> output \
&& echo -e "\n***\nRunning idf_size.py for esp32s3 with overflow..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --target esp32s3 overflow_esp32s3.map &>> output \
&& echo -e "\n***\nRunning idf_size.py for esp32s3 (target autodetected)..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py app_esp32s3.map &>> output \
&& echo -e "\n***\nRunning idf_size.py --archives for esp32s3..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --target esp32s3 --archives app_esp32s3.map &>> output \
&& echo -e "\n***\nRunning idf_size.py --files for esp32s3..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --target esp32s3 --files app_esp32s3.map &>> output \
&& echo -e "\n***\nRunning idf_size.py --archive_details for esp32s3..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --target esp32s3 --archive_details libdriver.a app_esp32s3.map &>> output \
&& echo -e "\n***\nRunning idf_size.py for esp32c6..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --target esp32c6 app_esp32c6.map &>> output \
&& echo -e "\n***\nRunning idf_size.py for esp32c6 with overflow..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --target esp32c6 overflow_esp32c6.map &>> output \
&& echo -e "\n***\nRunning idf_size.py for esp32c6 (target autodetected)..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py app_esp32c6.map &>> output \
&& echo -e "\n***\nRunning idf_size.py --archives for esp32c6..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --target esp32c6 --archives app_esp32c6.map &>> output \
&& echo -e "\n***\nRunning idf_size.py --files for esp32c6..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --target esp32c6 --files app_esp32c6.map &>> output \
&& echo -e "\n***\nRunning idf_size.py --archive_details for esp32c6..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --target esp32c6 --archive_details libdriver.a app_esp32c6.map &>> output \
&& echo -e "\n***\nProducing JSON output..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --format=json app.map | python $IDF_PATH/tools/test_idf_size/json_validate_test.py &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --format=json --archives app.map | python $IDF_PATH/tools/test_idf_size/json_validate_test.py &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --format=json --files app.map | python $IDF_PATH/tools/test_idf_size/json_validate_test.py &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --format=json --archive_details libdriver.a app.map | python $IDF_PATH/tools/test_idf_size/json_validate_test.py &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --format=json app.map --diff app2.map | python $IDF_PATH/tools/test_idf_size/json_validate_test.py &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --format=json --archives app.map --diff app2.map | python $IDF_PATH/tools/test_idf_size/json_validate_test.py &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --format=json --files app.map --diff app2.map | python $IDF_PATH/tools/test_idf_size/json_validate_test.py &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --format=json --archive_details libdriver.a app.map --diff app2.map | python $IDF_PATH/tools/test_idf_size/json_validate_test.py &>> output \
&& json_test esp32s2 \
&& json_test esp32c3 \
&& json_test esp32h4 \
&& json_test esp32s3 \
&& json_test esp32c6 \
&& echo -e "\n***\nProducing CSV output..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --format=csv app.map &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --format=csv --archives app.map &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --format=csv --files app.map &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --format=csv --archive_details libdriver.a app.map &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --format=csv app.map --diff app2.map &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --format=csv --archives app.map --diff app2.map &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --format=csv --files app.map --diff app2.map &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --format=csv --archive_details libdriver.a app.map --diff app2.map &>> output \
&& csv_test esp32s2 \
&& csv_test esp32c3 \
&& csv_test esp32h4 \
&& csv_test esp32s3 \
&& csv_test esp32c6 \
&& echo -e "\n***\nProducing JSON file output..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --format=json --output-file output.json app.map &>> output \
&& echo -e "\n***\nProducing text file output..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py -o output.txt app.map &>> output \
&& echo -e "\n***\nProducing csv file output..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --format=csv --output-file output.csv app.map &>> output \
&& echo -e "\n***\nRunning idf_size_tests.py..." &>> output \
&& python -m coverage run -a $IDF_PATH/tools/test_idf_size/test_idf_size.py &>> output \
&& echo -e "\n\nComparing expected output..." \
&& diff -Z output expected_output \
&& echo -e "\n\nComparing expected json output..." \
&& diff -Z output.json expected_output.json \
&& echo -e "\n\nComparing expected text output..." \
&& diff -Z output.txt expected_output.txt \
&& echo -e "\n\nComparing expected csv output..." \
&& diff -Z output.csv expected_output.csv \
&& python -m coverage report \
; } || { echo 'The test for idf_size has failed. Please examine the artifacts.' ; exit 1; }
# Note: "diff -Z is used because some versions of Python print trailing whitespace for JSON pretty-printing, and some don't

View File

@ -1,36 +0,0 @@
#!/usr/bin/env python
#
# SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
from __future__ import print_function
import sys
from typing import Dict
try:
import idf_size
except ImportError:
sys.path.append('..')
import idf_size
if __name__ == '__main__':
# Should deliver a RuntimeError as the 'test' header doesn't exist
try:
idf_size.scan_to_header([], 'test')
except RuntimeError as e:
assert "Didn't find line" in str(e)
# Should deliver a RuntimeError as there's no content under the heading
try:
idf_size.load_segments(['Memory Configuration'])
pass
except RuntimeError as e:
assert 'End of file' in str(e)
segments = {'iram0_0_seg': {'origin': 0, 'length': 0},
'dram0_0_seg': {'origin': 0, 'length': 0}}
sections = {} # type: Dict
print(idf_size.get_summary('a.map', segments, sections, 'esp32'), end='')