Error with Makefile when recompiling SAM-BA bootloader applet

1 post / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi guys, I am trying to recompile a SAM-BA bootloader applet, but get an error when running the make command.

 

I am using a SAM D21 Xplained Pro evaluation board.

 

At first I had many problems to even get the SAM-BA example tutorial working. (To get it to work, I had to flash the SAM-BA bootloader version 2.16 on my board (which is found under example projects in the Atmel Studio IDE), and use the SAM-BA GUI program version 2.18. For full details, read my other topic.)

 

So as said, I finally got a SAM-BA bootloader working on my Xplained Pro board, with application start address to 0x6000 (by default). But when I want to try to change the default application start address to 0x2000 for example, it doesn't work anymore.

 

I read here in another topic that the start address is hard coded into the applet program. It is this part in the flash_app_main.c file:

 

//Typical monitor size when compiled (rounded to 8kb upper bound)
#define MONITOR_SIZE (0x6000)

So I changed that to 0x2000, and tried to recompile the applet using the make command. I am doing that according to application note TB3190.

 

According to my knowledge, I only had to update the ASF_BRANCH_PATH to the latest ASF standalone directory. So I did:

 

ASF_BRANCH_PATH = C:\Atmel\xdk-asf-3.48.0

 

Only when I run the make command (as Administrator) in the folder "C:\Program Files (x86)\Atmel\sam-ba_2.18\applets\samd21j18a\sam-ba_applets\flash", I get this error:

 

make: *** No rule to make target `sram', needed by `all'.  Stop.

 

On Google I found one other topic by someone who has the same error, but unfortunately there is no solution...

 

What am I missing?

I don't have so much experience with Makefiles, but the script is pretty advanced. For reference, here is the Makefile:

# ----------------------------------------------------------------------------
#         SAM Software Package License
# ----------------------------------------------------------------------------
# Copyright (c) 2013, Atmel Corporation
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# - Redistributions of source code must retain the above copyright notice,
# this list of conditions and the disclaimer below.
#
# Atmel's name may not be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
# DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# ----------------------------------------------------------------------------

# Makefile for compiling applet-flash

#-------------------------------------------------------------------------------
# User-modifiable options
#-------------------------------------------------------------------------------

# Chip & board used for compilation
# (can be overriden by adding CHIP=chip and BOARD=board to the command-line)
SERIE = samd21
CHIP  = $(SERIE)j18a
BOARD = $(SERIE)_xplained_pro

ifeq (samd21j18a,$(CHIP))
BOARD_DIR = samd21_xplained_pro
CHIP_NAME  = __SAMD21J18A__
endif

MEMORIES = sram

# Trace level used for compilation
# (can be overriden by adding TRACE_LEVEL=#number to the command-line)
# TRACE_LEVEL_DEBUG      5
# TRACE_LEVEL_INFO       4
# TRACE_LEVEL_WARNING    3
# TRACE_LEVEL_ERROR      2
# TRACE_LEVEL_FATAL      1
# TRACE_LEVEL_NO_TRACE   0
#TRACE_LEVEL = 0    # use dynamic trace level instead

# Optimization level
# -O1 Optimize
# -O2 Optimize even more
# -O3 Optimize yet more
# -O0 Reduce compilation time and make debugging produce the expected results
# -Os Optimize for size

OPTIMIZATION = -Os

#-------------------------------------------------------------------------------
# Path
#-------------------------------------------------------------------------------

# Output file basename
OUTPUT = applet-flash-$(CHIP)

# Output directories
BIN = bin
OBJ = obj

# Libraries
#PATH_ATML_LIB_BOARD = $(PATH_ATML_LIB)/libboard_samd21_xplained_pro
#PATH_ATML_LIB_CHIP = $(PATH_ATML_LIB)/libchip_samd21
#PATH_RESOURCES = $(PATH_ATML_LIB_BOARD)/resources/gcc
SAMBA = ..
INSTALLDIR = "../../../../tcl_lib/$(BOARD_DIR)/"
#APPLET_LINKER_SCRIPT = "$(PATH_RESOURCES)/$(CHIP)/$$@_samba.lds"
APPLET_LINKER_SCRIPT = "../linker_script/sram_samba.lds"

#-------------------------------------------------------------------------------
# Tools
#-------------------------------------------------------------------------------

# Tool suffix when cross-compiling
CROSS_COMPILE = arm-none-eabi-

# Compilation tools
AR = $(CROSS_COMPILE)ar
CC = $(CROSS_COMPILE)gcc
LD = $(CROSS_COMPILE)ld
SIZE = $(CROSS_COMPILE)size
OBJCOPY = $(CROSS_COMPILE)objcopy
OBJDUMP = $(CROSS_COMPILE)objdump

