embedded - Makefile for nrf51sdk -
i working on programming nrf51822 evaluation board(this one). have been looking @ this site program , have gotten blinking program work.
i want modify makefile provided on site mentioned, such when go along pretty have add list of files compile. below have been trying work, not makefiles.
cc := /opt/arm-2012.09/bin/arm-none-eabi-gcc objcopy := /opt/arm-2012.09/bin/arm-none-eabi-objcopy nrf51_sdk := /opt/nrf51sdk nrf51_include := $(nrf51_sdk)/nordic/nrf51822/include nrf51_src := $(nrf51_sdk)/nordic/nrf51822/source cpu := cortex-m0 board := board_pca10001 objdir = . objdir += $(src)/templates/ includedirs = $(nrf51_include) includedirs += $(nrf51_include)/gcc define = board_pca10001 define += nrf51 cflags = -mcpu=$(cpu) cflags +=-mthumb cflags += $(patsubst %,-d%, $(define)) cflags += $(patsubst %,-i%, $(includedirs)) cflags += -c src = main.c src += $(nrf51_src)/templates/system_nrf51.c src += $(nrf51_src)/nrf_delay/nrf_delay.c assembly_src += $(nrf51_src)/templates/gcc/gcc_startup_nrf51.s all: main.bin main.hex %.o : %.c @echo "compiling: " $< $(cc) $(cflags) $< %.o : %.s @echo "compiling: " $< $(cc) $(cflags) $< main.out: $(src) $(assembly_src) $(cc) -l"/opt/arm-2012.09/arm-none-eabi/lib/armv6-m" -l"/opt/arm-2012.09/lib/gcc/arm-none-eabi/4.7.2/armv6-m" -xlinker -map=main.map -mcpu=$(cpu) -mthumb -mabi=aapcs -t$(nrf51_sdk)/nordic/nrf51822/source/templates/gcc/gcc_linker_script_nrf51.ld main.o system_nrf51.o nrf_delay.o gcc_startup_nrf51.o -o main.out main.bin: main.out $(objcopy) -o binary main.out main.bin main.hex: main.out $(objcopy) -o ihex main.out main.hex install: main.bin sed 's#\[\[--filename--\]\]#$(pwd)/main.bin#' segger/burn-template.seg > burn.seg ./segger/segger.sh $(pwd)/burn.seg clean: rm *.o *.out *.hex *.seg *.map *.bin *.hex
when runs make outputs following:
/opt/arm-2012.09/bin/arm-none-eabi-gcc -l"/opt/arm-2012.09/arm-none-eabi/lib/armv6-m" -l"/opt/arm-2012.09/lib/gcc/arm-none-eabi/4.7.2/armv6-m" -xlinker -map=main.map -mcpu=cortex-m0 -mthumb -mabi=aapcs -t/opt/nrf51sdk/nordic/nrf51822/source/templates/gcc/gcc_linker_script_nrf51.ld main.o system_nrf51.o nrf_delay.o gcc_startup_nrf51.o -o main.out arm-none-eabi-gcc: error: main.o: no such file or directory arm-none-eabi-gcc: error: system_nrf51.o: no such file or directory arm-none-eabi-gcc: error: nrf_delay.o: no such file or directory arm-none-eabi-gcc: error: gcc_startup_nrf51.o: no such file or directory make: *** [main.out] error 1
is there around here can me this?
(copied answer op edit solution)
the op wrote:
i figured out, , sharing if wants know how did it. if comment on how make 'better'
cc := /opt/arm-2012.09/bin/arm-none-eabi-gcc objcopy := /opt/arm-2012.09/bin/arm-none-eabi-objcopy nrf51_sdk := /opt/nrf51sdk nrf51_include := $(nrf51_sdk)/nordic/nrf51822/include nrf51_src := $(nrf51_sdk)/nordic/nrf51822/source cpu := cortex-m0 board := board_pca10001 includedirs = $(nrf51_include) includedirs += $(nrf51_include)/gcc define = board_pca10001 define += nrf51 # compiler stage cflags = -mcpu=$(cpu) cflags += -mthumb cflags += $(patsubst %,-d%, $(define)) cflags += $(patsubst %,-i%, $(includedirs)) cflags += -wall # linker stage ldirs = /opt/arm-2012.09/arm-none-eabi/lib/armv6-m ldirs += /opt/arm-2012.09/lib/gcc/arm-none-eabi/4.7.2/armv6-m tdirs = $(nrf51_src)/templates/gcc/gcc_linker_script_nrf51.ld lflags = -mcpu=$(cpu) lflags += -mthumb lflags += -mabi=aapcs lflags += -wall lflags += $(patsubst %, -l%, $(ldirs)) lflags += $(patsubst %, -t%, $(tdirs)) # source files compile src = main.c src += $(nrf51_src)/templates/system_nrf51.c src += $(nrf51_src)/nrf_delay/nrf_delay.c assembly_src += $(nrf51_src)/templates/gcc/gcc_startup_nrf51.s obj = $(src:.c=.o) $(assembly_src:.s=.o) # default target all: begin gcc_version build end build: main.bin main.hex main.out: $(obj) @echo @echo "linking compiled file. output saved to: " $@ $(cc) $(lflags) $(notdir $(obj)) -o $@ main.bin: main.out @echo @echo "making binary file. output saved to: " $@ $(objcopy) -o binary main.out main.bin main.hex: main.out @echo @echo "making hex file. output saved to: " $@ $(objcopy) -o ihex main.out main.hex upload: @echo @echo "uploading file mcu: " sed 's#\[\[--filename--\]\]#$(pwd)/main.bin#' segger/burn-template.seg > burn.seg ./segger/segger.sh $(pwd)/burn.seg clean: rm *.o *.out *.hex *.seg *.map *.bin *.hex # eye candy begin: @echo @echo "---------- begin ----------" end: @echo @echo "----------- end -----------" gcc_version: @echo @$(cc) --version # general rule compiling c source files %.o : %.c @echo @echo "compiling: " $(notdir $<) $(cc) $(cflags) -c $< -o $(notdir $@) # general rule compiling assembly source files %.o : %.s @echo @echo "compiling: " $(notdir $<) $(cc) $(cflags) -c $< -o $(notdir $@)
this @ least works :)
Comments
Post a Comment