From c34e1a72b2f21a428580baa6a6bc4dec361875a1 Mon Sep 17 00:00:00 2001 From: Steve Karg Date: Thu, 30 Nov 2023 23:02:26 -0600 Subject: [PATCH] add install recipe for stm32f4xx port example --- ports/stm32f4xx/Makefile | 57 +++++++++++++++++++++++++++++++--------- 1 file changed, 45 insertions(+), 12 deletions(-) diff --git a/ports/stm32f4xx/Makefile b/ports/stm32f4xx/Makefile index 112cb603..606a66fc 100644 --- a/ports/stm32f4xx/Makefile +++ b/ports/stm32f4xx/Makefile @@ -118,12 +118,14 @@ CSRC += $(STM32_SRC) ASRC = $(LIBRARY_CMSIS)/gcc_ride7/startup_stm32f4xx.s #Set the toolchain command names (only the ones needed are defined) +# sudo apt install gcc-arm-none-eabi PREFIX ?= arm-none-eabi- CC = $(PREFIX)gcc OBJCOPY = $(PREFIX)objcopy OBJDUMP = $(PREFIX)objdump AR = $(PREFIX)ar +NM = $(PREFIX)nm SIZE = $(PREFIX)size LDSCRIPT = $(PLATFORM_DIR)/stm32f4xx.ld @@ -196,18 +198,48 @@ $(TARGET).bin: $(TARGET).elf $(TARGET).elf: $(COBJ) $(AOBJ) Makefile $(CC) $(CFLAGS) $(AOBJ) $(COBJ) $(LDFLAGS) -o $@ -# allow a single file to be unoptimized for debugging purposes -#dlmstp.o: -# $(CC) -c $(CFLAGS) $*.c -o $@ -# -#main.o: -# $(CC) -c $(CFLAGS) $*.c -o $@ -# -#$(BACNET_CORE)/npdu.o: -# $(CC) -c $(CFLAGS) $*.c -o $@ -# -#$(BACNET_CORE)/apdu.o: -# $(CC) -c $(CFLAGS) $*.c -o $@ +: ram-usage +ram-usage: + $(NM) -t d -S --size-sort $(TARGET).elf 1> $(TARGET).nm + +# GDB using st-util (GDB server for ST Link) +GDB_PORT = 3333 +.PHONY: debug +debug: + st-util --listen $(GDB_PORT) + +# GDB using openocd (GDB server for ST Link) +# sudo apt install openocd +.PHONY: openocd +openocd: + openocd -f interface/stlink.cfg -f target/stm32f4x.cfg + +# graphical GDB debugging tool +# note: relies on .gdbinit containing: +# file "./release/target.elf" +# target extended-remote :3333 +# load +# break main +# sudo apt install ddd +.PHONY: ddd +ddd: + ddd --debugger $(GDB) $(realpath $(TARGET).elf) + +# web based graphical GDB debugging tool +# pip install gdbgui +.PHONY: gdbgui +gdbgui: + gdbgui -g $(GDB) $(realpath $(TARGET).elf) + +# sudo apt install stlink-tools +# note: might require adding rule file to /etc/udev/rules.d/ +# SUBSYSTEM=="usb", ATTRS{idVendor}=="0483", MODE="0666" +# SUBSYSTEM=="usb_device", ATTRS{idVendor}=="0483", MODE="0666" +# and reloading with +# $ sudo udevadm control --reload-rules +# or unplug and plugin the stlink after adding the rules file +install: $(TARGET).bin + st-flash write $(TARGET).bin 0x08000000 .c.o: $(CC) -c $(OPTIMIZATION) $(CFLAGS) $*.c -o $@ @@ -219,6 +251,7 @@ $(TARGET).elf: $(COBJ) $(AOBJ) Makefile clean: -rm -rf $(COBJ) $(AOBJ) $(COREOBJ) -rm -rf $(TARGET).elf $(TARGET).bin $(TARGET).dmp $(TARGET).map + -rm -rf $(TARGET).su $(TARGET).nm -rm -rf *.lst ## Other dependencies