mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-29 17:47:14 +02:00
Initial support for Arduino Zero board // Resolve #356
This commit is contained in:
@ -658,7 +658,7 @@
|
||||
"core": "arduino",
|
||||
"extra_flags": "-D__SAM3X8E__ -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM",
|
||||
"f_cpu": "84000000L",
|
||||
"mcu": "at91sam3x8e",
|
||||
"mcu": "sam3x8e",
|
||||
"cpu": "cortex-m3",
|
||||
"pid": "0x003e",
|
||||
"usb_product": "Arduino Due",
|
||||
@ -686,7 +686,7 @@
|
||||
"core": "arduino",
|
||||
"extra_flags": "-D__SAM3X8E__ -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM",
|
||||
"f_cpu": "84000000L",
|
||||
"mcu": "at91sam3x8e",
|
||||
"mcu": "sam3x8e",
|
||||
"cpu": "cortex-m3",
|
||||
"pid": "0x003e",
|
||||
"usb_product": "Arduino Due",
|
||||
@ -708,5 +708,61 @@
|
||||
},
|
||||
"url": "http://arduino.cc/en/Main/arduinoBoardDue",
|
||||
"vendor": "Arduino"
|
||||
},
|
||||
"zero": {
|
||||
"build": {
|
||||
"core": "arduino_zero",
|
||||
"extra_flags": "-DARDUINO_SAMD_ZERO -DARDUINO_ARCH_SAMD -D__SAMD21G18A__",
|
||||
"f_cpu": "48000000L",
|
||||
"mcu": "samd21g18a",
|
||||
"cpu": "cortex-m0plus",
|
||||
"pid": "0x804d",
|
||||
"usb_product": "Arduino Zero",
|
||||
"variant": "arduino_zero",
|
||||
"vid": "0x2341",
|
||||
"ldscript": "flash_with_bootloader.ld"
|
||||
},
|
||||
"frameworks": ["arduino"],
|
||||
"name": "Arduino Zero (Programming Port)",
|
||||
"platform": "atmelsam",
|
||||
"upload": {
|
||||
"disable_flushing": true,
|
||||
"maximum_ram_size": 32768,
|
||||
"maximum_size": 262144,
|
||||
"protocol": "sam-ba",
|
||||
"require_upload_port" : false,
|
||||
"use_1200bps_touch": false,
|
||||
"wait_for_upload_port": false
|
||||
},
|
||||
"url": "https://www.arduino.cc/en/Main/ArduinoBoardZero",
|
||||
"vendor": "Arduino"
|
||||
},
|
||||
"zeroUSB": {
|
||||
"build": {
|
||||
"core": "arduino_zero",
|
||||
"extra_flags": "-DARDUINO_SAMD_ZERO -DARDUINO_ARCH_SAMD -D__SAMD21G18A__",
|
||||
"f_cpu": "48000000L",
|
||||
"mcu": "samd21g18a",
|
||||
"cpu": "cortex-m0plus",
|
||||
"pid": "0x804d",
|
||||
"usb_product": "Arduino Zero",
|
||||
"variant": "arduino_zero",
|
||||
"vid": "0x2341",
|
||||
"ldscript": "flash_with_bootloader.ld"
|
||||
},
|
||||
"frameworks": ["arduino"],
|
||||
"name": "Arduino Zero (USB Native Port)",
|
||||
"platform": "atmelsam",
|
||||
"upload": {
|
||||
"disable_flushing": true,
|
||||
"maximum_ram_size": 32768,
|
||||
"maximum_size": 262144,
|
||||
"protocol": "sam-ba",
|
||||
"require_upload_port" : true,
|
||||
"use_1200bps_touch": true,
|
||||
"wait_for_upload_port": true
|
||||
},
|
||||
"url": "https://www.arduino.cc/en/Main/ArduinoBoardZero",
|
||||
"vendor": "Arduino"
|
||||
}
|
||||
}
|
||||
|
@ -28,12 +28,13 @@ def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621
|
||||
env.AutodetectUploadPort()
|
||||
|
||||
board_type = env.subst("$BOARD")
|
||||
env.Append(
|
||||
UPLOADERFLAGS=[
|
||||
"-U",
|
||||
"true" if ("usb" in board_type.lower(
|
||||
) or board_type == "digix") else "false"
|
||||
])
|
||||
if "zero" not in board_type:
|
||||
env.Append(
|
||||
UPLOADERFLAGS=[
|
||||
"-U",
|
||||
"true" if ("usb" in board_type.lower(
|
||||
) or board_type == "digix") else "false"
|
||||
])
|
||||
|
||||
upload_options = env.get("BOARD_OPTIONS", {}).get("upload", {})
|
||||
|
||||
@ -57,33 +58,82 @@ env = DefaultEnvironment()
|
||||
|
||||
SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py")))
|
||||
|
||||
env.Replace(
|
||||
UPLOADER=join("$PIOPACKAGES_DIR", "$PIOPACKAGE_UPLOADER", "bossac"),
|
||||
UPLOADERFLAGS=[
|
||||
"--info",
|
||||
"--port", "$UPLOAD_PORT",
|
||||
"--erase",
|
||||
"--write",
|
||||
"--verify",
|
||||
"--boot",
|
||||
"--reset"
|
||||
],
|
||||
UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS $SOURCES'
|
||||
)
|
||||
if "zero" == env.subst("$BOARD"):
|
||||
env.Replace(
|
||||
UPLOADER=join("$PIOPACKAGES_DIR", "tool-openocd", "bin", "openocd"),
|
||||
UPLOADERFLAGS=[
|
||||
"-d2",
|
||||
"-s",
|
||||
join(
|
||||
"$PIOPACKAGES_DIR",
|
||||
"tool-openocd", "share", "openocd", "scripts"),
|
||||
"-f",
|
||||
join(
|
||||
"$PLATFORMFW_DIR", "variants",
|
||||
"${BOARD_OPTIONS['build']['variant']}", "openocd_scripts",
|
||||
"${BOARD_OPTIONS['build']['variant']}.cfg"
|
||||
),
|
||||
"-c", "\"telnet_port", "disabled;",
|
||||
"program", "{{$SOURCES}}",
|
||||
"verify", "reset", "0x00002000;", "shutdown\""
|
||||
],
|
||||
UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS'
|
||||
)
|
||||
else:
|
||||
env.Replace(
|
||||
UPLOADER=join("$PIOPACKAGES_DIR", "$PIOPACKAGE_UPLOADER", "bossac"),
|
||||
UPLOADERFLAGS=[
|
||||
"--info",
|
||||
"--port", "$UPLOAD_PORT",
|
||||
"--erase",
|
||||
"--write",
|
||||
"--verify",
|
||||
"--reset",
|
||||
"--debug"
|
||||
],
|
||||
UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS $SOURCES'
|
||||
)
|
||||
|
||||
env.Append(
|
||||
CPPDEFINES=[
|
||||
"printf=iprintf",
|
||||
"USBCON",
|
||||
'USB_MANUFACTURER="PlatformIO"'
|
||||
],
|
||||
|
||||
LINKFLAGS=[
|
||||
"-Wl,--entry=Reset_Handler",
|
||||
"-Wl,--start-group"
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
if "due" in env.subst("$BOARD"):
|
||||
env.Append(
|
||||
CPPDEFINES=[
|
||||
"printf=iprintf"
|
||||
],
|
||||
|
||||
LINKFLAGS=[
|
||||
"-Wl,--entry=Reset_Handler",
|
||||
"-Wl,--start-group"
|
||||
],
|
||||
|
||||
UPLOADERFLAGS=[
|
||||
"--boot",
|
||||
]
|
||||
|
||||
)
|
||||
elif "zero" in env.subst("$BOARD"):
|
||||
env.Append(
|
||||
CPPFLAGS=[
|
||||
"--param", "max-inline-insns-single=500"
|
||||
],
|
||||
|
||||
CXXFLAGS=[
|
||||
"-fno-threadsafe-statics"
|
||||
],
|
||||
|
||||
LINKFLAGS=[
|
||||
"--specs=nosys.specs",
|
||||
"--specs=nano.specs"
|
||||
]
|
||||
)
|
||||
|
||||
#
|
||||
# Target: Build executable and linkable firmware
|
||||
#
|
||||
@ -110,8 +160,12 @@ AlwaysBuild(target_size)
|
||||
# Target: Upload by default .bin file
|
||||
#
|
||||
|
||||
upload = env.Alias(["upload", "uploadlazy"], target_firm,
|
||||
[BeforeUpload, "$UPLOADCMD"])
|
||||
if "zero" == env.subst("$BOARD"):
|
||||
upload = env.Alias(["upload", "uploadlazy"], target_firm, "$UPLOADCMD")
|
||||
else:
|
||||
upload = env.Alias(["upload", "uploadlazy"], target_firm,
|
||||
[BeforeUpload, "$UPLOADCMD"])
|
||||
|
||||
AlwaysBuild(upload)
|
||||
|
||||
#
|
||||
|
@ -168,7 +168,22 @@ if env.subst("${PLATFORMFW_DIR}")[-3:] == "sam":
|
||||
join("$BUILD_DIR", "FrameworkLibSam"),
|
||||
join("$BUILD_DIR", "FrameworkLibSam", "include"),
|
||||
join("$BUILD_DIR", "FrameworkDeviceInc"),
|
||||
join("$BUILD_DIR", "FrameworkDeviceInc", "sam3xa", "include")
|
||||
join(
|
||||
"$BUILD_DIR",
|
||||
"FrameworkDeviceInc",
|
||||
"${BOARD_OPTIONS['build']['mcu'][3:]}",
|
||||
"include"
|
||||
)
|
||||
],
|
||||
|
||||
LIBPATH=[
|
||||
join(
|
||||
"$PLATFORMFW_DIR",
|
||||
"variants",
|
||||
"${BOARD_OPTIONS['build']['variant']}",
|
||||
"linker_scripts",
|
||||
"gcc"
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
@ -235,12 +250,24 @@ if "variant" in BOARD_BUILDOPTS:
|
||||
))
|
||||
|
||||
envsafe = env.Clone()
|
||||
|
||||
if "zero" in env.subst("$BOARD"):
|
||||
envsafe.Append(
|
||||
CFLAGS=[
|
||||
"-std=gnu11"
|
||||
],
|
||||
|
||||
CXXFLAGS=[
|
||||
"-std=gnu++11",
|
||||
]
|
||||
)
|
||||
|
||||
libs.append(envsafe.BuildLibrary(
|
||||
join("$BUILD_DIR", "FrameworkArduino"),
|
||||
join("$PLATFORMFW_DIR", "cores", "${BOARD_OPTIONS['build']['core']}")
|
||||
))
|
||||
|
||||
if env.subst("${PLATFORMFW_DIR}")[-3:] == "sam":
|
||||
if "due" in env.subst("$BOARD"):
|
||||
env.Append(
|
||||
LIBPATH=[
|
||||
join("$PLATFORMFW_DIR", "variants",
|
||||
|
@ -42,6 +42,10 @@ class AtmelsamPlatform(BasePlatform):
|
||||
|
||||
"tool-bossac": {
|
||||
"alias": "uploader"
|
||||
},
|
||||
|
||||
"tool-openocd": {
|
||||
"alias": "uploader"
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user