lm4f: Fix problems with example Makefile.include

Fix three distinct issues were present with
examples/lm4f/Makefile.include:
1. Architecture flags were not being passed to the linker. This caused the linker
to link against the wrong libraries when trying to use any C library, causing
hard faults.
2. -lc and -lnosys were not linked against. Try using printf() without -lnosys
3. The makefile erroneously specified -mcpu=cortex-m3 instead of m4.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
This commit is contained in:
Alexandru Gagniuc 2012-11-27 08:20:54 -06:00
parent b2ac2ffc4b
commit c08bd17d90

View File

@ -6,7 +6,7 @@
## Copyright (C) 2012 Alexandru Gagniuc <mr.nuke.me@gmail.com> ## Copyright (C) 2012 Alexandru Gagniuc <mr.nuke.me@gmail.com>
## ##
## This library is free software: you can redistribute it and/or modify ## This library is free software: you can redistribute it and/or modify
## it under the terms of the GNU Lesser General Public License as published by ## it undebipr the terms of the GNU Lesser General Public License as published by
## the Free Software Foundation, either version 3 of the License, or ## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version. ## (at your option) any later version.
## ##
@ -20,7 +20,6 @@
## ##
PREFIX ?= arm-none-eabi PREFIX ?= arm-none-eabi
#PREFIX ?= arm-elf
CC = $(PREFIX)-gcc CC = $(PREFIX)-gcc
LD = $(PREFIX)-gcc LD = $(PREFIX)-gcc
OBJCOPY = $(PREFIX)-objcopy OBJCOPY = $(PREFIX)-objcopy
@ -37,17 +36,23 @@ $(info We seem to be building the example in the source directory. Using local l
endif endif
endif endif
CFLAGS += -O0 -g3 -Wall -Wextra -I$(TOOLCHAIN_DIR)/include -fno-common \ ARCH_FLAGS = -mthumb -mcpu=cortex-m4
-mcpu=cortex-m3 -mthumb -MD -DLM4F CFLAGS += -O0 -g3 -Wall -Wextra -I$(TOOLCHAIN_DIR)/include \
-fno-common $(ARCH_FLAGS) -MD -DLM4F
LDSCRIPT ?= $(BINARY).ld LDSCRIPT ?= $(BINARY).ld
LDFLAGS += -L$(TOOLCHAIN_DIR)/lib \ LDFLAGS += --static -Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group \
-T$(LDSCRIPT) -nostartfiles -Wl,--gc-sections -L$(TOOLCHAIN_DIR)/lib \
-T$(LDSCRIPT) -nostartfiles -Wl,--gc-sections \
$(ARCH_FLAGS)
OBJS += $(BINARY).o OBJS += $(BINARY).o
# Support for ICDI is not in any openocd release as of yet
# A patch to add support for ICDI is under review
OOCD ?= openocd OOCD ?= openocd
OOCD_INTERFACE ?= flossjtag OOCD_INTERFACE ?= ti-icdi
OOCD_BOARD ?= olimex_stm32_h103 # No official board.cfg for the stellaris launchpad
# FIXME OOCD_BOARD ?= stellaris_launchpad
# Be silent per default, but 'make V=1' will show all compiler calls. # Be silent per default, but 'make V=1' will show all compiler calls.
ifneq ($(V),1) ifneq ($(V),1)
@ -87,7 +92,7 @@ flash: $(BINARY).flash
%.elf: $(OBJS) $(LDSCRIPT) $(TOOLCHAIN_DIR)/lib/libopencm3_lm4f.a %.elf: $(OBJS) $(LDSCRIPT) $(TOOLCHAIN_DIR)/lib/libopencm3_lm4f.a
@#printf " LD $(subst $(shell pwd)/,,$(@))\n" @#printf " LD $(subst $(shell pwd)/,,$(@))\n"
$(Q)$(LD) $(LDFLAGS) -o $(*).elf $(OBJS) -lopencm3_lm4f $(Q)$(LD) -o $(*).elf $(OBJS) -lopencm3_lm4f $(LDFLAGS)
%.o: %.c Makefile %.o: %.c Makefile
@#printf " CC $(subst $(shell pwd)/,,$(@))\n" @#printf " CC $(subst $(shell pwd)/,,$(@))\n"
@ -102,7 +107,7 @@ clean:
$(Q)rm -f *.srec $(Q)rm -f *.srec
$(Q)rm -f *.list $(Q)rm -f *.list
# FIXME: Replace STM32 stuff with proper LPC13XX OpenOCD support later. # FIXME: Replace STM32 stuff with proper Stellaris support.
ifeq ($(OOCD_SERIAL),) ifeq ($(OOCD_SERIAL),)
%.flash: %.hex %.flash: %.hex
@printf " FLASH $<\n" @printf " FLASH $<\n"