# Flags
#ASF_BRANCH_PATH = ../../libraries
ASF_BRANCH_PATH = C:\Atmel\xdk-asf-3.48.0 <- this is my only change!
#GCC_LIB_PATH = $(ASF_BRANCH_PATH)/thirdparty/CMSIS/Lib/GCC
#INCLUDES  = -I$(PATH_ATML_LIB_BOARD)
#INCLUDES += -I$(PATH_ATML_LIB_BOARD)/include
#INCLUDES += -I$(PATH_ATML_LIB_BOARD)/source
#INCLUDES += -I$(PATH_ATML_LIB_CHIP)
#INCLUDES += -I$(PATH_ATML_LIB_CHIP)/include
#INCLUDES += -I$(PATH_ATML_LIB_CHIP)/source
#INCLUDES += -I$(PATH_ATML_LIB)/CMSIS/include
INCLUDES += -I$(ASF_BRANCH_PATH)/common/utils
INCLUDES += -I$(ASF_BRANCH_PATH)/common/utils/interrupt
INCLUDES += -I$(ASF_BRANCH_PATH)/sam0/utils
INCLUDES += -I$(ASF_BRANCH_PATH)/sam0/utils/header_files
INCLUDES += -I$(ASF_BRANCH_PATH)/sam0/utils/preprocessor
INCLUDES += -I$(ASF_BRANCH_PATH)/sam0/utils/cmsis/samd21/include
INCLUDES += -I$(ASF_BRANCH_PATH)/sam0/utils/cmsis/samd21/source
INCLUDES += -I$(ASF_BRANCH_PATH)/sam0/drivers/system
INCLUDES += -I$(ASF_BRANCH_PATH)/sam0/drivers/system/clock
INCLUDES += -I$(ASF_BRANCH_PATH)/sam0/drivers/system/pinmux
INCLUDES += -I$(ASF_BRANCH_PATH)/sam0/drivers/system/interrupt
INCLUDES += -I$(ASF_BRANCH_PATH)/sam0/drivers/nvm
INCLUDES += -I$(ASF_BRANCH_PATH)/thirdparty/CMSIS
INCLUDES += -I$(ASF_BRANCH_PATH)/thirdparty/CMSIS/Include
#INCLUDES += -I$(ASF_BRANCH_PATH)/thirdparty/CMSIS/Lib
#INCLUDES += -I$(ASF_BRANCH_PATH)/thirdparty/CMSIS/Lib/GCC

CFLAGS += -mthumb -mcpu=cortex-m0plus -mlong-calls -ffunction-sections -Wall -DNDEBUG -D__SAMBA__ -DARM_MATH_CM0=true
CFLAGS += -g $(OPTIMIZATION) $(INCLUDES) -D$(CHIP_NAME)
CFLAGS += -DDYN_TRACES
#CFLAGS += -v
CFLAGS += -c -g
CFLAGS += -DTRACE_LEVEL=$(TRACE_LEVEL)
CFLAGS += -std=gnu99
ASFLAGS = -mthumb -Wall -g $(OPTIMIZATION) $(INCLUDES) -D$(CHIP_NAME)
# -D__ASSEMBLY__
LDFLAGS = -g $(OPTIMIZATION) -nostartfiles -mthumb -mcpu=cortex-m0plus -Wl,-Map=$(OUTPUT).map,--cref,--gc-sections

#-------------------------------------------------------------------------------
# Files
#-------------------------------------------------------------------------------
# VPATH += $(PATH_ATML_LIB_BOARD)
# VPATH += $(PATH_ATML_LIB_BOARD)/include
# VPATH += $(PATH_ATML_LIB_BOARD)/source
# VPATH += $(PATH_ATML_LIB_CHIP)
# VPATH += $(PATH_ATML_LIB_CHIP)/include
# VPATH += $(PATH_ATML_LIB_CHIP)/source
VPATH += $(SAMBA)/common
VPATH += $(ASF_BRANCH_PATH)\sam0\utils
VPATH += $(ASF_BRANCH_PATH)\common\utils\interrupt
VPATH += $(ASF_BRANCH_PATH)\sam0\drivers\nvm
VPATH += $(ASF_BRANCH_PATH)\sam0\drivers\system

C_OBJECTS += interrupt_sam_nvic.o
C_OBJECTS += nvm.o
C_OBJECTS += system.o
C_OBJECTS += flash_app_main.o
C_OBJECTS += applet_cstartup.o

# Append OBJ and BIN directories to output filename
OUTPUT := $(BIN)/$(OUTPUT)

MEMORIES = sram

#-------------------------------------------------------------------------------
# Rules
#-------------------------------------------------------------------------------

all: $(BIN) $(OBJ) $(MEMORIES)

$(BIN) $(OBJ):
	mkdir $@

define RULES
C_OBJECTS_$(1) = $(addprefix $(OBJ)/$(1)_, $(C_OBJECTS))
ASM_OBJECTS_$(1) = $(addprefix $(OBJ)/$(1)_, $(ASM_OBJECTS))

$(1): $$(ASM_OBJECTS_$(1)) $$(C_OBJECTS_$(1))
	@$(CC) $(LDFLAGS) -T"$(APPLET_LINKER_SCRIPT)" -o $(OUTPUT).elf $$^
	$(OBJCOPY) -O binary $(OUTPUT).elf $(OUTPUT).bin
	$(SIZE) $$^ $(OUTPUT).elf
	$(OBJDUMP) -h -S $(OUTPUT).elf > $(OUTPUT).lss
	@[ -e $(INSTALLDIR) ] || mkdir $(INSTALLDIR)
	@cp -f $(OUTPUT).bin $(INSTALLDIR)
	@$(OBJDUMP) -S $(OUTPUT).elf > $(OUTPUT)_dis.txt

$$(C_OBJECTS_$(1)): $(OBJ)/$(1)_%.o: %.c Makefile $(OBJ) $(BIN)
	@$(CC) $(CFLAGS) -D$(1) -c -o $$@ $$<

$$(ASM_OBJECTS_$(1)): $(OBJ)/$(1)_%.o: %.S Makefile $(OBJ) $(BIN)
	@$(CC) $(ASFLAGS) -D$(1) -c -o $$@ $$<

endef

$(foreach MEMORY, $(MEMORIES), $(eval $(call RULES,$(MEMORY))))

clean:
	-rm -fR $(OBJ) $(BIN)

 

Maybe someday I'll have a nice quote here.