Merge branch 'refs/heads/master' into hcd_fsdev

This commit is contained in:
hathach
2025-12-13 14:56:15 +07:00
60 changed files with 2117 additions and 1592 deletions

View File

@ -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)

View File

@ -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 \

View File

@ -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 \

View File

@ -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()

View File

@ -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