Skip to content

Commit

Permalink
Makefile and linker update
Browse files Browse the repository at this point in the history
1) Custom linker script in case we are using luftboot (8kb memory offset)
2) Custom makefiles rules for chibios (no .dep/ folder)
  • Loading branch information
podhrmic committed Oct 15, 2013
1 parent fc9e862 commit 542673f
Show file tree
Hide file tree
Showing 4 changed files with 506 additions and 26 deletions.
124 changes: 99 additions & 25 deletions conf/Makefile.chibios
Expand Up @@ -30,6 +30,7 @@
#
CHIBIOS = $(PAPARAZZI_SRC)/sw/ext/chibios
CHIBIOS_SPECIFIC_DIR = $(PAPARAZZI_SRC)/sw/airborne/boards/$(BOARD)/chibios
CHIBIOS_ARCH_DIR = $(PAPARAZZI_SRC)/sw/airborne/arch/chibios

# Launch with "make Q=''" to get full command display
Q=@
Expand Down Expand Up @@ -108,13 +109,14 @@ include $(CHIBIOS)/os/hal/platforms/$(CHIBIOS_BOARD_PLATFORM)
include $(CHIBIOS)/os/hal/hal.mk
include $(CHIBIOS)/os/ports/GCC/$(CHIBIOS_BOARD_PORT)
include $(CHIBIOS)/os/kernel/kernel.mk
#include $(CHIBIOS)/test/test.mk


# Define linker script file here
ifdef NO_LUFTBOOT
LDSCRIPT= $(PORTLD)/$(CHIBIOS_BOARD_LINKER)
# Define linker script file here
#LDSCRIPT= $($(TARGET).LDSCRIPT)
else
LDSCRIPT= $(CHIBIOS_ARCH_DIR)/$(CHIBIOS_BOARD_LINKER)
endif

# C sources that can be compiled in ARM or THUMB mode depending on the global
# setting.
Expand Down Expand Up @@ -251,29 +253,11 @@ ULIBS =
# End of user defines
##############################################################################

# TODO: remove these...
# Info messages
#$(info CHIBIOS = $(CHIBIOS))
#$(info PORTSRC = $(PORTSRC))
#$(info KERNSRC = $(KERNSRC))
#$(info TESTSRC = $(TESTSRC))
#$(info HALSRC = $(HALSRC))
#$(info PLATFORMSRC = $(PLATFORMSRC))
#$(info BOARDSRC = $(BOARDSRC))
$(info INCDIR = $(INCDIR))
$(info UINCDIR = $(UINCDIR))
$(info CSRC = $(CSRC))
$(info UDEFS = $(UDEFS))

#
# Include upload rules
##############################################################################
# Default upload using black magic probe
#ifndef FLASH_MODE
#FLASH_MODE = JTAG
#endif

# for now, no luftboot
# default: assume the luftboot bootloader is used
# if luftboot is not used define NO_LUFTBOOT to a value != 0
ASSUMING_LUFTBOOT = "yes"

# Settings for GDB
Expand All @@ -294,8 +278,98 @@ OOCD_BOARD = $($(TARGET).OOCD_BOARD)
endif
###############################################################################
# Upload makefile
include $(PAPARAZZI_HOME)/conf/Makefile.stm32-upload
#include $(PAPARAZZI_HOME)/conf/Makefile.stm32-upload
#
# check which flash mode is configured
#
ifeq ($(FLASH_MODE),DFU)
ifeq ($(DFU_UTIL),y)
#
# DFU flash mode using dfu-util
DFU_ADDR ?= 0x08000000
upload: $(OBJDIR)/$(TARGET).bin
@echo "Using dfu-util at $(DFU_ADDR)"
$(Q)dfu-util -d 0483:df11 -c 1 -i 0 -a 0 -s $(DFU_ADDR) -D $^
else
#
# DFU flash mode paparazzi stm32_mem
ifdef DFU_ADDR
DFU_ADDR_CMD = --addr=$(DFU_ADDR)
endif
ifdef DFU_PRODUCT
DFU_PRODUCT_CMD = --product=$(DFU_PRODUCT)
endif
upload: $(OBJDIR)/$(TARGET).bin
@echo "Using stm32 mem dfu loader"
$(PYTHON) $(PAPARAZZI_SRC)/sw/tools/dfu/stm32_mem.py $(DFU_PRODUCT_CMD) $(DFU_ADDR_CMD) $^
endif

