60 lines
2.3 KiB
Makefile
60 lines
2.3 KiB
Makefile
GDB ?= gdb
|
|
OPENOCD_SCRIPTS = $(CONTIKI)/drivers/platform/galileo/bsp/openocd-scripts
|
|
|
|
.PHONY: debug $(CONTIKI_PROJECT)
|
|
|
|
# Multiboot ELF binary
|
|
MULTIBOOT_SFX = $(TARGET)
|
|
MULTIBOOT = $(CONTIKI_PROJECT).$(MULTIBOOT_SFX)
|
|
# UEFI binary
|
|
UEFI_DLL_SFX = $(TARGET).dll
|
|
UEFI_DLL = $(CONTIKI_PROJECT).$(UEFI_SFX)
|
|
# The GenFw program is unable to process absolute symbols like _stext_addr,
|
|
# etc., that are defined in quarkX1000_dma.ld and quarkX1000_multi_seg.ld
|
|
# and used to configure segments in multi-segment.c, etc. Furthermore,
|
|
# relocating the UEFI image during load would result in those symbols not
|
|
# pointing to the expected image locations. So, relocation data is omitted
|
|
# from the intermediate UEFI DLL. This will only result in a
|
|
# correctly-functioning build if the UEFI firmware does not attempt to
|
|
# relocate the UEFI image, so it may be desirable in the future to revisit
|
|
# this design. To emit relocation data, '-Xlinker --emit-relocs' should be
|
|
# appended to the following line.
|
|
UEFI_LDFLAGS = -Xlinker --entry=uefi_start
|
|
UEFI_SFX = $(TARGET).efi
|
|
UEFI = $(CONTIKI_PROJECT).$(UEFI_SFX)
|
|
|
|
# Suffixes for final (non-intermediate) files to be built
|
|
FINAL_SFXS = $(MULTIBOOT_SFX)
|
|
ifeq ($(EN_UEFI),1)
|
|
FINAL_SFXS += $(UEFI_SFX)
|
|
endif
|
|
|
|
debug: $(MULTIBOOT)
|
|
@openocd -s $(OPENOCD_SCRIPTS) -f debug.cfg &> $(shell pwd)/LOG_OPENOCD &
|
|
@$(GDB) $< -ex "target remote :3333"
|
|
|
|
CUSTOM_RULE_LINK=1
|
|
|
|
%.$(MULTIBOOT_SFX): %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a
|
|
$(TRACE_LD)
|
|
$(Q)$(LD) $(LDFLAGS) $(MULTIBOOT_LDFLAGS) $(TARGET_STARTFILES) ${filter-out %.a,$^} \
|
|
${filter %.a,$^} $(TARGET_LIBFILES) -o $@
|
|
|
|
%.$(UEFI_DLL_SFX): %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a
|
|
$(TRACE_LD)
|
|
$(Q)$(LD) $(LDFLAGS) $(UEFI_LDFLAGS) $(TARGET_STARTFILES) ${filter-out %.a,$^} \
|
|
${filter %.a,$^} $(TARGET_LIBFILES) -o $@
|
|
|
|
%.$(UEFI_SFX): %.$(UEFI_DLL_SFX)
|
|
$(Q)$(GEN_FW) -o $@ -e UEFI_APPLICATION $^
|
|
# The Intel Galileo firmware has been observed to not relocate the image
|
|
# if its base is set to the 1M boundary. This makes debugging easier,
|
|
# since the symbols in the intermediate DLL then correspond to the load
|
|
# addresses.
|
|
$(Q)$(GEN_FW) -o $@ --rebase 0x100000 $@
|
|
|
|
$(CONTIKI_PROJECT): $(addprefix $(CONTIKI_PROJECT).,$(FINAL_SFXS))
|
|
@$(SIZE) $^
|
|
|
|
CLEAN += $(addprefix $(CONTIKI_PROJECT).,$(FINAL_SFXS))
|