Initial support for Arduino Zero board // Resolve #356
This commit is contained in:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user