From 3c27ce49316a09d61a9fb0502533c8e267d48c10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arkadiusz=20Ry=C5=9B?= Date: Sun, 5 Jul 2020 16:06:59 +0200 Subject: [PATCH 1/2] Add support for programming the SAM3X on the Udoo Quad --- boards/udoo_quad.json | 49 ++++++++++++++++++++++++++++++++++ boards/udoo_quad_internal.json | 49 ++++++++++++++++++++++++++++++++++ builder/main.py | 11 ++++++-- platform.json | 8 +++++- platform.py | 2 ++ 5 files changed, 116 insertions(+), 3 deletions(-) create mode 100644 boards/udoo_quad.json create mode 100644 boards/udoo_quad_internal.json diff --git a/boards/udoo_quad.json b/boards/udoo_quad.json new file mode 100644 index 0000000..e8d98ac --- /dev/null +++ b/boards/udoo_quad.json @@ -0,0 +1,49 @@ +{ + "build": { + "arduino": { + "ldscript": "flash.ld" + }, + "core": "arduino", + "cpu": "cortex-m3", + "extra_flags": "-D__SAM3X8E__ -DARDUINO_SAM_DUE", + "f_cpu": "84000000L", + "hwids": [ + [ + "0x10C4", + "0xEA60" + ] + ], + "mcu": "at91sam3x8e", + "usb_product": "Arduino Due", + "variant": "arduino_due_x" + }, + "connectivity": [ + "can" + ], + "debug": { + "jlink_device": "ATSAM3X8E", + "openocd_chipname": "at91sam3X8E", + "openocd_target": "at91sam3ax_8x", + "svd_path": "ATSAM3X8E.svd" + }, + "frameworks": [ + "arduino" + ], + "name": "Udoo Quad", + "upload": { + "disable_flushing": true, + "maximum_ram_size": 98304, + "maximum_size": 524288, + "native_usb": false, + "protocol": "sam-ba", + "protocols": [ + "sam-ba" + ], + "internal": false, + "require_upload_port": true, + "use_1200bps_touch": false, + "wait_for_upload_port": false + }, + "url": "https://www.udoo.org/", + "vendor": "Udoo" +} diff --git a/boards/udoo_quad_internal.json b/boards/udoo_quad_internal.json new file mode 100644 index 0000000..d0dddca --- /dev/null +++ b/boards/udoo_quad_internal.json @@ -0,0 +1,49 @@ +{ + "build": { + "arduino": { + "ldscript": "flash.ld" + }, + "core": "arduino", + "cpu": "cortex-m3", + "extra_flags": "-D__SAM3X8E__ -DARDUINO_SAM_DUE", + "f_cpu": "84000000L", + "hwids": [ + [ + "0x10C4", + "0xEA60" + ] + ], + "mcu": "at91sam3x8e", + "usb_product": "Arduino Due", + "variant": "arduino_due_x" + }, + "connectivity": [ + "can" + ], + "debug": { + "jlink_device": "ATSAM3X8E", + "openocd_chipname": "at91sam3X8E", + "openocd_target": "at91sam3ax_8x", + "svd_path": "ATSAM3X8E.svd" + }, + "frameworks": [ + "arduino" + ], + "name": "Udoo Quad", + "upload": { + "disable_flushing": true, + "maximum_ram_size": 98304, + "maximum_size": 524288, + "native_usb": false, + "protocol": "sam-ba", + "protocols": [ + "sam-ba" + ], + "internal": true, + "require_upload_port": true, + "use_1200bps_touch": false, + "wait_for_upload_port": false + }, + "url": "https://www.udoo.org/", + "vendor": "Udoo" +} diff --git a/builder/main.py b/builder/main.py index 13888b2..a340f04 100644 --- a/builder/main.py +++ b/builder/main.py @@ -214,6 +214,13 @@ def _jlink_cmd_script(env, source): ], UPLOADCMD="$UPLOADER $UPLOADERFLAGS $SOURCES" ) + + # use patched bossac for Udoo Quad + if board.get("name") in ("Udoo Quad", "Udoo Dual"): + if bool(board.get("upload.internal", False)): + env.Replace(UPLOADER="bossac-udoo-internal") + env.Replace(UPLOADER="bossac-udoo") + if board.get("build.core") in ("adafruit", "seeed") and board.get( "build.mcu").startswith("samd51"): # special flags for the latest bossac tool @@ -267,9 +274,9 @@ def _jlink_cmd_script(env, source): "--device", "samd", "--speed", "1500000", "--port", '"$UPLOAD_PORT"', - "--upload", "$SOURCES", + "--upload", "$SOURCES", ], - UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS' + UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS' ) upload_actions = [ env.VerboseAction(env.AutodetectUploadPort, diff --git a/platform.json b/platform.json index 4c10b02..977929b 100644 --- a/platform.json +++ b/platform.json @@ -15,7 +15,8 @@ "packageRepositories": [ "https://dl.bintray.com/platformio/dl-packages/manifest.json", "http://dl.platformio.org/packages/manifest.json", - "https://raw.githubusercontent.com/eerimoq/simba/master/make/platformio/manifest.json" + "https://raw.githubusercontent.com/eerimoq/simba/master/make/platformio/manifest.json", + "https://raw.githubusercontent.com/ArkadiuszMichalRys/bossac-udoo/master/platformio/manifest.json" ], "frameworks": { "arduino": { @@ -201,6 +202,11 @@ "optional": true, "version": "~1.10700.0" }, + "tool-bossac-udoo": { + "type": "uploader", + "optional": true, + "version": "~0.0.1" + }, "tool-mbctool": { "optional": true, "version": ">=2.0.0" diff --git a/platform.py b/platform.py index cf8a1f5..8163d9a 100644 --- a/platform.py +++ b/platform.py @@ -31,6 +31,8 @@ def configure_default_packages(self, variables, targets): upload_tool = "tool-openocd" if upload_protocol == "sam-ba": upload_tool = "tool-bossac" + if board.get("name") in ("Udoo Quad", "Udoo Dual"): + upload_tool = "tool-bossac-udoo" elif upload_protocol == "stk500v2": upload_tool = "tool-avrdude" elif upload_protocol == "jlink": From 9b37923dccbf8a6aa71985934d68c5b94055a77e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arkadiusz=20Ry=C5=9B?= Date: Thu, 9 Jul 2020 11:54:06 +0200 Subject: [PATCH 2/2] Fix Udoo internal build tool being overridden --- builder/main.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/builder/main.py b/builder/main.py index a340f04..7e60151 100644 --- a/builder/main.py +++ b/builder/main.py @@ -217,9 +217,9 @@ def _jlink_cmd_script(env, source): # use patched bossac for Udoo Quad if board.get("name") in ("Udoo Quad", "Udoo Dual"): - if bool(board.get("upload.internal", False)): - env.Replace(UPLOADER="bossac-udoo-internal") env.Replace(UPLOADER="bossac-udoo") + if env.BoardConfig().get("upload.internal", False): + env.Replace(UPLOADER="bossac-udoo-internal") if board.get("build.core") in ("adafruit", "seeed") and board.get( "build.mcu").startswith("samd51"): @@ -227,7 +227,6 @@ def _jlink_cmd_script(env, source): env.Append( UPLOADERFLAGS=[ "-U", "--offset", board.get("upload.offset_address")]) - else: env.Append(UPLOADERFLAGS=[ "--erase",