How to abandon Atmel Studio

Discussions around product based on ARM Cortex M0+ core.

Moderator: nferre

pozz
Posts: 68
Joined: Fri Jun 13, 2014 2:55 pm

How to abandon Atmel Studio

Mon Jul 07, 2014 9:22 am

Do you think it's possible? I don't like Atmel Studio at all and I want to use another IDE, such as Code::Blocks or Eclipse.

I know I can install the Atmel ARM toolchain separately and create a custom Makefile, but I have two main concerns.

First of all, Atmel Studio Framework won't work anymore. I can think this can be solved creating a temporary project in Atmel Studio 6, adding the ASF functionalities I need (drivers, services, components) and copy the files I need from Atmel Studio project to my favourite IDE project.
At last, I hope to abandon ASF too.

Second, and most important: programming and debugging. I have no idea how to solve this.
pozz
Posts: 68
Joined: Fri Jun 13, 2014 2:55 pm

Re: How to abandon Atmel Studio

Mon Jul 07, 2014 11:11 am

That would be a question for whatever IDE(s) you choose - search their documentation and support forums for supported debug facilities...
Code::Blocks uses mingw compiler that includes a gcc and gdb port for windows. If I compile a native Windows application with mingw gcc, I can normally debug it (breakpoints, step over, step into, ...) through the IDE. gdb is under the scene... I think.

So the IDE is ready for debug purposes, but it uses gdb. Atmel ARM toolchain is a gcc port, so the question isn't related to the IDE, but to the toolchain. Does the toolchain from Atmel include a "standard" gdb (I don't know how exactly means "standard")? If yes, I think I can debug SAM applications whatever the IDE I use.
pozz
Posts: 68
Joined: Fri Jun 13, 2014 2:55 pm

Re: How to abandon Atmel Studio

Mon Jul 07, 2014 8:14 pm

awneil wrote: There is a third one - possibly bigger than the others - which is the level of support you'll get with those other IDEs...
Support from Atmel? None, of course.

However I think the main component that must have a good support from Atmel is only the ARM toolchain. Atmel Studio is just an IDE and can be replaced with other, more powerful and light, IDEs with a better support from community.

I don't like how Atmel Studio manages projects/solutions and configurations. Many times I need to compile the same application for two completely different boards with two processors. In Atmel Studio you can't define a different CPU for each configuration.
Have you tried to remove the default Debug/Release configurations? I have and it was so difficult that I leave those configurations in the project even if I wasn't used them.

Of course, I need the answers to my two concerns.
trangon
Posts: 2
Joined: Thu Aug 11, 2016 12:41 pm

Re: How to abandon Atmel Studio

Thu Aug 11, 2016 2:19 pm

Hi

I am using Atmel SAM R21 without Atmel Studio. What you need is to download the arm-none-eabi-gcc stuff and (if desired) the standalone version of Atmel's ASF. You can get both from Atmel's website (currently this part seems to be offline). Additionally, I use openOCD to download and debug my software. I use openOCD 0.10 directly compiled from the git repo. However, 0.9 also worked for me.

Below you see a configuration that I use on Linux. The makefile (see below) is probably not the most advanced makefile but it should work (at least with minor modifications). The file makedefs is the one that configures the compilation process. This file probably needs to be adjusted. Additionally, the variable $(GCC_BASE) must hold the path to the ARM GCC binaries.

The following directory structure is assumed:

Code: Select all

