
# Arduino 101 Core and platform.
#
# For more info:
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification

name=Intel Curie (32-bit) Boards
version=2.1.0

# Arduino 101 compile variables
# ----------------------

compiler.prefix=arc-elf32

compiler.path={runtime.tools.arc-elf32.path}/bin/
compiler.c.cmd=arc-elf32-gcc
compiler.c.flags=-c -std=gnu11 -mcpu=quarkse_em -mlittle-endian -g -Os -Wall -fno-reorder-functions -fno-asynchronous-unwind-tables -fno-omit-frame-pointer -fno-defer-pop -Wno-unused-but-set-variable -Wno-main -ffreestanding -fno-stack-protector -mno-sdata -ffunction-sections -fdata-sections -fsigned-char -MMD -D__ARDUINO_ARC__ -DCONFIG_BLUETOOTH_PERIPHERAL -DCONFIG_BLUETOOTH_CENTRAL -DCONFIG_BLUETOOTH_GATT_CLIENT
compiler.c.elf.cmd=arc-elf32-gcc
compiler.c.elf.flags=-nostartfiles -nodefaultlibs -nostdlib -static -Wl,-X -Wl,-N -Wl,-mcpu=quarkse_em -Wl,-marcelf -Wl,--gc-sections
compiler.S.flags=-c -g -x assembler-with-cpp
compiler.cpp.cmd=arc-elf32-g++
compiler.cpp.flags=-c -mcpu=quarkse_em -mlittle-endian -g -Os -Wall -fno-reorder-functions -fno-asynchronous-unwind-tables -fno-omit-frame-pointer -fno-defer-pop -Wno-unused-but-set-variable -Wno-main -ffreestanding -fno-stack-protector -mno-sdata -ffunction-sections -fdata-sections -fsigned-char -MMD -fno-rtti -fno-exceptions -fcheck-new -D__ARDUINO_ARC__ -std=c++11 -DCONFIG_BLUETOOTH_PERIPHERAL -DCONFIG_BLUETOOTH_CENTRAL -DCONFIG_BLUETOOTH_GATT_CLIENT
compiler.ar.cmd=arc-elf32-ar
compiler.ar.flags=rcs
compiler.objcopy.cmd=arc-elf32-objcopy
compiler.objcopy.eep.flags=-O ihex
compiler.elf2hex.flags=-S -O ihex -R .note -R .comment -R COMMON -R .eh_frame
compiler.elf2hex.cmd=arc-elf32-objcopy
compiler.elf2bin.flags=-S -O binary -R .note -R .comment -R COMMON -R .eh_frame
compiler.elf2bin.cmd=arc-elf32-objcopy
compiler.ldflags=
compiler.size.cmd=arc-elf32-size
compiler.define=-DARDUINO=
compiler.strip.cmd={compiler.prefix}-strip

# this can be overriden in boards.txt
build.extra_flags=

# These can be overridden in platform.local.txt
compiler.c.extra_flags=-D__CPU_ARC__ -DCLOCK_SPEED=32 -DCONFIG_SOC_GPIO_32 -DCONFIG_SOC_GPIO_AON -DINFRA_MULTI_CPU_SUPPORT -DCFW_MULTI_CPU_SUPPORT -DHAS_SHARED_MEM "-I{build.system.path}/libarc32_arduino101/common" "-I{build.system.path}/libarc32_arduino101/drivers" "-I{build.system.path}/libarc32_arduino101/bootcode" "-I{build.system.path}/libarc32_arduino101/framework/include"
compiler.c.elf.extra_flags=
compiler.cpp.extra_flags=-D__CPU_ARC__ -DCLOCK_SPEED=32 -DCONFIG_SOC_GPIO_32 -DCONFIG_SOC_GPIO_AON -DINFRA_MULTI_CPU_SUPPORT -DCFW_MULTI_CPU_SUPPORT -DHAS_SHARED_MEM "-I{build.system.path}/libarc32_arduino101/common" "-I{build.system.path}/libarc32_arduino101/drivers" "-I{build.system.path}/libarc32_arduino101/bootcode" "-I{build.system.path}/libarc32_arduino101/framework/include"
compiler.ar.extra_flags=
compiler.elf2hex.extra_flags=


#compiler.libsam.c.flags="-I{build.system.path}/libsam" "-I{build.system.path}/CMSIS/CMSIS/Include/" "-I{build.system.path}/CMSIS/Device/ATMEL/"

# USB Flags
# ---------
build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} -DUSBCON '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}'

# Default usb manufacturer will be replaced at compile time using
# numeric vendor ID if available or by board's specific value. 
build.usb_manufacturer="Unknown"


# Arduino 101 compile patterns
# ---------------------

## Compile c files
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"

## Compile c++ files
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"

## Create archives
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"

## Combine gc-sections, archives, and objects
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" "-L{build.path}" "-L{build.variant.path}" -Wl,--whole-archive "-l{build.variant_system_lib}" -Wl,--no-whole-archive -Wl,--start-group "-l{build.variant_system_lib}" -lnsim -lc -lm -lgcc {object_files} "{build.path}/{archive_file}"

## Save output with debug symbols (.debug.elf file). Uncomment if you wish to use OpenOCD to debug.
recipe.hooks.objcopy.preobjcopy.1.pattern="{runtime.tools.arduino101load.path}/arduino101load" -c -from="{build.path}/{build.project_name}.elf" -to="{build.path}/../arduino101_sketch.debug.elf"

## Create output (.bin file)
recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2bin.cmd}" {compiler.elf2bin.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin"

## Create output (.elf file)
recipe.objcopy.eep.pattern="{compiler.path}{compiler.strip.cmd}" "{build.path}/{build.project_name}.elf"

## Create output (.hex file)
recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"

## Save hex
recipe.output.tmp_file={build.project_name}.hex
recipe.output.save_file={build.project_name}.{build.variant}.hex

## Compute size
recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"
recipe.size.regex=^(?:text|ctors|rodata|datas)\s+([0-9]+).*

# Firmware check
# -------------------
tools.arduino101load.ble.fw.string="ATP1BLE00R-1631C4439"
tools.arduino101load.ble.fw.position=169984
# Dummy RTOS walues - don't update RTOS if not strictly needed
tools.arduino101load.rtos.fw.string="firmware_1.8.0_arduino101"
tools.arduino101load.rtos.fw.position=147424
#not ideal - should be inherited by the platform
tools.arduino101load.version=2.2.0

# Arc Uploader/Programmers tools
# -------------------
tools.arduino101load.cmd.path={runtime.tools.arduino101load.path}/arduino101load

tools.arduino101load.upload.params.verbose=-v
tools.arduino101load.upload.params.quiet=-q

tools.arduino101load.upload.pattern="{cmd.path}" "-dfu={runtime.tools.dfu-util.path}" "-bin={build.path}/{build.project_name}.bin" -port={serial.port} "{upload.verbose}" -ble_fw_str={ble.fw.string} -ble_fw_pos={ble.fw.position} -rtos_fw_str={rtos.fw.string} -rtos_fw_pos={rtos.fw.position} -core={version}

# This is needed to avoid an error on unexistent fields
tools.arduino101load.erase.params.verbose=
tools.arduino101load.erase.params.quiet=
tools.arduino101load.erase.pattern=
tools.arduino101load.bootloader.params.verbose=-v
tools.arduino101load.bootloader.params.quiet=-q
tools.arduino101load.bootloader.pattern="{cmd.path}" "-dfu={runtime.tools.dfu-util.path}"  -port={serial.port} "{bootloader.verbose}" -f -core={version}
