Feature/add memap cstack usage ports (#661)

* Added memap, avstack, and checkstackusage tools to STM32F4xx Makefile and CMake builds to calculate CSTACK depth and RAM usage

* Added memap, cstack, and ram-usage recipes to stm32f10x port Makefile.  Added Cmake build.

* Removed local dlmstp.c module from stm32f10x port, and used the common datalink dlmstp.c module with MS/TP extended frames and zero-config support.

* Added .nm and .su to .gitignore to skip the analysis file residue.
This commit is contained in:
Steve Karg
2024-05-31 14:39:25 -05:00
committed by GitHub
parent cf7eb7d98d
commit 4a7b7763c2
32 changed files with 3855 additions and 1974 deletions
+33
View File
@@ -48,7 +48,12 @@ set(CMAKE_AR arm-none-eabi-ar)
set(CMAKE_OBJCOPY arm-none-eabi-objcopy)
set(CMAKE_OBJDUMP arm-none-eabi-objdump)
set(SIZE arm-none-eabi-size)
set(CMAKE_SIZE arm-none-eabi-size)
set(CMAKE_NM arm-none-eabi-nm)
set(CMAKE_CSTACK "${CMAKE_SOURCE_DIR}/../../tools/check-stack-usage/checkStackUsage.py")
set(CMAKE_MEMAP "${CMAKE_SOURCE_DIR}/../../tools/memap/memap.py")
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
set(EXECUTABLE ${PROJECT_NAME}.elf)
project(bacnet-mstp)
@@ -65,6 +70,7 @@ add_link_options(-mno-thumb-interwork)
# Code size reduction using garbage collection sections
add_compile_options(-ffunction-sections -fdata-sections)
add_compile_options(-fno-common -fmessage-length=0)
add_compile_options(-fstack-usage -fdump-rtl-dfinish)
add_link_options(-Wl,-gc-sections,--print-memory-usage)
# Build types
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
@@ -240,3 +246,30 @@ add_custom_command(TARGET ${EXECUTABLE}
COMMAND arm-none-eabi-objcopy -O ihex ${EXECUTABLE} ${PROJECT_NAME}.hex
COMMAND arm-none-eabi-objcopy -O binary ${EXECUTABLE} ${PROJECT_NAME}.bin
)
# sort the RAM usage by size and place into a file
add_custom_target(symbols
DEPENDS ${EXECUTABLE}
COMMENT "Print memory symbols by size"
COMMAND ${CMAKE_NM} -t d -S --size-sort ${EXECUTABLE} 1> ${PROJECT_NAME}.nm
COMMAND echo "RAM usage by size analysis in ${PROJECT_NAME}.nm"
COMMAND echo "=ADDRESS= ==RAM=== = ==VARIABLE-NAME=="
COMMAND tail ${PROJECT_NAME}.nm
)
# calculate the worst case CSTACK memory usage by size and place into a file
add_custom_target(cstack
DEPENDS ${EXECUTABLE}
COMMENT "Print CSTACK memory depth by size"
COMMAND ${CMAKE_CSTACK} ${EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR} 1> ${PROJECT_NAME}.su
COMMAND echo "C-Stack maxium depth analysis in ${PROJECT_NAME}.su"
COMMAND echo "==DEPTH== : == Functions called =="
COMMAND tail ${PROJECT_NAME}.su
)
# Print file and library sizes
add_custom_target(memmap
DEPENDS ${PROJECT_NAME}.map
COMMENT "Print file and library memory usage by size"
COMMAND ${CMAKE_MEMAP} -t GCC_ARM ${PROJECT_NAME}.map
)