summaryrefslogtreecommitdiff
path: root/src/arch/stm32f746zg-nucleo/Makefile.inc
diff options
context:
space:
mode:
authorBirte Kristina Friesel <birte.friesel@uos.de>2024-02-08 13:46:48 +0100
committerBirte Kristina Friesel <birte.friesel@uos.de>2024-02-08 13:46:48 +0100
commitec871ef8ae230bcb779c8535c3c4526817fd5d93 (patch)
tree558e731639f7ece070d7abd14c3c82afa11f9647 /src/arch/stm32f746zg-nucleo/Makefile.inc
parent18db600341bcf1c21e4282515d458b898639f349 (diff)
Add preliminary STM32F746ZG-Nucleo support
Diffstat (limited to 'src/arch/stm32f746zg-nucleo/Makefile.inc')
-rw-r--r--src/arch/stm32f746zg-nucleo/Makefile.inc140
1 files changed, 140 insertions, 0 deletions
diff --git a/src/arch/stm32f746zg-nucleo/Makefile.inc b/src/arch/stm32f746zg-nucleo/Makefile.inc
new file mode 100644
index 0000000..b6e1944
--- /dev/null
+++ b/src/arch/stm32f746zg-nucleo/Makefile.inc
@@ -0,0 +1,140 @@
+# vim:ft=make
+#
+# Copyright 2024 Birte Kristina Friesel
+#
+# SPDX-License-Identifier: BSD-2-Clause
+
+SERIAL_PORT ?= ttyACM0
+
+cpu_freq ?= 216000000
+
+INCLUDES += -Iext/libopencm3/include
+
+COMMON_FLAGS += --static -nostartfiles -g3 -Os -fno-common
+COMMON_FLAGS += -ffunction-sections -fdata-sections
+COMMON_FLAGS += -mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=fpv5-sp-d16 -DSTM32F7
+
+CC = arm-none-eabi-gcc
+CXX = arm-none-eabi-g++
+OBJCOPY = arm-none-eabi-objcopy
+OBJDUMP = arm-none-eabi-objdump
+SIZE = arm-none-eabi-size
+
+ARCH_SHORTNAME = stm32f7
+
+CXX_TARGETS += src/arch/stm32f746zg-nucleo/arch.cc
+
+ifdef CONFIG_aspectc
+ CXX = ag++ -r build/repo.acp -v 0 --c_compiler arm-none-eabi-g++ -p . --Xcompiler
+endif
+
+CXX_TARGETS += src/arch/stm32f746zg-nucleo/driver/gpio.cc
+CXX_TARGETS += src/arch/stm32f746zg-nucleo/driver/stdout.cc
+
+# Commandline
+
+ifneq ($(findstring counter,${arch_drivers}), )
+ CONFIG_arch_stm32f746zg_nucleo_driver_counter = y
+endif
+
+#ifneq ($(findstring timer,${arch_drivers}), )
+# CONFIG_arch_stm32f746zg_nucleo_driver_timer = y
+#endif
+
+ifeq (${timer_s}, 1)
+ CONFIG_arch_stm32f746zg_nucleo_driver_uptime = y
+endif
+
+# Kconfig
+
+ifdef CONFIG_arch_stm32f746zg_nucleo_driver_counter
+ CXX_TARGETS += src/arch/stm32f746zg-nucleo/driver/counter.cc
+endif
+
+#ifdef CONFIG_arch_stm32f746zg_nucleo_driver_i2c
+# CXX_TARGETS += src/arch/stm32f746zg-nucleo/driver/i2c.cc
+#endif
+
+#ifdef CONFIG_arch_stm32f746zg_nucleo_driver_timer
+# CXX_TARGETS += src/arch/stm32f746zg-nucleo/driver/timer.cc
+#endif
+
+ifdef CONFIG_arch_stm32f746zg_nucleo_driver_uptime
+ COMMON_FLAGS += -DTIMER_S
+ CXX_TARGETS += src/arch/stm32f746zg-nucleo/driver/uptime.cc
+endif
+
+
+ifneq (${cpu_freq}, )
+ COMMON_FLAGS += -DF_CPU=${cpu_freq}UL
+else
+ COMMON_FLAGS += -DF_CPU=216000000UL
+endif
+
+
+OBJECTS = ${CXX_TARGETS:.cc=.o} ${C_TARGETS:.c=.o} ${ASM_TARGETS:.S=.o}
+
+%.o : %.cc | include/config.h
+ ${QUIET}${CXX} ${INCLUDES} ${COMMON_FLAGS} ${CXXFLAGS} -c -o $@ ${@:.o=.cc}
+
+%.o : %.c | include/config.h
+ ${QUIET}${CC} ${INCLUDES} ${COMMON_FLAGS} ${CFLAGS} -c -o $@ ${@:.o=.c}
+
+%.o : %.S | include/config.h
+ ${QUIET}${CC} ${INCLUDES} ${COMMON_FLAGS} -c -o $@ ${@:.o=.S}
+
+%.o : %.s | include/config.h
+ ${QUIET}${CC} ${INCLUDES} ${COMMON_FLAGS} -c -o $@ ${@:.o=.S}
+
+build/system.elf: ${OBJECTS} ext/libopencm3/lib/libopencm3_stm32f7.a
+ ${QUIET}mkdir -p build
+ ${QUIET}${CXX} ${INCLUDES} ${COMMON_FLAGS} ${CXXFLAGS} \
+ -Lext/libopencm3/lib -Wl,--gc-sections \
+ -Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group \
+ -T src/arch/stm32f746zg-nucleo/stm32f746zg.ld \
+ ${OBJECTS} -lopencm3_stm32f7 \
+ -o $@
+ ${QUIET}${SIZE} build/system.elf | tail -n1 | awk '{ print " ROM: " ($$1+$$2) " (" int(($$1+$$2)*100/1048576) "%) RAM: " ($$2 + $$3) " (" int(($$2+$$3)*100/327680) "%)" }'
+
+ext/libopencm3/Makefile:
+ git submodule update --init
+
+ext/libopencm3/lib/libopencm3_stm32f7.a: ext/libopencm3/Makefile
+ ${MAKE} -C ext/libopencm3
+
+program: build/system.elf
+ openocd -c 'source [find interface/stlink.cfg]' \
+ -c 'transport select hla_swd' -c 'source [find target/stm32f7x.cfg]' \
+ -c 'reset_config srst_only' -c '$$_TARGETNAME configure -rtos auto' \
+ -c 'reset_config connect_assert_srst' -c init -c targets \
+ -c 'reset halt' -c 'flash write_image erase "build/system.elf" 0' \
+ -c 'verify_image "build/system.elf" 0' -c 'reset run' -c 'shutdown'
+
+arch_clean:
+ ${QUIET}rm -f ${OBJECTS}
+
+cat:
+ ${QUIET}script/cat.py /dev/${SERIAL_PORT} 115200 ${cpu_freq} 65536
+
+monitor:
+ ${QUIET}screen /dev/${SERIAL_PORT} 115200
+
+arch_help:
+ @echo "stm32f746zg-nucleo specific flags:"
+ @echo " cpu_freq = ${cpu_freq} (desired CPU frequency in Hz)"
+ @echo " supported frequencies: 84 / 168 / 180 MHz"
+
+arch_info:
+ @echo "CPU Freq: ${cpu_freq} Hz"
+ @echo "Timer Freq: ${timer_freq} Hz -> $(shell src/arch/stm32f746zg-nucleo/model.py f_timer "${cpu_freq}" "${timer_freq}")"
+ @echo "I2C Freq: ${i2c_freq} Hz"
+ @echo "Counter Overflow: 4294967296/255"
+ @echo "Monitor: /dev/${SERIAL_PORT} 115200"
+
+attributes: build/system.elf
+ ${QUIET}script/size.py ${SIZE} text,data data,bss
+
+nfpvalues: build/system.elf
+ ${QUIET}script/nfpvalues.py ${SIZE} text,data data,bss
+
+.PHONY: arch_clean arch_help arch_info attributes cat monitor program