Skip to content

Commit

Permalink
experimental support for STM32F7xx based modems;
Browse files Browse the repository at this point in the history
  • Loading branch information
gatekeep committed Jul 26, 2024
1 parent a014db7 commit c81ba8e
Show file tree
Hide file tree
Showing 15 changed files with 868 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "STM32F4XX_Platform"]
path = STM32F4XX_Platform
url = https://github.com/DVMProject/STM32F4XX_Platform.git
[submodule "STM32F7XX_Platform"]
path = STM32F7XX_Platform
url = https://github.com/DVMProject/STM32F7XX_Platform.git
2 changes: 2 additions & 0 deletions Defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#define ARM_MATH_CM3
#elif defined(STM32F4XX)
#define ARM_MATH_CM4
#elif defined(STM32F7XX)
#define ARM_MATH_CM7
#else
#error "Unknown processor type"
#endif
Expand Down
2 changes: 1 addition & 1 deletion FirmwareMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ int main(void)
extern "C" void __cxa_pure_virtual() { while (true); }
#endif // defined(__SAM3X8E__) && defined(ARDUINO_SAM_DUE)

#if defined(STM32F4XX)
#if defined(STM32F4XX) || defined(STM32F7XX)
// --------------------------------------------------------------------------
// Firmware Entry Point
// ---------------------------------------------------------------------------
Expand Down
5 changes: 5 additions & 0 deletions Globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@
#if !defined(__GLOBALS_H__)
#define __GLOBALS_H__

#if defined(STM32F4XX) || defined(STM32F7XX)
#if defined(STM32F4XX)
#include "stm32f4xx.h"
#endif
#if defined(STM32F7XX)
#include "stm32f7xx.h"
#endif
#include <cstddef>
#else
#include <Arduino.h>
Expand Down
83 changes: 82 additions & 1 deletion IOSTM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// Constants
// ---------------------------------------------------------------------------

#if defined(STM32F4XX)
#if defined(STM32F4XX) || defined(STM32F7XX)
/**
* The STM32 factory-programmed UUID memory.
* Three values of 32 bits each starting at this address
Expand Down Expand Up @@ -89,6 +89,87 @@
#define PIN_TX GPIO_Pin_4
#define PIN_TX_CH DAC_Channel_1

#elif defined(STM32F7_PI)

/*
Pin definitions for STM32F722 Pi Board:
PTT PB13 output
COSLED PB14 output
LED PB15 output
COS PC0 input
DSTAR PC7 output
DMR PC8 output
YSF PA8 output
P25 PC9 output
NXDN PB1 output
POCSAG PB12 output
RX PA0 analog input
RSSI PA7 analog input
TX PA4 analog output
EXT_CLK PA15 input
*/

#define PIN_COS GPIO_Pin_0
#define PORT_COS GPIOC
#define RCC_Per_COS RCC_AHB1Periph_GPIOC

#define PIN_PTT GPIO_Pin_13
#define PORT_PTT GPIOB
#define RCC_Per_PTT RCC_AHB1Periph_GPIOB

#define PIN_COSLED GPIO_Pin_14
#define PORT_COSLED GPIOB
#define RCC_Per_COSLED RCC_AHB1Periph_GPIOB

#define PIN_LED GPIO_Pin_15
#define PORT_LED GPIOB
#define RCC_Per_LED RCC_AHB1Periph_GPIOB

#define PIN_P25 GPIO_Pin_9
#define PORT_P25 GPIOC
#define RCC_Per_P25 RCC_AHB1Periph_GPIOC

#define PIN_NXDN GPIO_Pin_1
#define PORT_NXDN GPIOB
#define RCC_Per_NXDN RCC_AHB1Periph_GPIOB

#define PIN_POCSAG GPIO_Pin_12
#define PORT_POCSAG GPIOB
#define RCC_Per_POCSAG RCC_AHB1Periph_GPIOB

#define PIN_DSTAR GPIO_Pin_7
#define PORT_DSTAR GPIOC
#define RCC_Per_DSTAR RCC_AHB1Periph_GPIOC

#define PIN_DMR GPIO_Pin_8
#define PORT_DMR GPIOC
#define RCC_Per_DMR RCC_AHB1Periph_GPIOC

