mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-31 10:37:13 +02:00
Add second upload method through native USB Port for SAM-based boards
This commit is contained in:
@ -620,5 +620,31 @@
|
|||||||
"use_1200bps_touch": true,
|
"use_1200bps_touch": true,
|
||||||
"wait_for_upload_port": true
|
"wait_for_upload_port": true
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"dueUSB": {
|
||||||
|
"build": {
|
||||||
|
"core": "arduino",
|
||||||
|
"extra_flags": "-D__SAM3X8E__ -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM",
|
||||||
|
"f_cpu": "84000000L",
|
||||||
|
"mcu": "at91sam3x8e",
|
||||||
|
"cpu": "cortex-m3",
|
||||||
|
"pid": "0x003e",
|
||||||
|
"usb_product": "Arduino Due",
|
||||||
|
"variant": "arduino_due_x",
|
||||||
|
"vid": "0x2341",
|
||||||
|
"ldscript": "sam3x8e.ld"
|
||||||
|
},
|
||||||
|
"framework": "arduino",
|
||||||
|
"name": "Arduino Due (USB Native Port)",
|
||||||
|
"platform": "atmelsam",
|
||||||
|
"upload": {
|
||||||
|
"disable_flushing": true,
|
||||||
|
"maximum_ram_size": 28672,
|
||||||
|
"maximum_size": 524288,
|
||||||
|
"protocol": "sam-ba",
|
||||||
|
"require_upload_port" : true,
|
||||||
|
"use_1200bps_touch": true,
|
||||||
|
"wait_for_upload_port": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,10 +10,33 @@ from os.path import join
|
|||||||
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default,
|
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default,
|
||||||
DefaultEnvironment, SConscript)
|
DefaultEnvironment, SConscript)
|
||||||
|
|
||||||
|
from platformio.util import get_serialports
|
||||||
|
|
||||||
|
|
||||||
def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621
|
def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621
|
||||||
env.AutodetectUploadPort()
|
env.AutodetectUploadPort()
|
||||||
|
|
||||||
|
board_type = env.subst("$BOARD")
|
||||||
|
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", {})
|
||||||
|
|
||||||
|
if not upload_options.get("disable_flushing", False):
|
||||||
|
env.FlushSerialBuffer("$UPLOAD_PORT")
|
||||||
|
|
||||||
|
before_ports = [i['port'] for i in get_serialports()]
|
||||||
|
|
||||||
|
if upload_options.get("use_1200bps_touch", False):
|
||||||
|
env.TouchSerialPort("$UPLOAD_PORT", 1200)
|
||||||
|
|
||||||
|
if upload_options.get("wait_for_upload_port", False):
|
||||||
|
env.Replace(UPLOAD_PORT=env.WaitForNewSerialPort(before_ports))
|
||||||
|
|
||||||
|
|
||||||
env = DefaultEnvironment()
|
env = DefaultEnvironment()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user