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
This commit is contained in:
Michael (XIAO Xufeng) 2020-10-30 13:31:24 +08:00 committed by simon.chupin
parent f80c0e8d31
commit 7716134457
8 changed files with 1004 additions and 489 deletions

View File

@ -16,15 +16,34 @@
#define ESP_BOOTLOADER_RESERVE_RTC 0
#endif
/*
* 40370000 <- IRAM/Icache -> 40378000 <- D/IRAM (I) -> 403E0000
* 3FC88000 <- D/IRAM (D) -> 3FCF0000 <- DRAM/DCache -> 3FD00000
*
* Startup code uses the IRAM from 0x403BA000 to 0x403E0000, which is not available for static
* memory, but can only be used after app starts.
*
* D cache use the memory from high address, so when it's configured to 16K/32K, the region
* 0x3FCF000 ~ (3FD00000 - DATA_CACHE_SIZE) should be available. This region is not used as
* static memory, leaving to the heap.
*/
#define SRAM_IRAM_START 0x40370000
#define SRAM_DRAM_START 0x3FC80000
#define I_D_SRAM_OFFSET (SRAM_IRAM_START - SRAM_DRAM_START)
#define SRAM_DRAM_END 0x403BA000 - I_D_SRAM_OFFSET /* 2nd stage bootloader iram_loader_seg start address */
#define SRAM_DIRAM_I_START 0x40378000
#define SRAM_IRAM_END 0x403BA000
#define I_D_SRAM_OFFSET (SRAM_DIRAM_I_START - SRAM_DRAM_START)
#define SRAM_DRAM_START 0x3FC88000
#define SRAM_DRAM_END (SRAM_IRAM_END - I_D_SRAM_OFFSET) /* 2nd stage bootloader iram_loader_seg start address */
#define I_D_SRAM_SIZE (SRAM_DRAM_END - SRAM_DRAM_START)
#define ICACHE_SIZE 0x8000
#define SRAM_IRAM_ORG (SRAM_IRAM_START + CONFIG_ESP32S3_INSTRUCTION_CACHE_SIZE)
#define SRAM_DRAM_ORG (SRAM_DRAM_START + CONFIG_ESP32S3_INSTRUCTION_CACHE_SIZE)
#define SRAM_IRAM_SIZE (I_D_SRAM_SIZE + ICACHE_SIZE - CONFIG_ESP32S3_INSTRUCTION_CACHE_SIZE)
#define I_D_SRAM_SIZE SRAM_DRAM_END - SRAM_DRAM_ORG
#define DCACHE_SIZE 0x10000
#define SRAM_DRAM_ORG (SRAM_DRAM_START)
#if CONFIG_ESP32S3_USE_FIXED_STATIC_RAM_SIZE
ASSERT((CONFIG_ESP32S3_FIXED_STATIC_RAM_SIZE <= I_D_SRAM_SIZE), "Fixed static ram data does not fit.")
@ -42,12 +61,12 @@ MEMORY
*/
/* IRAM for PRO CPU. */
iram0_0_seg (RX) : org = SRAM_IRAM_ORG, len = I_D_SRAM_SIZE
iram0_0_seg (RX) : org = SRAM_IRAM_ORG, len = SRAM_IRAM_SIZE
#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.
* Flash cache has 64KB pages. The .bin file which is flashed to the chip
@ -65,7 +84,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