#
# serial flash mode
else ifeq ($(FLASH_MODE),SERIAL)
upload: $(OBJDIR)/$(TARGET).bin
$(LOADER) -p /dev/ttyUSB0 -b 115200 -e -w -v $^
#
# JTAG flash mode
else ifeq ($(FLASH_MODE),JTAG)
# either via normal jtag or BlackMagicProbe
ifeq ($(BMP_PORT),)
# normal jtag via OpenOCD
upload: $(OBJDIR)/$(TARGET).hex
@echo "Assuming luftboot bootloader: $(ASSUMING_LUFTBOOT)"
@echo "Using OOCD = $(OOCD)"
@echo " OOCD\t$<"
$(Q)$(OOCD) -f interface/$(OOCD_INTERFACE).cfg \
-f board/$(OOCD_BOARD).cfg $(OOCD_OPTIONS) \
-c init \
-c "reset halt" \
-c "reset init" \
-c "flash erase_sector 0 $(OOCD_START_SECTOR) last" \
-c "flash write_image $<" \
-c reset \
-c shutdown
else
# jtag via BMP
BMP_UPLOAD_SCRIPT ?= $(PAPARAZZI_SRC)/sw/tools/flash_scripts/bmp_jtag_flash.scr

upload: $(OBJDIR)/$(TARGET).elf
@echo "Assuming luftboot bootloader: $(ASSUMING_LUFTBOOT)"
@echo "Using Black Magic Probe with JTAG on BMP_PORT $(BMP_PORT)"
@echo "Using GDB = $(GDB)"
@echo " BMP\t$<"
$(Q)$(GDB) --batch \
-ex 'target extended-remote $(BMP_PORT)' \
-x $(BMP_UPLOAD_SCRIPT) \
$<
endif
#
# SWD flash mode
else ifeq ($(FLASH_MODE),SWD)
# only works if BMP_PORT is defined
ifeq ($(STLINK),y)
STLINK_ADDR ?= 0x08000000
upload: $(OBJDIR)/$(TARGET).bin
@echo "Using ST-LINK with SWD at $(STLINK_ADDR)"
$(Q)st-flash write $^ $(STLINK_ADDR)
else
BMP_PORT ?= /dev/ttyACM0
BMP_UPLOAD_SCRIPT ?= $(PAPARAZZI_SRC)/sw/tools/flash_scripts/bmp_swd_flash.scr
upload: $(OBJDIR)/$(TARGET).elf
@echo "Assuming luftboot bootloader: $(ASSUMING_LUFTBOOT)"
@echo "Using Black Magic Probe with SWD on BMP_PORT $(BMP_PORT)"
@echo "Using GDB = $(GDB)"
@echo " BMP\t$<"
$(Q)$(GDB) --batch \
-ex 'target extended-remote $(BMP_PORT)' \
-x $(BMP_UPLOAD_SCRIPT) \
$<
endif
#
# no known flash mode
else
upload:
@echo unknown flash_mode $(FLASH_MODE)
endif

###############################################################################
ifeq ($(USE_FPU),yes)
Expand All @@ -306,4 +380,4 @@ else
endif

# Compile
include $(CHIBIOS)/os/ports/GCC/ARMCMx/rules.mk
include $(PAPARAZZI_HOME)/conf/chibios_rules.mk
1 change: 0 additions & 1 deletion conf/boards/lia_1.1_chibios.makefile
Expand Up @@ -65,7 +65,6 @@ DFU_UTIL ?= n

ifndef NO_LUFTBOOT
$(TARGET).CFLAGS+=-DLUFTBOOT
$(TARGET).LDFLAGS+=-Wl,-Ttext=0x8002000
endif

##############################################################################
Expand Down

0 comments on commit 542673f

Please sign in to comment.