Tools: Fix memory calculations of idf_size.py

This commit is contained in:
simon.chupin 2021-07-28 00:24:05 +02:00
parent 48b98214ae
commit 294f9783fc
13 changed files with 64094 additions and 14968 deletions

View File

@ -46,7 +46,7 @@ MEMORY
#if CONFIG_APP_BUILD_USE_FLASH_SECTIONS
/* Flash mapped instruction data */
iram0_2_seg (RX) : org = 0x42000020, len = 0x8000000-0x20
iram0_2_seg (RX) : org = 0x42000020, len = 0x800000-0x20
/**
* (0x20 offset above is a convenience for the app binary image generation.
@ -65,7 +65,7 @@ MEMORY
#if CONFIG_APP_BUILD_USE_FLASH_SECTIONS
/* Flash mapped constant data */
drom0_0_seg (R) : org = 0x3C000020, len = 0x8000000-0x20
drom0_0_seg (R) : org = 0x3C000020, len = 0x800000-0x20
/* (See iram0_2_seg for meaning of 0x20 offset in the above.) */
#endif // CONFIG_APP_BUILD_USE_FLASH_SECTIONS

View File

@ -70,11 +70,7 @@ MEMORY
#if CONFIG_APP_BUILD_USE_FLASH_SECTIONS
/* Flash mapped instruction data */
<<<<<<< HEAD:components/esp_system/ld/esp32s3/memory.ld.in
iram0_2_seg (RX) : org = 0x42000020, len = 0x2000000-0x20
=======
iram0_2_seg (RX) : org = 0x42000020, len = 0x800000-0x20
>>>>>>> ld: fix linker script for C3 and S3:components/esp32s3/ld/esp32s3.ld
/**
* (0x20 offset above is a convenience for the app binary image generation.
@ -93,11 +89,7 @@ MEMORY
#if CONFIG_APP_BUILD_USE_FLASH_SECTIONS
/* Flash mapped constant data */
<<<<<<< HEAD:components/esp_system/ld/esp32s3/memory.ld.in
drom0_0_seg (R) : org = 0x3C000020, len = 0x2000000-0x20
=======
drom0_0_seg (R) : org = 0x3C000020, len = 0x800000-0x20
>>>>>>> ld: fix linker script for C3 and S3:components/esp32s3/ld/esp32s3.ld
/* (See iram0_2_seg for meaning of 0x20 offset in the above.) */
#endif // CONFIG_APP_BUILD_USE_FLASH_SECTIONS

View File

@ -27,4 +27,3 @@ PROVIDE ( GPSPI4 = 0x60037000 );
PROVIDE ( APB_SARADC = 0x60040000 );
PROVIDE ( USB_SERIAL_JTAG = 0x60043000 );
PROVIDE ( GDMA = 0x6003F000 );
PROVIDE ( IEEE802154 = 0x60047000 );

View File

