diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..efa4aea --- /dev/null +++ b/.gitattributes @@ -0,0 +1,57 @@ +# +# .gitattributes +# + +## GENERIC ## + +* text=auto + + +## SOURCE CODE ## + +*.c eol=lf diff=cpp +*.h eol=lf diff=cpp +*.cpp eol=lf diff=cpp +*.hpp eol=lf diff=cpp +*.cxx eol=lf diff=cpp +*.hxx eol=lf diff=cpp +*.cc eol=lf diff=cpp +*.hh eol=lf diff=cpp +*.c++ eol=lf diff=cpp +*.h++ eol=lf diff=cpp +*.ino eol=lf diff=cpp +*.pde eol=lf diff=cpp + + +## SCRIPTS ## + +*.sh eol=lf +*.bat eol=crlf +*.cmd eol=crlf +*.ps1 eol=crlf +*.py eol=lf diff=python +*.ld eol=lf +Makefile eol=lf +*.mk eol=lf +*.make eol=lf +*.makefile eol=lf + + +## TEXT & MARKUP ## + +*.txt eol=crlf +*.log eol=crlf +*.md eol=crlf diff=markdown +*.mkdn eol=crlf diff=markdown +*.markdown eol=crlf diff=markdown +*.rst eol=crlf +*.adoc eol=crlf +README eol=lf +LICENSE eol=lf +INSTALL eol=lf +COPYING eol=lf +HOWTO eol=lf +BUILD eol=lf +HACKING eol=lf +CHANGES eol=lf +CHANGELOG eol=lf diff --git a/.gitignore b/.gitignore index 2009393..b227053 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,30 @@ +# +# .gitignore +# -*.o +## BACKUP & TEMPORARY FILES ## -bin/ +*~ +*.bak +*.tmp +*.swp + + +## BUILD ARTIFACTS ## +*.o +*.elf +*.hex +*.bin +*.map +*.lst +bin/ +obj_f1/ +obj_f4/ +obj_f7/ GitVersion\.h + +## IDEs ## + .vscode/ diff --git a/Makefile b/Makefile index c73834e..35fc954 100644 --- a/Makefile +++ b/Makefile @@ -16,115 +16,156 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # MMDVM source files -MMDVM_HS_PATH=. +MMDVM_HS_PATH := . + + +# Optimization Level +OPTLVL := s + +# Debug Level +DBGLVL := 0 + +# C Standard +CSTD := gnu11 + +# C++ Standard +CXXSTD := gnu++14 + +# sleep delays for multi-stage flashing processes +STLINK_SLEEP_DELAY := 3 +SERIAL_SLEEP_DELAY := 3 + # STM32 library paths -F1_LIB_PATH=./STM32F10X_Lib -F4_LIB_PATH=./STM32F4XX_Lib -F7_LIB_PATH=./STM32F7XX_Lib +F1_LIB_PATH := ./STM32F10X_Lib +F4_LIB_PATH := ./STM32F4XX_Lib +F7_LIB_PATH := ./STM32F7XX_Lib + # MCU external clock frequency (Hz) -CLK_PI_F4=12000000 -CLK_DEF=8000000 +CLK_PI_F4 := 12000000 +CLK_DEF := 8000000 + # Directory Structure -BINDIR=bin -OBJDIR_F1=obj_f1 -OBJDIR_F4=obj_f4 -OBJDIR_F7=obj_f7 +BINDIR := bin +OBJDIR_F1 := obj_f1 +OBJDIR_F4 := obj_f4 +OBJDIR_F7 := obj_f7 + # Output files -BINELF_F1=mmdvm_f1.elf -BINHEX_F1=mmdvm_f1.hex -BINBIN_F1=mmdvm_f1.bin -BINELF_F1BL=mmdvm_f1bl.elf -BINHEX_F1BL=mmdvm_f1bl.hex -BINBIN_F1BL=mmdvm_f1bl.bin -BINELF_F1NOBL=mmdvm_f1nobl.elf -BINHEX_F1NOBL=mmdvm_f1nobl.hex -BINBIN_F1NOBL=mmdvm_f1nobl.bin -BINELF_F4=mmdvm_f4.elf -BINHEX_F4=mmdvm_f4.hex -BINBIN_F4=mmdvm_f4.bin -BINELF_F7=mmdvm_f7.elf -BINHEX_F7=mmdvm_f7.hex -BINBIN_F7=mmdvm_f7.bin +BINELF_F1 = mmdvm_f1.elf +BINHEX_F1 = mmdvm_f1.hex +BINBIN_F1 = mmdvm_f1.bin + +BINELF_F1BL = mmdvm_f1bl.elf +BINHEX_F1BL = mmdvm_f1bl.hex +BINBIN_F1BL = mmdvm_f1bl.bin + +BINELF_F1NOBL = mmdvm_f1nobl.elf +BINHEX_F1NOBL = mmdvm_f1nobl.hex +BINBIN_F1NOBL = mmdvm_f1nobl.bin + +BINELF_F4 = mmdvm_f4.elf +BINHEX_F4 = mmdvm_f4.hex +BINBIN_F4 = mmdvm_f4.bin + +BINELF_F7 = mmdvm_f7.elf +BINHEX_F7 = mmdvm_f7.hex +BINBIN_F7 = mmdvm_f7.bin + # Header directories -INC_F1= . $(F1_LIB_PATH)/CMSIS/ $(F1_LIB_PATH)/Device/ $(F1_LIB_PATH)/STM32F10x_StdPeriph_Driver/inc/ $(F1_LIB_PATH)/usb/inc/ -INCLUDES_F1=$(INC_F1:%=-I%) -INC_F4= . $(F4_LIB_PATH)/CMSIS/Include/ $(F4_LIB_PATH)/Device/ $(F4_LIB_PATH)/STM32F4xx_StdPeriph_Driver/include/ -INCLUDES_F4=$(INC_F4:%=-I%) -INC_F7= . $(F7_LIB_PATH)/CMSIS/Include/ $(F7_LIB_PATH)/Device/ $(F7_LIB_PATH)/STM32F7xx_StdPeriph_Driver/inc/ -INCLUDES_F7=$(INC_F7:%=-I%) +INC_F1 := . +INC_F1 += $(F1_LIB_PATH)/CMSIS/ +INC_F1 += $(F1_LIB_PATH)/Device/ +INC_F1 += $(F1_LIB_PATH)/STM32F10x_StdPeriph_Driver/inc/ +INC_F1 += $(F1_LIB_PATH)/usb/inc/ +INCLUDES_F1 := $(INC_F1:%=-I%) + +INC_F4 := . +INC_F4 += $(F4_LIB_PATH)/CMSIS/Include/ +INC_F4 += $(F4_LIB_PATH)/Device/ +INC_F4 += $(F4_LIB_PATH)/STM32F4xx_StdPeriph_Driver/include/ +INCLUDES_F4 := $(INC_F4:%=-I%) + +INC_F7 := . +INC_F7 += $(F7_LIB_PATH)/CMSIS/Include/ +INC_F7 += $(F7_LIB_PATH)/Device/ +INC_F7 += $(F7_LIB_PATH)/STM32F7xx_StdPeriph_Driver/inc/ +INCLUDES_F7 := $(INC_F7:%=-I%) + # CMSIS libraries -INCLUDES_LIBS_F1= -INCLUDES_LIBS_F4=$(F4_LIB_PATH)/CMSIS/Lib/GCC/libarm_cortexM4lf_math.a -INCLUDES_LIBS_F7=$(F7_LIB_PATH)/CMSIS/Lib/GCC/libarm_cortexM7lfsp_math.a +INCLUDES_LIBS_F1 := +INCLUDES_LIBS_F4 := $(F4_LIB_PATH)/CMSIS/Lib/GCC/libarm_cortexM4lf_math.a +INCLUDES_LIBS_F7 := $(F7_LIB_PATH)/CMSIS/Lib/GCC/libarm_cortexM7lfsp_math.a + # STM32F1 Standard Peripheral Libraries source path -STD_LIB_F1=$(F1_LIB_PATH)/STM32F10x_StdPeriph_Driver/src +STD_LIB_F1 := $(F1_LIB_PATH)/STM32F10x_StdPeriph_Driver/src # STM32F1 USB support source path -USB_F1=$(F1_LIB_PATH)/usb +USB_F1 := $(F1_LIB_PATH)/usb # STM32F4 Standard Peripheral Libraries source path -STD_LIB_F4=$(F4_LIB_PATH)/STM32F4xx_StdPeriph_Driver/source +STD_LIB_F4 = $(F4_LIB_PATH)/STM32F4xx_StdPeriph_Driver/source # STM32F7 Standard Peripheral Libraries source path -STD_LIB_F7=$(F7_LIB_PATH)/STM32F7xx_StdPeriph_Driver/src +STD_LIB_F7 = $(F7_LIB_PATH)/STM32F7xx_StdPeriph_Driver/src # STM32F1 system source path -SYS_DIR_F1=$(F1_LIB_PATH)/Device -STARTUP_DIR_F1=$(F1_LIB_PATH)/Device/startup +SYS_DIR_F1 = $(F1_LIB_PATH)/Device +STARTUP_DIR_F1 = $(F1_LIB_PATH)/Device/startup # STM32F4 system source path -SYS_DIR_F4=$(F4_LIB_PATH)/Device -STARTUP_DIR_F4=$(F4_LIB_PATH)/Device/startup +SYS_DIR_F4 = $(F4_LIB_PATH)/Device +STARTUP_DIR_F4 = $(F4_LIB_PATH)/Device/startup # STM32F7 system source path -SYS_DIR_F7=$(F7_LIB_PATH)/Device -STARTUP_DIR_F7=$(F7_LIB_PATH)/Device/startup +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 +CROSS := arm-none-eabi- +CC := $(CROSS)gcc +CXX := $(CROSS)g++ +LD := $(CROSS)ld +AR := $(CROSS)ar +AS := $(CROSS)as +CP := $(CROSS)objcopy +OD := $(CROSS)objdump +NM := $(CROSS)nm +SIZE := $(CROSS)size +A2L := $(CROSS)addr2line # Configure vars depending on OS ifeq ($(OS),Windows_NT) - CLEANCMD=del /S *.o *.hex *.bin *.elf - MDDIRS=md $@ - DFU_UTIL=./$(F1_LIB_PATH)/utils/win/dfu-util.exe - STM32FLASH=./$(F1_LIB_PATH)/utils/win/stm32flash.exe + CLEANCMD := del /S *.o *.hex *.bin *.elf + MDDIRS := md $@ + DFU_UTIL := ./$(F1_LIB_PATH)/utils/win/dfu-util.exe + STM32FLASH := ./$(F1_LIB_PATH)/utils/win/stm32flash.exe else - CLEANCMD=rm -f $(OBJ_F1BL) $(OBJ_F4) $(OBJ_F7) $(BINDIR)/*.hex $(BINDIR)/mmdvm_f1.bin $(BINDIR)/mmdvm_f1bl.bin $(BINDIR)/mmdvm_f1nobl.bin $(BINDIR)/*.elf - MDDIRS=mkdir $@ + CLEANCMD := rm -f $(OBJ_F1) $(OBJ_F1BL) $(OBJ_F4) $(OBJ_F7) $(BINDIR)/*.hex $(BINDIR)/mmdvm_f1.bin $(BINDIR)/mmdvm_f1bl.bin $(BINDIR)/mmdvm_f1nobl.bin $(BINDIR)/*.elf + MDDIRS := mkdir $@ ifeq ($(shell uname -s),Linux) - ST_FLASH_ON_PATH=$(shell which st-flash) - ST_FLASH_IS_ON_PATH=$(.SHELLSTATUS) + ST_FLASH_ON_PATH = $(shell which st-flash) + ST_FLASH_IS_ON_PATH = $(.SHELLSTATUS) ifeq ($(shell uname -m),x86_64) - DFU_RST=./$(F1_LIB_PATH)/utils/linux64/upload-reset - DFU_UTIL=./$(F1_LIB_PATH)/utils/linux64/dfu-util - DFU_RST=./$(F1_LIB_PATH)/utils/linux64/upload-reset - DFU_UTIL=./$(F1_LIB_PATH)/utils/linux64/dfu-util + DFU_RST = ./$(F1_LIB_PATH)/utils/linux64/upload-reset + DFU_UTIL = ./$(F1_LIB_PATH)/utils/linux64/dfu-util + DFU_RST = ./$(F1_LIB_PATH)/utils/linux64/upload-reset + DFU_UTIL = ./$(F1_LIB_PATH)/utils/linux64/dfu-util ifeq ($(ST_FLASH_IS_ON_PATH),0) - ST_FLASH=$(ST_FLASH_ON_PATH) - ST_FLASH_OPTS=--flash=128k + ST_FLASH = $(ST_FLASH_ON_PATH) + ST_FLASH_OPTS = --flash=128k else - ST_FLASH=./$(F1_LIB_PATH)/utils/linux64/st-flash - ST_FLASH_OPTS= - endif - STM32FLASH=./$(F1_LIB_PATH)/utils/linux64/stm32flash + ST_FLASH = ./$(F1_LIB_PATH)/utils/linux64/st-flash + ST_FLASH_OPTS = + endif + STM32FLASH = ./$(F1_LIB_PATH)/utils/linux64/stm32flash else ifeq ($(shell uname -m),armv7l) DFU_RST=./$(F1_LIB_PATH)/utils/rpi32/upload-reset DFU_UTIL=./$(F1_LIB_PATH)/utils/rpi32/dfu-util @@ -142,117 +183,133 @@ else ST_FLASH=$(ST_FLASH_ON_PATH) ST_FLASH_OPTS=--flash=128k else - ST_FLASH=./$(F1_LIB_PATH)/utils/linux/st-flash - ST_FLASH_OPTS= - endif + ST_FLASH = ./$(F1_LIB_PATH)/utils/linux/st-flash + ST_FLASH_OPTS = + endif STM32FLASH=./$(F1_LIB_PATH)/utils/linux/stm32flash endif endif ifeq ($(shell uname -s),Darwin) - DFU_RST=./$(F1_LIB_PATH)/utils/macosx/upload-reset - DFU_UTIL=./$(F1_LIB_PATH)/utils/macosx/dfu-util - ST_FLASH=./$(F1_LIB_PATH)/utils/macosx/st-flash - STM32FLASH=./$(F1_LIB_PATH)/utils/macosx/stm32flash + DFU_RST = ./$(F1_LIB_PATH)/utils/macosx/upload-reset + DFU_UTIL = ./$(F1_LIB_PATH)/utils/macosx/dfu-util + ST_FLASH = ./$(F1_LIB_PATH)/utils/macosx/st-flash + STM32FLASH = ./$(F1_LIB_PATH)/utils/macosx/stm32flash endif endif # Default reference oscillator frequencies ifndef $(OSC) ifeq ($(MAKECMDGOALS),pi-f4) - OSC=$(CLK_PI_F4) + OSC := $(CLK_PI_F4) else - OSC=$(CLK_DEF) + OSC := $(CLK_DEF) endif endif # Build object lists -CXXSRC=$(wildcard $(MMDVM_HS_PATH)/*.cpp) -CSRC_STD_F1=$(wildcard $(STD_LIB_F1)/*.c) -SYS_F1=$(wildcard $(SYS_DIR_F1)/*.c) -STARTUP_F1=$(wildcard $(STARTUP_DIR_F1)/*.c) -CXX_USB_F1=$(wildcard $(USB_F1)/*.cpp) -C_USB_F1=$(wildcard $(USB_F1)/*.c) -CSRC_STD_F4=$(wildcard $(STD_LIB_F4)/*.c) -SYS_F4=$(wildcard $(SYS_DIR_F4)/*.c) -STARTUP_F4=$(wildcard $(STARTUP_DIR_F4)/*.c) -CSRC_STD_F7=$(wildcard $(STD_LIB_F7)/*.c) -SYS_F7=$(wildcard $(SYS_DIR_F7)/*.c) -STARTUP_F7=$(wildcard $(STARTUP_DIR_F7)/*.c) -OBJ_F1=$(CXXSRC:$(MMDVM_HS_PATH)/%.cpp=$(OBJDIR_F1)/%.o) $(CSRC_STD_F1:$(STD_LIB_F1)/%.c=$(OBJDIR_F1)/%.o) $(SYS_F1:$(SYS_DIR_F1)/%.c=$(OBJDIR_F1)/%.o) $(STARTUP_F1:$(STARTUP_DIR_F1)/%.c=$(OBJDIR_F1)/%.o) -OBJ_F1BL=$(CXXSRC:$(MMDVM_HS_PATH)/%.cpp=$(OBJDIR_F1)/%.o) $(CSRC_STD_F1:$(STD_LIB_F1)/%.c=$(OBJDIR_F1)/%.o) $(SYS_F1:$(SYS_DIR_F1)/%.c=$(OBJDIR_F1)/%.o) $(STARTUP_F1:$(STARTUP_DIR_F1)/%.c=$(OBJDIR_F1)/%.o) $(CXX_USB_F1:$(USB_F1)/%.cpp=$(OBJDIR_F1)/%.o) $(C_USB_F1:$(USB_F1)/%.c=$(OBJDIR_F1)/%.o) -OBJ_F4=$(CXXSRC:$(MMDVM_HS_PATH)/%.cpp=$(OBJDIR_F4)/%.o) $(CSRC_STD_F4:$(STD_LIB_F4)/%.c=$(OBJDIR_F4)/%.o) $(SYS_F4:$(SYS_DIR_F4)/%.c=$(OBJDIR_F4)/%.o) $(STARTUP_F4:$(STARTUP_DIR_F4)/%.c=$(OBJDIR_F4)/%.o) -OBJ_F7=$(CXXSRC:$(MMDVM_HS_PATH)/%.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) +CXXSRC := $(wildcard $(MMDVM_HS_PATH)/*.cpp) +CSRC_STD_F1 := $(wildcard $(STD_LIB_F1)/*.c) +SYS_F1 := $(wildcard $(SYS_DIR_F1)/*.c) +STARTUP_F1 := $(wildcard $(STARTUP_DIR_F1)/*.c) +CXX_USB_F1 := $(wildcard $(USB_F1)/*.cpp) +C_USB_F1 := $(wildcard $(USB_F1)/*.c) +CSRC_STD_F4 := $(wildcard $(STD_LIB_F4)/*.c) +SYS_F4 := $(wildcard $(SYS_DIR_F4)/*.c) +STARTUP_F4 := $(wildcard $(STARTUP_DIR_F4)/*.c) +CSRC_STD_F7 := $(wildcard $(STD_LIB_F7)/*.c) +SYS_F7 := $(wildcard $(SYS_DIR_F7)/*.c) +STARTUP_F7 := $(wildcard $(STARTUP_DIR_F7)/*.c) + +OBJ_F1 := $(CXXSRC:$(MMDVM_HS_PATH)/%.cpp=$(OBJDIR_F1)/%.o) $(CSRC_STD_F1:$(STD_LIB_F1)/%.c=$(OBJDIR_F1)/%.o) $(SYS_F1:$(SYS_DIR_F1)/%.c=$(OBJDIR_F1)/%.o) $(STARTUP_F1:$(STARTUP_DIR_F1)/%.c=$(OBJDIR_F1)/%.o) +OBJ_F1BL := $(CXXSRC:$(MMDVM_HS_PATH)/%.cpp=$(OBJDIR_F1)/%.o) $(CSRC_STD_F1:$(STD_LIB_F1)/%.c=$(OBJDIR_F1)/%.o) $(SYS_F1:$(SYS_DIR_F1)/%.c=$(OBJDIR_F1)/%.o) $(STARTUP_F1:$(STARTUP_DIR_F1)/%.c=$(OBJDIR_F1)/%.o) $(CXX_USB_F1:$(USB_F1)/%.cpp=$(OBJDIR_F1)/%.o) $(C_USB_F1:$(USB_F1)/%.c=$(OBJDIR_F1)/%.o) +OBJ_F4 := $(CXXSRC:$(MMDVM_HS_PATH)/%.cpp=$(OBJDIR_F4)/%.o) $(CSRC_STD_F4:$(STD_LIB_F4)/%.c=$(OBJDIR_F4)/%.o) $(SYS_F4:$(SYS_DIR_F4)/%.c=$(OBJDIR_F4)/%.o) $(STARTUP_F4:$(STARTUP_DIR_F4)/%.c=$(OBJDIR_F4)/%.o) +OBJ_F7 := $(CXXSRC:$(MMDVM_HS_PATH)/%.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) + # MCU flags -MCFLAGS_F1=-mcpu=cortex-m3 -march=armv7-m -mthumb -Wall -Wextra -MCFLAGS_F4=-mcpu=cortex-m4 -mthumb -mlittle-endian -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb-interwork -MCFLAGS_F7=-mcpu=cortex-m7 -mthumb -mlittle-endian -mfpu=fpv5-sp-d16 -mfloat-abi=hard -mthumb-interwork +MCFLAGS_F1 := -mcpu=cortex-m3 -march=armv7-m -mthumb -Wall -Wextra +MCFLAGS_F4 := -mcpu=cortex-m4 -mthumb -mlittle-endian -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb-interwork +MCFLAGS_F7 := -mcpu=cortex-m7 -mthumb -mlittle-endian -mfpu=fpv5-sp-d16 -mfloat-abi=hard -mthumb-interwork + # Compile flags -DEFS_F1_HS=-DUSE_STDPERIPH_DRIVER -DSTM32F10X_MD -DHSE_VALUE=$(OSC) -DVECT_TAB_OFFSET=0x0 -DMADEBYMAKEFILE -DEFS_F1_HS_BL=-DUSE_STDPERIPH_DRIVER -DSTM32F10X_MD -DHSE_VALUE=$(OSC) -DVECT_TAB_OFFSET=0x2000 -DMADEBYMAKEFILE +DEFS_F1_HS := -DUSE_STDPERIPH_DRIVER -DSTM32F10X_MD -DHSE_VALUE=$(OSC) -DVECT_TAB_OFFSET=0x0 -DMADEBYMAKEFILE +DEFS_F1_HS_BL := -DUSE_STDPERIPH_DRIVER -DSTM32F10X_MD -DHSE_VALUE=$(OSC) -DVECT_TAB_OFFSET=0x2000 -DMADEBYMAKEFILE + # STM32F446 Pi-Hat board: -DEFS_PI_F4=-DUSE_STDPERIPH_DRIVER -DSTM32F4XX -DSTM32F446xx -DSTM32F4_PI -DHSE_VALUE=$(OSC) -DMADEBYMAKEFILE +DEFS_PI_F4 := -DUSE_STDPERIPH_DRIVER -DSTM32F4XX -DSTM32F446xx -DSTM32F4_PI -DHSE_VALUE=$(OSC) -DMADEBYMAKEFILE + # STM32F4 Nucleo-64 F446RE board: -DEFS_F446=-DUSE_STDPERIPH_DRIVER -DSTM32F4XX -DSTM32F446xx -DSTM32F4_NUCLEO -DHSE_VALUE=$(OSC) -DMADEBYMAKEFILE +DEFS_F446 := -DUSE_STDPERIPH_DRIVER -DSTM32F4XX -DSTM32F446xx -DSTM32F4_NUCLEO -DHSE_VALUE=$(OSC) -DMADEBYMAKEFILE + # STM32F7 Nucleo-144 F767ZI board: -DEFS_F767=-DUSE_HAL_DRIVER -DSTM32F767xx -DSTM32F7XX -DSTM32F7_NUCLEO -DHSE_VALUE=$(OSC) -DMADEBYMAKEFILE +DEFS_F767 := -DUSE_HAL_DRIVER -DSTM32F767xx -DSTM32F7XX -DSTM32F7_NUCLEO -DHSE_VALUE=$(OSC) -DMADEBYMAKEFILE + # Build compiler flags -CFLAGS_F1=-c $(MCFLAGS_F1) $(INCLUDES_F1) -CXXFLAGS_F1=-c $(MCFLAGS_F1) $(INCLUDES_F1) -CFLAGS_F4=-c $(MCFLAGS_F4) $(INCLUDES_F4) -CXXFLAGS_F4=-c $(MCFLAGS_F4) $(INCLUDES_F4) -CFLAGS_F7=-c $(MCFLAGS_F7) $(INCLUDES_F7) -CXXFLAGS_F7=-c $(MCFLAGS_F7) $(INCLUDES_F7) +CFLAGS_F1 := -c $(MCFLAGS_F1) $(INCLUDES_F1) +CXXFLAGS_F1 := -c $(MCFLAGS_F1) $(INCLUDES_F1) +CFLAGS_F4 := -c $(MCFLAGS_F4) $(INCLUDES_F4) +CXXFLAGS_F4 := -c $(MCFLAGS_F4) $(INCLUDES_F4) +CFLAGS_F7 := -c $(MCFLAGS_F7) $(INCLUDES_F7) +CXXFLAGS_F7 := -c $(MCFLAGS_F7) $(INCLUDES_F7) + # Linker flags -LDFLAGS_F1_N =-T normal.ld $(MCFLAGS_F1) $(INCLUDES_LIBS_F1) -LDFLAGS_F1_BL =-T bootloader.ld $(MCFLAGS_F1) $(INCLUDES_LIBS_F1) -LDFLAGS_F4 =-T stm32f4xx_link.ld $(MCFLAGS_F4) $(INCLUDES_LIBS_F4) -LDFLAGS_F7 =-T stm32f7xx_link.ld $(MCFLAGS_F7) $(INCLUDES_LIBS_F7) +LDFLAGS_F1_N := -T normal.ld $(MCFLAGS_F1) $(INCLUDES_LIBS_F1) +LDFLAGS_F1_BL := -T bootloader.ld $(MCFLAGS_F1) $(INCLUDES_LIBS_F1) +LDFLAGS_F4 := -T stm32f4xx_link.ld $(MCFLAGS_F4) $(INCLUDES_LIBS_F4) +LDFLAGS_F7 := -T stm32f7xx_link.ld $(MCFLAGS_F7) $(INCLUDES_LIBS_F7) + # Common flags -CFLAGS=-Os -ffunction-sections -fdata-sections -nostdlib -DCUSTOM_NEW -DNO_EXCEPTIONS -Wno-unused-parameter -nostdlib -CXXFLAGS=-Os -fno-exceptions -ffunction-sections -fdata-sections -nostdlib -fno-rtti -DCUSTOM_NEW -DNO_EXCEPTIONS -Wno-unused-parameter -LDFLAGS=-Os --specs=nano.specs --specs=nosys.specs +DEFINES := -DCUSTOM_NEW +DEFINES += -DNO_EXCEPTIONS + +CFLAGS := -O$(OPTLVL) -ffunction-sections -fdata-sections -nostdlib $(DEFINES) -Wno-unused-parameter -nostdlib +CXXFLAGS := -O$(OPTLVL) -fno-exceptions -ffunction-sections -fdata-sections -nostdlib -fno-rtti $(DEFINES) -Wno-unused-parameter +LDFLAGS := -O$(OPTLVL) --specs=nano.specs --specs=nosys.specs + + # Build Rules .PHONY: all release_f1 release_f4 release_f7 hs bl nobl pi-f4 f446 f767 clean all: hs -pi-f4: CFLAGS+=$(CFLAGS_F4) $(DEFS_PI_F4) -pi-f4: CXXFLAGS+=$(CXXFLAGS_F4) $(DEFS_PI_F4) -pi-f4: LDFLAGS+=$(LDFLAGS_F4) +pi-f4: CFLAGS += $(CFLAGS_F4) $(DEFS_PI_F4) +pi-f4: CXXFLAGS += $(CXXFLAGS_F4) $(DEFS_PI_F4) +pi-f4: LDFLAGS += $(LDFLAGS_F4) pi-f4: release_f4 -f446: CFLAGS+=$(CFLAGS_F4) $(DEFS_F446) -f446: CXXFLAGS+=$(CXXFLAGS_F4) $(DEFS_F446) -f446: LDFLAGS+=$(LDFLAGS_F4) +f446: CFLAGS += $(CFLAGS_F4) $(DEFS_F446) +f446: CXXFLAGS += $(CXXFLAGS_F4) $(DEFS_F446) +f446: LDFLAGS += $(LDFLAGS_F4) f446: release_f4 -f767: CFLAGS+=$(CFLAGS_F7) $(DEFS_F767) -f767: CXXFLAGS+=$(CXXFLAGS_F7) $(DEFS_F767) -f767: LDFLAGS+=$(LDFLAGS_F7) +f767: CFLAGS += $(CFLAGS_F7) $(DEFS_F767) +f767: CXXFLAGS += $(CXXFLAGS_F7) $(DEFS_F767) +f767: LDFLAGS += $(LDFLAGS_F7) f767: release_f7 -hs: CFLAGS+=$(CFLAGS_F1) $(DEFS_F1_HS) -hs: CXXFLAGS+=$(CXXFLAGS_F1) $(DEFS_F1_HS) -hs: LDFLAGS+=$(LDFLAGS_F1_N) +hs: CFLAGS += $(CFLAGS_F1) $(DEFS_F1_HS) +hs: CXXFLAGS += $(CXXFLAGS_F1) $(DEFS_F1_HS) +hs: LDFLAGS += $(LDFLAGS_F1_N) hs: release_f1 -bl: CFLAGS+=$(CFLAGS_F1) $(DEFS_F1_HS_BL) -bl: CXXFLAGS+=$(CXXFLAGS_F1) $(DEFS_F1_HS_BL) -bl: LDFLAGS+=$(LDFLAGS_F1_BL) +bl: CFLAGS += $(CFLAGS_F1) $(DEFS_F1_HS_BL) +bl: CXXFLAGS += $(CXXFLAGS_F1) $(DEFS_F1_HS_BL) +bl: LDFLAGS += $(LDFLAGS_F1_BL) bl: release_f1bl -nobl: CFLAGS+=$(CFLAGS_F1) $(DEFS_F1_HS) -nobl: CXXFLAGS+=$(CXXFLAGS_F1) $(DEFS_F1_HS) -nobl: LDFLAGS+=$(LDFLAGS_F1_N) +nobl: CFLAGS += $(CFLAGS_F1) $(DEFS_F1_HS) +nobl: CXXFLAGS += $(CXXFLAGS_F1) $(DEFS_F1_HS) +nobl: LDFLAGS += $(LDFLAGS_F1_N) nobl: release_f1nobl + + release_f1: GitVersion.h release_f1: $(BINDIR) release_f1: $(OBJDIR_F1) @@ -283,6 +340,8 @@ release_f7: $(OBJDIR_F7) release_f7: $(BINDIR)/$(BINHEX_F7) release_f7: $(BINDIR)/$(BINBIN_F7) + + $(BINDIR): $(MDDIRS) @@ -416,42 +475,53 @@ $(OBJDIR_F1)/%.o: $(USB_F1)/%.c $(CC) $(CFLAGS) $< -o $@ @echo "Compiled "$<"!\n" + clean: + @echo "Cleaning project...\n" $(CLEANCMD) $(RM) GitVersion.h + stlink: $(ST_FLASH) $(ST_FLASH_OPTS) write bin/$(BINBIN_F1) 0x8000000 + stlink-nobl: $(ST_FLASH) $(ST_FLASH_OPTS) write bin/$(BINBIN_F1NOBL) 0x8000000 + stlink-bl: $(ST_FLASH) $(ST_FLASH_OPTS) write $(F1_LIB_PATH)/utils/bootloader/generic_boot20_pc13_long_rst.bin 0x8000000 - sleep 3 + sleep $(STLINK_SLEEP_DELAY) $(ST_FLASH) $(ST_FLASH_OPTS) write bin/$(BINBIN_F1BL) 0x8002000 + stlink-bl-old: $(ST_FLASH) $(ST_FLASH_OPTS) write $(F1_LIB_PATH)/utils/bootloader/generic_boot20_pc13.bin 0x8000000 - sleep 3 + sleep $(STLINK_SLEEP_DELAY) $(ST_FLASH) $(ST_FLASH_OPTS) write bin/$(BINBIN_F1BL) 0x8002000 + serial: $(STM32FLASH) -v -w bin/$(BINBIN_F1) -g 0x0 $(devser) + serial-nobl: $(STM32FLASH) -v -w bin/$(BINBIN_F1NOBL) -g 0x0 $(devser) + serial-bl: $(STM32FLASH) -v -w $(F1_LIB_PATH)/utils/bootloader/generic_boot20_pc13_long_rst.bin -g 0x0 $(devser) - sleep 3 + sleep $(SERIAL_SLEEP_DELAY) $(STM32FLASH) -v -w bin/$(BINBIN_F1BL) -g 0x0 -S 0x08002000 $(devser) + serial-bl-old: $(STM32FLASH) -v -w $(F1_LIB_PATH)/utils/bootloader/generic_boot20_pc13.bin -g 0x0 $(devser) - sleep 3 + sleep $(SERIAL_SLEEP_DELAY) $(STM32FLASH) -v -w bin/$(BINBIN_F1BL) -g 0x0 -S 0x08002000 $(devser) + nano-hotspot: ifneq ($(wildcard /usr/local/bin/stm32flash),) /usr/local/bin/stm32flash -v -w bin/$(BINBIN_F1) -g 0x0 -R -i 200,-3,3:-200,3 /dev/ttyAMA0 @@ -461,6 +531,7 @@ ifneq ($(wildcard /usr/bin/stm32flash),) /usr/bin/stm32flash -v -w bin/$(BINBIN_F1) -g 0x0 -R -i 200,-3,3:-200,3 /dev/ttyAMA0 endif + nano-dv: ifneq ($(wildcard /usr/local/bin/stm32flash),) /usr/local/bin/stm32flash -v -w bin/$(BINBIN_F1) -g 0x0 -R -i 66,-67,67:-66,67 /dev/ttyAMA0 @@ -470,6 +541,7 @@ ifneq ($(wildcard /usr/bin/stm32flash),) /usr/bin/stm32flash -v -w bin/$(BINBIN_F1) -g 0x0 -R -i 66,-67,67:-66,67 /dev/ttyAMA0 endif + d2rg_mmdvm_hs: ifneq ($(wildcard /usr/local/bin/stm32flash),) /usr/local/bin/stm32flash -v -w bin/$(BINBIN_F1) -g 0x0 -R -i 23,-22,22:-23,22 /dev/ttySC0 @@ -479,6 +551,7 @@ ifneq ($(wildcard /usr/bin/stm32flash),) /usr/bin/stm32flash -v -w bin/$(BINBIN_F1) -g 0x0 -R -i 23,-22,22:-23,22 /dev/ttySC0 endif + zumspot-pi: ifneq ($(wildcard /usr/local/bin/stm32flash),) /usr/local/bin/stm32flash -v -w bin/$(BINBIN_F1) -g 0x0 -R -i 20,-21,21:-20,21 /dev/ttyAMA0 @@ -488,12 +561,16 @@ ifneq ($(wildcard /usr/bin/stm32flash),) /usr/bin/stm32flash -v -w bin/$(BINBIN_F1) -g 0x0 -R -i 20,-21,21:-20,21 /dev/ttyAMA0 endif + mmdvm_hs_hat: zumspot-pi + mmdvm_hs_dual_hat: zumspot-pi + skybridge: zumspot-pi + hotpot-opipc_opipcplus: ifneq ($(wildcard /usr/local/bin/stm32flash),) /usr/local/bin/stm32flash -v -w bin/$(BINBIN_F1) -g 0x0 -R -i 198,-199,199:-198,199 /dev/ttyS3 @@ -503,16 +580,20 @@ ifneq ($(wildcard /usr/bin/stm32flash),) /usr/bin/stm32flash -v -w bin/$(BINBIN_F1) -g 0x0 -R -i 198,-199,199:-198,199 /dev/ttyS3 endif + mmdvm_hs_hat_opi: hotpot-opipc_opipcplus + mmdvm_hs_dual_hat_opi: hotpot-opipc_opipcplus + dfu: ifdef devser $(DFU_RST) $(devser) 750 endif $(DFU_UTIL) -D bin/$(BINBIN_F1BL) -d 1eaf:0003 -a 2 -R -R + ocd: ifneq ($(wildcard /usr/bin/openocd),) /usr/bin/openocd -f /usr/share/openocd/scripts/interface/stlink-v2-1.cfg -f /usr/share/openocd/scripts/target/stm32f1x.cfg -c "program bin/$(BINELF_F1) verify reset exit" @@ -526,6 +607,7 @@ ifneq ($(wildcard /opt/openocd/bin/openocd),) /opt/openocd/bin/openocd -f /opt/openocd/scripts/interface/stlink-v2-1.cfg -f /opt/openocd/share/openocd/scripts/target/stm32f1x.cfg -c "program bin/$(BINELF_F1) verify reset exit" endif + ocd-nobl: ifneq ($(wildcard /usr/bin/openocd),) /usr/bin/openocd -f /usr/share/openocd/scripts/interface/stlink-v2-1.cfg -f /usr/share/openocd/scripts/target/stm32f1x.cfg -c "program bin/$(BINELF_F1NOBL) verify reset exit" @@ -539,6 +621,7 @@ ifneq ($(wildcard /opt/openocd/bin/openocd),) /opt/openocd/bin/openocd -f /opt/openocd/scripts/interface/stlink-v2-1.cfg -f /opt/openocd/share/openocd/scripts/target/stm32f1x.cfg -c "program bin/$(BINELF_F1NOBL) verify reset exit" endif + ocd-bl: ifneq ($(wildcard /usr/bin/openocd),) /usr/bin/openocd -f /usr/share/openocd/scripts/interface/stlink-v2-1.cfg -f /usr/share/openocd/scripts/target/stm32f1x.cfg -c "program $(F1_LIB_PATH)/utils/bootloader/generic_boot20_pc13_long_rst.bin verify reset exit 0x08000000" @@ -555,6 +638,7 @@ ifneq ($(wildcard /opt/openocd/bin/openocd),) /opt/openocd/bin/openocd -f /opt/openocd/scripts/interface/stlink-v2-1.cfg -f /opt/openocd/share/openocd/scripts/target/stm32f1x.cfg -c "program bin/$(BINBIN_F1BL) verify reset exit 0x08002000" endif + ocd-bl-old: ifneq ($(wildcard /usr/bin/openocd),) /usr/bin/openocd -f /usr/share/openocd/scripts/interface/stlink-v2-1.cfg -f /usr/share/openocd/scripts/target/stm32f1x.cfg -c "program $(F1_LIB_PATH)/utils/bootloader/generic_boot20_pc13.bin verify reset exit 0x08000000" @@ -571,6 +655,7 @@ ifneq ($(wildcard /opt/openocd/bin/openocd),) /opt/openocd/bin/openocd -f /opt/openocd/scripts/interface/stlink-v2-1.cfg -f /opt/openocd/share/openocd/scripts/target/stm32f1x.cfg -c "program bin/$(BINBIN_F1BL) verify reset exit 0x08002000" endif + # Export the current git version if the index file exists, else 000... GitVersion.h: .FORCE ifdef SYSTEMROOT diff --git a/POCSAGDefines.h b/POCSAGDefines.h index 513ffbc..d038764 100644 --- a/POCSAGDefines.h +++ b/POCSAGDefines.h @@ -17,11 +17,13 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#if !defined(POCSAGDEFINES_H) -#define POCSAGDEFINES_H +#if !defined(POCSAGDEFINES_H_) +#define POCSAGDEFINES_H_ + const uint16_t POCSAG_PREAMBLE_LENGTH_BYTES = 18U * sizeof(uint32_t); const uint16_t POCSAG_FRAME_LENGTH_BYTES = 17U * sizeof(uint32_t); -const uint8_t POCSAG_SYNC = 0xAAU; +const uint8_t POCSAG_SYNC = 0xAAU; + -#endif +#endif /* !POCSAGDEFINES_H_ */ diff --git a/POCSAGTX.cpp b/POCSAGTX.cpp index e8e9146..12a32ed 100644 --- a/POCSAGTX.cpp +++ b/POCSAGTX.cpp @@ -23,132 +23,129 @@ #include "POCSAGTX.h" #include "POCSAGDefines.h" -CPOCSAGTX::CPOCSAGTX() : -m_buffer(1000U), -m_poBuffer(), -m_poLen(0U), -m_poPtr(0U), -m_txDelay(POCSAG_PREAMBLE_LENGTH_BYTES), -m_delay(false), -m_cal(false) -{ + + +CPOCSAGTX::CPOCSAGTX(): m_buffer(1000U), + m_poBuffer(), + m_poLen(0U), + m_poPtr(0U), + m_txDelay(POCSAG_PREAMBLE_LENGTH_BYTES), + m_delay(false), + m_cal(false) { } -void CPOCSAGTX::process() -{ - if (m_cal) { - m_delay = false; - createCal(); - } - - if (m_poLen == 0U && m_buffer.getData() > 0U) { - if (!m_tx) { - m_delay = true; - m_poLen = m_txDelay; - } else { - m_delay = false; - for (uint8_t i = 0U; i < POCSAG_FRAME_LENGTH_BYTES; i++) - m_poBuffer[i] = m_buffer.get(); - - m_poLen = POCSAG_FRAME_LENGTH_BYTES; - } - m_poPtr = 0U; - } - - if (m_poLen > 0U) { - uint16_t space = io.getSpace(); - - while (space > 8U) { - if (m_delay) { - m_poPtr++; - writeByte(POCSAG_SYNC); - } else - writeByte(m_poBuffer[m_poPtr++]); - - space -= 8U; - - if (m_poPtr >= m_poLen) { - m_poPtr = 0U; - m_poLen = 0U; - m_delay = false; - return; - } - } - } +void CPOCSAGTX::process() { + if (m_cal) { + m_delay = false; + createCal(); + } + + if (m_poLen == 0U && m_buffer.getData() > 0U) { + if (!m_tx) { + m_delay = true; + m_poLen = m_txDelay; + } else { + m_delay = false; + for (uint8_t i = 0U; i < POCSAG_FRAME_LENGTH_BYTES; i++) { + m_poBuffer[i] = m_buffer.get(); + } + + m_poLen = POCSAG_FRAME_LENGTH_BYTES; + } + m_poPtr = 0U; + } + + if (m_poLen > 0U) { + uint16_t space = io.getSpace(); + + while (space > 8U) { + if (m_delay) { + m_poPtr++; + writeByte(POCSAG_SYNC); + } else { + writeByte(m_poBuffer[m_poPtr++]); + } + + space -= 8U; + + if (m_poPtr >= m_poLen) { + m_poPtr = 0U; + m_poLen = 0U; + m_delay = false; + return; + } + } + } } -bool CPOCSAGTX::busy() -{ - if (m_poLen > 0U || m_buffer.getData() > 0U) - return true; - else - return false; +bool CPOCSAGTX::busy() { + if (m_poLen > 0U || m_buffer.getData() > 0U) { + return true; + } else { + return false; + } } -uint8_t CPOCSAGTX::writeData(const uint8_t* data, uint8_t length) -{ - if (length != POCSAG_FRAME_LENGTH_BYTES) - return 4U; +uint8_t CPOCSAGTX::writeData(const uint8_t* data, uint8_t length) { + if (length != POCSAG_FRAME_LENGTH_BYTES) + return 4U; - uint16_t space = m_buffer.getSpace(); - if (space < POCSAG_FRAME_LENGTH_BYTES) - return 5U; + uint16_t space = m_buffer.getSpace(); + if (space < POCSAG_FRAME_LENGTH_BYTES) + return 5U; - for (uint8_t i = 0U; i < POCSAG_FRAME_LENGTH_BYTES; i++) - m_buffer.put(data[i]); + for (uint8_t i = 0U; i < POCSAG_FRAME_LENGTH_BYTES; i++) + m_buffer.put(data[i]); - return 0U; + return 0U; } -void CPOCSAGTX::writeByte(uint8_t c) -{ - uint8_t bit; - uint8_t mask = 0x80U; +void CPOCSAGTX::writeByte(uint8_t c) { + uint8_t bit; + uint8_t mask = 0x80U; - for (uint8_t i = 0U; i < 8U; i++, c <<= 1) { - if ((c & mask) == mask) - bit = 1U; - else - bit = 0U; + for (uint8_t i = 0U; i < 8U; i++, c <<= 1) { + if ((c & mask) == mask) { + bit = 1U; + } else { + bit = 0U; + } - io.write(&bit, 1); - } + io.write(&bit, 1); + } } -void CPOCSAGTX::setTXDelay(uint8_t delay) -{ - m_txDelay = POCSAG_PREAMBLE_LENGTH_BYTES + (delay * 3U) / 2U; +void CPOCSAGTX::setTXDelay(uint8_t delay) { + m_txDelay = POCSAG_PREAMBLE_LENGTH_BYTES + (delay * 3U) / 2U; - if (m_txDelay > 150U) - m_txDelay = 150U; + if (m_txDelay > 150U) { + m_txDelay = 150U; + } } -uint8_t CPOCSAGTX::getSpace() const -{ - return m_buffer.getSpace() / POCSAG_FRAME_LENGTH_BYTES; +uint8_t CPOCSAGTX::getSpace() const { + return m_buffer.getSpace() / POCSAG_FRAME_LENGTH_BYTES; } -uint8_t CPOCSAGTX::setCal(const uint8_t* data, uint8_t length) -{ - if (length != 1U) - return 4U; +uint8_t CPOCSAGTX::setCal(const uint8_t* data, uint8_t length) { + if (length != 1U) + return 4U; - m_cal = data[0U] == 1U; + m_cal = data[0U] == 1U; - if (m_cal) - io.ifConf(STATE_POCSAG, true); + if (m_cal) + io.ifConf(STATE_POCSAG, true); - return 0U; + return 0U; } -void CPOCSAGTX::createCal() -{ - // 600 Hz square wave generation - for (unsigned int i = 0U; i < POCSAG_FRAME_LENGTH_BYTES; i++) { - m_poBuffer[i] = 0xAAU; - } +void CPOCSAGTX::createCal() { + // 600 Hz square wave generation + for (unsigned int i = 0U; i < POCSAG_FRAME_LENGTH_BYTES; i++) { + m_poBuffer[i] = 0xAAU; + } - m_poLen = POCSAG_FRAME_LENGTH_BYTES; + m_poLen = POCSAG_FRAME_LENGTH_BYTES; - m_poPtr = 0U; + m_poPtr = 0U; } diff --git a/POCSAGTX.h b/POCSAGTX.h index 6862304..4198fdc 100644 --- a/POCSAGTX.h +++ b/POCSAGTX.h @@ -18,37 +18,39 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#if !defined(POCSAGTX_H) -#define POCSAGTX_H +#if !defined(POCSAGTX_H_) +#define POCSAGTX_H_ + class CPOCSAGTX { public: - CPOCSAGTX(); + CPOCSAGTX(); - uint8_t writeData(const uint8_t* data, uint8_t length); + uint8_t writeData(const uint8_t *data, uint8_t length); - void setTXDelay(uint8_t delay); + void setTXDelay(uint8_t delay); - uint8_t setCal(const uint8_t* data, uint8_t length); + uint8_t setCal(const uint8_t *data, uint8_t length); - void createCal(); + void createCal(); - uint8_t getSpace() const; + uint8_t getSpace() const; - void process(); + void process(); - bool busy(); + bool busy(); private: - CSerialRB m_buffer; - uint8_t m_poBuffer[200U]; - uint16_t m_poLen; - uint16_t m_poPtr; - uint16_t m_txDelay; - bool m_delay; - bool m_cal; - - void writeByte(uint8_t c); + CSerialRB m_buffer; + uint8_t m_poBuffer[200U]; + uint16_t m_poLen; + uint16_t m_poPtr; + uint16_t m_txDelay; + bool m_delay; + bool m_cal; + + void writeByte(uint8_t c); + }; -#endif +#endif /* !POCSAGTX_H_ */ diff --git a/README.md b/README.md index ad55656..549e758 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -# Introduction +# MMDVM_HS -- MMDVM Hotspot Firmware # + +## Introduction ## This is the source code of ZUMspot/MMDVM_HS firmware for personal hotspots (ADF7021 version of the MMDVM firmware), based on Jonathan G4KLX's [MMDVM](https://github.com/g4klx/MMDVM) software. This firmware supports D-Star, DMR, System Fusion, P25 and NXDN digital voice modes and POCSAG 1200 pager protocol. @@ -8,7 +10,8 @@ This software comes with ABSOLUTELY NO WARRANTY, it is provided "AS IS" with the This software is licenced under the GPL v2 and is intended for amateur and educational use only. Use of this software for commercial purposes is strictly forbidden. -# Features + +## Features ## - Supported modes: D-Star, DMR, Yaesu Fusion, P25 Phase 1 and NXDN - Other modes: POCSAG 1200 @@ -23,9 +26,10 @@ This software is licenced under the GPL v2 and is intended for amateur and educa - CW ID support - Full duplex support with two ADF7021 -# Known issues -## Common issues for simplex and duplex boards +## Known issues ## + +### Common issues for simplex and duplex boards ### - High RX BER or not RX, poor TX audio (4FSK modes): adjust frequency offset, specially RXOffset. - Not instantaneous mode detection (2 modes or more enabled): mode detection could be slow and sometimes you need to hold PTT several seconds, in order to activate the hotspot. There is no solution for that, since ADF7021 works only one mode at once. You can disable mode scanning, enabling just one mode. @@ -34,13 +38,15 @@ This software is licenced under the GPL v2 and is intended for amateur and educa - Not working with RPi 3B+ (USB): be sure your firmware version is >= 1.4.8 and update to new USB bootloader with long reset pulse (make stlink-bl, for example). - Not working with USB (not RPi 3B+): compile with "LONG_USB_RESET" option disabled, and use old bootloader (make stlink-bl-old, for example). -## Duplex boards + +### Duplex boards ### - Very difficult DMR activation ("repeater fail" error): disable mode scanning, select just DMR mode. - Not DMR activation ("repeater fail" error) with MD380, Ailunce HD1 or some other radios: increase DMR deviation to 55 % or 60 %. - RX timeout: this is due to TX and RX clock differences, which does not have easy solution. Be sure your firmware version is >= 1.4.7, which minimizes this problem. -# Notes for previous users of MMDVM boards + +## Notes for previous users of MMDVM boards ## MMDVM_HS boards do not need deviation calibration like MMDVM boards, but could be necessary some frequency offset calibration (ADF7021 does not have AFC for 4FSK modes). @@ -67,7 +73,8 @@ The following options in MMDVM.ini ([Modem] section) are very important for MMDV NXDNTXLevel: NXDN deviation setting (recommended value: 50) POCSAGTXLevel: POCSAG deviation setting (recommended value: 50) -# Important notes + +## Important notes ## The ADF7021 (or RF7021SE module) must operate with a 14.7456 MHz TCXO and with at least 2.5 ppm of frequency stability or better. For 800-900 MHz frequency band you will need even a better frequency stability TCXO. You could use also 12.2880 MHz TCXO. Any other TCXO frequency is not supported. Please note that a bad quality TCXO not only affects the frequency offset, also affects clock data rate, which is not possible to fix and will cause BER issues. @@ -85,57 +92,62 @@ If you can't decode any 4FSK modulation (DMR, YSF, P25 or NXDN) with your ZUMspo If you have problems updating firmware using USB bootloader (DFU mode) on Orange Pi or any other system different from RPi, you could compile the dfu tool directly. You could get the source code of a dfu tool [here](https://sourceforge.net/projects/dfu-programmer/files/dfu-programmer/0.7.0/). -# Quick start + +## Quick start ## Please see [BUILD.md](BUILD.md) for more details, and also [MMDVM](https://groups.yahoo.com/neo/groups/mmdvm/info) Yahoo Groups. You also can check at MMDVM_HS/scripts folder for some automatic tasks. -## Binary firmware installation + +### Binary firmware installation ### Please check the latest firmware [here](https://github.com/juribeparada/MMDVM_HS/releases). -### Pi-Star binary firmware installation + +#### Pi-Star binary firmware installation #### You could use some pi-star commands under SSH console: -- sudo pistar-zumspotflash rpi: ZUMspot RPi board -- sudo pistar-zumspotflash rpi_duplex: ZUMSpot duplex board conected to GPIO -- sudo pistar-zumspotflash usb: ZUMspot USB dongle -- sudo pistar-zumspotflash libre: ZUMspot Libre Kit or generic MMDVM_HS board with USB -- sudo pistar-mmdvmhshatflash hs_hat: MMDVM_HS_Hat board (14.7456MHz TCXO) -- sudo pistar-mmdvmhshatflash hs_dual_hat: HS_DUAL_HAT board (14.7456MHz TCXO) -- sudo pistar-mmdvmhshatflash hs_hat-12mhz: MMDVM_HS_Hat board (12.288MHz TCXO) -- sudo pistar-mmdvmhshatflash hs_dual_hat-12mhz: HS_DUAL_HAT board (12.288MHz TCXO) -- sudo pistar-nanohsflash nano_hs: Nano hotSPOT board -- sudo pistar-nanodvflash pi: NanoDV NPi board -- sudo pistar-nanodvflash usb: NanoDV USB board +- `sudo pistar-zumspotflash rpi`: ZUMspot RPi board +- `sudo pistar-zumspotflash rpi_duplex`: ZUMSpot duplex board conected to GPIO +- `sudo pistar-zumspotflash usb`: ZUMspot USB dongle +- `sudo pistar-zumspotflash libre`: ZUMspot Libre Kit or generic MMDVM_HS board with USB +- `sudo pistar-mmdvmhshatflash hs_hat`: MMDVM_HS_Hat board (14.7456MHz TCXO) +- `sudo pistar-mmdvmhshatflash hs_dual_hat`: HS_DUAL_HAT board (14.7456MHz TCXO) +- `sudo pistar-mmdvmhshatflash hs_hat-12mhz`: MMDVM_HS_Hat board (12.288MHz TCXO) +- `sudo pistar-mmdvmhshatflash hs_dual_hat-12mhz`: HS_DUAL_HAT board (12.288MHz TCXO) +- `sudo pistar-nanohsflash nano_hs`: Nano hotSPOT board +- `sudo pistar-nanodvflash pi`: NanoDV NPi board +- `sudo pistar-nanodvflash usb`: NanoDV USB board -### Windows -Download the ZUMspotFW firmware upgrade utility (ZUMspotFW_setup.exe) from the [releases section](https://github.com/juribeparada/MMDVM_HS/releases). +#### Windows #### + +Download the ZUMspotFW firmware upgrade utility (`ZUMspotFW_setup.exe`) from the [releases section](https://github.com/juribeparada/MMDVM_HS/releases). This utility includes firmwares binaries and USB drivers for Windows 7/8/10. If you have problems with the installer, you can download [ZUMspotFW.zip](https://github.com/juribeparada/MMDVM_HS/releases/download/v1.0.2/ZUMspotFW.zip) for a manual installation. -### Linux or macOS - -Download the script (*.sh) that matches with your ZUMspot/MMDVM_HS board: - -- install_fw_librekit.sh: only for ZUMspot Libre Kit board (KI6ZUM & VE2GZI) or generic MMDVM_HS board with USB interface -- install_fw_rpi.sh: only for ZUMspot RPi board (KI6ZUM & VE2GZI) -- install_fw_usb.sh: only for ZUMspot USB dongle (KI6ZUM) -- install_fw_duplex.sh: only for ZUMspot Duplex for RPi (KI6ZUM) -- install_fw_dualband.sh: only for ZUMspot Dualband for RPi (KI6ZUM) -- install_fw_hshat.sh: only for MMDVM_HS_Hat board (DB9MAT & DF2ET) -- install_fw_hshat-12mhz.sh: only for MMDVM_HS_Hat board with 12.288 MHz TCXO (DB9MAT & DF2ET) -- install_fw_hsdualhat.sh: only for MMDVM_HS_Dual_Hat board (DB9MAT & DF2ET & DO7EN) -- install_fw_hsdualhat-12mhz.sh: only for MMDVM_HS_Dual_Hat board with 12.288 MHz TCXO (DB9MAT & DF2ET & DO7EN) -- install_fw_nanohs.sh: only for Nano hotSPOT board (BI7JTA) -- install_fw_nanodv_npi.sh: only for NanoDV NPi board 1.0 (BG4TGO & BG5HHP) -- install_fw_nanodv_usb.sh: only for NanoDV USB board 1.0 (BG4TGO & BG5HHP) -- install_fw_d2rg_mmdvmhs.sh: only for D2RG MMDVM_HS board (BG3MDO, VE2GZI, CA6JAU) -- install_fw_gen_gpio.sh: only for generic MMDVM_HS board (EA7GIB) with GPIO serial interface -- install_fw_duplex_gpio.sh: only for MMDVM_HS with dual ADF7021 (EA7GIB) or generic dual ADF7021 board with GPIO serial interface -- install_fw_duplex_usb.sh: only for MMDVM_HS with dual ADF7021 (EA7GIB) or generic dual ADF7021 board with USB interface -- install_fw_skybridge_rpi.sh: only for BridgeCom SkyBridge HotSpot + +#### Linux or macOS #### + +Download the script (`*.sh`) that matches with your ZUMspot/MMDVM_HS board: + +- `install_fw_librekit.sh`: only for ZUMspot Libre Kit board (KI6ZUM & VE2GZI) or generic MMDVM_HS board with USB interface +- `install_fw_rpi.sh`: only for ZUMspot RPi board (KI6ZUM & VE2GZI) +- `install_fw_usb.sh`: only for ZUMspot USB dongle (KI6ZUM) +- `install_fw_duplex.sh`: only for ZUMspot Duplex for RPi (KI6ZUM) +- `install_fw_dualband.sh`: only for ZUMspot Dualband for RPi (KI6ZUM) +- `install_fw_hshat.sh`: only for MMDVM_HS_Hat board (DB9MAT & DF2ET) +- `install_fw_hshat-12mhz.sh`: only for MMDVM_HS_Hat board with 12.288 MHz TCXO (DB9MAT & DF2ET) +- `install_fw_hsdualhat.sh`: only for MMDVM_HS_Dual_Hat board (DB9MAT & DF2ET & DO7EN) +- `install_fw_hsdualhat-12mhz.sh`: only for MMDVM_HS_Dual_Hat board with 12.288 MHz TCXO (DB9MAT & DF2ET & DO7EN) +- `install_fw_nanohs.sh`: only for Nano hotSPOT board (BI7JTA) +- `install_fw_nanodv_npi.sh`: only for NanoDV NPi board 1.0 (BG4TGO & BG5HHP) +- `install_fw_nanodv_usb.sh`: only for NanoDV USB board 1.0 (BG4TGO & BG5HHP) +- `install_fw_d2rg_mmdvmhs.sh`: only for D2RG MMDVM_HS board (BG3MDO, VE2GZI, CA6JAU) +- `install_fw_gen_gpio.sh`: only for generic MMDVM_HS board (EA7GIB) with GPIO serial interface +- `install_fw_duplex_gpio.sh`: only for MMDVM_HS with dual ADF7021 (EA7GIB) or generic dual ADF7021 board with GPIO serial interface +- `install_fw_duplex_usb.sh`: only for MMDVM_HS with dual ADF7021 (EA7GIB) or generic dual ADF7021 board with USB interface +- `install_fw_skybridge_rpi.sh`: only for BridgeCom SkyBridge HotSpot For example, download the ZUMspot RPi upgrade script: @@ -156,13 +168,14 @@ You could optionally install a beta firmware for testing: ./install_fw_rpi.sh beta -## Build from the sources -You could use example files from MMDVM_HS/configs folder and overwrite the Config.h file, in order to compile a firmware with default settings. There are a specific config file for each ZUMspot or any MMDVM_HS compatible boards. In general, there are two possible compilation ways: +### Build from the sources ### + +You could use example files from `MMDVM_HS/configs` folder and overwrite the `Config.h` file, in order to compile a firmware with default settings. There are a specific config file for each ZUMspot or any MMDVM_HS compatible boards. In general, there are two possible compilation ways: - Boards with USB interface: -Boards with STM32_USB_HOST option enabled in Config.h (ZUMspot Libre Kit, ZUMspot USB, GIBSpot USB, NanoDV USB, etc). Those boards need to have the USB bootloader installed. For example: +Boards with `STM32_USB_HOST` option enabled in `Config.h` (ZUMspot Libre Kit, ZUMspot USB, GIBSpot USB, NanoDV USB, etc). Those boards need to have the USB bootloader installed. For example: make clean make bl @@ -184,15 +197,18 @@ Boards with STM32_USART1_HOST option enabled in Config.h (ZUMspot RPi, MMDVM_HS_ Some detailed examples as follows: -### MMDVM_HS_Hat + +#### MMDVM_HS_Hat Please visit Mathis Schmieder GitHub [here](https://github.com/mathisschmieder/MMDVM_HS_Hat/blob/master/README.md) for detailed instructions. -### D2RG MMDVM_HS board + +#### D2RG MMDVM_HS board This hotspot needs Raspbian support for SPI-UART converter included in this board. If you don't see /dev/ttySC0, please visit Yuan BG3MDO GitHub [here](https://github.com/bg3mdo/D2RG_MMDVM_HS_ambe_uart_service) for driver installation instructions. -### ZUMspot Libre Kit (under Linux Raspbian) + +#### ZUMspot Libre Kit (under Linux Raspbian) If you are using Pi-Star, expand filesystem (if you haven't done before): @@ -230,9 +246,10 @@ Upload the firmware to ZUMspot Libre Kit using the USB port (your Libre Kit has sudo make dfu devser=/dev/ttyACM0 -### ZUMspot RPi -#### Enable serial port in Raspberry Pi 3 or Pi Zero W +#### ZUMspot RPi + +##### Enable serial port in Raspberry Pi 3 or Pi Zero W This this necessary only if you are installing a fresh copy of Raspbian OS. @@ -259,7 +276,8 @@ Reboot your RPi: sudo reboot -#### Build the firmware and upload to ZUMspot RPi + +##### Build the firmware and upload to ZUMspot RPi If you are using Pi-Star, expand filesystem (if you haven't done before): @@ -320,7 +338,8 @@ Upload the firmware to ZUMspot RPi board: sudo make zumspot-pi -### MMDVM_HS_Dual_Hat\MMDVM_HS_Hat gpio firmware update on OrangePI PC/PC2/PC Plus + +#### MMDVM_HS_Dual_Hat\MMDVM_HS_Hat gpio firmware update on OrangePI PC/PC2/PC Plus Install the necessary software tools: diff --git a/bootloader.ld b/bootloader.ld index 4738f25..ae6df40 100644 --- a/bootloader.ld +++ b/bootloader.ld @@ -17,10 +17,9 @@ */ /* Memory areas */ -MEMORY -{ - ROM (rx) : ORIGIN = 0x08002000, LENGTH = 120K /* FLASH */ - RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K /* Main RAM */ +MEMORY { + ROM (rx) : ORIGIN = 0x08002000, LENGTH = 120K /* FLASH */ + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K /* Main RAM */ } INCLUDE stm32f10x_link.ld diff --git a/configs/MMDVM_HS_Dual_Hat-12mhz-USB.h b/configs/MMDVM_HS_Dual_Hat-12mhz-USB.h new file mode 100644 index 0000000..4dc08af --- /dev/null +++ b/configs/MMDVM_HS_Dual_Hat-12mhz-USB.h @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2017,2018,2019,2020 by Andy Uribe CA6JAU, Florian Wolters DF2ET + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#if !defined(CONFIG_H_) +#define CONFIG_H_ + + +// Select one board (STM32F103 based boards) +// 1) ZUMspot RPi or ZUMspot USB: +//#define ZUMSPOT_ADF7021 +// 2) Libre Kit board or any homebrew hotspot with modified RF7021SE and Blue Pill STM32F103: +//#define LIBRE_KIT_ADF7021 +// 3) MMDVM_HS_Hat revisions 1.1, 1.2 and 1.4 (DB9MAT & DF2ET) +//#define MMDVM_HS_HAT_REV12 +// 4) MMDVM_HS_Dual_Hat revisions 1.0 (DB9MAT & DF2ET & DO7EN) +#define MMDVM_HS_DUAL_HAT_REV10 +// 5) Nano hotSPOT (BI7JTA) +//#define NANO_HOTSPOT +// 6) NanoDV NPi or USB revisions 1.0 (BG4TGO & BG5HHP) +//#define NANO_DV_REV10 +// 7) D2RG MMDVM_HS RPi (BG3MDO, VE2GZI, CA6JAU) +//#define D2RG_MMDVM_HS +// 8) BridgeCom SkyBridge HotSpot +//#define SKYBRIDGE_HS + +// Enable ADF7021 support: +#define ENABLE_ADF7021 + +// Enable full duplex support with dual ADF7021 (valid for homebrew hotspots only): +#define DUPLEX + +// TCXO of the ADF7021 +// For 14.7456 MHz: +//#define ADF7021_14_7456 +// For 12.2880 MHz: +#define ADF7021_12_2880 + +// Configure receiver gain for ADF7021 +// AGC automatic, default settings: +#define AD7021_GAIN_AUTO +// AGC automatic with high LNA linearity: +//#define AD7021_GAIN_AUTO_LIN +// AGC OFF, lowest gain: +//#define AD7021_GAIN_LOW +// AGC OFF, highest gain: +//#define AD7021_GAIN_HIGH + +// Host communication selection: +//#define STM32_USART1_HOST +#define STM32_USB_HOST +//#define STM32_I2C_HOST + +// I2C host address: +#define I2C_ADDR 0x22 + +// Enable mode detection: +#define ENABLE_SCAN_MODE + +// Send RSSI value: +#define SEND_RSSI_DATA + +// Enable Nextion LCD serial port repeater on USART2 (ZUMspot Libre Kit and ZUMspot RPi): +#define SERIAL_REPEATER +#define SERIAL_REPEATER_BAUD 9600 + +// Enable Nextion LCD serial port repeater on USART1 (Do not use with STM32_USART1_HOST enabled): +#define SERIAL_REPEATER_USART1 + +// Enable P25 Wide modulation: +//#define ENABLE_P25_WIDE + +// Disable mode LEDs blink during scan mode: +//#define QUIET_MODE_LEDS + +// Engage a constant or descreet Service LED mode once repeater is running +//#define CONSTANT_SRV_LED +//#define CONSTANT_SRV_LED_INVERTED +//#define DISCREET_SRV_LED +//#define DISCREET_SRV_LED_INVERTED + +// Use the YSF and P25 LEDs for NXDN +#define USE_ALTERNATE_NXDN_LEDS + +// Use the D-Star and P25 LEDs for M17 +#define USE_ALTERNATE_M17_LEDS + +// Use the D-Star and DMR LEDs for POCSAG +#define USE_ALTERNATE_POCSAG_LEDS + +// Enable for RPi 3B+, USB mode +#define LONG_USB_RESET + +// Enable modem debug messages +//#define ENABLE_DEBUG + +// Disable frequency bands check +#define DISABLE_FREQ_CHECK + +// Disable frequency restrictions (satellite, ISS, etc) +#define DISABLE_FREQ_BAN + +// Enable UDID feature +#define ENABLE_UDID + + +#endif /* !CONFIG_H_ */ diff --git a/configs/MMDVM_HS_Dual_Hat-USB.h b/configs/MMDVM_HS_Dual_Hat-USB.h new file mode 100644 index 0000000..b651549 --- /dev/null +++ b/configs/MMDVM_HS_Dual_Hat-USB.h @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2017,2018,2019,2020 by Andy Uribe CA6JAU, Florian Wolters DF2ET + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#if !defined(CONFIG_H_) +#define CONFIG_H_ + + +// Select one board (STM32F103 based boards) +// 1) ZUMspot RPi or ZUMspot USB: +//#define ZUMSPOT_ADF7021 +// 2) Libre Kit board or any homebrew hotspot with modified RF7021SE and Blue Pill STM32F103: +//#define LIBRE_KIT_ADF7021 +// 3) MMDVM_HS_Hat revisions 1.1, 1.2 and 1.4 (DB9MAT & DF2ET) +//#define MMDVM_HS_HAT_REV12 +// 4) MMDVM_HS_Dual_Hat revisions 1.0 (DB9MAT & DF2ET & DO7EN) +#define MMDVM_HS_DUAL_HAT_REV10 +// 5) Nano hotSPOT (BI7JTA) +//#define NANO_HOTSPOT +// 6) NanoDV NPi or USB revisions 1.0 (BG4TGO & BG5HHP) +//#define NANO_DV_REV10 +// 7) D2RG MMDVM_HS RPi (BG3MDO, VE2GZI, CA6JAU) +//#define D2RG_MMDVM_HS +// 8) BridgeCom SkyBridge HotSpot +//#define SKYBRIDGE_HS + +// Enable ADF7021 support: +#define ENABLE_ADF7021 + +// Enable full duplex support with dual ADF7021 (valid for homebrew hotspots only): +#define DUPLEX + +// TCXO of the ADF7021 +// For 14.7456 MHz: +#define ADF7021_14_7456 +// For 12.2880 MHz: +//#define ADF7021_12_2880 + +// Configure receiver gain for ADF7021 +// AGC automatic, default settings: +#define AD7021_GAIN_AUTO +// AGC automatic with high LNA linearity: +//#define AD7021_GAIN_AUTO_LIN +// AGC OFF, lowest gain: +//#define AD7021_GAIN_LOW +// AGC OFF, highest gain: +//#define AD7021_GAIN_HIGH + +// Host communication selection: +//#define STM32_USART1_HOST +#define STM32_USB_HOST +//#define STM32_I2C_HOST + +// I2C host address: +#define I2C_ADDR 0x22 + +// Enable mode detection: +#define ENABLE_SCAN_MODE + +// Send RSSI value: +#define SEND_RSSI_DATA + +// Enable Nextion LCD serial port repeater on USART2 (ZUMspot Libre Kit and ZUMspot RPi): +#define SERIAL_REPEATER +#define SERIAL_REPEATER_BAUD 9600 + +// Enable Nextion LCD serial port repeater on USART1 (Do not use with STM32_USART1_HOST enabled): +#define SERIAL_REPEATER_USART1 + +// Enable P25 Wide modulation: +//#define ENABLE_P25_WIDE + +// Disable mode LEDs blink during scan mode: +//#define QUIET_MODE_LEDS + +// Engage a constant or descreet Service LED mode once repeater is running +//#define CONSTANT_SRV_LED +//#define CONSTANT_SRV_LED_INVERTED +//#define DISCREET_SRV_LED +//#define DISCREET_SRV_LED_INVERTED + +// Use the YSF and P25 LEDs for NXDN +#define USE_ALTERNATE_NXDN_LEDS + +// Use the D-Star and P25 LEDs for M17 +#define USE_ALTERNATE_M17_LEDS + +// Use the D-Star and DMR LEDs for POCSAG +#define USE_ALTERNATE_POCSAG_LEDS + +// Enable for RPi 3B+, USB mode +#define LONG_USB_RESET + +// Enable modem debug messages +//#define ENABLE_DEBUG + +// Disable frequency bands check +#define DISABLE_FREQ_CHECK + +// Disable frequency restrictions (satellite, ISS, etc) +#define DISABLE_FREQ_BAN + +// Enable UDID feature +#define ENABLE_UDID + + +#endif /* !CONFIG_H_ */ diff --git a/normal.ld b/normal.ld index 290f7ab..4b717cb 100644 --- a/normal.ld +++ b/normal.ld @@ -17,10 +17,9 @@ */ /* Memory areas */ -MEMORY -{ - ROM (rx) : ORIGIN = 0x08000000, LENGTH = 128K /* FLASH */ - RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K /* Main RAM */ +MEMORY { + ROM (rx) : ORIGIN = 0x08000000, LENGTH = 128K /* FLASH */ + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K /* Main RAM */ } -INCLUDE stm32f10x_link.ld \ No newline at end of file +INCLUDE stm32f10x_link.ld diff --git a/stm32f10x_link.ld b/stm32f10x_link.ld index 28047f0..856abfe 100644 --- a/stm32f10x_link.ld +++ b/stm32f10x_link.ld @@ -26,10 +26,9 @@ ENTRY(Reset_Handler) /* Stack start address (end of 20K RAM) */ _estack = ORIGIN(RAM) + LENGTH(RAM); -SECTIONS -{ - .text : - { + +SECTIONS { + .text : { /* The interrupt vector table */ . = ALIGN(4); KEEP(*(.isr_vector .isr_vector.*)) @@ -65,10 +64,9 @@ SECTIONS KEEP (*(.fini_array)) KEEP (*(SORT(.fini_array.*))) __fini_array_end = .; - } > ROM - /* ARM sections containing exception unwinding information */ + /* ARM sections containing exception unwinding information */ .ARM.extab : { __extab_start = .; *(.ARM.extab* .gnu.linkonce.armextab.*) @@ -86,19 +84,17 @@ SECTIONS _sidata = .; /* The .data section (initialized data) */ - .data : AT ( _sidata ) - { + .data : AT(_sidata) { . = ALIGN(4); - _sdata = . ; /* Start address for the .data section */ + _sdata = .; /* Start address for the .data section */ *(.data .data*) . = ALIGN(4); - _edata = . ; /* End address for the .data section */ + _edata = .; /* End address for the .data section */ } > RAM /* The .bss section (uninitialized data) */ - .bss : - { + .bss : { . = ALIGN(4); _sbss = .; /* Start address for the .bss section */ __bss_start__ = _sbss; @@ -108,23 +104,21 @@ SECTIONS . = ALIGN(4); _ebss = . ; /* End address for the .bss section */ - __bss_end__ = _ebss; + __bss_end__ = _ebss; } > RAM /* Space for heap and stack */ - .heap_stack : - { - end = . ; /* 'end' symbol defines heap location */ - _end = end ; + .heap_stack : { + end = .; /* 'end' symbol defines heap location */ + _end = end; . = . + _min_heap_size; /* Additional space for heap and stack */ . = . + _min_stack_size; } > RAM /* Remove information from the standard libraries */ - /DISCARD/ : - { - libc.a ( * ) - libm.a ( * ) - libgcc.a ( * ) + /DISCARD/ : { + libc.a(*) + libm.a(*) + libgcc.a(*) } }