.  (project root)      
      |
      +-- build/     (empty build directory)
      |
      +-- src/ --
            |
            +-- ASF/    (standalone ASF source tree)
            |
            +-- config/    (directory with config files as seen in Atmel's example projects)
            |
            + -- asf.h    (asf.h as seen in Atmel's example projects)
            |
            + -- main.c
            |
            + -- ...     (any other of my application's source files)
      |
      +-- makefile (see below)
      |
      +-- makedefs (see below)
      |
      +-- .gdbinit
makefile:

Code: Select all

include ./makedefs

PROJECT = <name of your project>

SOURCE_DIR = ./src
OUT_DIR = ./build
OBJ_DIR = $(OUT_DIR)/obj

# Directory of ASF source tree:
ASF_DIR = $(SOURCE_DIR)/ASF

rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))

# Source files:
SOURCE_FILES_C := $(call rwildcard,$(SOURCE_DIR),*.c)
SOURCE_DIRS_C := $(sort $(dir $(SOURCE_FILES_C) ))
SOURCE_DIRS_REL_C := $(SOURCE_DIRS_C:$(SOURCE_DIR)/%=%)
OBJ_FILES_REL_C := $(SOURCE_FILES_C:$(SOURCE_DIR)/%=%.o)
OBJ_FILES_C := $(OBJ_FILES_REL_C:%=$(OBJ_DIR)/%)
OBJ_DIRS_C := $(sort $(dir $(OBJ_FILES_C) ))

SOURCE_FILES_CPP := $(call rwildcard,$(SOURCE_DIR),*.cpp)
SOURCE_DIRS_CPP := $(sort $(dir $(SOURCE_FILES_CPP) ))
SOURCE_DIRS_REL_CPP := $(SOURCE_DIRS_CPP:$(SOURCE_DIR)/%=%)
OBJ_FILES_REL_CPP := $(SOURCE_FILES_CPP:$(SOURCE_DIR)/%=%.o)
OBJ_FILES_CPP := $(OBJ_FILES_REL_CPP:%=$(OBJ_DIR)/%)
OBJ_DIRS_CPP := $(sort $(dir $(OBJ_FILES_CPP) ))

OLD_FILES =  $(notdir $(call rwildcard,$(OUT_DIR),*))

# Include paths
INCLUDE_DIRS =  $(sort $(dir $(call rwildcard,src/,*.h) ))
INCLUDES += $(INCLUDE_DIRS:%=-I"%")
INCLUDES += -I.

LIB_DIRS =  $(sort $(dir $(call rwildcard,src/,*.a) ))
LIBS = $(LIB_DIRS:%=-L"%")

# Paths where source files are located
vpath %.c $(SOURCE_FILES_C)
vpath %.cpp $(SOURCE_FILES_CPP)
vpath %.h $(INCLUDE_DIRS)
# TODO: we should also add header file locations

# ELF file:
ELF_FILE = $(OUT_DIR)/$(PROJECT).elf

VERBOSE_MODE=0
LD = $(C)
ifeq ($(VERBOSE_MODE),1)
  TRACE_CPP =
  TRACE_C =
  TRACE_LD =
  TRACE_AR =
  TRACE_AS =
  QUIET= 
else
  TRACE_C      = @echo "  C         " $<
  TRACE_CPP    = @echo "  CPP       " $<
  TRACE_LD     = @echo "  LD        " $@
  TRACE_AR     = @echo "  AR        " $@
  TRACE_AS     = @echo "  AS        " $<
  QUIET=@
endif

.DEFAULT_GOAL := all

.PHONY: clean
clean:
	find $(OUT_DIR) -name "*" -type f -delete

.PHONY: distclean
distclean:
	find $(OUT_DIR)/* -delete

.PHONY: all
all:  $(PROJECT).elf $(PROJECT).bin

# Rule for creating object directory
$(OBJ_DIRS_C): 
	$(QUIET)mkdir -p $@

$(OBJ_DIRS_CPP): 
	$(QUIET)mkdir -p $@	
	
# Rule for creating output directory
$(OUT_DIR): 
	$(QUIET)mkdir $@
	
$(OBJ_FILES_C): | $(OBJ_DIRS_C)

$(OBJ_FILES_CPP): | $(OBJ_DIRS_CPP)

$(OBJ_DIR)/%.c.o: $(SOURCE_DIR)/%.c
	$(TRACE_C)
	$(QUIET)$(C) $(INCLUDES) $(COMPILE_OPTIONS) $(C_COMPILE_OBJ_OPTIONS) $(COMPILE_OBJ_OPTIONS) $(DEFINES) -I $(STD_INCLUDE_DIR) -c $< -o $@ -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" 
	
$(OBJ_DIR)/%.cpp.o: $(SOURCE_DIR)/%.cpp
	$(TRACE_CPP)	
	$(QUIET)$(CPP) $(INCLUDES) $(COMPILE_OPTIONS) $(CPP_COMPILE_OBJ_OPTIONS) $(COMPILE_OBJ_OPTIONS) $(DEFINES) -I $(STD_INCLUDE_DIR)-c $< -o $@ -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" 	
	
$(PROJECT).elf $(PROJECT).bin: | $(OUT_DIR)

# Rules for building output files
$(PROJECT).elf:  $(OBJ_FILES_C) $(OBJ_FILES_CPP)
	$(TRACE_LD)
	$(QUIET)$(LD) -o $(OUT_DIR)/$@  $(OBJ_FILES_C) $(OBJ_FILES_CPP)  -Wl,-Map=$(OUT_DIR)/$@.map $(COMPILE_ELF_OPTIONS) -T"$(LINKER_FILE)" -L$(STD_LIB_DIR)  $(LIBS)

$(PROJECT).bin: $(PROJECT).elf
	$(QUIET)$(OBJCOPY) -O binary --gap-fill 0xff $(OUT_DIR)/$< $(OUT_DIR)/$@
	$(QUIET)$(OBJCOPY) -O binary $(OUT_DIR)/$< $(OUT_DIR)/$@
	$(QUIET)$(OBJCOPY) -O ihex -R .eeprom -R .fuse -R .lock -R .signature $(OUT_DIR)/$< $(OUT_DIR)/$(@:%.elf=%.hex)
	$(QUIET)$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0 --no-change-warnings -O binary $(OUT_DIR)/$< $(OUT_DIR)/$(@:%.elf=%.eep) || exit 0
	$(QUIET)$(OBJDUMP) -h -S $(OUT_DIR)/$< > $(OUT_DIR)/$(@:%.elf=%.lss)
	$(QUIET)$(OBJCOPY) -O srec -R .eeprom -R .fuse -R .lock -R .signature  $(OUT_DIR)/$< $(OUT_DIR)/$(@:%.elf=%.srec)
	$(QUIET)$(SIZE) $(OUT_DIR)/$< $(OUT_DIR)/$(@:%.elf=%.hex)
makedefs (configure your compilation process here):

Code: Select all

GCC_BASE=<path to your ARM GCC binaries>

C = $(GCC_BASE)/arm-none-eabi-gcc 
CPP = $(GCC_BASE)/arm-none-eabi-g++
OBJCOPY = $(GCC_BASE)/arm-none-eabi-objcopy
OBJDUMP = $(GCC_BASE)/arm-none-eabi-objdump
SIZE = $(GCC_BASE)/arm-none-eabi-size
GDB = $(GCC_BASE)/arm-none-eabi-gdb

COMPILE_OBJ_OPTIONS =  -c -mthumb -O1 -g3 -mlong-calls -mcpu=cortex-m0plus -pipe --param max-inline-insns-single=500 
COMPILE_OBJ_OPTIONS += -fdata-sections -ffunction-sections -ffunction-sections -fdata-sections -fno-strict-aliasing
COMPILE_OBJ_OPTIONS += -Wall -Wno-deprecated-declarations

C_COMPILE_OBJ_OPTIONS =   -std=gnu99
CPP_COMPILE_OBJ_OPTIONS = -std=c++11

COMPILE_ELF_OPTIONS = -mthumb --specs=nano.specs -Wl,--start-group -larm_cortexM0l_math -lm  -lsam0_lib_hw_timer -Wl,--end-group   -Wl,--gc-sections -mcpu=cortex-m0plus -Wl,--entry=Reset_Handler -Wl,--cref -mthumb

LINKER_FILE = ./src/ASF/sam0/utils/linker_scripts/samr21/gcc/samr21g18a_flash.ld

STD_INCLUDE_DIR = $(GCC_BASE)/arm-none-eabi/include
STD_LIB_DIR     = $(GCC_BASE)/arm-none-eabi/lib

DEFINES  = -DDEBUG
DEFINES += -DSIO_HUB
DEFINES += -DENABLE_DEEP_SLEEP
DEFINES += -DTAL_TYPE=AT86RF233
DEFINES += -DHIGHEST_STACK_LAYER=MAC
DEFINES += -DSTB_ON_SAL
DEFINES += -DDISABLE_TSTAMP_IRQ=1
DEFINES += -DARM_MATH_CM0PLUS=true
DEFINES += -DRTC_COUNT_ASYNC=true
DEFINES += -D__SAMR21G18A__
DEFINES += -DSYSTICK_MODE
DEFINES += -DSAL_TYPE=AT86RF2xx
DEFINES += -DENABLE_TSTAMP
DEFINES += -DTC_ASYNC=true
DEFINES += -D_DEBUG_=0
DEFINES += -DBOARD=SAMR21_XPLAINED_PRO
DEFINES += -DPAL_USE_SPI_TRX=1
DEFINES += -DEXTINT_CALLBACK_MODE=true
DEFINES += -DUSART_CALLBACK_MODE=true
DEFINES += -DSPI_CALLBACK_MODE=false
DEFINES += -DANTENNA_DIVERSITY=1
<add your defines here>

.gdbinit (GDB configuration file, to be placed in the same directory as your makefile):

Code: Select all

set remote hardware-watchpoint-limit 2
set remote hardware-breakpoint-limit 4
target remote | openocd -f board/atmel_samr21_xplained_pro.cfg -c "gdb_port pipe; log_output openocd.log"
monitor reset halt
load
This is how I invoke GDB:

Code: Select all

<path to your ARM GCC binary>/arm-none-eabi-gdb --silent -iex "set auto-load safe-path /" <your_elf_file>
main.c

Code: Select all

#include "conf_board.h"
#include <asf.h>


int main(void) 
{
    irq_initialize_vectors();
    system_init();

    // your code
}

Return to “SAM D20 Cortex-M0+ MCU”

Who is online

Users browsing this forum: No registered users and 2 guests