@ -1,6 +1,8 @@
/* Default entry point */
ENTRY(call_start_cpu0);
_diram_i_start = 0x40378000;
SECTIONS
{
/**
@ -183,7 +185,7 @@ SECTIONS
*/
.dram0.dummy (NOLOAD):
{
. = ORIGIN(dram0_0_seg) + _iram_end - _iram_start;
. = ORIGIN(dram0_0_seg) + MAX(_iram_end - _diram_i_start, 0);
} > dram0_0_seg
.dram0.data :

View File

@ -69,7 +69,9 @@ const soc_memory_region_t soc_memory_regions[] = {
{ 0x3FCC0000, 0x10000, 2, 0x403B0000}, //Level 6, IDRAM, can be used as trace memroy
{ 0x3FCD0000, 0x10000, 2, 0x403C0000}, //Level 7, IDRAM, can be used as trace memroy
{ 0x3FCE0000, 0x10000, 1, 0}, //Level 8, IDRAM, can be used as trace memroy, contains stacks used by startup flow, recycled by heap allocator in app_main task
#if CONFIG_ESP32S3_DATA_CACHE_32KB
#if CONFIG_ESP32S3_DATA_CACHE_16KB
{ 0x3FCF0000, 0xC000, 0, 0}, //Level 9, DRAM
#elif CONFIG_ESP32S3_DATA_CACHE_32KB
{ 0x3FCF0000, 0x8000, 0, 0}, //Level 9, DRAM
#endif
};
@ -93,11 +95,11 @@ SOC_RESERVE_MEMORY_REGION((intptr_t)&_data_start, (intptr_t)&_heap_start, dram_d
// ESP32S3 has a big D/IRAM region, the part used by code is reserved
// The address of the D/I bus are in the same order, directly shift IRAM address to get reserved DRAM address
#define I_D_OFFSET (SOC_DIRAM_IRAM_LOW - SOC_DIRAM_DRAM_LOW)
#if CONFIG_ESP32S3_INSTRUCTION_CACHE_16KB
SOC_RESERVE_MEMORY_REGION((intptr_t)&_iram_start, (intptr_t)&_iram_start + 0x4000, iram_code_1);
SOC_RESERVE_MEMORY_REGION((intptr_t)&_iram_start + 0x4000 - I_D_OFFSET, (intptr_t)&_iram_end - I_D_OFFSET, iram_code_2);
#else
// .text region in diram. DRAM used by text (shared with IBUS).
SOC_RESERVE_MEMORY_REGION((intptr_t)&_iram_start - I_D_OFFSET, (intptr_t)&_iram_end - I_D_OFFSET, iram_code);
#if CONFIG_ESP32S3_INSTRUCTION_CACHE_16KB
SOC_RESERVE_MEMORY_REGION((intptr_t)&_iram_start, (intptr_t)&_iram_end, iram_code_2);
#endif
#ifdef CONFIG_SPIRAM

View File

@ -0,0 +1,288 @@
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
components/espcoredump/test/test_espcoredump.py
components/lwip/weekend_test/net_suite_test.py
components/mbedtls/esp_crt_bundle/gen_crt_bundle.py
components/mbedtls/esp_crt_bundle/test_gen_crt_bundle/test_gen_crt_bundle.py
components/mqtt/weekend_test/mqtt_publish_test.py
components/nvs_flash/nvs_partition_generator/nvs_partition_gen.py
components/partition_table/gen_empty_partition.py
components/partition_table/gen_esp32part.py
components/partition_table/parttool.py
components/partition_table/test_gen_esp32part_host/gen_esp32part_tests.py
components/protocomm/python/constants_pb2.py
components/protocomm/python/sec0_pb2.py
components/protocomm/python/sec1_pb2.py
components/protocomm/python/session_pb2.py
components/ulp/esp32ulp_mapgen.py
components/wifi_provisioning/python/wifi_config_pb2.py
components/wifi_provisioning/python/wifi_constants_pb2.py
components/wifi_provisioning/python/wifi_scan_pb2.py
components/xtensa/trax/traceparse.py
docs/build_docs.py
docs/conf_common.py
docs/en/conf.py
docs/extensions/google_analytics.py
docs/extensions/html_redirects.py
docs/extensions/list_filter.py
docs/extensions/toctree_filter.py
docs/generate_chart.py
docs/get_github_rev.py
docs/idf_extensions/build_system/__init__.py
docs/idf_extensions/esp_err_definitions.py
docs/idf_extensions/exclude_docs.py
docs/idf_extensions/format_idf_target.py
docs/idf_extensions/gen_defines.py
docs/idf_extensions/gen_idf_tools_links.py
docs/idf_extensions/gen_toolchain_links.py
docs/idf_extensions/gen_version_specific_includes.py
docs/idf_extensions/include_build_file.py
docs/idf_extensions/kconfig_reference.py
docs/idf_extensions/latex_builder.py
docs/idf_extensions/link_roles.py
docs/idf_extensions/run_doxygen.py
docs/idf_extensions/util.py
docs/sanitize_version.py
docs/test/en/conf.py
docs/test/test_docs.py
docs/test/test_sphinx_idf_extensions.py
docs/zh_CN/conf.py
examples/bluetooth/nimble/blecent/blecent_test.py
examples/bluetooth/nimble/blehr/blehr_test.py
examples/bluetooth/nimble/bleprph/bleprph_test.py
examples/cxx/exceptions/example_test.py
examples/cxx/pthread/example_test.py
examples/cxx/rtti/example_test.py
examples/get-started/blink/example_test.py
examples/get-started/hello_world/example_test.py
examples/peripherals/gpio/generic_gpio/example_test.py
examples/peripherals/i2c/i2c_tools/example_test.py
examples/peripherals/rmt/ir_protocols/example_test.py
examples/peripherals/sdio/sdio_test.py
examples/peripherals/twai/twai_alert_and_recovery/example_test.py
examples/peripherals/twai/twai_network/example_test.py
examples/peripherals/twai/twai_self_test/example_test.py
examples/protocols/asio/chat_client/asio_chat_client_test.py
examples/protocols/asio/chat_server/asio_chat_server_test.py
examples/protocols/asio/ssl_client_server/example_test.py
examples/protocols/asio/tcp_echo_server/asio_tcp_server_test.py
examples/protocols/asio/udp_echo_server/asio_udp_server_test.py
examples/protocols/cbor/example_test.py
examples/protocols/esp_http_client/esp_http_client_test.py
examples/protocols/esp_local_ctrl/example_test.py
examples/protocols/esp_local_ctrl/scripts/esp_local_ctrl.py
examples/protocols/esp_local_ctrl/scripts/proto.py
examples/protocols/http_server/advanced_tests/http_server_advanced_test.py
examples/protocols/http_server/advanced_tests/scripts/test.py
examples/protocols/http_server/persistent_sockets/http_server_persistence_test.py
examples/protocols/http_server/simple/http_server_simple_test.py
examples/protocols/http_server/ws_echo_server/ws_server_example_test.py
examples/protocols/https_request/example_test.py
examples/protocols/https_x509_bundle/example_test.py
examples/protocols/icmp_echo/example_test.py
examples/protocols/mdns/mdns_example_test.py
examples/protocols/modbus/serial/example_test.py
examples/protocols/modbus/tcp/example_test.py
examples/protocols/mqtt/ssl/mqtt_ssl_example_test.py
examples/protocols/mqtt/ssl_ds/configure_ds.py
examples/protocols/mqtt/tcp/mqtt_tcp_example_test.py
examples/protocols/mqtt/ws/mqtt_ws_example_test.py
examples/protocols/mqtt/wss/mqtt_wss_example_test.py
examples/protocols/openssl_client/example_test.py
examples/protocols/openssl_server/example_test.py
examples/protocols/pppos_client/example_test.py
examples/protocols/sntp/example_test.py
examples/protocols/sockets/non_blocking/example_test.py
examples/protocols/sockets/tcp_client/example_test.py
examples/protocols/sockets/tcp_server/example_test.py
examples/protocols/sockets/udp_client/example_test.py
examples/protocols/sockets/udp_server/example_test.py
examples/protocols/websocket/example_test.py
examples/provisioning/legacy/ble_prov/ble_prov_test.py
examples/provisioning/legacy/custom_config/components/custom_provisioning/python/custom_config_pb2.py
examples/provisioning/legacy/softap_prov/softap_prov_test.py
examples/provisioning/wifi_prov_mgr/wifi_prov_mgr_test.py
examples/security/flash_encryption/example_test.py
examples/storage/ext_flash_fatfs/example_test.py
examples/storage/nvs_rw_blob/nvs_rw_blob_example_test.py
examples/storage/nvs_rw_value/nvs_rw_value_example_test.py
examples/storage/nvs_rw_value_cxx/nvs_rw_value_cxx_example_test.py
examples/storage/partition_api/partition_find/partition_find_example_test.py
examples/storage/partition_api/partition_mmap/partition_mmap_example_test.py
examples/storage/partition_api/partition_ops/partition_ops_example_test.py
examples/storage/parttool/example_test.py
examples/storage/parttool/parttool_example.py
examples/storage/sd_card/sd_card_example_test.py
examples/storage/semihost_vfs/semihost_vfs_example_test.py
examples/storage/spiffs/spiffs_example_test.py
examples/storage/spiffsgen/example_test.py
examples/storage/wear_levelling/wear_levelling_example_test.py
examples/system/app_trace_to_host/example_test.py
examples/system/base_mac_address/example_test.py
examples/system/console/example_test.py
examples/system/deep_sleep/example_test.py
examples/system/esp_event/default_event_loop/example_test.py
examples/system/esp_event/user_event_loops/example_test.py
examples/system/esp_timer/example_test.py
examples/system/freertos/real_time_stats/example_test.py
examples/system/gcov/example_test.py
examples/system/himem/example_test.py
examples/system/light_sleep/example_test.py
examples/system/ota/advanced_https_ota/example_test.py
examples/system/ota/native_ota_example/example_test.py
examples/system/ota/otatool/example_test.py
examples/system/ota/otatool/get_running_partition.py
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
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
examples/system/unit_test/example_test.py
examples/wifi/iperf/iperf_test.py
tools/ble/lib_ble_client.py
tools/ble/lib_gap.py
tools/ble/lib_gatt.py
tools/check_python_dependencies.py
tools/check_term.py
tools/ci/check_artifacts_expire_time.py
tools/ci/check_callgraph.py
tools/ci/check_codeowners.py
tools/ci/check_deprecated_kconfigs.py
tools/ci/check_examples_cmake_make.py
tools/ci/check_executables.py
tools/ci/check_kconfigs.py
tools/ci/check_public_headers.py
tools/ci/check_readme_links.py
tools/ci/check_rules_yml.py
tools/ci/check_tools_files_patterns.py
tools/ci/checkout_project_ref.py
tools/ci/ci_fetch_submodule.py
tools/ci/deploy_docs.py
tools/ci/envsubst.py
tools/ci/normalize_clangtidy_path.py
tools/ci/python_packages/gitlab_api.py
tools/ci/python_packages/idf_http_server_test/adder.py
tools/ci/python_packages/idf_http_server_test/client.py
tools/ci/python_packages/idf_http_server_test/test.py
tools/ci/python_packages/idf_iperf_test_util/Attenuator.py
tools/ci/python_packages/idf_iperf_test_util/LineChart.py
tools/ci/python_packages/idf_iperf_test_util/PowerControl.py
tools/ci/python_packages/idf_iperf_test_util/TestReport.py
tools/ci/python_packages/tiny_test_fw/App.py
tools/ci/python_packages/tiny_test_fw/DUT.py
tools/ci/python_packages/tiny_test_fw/Env.py
tools/ci/python_packages/tiny_test_fw/EnvConfig.py
tools/ci/python_packages/tiny_test_fw/TinyFW.py
tools/ci/python_packages/tiny_test_fw/Utility/CIAssignTest.py
tools/ci/python_packages/tiny_test_fw/Utility/CaseConfig.py
tools/ci/python_packages/tiny_test_fw/Utility/GitlabCIJob.py
tools/ci/python_packages/tiny_test_fw/Utility/SearchCases.py
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
tools/ci/python_packages/ttfw_idf/__init__.py
tools/ci/python_packages/ttfw_idf/unity_test_parser.py
tools/ci/python_packages/wifi_tools.py
tools/ci/test_autocomplete.py
tools/ci/test_check_kconfigs.py
tools/cmake/convert_to_cmake.py
tools/esp_app_trace/espytrace/apptrace.py
tools/esp_app_trace/espytrace/sysview.py
tools/esp_app_trace/logtrace_proc.py
tools/esp_app_trace/sysviewtrace_proc.py
tools/esp_prov/esp_prov.py
tools/esp_prov/prov/custom_prov.py
tools/esp_prov/prov/wifi_prov.py
tools/esp_prov/prov/wifi_scan.py
tools/esp_prov/security/security.py
tools/esp_prov/security/security0.py
tools/esp_prov/security/security1.py
tools/esp_prov/transport/ble_cli.py
tools/esp_prov/transport/transport.py
tools/esp_prov/transport/transport_ble.py
tools/esp_prov/transport/transport_console.py
tools/esp_prov/transport/transport_http.py
tools/esp_prov/utils/convenience.py
tools/find_apps.py
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
tools/idf_py_actions/dfu_ext.py
tools/idf_py_actions/errors.py
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
tools/kconfig_new/gen_kconfig_doc.py
tools/kconfig_new/prepare_kconfig_files.py
tools/kconfig_new/test/confgen/test_confgen.py
tools/kconfig_new/test/confserver/test_confserver.py
tools/kconfig_new/test/gen_kconfig_doc/test_kconfig_out.py
tools/kconfig_new/test/gen_kconfig_doc/test_target_visibility.py
tools/ldgen/fragments.py
tools/ldgen/generation.py
tools/ldgen/ldgen.py
tools/ldgen/ldgen_common.py
tools/ldgen/linker_script.py
tools/ldgen/output_commands.py
tools/ldgen/sdkconfig.py
tools/ldgen/test/test_entity.py
tools/ldgen/test/test_fragments.py
tools/ldgen/test/test_generation.py
tools/ldgen/test/test_output_commands.py
tools/mass_mfg/mfg_gen.py
tools/mkuf2.py
tools/test_apps/build_system/ldgen_test/check_placements.py
tools/test_apps/protocols/mqtt/publish_connect_test/app_test.py
tools/test_apps/protocols/openssl/app_test.py
tools/test_apps/protocols/pppos/app_test.py
tools/test_apps/system/gdb_loadable_elf/app_test.py
tools/test_apps/system/longjmp_test/app_test.py
tools/test_apps/system/memprot/app_test.py
tools/test_apps/system/monitor_ide_integration/app_test.py
tools/test_apps/system/panic/app_test.py
tools/test_apps/system/panic/panic_tests.py
tools/test_apps/system/panic/test_panic_util/test_panic_util.py
tools/test_apps/system/startup/app_test.py
tools/test_idf_monitor/idf_monitor_wrapper.py
tools/test_idf_monitor/run_test_idf_monitor.py
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
tools/unit-test-app/idf_ext.py
tools/unit-test-app/tools/CreateSectionTable.py
tools/unit-test-app/tools/UnitTestParser.py
tools/unit-test-app/unit_test.py
tools/windows/eclipse_make.py

File diff suppressed because it is too large Load Diff

View File

@ -17750,10 +17750,4 @@ Producing text file output...
***
Running idf_size_tests.py...
Total sizes:
DRAM .data size: 0 bytes
DRAM .bss size: 0 bytes
Used static DRAM: 0 bytes ( 0 available, nan% used)
Used static IRAM: 0 bytes ( 0 available, nan% used)
Flash code: 0 bytes
Flash rodata: 0 bytes
Total image size:~ 0 bytes (.bin may be padded larger)
Total image size: 0 bytes (.bin may be padded larger)

View File

@ -64,8 +64,6 @@
&& 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 diff with another app (wrong target)..." &>> output \
&& coverage run -a $IDF_PATH/tools/idf_size.py --target esp32s2 app.map --diff app2.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

@ -16,7 +16,6 @@
from __future__ import print_function
import collections
import sys
try:
@ -35,16 +34,13 @@ if __name__ == '__main__':
# Should deliver a RuntimeError as there's no content under the heading
try:
idf_size.load_memory_config(['Memory Configuration'])
idf_size.load_segments(['Memory Configuration'])
pass
except RuntimeError as e:
assert 'End of file' in str(e)
# This used to crash with a division by zero error but now it just prints nan% due to
# zero lengths
MemRegNames = collections.namedtuple('MemRegNames', ['iram_names', 'dram_names', 'diram_names', 'used_iram_names',
'used_dram_names', 'used_diram_names'])
mem_reg = MemRegNames(set(), set(), set(), set(), set(), set())
segments = {'iram0_0_seg': {'origin': 0, 'length': 0},
'dram0_0_seg': {'origin': 0, 'length': 0}}
sections = {}
print(idf_size.get_summary('a.map', mem_reg, {'iram0_0_seg': {'origin':0,'length':0}, 'dram0_0_seg':
{'origin':0, 'length':0}}, {}), end='')
print(idf_size.get_summary('a.map', segments, sections, 'esp32'), end='')