diff options
| author | hathach <[email protected]> | 2025-12-13 14:56:15 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2025-12-13 14:56:15 +0700 |
| commit | 80886fb32a9610d863246726950ffefeb2ffb21b (patch) | |
| tree | 8914ea1e2702d6ebf8e8346ca4641a402e91b321 /hw | |
| parent | 7a4af1e9b833d334cca8fa98bc200d4738cb6b82 (diff) | |
| parent | 3a4d02ba9f150b74df08384d16fac124a7c27485 (diff) | |
Merge branch 'refs/heads/master' into hcd_fsdev
Diffstat (limited to 'hw')
| -rw-r--r-- | hw/bsp/family_support.cmake | 52 | ||||
| -rw-r--r-- | hw/bsp/kinetis_k/family.mk | 6 | ||||
| -rw-r--r-- | hw/bsp/kinetis_kl/family.mk | 6 | ||||
| -rw-r--r-- | hw/bsp/rp2040/family.cmake | 7 | ||||
| -rw-r--r-- | hw/bsp/rp2040/skip_ci.txt | 7 |
5 files changed, 67 insertions, 11 deletions
diff --git a/hw/bsp/family_support.cmake b/hw/bsp/family_support.cmake index 2b9612186..5eadcdaa9 100644 --- a/hw/bsp/family_support.cmake +++ b/hw/bsp/family_support.cmake @@ -9,6 +9,8 @@ set(TOP "${CMAKE_CURRENT_LIST_DIR}/../..") get_filename_component(TOP ${TOP} ABSOLUTE) set(UF2CONV_PY ${TOP}/tools/uf2/utils/uf2conv.py) +set(LINKERMAP_PY ${TOP}/tools/linkermap/linkermap.py) +set(METRICS_PY ${TOP}/tools/metrics.py) function(family_resolve_board BOARD_NAME BOARD_PATH_OUT) if ("${BOARD_NAME}" STREQUAL "") @@ -223,6 +225,50 @@ function(family_initialize_project PROJECT DIR) endif() endfunction() +# Add bloaty (https://github.com/google/bloaty/) target, required compile with -g (debug) +function(family_add_bloaty TARGET) + find_program(BLOATY_EXE bloaty) + if (BLOATY_EXE STREQUAL BLOATY_EXE-NOTFOUND) + return() + endif () + + set(OPTION "--domain=vm -d compileunits,sections,symbols") + if (DEFINED BLOATY_OPTION) + string(APPEND OPTION " ${BLOATY_OPTION}") + endif () + separate_arguments(OPTION_LIST UNIX_COMMAND ${OPTION}) + + add_custom_target(${TARGET}-bloaty + DEPENDS ${TARGET} + COMMAND ${BLOATY_EXE} ${OPTION_LIST} $<TARGET_FILE:${TARGET}> + VERBATIM) + + # post build + # add_custom_command(TARGET ${TARGET} POST_BUILD + # COMMAND ${BLOATY_EXE} --csv ${OPTION_LIST} $<TARGET_FILE:${TARGET}> > ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_bloaty.csv + # VERBATIM + # ) +endfunction() + +# Add linkermap target (https://github.com/hathach/linkermap) +function(family_add_linkermap TARGET) + set(OPTION "-j") + if (DEFINED LINKERMAP_OPTION) + string(APPEND OPTION " ${LINKERMAP_OPTION}") + endif () + separate_arguments(OPTION_LIST UNIX_COMMAND ${OPTION}) + + add_custom_target(${TARGET}-linkermap + COMMAND python ${LINKERMAP_PY} ${OPTION_LIST} $<TARGET_FILE:${TARGET}>.map + VERBATIM + ) + + # post build + add_custom_command(TARGET ${TARGET} POST_BUILD + COMMAND python ${LINKERMAP_PY} ${OPTION_LIST} $<TARGET_FILE:${TARGET}>.map + VERBATIM) +endfunction() + #------------------------------------------------------------- # Common Target Configure # Most families use these settings except rp2040 and espressif @@ -332,6 +378,12 @@ function(family_configure_common TARGET RTOS) endif () endif () + if (NOT RTOS STREQUAL zephyr) + # Analyze size with bloaty and linkermap + family_add_bloaty(${TARGET}) + family_add_linkermap(${TARGET}) + endif () + # run size after build # find_program(SIZE_EXE ${CMAKE_SIZE}) # if(NOT ${SIZE_EXE} STREQUAL SIZE_EXE-NOTFOUND) diff --git a/hw/bsp/kinetis_k/family.mk b/hw/bsp/kinetis_k/family.mk index e95cdb717..7a51a77d8 100644 --- a/hw/bsp/kinetis_k/family.mk +++ b/hw/bsp/kinetis_k/family.mk @@ -9,11 +9,13 @@ CFLAGS += \ -DCFG_TUSB_MCU=OPT_MCU_KINETIS_K \ LDFLAGS += \ - -nostartfiles \ - --specs=nosys.specs --specs=nano.specs \ -Wl,--defsym,__stack_size__=0x400 \ -Wl,--defsym,__heap_size__=0 +LDFLAGS_GCC += \ + -nostartfiles \ + --specs=nosys.specs --specs=nano.specs \ + SRC_C += \ src/portable/nxp/khci/dcd_khci.c \ src/portable/nxp/khci/hcd_khci.c \ diff --git a/hw/bsp/kinetis_kl/family.mk b/hw/bsp/kinetis_kl/family.mk index 8d113aecf..aec53d486 100644 --- a/hw/bsp/kinetis_kl/family.mk +++ b/hw/bsp/kinetis_kl/family.mk @@ -9,11 +9,13 @@ CFLAGS += \ -DCFG_TUSB_MCU=OPT_MCU_KINETIS_KL \ LDFLAGS += \ - -nostartfiles \ - -specs=nosys.specs -specs=nano.specs \ -Wl,--defsym,__stack_size__=0x400 \ -Wl,--defsym,__heap_size__=0 +LDFLAGS_GCC += \ + -nostartfiles \ + -specs=nosys.specs -specs=nano.specs \ + SRC_C += \ src/portable/nxp/khci/dcd_khci.c \ src/portable/nxp/khci/hcd_khci.c \ diff --git a/hw/bsp/rp2040/family.cmake b/hw/bsp/rp2040/family.cmake index 5d6d8b40e..390d6072c 100644 --- a/hw/bsp/rp2040/family.cmake +++ b/hw/bsp/rp2040/family.cmake @@ -222,6 +222,8 @@ function(family_add_default_example_warnings TARGET) endif() endfunction() + +# TODO merge with family_configure_common from family_support.cmake function(family_configure_target TARGET RTOS) if (RTOS STREQUAL noos OR RTOS STREQUAL "") set(RTOS_SUFFIX "") @@ -239,10 +241,15 @@ function(family_configure_target TARGET RTOS) pico_add_extra_outputs(${TARGET}) pico_enable_stdio_uart(${TARGET} 1) + + target_link_options(${TARGET} PUBLIC "LINKER:-Map=$<TARGET_FILE:${TARGET}>.map") target_link_libraries(${TARGET} PUBLIC pico_stdlib tinyusb_board${RTOS_SUFFIX} tinyusb_additions) family_flash_openocd(${TARGET}) family_flash_jlink(${TARGET}) + + # Generate linkermap target and post build. LINKERMAP_OPTION can be set with -D to change default options + family_add_linkermap(${TARGET}) endfunction() diff --git a/hw/bsp/rp2040/skip_ci.txt b/hw/bsp/rp2040/skip_ci.txt deleted file mode 100644 index fe99c9f65..000000000 --- a/hw/bsp/rp2040/skip_ci.txt +++ /dev/null @@ -1,7 +0,0 @@ -# boards in this files are skipped when running CI with this family -adafruit_feather_rp2040_usb_host -adafruit_fruit_jam -adafruit_metro_rp2350 -feather_rp2040_max3421 -pico_sdk -raspberry_pi_pico_w |
