From f9fc9a6541c505059275b29ae78986f6d8b4a199 Mon Sep 17 00:00:00 2001 From: Felix Ruess Date: Mon, 14 Oct 2013 18:13:50 +0200 Subject: [PATCH] [conf][stm32] separate file for upload rules --- conf/Makefile.stm32 | 96 +----------------------------- conf/Makefile.stm32-upload | 119 +++++++++++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+), 93 deletions(-) create mode 100644 conf/Makefile.stm32-upload diff --git a/conf/Makefile.stm32 b/conf/Makefile.stm32 index 8aaaeddef4..fa39dbb7cf 100644 --- a/conf/Makefile.stm32 +++ b/conf/Makefile.stm32 @@ -227,101 +227,11 @@ $(AOBJ) : $(OBJDIR)/%.o : %.S $(Q)test -d $(dir $@) || mkdir -p $(dir $@) $(Q)$(CC) -c $(AFLAGS) $< -o $@ -# -# 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 - +# Load upload rules +include $(PAPARAZZI_SRC)/conf/Makefile.stm32-upload # Listing of phony targets. -.PHONY : all build elf bin lss sym upload start_gdb start_telnet +.PHONY : all build elf bin lss sym start_gdb start_telnet # # Dependencies diff --git a/conf/Makefile.stm32-upload b/conf/Makefile.stm32-upload new file mode 100644 index 0000000000..2c960fb1bb --- /dev/null +++ b/conf/Makefile.stm32-upload @@ -0,0 +1,119 @@ +# Hey Emacs, this is a -*- makefile -*- +# +# Copyright (C) 2013 Gautier Hattenberger +# +# This file is part of paparazzi. +# +# paparazzi is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# paparazzi is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with paparazzi; see the file COPYING. If not, see +# . +# + +# +# This is the common Makefile for STM32 upload rules +# + +# +# 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 + +.PHONY : upload +