Statistics
| Branch: | Tag: | Revision:

amiro-os / bootloader / bootloader.mk @ e375d633

History | View | Annotate | Download (3.55 KB)

1
################################################################################
2
# AMiRo-OS is an operating system designed for the Autonomous Mini Robot       #
3
# (AMiRo) platform.                                                            #
4
# Copyright (C) 2016..2020  Thomas Schöpping et al.                            #
5
#                                                                              #
6
# This program is free software: you can redistribute it and/or modify         #
7
# it under the terms of the GNU General Public License as published by         #
8
# the Free Software Foundation, either version 3 of the License, or            #
9
# (at your option) any later version.                                          #
10
#                                                                              #
11
# This program is distributed in the hope that it will be useful,              #
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of               #
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                #
14
# GNU General Public License for more details.                                 #
15
#                                                                              #
16
# You should have received a copy of the GNU General Public License            #
17
# along with this program.  If not, see <http://www.gnu.org/licenses/>.        #
18
#                                                                              #
19
# This research/work was supported by the Cluster of Excellence Cognitive      #
20
# Interaction Technology 'CITEC' (EXC 277) at Bielefeld University, which is   #
21
# funded by the German Research Foundation (DFG).                              #
22
################################################################################
23

    
24

    
25

    
26
# path to this makefile
27
AMIROOS_BOOTLOADER_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
28

    
29
# set AMiRo-BLT path variable
30
AMIROBLT := $(AMIROOS_BOOTLOADER_DIR)AMiRo-BLT
31

    
32
# include paths
33
AMIROOS_BOOTLOADER_INC = $(AMIROOS_BOOTLOADER_DIR) \
34
                         $(AMIROBLT)/Target/Source/AMiRo
35

    
36
# load module ID constants
37
include $(AMIROBLT)/Target/Modules/moduleids.mk
38

    
39
# set the FLASH_PORT if no custom value has been specified
40
ifeq ($(FLASH_PORT),)
41
  ifeq ($(OS),Windows_NT)
42
    FLASH_PORT ?= COM4
43
  else
44
    # check whether /dev/ttyAMiRo0 exists
45
    ifeq ($(wildcard /dev/ttyAMiRo0),)
46
      # check whether /dev/ttyUSB0 exists
47
      ifeq ($(wildcard /dev/ttyUSB0),)
48
        # set to /dev/ttyAMiRo0 for meaningful error message
49
        FLASH_PORT ?= /dev/ttyAMiRo0
50
      else
51
        # legacy support
52
        FLASH_PORT ?= /dev/ttyUSB0
53
      endif
54
    else
55
      FLASH_PORT ?= /dev/ttyAMiRo0
56
    endif
57
  endif
58
endif
59
# set the baud rate if no custom value has been specified
60
FLASH_BAUDRATE ?= 115200
61

    
62
# set the flashing tool, the command to call it, arguments, and file extensions
63
ifneq ($(wildcard $(AMIROBLT)/Host/Source/SerialBoot/build/SerialBoot),)
64
  # if AMiRo-BLT project is available, use SerialBoot
65
  FLASHTOOL := SerialBoot
66
  FLASHTOOL_CMD := $(AMIROBLT)/Host/Source/SerialBoot/build/SerialBoot
67
  FLASHTOOL_EXT := srec
68
  FLASHTOOL_ARGS = -d$(FLASH_PORT) -b$(FLASH_BAUDRATE) $(foreach module,$(FLASH_MODULES),-T$($(module)_ID_HEX) $(BUILDDIR)/$(module).$(FLASHTOOL_EXT))
69
else
70
  # the default tool to use is stm32flash
71
  ifneq ($(words $(FLASH_MODULES)),1)
72
    FLASH_MODULES := $(firstword $(FLASH_MODULES))
73
  endif
74
  FLASHTOOL := stm32flash
75
  FLASHTOOL_CMD := stm32flash
76
  FLASHTOOL_EXT := hex
77
  FLASHTOOL_ARGS = $(FLASH_PORT) -i "rts,-dtr,-rts":"rts,dtr,-rts" -R -b $(FLASH_BAUDRATE) -w $(BUILDDIR)/$(FLASH_MODULES).$(FLASHTOOL_EXT)
78
endif
79