@ -1,7 +1,6 @@
components/app_update/otatool.py
components/efuse/efuse_table_gen.py
components/efuse/test_efuse_host/efuse_tests.py
components/esp32s2/test/gen_digital_signature_tests.py
components/esp_local_ctrl/python/esp_local_ctrl_pb2.py
components/esp_netif/test_apps/component_ut_test.py
components/espcoredump/corefile/gdb.py
@ -141,20 +140,12 @@ examples/system/ota/otatool/otatool_example.py
examples/system/ota/simple_ota_example/example_test.py
examples/system/perfmon/example_test.py
examples/system/select/example_test.py
<<<<<<< HEAD
examples/system/startup_time/example_test.py
examples/system/sysview_tracing/example_test.py
examples/system/sysview_tracing_heap_log/example_test.py
examples/system/task_watchdog/example_test.py
examples/system/ulp_fsm/ulp/example_test.py
examples/system/ulp_fsm/ulp_adc/example_test.py
=======
examples/system/sysview_tracing/example_test.py
examples/system/sysview_tracing_heap_log/example_test.py
examples/system/task_watchdog/example_test.py
examples/system/ulp/example_test.py
examples/system/ulp_adc/example_test.py
>>>>>>> idf_size.py: fixed diram counted twice issue, and improve display
examples/system/unit_test/example_test.py
examples/wifi/iperf/iperf_test.py
tools/ble/lib_ble_client.py
@ -199,10 +190,6 @@ tools/ci/python_packages/tiny_test_fw/Utility/TestCase.py
tools/ci/python_packages/tiny_test_fw/bin/Runner.py
tools/ci/python_packages/tiny_test_fw/bin/example.py
tools/ci/python_packages/tiny_test_fw/docs/conf.py
<<<<<<< HEAD
=======
tools/ci/python_packages/ttfw_idf/CIScanTests.py
>>>>>>> idf_size.py: fixed diram counted twice issue, and improve display
tools/ci/python_packages/ttfw_idf/DebugUtils.py
tools/ci/python_packages/ttfw_idf/IDFAssignTest.py
tools/ci/python_packages/ttfw_idf/IDFDUT.py
@ -234,8 +221,6 @@ tools/find_build_apps/common.py
tools/find_build_apps/make.py
tools/gen_esp_err_to_name.py
tools/idf.py
tools/idf_monitor.py
tools/idf_py_actions/constants.py
tools/idf_py_actions/core_ext.py
tools/idf_py_actions/create_ext.py
tools/idf_py_actions/debug_ext.py
@ -245,7 +230,6 @@ tools/idf_py_actions/global_options.py
tools/idf_py_actions/serial_ext.py
tools/idf_py_actions/tools.py
tools/idf_py_actions/uf2_ext.py
tools/idf_size.py
tools/kconfig_new/confgen.py
tools/kconfig_new/confserver.py
tools/kconfig_new/esp-windows-curses/setup.py
@ -286,7 +270,6 @@ tools/test_idf_py/extra_path/some_ext.py
tools/test_idf_py/idf_ext.py
tools/test_idf_py/test_idf_extensions/test_ext/test_extension.py
tools/test_idf_py/test_idf_py.py
tools/test_idf_size/test_idf_size.py
tools/test_idf_tools/test_idf_tools.py
tools/test_mkdfu/test_mkdfu.py
tools/test_mkuf2/test_mkuf2.py

View File

