diff --git a/.travis.yml b/.travis.yml index be1cc9b..da8f090 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ env: - PLATFORMIO_PROJECT_DIR=examples/arduino-internal-libs - PLATFORMIO_PROJECT_DIR=examples/mbed-blink - PLATFORMIO_PROJECT_DIR=examples/mbed-dsp + # - PLATFORMIO_PROJECT_DIR=examples/mbed-events - PLATFORMIO_PROJECT_DIR=examples/mbed-serial - PLATFORMIO_PROJECT_DIR=examples/simba-blink diff --git a/README.md b/README.md index f9ac331..c2a3ae7 100644 --- a/README.md +++ b/README.md @@ -9,12 +9,27 @@ Atmel | SMART offers Flash- based ARM products based on the ARM Cortex-M0+, Cort # Usage -1. [Install PlatformIO Core](http://docs.platformio.org/page/core.html) -2. Install Atmel SAM development platform: -```bash -# install the latest stable version -> platformio platform install atmelsam - -# install development version -> platformio platform install https://github.com/platformio/platform-atmelsam.git +1. [Install PlatformIO](http://platformio.org) +2. Create PlatformIO project and configure a platform option in [platformio.ini](http://docs.platformio.org/page/projectconf.html) file: + +## Stable version + +```ini +[env:stable] +platform = atmelsam +board = ... +... ``` + +## Development version + +```ini +[env:development] +platform = https://github.com/platformio/platform-atmelsam.git +board = ... +... +``` + +# Configuration + +Please navigate to [documentation](http://docs.platformio.org/page/platforms/atmelsam.html). diff --git a/appveyor.yml b/appveyor.yml index a86488b..69f843c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -7,6 +7,7 @@ environment: - PLATFORMIO_PROJECT_DIR: "examples/arduino-internal-libs" - PLATFORMIO_PROJECT_DIR: "examples/mbed-blink" - PLATFORMIO_PROJECT_DIR: "examples/mbed-dsp" + # - PLATFORMIO_PROJECT_DIR: "examples/mbed-events" - PLATFORMIO_PROJECT_DIR: "examples/mbed-serial" - PLATFORMIO_PROJECT_DIR: "examples/simba-blink" diff --git a/boards/adafruit_circuitplayground_m0.json b/boards/adafruit_circuitplayground_m0.json index 4f71216..db734fd 100644 --- a/boards/adafruit_circuitplayground_m0.json +++ b/boards/adafruit_circuitplayground_m0.json @@ -20,30 +20,7 @@ "variant": "circuitplay" }, "debug": { - "tools": { - "cmsis-dap": { - "server": { - "package": "tool-openocd", - "executable": "bin/openocd", - "arguments": [ - "-s", "$PACKAGE_DIR/scripts", - "-f", "interface/cmsis-dap.cfg", - "-c", "set CHIPNAME at91samd21g18; set ENDIAN little; set telnet_port 0", - "-f", "target/at91samdXX.cfg" - ] - }, - "load_cmd": "preload" - }, - "blackmagic": { - "hwids": [ - [ - "0x1d50", - "0x6018" - ] - ], - "require_debug_port": true - } - } + "openocd_chipname": "at91samd21g18" }, "frameworks": [ "arduino" @@ -55,10 +32,16 @@ "maximum_size": 262144, "native_usb": true, "protocol": "sam-ba", + "protocols": [ + "sam-ba", + "blackmagic", + "jlink", + "atmel-ice" + ], "require_upload_port": true, "use_1200bps_touch": true, "wait_for_upload_port": true }, - "url": "https://www.adafruit.com/product/3000", + "url": "https://www.adafruit.com/product/3333", "vendor": "Adafruit" } diff --git a/boards/adafruit_feather_m0.json b/boards/adafruit_feather_m0.json index a353cf2..0c7835a 100644 --- a/boards/adafruit_feather_m0.json +++ b/boards/adafruit_feather_m0.json @@ -21,30 +21,7 @@ "variant": "feather_m0" }, "debug": { - "tools": { - "cmsis-dap": { - "server": { - "package": "tool-openocd", - "executable": "bin/openocd", - "arguments": [ - "-s", "$PACKAGE_DIR/scripts", - "-f", "interface/cmsis-dap.cfg", - "-c", "set CHIPNAME at91samd21g18; set ENDIAN little; set telnet_port 0", - "-f", "target/at91samdXX.cfg" - ] - }, - "load_cmd": "preload" - }, - "blackmagic": { - "hwids": [ - [ - "0x1d50", - "0x6018" - ] - ], - "require_debug_port": true - } - } + "openocd_chipname": "at91samd21g18" }, "frameworks": [ "arduino" @@ -56,6 +33,12 @@ "maximum_size": 262144, "native_usb": true, "protocol": "sam-ba", + "protocols": [ + "sam-ba", + "blackmagic", + "jlink", + "atmel-ice" + ], "require_upload_port": true, "use_1200bps_touch": true, "wait_for_upload_port": true diff --git a/boards/adafruit_feather_m0_express.json b/boards/adafruit_feather_m0_express.json index f4dc9aa..1cbbcd9 100644 --- a/boards/adafruit_feather_m0_express.json +++ b/boards/adafruit_feather_m0_express.json @@ -20,6 +20,9 @@ "usb_product": "Feather M0 Express", "variant": "feather_m0_express" }, + "debug": { + "openocd_chipname": "at91samd21g18" + }, "frameworks": [ "arduino" ], @@ -30,6 +33,12 @@ "maximum_size": 262144, "native_usb": true, "protocol": "sam-ba", + "protocols": [ + "sam-ba", + "blackmagic", + "jlink", + "atmel-ice" + ], "require_upload_port": true, "use_1200bps_touch": true, "wait_for_upload_port": true diff --git a/boards/adafruit_gemma_m0.json b/boards/adafruit_gemma_m0.json index 0aad4ee..335c276 100644 --- a/boards/adafruit_gemma_m0.json +++ b/boards/adafruit_gemma_m0.json @@ -20,6 +20,9 @@ "usb_product": "Adafruit Gemma M0", "variant": "gemma_m0" }, + "debug": { + "openocd_chipname": "at91samd21e18" + }, "frameworks": [ "arduino" ], @@ -30,6 +33,12 @@ "maximum_size": 262144, "native_usb": true, "protocol": "sam-ba", + "protocols": [ + "sam-ba", + "blackmagic", + "jlink", + "atmel-ice" + ], "require_upload_port": true, "use_1200bps_touch": true, "wait_for_upload_port": true diff --git a/boards/adafruit_metro_m0.json b/boards/adafruit_metro_m0.json index 9f3bbc6..a557213 100644 --- a/boards/adafruit_metro_m0.json +++ b/boards/adafruit_metro_m0.json @@ -21,30 +21,7 @@ "variant": "metro_m0" }, "debug": { - "tools": { - "cmsis-dap": { - "server": { - "package": "tool-openocd", - "executable": "bin/openocd", - "arguments": [ - "-s", "$PACKAGE_DIR/scripts", - "-f", "interface/cmsis-dap.cfg", - "-c", "set CHIPNAME at91samd21g18; set ENDIAN little; set telnet_port 0", - "-f", "target/at91samdXX.cfg" - ] - }, - "load_cmd": "preload" - }, - "blackmagic": { - "hwids": [ - [ - "0x1d50", - "0x6018" - ] - ], - "require_debug_port": true - } - } + "openocd_chipname": "at91samd21g18" }, "frameworks": [ "arduino" @@ -56,6 +33,12 @@ "maximum_size": 262144, "native_usb": true, "protocol": "sam-ba", + "protocols": [ + "sam-ba", + "blackmagic", + "jlink", + "atmel-ice" + ], "require_upload_port": true, "use_1200bps_touch": true, "wait_for_upload_port": true diff --git a/boards/adafruit_trinket_m0.json b/boards/adafruit_trinket_m0.json index 9643da6..e6ace5e 100644 --- a/boards/adafruit_trinket_m0.json +++ b/boards/adafruit_trinket_m0.json @@ -20,6 +20,9 @@ "usb_product": "Adafruit Trinket M0", "variant": "trinket_m0" }, + "debug": { + "openocd_chipname": "at91samd21e18" + }, "frameworks": [ "arduino" ], @@ -30,6 +33,12 @@ "maximum_size": 262144, "native_usb": true, "protocol": "sam-ba", + "protocols": [ + "sam-ba", + "blackmagic", + "jlink", + "atmel-ice" + ], "require_upload_port": true, "use_1200bps_touch": true, "wait_for_upload_port": true diff --git a/boards/digix.json b/boards/digix.json index 78075b0..ad78788 100644 --- a/boards/digix.json +++ b/boards/digix.json @@ -18,6 +18,9 @@ "connectivity": [ "can" ], + "debug": { + "openocd_chipname": "at91sam3X8E" + }, "frameworks": [ "arduino" ], @@ -28,6 +31,11 @@ "maximum_size": 524288, "native_usb": true, "protocol": "sam-ba", + "protocols": [ + "sam-ba", + "jlink", + "blackmagic" + ], "require_upload_port": true, "use_1200bps_touch": true, "wait_for_upload_port": true diff --git a/boards/due.json b/boards/due.json index 58e2426..4295520 100644 --- a/boards/due.json +++ b/boards/due.json @@ -23,6 +23,9 @@ "usb_product": "Arduino Due", "variant": "arduino_due_x" }, + "debug": { + "openocd_chipname": "at91sam3X8E" + }, "connectivity": [ "can" ], @@ -37,6 +40,11 @@ "maximum_size": 524288, "native_usb": false, "protocol": "sam-ba", + "protocols": [ + "sam-ba", + "jlink", + "blackmagic" + ], "require_upload_port": true, "use_1200bps_touch": true, "wait_for_upload_port": false diff --git a/boards/dueUSB.json b/boards/dueUSB.json index b75c59d..71a6028 100644 --- a/boards/dueUSB.json +++ b/boards/dueUSB.json @@ -22,6 +22,9 @@ "connectivity": [ "can" ], + "debug": { + "openocd_chipname": "at91sam3X8E" + }, "frameworks": [ "arduino", "simba" @@ -33,6 +36,11 @@ "maximum_size": 524288, "native_usb": true, "protocol": "sam-ba", + "protocols": [ + "sam-ba", + "jlink", + "blackmagic" + ], "require_upload_port": true, "use_1200bps_touch": true, "wait_for_upload_port": true diff --git a/boards/macchina2.json b/boards/macchina2.json index d23b1ce..f007a38 100644 --- a/boards/macchina2.json +++ b/boards/macchina2.json @@ -22,6 +22,9 @@ "connectivity": [ "can" ], + "debug": { + "openocd_chipname": "at91sam3X8E" + }, "frameworks": [ "arduino" ], @@ -32,6 +35,11 @@ "maximum_size": 524288, "native_usb": true, "protocol": "sam-ba", + "protocols": [ + "sam-ba", + "jlink", + "blackmagic" + ], "require_upload_port": true, "use_1200bps_touch": true, "wait_for_upload_port": true diff --git a/boards/mkr1000USB.json b/boards/mkr1000USB.json index 607d361..06070a6 100644 --- a/boards/mkr1000USB.json +++ b/boards/mkr1000USB.json @@ -31,30 +31,7 @@ "wifi" ], "debug": { - "tools": { - "cmsis-dap": { - "server": { - "package": "tool-openocd", - "executable": "bin/openocd", - "arguments": [ - "-s", "$PACKAGE_DIR/scripts", - "-f", "interface/cmsis-dap.cfg", - "-c", "set CHIPNAME at91samd21g18; set ENDIAN little; set telnet_port 0", - "-f", "target/at91samdXX.cfg" - ] - }, - "load_cmd": "preload" - }, - "blackmagic": { - "hwids": [ - [ - "0x1d50", - "0x6018" - ] - ], - "require_debug_port": true - } - } + "openocd_chipname": "at91samd21g18" }, "frameworks": [ "arduino" @@ -66,6 +43,12 @@ "maximum_size": 262144, "native_usb": true, "protocol": "sam-ba", + "protocols": [ + "sam-ba", + "blackmagic", + "jlink", + "atmel-ice" + ], "require_upload_port": true, "use_1200bps_touch": true, "wait_for_upload_port": true diff --git a/boards/mkrfox1200.json b/boards/mkrfox1200.json index 723b88d..d8001c0 100644 --- a/boards/mkrfox1200.json +++ b/boards/mkrfox1200.json @@ -19,16 +19,25 @@ "usb_product": "Arduino MKRFox1200", "variant": "mkrfox1200" }, + "debug": { + "openocd_chipname": "at91samd21g18" + }, "frameworks": [ "arduino" ], - "name": "Arduino MKRFox1200", + "name": "Arduino MKR FOX 1200", "upload": { "disable_flushing": true, "maximum_ram_size": 32768, "maximum_size": 262144, "native_usb": true, "protocol": "sam-ba", + "protocols": [ + "sam-ba", + "blackmagic", + "jlink", + "atmel-ice" + ], "require_upload_port": true, "use_1200bps_touch": true, "wait_for_upload_port": true diff --git a/boards/mkrgsm1400.json b/boards/mkrgsm1400.json new file mode 100644 index 0000000..a8b7d0d --- /dev/null +++ b/boards/mkrgsm1400.json @@ -0,0 +1,47 @@ +{ + "build": { + "core": "samd", + "cpu": "cortex-m0plus", + "extra_flags": "-DARDUINO_SAMD_MKRGSM1400 -DARDUINO_ARCH_SAMD -D__SAMD21G18A__ -DUSE_BQ24195L_PMIC", + "f_cpu": "48000000L", + "hwids": [ + [ + "0x2341", + "0x8052" + ], + [ + "0x2341", + "0x0052" + ] + ], + "ldscript": "flash_with_bootloader.ld", + "mcu": "samd21g18a", + "usb_product": "Arduino MKR GSM 1400", + "variant": "mkrgsm1400" + }, + "debug": { + "openocd_chipname": "at91samd21g18" + }, + "frameworks": [ + "arduino" + ], + "name": "Arduino MKR GSM 1400", + "upload": { + "disable_flushing": true, + "maximum_ram_size": 32768, + "maximum_size": 262144, + "native_usb": true, + "protocol": "sam-ba", + "protocols": [ + "sam-ba", + "blackmagic", + "jlink", + "atmel-ice" + ], + "require_upload_port": true, + "use_1200bps_touch": true, + "wait_for_upload_port": true + }, + "url": "https://store.arduino.cc/mkr-gsm-1400", + "vendor": "Arduino" +} \ No newline at end of file diff --git a/boards/mkrwan1300.json b/boards/mkrwan1300.json new file mode 100644 index 0000000..ffa3064 --- /dev/null +++ b/boards/mkrwan1300.json @@ -0,0 +1,47 @@ +{ + "build": { + "core": "samd", + "cpu": "cortex-m0plus", + "extra_flags": "-DARDUINO_SAMD_MKRWAN1300 -DARDUINO_ARCH_SAMD -D__SAMD21G18A__", + "f_cpu": "48000000L", + "hwids": [ + [ + "0x2341", + "0x8053" + ], + [ + "0x2341", + "0x0053" + ] + ], + "ldscript": "flash_with_bootloader.ld", + "mcu": "samd21g18a", + "usb_product": "Arduino MKR WAN 1300", + "variant": "mkrwan1300" + }, + "debug": { + "openocd_chipname": "at91samd21g18" + }, + "frameworks": [ + "arduino" + ], + "name": "Arduino MKR WAN 1300", + "upload": { + "disable_flushing": true, + "maximum_ram_size": 32768, + "maximum_size": 262144, + "native_usb": true, + "protocol": "sam-ba", + "protocols": [ + "sam-ba", + "blackmagic", + "jlink", + "atmel-ice" + ], + "require_upload_port": true, + "use_1200bps_touch": true, + "wait_for_upload_port": true + }, + "url": "https://store.arduino.cc/mkr-wan-1300", + "vendor": "Arduino" +} \ No newline at end of file diff --git a/boards/mkrzero.json b/boards/mkrzero.json index 842f82a..3ec7e57 100644 --- a/boards/mkrzero.json +++ b/boards/mkrzero.json @@ -16,19 +16,28 @@ ], "ldscript": "flash_with_bootloader.ld", "mcu": "samd21g18a", - "usb_product": "Arduino MKRZero", + "usb_product": "Arduino MKRZERO", "variant": "mkrzero" }, + "debug": { + "openocd_chipname": "at91samd21g18" + }, "frameworks": [ "arduino" ], - "name": "Arduino MKRZero", + "name": "Arduino MKRZERO", "upload": { "disable_flushing": true, "maximum_ram_size": 32768, "maximum_size": 262144, "native_usb": true, "protocol": "sam-ba", + "protocols": [ + "sam-ba", + "blackmagic", + "jlink", + "atmel-ice" + ], "require_upload_port": true, "use_1200bps_touch": true, "wait_for_upload_port": true diff --git a/boards/mzeroUSB.json b/boards/mzeroUSB.json index 7650ad6..37c1298 100644 --- a/boards/mzeroUSB.json +++ b/boards/mzeroUSB.json @@ -20,30 +20,7 @@ "variant": "arduino_mzero" }, "debug": { - "tools": { - "cmsis-dap": { - "server": { - "package": "tool-openocd", - "executable": "bin/openocd", - "arguments": [ - "-s", "$PACKAGE_DIR/scripts", - "-f", "interface/cmsis-dap.cfg", - "-c", "set CHIPNAME at91samd21g18; set ENDIAN little; set telnet_port 0", - "-f", "target/at91samdXX.cfg" - ] - }, - "load_cmd": "mon program \"$PROG_DIR/firmware.bin\" 0x4000" - }, - "blackmagic": { - "hwids": [ - [ - "0x1d50", - "0x6018" - ] - ], - "require_debug_port": true - } - } + "openocd_chipname": "at91samd21g18" }, "frameworks": [ "arduino" @@ -54,6 +31,12 @@ "maximum_ram_size": 32768, "maximum_size": 262144, "protocol": "stk500v2", + "protocols": [ + "stk500v2", + "blackmagic", + "jlink", + "atmel-ice" + ], "require_upload_port": true, "speed": 57600, "use_1200bps_touch": true, diff --git a/boards/mzeropro.json b/boards/mzeropro.json index f2956cf..aed5cb6 100644 --- a/boards/mzeropro.json +++ b/boards/mzeropro.json @@ -20,22 +20,10 @@ "variant": "arduino_mzero" }, "debug": { - "tools": { - "cmsis-dap": { - "server": { - "package": "tool-openocd", - "executable": "bin/openocd", - "arguments": [ - "-s", "$PACKAGE_DIR/scripts", - "-f", "interface/cmsis-dap.cfg", - "-c", "set CHIPNAME at91samd21g18; set ENDIAN little; set telnet_port 0", - "-f", "target/at91samdXX.cfg" - ] - }, - "load_cmd": "mon program \"$PROG_DIR/firmware.bin\" 0x4000", - "onboard": true - } - } + "onboard_tools": [ + "cmsis-dap" + ], + "openocd_chipname": "at91samd21g18" }, "frameworks": [ "arduino" @@ -45,8 +33,13 @@ "disable_flushing": true, "maximum_ram_size": 32768, "maximum_size": 262144, - "openocdcfg": "arduino_zero.cfg", - "protocol": "openocd", + "protocol": "cmsis-dap", + "protocols": [ + "cmsis-dap", + "blackmagic", + "jlink", + "atmel-ice" + ], "require_upload_port": false, "section_start": "0x4000", "use_1200bps_touch": false, diff --git a/boards/mzeroproUSB.json b/boards/mzeroproUSB.json index 43fdbbc..d141d62 100644 --- a/boards/mzeroproUSB.json +++ b/boards/mzeroproUSB.json @@ -27,6 +27,12 @@ "usb_product": "Arduino M0 Pro", "variant": "arduino_mzero" }, + "debug": { + "onboard_tools": [ + "cmsis-dap" + ], + "openocd_chipname": "at91samd21g18" + }, "frameworks": [ "arduino" ], @@ -36,6 +42,12 @@ "maximum_ram_size": 32768, "maximum_size": 262144, "protocol": "stk500v2", + "protocols": [ + "stk500v2", + "blackmagic", + "jlink", + "atmel-ice" + ], "require_upload_port": true, "speed": 57600, "use_1200bps_touch": true, diff --git a/boards/sainSmartDue.json b/boards/sainSmartDue.json index 1256994..13145f7 100644 --- a/boards/sainSmartDue.json +++ b/boards/sainSmartDue.json @@ -18,6 +18,9 @@ "connectivity": [ "can" ], + "debug": { + "openocd_chipname": "at91sam3X8E" + }, "frameworks": [ "arduino" ], @@ -28,6 +31,11 @@ "maximum_size": 524288, "native_usb": false, "protocol": "sam-ba", + "protocols": [ + "sam-ba", + "jlink", + "blackmagic" + ], "require_upload_port": true, "use_1200bps_touch": true, "wait_for_upload_port": false diff --git a/boards/sainSmartDueUSB.json b/boards/sainSmartDueUSB.json index 5d844a0..19f238a 100644 --- a/boards/sainSmartDueUSB.json +++ b/boards/sainSmartDueUSB.json @@ -18,6 +18,9 @@ "connectivity": [ "can" ], + "debug": { + "openocd_chipname": "at91sam3X8E" + }, "frameworks": [ "arduino" ], @@ -27,6 +30,11 @@ "maximum_ram_size": 32768, "maximum_size": 524288, "protocol": "sam-ba", + "protocols": [ + "sam-ba", + "jlink", + "blackmagic" + ], "native_usb": true, "require_upload_port": true, "use_1200bps_touch": true, diff --git a/boards/samd21_xpro.json b/boards/samd21_xpro.json index 8ffee0b..eef5d50 100644 --- a/boards/samd21_xpro.json +++ b/boards/samd21_xpro.json @@ -5,16 +5,10 @@ "mcu": "atsamd21j18a" }, "debug": { - "tools": { - "cmsis-dap": { - "server": { - "package": "tool-openocd", - "executable": "bin/openocd", - "arguments": ["-f", "scripts/board/atmel_samd21_xplained_pro.cfg"] - }, - "onboard": true - } - } + "onboard_tools": [ + "cmsis-dap" + ], + "openocd_chipname": "at91samd21j18" }, "frameworks": [ "mbed" @@ -23,8 +17,13 @@ "upload": { "maximum_ram_size": 32768, "maximum_size": 262144, - "openocdcfg": "atmel_samd21_xplained_pro.cfg", - "protocol": "openocd" + "protocol": "cmsis-dap", + "protocols": [ + "cmsis-dap", + "blackmagic", + "jlink", + "atmel-ice" + ] }, "url": "https://developer.mbed.org/platforms/SAMD21-XPRO/", "vendor": "Atmel" diff --git a/boards/samd21g18a.json b/boards/samd21g18a.json index fc7fb40..6662366 100644 --- a/boards/samd21g18a.json +++ b/boards/samd21g18a.json @@ -5,21 +5,10 @@ "mcu": "atsamd21g18a" }, "debug": { - "tools": { - "cmsis-dap": { - "server": { - "package": "tool-openocd", - "executable": "bin/openocd", - "arguments": [ - "-s", "$PACKAGE_DIR/scripts", - "-f", "interface/cmsis-dap.cfg", - "-c", "set CHIPNAME at91samd21g18;", - "-f", "target/at91samdXX.cfg" - ] - }, - "onboard": true - } - } + "onboard_tools": [ + "cmsis-dap" + ], + "openocd_chipname": "at91samd21g18" }, "frameworks": [ "mbed" @@ -28,8 +17,13 @@ "upload": { "maximum_ram_size": 32768, "maximum_size": 262144, - "openocdcfg": "atmel_samd21_xplained_pro.cfg", - "protocol": "openocd" + "protocol": "cmsis-dap", + "protocols": [ + "cmsis-dap", + "blackmagic", + "jlink", + "atmel-ice" + ] }, "url": "https://developer.mbed.org/platforms/SAMW25-XPRO/", "vendor": "Atmel" diff --git a/boards/saml21_xpro_b.json b/boards/saml21_xpro_b.json index 559442d..bb44156 100644 --- a/boards/saml21_xpro_b.json +++ b/boards/saml21_xpro_b.json @@ -5,16 +5,10 @@ "mcu": "atsaml21j18b" }, "debug": { - "tools": { - "cmsis-dap": { - "server": { - "package": "tool-openocd", - "executable": "bin/openocd", - "arguments": ["-f", "scripts/board/atmel_saml21_xplained_pro.cfg"] - }, - "onboard": true - } - } + "onboard_tools": [ + "cmsis-dap" + ], + "openocd_chipname": "at91saml21j18" }, "frameworks": [ "mbed" @@ -23,8 +17,13 @@ "upload": { "maximum_ram_size": 32768, "maximum_size": 262144, - "openocdcfg": "atmel_saml21_xplained_pro.cfg", - "protocol": "openocd" + "protocol": "cmsis-dap", + "protocols": [ + "cmsis-dap", + "blackmagic", + "jlink", + "atmel-ice" + ] }, "url": "https://developer.mbed.org/platforms/SAML21-XPRO/", "vendor": "Atmel" diff --git a/boards/samr21_xpro.json b/boards/samr21_xpro.json index db3dee5..3a459ec 100644 --- a/boards/samr21_xpro.json +++ b/boards/samr21_xpro.json @@ -5,16 +5,10 @@ "mcu": "atsamr21g18a" }, "debug": { - "tools": { - "cmsis-dap": { - "server": { - "package": "tool-openocd", - "executable": "bin/openocd", - "arguments": ["-f", "scripts/board/atmel_samr21_xplained_pro.cfg"] - }, - "onboard": true - } - } + "onboard_tools": [ + "cmsis-dap" + ], + "openocd_chipname": "at91samr21g18" }, "frameworks": [ "mbed" @@ -23,8 +17,13 @@ "upload": { "maximum_ram_size": 32768, "maximum_size": 262144, - "openocdcfg": "atmel_samr21_xplained_pro.cfg", - "protocol": "openocd" + "protocol": "cmsis-dap", + "protocols": [ + "cmsis-dap", + "blackmagic", + "jlink", + "atmel-ice" + ] }, "url": "https://developer.mbed.org/platforms/SAMR21-XPRO/", "vendor": "Atmel" diff --git a/boards/sodaq_autonomo.json b/boards/sodaq_autonomo.json index 5ba23ae..cf4e11a 100644 --- a/boards/sodaq_autonomo.json +++ b/boards/sodaq_autonomo.json @@ -20,6 +20,9 @@ "usb_product": "SODAQ Autonomo", "variant": "sodaq_autonomo" }, + "debug": { + "openocd_chipname": "at91samd21j18" + }, "frameworks": [ "arduino" ], @@ -30,6 +33,12 @@ "maximum_size": 262144, "native_usb": true, "protocol": "sam-ba", + "protocols": [ + "sam-ba", + "blackmagic", + "jlink", + "atmel-ice" + ], "require_upload_port": true, "use_1200bps_touch": true, "wait_for_upload_port": true diff --git a/boards/sodaq_explorer.json b/boards/sodaq_explorer.json index 3dad5d5..32b9ec5 100644 --- a/boards/sodaq_explorer.json +++ b/boards/sodaq_explorer.json @@ -21,42 +21,7 @@ "variant": "sodaq_explorer" }, "debug": { - "tools": { - "jlink": { - "server": [ - { - "arguments": [ - "-singlerun", - "-if", "SWD", - "-select", "USB", - "-device", "ATSAMD21J18", - "-port", "2331" - ], - "executable": "JLinkGDBServerCL.exe", - "system": [ - "windows", - "windows_amd64", - "windows_x86" - ] - }, - { - "arguments": [ - "-singlerun", - "-if", "SWD", - "-select", "USB", - "-device", "ATSAMD21J18", - "-port", "2331" - ], - "executable": "JLinkGDBServer", - "system": [ - "darwin_x86_64", - "linux_i686", - "linux_x86_64" - ] - } - ] - } - } + "openocd_chipname": "at91samd21j18" }, "frameworks": [ "arduino" @@ -68,6 +33,12 @@ "maximum_size": 262144, "native_usb": true, "protocol": "sam-ba", + "protocols": [ + "sam-ba", + "blackmagic", + "jlink", + "atmel-ice" + ], "require_upload_port": true, "use_1200bps_touch": true, "wait_for_upload_port": true diff --git a/boards/sodaq_one.json b/boards/sodaq_one.json index 5a8ef96..42a3270 100644 --- a/boards/sodaq_one.json +++ b/boards/sodaq_one.json @@ -21,42 +21,7 @@ "variant": "sodaq_one" }, "debug": { - "tools": { - "jlink": { - "server": [ - { - "arguments": [ - "-singlerun", - "-if", "SWD", - "-select", "USB", - "-device", "ATSAMD21G18", - "-port", "2331" - ], - "executable": "JLinkGDBServerCL.exe", - "system": [ - "windows", - "windows_amd64", - "windows_x86" - ] - }, - { - "arguments": [ - "-singlerun", - "-if", "SWD", - "-select", "USB", - "-device", "ATSAMD21G18", - "-port", "2331" - ], - "executable": "JLinkGDBServer", - "system": [ - "darwin_x86_64", - "linux_i686", - "linux_x86_64" - ] - } - ] - } - } + "openocd_chipname": "at91samd21g18" }, "frameworks": [ "arduino" @@ -68,6 +33,12 @@ "maximum_size": 262144, "native_usb": true, "protocol": "sam-ba", + "protocols": [ + "sam-ba", + "blackmagic", + "jlink", + "atmel-ice" + ], "require_upload_port": true, "use_1200bps_touch": true, "wait_for_upload_port": true diff --git a/boards/sparkfun_samd21_dev_usb.json b/boards/sparkfun_samd21_dev_usb.json index c63406f..54b0e1d 100644 --- a/boards/sparkfun_samd21_dev_usb.json +++ b/boards/sparkfun_samd21_dev_usb.json @@ -20,30 +20,7 @@ "variant": "arduino_zero" }, "debug": { - "tools": { - "cmsis-dap": { - "server": { - "package": "tool-openocd", - "executable": "bin/openocd", - "arguments": [ - "-s", "$PACKAGE_DIR/scripts", - "-f", "interface/cmsis-dap.cfg", - "-c", "set CHIPNAME at91samd21g18; set ENDIAN little; set telnet_port 0", - "-f", "target/at91samdXX.cfg" - ] - }, - "load_cmd": "preload" - }, - "blackmagic": { - "hwids": [ - [ - "0x1d50", - "0x6018" - ] - ], - "require_debug_port": true - } - } + "openocd_chipname": "at91samd21g18" }, "frameworks": [ "arduino" @@ -55,6 +32,12 @@ "maximum_size": 262144, "native_usb": true, "protocol": "sam-ba", + "protocols": [ + "sam-ba", + "blackmagic", + "jlink", + "atmel-ice" + ], "require_upload_port": true, "use_1200bps_touch": true, "wait_for_upload_port": true diff --git a/boards/sparkfun_samd21_mini_usb.json b/boards/sparkfun_samd21_mini_usb.json index e066c34..5d0f67b 100644 --- a/boards/sparkfun_samd21_mini_usb.json +++ b/boards/sparkfun_samd21_mini_usb.json @@ -20,30 +20,7 @@ "variant": "SparkFun_SAMD_Mini" }, "debug": { - "tools": { - "cmsis-dap": { - "server": { - "package": "tool-openocd", - "executable": "bin/openocd", - "arguments": [ - "-s", "$PACKAGE_DIR/scripts", - "-f", "interface/cmsis-dap.cfg", - "-c", "set CHIPNAME at91samd21g18; set ENDIAN little; set telnet_port 0", - "-f", "target/at91samdXX.cfg" - ] - }, - "load_cmd": "preload" - }, - "blackmagic": { - "hwids": [ - [ - "0x1d50", - "0x6018" - ] - ], - "require_debug_port": true - } - } + "openocd_chipname": "at91samd21g18" }, "frameworks": [ "arduino" @@ -55,6 +32,12 @@ "maximum_size": 262144, "native_usb": true, "protocol": "sam-ba", + "protocols": [ + "sam-ba", + "blackmagic", + "jlink", + "atmel-ice" + ], "require_upload_port": true, "use_1200bps_touch": true, "wait_for_upload_port": true diff --git a/boards/tian.json b/boards/tian.json index 0127c81..a68d269 100644 --- a/boards/tian.json +++ b/boards/tian.json @@ -22,6 +22,9 @@ "connectivity": [ "ethernet" ], + "debug": { + "openocd_chipname": "at91samd21g18" + }, "frameworks": [ "arduino" ], @@ -31,6 +34,12 @@ "maximum_ram_size": 32768, "maximum_size": 262144, "protocol": "stk500v2", + "protocols": [ + "stk500v2", + "blackmagic", + "jlink", + "atmel-ice" + ], "require_upload_port": true, "speed": 57600, "use_1200bps_touch": true, diff --git a/boards/zero.json b/boards/zero.json index 9001387..e9e5733 100644 --- a/boards/zero.json +++ b/boards/zero.json @@ -20,22 +20,10 @@ "variant": "arduino_zero" }, "debug": { - "tools": { - "cmsis-dap": { - "server": { - "package": "tool-openocd", - "executable": "bin/openocd", - "arguments": [ - "-s", "$PACKAGE_DIR/scripts", - "-f", "interface/cmsis-dap.cfg", - "-c", "set CHIPNAME at91samd21g18; set ENDIAN little; set telnet_port 0", - "-f", "target/at91samdXX.cfg" - ] - }, - "load_cmd": "mon program \"$PROG_DIR/firmware.bin\" 0x2000", - "onboard": true - } - } + "onboard_tools": [ + "cmsis-dap" + ], + "openocd_chipname": "at91samd21g18" }, "frameworks": [ "arduino" @@ -45,8 +33,13 @@ "disable_flushing": true, "maximum_ram_size": 32768, "maximum_size": 262144, - "openocdcfg": "arduino_zero.cfg", - "protocol": "openocd", + "protocol": "cmsis-dap", + "protocols": [ + "cmsis-dap", + "blackmagic", + "jlink", + "atmel-ice" + ], "require_upload_port": false, "section_start": "0x2000", "use_1200bps_touch": false, diff --git a/boards/zeroUSB.json b/boards/zeroUSB.json index e938ceb..78db719 100644 --- a/boards/zeroUSB.json +++ b/boards/zeroUSB.json @@ -23,6 +23,12 @@ "usb_product": "Arduino Zero", "variant": "arduino_zero" }, + "debug": { + "onboard_tools": [ + "cmsis-dap" + ], + "openocd_chipname": "at91samd21g18" + }, "frameworks": [ "arduino" ], @@ -33,6 +39,12 @@ "maximum_size": 262144, "native_usb": true, "protocol": "sam-ba", + "protocols": [ + "sam-ba", + "blackmagic", + "jlink", + "atmel-ice" + ], "require_upload_port": true, "use_1200bps_touch": true, "wait_for_upload_port": true diff --git a/builder/frameworks/mbed b/builder/frameworks/mbed index 8419e5c..f8391f1 160000 --- a/builder/frameworks/mbed +++ b/builder/frameworks/mbed @@ -1 +1 @@ -Subproject commit 8419e5c5da9a7d54443ae96635f995d27af79095 +Subproject commit f8391f1cdc5d7d01800f8d6e2e5993c56b7f03a3 diff --git a/builder/main.py b/builder/main.py index 28e2feb..c2f20fb 100644 --- a/builder/main.py +++ b/builder/main.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import sys from os.path import basename, join from SCons.Script import (ARGUMENTS, COMMAND_LINE_TARGETS, AlwaysBuild, @@ -46,6 +47,8 @@ def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621 env = DefaultEnvironment() platform = env.PioPlatform() +upload_protocol = env.subst("$UPLOAD_PROTOCOL") +build_mcu = env.get("BOARD_MCU", env.BoardConfig().get("build.mcu", "")) env.Replace( AR="arm-none-eabi-ar", @@ -66,7 +69,6 @@ def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621 ], CCFLAGS=[ - "-g", # include debugging info (so errors include line numbers) "-Os", # optimize for size "-ffunction-sections", # place each function in its own section "-fdata-sections", @@ -104,7 +106,6 @@ def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621 SIZEPRINTCMD='$SIZETOOL -B -d $SOURCES', - PROGNAME="firmware", PROGSUFFIX=".elf" ) @@ -137,9 +138,9 @@ def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621 ) ) -build_mcu = env.get("BOARD_MCU", env.BoardConfig().get("build.mcu", "")) -upload_protocol = env.get("UPLOAD_PROTOCOL", - env.BoardConfig().get("upload.protocol", "")) +# Allow user to override via pre:script +if env.get("PROGNAME", "program") == "program": + env.Replace(PROGNAME="firmware") if ("samd" in build_mcu) or ("samc" in build_mcu): env.Append( @@ -149,35 +150,62 @@ def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621 ] ) -if upload_protocol == "openocd": - env.Replace( - UPLOADER="openocd", - UPLOADERFLAGS=[ - "-s", join(platform.get_package_dir("tool-openocd") or "", - "scripts"), - "-f", join(env.BoardConfig().get("upload.openocdcfg", "")) - ], +# +# Target: Build executable and linkable firmware +# - UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS' - ) +target_elf = None +if "nobuild" in COMMAND_LINE_TARGETS: + target_firm = join("$BUILD_DIR", "${PROGNAME}.%s" % + ("hex" if upload_protocol == "stk500v2" else "bin")) +else: + target_elf = env.BuildProgram() + if upload_protocol == "stk500v2": + target_firm = env.ElfToHex( + join("$BUILD_DIR", "${PROGNAME}"), target_elf) + else: + target_firm = env.ElfToBin( + join("$BUILD_DIR", "${PROGNAME}"), target_elf) - if "zero" in env.subst("$BOARD"): - env.Append( - UPLOADERFLAGS=[ - "-s", join( - platform.get_package_dir("framework-arduinosam") or "", - "variants", env.BoardConfig().get("build.variant"), - "openocd_scripts") - ] - ) +AlwaysBuild(env.Alias("nobuild", target_firm)) +target_buildprog = env.Alias("buildprog", target_firm, target_firm) - env.Append( +# +# Target: Print binary size +# + +target_size = env.Alias( + "size", target_elf, + env.VerboseAction("$SIZEPRINTCMD", "Calculating size $SOURCE")) +AlwaysBuild(target_size) + +# +# Target: Upload by default .bin file +# + +debug_tools = env.BoardConfig().get("debug.tools", {}) +upload_actions = [] + +if upload_protocol.startswith("blackmagic"): + env.Replace( + UPLOADER="$GDB", UPLOADERFLAGS=[ - "-c", ("telnet_port disabled; program {{$SOURCES}} " - "verify reset %s; shutdown" % - env.BoardConfig().get("upload.section_start", "")) - ] + "-nx", + "--batch", + "-ex", "target extended-remote $UPLOAD_PORT", + "-ex", "monitor %s_scan" % + ("jtag" if upload_protocol == "blackmagic-jtag" else "swdp"), + "-ex", "attach 1", + "-ex", "load", + "-ex", "compare-sections", + "-ex", "kill" + ], + UPLOADCMD="$UPLOADER $UPLOADERFLAGS $BUILD_DIR/${PROGNAME}.elf" ) + upload_actions = [ + env.VerboseAction(env.AutodetectUploadPort, "Looking for BlackMagic port..."), + env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE") + ] elif upload_protocol == "sam-ba": env.Replace( @@ -192,14 +220,16 @@ def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621 "true" if env.BoardConfig().get( "upload.native_usb", False) else "false" ], - - UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS $SOURCES' + UPLOADCMD="$UPLOADER $UPLOADERFLAGS $SOURCES" ) if "sam3x8e" in build_mcu: env.Append(UPLOADERFLAGS=["--boot"]) - if int(ARGUMENTS.get("PIOVERBOSE", 0)): env.Prepend(UPLOADERFLAGS=["--info", "--debug"]) + upload_actions = [ + env.VerboseAction(BeforeUpload, "Looking for upload port..."), + env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE") + ] elif upload_protocol == "stk500v2": env.Replace( @@ -214,53 +244,40 @@ def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621 "-b", "$UPLOAD_SPEED", "-u" ], - - UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS -U flash:w:$SOURCES:i' + UPLOADCMD="$UPLOADER $UPLOADERFLAGS -U flash:w:$SOURCES:i" ) if int(ARGUMENTS.get("PIOVERBOSE", 0)): env.Prepend(UPLOADERFLAGS=["-v"]) + upload_actions = [ + env.VerboseAction(BeforeUpload, "Looking for upload port..."), + env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE") + ] -# -# Target: Build executable and linkable firmware -# - -target_elf = None -if "nobuild" in COMMAND_LINE_TARGETS: - target_firm = join("$BUILD_DIR", "firmware.%s" % ( - "hex" if upload_protocol == "stk500v2" else "bin")) -else: - target_elf = env.BuildProgram() - if upload_protocol == "stk500v2": - target_firm = env.ElfToHex(join("$BUILD_DIR", "firmware"), target_elf) - else: - target_firm = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf) - -AlwaysBuild(env.Alias("nobuild", target_firm)) -target_buildprog = env.Alias("buildprog", target_firm, target_firm) - -# -# Target: Print binary size -# - -target_size = env.Alias( - "size", target_elf, - env.VerboseAction("$SIZEPRINTCMD", "Calculating size $SOURCE")) -AlwaysBuild(target_size) +elif upload_protocol in debug_tools: + env.Replace( + UPLOADER="openocd", + UPLOADERFLAGS=debug_tools.get(upload_protocol).get("server").get( + "arguments", []) + [ + "-c", + "program {{$SOURCE}} verify reset %s; shutdown" % + env.BoardConfig().get("upload.section_start", "") + ], + UPLOADCMD="$UPLOADER $UPLOADERFLAGS" + ) + env['UPLOADERFLAGS'] = [ + f.replace("$PACKAGE_DIR", platform.get_package_dir("tool-openocd") or "") + for f in env['UPLOADERFLAGS'] + ] + upload_actions = [env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")] -# -# Target: Upload by default .bin file -# +# custom upload tool +elif "UPLOADCMD" in env: + upload_actions = [env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")] -if upload_protocol == "openocd": - target_upload = env.Alias( - "upload", target_firm, - env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")) else: - target_upload = env.Alias( - "upload", target_firm, - [env.VerboseAction(BeforeUpload, "Looking for upload port..."), - env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")]) -AlwaysBuild(target_upload) + sys.stderr.write("Warning! Unknown upload protocol %s\n" % upload_protocol) + +AlwaysBuild(env.Alias("upload", target_firm, upload_actions)) # # Setup default targets diff --git a/examples/mbed-events/.skiptest b/examples/mbed-events/.skiptest new file mode 100644 index 0000000..e69de29 diff --git a/platform.json b/platform.json index 38cc31f..b1da945 100644 --- a/platform.json +++ b/platform.json @@ -12,7 +12,7 @@ "type": "git", "url": "https://github.com/platformio/platform-atmelsam.git" }, - "version": "2.7.1", + "version": "3.0.0", "packageRepositories": [ "https://dl.bintray.com/platformio/dl-packages/manifest.json", "http://dl.platformio.org/packages/manifest.json", @@ -40,7 +40,7 @@ "framework-arduinosam": { "type": "framework", "optional": true, - "version": "~2.10616.1" + "version": "~2.10617.0" }, "framework-mbed": { "type": "framework", @@ -65,7 +65,7 @@ "tool-openocd": { "type": "uploader", "optional": true, - "version": "~1.900.2" + "version": "~1.1000.0" } } } diff --git a/platform.py b/platform.py index 2e5c159..011022d 100644 --- a/platform.py +++ b/platform.py @@ -19,14 +19,12 @@ class AtmelsamPlatform(PlatformBase): def configure_default_packages(self, variables, targets): if variables.get("board"): - upload_protocol = variables.get( - "upload_protocol", - self.board_config(variables.get("board")).get( - "upload.protocol", "")) - upload_tool = None - if upload_protocol == "openocd": - upload_tool = "tool-openocd" - elif upload_protocol == "sam-ba": + upload_protocol = variables.get("upload_protocol", + self.board_config( + variables.get("board")).get( + "upload.protocol", "")) + upload_tool = "tool-openocd" + if upload_protocol == "sam-ba": upload_tool = "tool-bossac" elif upload_protocol == "stk500v2": upload_tool = "tool-avrdude" @@ -44,3 +42,56 @@ def configure_default_packages(self, variables, targets): return PlatformBase.configure_default_packages(self, variables, targets) + + def get_boards(self, id_=None): + result = PlatformBase.get_boards(self, id_) + if not result: + return result + if id_: + return self._add_default_debug_tools(result) + else: + for key, value in result.items(): + result[key] = self._add_default_debug_tools(result[key]) + return result + + def _add_default_debug_tools(self, board): + debug = board.manifest.get("debug", {}) + upload_protocols = board.manifest.get("upload", {}).get( + "protocols", []) + if "tools" not in debug: + debug['tools'] = {} + + # Atmel Ice / J-Link / BlackMagic Probe + for link in ("blackmagic", "jlink", "atmel-ice", "cmsis-dap"): + if link not in upload_protocols or link in debug['tools']: + continue + if link == "blackmagic": + debug['tools']['blackmagic'] = { + "hwids": [["0x1d50", "0x6018"]], + "require_debug_port": True + } + else: + openocd_chipname = debug.get("openocd_chipname") + assert openocd_chipname + server_args = [ + "-s", "$PACKAGE_DIR/scripts", "-f", + "interface/%s.cfg" % ("cmsis-dap" + if link == "atmel-ice" else link), + "-c", + "set CHIPNAME %s; set ENDIAN little" % openocd_chipname, + "-f", + "target/%s.cfg" % + ("at91samdXX" + if "samd" in openocd_chipname else "at91sam3ax_8x") + ] + debug['tools'][link] = { + "server": { + "package": "tool-openocd", + "executable": "bin/openocd", + "arguments": server_args + }, + "onboard": link in debug.get("onboard_tools", []) + } + + board.manifest['debug'] = debug + return board \ No newline at end of file