From b39a79582c6b821d24b4bfb3a0e27d9e7af0223f Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Sat, 3 Aug 2013 14:11:44 -0400 Subject: [PATCH] Build system builds the peripheral library proprly now. --- .gitignore | 1 + Makefile | 11 +++++------ Makefile.common | 4 ++-- Makefile.opts | 3 ++- crosstool-ng/config/configure.in | 14 -------------- libs/stm32f10x.mk | 20 ++++++++++++-------- 6 files changed, 22 insertions(+), 31 deletions(-) delete mode 100644 crosstool-ng/config/configure.in diff --git a/.gitignore b/.gitignore index 20f345c..8557cab 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ *.o *.elf *.bin +*.ld # Autogenerated files inc/version.h diff --git a/Makefile b/Makefile index 68e0827..0dfcec4 100644 --- a/Makefile +++ b/Makefile @@ -22,9 +22,9 @@ LIBS_OBJS = $(MCU_LIBS_OBJS) PROGRAM_LIBS = src/core.a # Generic compilation rules -XXXX.ld: libs/$(MCU).ld.in inc/hw.h +XXXX.ld: libs/$(MCU).ld.in inc/hw.h $(LIBRARIES) @$(E) " GENERATE " $@ - $(Q)$(CPP) $(TARGET_LDCPPFLAGS) $(MCU).ld.in -P -o $@ + $(Q)$(CPP) $(TARGET_LDCPPFLAGS) -I$(TOP) libs/$(MCU).ld.in -P -o $@ %.bin: %.elf @$(E) " OBJCOPY " $@ @@ -50,11 +50,10 @@ distclean: clean ${RM} -f $(DEPFILE) $(VERSION_H) ${RM} -f $(LIBS_OBJS) $(LIBRARIES) ${RM} -Rf $(TOOLCHAIN_SRC_DIR)/.build - if [ -r ${TOOLCHAIN_SRC_DIR}/Makefile ] ; then \ + @if [ -r ${TOOLCHAIN_SRC_DIR}/Makefile ] ; then \ cd ${TOOLCHAIN_SRC_DIR} ; \ - make uninstall ; \ - make clean ; \ - make distclean ; \ + MAKELEVEL='' make clean ; \ + MAKELEVEL='' make distclean ; \ fi ${RM} -f .toolchain ${RM} -f tags TAGS diff --git a/Makefile.common b/Makefile.common index 7069134..73a2340 100644 --- a/Makefile.common +++ b/Makefile.common @@ -26,8 +26,8 @@ JLEVEL:=${shell cat /proc/cpuinfo |grep processor |wc -l} LIBDIR=$(TOP)/libs # Compiler flags -CFLAGS += -pipe -Wall -Wextra -g -Os -flto -fuse-linker-plugin -fwhole-program -std=c99 $(TARGET_CFLAGS) -CPPFLAGS += $(MCU_CFLAGS) $(MCU_INCLUDE) $(TARGET_CPPFLAGS) $(INCLUDE) +CFLAGS += -pipe -Wall -Wextra -g -Os -flto -fuse-linker-plugin -fwhole-program -std=c99 $(MCU_CFLAGS) $(TARGET_CFLAGS) +CPPFLAGS += $(MCU_INCLUDE) $(INCLUDE) $(MCU_CPPFLAGS) $(TARGET_CPPFLAGS) # Linker Flags LDFLAGS += -fno-exceptions -ffunction-sections -fdata-sections -nostartfiles # -fuse-linker-plugin diff --git a/Makefile.opts b/Makefile.opts index cee52b1..e13bc5a 100644 --- a/Makefile.opts +++ b/Makefile.opts @@ -1,7 +1,8 @@ # Add build-specific stuff here: MCU=stm32f10x -MCU_SUBTYPE=stm32f10x_ld ### _ld, _ld_vl, _md, _md_vl, _hd, _hd_vl, _xl, _cl +MCU_SUBTYPE=stm32f10x_ld +### _ld, _ld_vl, _md, _md_vl, _hd, _hd_vl, _xl, _cl TARGET_LDCPPFLAGS = -DMCU=$(MCU) -DFLASH=_FLASH_0 #TARGET_CPPFLAGS = -DVECT_TAB_SRAM diff --git a/crosstool-ng/config/configure.in b/crosstool-ng/config/configure.in deleted file mode 100644 index 7080cf1..0000000 --- a/crosstool-ng/config/configure.in +++ /dev/null @@ -1,14 +0,0 @@ -# Generated file, do not edit -# Default values as found by ./configure - -config CONFIGURE_has_xz - def_bool y - -config CONFIGURE_has_lzma - bool - -config CONFIGURE_has_cvs - def_bool y - -config CONFIGURE_has_svn - bool diff --git a/libs/stm32f10x.mk b/libs/stm32f10x.mk index 3b2e4b4..de88ae4 100644 --- a/libs/stm32f10x.mk +++ b/libs/stm32f10x.mk @@ -4,14 +4,18 @@ MCU_CORE=cm3 MCU_INCLUDE += -I$(LIBDIR)/CMSIS/Include MCU_INCLUDE += -I$(LIBDIR)/CMSIS/Device/ST/STM32F10x/Include MCU_INCLUDE += -I$(LIBDIR)/STM32F10x_StdPeriph_Driver/inc + # Set up CFLAGS -MCU_CPPFLAGS += -D$(call uc,$MCU_SUBTYPE) +#MCU_CPPFLAGS += -D$(call uc,$(MCU_SUBTYPE)) +MCU_CPPFLAGS += -D$(shell echo -n $(MCU_SUBTYPE) | tr a-z A-Z ) +MCU_CPPFLAGS += -D"assert_param(expr)=((void)0)" MCU_CFLAGS += -mcpu=cortex-m3 -mthumb -Wa,-mthumb + # Target Libraries MCU_LIBS += $(LIBDIR)/libstm32f10x.a # CMSIS -STM32F10x_OBJS = $(LIBDIR)/$(MCU_SUBTYPE)_startup.o $(LIBDIR)/CMSIS/Device/ST/STM32F10x/Source/Templates/system_stm32f10x.o +STM32F10x_OBJS = $(LIBDIR)/CMSIS/Device/ST/STM32F10x/Source/Templates/system_stm32f10x.o # Standard Peripheral Library STM32F10x_OBJSR = misc.o stm32f10x_dac.o stm32f10x_gpio.o stm32f10x_sdio.o \ stm32f10x_adc.o stm32f10x_dbgmcu.o stm32f10x_i2c.o stm32f10x_spi.o \ @@ -20,17 +24,17 @@ STM32F10x_OBJSR = misc.o stm32f10x_dac.o stm32f10x_gpio.o stm32f10x_sdio.o \ stm32f10x_cec.o stm32f10x_flash.o stm32f10x_rcc.o stm32f10x_wwdg.o \ stm32f10x_crc.o stm32f10x_fsmc.o stm32f10x_rtc.o -STM32F10x_OBJS += $(addprefix $(LIBDIR)/STM32F10x_StdPeriph_Driver/src,$(STM32F10x_OBJSR)) +STM32F10x_OBJS += $(addprefix $(LIBDIR)/STM32F10x_StdPeriph_Driver/src/,$(STM32F10x_OBJSR)) # Bookkeeping MCU_LIBS_OBJS += $(STM32F10x_OBJS) # Build Rules -$(LIBDIR)/$(MCU_SUBTYPE)_startup.o: $(LIBDIR)/CMSIS/Device/ST/STM32F10x/Source/Templates/gcc_ride7/startup_$(MCU_SUBTYPE).s - @$(E) " AR " $@ - $(Q)$(AS) -o $@ $< +$(LIBDIR)/startup_$(MCU_SUBTYPE).o: $(LIBDIR)/CMSIS/Device/ST/STM32F10x/Source/Templates/gcc_ride7/startup_$(MCU_SUBTYPE).s + @$(E) " AS " $@ + $(Q)$(AS) -c -o $@ $< -$(LIBDIR)/libstm32f10x.a: $(STM32F10x_OBJS) +$(LIBDIR)/libstm32f10x.a: $(STM32F10x_OBJS) $(LIBDIR)/startup_$(MCU_SUBTYPE).o @$(E) " AR " $@ - $(Q)$(AR) cr $@ $(STM32F10x_OBJS) + $(Q)$(AR) cr $@ $(STM32F10x_OBJS) $(LIBDIR)/startup_$(MCU_SUBTYPE).o