@ -113,7 +113,7 @@ class MemRegions(object):
MemRegDef(0x3ff80000, 0x2000, MemRegions.RTC_FAST_D_ID, 0x600FE000),
MemRegDef(0x50000000, 0x2000, MemRegions.RTC_SLOW_D_ID, 0),
])
elif target == 'esp32c3':
elif target in ['esp32c3', 'esp32h2']:
return sorted([
MemRegDef(0x3FC80000, 0x60000, MemRegions.DRAM_ID, 0x40380000),
MemRegDef(0x4037C000, 0x4000, MemRegions.IRAM_ID, 0),
@ -121,17 +121,6 @@ class MemRegions(object):
MemRegDef(0x3C000000, 0x800000, MemRegions.CACHE_D_ID, 0),
MemRegDef(0x50000000, 0x2000, MemRegions.RTC_SLOW_D_ID, 0),
])
elif target == 'esp32h2':
return sorted([
MemRegDef(0x3FC80000, 0x60000, MemRegions.DIRAM_ID, 0x40380000),
# MemRegDef(0x3FC80000, 0x20000, MemRegions.DIRAM_ID, 0x40380000),
# MemRegDef(0x3FCA0000, 0x20000, MemRegions.DIRAM_ID, 0x403A0000),
# MemRegDef(0x3FCC0000, 0x20000, MemRegions.DIRAM_ID, 0x403C0000),
# Used by cache
MemRegDef(0x4037C000, 0x4000, MemRegions.IRAM_ID, 0),
])
else:
raise RuntimeError('Target not detected.')
@ -148,7 +137,6 @@ class MemRegions(object):
if (region.secondary_addr and region.secondary_addr <= start < region.secondary_addr + region.length):
return (region, min(length, region.secondary_addr + region.length - start))
raise RuntimeError('Given section not found in any memory region. '
'Check whether the LD file is compatible with the definitions in get_mem_regions in idf_size.py')
@ -237,9 +225,9 @@ class LinkingSections(object):
display_name_list = ordered_name_list.copy()
memory_name = ''
for i in range(len(section_name_list)):
section = ordered_name_list[i]
display_name_list = sorted(display_name_list)
ordered_name_list = sorted(ordered_name_list)
for i, section in enumerate(ordered_name_list):
if memory_name and section.startswith(memory_name):
# If the section has same memory type with the previous one, use shorter name
display_name_list[i] = section.replace(memory_name, '& ')
@ -250,9 +238,12 @@ class LinkingSections(object):
if len(split_name) > 1:
# If the section has a memory type, update the type and try to display the type properly
assert len(split_name) == 3 and split_name[0] == '', 'Unexpected section name'
memory_name = '.' + split_name[1]
memory_name = '.iram' if 'iram' in split_name[1] else\
'.dram' if 'dram' in split_name[1] else\
'.flash' if 'flash' in split_name[1] else\
'.' + split_name[1]
display_name_list[i] = 'DRAM .' + split_name[2] if 'dram' in split_name[1] else\
'IRAM .' + split_name[2] if 'iram' in split_name[1] else\
'IRAM' + split_name[1].replace('iram', '') + ' .' + split_name[2] if 'iram' in split_name[1] else\
'Flash .' + split_name[2] if 'flash' in split_name[1] else\
section
continue
@ -616,9 +607,10 @@ class StructureForSummary(object):
dram_filter = filter(in_dram, segments)
r.dram_total = get_size(dram_filter)
iram_filter = filter(in_iram, segments)
r.iram_total = get_size(iram_filter)
if r.diram_total == 0:
r.diram_total = r.dram_total + r.iram_total
def filter_in_section(sections, section_to_check): # type: (Iterable[MemRegions.Region], str) -> List[MemRegions.Region]
return list(filter(lambda x: LinkingSections.in_section(x.section, section_to_check), sections)) # type: ignore
@ -626,6 +618,8 @@ class StructureForSummary(object):
dram_sections = list(filter(in_dram, sections))
iram_sections = list(filter(in_iram, sections))
diram_sections = list(filter(in_diram, sections))
if not diram_sections:
diram_sections = dram_sections + iram_sections
flash_sections = filter_in_section(sections, 'flash')
dram_data_list = filter_in_section(dram_sections, 'data')
@ -690,7 +684,6 @@ class StructureForSummary(object):
# The used DRAM BSS is counted into the "Used static DRAM" but not into the "Total image size"
r.total_size = r.used_dram - r.used_dram_bss + r.used_iram + r.used_diram - r.used_diram_bss + r.used_flash
return r
def get_json_dic(self): # type: (StructureForSummary) -> collections.OrderedDict
@ -878,6 +871,23 @@ def get_summary(path, segments, sections, target,
return output
def check_is_dict_sort(non_sort_list): # type: (List) -> List
# keeping the order data, bss, other, iram, diram, ram_st_total, flash_text, flash_rodata, flash_total
start_of_other = 0
props_sort = [] # type: List
props_elem = ['data', 'bss', 'other', 'iram', 'diram', 'ram_st_total', 'flash_text', 'flash_rodata', 'flash_total']
for i in props_elem:
for j in non_sort_list:
if i == 'other':
start_of_other = len(props_sort)
elif i in j[0]:
props_sort.append(j)
for j in non_sort_list:
if j not in props_sort:
props_sort.insert(start_of_other, j)
return props_sort
class StructureForDetailedSizes(object):
@staticmethod
@ -916,12 +926,14 @@ class StructureForDetailedSizes(object):
section_dict['ram_st_total'] = ram_st_total
section_dict['flash_total'] = flash_total
# TODO: keep the order data, bss, other, iram, diram, ram_st_total, flash_text, flash_rodata, flash_total
s.append((key, collections.OrderedDict(section_dict)))
sorted_dict = sorted(section_dict.items(), key=lambda elem: elem[0])
sorted_dict = check_is_dict_sort(sorted_dict)
s.append((key, collections.OrderedDict(sorted_dict)))
s = sorted(s, key=lambda elem: elem[0])
# do a secondary sort in order to have consistent order (for diff-ing the output)
s = sorted(s, key=lambda elem: elem[1]['flash_total'], reverse=True)
# s = sorted(s, key=lambda elem: elem[1]['flash_total'], reverse=True)
return collections.OrderedDict(s)

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

View File

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

View File

@ -1,8 +1,16 @@
Total sizes:
DRAM .data size: 9324 bytes
DRAM .bss size: 8296 bytes
Used static DRAM: 17620 bytes ( 163116 available, 9.7% used)
Used static IRAM: 38932 bytes ( 92140 available, 29.7% used)
Flash code: 146944 bytes
Flash rodata: 39580 bytes
Total image size:~ 234780 bytes (.bin may be padded larger)
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 stat D/IRAM: 56552 bytes ( 255256 remain, 18.1% used)
.data size: 9324 bytes
.bss size: 8296 bytes
.text size: 37908 bytes
.vectors size: 1024 bytes
Used Flash size : 186524 bytes
.text : 146944 bytes
.rodata : 39580 bytes
Total image size: 283036 bytes (.bin may be padded larger)

View File

@ -64,6 +64,36 @@
&& 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 \
&& coverage run -a $IDF_PATH/tools/idf_size.py app.map --diff app_esp32s2.map &>> output \
&& echo -e "\n***\nRunning idf_size.py for esp32h2..." &>> output \
&& coverage run -a $IDF_PATH/tools/idf_size.py --target esp32h2 app_esp32h2.map &>> output \
&& echo -e "\n***\nRunning idf_size.py for esp32h2 (target autodetected)..." &>> output \
&& coverage run -a $IDF_PATH/tools/idf_size.py app_esp32h2.map &>> output \
&& echo -e "\n***\nRunning idf_size.py --archives for esp32h2..." &>> output \
&& coverage run -a $IDF_PATH/tools/idf_size.py --target esp32h2 --archives app_esp32h2.map &>> output \
&& echo -e "\n***\nRunning idf_size.py --files for esp32h2..." &>> output \
&& coverage run -a $IDF_PATH/tools/idf_size.py --target esp32h2 --files app_esp32h2.map &>> output \
&& echo -e "\n***\nRunning idf_size.py --archive_details for esp32h2..." &>> output \
&& coverage run -a $IDF_PATH/tools/idf_size.py --target esp32h2 --archive_details libdriver.a app_esp32h2.map &>> output \
&& echo -e "\n***\nRunning idf_size.py for esp32c3..." &>> output \
&& coverage run -a $IDF_PATH/tools/idf_size.py --target esp32c3 app_esp32c3.map &>> output \
&& echo -e "\n***\nRunning idf_size.py for esp32c3 (target autodetected)..." &>> output \
&& coverage run -a $IDF_PATH/tools/idf_size.py app_esp32c3.map &>> output \
&& echo -e "\n***\nRunning idf_size.py --archives for esp32c3..." &>> output \
&& 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 \
&& 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 \
&& 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 \
&& coverage run -a $IDF_PATH/tools/idf_size.py --target esp32s3 app_esp32s3.map &>> output \
&& echo -e "\n***\nRunning idf_size.py for esp32s3 (target autodetected)..." &>> output \
&& coverage run -a $IDF_PATH/tools/idf_size.py app_esp32s3.map &>> output \
&& echo -e "\n***\nRunning idf_size.py --archives for esp32s3..." &>> output \
&& 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 \
&& 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 \
&& coverage run -a $IDF_PATH/tools/idf_size.py --target esp32s3 --archive_details libdriver.a app_esp32s3.map &>> output \
&& echo -e "\n***\nProducing JSON output..." &>> output \
&& coverage run -a $IDF_PATH/tools/idf_size.py --json app.map &>> output \
&& coverage run -a $IDF_PATH/tools/idf_size.py --json --archives app.map &>> output \

View File

@ -17,6 +17,7 @@
from __future__ import print_function
import sys
from typing import Dict
try:
import idf_size
@ -41,6 +42,6 @@ if __name__ == '__main__':
segments = {'iram0_0_seg': {'origin': 0, 'length': 0},
'dram0_0_seg': {'origin': 0, 'length': 0}}
sections = {}
sections = {} # type: Dict
print(idf_size.get_summary('a.map', segments, sections, 'esp32'), end='')