Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Copyright 2014, Jernej Kovacic
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- #
- # Type "make help" for more details.
- #
- # quiet build
- AD = @
- TOOLCHAIN = arm-none-eabi-
- CC = $(TOOLCHAIN)gcc
- CXX = $(TOOLCHAIN)g++
- AS = $(TOOLCHAIN)as
- LD = $(TOOLCHAIN)ld
- OBJCOPY = $(TOOLCHAIN)objcopy
- SIZE = $(TOOLCHAIN)size
- AR = $(TOOLCHAIN)ar
- FLASHER = lm4flash
- TERM = pyterm
- TARGS= -p /dev/ttyACM0
- INCLUDEFLAG = -I
- CPUFLAG = -mthumb -mcpu=cortex-m4
- FPUFLAG = -mfpu=fpv4-sp-d16 -mfloat-abi=hard
- WFLAG = -Wall -Wextra -Werror -Wstrict-prototypes
- CFLAGS += -std=gnu99 $(WFLAG) $(CPUFLAG) $(FPUFLAG) -mlittle-endian -mthumb -mthumb-interwork -nostartfiles
- CFLAGS += -ffunction-sections -fdata-sections -fno-builtin
- LDFLAGS += -nostdlib --gc-sections -static
- # Additional C compiler flags to produce debugging symbols
- DEB_FLAG = -ggdb -g3 -DDEBUG
- # Compiler/target path in FreeRTOS/Source/portable
- PORT_COMP_TARG = GCC/ARM_CM4F/
- # Intermediate directory for all *.o and other files:
- OBJDIR = obj/
- # FreeRTOS source base directory
- FREERTOS_SRC = FreeRTOS/Source/
- # Directory with memory management source files
- FREERTOS_MEMMANG_SRC = $(FREERTOS_SRC)portable/MemMang/
- # Directory with platform specific source files
- FREERTOS_PORT_SRC = $(FREERTOS_SRC)portable/$(PORT_COMP_TARG)
- # Directory with HW drivers' source files
- DRIVERS_SRC = drivers/
- # Directory with demo specific source (and header) files
- APP_SRC = app/
- LIB_SRC = lib/
- # Specify location of TivaWare
- TIVAWARE = TivaWare/
- PART=TM4C123GH6PM
- CFLAGS +=-DTARGET_IS_BLIZZARD_RB1 -DPART_${PART}
- # Object files to be linked into an application
- # Due to a large number, the .o files are arranged into logical groups:
- FREERTOS_OBJS = queue.o list.o tasks.o
- # The following o. files are only necessary if
- # certain options are enabled in FreeRTOSConfig.h
- #FREERTOS_OBJS += timers.o
- #FREERTOS_OBJS += croutine.o
- #FREERTOS_OBJS += event_groups.o
- # Only one memory management .o file must be uncommented!
- FREERTOS_MEMMANG_OBJS = heap_1.o
- #FREERTOS_MEMMANG_OBJS = heap_2.o
- #FREERTOS_MEMMANG_OBJS = heap_3.o
- #FREERTOS_MEMMANG_OBJS = heap_4.o
- #FREERTOS_MEMMANG_OBJS = heap_5.o
- FREERTOS_PORT_OBJS = port.o
- # DRIVERS_OBJS = sysctl.o systick.o nvic.o scb.o interrupt.o
- #Unnnecessary driver object files may be commented out
- DRIVERS_OBJS += led.o
- DRIVERS_OBJS += uart.o
- # DRIVERS_OBJS += watchdog.o
- # DRIVERS_OBJS += led.o
- # DRIVERS_OBJS += switch.o
- APP_OBJS = startup.o init.o main.o
- # APP_OBJS += wdtask.o
- # APP_OBJS += print.o
- # APP_OBJS += receive.o
- # APP_OBJS += lightshow.o
- # nostdlib.o must be commented out if standard lib is going to be linked!
- LIB_OBJS += nostdlib.o
- LIB_OBJS += printf.o
- # All object files specified above are prefixed the intermediate directory
- OBJS = $(addprefix $(OBJDIR), $(FREERTOS_OBJS) $(FREERTOS_MEMMANG_OBJS) $(FREERTOS_PORT_OBJS) $(DRIVERS_OBJS) $(APP_OBJS) $(LIB_OBJS))
- # Definition of the linker script and final targets
- LINKER_SCRIPT = $(addprefix $(APP_SRC), tiva.ld)
- ELF_IMAGE = image.elf
- TARGET = image.bin
- # Include paths to be passed to $(CC) where necessary
- INC_FREERTOS = $(FREERTOS_SRC)include/
- INC_DRIVERS = $(DRIVERS_SRC)include/
- INC_LIB = $(LIB_SRC)include/
- # Complete include flags to be passed to $(CC) where necessary
- INC_FLAGS = $(INCLUDEFLAG)$(INC_FREERTOS) $(INCLUDEFLAG)$(APP_SRC) $(INCLUDEFLAG)$(FREERTOS_PORT_SRC) $(INCLUDEFLAG)$(INC_DRIVERS) $(INCLUDEFLAG)$(INC_LIB) $(INCLUDEFLAG)$(TIVAWARE)
- DEP_FRTOS_CONFIG = $(APP_SRC)/FreeRTOSConfig.h
- DEP_SETTINGS = $(DEP_FRTOS_CONFIG)
- #
- # Make rules:
- #
- all : $(TARGET)
- rebuild : clean all
- $(TARGET) : $(OBJDIR) $(ELF_IMAGE)
- $(AD)$(OBJCOPY) -O binary $(word 2,$^) $@
- $(OBJDIR) :
- $(AD)mkdir -p $@
- $(ELF_IMAGE) : $(OBJS) $(LINKER_SCRIPT)
- $(AD)$(LD) $(LDFLAGS) -L $(OBJDIR) -T $(LINKER_SCRIPT) $(OBJS) -o $@
- $(SIZE) $(ELF_IMAGE)
- debug : _debug_flags all
- debug_rebuild : _debug_flags rebuild
- _debug_flags :
- $(eval CFLAGS += $(DEB_FLAG))
- flash : $(TARGET)
- $(FLASHER) $(TARGET)
- term:
- $(TERM) $(TARGS)
- # FreeRTOS core
- $(OBJDIR)queue.o : $(FREERTOS_SRC)queue.c $(DEP_FRTOS_CONFIG)
- $(AD)$(CC) -c $(CFLAGS) $(INC_FLAGS) $< -o $@
- $(OBJDIR)list.o : $(FREERTOS_SRC)list.c $(DEP_FRTOS_CONFIG)
- $(AD)$(CC) -c $(CFLAGS) $(INC_FLAGS) $< -o $@
- $(OBJDIR)tasks.o : $(FREERTOS_SRC)tasks.c $(DEP_FRTOS_CONFIG)
- $(AD)$(CC) -c $(CFLAGS) $(INC_FLAGS) $< -o $@
- $(OBJDIR)timers.o : $(FREERTOS_SRC)timers.c $(DEP_FRTOS_CONFIG)
- $(AD)$(CC) -c $(CFLAGS) $(INC_FLAGS) $< -o $@
- $(OBJDIR)croutine.o : $(FREERTOS_SRC)croutine.c $(DEP_FRTOS_CONFIG)
- $(AD)$(CC) -c $(CFLAGS) $(INC_FLAGS) $< -o $@
- $(OBJDIR)event_groups.o : $(FREERTOS_SRC)event_groups.c $(DEP_FRTOS_CONFIG)
- $(AD)$(CC) -c $(CFLAGS) $(INC_FLAGS) $< -o $@
- # HW specific part, in FreeRTOS/Source/portable/$(PORT_COMP_TARGET)
- $(OBJDIR)port.o : $(FREERTOS_PORT_SRC)port.c $(DEP_FRTOS_CONFIG)
- $(AD)$(CC) -c $(CFLAGS) $(INC_FLAGS) $< -o $@
- # Rules for all MemMang implementations are provided
- # Only one of these object files must be linked to the final target
- $(OBJDIR)heap_1.o : $(FREERTOS_MEMMANG_SRC)heap_1.c $(DEP_FRTOS_CONFIG)
- $(AD)$(CC) -c $(CFLAGS) $(INC_FLAGS) $< -o $@
- $(OBJDIR)heap_2.o : $(FREERTOS_MEMMANG_SRC)heap_2.c $(DEP_FRTOS_CONFIG)
- $(AD)$(CC) -c $(CFLAGS) $(INC_FLAGS) $< -o $@
- $(OBJDIR)heap_3.o : $(FREERTOS_MEMMANG_SRC)heap_3.c $(DEP_FRTOS_CONFIG)
- $(AD)$(CC) -c $(CFLAGS) $(INC_FLAGS) $< -o $@
- $(OBJDIR)heap_4.o : $(FREERTOS_MEMMANG_SRC)heap_4.c $(DEP_FRTOS_CONFIG)
- $(AD)$(CC) -c $(CFLAGS) $(INC_FLAGS) $< -o $@
- $(OBJDIR)heap_5.o : $(FREERTOS_MEMMANG_SRC)heap_5.c $(DEP_FRTOS_CONFIG)
- $(AD)$(CC) -c $(CFLAGS) $(INC_FLAGS) $< -o $@
- # Drivers
- $(OBJDIR)sysctl.o : $(DRIVERS_SRC)sysctl.c $(DEP_BSP)
- $(AD)$(CC) -c $(CFLAGS) $(INC_FLAGS) $< -o $@
- $(OBJDIR)systick.o : $(DRIVERS_SRC)systick.c $(DEP_BSP)
- $(AD)$(CC) -c $(CFLAGS) $(INC_FLAGS) $< -o $@
- $(OBJDIR)nvic.o : $(DRIVERS_SRC)nvic.c $(DEP_BSP)
- $(AD)$(CC) -c $(CFLAGS) $(INC_FLAGS) $< -o $@
- $(OBJDIR)scb.o : $(DRIVERS_SRC)scb.c $(DEP_BSP)
- $(AD)$(CC) -c $(CFLAGS) $(INC_FLAGS) $< -o $@
- $(OBJDIR)interrupt.o : $(DRIVERS_SRC)interrupt.c
- $(AD)$(CC) -c $(CFLAGS) $(INC_FLAGS) $< -o $@
- $(OBJDIR)gpio.o : $(DRIVERS_SRC)gpio.c $(DEP_BSP)
- $(AD)$(CC) -c $(CFLAGS) $(INC_FLAGS) $< -o $@
- $(OBJDIR)uart.o : $(DRIVERS_SRC)uart.c $(DEP_BSP)
- $(AD)$(CC) -c $(CFLAGS) $(INC_FLAGS) $< -o $@
- $(OBJDIR)watchdog.o : $(DRIVERS_SRC)watchdog.c $(DEP_BSP)
- $(AD)$(CC) -c $(CFLAGS) $(INC_FLAGS) $< -o $@
- $(OBJDIR)led.o : $(DRIVERS_SRC)led.c $(DEP_BSP)
- $(AD)$(CC) -c $(CFLAGS) $(INC_FLAGS) $< -o $@
- $(OBJDIR)switch.o : $(DRIVERS_SRC)switch.c $(DEP_BSP)
- $(AD)$(CC) -c $(CFLAGS) $(INC_FLAGS) $< -o $@
- $(OBJDIR)fpu.o : $(DRIVERS_SRC)fpu.c $(DEP_BSP)
- $(AD)$(CC) -c $(CFLAGS) $(INC_FLAGS) $< -o $@
- # Demo application
- $(OBJDIR)startup.o : $(APP_SRC)startup.c $(DEP_SETTINGS)
- $(AD)$(CC) -c $(CFLAGS) $(INC_FLAGS) $< -o $@
- $(OBJDIR)handlers.o : $(APP_SRC)handlers.c $(DEP_SETTINGS)
- $(AD)$(CC) -c $(CFLAGS) $(INC_FLAGS) $< -o $@
- $(OBJDIR)init.o : $(APP_SRC)init.c $(DEP_SETTINGS)
- $(AD)$(CC) -c $(CFLAGS) $(INC_FLAGS) $< -o $@
- $(OBJDIR)main.o : $(APP_SRC)main.c $(DEP_SETTINGS)
- $(AD)$(CC) -c $(CFLAGS) $(INC_FLAGS) $< -o $@
- $(OBJDIR)wdtask.o : $(APP_SRC)wdtask.c $(DEP_SETTINGS)
- $(AD)$(CC) -c $(CFLAGS) $(INC_FLAGS) $< -o $@
- $(OBJDIR)print.o : $(APP_SRC)print.c $(DEP_SETTINGS)
- $(AD)$(CC) -c $(CFLAGS) $(INC_FLAGS) $< -o $@
- $(OBJDIR)receive.o : $(APP_SRC)receive.c $(DEP_SETTINGS)
- $(AD)$(CC) -c $(CFLAGS) $(INC_FLAGS) $< -o $@
- $(OBJDIR)lightshow.o : $(APP_SRC)lightshow.c $(DEP_SETTINGS)
- $(AD)$(CC) -c $(CFLAGS) $(INC_FLAGS) $< -o $@
- $(OBJDIR)nostdlib.o : $(LIB_SRC)nostdlib.c
- $(AD)$(CC) -c $(CFLAGS) $< -o $@
- $(OBJDIR)printf.o : $(LIB_SRC)printf.c
- $(AD)$(CC) -c $(CFLAGS) $< -o $@
- # Cleanup directives:
- clean_obj :
- $(AD)$(RM) -r $(OBJDIR)
- clean_intermediate : clean_obj
- $(AD)$(RM) *.elf
- $(AD)$(RM) *.img
- clean : clean_intermediate
- $(AD)$(RM) *.bin
- # Short help instructions:
- help :
- @echo
- @echo Valid targets:
- @echo - all: builds missing dependencies and creates the target image \'$(IMAGE)\'.
- @echo - rebuild: rebuilds all dependencies and creates the target image \'$(IMAGE)\'.
- @echo - debug: same as \'all\', also includes debugging symbols to \'$(ELF_IMAGE)\'.
- @echo - debug_rebuild: same as \'rebuild\', also includes debugging symbols to \'$(ELF_IMAGE)\'.
- @echo - clean_obj: deletes all object files, only keeps \'$(ELF_IMAGE)\' and \'$(IMAGE)\'.
- @echo - clean_intermediate: deletes all intermediate binaries, only keeps the target image \'$(IMAGE)\'.
- @echo - clean: deletes all intermediate binaries, incl. the target image \'$(IMAGE)\'.
- @echo - help: displays these help instructions.
- @echo
- .PHONY : all rebuild clean clean_intermediate clean_obj debug debug_rebuild _debug_flags help
Advertisement
Add Comment
Please, Sign In to add comment