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
+36 -13
View File
@@ -13,6 +13,9 @@ LIBRARY_STM32 = ./STM32F4xx_StdPeriph_Driver/src
LIBRARY_STM32_INCLUDES = ./STM32F4xx_StdPeriph_Driver/inc
LIBRARY_CMSIS = ./CMSIS
CSTACK_TOOL := $(BACNET_DIR)/tools/avstack/avstack.pl
MEMAP_TOOL := $(BACNET_DIR)/tools/memap/memap.py
INCLUDES = -I$(PLATFORM_DIR)
INCLUDES += -I$(LIBRARY_STM32_INCLUDES)
INCLUDES += -I$(LIBRARY_CMSIS)
@@ -59,17 +62,15 @@ BACNET_SRC = \
$(BACNET_CORE)/bacint.c \
$(BACNET_CORE)/bacreal.c \
$(BACNET_CORE)/bacstr.c \
$(BACNET_CORE)/datalink/cobs.c \
$(BACNET_CORE)/datalink/crc.c \
$(BACNET_CORE)/datalink/dlmstp.c \
$(BACNET_CORE)/datalink/mstp.c \
$(BACNET_CORE)/datalink/mstptext.c \
$(BACNET_CORE)/bactimevalue.c \
$(BACNET_CORE)/calendar_entry.c \
$(BACNET_CORE)/dailyschedule.c \
$(BACNET_CORE)/datetime.c \
$(BACNET_CORE)/dcc.c \
$(BACNET_CORE)/indtext.c \
$(BACNET_CORE)/hostnport.c \
$(BACNET_CORE)/iam.c \
$(BACNET_CORE)/ihave.c \
$(BACNET_CORE)/hostnport.c \
$(BACNET_CORE)/indtext.c \
$(BACNET_CORE)/lighting.c \
$(BACNET_CORE)/memcopy.c \
$(BACNET_CORE)/npdu.c \
@@ -78,16 +79,20 @@ BACNET_SRC = \
$(BACNET_CORE)/reject.c \
$(BACNET_CORE)/rp.c \
$(BACNET_CORE)/rpm.c \
$(BACNET_CORE)/special_event.c \
$(BACNET_CORE)/timestamp.c \
$(BACNET_CORE)/weeklyschedule.c \
$(BACNET_CORE)/dailyschedule.c \
$(BACNET_CORE)/calendar_entry.c \
$(BACNET_CORE)/special_event.c \
$(BACNET_CORE)/bactimevalue.c \
$(BACNET_CORE)/whohas.c \
$(BACNET_CORE)/whois.c \
$(BACNET_CORE)/wp.c
DATALINK_SRC = \
$(BACNET_CORE)/datalink/cobs.c \
$(BACNET_CORE)/datalink/crc.c \
$(BACNET_CORE)/datalink/dlmstp.c \
$(BACNET_CORE)/datalink/mstp.c \
$(BACNET_CORE)/datalink/mstptext.c
STM32_SRC = \
$(LIBRARY_STM32)/stm32f4xx_adc.c \
$(LIBRARY_STM32)/stm32f4xx_can.c \
@@ -118,6 +123,7 @@ STM32_SRC = \
CSRC = $(PLATFORM_SRC)
CSRC += $(BASIC_SRC)
CSRC += $(BACNET_SRC)
CSRC += $(DATALINK_SRC)
CSRC += $(STM32_SRC)
ASRC = $(LIBRARY_CMSIS)/gcc_ride7/startup_stm32f4xx.s
@@ -173,6 +179,8 @@ CFLAGS += $(BACNET_FLAGS)
CFLAGS += $(INCLUDES)
# enable garbage collection of unused functions and data to shrink binary
CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
# enable stack usage tracking
CFLAGS += -fstack-usage
# function calls will not use any special __builtin_xx to allow debug/linking
CFLAGS += -fno-builtin
# place uninitialized global variables in the data section of the object file.
@@ -211,6 +219,7 @@ ODFLAGS = -x --syms
AOBJ = $(ASRC:.s=.o)
COBJ = $(CSRC:.c=.o)
CSTACK = $(CSRC:.c=.su)
all: $(TARGET).bin $(TARGET).hex $(TARGET).elf
$(OBJDUMP) $(ODFLAGS) $(TARGET).elf > $(TARGET).dmp
@@ -225,9 +234,22 @@ $(TARGET).hex: $(TARGET).elf
$(TARGET).elf: $(COBJ) $(AOBJ) Makefile
$(CC) $(CFLAGS) $(AOBJ) $(COBJ) $(LDFLAGS) -o $@
: ram-usage
.PHONY: ram-usage
ram-usage:
$(NM) -t d -S --size-sort $(TARGET).elf 1> $(TARGET).nm
@$(NM) -t d -S --size-sort $(TARGET).elf 1> $(TARGET).nm
@echo "=ADDRESS= ==SIZE== = ==VARIABLE NAME=="
@tail $(TARGET).nm
.PHONY: cstack
cstack:
@$(CSTACK_TOOL) $(COBJ) 2> /dev/null 1> $(TARGET).su
@head -n 25 $(TARGET).su
.PHONY: memap
memap:
# memmap needs Python and PrettyPrint and IntelHex
# sudo apt install python3-prettytable python3-intelhex
$(MEMAP_TOOL) -t GCC_ARM $(TARGET).map
# GDB using st-util (GDB server for ST Link)
GDB_PORT = 3333
@@ -282,6 +304,7 @@ install: $(TARGET).bin
.PHONY: clean
clean:
-rm -rf $(COBJ) $(AOBJ) $(COREOBJ)
-rm -rf $(CSTACK) $(CEXPAND)
-rm -rf $(TARGET).elf $(TARGET).bin $(TARGET).dmp $(TARGET).map
-rm -rf $(TARGET).su $(TARGET).nm
-rm -rf *.lst