Skip to content

Commit

Permalink
Initial support for Arduino M0/Tian boards // Issue #472
Browse files Browse the repository at this point in the history
  • Loading branch information
valeros committed Jul 4, 2016
1 parent 4dd90d5 commit 2c7c747
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 1 deletion.
66 changes: 66 additions & 0 deletions platformio/boards/arduino.json
Original file line number Diff line number Diff line change
Expand Up @@ -986,5 +986,71 @@
},
"url": "http://www.arduino.org/products/boards/arduino-m0-pro",
"vendor": "Arduino"
},
"mzeroUSB": {
"build": {
"core": "arduino_zero",
"extra_flags": "-DARDUINO_SAMD_ZERO -DARDUINO_ARCH_SAMD -D__SAMD21G18A__",
"f_cpu": "48000000L",
"mcu": "samd21g18a",
"cpu": "cortex-m0plus",
"usb_product": "Arduino M0/Pro",
"variant": "arduino_zero",
"ldscript": "samd21g18a_bootloader_org.ld",
"hwids": [
["0x2A03", "0x004D"],
["0x2A03", "0x804D"],
["0x2A03", "0x004F"],
["0x2A03", "0x804F"]
]
},
"frameworks": ["arduino"],
"name": "Arduino M0 Pro (Native USB Port)",
"platform": "atmelsam",
"upload": {
"disable_flushing": true,
"maximum_ram_size": 32768,
"maximum_size": 262144,
"protocol": "stk500v2",
"require_upload_port" : true,
"speed": 57600,
"use_1200bps_touch": true,
"wait_for_upload_port": true,
"section_start": "0x4000"
},
"url": "http://www.arduino.org/products/boards/arduino-m0-pro",
"vendor": "Arduino"
},
"tian": {
"build": {
"core": "arduino_zero",
"extra_flags": "-DARDUINO_SAMD_ZERO -DARDUINO_ARCH_SAMD -D__SAMD21G18A__",
"f_cpu": "48000000L",
"mcu": "samd21g18a",
"cpu": "cortex-m0plus",
"usb_product": "Arduino Tian",
"variant": "arduino_zero",
"ldscript": "samd21g18a_bootloader_org.ld",
"hwids": [
["0x10C4", "0xEA70"],
["0x2A03", "0x8052"]
]
},
"frameworks": ["arduino"],
"name": "Arduino Tian",
"platform": "atmelsam",
"upload": {
"disable_flushing": true,
"maximum_ram_size": 32768,
"maximum_size": 262144,
"protocol": "stk500v2",
"require_upload_port" : true,
"speed": 57600,
"use_1200bps_touch": true,
"wait_for_upload_port": true,
"section_start": "0x4000"
},
"url": "http://www.arduino.org/products/boards/arduino-tian",
"vendor": "Arduino"
}
}
36 changes: 35 additions & 1 deletion platformio/builder/scripts/atmelsam.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from os.path import basename, join

from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default,
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Builder, Default,
DefaultEnvironment, SConscript)

from platformio.util import get_serialports
Expand Down Expand Up @@ -173,6 +173,38 @@ def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621
if "sam3x8e" in BOARD_OPTIONS.get("build", {}).get("mcu", ""):
env.Append(UPLOADERFLAGS=["--boot"])

elif upload_protocol == "stk500v2":
env.Append(
BUILDERS=dict(
ElfToHex=Builder(
action=" ".join([
"$OBJCOPY",
"-O",
"ihex",
"-R",
".eeprom",
"$SOURCES",
"$TARGET"]),
suffix=".hex"
)
)
)

env.Replace(
UPLOADER=join("$PIOPACKAGES_DIR", "tool-avrdude", "avrdude"),
UPLOADERFLAGS=[
"-C", '"%s"' % join("$PIOPACKAGES_DIR",
"tool-avrdude", "avrdude.conf"),
"-v",
"-p", "atmega2560", # Arduino M0/Tian upload hook
"-c", "$UPLOAD_PROTOCOL",
"-P", '"$UPLOAD_PORT"',
"-b", "$UPLOAD_SPEED"
],

UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS -U flash:w:$SOURCES:i'
)

#
# Target: Build executable and linkable firmware
#
Expand All @@ -185,6 +217,8 @@ def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621

if "uploadlazy" in COMMAND_LINE_TARGETS:
target_firm = join("$BUILD_DIR", "firmware.bin")
elif upload_protocol == "stk500v2":
target_firm = env.ElfToHex(join("$BUILD_DIR", "firmware"), target_elf)
else:
target_firm = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf)

Expand Down

0 comments on commit 2c7c747

Please sign in to comment.