#define PIN_YSF GPIO_Pin_8
#define PORT_YSF GPIOA
#define RCC_Per_YSF RCC_AHB1Periph_GPIOA

#define PIN_EXT_CLK GPIO_Pin_15
#define SRC_EXT_CLK GPIO_PinSource15
#define PORT_EXT_CLK GPIOA

#define PIN_RX GPIO_Pin_0
#define PIN_RX_CH ADC_Channel_0
#define PORT_RX GPIOA
#define RCC_Per_RX RCC_AHB1Periph_GPIOA

#define PIN_RSSI GPIO_Pin_7
#define PIN_RSSI_CH ADC_Channel_7
#define PORT_RSSI GPIOA
#define RCC_Per_RSSI RCC_AHB1Periph_GPIOA

#define PIN_TX GPIO_Pin_4
#define PIN_TX_CH DAC_Channel_1

#elif defined(STM32F4_POG)
/*
Pin definitions for STM32F4 POG Board:
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ clean:
$(MAKE) -f Makefile.STM32F4_POG clean
$(MAKE) -f Makefile.STM32F4_EDA clean
$(MAKE) -f Makefile.STM32F4_DVMV1 clean
$(MAKE) -f Makefile.STM32F7 clean

.FORCE:
155 changes: 155 additions & 0 deletions Makefile.STM32F7
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
# STM32 library paths
F7_LIB_PATH=./STM32F7XX_Platform

# MCU external clock frequency (Hz)
OSC=12000000

# Directory Structure
BINDIR=.
OBJDIR_F7=obj_f722
OBJDIR_F767=obj_f767


# Output files
BINELF_F7=dvm-firmware_f722.elf
BINBIN_F7=dvm-firmware_f722.bin
BINELF_F767=dvm-firmware_f767.elf
BINBIN_F767=dvm-firmware_f767.bin

# Header directories
INC_F7=. $(F7_LIB_PATH)/CMSIS/Include/ $(F7_LIB_PATH)/Device/ $(F7_LIB_PATH)/STM32F7xx_StdPeriph_Driver/inc/
INCLUDES_F7=$(INC_F7:%=-I%)

# CMSIS libraries
INCLUDES_LIBS_F7=$(F7_LIB_PATH)/CMSIS/Lib/GCC/libarm_cortexM7lfsp_math.a

# STM32F7 Standard Peripheral Libraries source path
STD_LIB_F7=$(F7_LIB_PATH)/STM32F7xx_StdPeriph_Driver/src

# STM32F7 system source path
SYS_DIR_F7=$(F7_LIB_PATH)/Device
STARTUP_DIR_F7=$(F7_LIB_PATH)/Device/startup

# GNU ARM Embedded Toolchain
CC=arm-none-eabi-gcc
CXX=arm-none-eabi-g++
LD=arm-none-eabi-ld
AR=arm-none-eabi-ar
AS=arm-none-eabi-as
CP=arm-none-eabi-objcopy
OD=arm-none-eabi-objdump
NM=arm-none-eabi-nm
SIZE=arm-none-eabi-size
A2L=arm-none-eabi-addr2line

# Build object lists
CXXSRC=$(wildcard ./*.cpp) $(wildcard ./dmr/*.cpp) $(wildcard ./p25/*.cpp) $(wildcard ./nxdn/*.cpp)
CSRC_STD_F7=$(wildcard $(STD_LIB_F7)/*.c)
SYS_F7=$(wildcard $(SYS_DIR_F7)/*.c)
STARTUP_F7=$(wildcard $(STARTUP_DIR_F7)/*.c)
OBJ_F7=$(CXXSRC:./%.cpp=$(OBJDIR_F7)/%.o) $(CSRC_STD_F7:$(STD_LIB_F7)/%.c=$(OBJDIR_F7)/%.o) $(SYS_F7:$(SYS_DIR_F7)/%.c=$(OBJDIR_F7)/%.o) $(STARTUP_F7:$(STARTUP_DIR_F7)/%.c=$(OBJDIR_F7)/%.o)
OBJ_F767=$(CXXSRC:./%.cpp=$(OBJDIR_F767)/%.o) $(CSRC_STD_F7:$(STD_LIB_F7)/%.c=$(OBJDIR_F767)/%.o) $(SYS_F7:$(SYS_DIR_F7)/%.c=$(OBJDIR_F767)/%.o) $(STARTUP_F7:$(STARTUP_DIR_F7)/%.c=$(OBJDIR_F767)/%.o)

# MCU flags
MCFLAGS_F7=-mcpu=cortex-m7 -mthumb -mlittle-endian -mfpu=fpv5-sp-d16 -mfloat-abi=hard -mthumb-interwork

# Compile flags
DEFS_PI=-DUSE_HAL_DRIVER -DSTM32F722xx -DSTM32F7XX -DSTM32F7_PI -DHSE_VALUE=$(OSC) -DMADEBYMAKEFILE
DEFS_PI_767=-DUSE_HAL_DRIVER -DSTM32F767xx -DSTM32F7XX -DSTM32F7_PI -DHSE_VALUE=$(OSC) -DMADEBYMAKEFILE

# Build compiler flags
CFLAGS_F7=-c $(MCFLAGS_F7) $(INCLUDES_F7)
CXXFLAGS_F7=-c $(MCFLAGS_F7) $(INCLUDES_F7)

# Linker flags
LDFLAGS_F7 =-T stm32f722_link.ld $(MCFLAGS_F7) --specs=nosys.specs $(INCLUDES_LIBS_F7)
LDFLAGS_F7_D =-T stm32f722_link_debug.ld $(MCFLAGS_F7) --specs=nosys.specs $(INCLUDES_LIBS_F7)
LDFLAGS_F7_767 =-T stm32f767_link.ld $(MCFLAGS_F7) --specs=nosys.specs $(INCLUDES_LIBS_F7)
LDFLAGS_F7_767_D =-T stm32f767_link_debug.ld $(MCFLAGS_F7) --specs=nosys.specs $(INCLUDES_LIBS_F7)

# Common flags
CFLAGS=-Os -g -ffunction-sections -fdata-sections -fno-builtin -Wno-implicit -DCUSTOM_NEW -DNO_EXCEPTIONS
CXXFLAGS=-Os -g -fno-exceptions -ffunction-sections -fdata-sections -fno-builtin -fno-rtti -Wall -DCUSTOM_NEW -DNO_EXCEPTIONS
LDFLAGS=-Os -g --specs=nano.specs

# Build Rules
.PHONY: all f7 f7-debug clean

all: f7

f7: CFLAGS+=$(CFLAGS_F7) $(DEFS_PI)
f7: CXXFLAGS+=$(CXXFLAGS_F7) $(DEFS_PI)
f7: LDFLAGS+=$(LDFLAGS_F7)
f7: $(BINDIR)
f7: $(OBJDIR_F7)
f7: $(BINDIR)/$(BINBIN_F7)

f7-debug: CFLAGS+=$(CFLAGS_F7) $(DEFS_PI)
f7-debug: CXXFLAGS+=$(CXXFLAGS_F7) $(DEFS_PI)
f7-debug: LDFLAGS+=$(LDFLAGS_F7_D)
f7-debug: $(BINDIR)
f7-debug: $(OBJDIR_F7)
f7-debug: $(BINDIR)/$(BINBIN_F7)

f767: CFLAGS+=$(CFLAGS_F7) $(DEFS_PI_767)
f767: CXXFLAGS+=$(CXXFLAGS_F7) $(DEFS_PI_767)
f767: LDFLAGS+=$(LDFLAGS_F7_767)
f767: $(BINDIR)
f767: $(OBJDIR_F767)
f767: $(BINDIR)/$(BINBIN_F767)

f767-debug: CFLAGS+=$(CFLAGS_F7) $(DEFS_PI_767)
f767-debug: CXXFLAGS+=$(CXXFLAGS_F7) $(DEFS_PI_767)
f767-debug: LDFLAGS+=$(LDFLAGS_F7_767_D)
f767-debug: $(BINDIR)
f767-debug: $(OBJDIR_F767)
f767-debug: $(BINDIR)/$(BINBIN_F767)

$(BINDIR):
mkdir $@
$(OBJDIR_F7):
mkdir $@
mkdir $@/dmr
mkdir $@/p25
mkdir $@/nxdn
$(OBJDIR_F767):
mkdir $@
mkdir $@/dmr
mkdir $@/p25
mkdir $@/nxdn

$(BINDIR)/$(BINBIN_F7): $(BINDIR)/$(BINELF_F7)
$(CP) -O binary $< $@
$(BINDIR)/$(BINELF_F7): $(OBJ_F7)
$(CXX) $(OBJ_F7) $(LDFLAGS) -o $@
$(SIZE) $(BINDIR)/$(BINELF_F7)
$(BINDIR)/$(BINBIN_F767): $(BINDIR)/$(BINELF_F767)
$(CP) -O binary $< $@
$(BINDIR)/$(BINELF_F767): $(OBJ_F767)
$(CXX) $(OBJ_F767) $(LDFLAGS) -o $@
$(SIZE) $(BINDIR)/$(BINELF_F767)

$(OBJDIR_F7)/%.o: ./%.cpp
$(CXX) $(CXXFLAGS) $< -o $@
$(OBJDIR_F7)/%.o: $(STD_LIB_F7)/%.c
$(CC) $(CFLAGS) $< -o $@
$(OBJDIR_F7)/%.o: $(SYS_DIR_F7)/%.c
$(CC) $(CFLAGS) $< -o $@
$(OBJDIR_F7)/%.o: $(STARTUP_DIR_F7)/%.c
$(CC) $(CFLAGS) $< -o $@
$(OBJDIR_F767)/%.o: ./%.cpp
$(CXX) $(CXXFLAGS) $< -o $@
$(OBJDIR_F767)/%.o: $(STD_LIB_F7)/%.c
$(CC) $(CFLAGS) $< -o $@
$(OBJDIR_F767)/%.o: $(SYS_DIR_F7)/%.c
$(CC) $(CFLAGS) $< -o $@
$(OBJDIR_F767)/%.o: $(STARTUP_DIR_F7)/%.c
$(CC) $(CFLAGS) $< -o $@

clean-objs:
test ! -d $(OBJDIR_F7) || rm -rf $(OBJDIR_F7)
test ! -d $(OBJDIR_F767) || rm -rf $(OBJDIR_F767)
clean:
test ! -d $(OBJDIR_F7) || rm -rf $(OBJDIR_F7)
test ! -d $(OBJDIR_F767) || rm -rf $(OBJDIR_F767)
rm -f $(BINDIR)/*.bin $(BINDIR)/*.elf
1 change: 1 addition & 0 deletions STM32F7XX_Platform
Submodule STM32F7XX_Platform added at 14cc10
2 changes: 1 addition & 1 deletion STM_UART.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Copyright (c) 2020 Geoffrey Merck, F4FXL - KC3FRA
*
*/
#if defined(STM32F4XX)
#if defined(STM32F4XX) || defined(STM32F7XX)

#include "STM_UART.h"

Expand Down
5 changes: 4 additions & 1 deletion STM_UART.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @file STM_UART.cpp
* @ingroup modem_fw
*/
#if defined(STM32F4XX)
#if defined(STM32F4XX) || defined(STM32F7XX)
#if !defined(__STM_UART_H__)
#define __STM_UART_H__

Expand All @@ -23,6 +23,9 @@
#if defined(STM32F4XX)
#include "stm32f4xx.h"
#endif
#if defined(STM32F7XX)
#include "stm32f7xx.h"
#endif

const uint16_t BUFFER_SIZE = 2048U; //needs to be a power of 2 !
const uint16_t BUFFER_MASK = BUFFER_SIZE - 1;
Expand Down
5 changes: 5 additions & 0 deletions SerialSTM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@
#include "SerialPort.h"
#include "STM_UART.h"

#if defined(STM32F4XX) || defined(STM32F7XX)
#if defined(STM32F4XX)
#include <stm32f4xx_flash.h>
#endif
#if defined(STM32F7XX)
#include <stm32f7xx_flash.h>
#endif

// ---------------------------------------------------------------------------
// Constants
Expand Down
Loading

0 comments on commit c81ba8e

Please sign in to comment.