-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
Zephyr has a very useful command west build -t rom_report which gives a report of how much space is being used for each part of the code. To see how a PR impacts the rom usage we could make this command run automatically on every PR and compare with the main branch.
Part of the output:
│ │ │ ├── stl_vector.h 712 0.51% -
│ │ │ │ ├── _ZNKSt6vectorIN8nlohmann10basic_jsonISt3mapS_NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbxydSaNS0_14adl_serializerES_IhSaIhEEEESaISC_EE12_M_check_lenEjPKc 60 0.04% 0x1000ac29 text
│ │ │ │ ├── _ZNKSt6vectorIPN8nlohmann10basic_jsonISt3mapS_NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbxydSaNS0_14adl_serializerES_IhSaIhEEEESaISD_EE12_M_check_lenEjPKc 60 0.04% 0x1000b0fd text
│ │ │ │ ├── _ZNSt12_Vector_baseI10StackValueSaIS0_EED2Ev 22 0.02% 0x10017115 text
│ │ │ │ ├── _ZNSt12_Vector_baseI14IOStateElementSaIS0_EE11_M_allocateEj.isra.0 38 0.03% 0x10017503 text
│ │ │ │ ├── _ZNSt12_Vector_baseI14IOStateElementSaIS0_EED2Ev 22 0.02% 0x10017203 text
│ │ │ │ ├── _ZNSt12_Vector_baseIN8nlohmann10basic_jsonISt3mapSt6vectorNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbxydSaNS0_14adl_serializerES3_IhSaIhEEEESaISD_EE11_M_allocateEj.isra.0 38 0.03% 0x100174dd text
│ │ │ │ ├── _ZNSt12_Vector_baseIN8nlohmann10basic_jsonISt3mapSt6vectorNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbxydSaNS0_14adl_serializerES3_IhSaIhEEEESaISD_EE13_M_deallocateEPSD_j.constprop.0 14 0.01% 0x10017455 text
│ │ │ │ ├── _ZNSt12_Vector_baseIN8nlohmann10basic_jsonISt3mapSt6vectorNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbxydSaNS0_14adl_serializerES3_IhSaIhEEEESaISD_EED1Ev 20 0.01% 0x10017f15 text
│ │ │ │ ├── _ZNSt12_Vector_baseIP14IOStateElementSaIS1_EED2Ev 22 0.02% 0x10017cdb text
│ │ │ │ ├── _ZNSt12_Vector_baseIPN8nlohmann10basic_jsonISt3mapSt6vectorNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbxydSaNS0_14adl_serializerES3_IhSaIhEEEESaISE_EE11_M_allocateEj.isra.0 38 0.03% 0x10017463 text
│ │ │ │ ├── _ZNSt12_Vector_baseIPN8nlohmann10basic_jsonISt3mapSt6vectorNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbxydSaNS0_14adl_serializerES3_IhSaIhEEEESaISE_EED2Ev 22 0.02% 0x1001804b text
│ │ │ │ ├── _ZNSt12_Vector_baseIcSaIcEED1Ev 22 0.02% 0x10017eb5 text
│ │ │ │ ├── _ZNSt12_Vector_baseIhSaIhEED2Ev 22 0.02% 0x10017b45 text
│ │ │ │ ├── _ZNSt6vectorI10StackValueSaIS0_EE9push_backERKS0_ 42 0.03% 0x10017239 text
│ │ │ │ ├── _ZNSt6vectorI14IOStateElementSaIS0_EED1Ev 32 0.02% 0x10017219 text
│ │ │ │ ├── _ZNSt6vectorI8CallbackSaIS0_EE9push_backERKS0_ 40 0.03% 0x10016569 text
│ │ │ │ ├── _ZNSt6vectorIN8nlohmann10basic_jsonISt3mapS_NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbxydSaNS0_14adl_serializerES_IhSaIhEEEESaISC_EED2Ev 22 0.02% 0x1001857f text
│ │ │ │ └── _ZNSt6vectorIPN8nlohmann10basic_jsonISt3mapS_NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbxydSaNS0_14adl_serializerES_IhSaIhEEEESaISD_EE9push_backERKSD_ 176 0.13% 0x1000b139 text
│ │ │ ├── unique_ptr.h 160 0.11% -
│ │ │ │ ├── _ZNSt10unique_ptrIN8nlohmann27byte_container_with_subtypeISt6vectorIhSaIhEEEEZNS0_10basic_jsonISt3mapS2_NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbxydSaNS0_14adl_serializerES4_E6createIS5_JEEEPT_DpOT0_EUlPS5_E_ED2Ev 20 0.01% 0x10018385 text
│ │ │ │ ├── _ZNSt10unique_ptrIN8nlohmann27byte_container_with_subtypeISt6vectorIhSaIhEEEEZNS0_10basic_jsonISt3mapS2_NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbxydSaNS0_14adl_serializerES4_E6createIS5_JRKS5_EEEPT_DpOT0_EUlPS5_E_ED1Ev 20 0.01% 0x100181a7 text
│ │ │ │ ├── _ZNSt10unique_ptrINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEZN8nlohmann10basic_jsonISt3mapSt6vectorS5_bxydSaNS6_14adl_serializerES9_IhSaIhEEE6createIS5_JRA1_KcEEEPT_DpOT0_EUlPS5_E_ED2Ev 20 0.01% 0x10018371 text
│ │ │ │ ├── _ZNSt10unique_ptrINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEZN8nlohmann10basic_jsonISt3mapSt6vectorS5_bxydSaNS6_14adl_serializerES9_IhSaIhEEE6createIS5_JRKS5_EEEPT_DpOT0_EUlPS5_E_ED2Ev 20 0.01% 0x10018159 text
│ │ │ │ ├── _ZNSt10unique_ptrISt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN8nlohmann10basic_jsonIS0_St6vectorS6_bxydSaNS7_14adl_serializerES9_IhSaIhEEEESt4lessIvESaISt4pairIKS6_SD_EEEZNSD_6createISK_JEEEPT_DpOT0_EUlPSK_E_ED2Ev 20 0.01% 0x10018349 text
│ │ │ │ ├── _ZNSt10unique_ptrISt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN8nlohmann10basic_jsonIS0_St6vectorS6_bxydSaNS7_14adl_serializerES9_IhSaIhEEEESt4lessIvESaISt4pairIKS6_SD_EEEZNSD_6createISK_JRKSK_EEEPT_DpOT0_EUlPSK_E_ED2Ev 20 0.01% 0x10018131 text
│ │ │ │ ├── _ZNSt10unique_ptrISt6vectorIN8nlohmann10basic_jsonISt3mapS0_NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbxydSaNS1_14adl_serializerES0_IhSaIhEEEESaISD_EEZNSD_6createISF_JEEEPT_DpOT0_EUlPSF_E_ED1Ev 20 0.01% 0x1001835d text
│ │ │ │ └── _ZNSt10unique_ptrISt6vectorIN8nlohmann10basic_jsonISt3mapS0_NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbxydSaNS1_14adl_serializerES0_IhSaIhEEEESaISD_EEZNSD_6createISF_JRKSF_EEEPT_DpOT0_EUlPSF_E_ED2Ev 20 0.01% 0x10018145 text
│ │ │ ├── unordered_map.h 50 0.04% -
│ │ │ │ └── _ZNSt13unordered_mapIjjSt4hashIjESt8equal_toIjESaISt4pairIKjjEEED2Ev 50 0.04% 0x100170e3 text
│ │ │ └── vector.tcc 2626 1.88% -
│ │ │ ├── _ZNSt6vectorI10StackValueSaIS0_EE17_M_realloc_insertIJRKS0_EEEvN9__gnu_cxx17__normal_iteratorIPS0_S2_EEDpOT_ 204 0.15% 0x100077d1 text
│ │ │ ├── _ZNSt6vectorI14IOStateElementSaIS0_EE17_M_realloc_insertIJRS0_EEEvN9__gnu_cxx17__normal_iteratorIPS0_S2_EEDpOT_ 200 0.14% 0x10009121 text
│ │ │ ├── _ZNSt6vectorI8CallbackSaIS0_EE17_M_realloc_insertIJRKS0_EEEvN9__gnu_cxx17__normal_iteratorIPS0_S2_EEDpOT_ 252 0.18% 0x10005891 text
│ │ │ ├── _ZNSt6vectorIN8nlohmann10basic_jsonISt3mapS_NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbxydSaNS0_14adl_serializerES_IhSaIhEEEESaISC_EE12emplace_backIJSC_EEERSC_DpOT_.isra.0 128 0.09% 0x1000ac65 text
│ │ │ ├── _ZNSt6vectorIN8nlohmann10basic_jsonISt3mapS_NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbxydSaNS0_14adl_serializerES_IhSaIhEEEESaISC_EE17_M_realloc_insertIJNS0_6detail7value_tEEEEvN9__gnu_cxx17__normal_iteratorIPSC_SE_EEDpOT_ 156 0.11% 0x1000b411 text
│ │ │ ├── _ZNSt6vectorIN8nlohmann10basic_jsonISt3mapS_NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbxydSaNS0_14adl_serializerES_IhSaIhEEEESaISC_EE17_M_realloc_insertIJRS8_EEEvN9__gnu_cxx17__normal_iteratorIPSC_SE_EEDpOT_ 152 0.11% 0x1000b5dd text
│ │ │ ├── _ZNSt6vectorIN8nlohmann10basic_jsonISt3mapS_NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbxydSaNS0_14adl_serializerES_IhSaIhEEEESaISC_EE7reserveEj 84 0.06% 0x1000af0d text
│ │ │ ├── _ZNSt6vectorIP14IOStateElementSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_ 200 0.14% 0x10007365 text
│ │ │ ├── _ZNSt6vectorIP6ModuleSaIS1_EE17_M_realloc_insertIJRKS1_EEEvN9__gnu_cxx17__normal_iteratorIPS1_S3_EEDpOT_ 200 0.14% 0x10004419 text
│ │ │ ├── _ZNSt6vectorIPN8nlohmann10basic_jsonISt3mapS_NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbxydSaNS0_14adl_serializerES_IhSaIhEEEESaISD_EE12emplace_backIJSD_EEERSD_DpOT_.isra.0 176 0.13% 0x1000b361 text
│ │ │ ├── _ZNSt6vectorIbSaIbEE13_M_insert_auxESt13_Bit_iteratorb 464 0.33% 0x1000a8a1 text
│ │ │ ├── _ZNSt6vectorIcSaIcEE12emplace_backIJcEEERcDpOT_.isra.0 34 0.02% 0x100190e3 text
│ │ │ ├── _ZNSt6vectorIcSaIcEE17_M_realloc_insertIJcEEEvN9__gnu_cxx17__normal_iteratorIPcS1_EEDpOT_ 188 0.13% 0x1000b7e5 text
│ │ │ └── _ZNSt6vectorIhSaIhEE17_M_realloc_insertIJRKhEEEvN9__gnu_cxx17__normal_iteratorIPhS1_EEDpOT_ 188 0.13% 0x10008f1d text
│ │ ├── ext 56 0.04% -
│ │ │ └── string_conversions.h 56 0.04% -
│ │ │ └── _ZZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PjS9_EN11_Save_errnoD2Ev 56 0.04% 0x100072dd text
│ │ └── optional 88 0.06% -
│ │ ├── _ZNKSt19bad_optional_access4whatEv 8 0.01% 0x10007f05 text
│ │ ├── _ZNRSt8optionalIjE5valueEv 40 0.03% 0x10008b61 text
│ │ ├── _ZNSt19bad_optional_accessD0Ev 20 0.01% 0x10017441 text
│ │ └── _ZNSt19bad_optional_accessD1Ev 20 0.01% 0x10007f0d text
│ └── picolibc 212 0.15% -
│ └── include 212 0.15% -
│ ├── stdio.h 8 0.01% -
│ │ └── fileno 8 0.01% 0x1001a26b text
│ └── stdlib.h 204 0.15% -
│ ├── abort 24 0.02% 0x1000fe79 text
│ ├── calloc 100 0.07% 0x1000ff29 text
│ ├── free 28 0.02% 0x1000ff0d text
│ └── malloc 52 0.04% 0x1000fed9 text
Total at the end (for reference, upload.wasm is 847B in this example):
├── usb_transfer.c 762 0.55% -
│ ├── usb_cancel_transfer 52 0.04% 0x1000f475 text
│ ├── usb_cancel_transfers 64 0.05% 0x1000f4a9 text
│ ├── usb_ep_get_transfer 44 0.03% 0x1000f235 text
│ ├── usb_transfer 228 0.16% 0x1000f391 text
│ ├── usb_transfer_ep_callback 84 0.06% 0x1000f33d text
│ ├── usb_transfer_init 48 0.03% 0x1000f4e9 text
│ ├── usb_transfer_is_busy 22 0.02% 0x10019dd9 text
│ └── usb_transfer_work 220 0.16% 0x1000f261 text
└── usb_work_q.c 56 0.04% -
├── __init_z_usb_work_q_init 8 0.01% 0x1001e730 initlevel
└── z_usb_work_q_init 48 0.03% 0x1000f921 text
==========================================================================================================================================
139397
Another option is to just use what is printed at the end of a regular west build output:
Memory region Used Size Region Size %age Used
BOOT_FLASH: 256 B 256 B 100.00%
FLASH: 142664 B 2096896 B 6.80%
RAM: 36616 B 264 KB 13.54%
IDT_LIST: 0 GB 32 KB 0.00%
Generating files from /Users/maarten/Projects/temp-demo/mio/WARDuino/platforms/Zephyr/build/zephyr/zephyr.elf for board: rpi_pico
Converted to uf2, output size: 286208, start address: 0x10000000
Wrote 286208 bytes to zephyr.uf2
We could probably take inspiration from micropython for this which already does something like this:
micropython/micropython#17765 (comment)
bare-arm: +0 +0.000%
minimal x86: +0 +0.000%
unix x64: +0 +0.000% standard
stm32: +0 +0.000% PYBV10
mimxrt: +0 +0.000% TEENSY40
rp2: +0 +0.000% RPI_PICO_W
samd: +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
qemu rv32: +0 +0.000% VIRT_RV32
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
No status