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

Fix expected output
This commit is contained in:
Djordje Nedic 2022-12-16 18:57:20 +01:00
parent dfa9a81233
commit 1c35538b96
4 changed files with 26314 additions and 387 deletions

View File

@ -571,13 +571,17 @@ class StructureForSummary(object):
r = StructureForSummary() r = StructureForSummary()
diram_filter = filter(in_diram, segments) diram_filter = filter(in_diram, segments)
r.diram_total = int(get_size(diram_filter) / 2) r.diram_total = get_size(diram_filter)
dram_filter = filter(in_dram, segments) dram_filter = filter(in_dram, segments)
r.dram_total = get_size(dram_filter) r.dram_total = get_size(dram_filter)
iram_filter = filter(in_iram, segments) iram_filter = filter(in_iram, segments)
r.iram_total = get_size(iram_filter) r.iram_total = get_size(iram_filter)
# This fixes counting the diram twice if the cache fills the iram entirely
if r.iram_total == 0:
r.diram_total //= 2
def filter_in_section(sections: Iterable[MemRegions.Region], section_to_check: str) -> List[MemRegions.Region]: def filter_in_section(sections: Iterable[MemRegions.Region], section_to_check: str) -> List[MemRegions.Region]:
return list(filter(lambda x: LinkingSections.in_section(x.section, section_to_check), sections)) # type: ignore return list(filter(lambda x: LinkingSections.in_section(x.section, section_to_check), sections)) # type: ignore

File diff suppressed because one or more lines are too long

View File

