Offline compiling
Offline compiling is accomplished by these steps:
1. Download and install the CodeSourcery toolchain for LPC17xx
2. Download
http://www.onarm.com/download/files/cmsis_v1p30.zip
from
http://www.onarm.com/download/download395.asp
3. Unpack and use these files:
-
CMSIS_V1P30/CM3/CoreSupport/core_cm3.c
-
CMSIS_V1P30/CM3/CoreSupport/core_cm3.h
-
CMSIS_V1P30/CM3/DeviceSupport/NXP/LPC17xx/system_LPC17xx.c
-
CMSIS_V1P30/CM3/DeviceSupport/NXP/LPC17xx/system_LPC17xx.h
-
CMSIS_V1P30/CM3/DeviceSupport/NXP/LPC17xx/LPC17xx.h
when compiling for instance the example code in CMSIS_V1P30/CM3/Example/Sourcery G++Lite/LPC17xx/
by using a Makefile similar to this:
# Project Name PROJECT=mbed_test # List of the objects files to be compiled/assembled OBJECTS=startup_LPC17xx.o core_cm3.o system_LPC17xx.o main_LPC17xx.o LSCRIPT=LPC17xx.ld OPTIMIZATION = 0 DEBUG = -g #LISTING = -ahls # Compiler Options GCFLAGS = -Wall -fno-common -mcpu=cortex-m3 -mthumb -O$(OPTIMIZATION) $(DEBUG) #GCFLAGS += -Wcast-align -Wcast-qual -Wimplicit -Wpointer-arith -Wswitch #GCFLAGS += -Wredundant-decls -Wreturn-type -Wshadow -Wunused LDFLAGS = -mcpu=cortex-m3 -mthumb -O$(OPTIMIZATION) -nostartfiles -Wl,-Map=$(PROJECT).map -T$(LSCRIPT) ASFLAGS = $(LISTING) -mcpu=cortex-m3 # Compiler/Assembler/Linker Paths GCC = arm-none-eabi-gcc AS = arm-none-eabi-as LD = arm-none-eabi-ld OBJCOPY = arm-none-eabi-objcopy REMOVE = rm -f SIZE = arm-none-eabi-size ######################################################################### all:: $(PROJECT).hex $(PROJECT).bin $(PROJECT).bin: $(PROJECT).elf $(OBJCOPY) -O binary -j .text -j .data $(PROJECT).elf $(PROJECT).bin $(PROJECT).hex: $(PROJECT).elf $(OBJCOPY) -R .stack -O ihex $(PROJECT).elf $(PROJECT).hex $(PROJECT).elf: $(OBJECTS) $(GCC) $(LDFLAGS) $(OBJECTS) -o $(PROJECT).elf stats: $(PROJECT).elf $(SIZE) $(PROJECT).elf clean: $(REMOVE) $(OBJECTS) $(REMOVE) $(PROJECT).hex $(REMOVE) $(PROJECT).elf $(REMOVE) $(PROJECT).map $(REMOVE) $(PROJECT).bin $(REMOVE) $(OBJECTS) ######################################################################### # Default rules to compile .c and .cpp file to .o # and assemble .s files to .o .c.o : $(GCC) $(GCFLAGS) -c $< .cpp.o : $(GCC) $(GCFLAGS) -c $< .S.o : $(AS) $(ASFLAGS) -o $(PROJECT)_crt.o $< > $(PROJECT)_crt.lst #########################################################################
Some modifications are necessary:
-
Delete the “GROUP(-lgcc -lc -lcs3 -lcs3unhosted -lcs3micro)” line (line 21) from LPC17xx.ld linker script.
-
Change “ENTRY(_start)” to “ENTRY(main)” (line 19) in LPC17xx.ld.
-
Change “_start” to “main” on line 126 in startup_LPC17xx.s.
-
Adjust the sample LED flashing program in main_LPC17xx.c for the mbed pinout: I just changed the FIODIR 0xB0000000 to 0xFFFFFFFF and the LED being turned on from 1«28 to 1«18 (this corresponds to LED1 on the mbed board).
EOF
0 comments
You need to log in to post a comment