You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
124 lines
3.7 KiB
124 lines
3.7 KiB
9 years ago
|
#####################################################################################
|
||
|
# File config
|
||
|
#####################################################################################
|
||
|
|
||
|
main_file = main.asm
|
||
|
startup_file = startup_stm32l100xc.s
|
||
|
lib_dir = lib/
|
||
|
|
||
|
#####################################################################################
|
||
|
# ASSEMBLER CONFIG
|
||
|
#####################################################################################
|
||
|
|
||
9 years ago
|
ASOPTS = --cpu Cortex-M3 -g --apcs interwork
|
||
9 years ago
|
|
||
|
# Add library to include path
|
||
|
ASOPTS += -I$(lib_dir)
|
||
|
|
||
|
|
||
|
#####################################################################################
|
||
|
# LINKER CONFIG
|
||
|
#####################################################################################
|
||
|
|
||
|
LDOPTS = --cpu Cortex-M3 --strict
|
||
9 years ago
|
LDOPTS += --bestdebug
|
||
9 years ago
|
LDOPTS += --ro-base 0x08000000 --entry 0x08000000 --rw-base 0x20000000
|
||
|
LDOPTS += --entry Reset_Handler --first __Vectors
|
||
|
|
||
|
# Verbose flags (run make V=1)
|
||
|
ifeq ($(V), 1)
|
||
|
LDOPTS += --summary_stderr --map --xref --callgraph --symbols
|
||
|
LDOPTS += --info summarysizes,sizes,totals,unused,veneers
|
||
|
endif
|
||
|
|
||
|
|
||
|
#####################################################################################
|
||
9 years ago
|
# EXTERNAL PROGRAMS
|
||
9 years ago
|
#####################################################################################
|
||
|
|
||
|
# armlink, armasm, fromelf - exe files in Wine directory (with Keil installed)
|
||
|
|
||
9 years ago
|
# Disable Wine fixme warnings
|
||
9 years ago
|
ENVS = WINEDEBUG=fixme-all
|
||
9 years ago
|
# Stop DS-5 from trying to use it's internal unlicensed compiler (Attempt at DRM?)
|
||
|
ENVS += ARMCC5_ASMOPT='' ARMCC5_CCOPT='' ARMCC5_FROMELFOPT='' ARMCC5_LINKOPT='' ARMCOMPILER6_ASMOPT='' ARMCOMPILER6_CLANGOPT=''
|
||
|
ENVS += ARMCOMPILER6_FROMELFOPT='' ARMCOMPILER6_LINKOPT='' ARM_PRODUCT_PATH='' ARM_TOOL_VARIANT=''
|
||
|
|
||
9 years ago
|
# ARM_PRODUCT_PATH should be possible to use if you want to run linux version of those programs.
|
||
9 years ago
|
|
||
|
WINEPREFIX=$(ENVS) wine ~/.wine/drive_c/Keil_v5/ARM/ARMCC_505u2/bin
|
||
|
|
||
9 years ago
|
# ARM programs from Keil
|
||
9 years ago
|
LD = $(WINEPREFIX)/armlink.exe
|
||
|
AS = $(WINEPREFIX)/armasm.exe
|
||
|
FROMELF = $(WINEPREFIX)/fromelf.exe
|
||
9 years ago
|
|
||
|
# Native programs
|
||
9 years ago
|
OBJDUMP = arm-none-eabi-objdump
|
||
|
STFLASH = st-flash
|
||
|
RM = rm
|
||
|
|
||
|
|
||
|
# --- END OF CONFIG ---
|
||
|
|
||
|
main_base = $(basename $(main_file))
|
||
|
startup_base = $(basename $(startup_file))
|
||
|
|
||
|
|
||
|
.PHONY: all build clean flash hex disasm
|
||
|
|
||
|
all: build
|
||
|
|
||
|
# Link object files to AXF file
|
||
|
output.axf: $(main_base).o $(startup_base).o
|
||
9 years ago
|
@echo "== Linking object files to $@ =="
|
||
9 years ago
|
@$(LD) $(LDOPTS) --output $@ "$(main_base).o" "$(startup_base).o"
|
||
|
|
||
|
# Get BIN image file from AXF file
|
||
|
%.bin: %.axf
|
||
9 years ago
|
@echo "== Converting $< to $@ =="
|
||
9 years ago
|
@$(FROMELF) --bincombined --output $@ $<
|
||
|
|
||
|
# Get Intel Hex file from AXF file
|
||
|
%.hex: %.axf
|
||
9 years ago
|
@echo "== Converting $< to $@ =="
|
||
9 years ago
|
@$(FROMELF) --i32combined --output $@ $<
|
||
|
|
||
|
# Get Object file from Assembler source file
|
||
|
$(main_base).o: $(main_file)
|
||
9 years ago
|
@echo "== Compiling $< to $@ =="
|
||
9 years ago
|
@$(AS) $(ASOPTS) --list $(main_base).lst -o $@ --depend $(main_base).d $<
|
||
|
|
||
|
$(startup_base).o: $(startup_file)
|
||
9 years ago
|
@echo "== Compiling $< to $@ =="
|
||
9 years ago
|
@$(AS) $(ASOPTS) --list $(startup_base).lst -o $@ --depend $(startup_base).d $<
|
||
|
|
||
|
# Get binary image (compile and link)
|
||
|
build: output.bin
|
||
|
|
||
|
# Get hex image (compile and link)
|
||
|
hex: output.hex
|
||
|
|
||
|
# Run through assembler (checks for errors)
|
||
|
asm: $(main_base).o
|
||
|
|
||
|
# Run through linker
|
||
|
link: output.axf
|
||
|
|
||
|
# Flash using st-link
|
||
|
flash: output.bin
|
||
9 years ago
|
@echo "== Writing image to device via ST-Link =="
|
||
9 years ago
|
@$(STFLASH) write "output.bin" 0x8000000
|
||
9 years ago
|
@echo "== Write OK! =="
|
||
9 years ago
|
|
||
|
disasm: output.axf
|
||
9 years ago
|
@echo "== Disassembling $< to output.disasm =="
|
||
9 years ago
|
@$(OBJDUMP) -S -d $< > output.disasm
|
||
9 years ago
|
|
||
|
# Remove temporary files
|
||
|
clean:
|
||
9 years ago
|
@echo "== Removing temporary files =="
|
||
9 years ago
|
$(RM) -f *.bak *.lnp *.iex *.hex *.elf *.axf *.htm *.lnp *.lst *.plg *.tra *.o *.map *.d *.dep *.disasm *.bin *.uvguix.*
|
||
|
$(RM) -rf ./RTE
|
||
|
|