You are on page 1of 2

Offline compiling | mbed

http://mbed.org/users/mjansson/notebook/offline-compiling/

Users mjansson Notebook Oine compiling

Oine compiling
Page last updated 24 Oct 2010, by Marcus Jansson No tags | post a reply

Oine compiling is accomplished by these steps: 1. Download and install the CodeSourcery toolchain for LPC17xx 2. Download http://www.onarm.com/download/les/cmsis_v1p30.zip from http://www.onarm.com/download/download395.asp 3. Unpack and use these les: 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 Makele 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) $(REMOVE) $(REMOVE) $(REMOVE) $(REMOVE) $(REMOVE) $(OBJECTS) $(PROJECT).hex $(PROJECT).elf $(PROJECT).map $(PROJECT).bin $(OBJECTS)

######################################################################### # Default rules to compile .c and .cpp file to .o # and assemble .s files to .o .c.o : $(GCC) $(GCFLAGS) -c $<

1 of 2

Tuesday 01 May 2012 03:26 PM

Offline compiling | mbed


.cpp.o : $(GCC) $(GCFLAGS) -c $< .S.o : $(AS) $(ASFLAGS) -o $(PROJECT)_crt.o $< > $(PROJECT)_crt.lst #########################################################################

http://mbed.org/users/mjansson/notebook/offline-compiling/

Some modications 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 ashing program in main_LPC17xx.c for the mbed pinout: I just changed the FIODIR 0xB0000000 to 0xFFFFFFFF and the LED being turned on from 128 to 118 (this corresponds to LED1 on the mbed board). EOF

0 comments Post new comment


Paragraph

Post comment

2 of 2

Tuesday 01 May 2012 03:26 PM