@ -4421,7 +4421,7 @@ Total sizes:
Used static IRAM: 46786 bytes ( 239934 remain, 16.3% used) Used static IRAM: 46786 bytes ( 239934 remain, 16.3% used)
.text size: 45759 bytes .text size: 45759 bytes
.vectors size: 1027 bytes .vectors size: 1027 bytes
Used stat D/IRAM: 11772 bytes ( 123396 remain, 8.7% used) Used stat D/IRAM: 11772 bytes ( 258564 remain, 4.4% used)
.data size: 9252 bytes .data size: 9252 bytes
.bss size: 2520 bytes .bss size: 2520 bytes
Used Flash size : 114851 bytes Used Flash size : 114851 bytes
@ -4429,13 +4429,26 @@ Used Flash size : 114851 bytes
.rodata : 27132 bytes .rodata : 27132 bytes
Total image size: 170889 bytes (.bin may be padded larger) Total image size: 170889 bytes (.bin may be padded larger)
***
Running idf_size.py for esp32s3 configured with 32KB of icache...
Total sizes:
Used stat D/IRAM: 66970 bytes ( 278886 remain, 19.4% used)
.data size: 10912 bytes
.bss size: 2584 bytes
.text size: 52447 bytes
.vectors size: 1027 bytes
Used Flash size : 136043 bytes
.text : 102383 bytes
.rodata : 33404 bytes
Total image size: 200429 bytes (.bin may be padded larger)
*** ***
Running idf_size.py for esp32s3 with overflow... Running idf_size.py for esp32s3 with overflow...
Total sizes: Total sizes:
Used static IRAM: 337906 bytes ( -51186 remain, 117.9% used) Overflow detected! You can run idf.py size-files for more information. Used static IRAM: 337906 bytes ( -51186 remain, 117.9% used) Overflow detected! You can run idf.py size-files for more information.
.text size: 336879 bytes .text size: 336879 bytes
.vectors size: 1027 bytes .vectors size: 1027 bytes
Used stat D/IRAM: 94049 bytes ( 41119 remain, 69.6% used) Used stat D/IRAM: 94049 bytes ( 176287 remain, 34.8% used)
.data size: 68929 bytes .data size: 68929 bytes
.bss size: 25120 bytes .bss size: 25120 bytes
Used Flash size : 461714 bytes Used Flash size : 461714 bytes
@ -4449,7 +4462,7 @@ Total sizes:
Used static IRAM: 46786 bytes ( 239934 remain, 16.3% used) Used static IRAM: 46786 bytes ( 239934 remain, 16.3% used)
.text size: 45759 bytes .text size: 45759 bytes
.vectors size: 1027 bytes .vectors size: 1027 bytes
Used stat D/IRAM: 11772 bytes ( 123396 remain, 8.7% used) Used stat D/IRAM: 11772 bytes ( 258564 remain, 4.4% used)
.data size: 9252 bytes .data size: 9252 bytes
.bss size: 2520 bytes .bss size: 2520 bytes
Used Flash size : 114851 bytes Used Flash size : 114851 bytes
@ -4463,7 +4476,7 @@ Total sizes:
Used static IRAM: 46786 bytes ( 239934 remain, 16.3% used) Used static IRAM: 46786 bytes ( 239934 remain, 16.3% used)
.text size: 45759 bytes .text size: 45759 bytes
.vectors size: 1027 bytes .vectors size: 1027 bytes
Used stat D/IRAM: 11772 bytes ( 123396 remain, 8.7% used) Used stat D/IRAM: 11772 bytes ( 258564 remain, 4.4% used)
.data size: 9252 bytes .data size: 9252 bytes
.bss size: 2520 bytes .bss size: 2520 bytes
Used Flash size : 114851 bytes Used Flash size : 114851 bytes
@ -4507,7 +4520,7 @@ Total sizes:
Used static IRAM: 46786 bytes ( 239934 remain, 16.3% used) Used static IRAM: 46786 bytes ( 239934 remain, 16.3% used)
.text size: 45759 bytes .text size: 45759 bytes
.vectors size: 1027 bytes .vectors size: 1027 bytes
Used stat D/IRAM: 11772 bytes ( 123396 remain, 8.7% used) Used stat D/IRAM: 11772 bytes ( 258564 remain, 4.4% used)
.data size: 9252 bytes .data size: 9252 bytes
.bss size: 2520 bytes .bss size: 2520 bytes
Used Flash size : 114851 bytes Used Flash size : 114851 bytes
@ -4773,7 +4786,7 @@ Total sizes:
Used static IRAM: 46786 bytes ( 239934 remain, 16.3% used) Used static IRAM: 46786 bytes ( 239934 remain, 16.3% used)
.text size: 45759 bytes .text size: 45759 bytes
.vectors size: 1027 bytes .vectors size: 1027 bytes
Used stat D/IRAM: 11772 bytes ( 123396 remain, 8.7% used) Used stat D/IRAM: 11772 bytes ( 258564 remain, 4.4% used)
.data size: 9252 bytes .data size: 9252 bytes
.bss size: 2520 bytes .bss size: 2520 bytes
Used Flash size : 114851 bytes Used Flash size : 114851 bytes
@ -16560,10 +16573,10 @@ Producing JSON output for esp32s3...
"diram_vectors": 0, "diram_vectors": 0,
"diram_rodata": 0, "diram_rodata": 0,
"diram_other": 0, "diram_other": 0,
"diram_total": 135168, "diram_total": 270336,
"used_diram": 11772, "used_diram": 11772,
"used_diram_ratio": 0.08709161931818182, "used_diram_ratio": 0.04354580965909091,
"diram_remain": 123396, "diram_remain": 258564,
"flash_code": 87463, "flash_code": 87463,
"flash_rodata": 27132, "flash_rodata": 27132,
"flash_other": 256, "flash_other": 256,

View File

@ -117,6 +117,8 @@ json_test() {
&& python -m coverage run -a $IDF_PATH/tools/idf_size.py --target esp32c3 --archive_details libdriver.a app_esp32c3.map &>> 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 \ && 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 \ && 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 \ && 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 \ && 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 \ && echo -e "\n***\nRunning idf_size.py for esp32s3 (target autodetected)..." &>> output \