From 1dc3c2fdb94d4ca81072357af0771af798957299 Mon Sep 17 00:00:00 2001 From: Frank Leon Rose Date: Sun, 20 Oct 2019 12:17:48 -0400 Subject: [PATCH 01/14] Working CMSIS build --- builder/frameworks/cmsis.py | 521 ++++++++++++++++++++++++++++++++++++ platform.json | 9 + 2 files changed, 530 insertions(+) create mode 100644 builder/frameworks/cmsis.py diff --git a/builder/frameworks/cmsis.py b/builder/frameworks/cmsis.py new file mode 100644 index 0000000..9a2bab0 --- /dev/null +++ b/builder/frameworks/cmsis.py @@ -0,0 +1,521 @@ +# Copyright 2014-present PlatformIO +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +CMSIS + +The ARM Cortex Microcontroller Software Interface Standard (CMSIS) is a +vendor-independent hardware abstraction layer for the Cortex-M processor +series and specifies debugger interfaces. The CMSIS enables consistent and +simple software interfaces to the processor for interface peripherals, +real-time operating systems, and middleware. It simplifies software +re-use, reducing the learning curve for new microcontroller developers +and cutting the time-to-market for devices. + +http://www.arm.com/products/processors/cortex-m/cortex-microcontroller-software-interface-standard.php +""" + +import sys +import re +from glob import glob +from string import Template +from os.path import isdir, isfile, join, basename + +from SCons.Script import DefaultEnvironment + +env = DefaultEnvironment() +platform = env.PioPlatform() + +env.SConscript("_bare.py") + +PLATFORM_NAME = env.get("PIOPLATFORM") +FRAMEWORK_DIR = platform.get_package_dir("framework-cmsis") +assert isdir(FRAMEWORK_DIR) + +VARIANT_DIRS = { + 'sam3a8c': 'sam3a', + 'sam3xa': 'sam3x', + 'sam3a4c': 'sam3a', + 'sam3n2a': 'sam3n', + 'sam3n4a': 'sam3n', + 'sam3n00a': 'sam3n', + 'sam3n0b': 'sam3n', + 'sam3n0c': 'sam3n', + 'sam3n1b': 'sam3n', + 'sam3n1c': 'sam3n', + 'sam3n00b': 'sam3n', + 'sam3n0a': 'sam3n', + 'sam3n4b': 'sam3n', + 'sam3n4c': 'sam3n', + 'sam3n2b': 'sam3n', + 'sam3n2c': 'sam3n', + 'sam3n1a': 'sam3n', + 'sam3n': 'sam3n', + 'sam3s8c': 'sam3sd8', + 'sam3s8b': 'sam3sd8', + 'sam3sd8c': 'sam3sd8', + 'sam3sd8b': 'sam3sd8', + 'sam3sd8': 'sam3sd8', + 'sam3s1a': 'sam3s', + 'sam3s2b': 'sam3s', + 'sam3s2c': 'sam3s', + 'sam3s': 'sam3s', + 'sam3s4b': 'sam3s', + 'sam3s4c': 'sam3s', + 'sam3s1b': 'sam3s', + 'sam3s1c': 'sam3s', + 'sam3s4a': 'sam3s', + 'sam3s2a': 'sam3s', + 'sam3u': 'sam3u', + 'sam3u1e': 'sam3u', + 'sam3u1c': 'sam3u', + 'sam3u2c': 'sam3u', + 'sam3u4c': 'sam3u', + 'sam3u4e': 'sam3u', + 'sam3u2e': 'sam3u', + 'sam3x8e': 'sam3x', + 'sam3x4c': 'sam3x', + 'sam3x4e': 'sam3x', + 'sam3x8c': 'sam3x', + 'sam3x8h': 'sam3x', + 'sam4cms32c_0': 'sam4cm32', + 'sam4cms32c_1': 'sam4cm32', + 'sam4cmp32c_0': 'sam4cm32', + 'sam4cmp32c_1': 'sam4cm32', + 'sam4cm': 'sam4cm', + 'sam4c8c_1': 'sam4c', + 'sam4c8c_0': 'sam4c', + 'sam4c4c_0': 'sam4c', + 'sam4c4c_1': 'sam4c', + 'sam4c16c_1': 'sam4c', + 'sam4c16c_0': 'sam4c', + 'sam4c': 'sam4c', + 'sam4cmp16c_1': 'sam4cm', + 'sam4cmp16c_0': 'sam4cm', + 'sam4cmp8c_1': 'sam4cm', + 'sam4cmp8c_0': 'sam4cm', + 'sam4cms16c_1': 'sam4cm', + 'sam4cms16c_0': 'sam4cm', + 'sam4cms4c_1': 'sam4cm', + 'sam4cms4c_0': 'sam4cm', + 'sam4cms8c_0': 'sam4cm', + 'sam4cms8c_1': 'sam4cm', + 'sam4cp16b_0': 'sam4cp', + 'sam4cp16b_1': 'sam4cp', + 'sam4cp16c_1': 'sam4cp', + 'sam4cp16c_0': 'sam4cp', + 'sam4cp': 'sam4cp', + 'sam4c32c_0': 'sam4c32', + 'sam4c32c_1': 'sam4c32', + 'sam4c32e_0': 'sam4c32', + 'sam4c32e_1': 'sam4c32', + 'sam4c32': 'sam4c32', + 'sam4e': 'sam4e', + 'sam4e8cb': 'sam4ecb', + 'sam4e16cb': 'sam4ecb', + 'sam4e8e': 'sam4e', + 'sam4e16e': 'sam4e', + 'sam4e16c': 'sam4e', + 'sam4e8c': 'sam4e', + 'sam4ls4c': 'sam4l4', + 'sam4ls4b': 'sam4l4', + 'sam4ls2c': 'sam4l4', + 'sam4ls2b': 'sam4l4', + 'sam4lc4a': 'sam4l4', + 'sam4lc2a': 'sam4l4', + 'sam4ls2a': 'sam4l4', + 'sam4ls4a': 'sam4l4', + 'sam4lc2c': 'sam4l4', + 'sam4lc2b': 'sam4l4', + 'sam4lc4c': 'sam4l4', + 'sam4lc4b': 'sam4l4', + 'sam4lc8a': 'sam4l8', + 'sam4ls8b': 'sam4l8', + 'sam4ls8c': 'sam4l8', + 'sam4lc8b': 'sam4l8', + 'sam4lc8c': 'sam4l8', + 'sam4ls8a': 'sam4l8', + 'sam4n16c': 'sam4n', + 'sam4n16b': 'sam4n', + 'sam4n8b': 'sam4n', + 'sam4n8c': 'sam4n', + 'sam4n': 'sam4n', + 'sam4n8a': 'sam4n', + 'sam4sp': 'sam4sp', + 'sam4sp32a': 'sam4sp', + 'sam4s': 'sam4s', + 'sam4sd16b': 'sam4s', + 'sam4sd16c': 'sam4s', + 'sam4s2a': 'sam4s', + 'sam4sa16b': 'sam4s', + 'sam4sa16c': 'sam4s', + 'sam4s4a': 'sam4s', + 'sam4s4c': 'sam4s', + 'sam4s4b': 'sam4s', + 'sam4s2c': 'sam4s', + 'sam4s2b': 'sam4s', + 'sam4s16b': 'sam4s', + 'sam4s16c': 'sam4s', + 'sam4s8b': 'sam4s', + 'sam4s8c': 'sam4s', + 'sam4sd32c': 'sam4s', + 'sam4sd32b': 'sam4s', + 'samb11': 'samb11', + 'samc20e18a': 'samc20', + 'samc20e15a': 'samc20', + 'samc20g16a': 'samc20', + 'samc20j17au': 'samc20', + 'samc20j15a': 'samc20', + 'samc20j18a': 'samc20', + 'samc20g17a': 'samc20', + 'samc20j18au': 'samc20', + 'samc20j16a': 'samc20', + 'samc20e17a': 'samc20', + 'samc20j17a': 'samc20', + 'samc20g18a': 'samc20', + 'samc20g15a': 'samc20', + 'samc20e16a': 'samc20', + 'samc20n17a': 'samc20n', + 'samc20n18a': 'samc20n', + 'samc21n17a': 'samc21n', + 'samc21n18a': 'samc21n', + 'samc21e18a': 'samc21', + 'samc21g16a': 'samc21', + 'samc21e15a': 'samc21', + 'samc21j15a': 'samc21', + 'samc21j18a': 'samc21', + 'samc21g17a': 'samc21', + 'samc21j18au': 'samc21', + 'samc21j16a': 'samc21', + 'samc21e17a': 'samc21', + 'samc21j17au': 'samc21', + 'samc21j17a': 'samc21', + 'samc21g18a': 'samc21', + 'samc21e16a': 'samc21', + 'samc21g15a': 'samc21', + 'samd09c13a': 'samd09', + 'samd09d14a': 'samd09', + 'samd10d13as': 'samd10', + 'samd10d14au': 'samd10', + 'samd10d13am': 'samd10', + 'samd10c14a': 'samd10', + 'samd10d14am': 'samd10', + 'samd10c13a': 'samd10', + 'samd10d14as': 'samd10', + 'samd11c14a': 'samd11', + 'samd11d14as': 'samd11', + 'samd11d14am': 'samd11', + 'samd11d14au': 'samd11', + 'samd20g17': 'samd20', + 'samd20g16': 'samd20', + 'samd20j17': 'samd20', + 'samd20j16': 'samd20', + 'samd20e16': 'samd20', + 'samd20e17': 'samd20', + 'samd20g17u': 'samd20', + 'samd20e18': 'samd20', + 'samd20j14': 'samd20', + 'samd20j15': 'samd20', + 'samd20g14': 'samd20', + 'samd20g15': 'samd20', + 'samd20g18': 'samd20', + 'samd20j18': 'samd20', + 'samd20g18u': 'samd20', + 'samd20e15': 'samd20', + 'samd20e14': 'samd20', + 'samd20j16b': 'samd20b', + 'samd20g14b': 'samd20b', + 'samd20g15b': 'samd20b', + 'samd20e16b': 'samd20b', + 'samd20j14b': 'samd20b', + 'samd20e15b': 'samd20b', + 'samd20g16b': 'samd20b', + 'samd20j15b': 'samd20b', + 'samd20e14b': 'samd20b', + 'samd21e16bu': 'samd21b', + 'samd21e15bu': 'samd21b', + 'samd21g17l': 'samd21d', + 'samd21j17d': 'samd21d', + 'samd21e17d': 'samd21d', + 'samd21e17du': 'samd21d', + 'samd21g17d': 'samd21d', + 'samd21e17l': 'samd21d', + 'samd21j16b': 'samd21c', + 'samd21g16l': 'samd21c', + 'samd21e16b': 'samd21c', + 'samd21g15b': 'samd21c', + 'samd21e16cu': 'samd21c', + 'samd21e15l': 'samd21c', + 'samd21g16b': 'samd21c', + 'samd21e16l': 'samd21c', + 'samd21g15l': 'samd21c', + 'samd21e15b': 'samd21c', + 'samd21e15cu': 'samd21c', + 'samd21j15b': 'samd21c', + 'samd21g16a': 'samd21a', + 'samd21e15a': 'samd21a', + 'samd21e18a': 'samd21a', + 'samd21j18a': 'samd21a', + 'samd21g17a': 'samd21a', + 'samd21j15a': 'samd21a', + 'samd21g17au': 'samd21a', + 'samd21e17a': 'samd21a', + 'samd21j16a': 'samd21a', + 'samd21g18au': 'samd21a', + 'samd21e16a': 'samd21a', + 'samd21g15a': 'samd21a', + 'samd21j17a': 'samd21a', + 'samd21g18a': 'samd21a', + 'samd51j19a': 'samd51a', + 'samd51p19a': 'samd51a', + 'samd51j20a': 'samd51a', + 'samd51j18a': 'samd51a', + 'samd51p20a': 'samd51a', + 'samd51g19a': 'samd51a', + 'samd51n19a': 'samd51a', + 'samd51g18a': 'samd51a', + 'samd51n20a': 'samd51a', + 'samda1j14b': 'samda1b', + 'samda1e15b': 'samda1b', + 'samda1g16b': 'samda1b', + 'samda1j15b': 'samda1b', + 'samda1e14b': 'samda1b', + 'samda1j16b': 'samda1b', + 'samda1g14b': 'samda1b', + 'samda1g15b': 'samda1b', + 'samda1e16b': 'samda1b', + 'samda1g14a': 'samda1', + 'samda1j16a': 'samda1', + 'samda1g15a': 'samda1', + 'samda1e16a': 'samda1', + 'samda1e15a': 'samda1', + 'samda1g16a': 'samda1', + 'samda1j14a': 'samda1', + 'samda1e14a': 'samda1', + 'samda1j15a': 'samda1', + 'same51j19a': 'same51', + 'same51j18a': 'same51', + 'same51j20a': 'same51', + 'same51n19a': 'same51', + 'same51n20a': 'same51', + 'same53n20a': 'same53', + 'same53n19a': 'same53', + 'same53j18a': 'same53', + 'same53j20a': 'same53', + 'same53j19a': 'same53', + 'same54n20a': 'same54', + 'same54n19a': 'same54', + 'same54p20a': 'same54', + 'same54p19a': 'same54', + 'same70j20b': 'same70b', + 'same70j19b': 'same70b', + 'same70j21b': 'same70b', + 'same70n20b': 'same70b', + 'same70q20b': 'same70b', + 'same70q19b': 'same70b', + 'same70n19b': 'same70b', + 'same70n21b': 'same70b', + 'same70q21b': 'same70b', + 'same70n21': 'same70a', + 'same70n20': 'same70a', + 'same70n19': 'same70a', + 'same70q20': 'same70a', + 'same70q21': 'same70a', + 'same70j20': 'same70a', + 'same70j21': 'same70a', + 'same70j19': 'same70a', + 'same70q19': 'same70a', + 'samg51g18': 'samg51', + 'samg51n18': 'samg51', + 'samg55g19': 'samg55', + 'samg55j19': 'samg55', + 'samg53n19': 'samg53', + 'samg53g19': 'samg53', + 'samg54j19': 'samg54', + 'samg54g19': 'samg54', + 'samg54n19': 'samg54', + 'samha1g15a': 'samha1a', + 'samha1g14a': 'samha1a', + 'samha1g16a': 'samha1a', + 'samha1e16ab': 'samha1ab', + 'samha1g15ab': 'samha1ab', + 'samha1e14ab': 'samha1ab', + 'samha1g14ab': 'samha1ab', + 'samha1g16ab': 'samha1ab', + 'samha1e15ab': 'samha1ab', + 'saml10e15a': 'saml10', + 'saml10d16a': 'saml10', + 'saml10e14a': 'saml10', + 'saml10d15a': 'saml10', + 'saml10d14a': 'saml10', + 'saml10e16a': 'saml10', + 'saml11e15a': 'saml11', + 'saml11e14a': 'saml11', + 'saml11d16a': 'saml11', + 'saml11d15a': 'saml11', + 'saml11e16a': 'saml11', + 'saml11d14a': 'saml11', + 'saml21e18a': 'saml21a1', + 'saml21j18a': 'saml21a1', + 'saml21g18a': 'saml21a1', + 'saml21j16b': 'saml21b', + 'saml21j17bu': 'saml21b', + 'saml21e17b': 'saml21b', + 'saml21g18b': 'saml21b', + 'saml21j17b': 'saml21b', + 'saml21e16b': 'saml21b', + 'saml21j18bu': 'saml21b', + 'saml21e18b': 'saml21b', + 'saml21e15b': 'saml21b', + 'saml21g16b': 'saml21b', + 'saml21g17b': 'saml21b', + 'saml21j18b': 'saml21b', + 'saml22n18a': 'saml22', + 'saml22j17a': 'saml22', + 'saml22g18a': 'saml22', + 'saml22j16a': 'saml22', + 'saml22j18a': 'saml22', + 'saml22g17a': 'saml22', + 'saml22n17a': 'saml22', + 'saml22g16a': 'saml22', + 'saml22n16a': 'saml22', + 'samr21e17a': 'samr21', + 'samr21e16a': 'samr21', + 'samr21g18a': 'samr21', + 'samr21g16a': 'samr21', + 'samr21e18a': 'samr21', + 'samr21g17a': 'samr21', + 'samr21e19a': 'samr21', + 'samr30e18a': 'samr30', + 'samr30g18a': 'samr30', + 'samr34j18b': 'samr34', + 'samr34j16b': 'samr34', + 'samr34j17b': 'samr34', + 'samr35j18b': 'samr35', + 'samr35j16b': 'samr35', + 'samr35j17b': 'samr35', + 'sams70n20b': 'sams70b', + 'sams70q20b': 'sams70b', + 'sams70q19b': 'sams70b', + 'sams70n19b': 'sams70b', + 'sams70n21b': 'sams70b', + 'sams70q21b': 'sams70b', + 'sams70j20b': 'sams70b', + 'sams70j19b': 'sams70b', + 'sams70j21b': 'sams70b', + 'sams70n21': 'sams70a', + 'sams70n20': 'sams70a', + 'sams70n19': 'sams70a', + 'sams70j20': 'sams70a', + 'sams70j21': 'sams70a', + 'sams70q20': 'sams70a', + 'sams70q21': 'sams70a', + 'sams70q19': 'sams70a', + 'sams70j19': 'sams70a', + 'samv70q19b': 'samv70b', + 'samv70n19b': 'samv70b', + 'samv70n20b': 'samv70b', + 'samv70q20b': 'samv70b', + 'samv70j19b': 'samv70b', + 'samv70j20b': 'samv70b', + 'samv70j19': 'samv70', + 'samv70q19': 'samv70', + 'samv70q20': 'samv70', + 'samv70j20': 'samv70', + 'samv70n19': 'samv70', + 'samv70n20': 'samv70', + 'samv71n19': 'samv71', + 'samv71n20': 'samv71', + 'samv71n21': 'samv71', + 'samv71q19': 'samv71', + 'samv71j19': 'samv71', + 'samv71j21': 'samv71', + 'samv71j20': 'samv71', + 'samv71q21': 'samv71', + 'samv71q20': 'samv71', + 'samv71n19b': 'samv71b', + 'samv71q19b': 'samv71b', + 'samv71q21b': 'samv71b', + 'samv71n21b': 'samv71b', + 'samv71q20b': 'samv71b', + 'samv71n20b': 'samv71b', + 'samv71j19b': 'samv71b', + 'samv71j21b': 'samv71b', + 'samv71j20b': 'samv71b', +} + +def get_variant_dir(mcu): + mcu = mcu.lower() + if mcu not in VARIANT_DIRS: + sys.stderr.write( + """Error: There is no variant dir for %s MCU! + Please add initialization code to your project manually!""" % mcu) + raise Exception("Unknown MCU '%s'" % mcu) + + return join(FRAMEWORK_DIR, "variants", PLATFORM_NAME, VARIANT_DIRS[mcu]) + +def adjust_linker_offset(mcu, ldscript): + offset_address = env.BoardConfig().get("upload.offset_address", None) + if offset_address is None or int(offset_address, 0)==0: + return ldscript + + content = "" + with open(ldscript) as fp: + content = fp.read() + # original: rom (rx) : ORIGIN = 0x00000000, LENGTH = 0x00040000 + # transformed: rom (rx) : ORIGIN = 0x00000000+0x2000, LENGTH = 0x00040000-0x2000 + content = re.sub( + r"^(\s*rom.*ORIGIN[^,]+)(,\s*LENGTH.*)$", + r"\1+%s\2-%s" % (offset_address, offset_address), + content, flags=re.MULTILINE) + + # offset_script = join("$BUILD_DIR", basename(ldscript)) + offset_script = join(FRAMEWORK_DIR, "platformio", "ldscripts", PLATFORM_NAME, + "%s_flash_%s.ld" % (mcu, offset_address)) + + with open(offset_script, "w") as fp: + fp.write(content) + + return offset_script + +def get_linker_script(mcu): + ldscript = join(FRAMEWORK_DIR, "platformio", "ldscripts", PLATFORM_NAME, + mcu.lower() + "_flash.ld") + + if isfile(ldscript): + return adjust_linker_offset(mcu, ldscript) + + sys.stderr.write( + """Error: There is no linker script for %s MCU! + Please add custom linker script to your project manually!""" % mcu) + raise Exception("Unknown MCU '%s'" % mcu) + +env.Append(CPPPATH=[ + join(FRAMEWORK_DIR, "CMSIS", "Core", "Include"), + join(get_variant_dir(env.BoardConfig().get("build.mcu")), "include") +]) + + +env.Replace( + LDSCRIPT_PATH=get_linker_script(env.BoardConfig().get("build.mcu"))) + +# +# Target: Build Core Library +# + +# Sources because as Library the vector table doesn't get linked in. +env.BuildSources( + join("$BUILD_DIR", "FrameworkCMSISVariant"), + join(get_variant_dir(env.BoardConfig().get("build.mcu")), "gcc") +) diff --git a/platform.json b/platform.json index b00fb8c..5844f9a 100644 --- a/platform.json +++ b/platform.json @@ -23,6 +23,10 @@ "package": "framework-arduinosam", "script": "builder/frameworks/arduino.py" }, + "cmsis": { + "package": "framework-cmsis", + "script": "builder/frameworks/cmsis.py" + }, "mbed": { "package": "framework-mbed", "script": "builder/frameworks/mbed/mbed.py" @@ -42,6 +46,11 @@ "optional": true, "version": "~4.4.0" }, + "framework-cmsis": { + "type": "framework", + "optional": true, + "version": "~2.50400.191019" + }, "framework-mbed": { "type": "framework", "optional": true, From 5b34729dcf7f304e87bfd3ee518e186e309db095 Mon Sep 17 00:00:00 2001 From: Frank Leon Rose Date: Sun, 20 Oct 2019 12:18:38 -0400 Subject: [PATCH 02/14] Added CMSIS framework to FeatherM0 and Moteino Zero --- boards/adafruit_feather_m0.json | 3 ++- boards/moteino_zero.json | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/boards/adafruit_feather_m0.json b/boards/adafruit_feather_m0.json index 2d7368f..77babd8 100644 --- a/boards/adafruit_feather_m0.json +++ b/boards/adafruit_feather_m0.json @@ -31,7 +31,8 @@ "svd_path": "ATSAMD21G18A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Adafruit Feather M0", "upload": { diff --git a/boards/moteino_zero.json b/boards/moteino_zero.json index 46d6888..a0bfd9b 100644 --- a/boards/moteino_zero.json +++ b/boards/moteino_zero.json @@ -26,7 +26,8 @@ "svd_path": "ATSAMD21G18A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Moteino M0", "upload": { From a82f95ce759c0e5bed654abaaa623ca83c234f24 Mon Sep 17 00:00:00 2001 From: Frank Leon Rose Date: Tue, 22 Oct 2019 12:40:03 -0400 Subject: [PATCH 03/14] Don't `raise` exceptions, use `env.Exit(1)` to fail out of build --- builder/frameworks/cmsis.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/builder/frameworks/cmsis.py b/builder/frameworks/cmsis.py index 9a2bab0..e64b685 100644 --- a/builder/frameworks/cmsis.py +++ b/builder/frameworks/cmsis.py @@ -461,7 +461,7 @@ def get_variant_dir(mcu): sys.stderr.write( """Error: There is no variant dir for %s MCU! Please add initialization code to your project manually!""" % mcu) - raise Exception("Unknown MCU '%s'" % mcu) + env.Exit(1) return join(FRAMEWORK_DIR, "variants", PLATFORM_NAME, VARIANT_DIRS[mcu]) @@ -499,7 +499,7 @@ def get_linker_script(mcu): sys.stderr.write( """Error: There is no linker script for %s MCU! Please add custom linker script to your project manually!""" % mcu) - raise Exception("Unknown MCU '%s'" % mcu) + env.Exit(1) env.Append(CPPPATH=[ join(FRAMEWORK_DIR, "CMSIS", "Core", "Include"), From a8e71c28c722d029cf68598adaf2ea256c7ffe2c Mon Sep 17 00:00:00 2001 From: Frank Leon Rose Date: Sun, 27 Oct 2019 15:00:09 -0400 Subject: [PATCH 04/14] Added CMSIS Blink example --- examples/cmsis-blink/include/README | 39 ++++++++++++++++++++++ examples/cmsis-blink/lib/README | 46 ++++++++++++++++++++++++++ examples/cmsis-blink/platformio.ini | 4 +++ examples/cmsis-blink/src/main.cpp | 50 +++++++++++++++++++++++++++++ examples/cmsis-blink/test/README | 11 +++++++ 5 files changed, 150 insertions(+) create mode 100644 examples/cmsis-blink/include/README create mode 100644 examples/cmsis-blink/lib/README create mode 100644 examples/cmsis-blink/platformio.ini create mode 100644 examples/cmsis-blink/src/main.cpp create mode 100644 examples/cmsis-blink/test/README diff --git a/examples/cmsis-blink/include/README b/examples/cmsis-blink/include/README new file mode 100644 index 0000000..194dcd4 --- /dev/null +++ b/examples/cmsis-blink/include/README @@ -0,0 +1,39 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/examples/cmsis-blink/lib/README b/examples/cmsis-blink/lib/README new file mode 100644 index 0000000..6debab1 --- /dev/null +++ b/examples/cmsis-blink/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into executable file. + +The source code of each library should be placed in a an own separate directory +("lib/your_library_name/[here are source files]"). + +For example, see a structure of the following two libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +and a contents of `src/main.c`: +``` +#include +#include + +int main (void) +{ + ... +} + +``` + +PlatformIO Library Dependency Finder will find automatically dependent +libraries scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/examples/cmsis-blink/platformio.ini b/examples/cmsis-blink/platformio.ini new file mode 100644 index 0000000..b96382a --- /dev/null +++ b/examples/cmsis-blink/platformio.ini @@ -0,0 +1,4 @@ +[env:feather_bare] +platform = atmelsam +framework = cmsis +board = adafruit_feather_m0 diff --git a/examples/cmsis-blink/src/main.cpp b/examples/cmsis-blink/src/main.cpp new file mode 100644 index 0000000..d455faf --- /dev/null +++ b/examples/cmsis-blink/src/main.cpp @@ -0,0 +1,50 @@ +#include +#include + +#define LED_PORT PORT_PA17 + +void toggleLED() { + static bool led = false; + led = !led; + + if (led) { + REG_PORT_OUT0 &= ~LED_PORT; + } + else { + REG_PORT_OUT0 |= LED_PORT; + } +} + +void init() { + SystemInit(); + + // Direct register manipulation, because CMSIS does not provide a GPIO abstraction. + REG_PORT_DIR0 |= LED_PORT; +} + +const uint32_t CYCLES_PER_SEC = 1000000; // Initial speed of SAMD21 post reset +const uint32_t CYCLES_PER_MS = CYCLES_PER_SEC / 1000; +const uint32_t CYCLES_PER_LOOP = 6; +const uint32_t LOOPS_PER_MS = CYCLES_PER_MS / CYCLES_PER_LOOP; +void spinDelay(uint16_t ms) { + for (uint16_t d = 0; d Date: Sun, 27 Oct 2019 15:03:34 -0400 Subject: [PATCH 05/14] Renamed env same as board to match other examples --- examples/cmsis-blink/platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/cmsis-blink/platformio.ini b/examples/cmsis-blink/platformio.ini index b96382a..276e507 100644 --- a/examples/cmsis-blink/platformio.ini +++ b/examples/cmsis-blink/platformio.ini @@ -1,4 +1,4 @@ -[env:feather_bare] +[env:adafruit_feather_m0] platform = atmelsam framework = cmsis board = adafruit_feather_m0 From e5c9a7157d45e861166e7482c87ca6511fcb4598 Mon Sep 17 00:00:00 2001 From: Frank Leon Rose Date: Sun, 27 Oct 2019 15:38:01 -0400 Subject: [PATCH 06/14] Added some more example boards --- boards/adafruit_circuitplayground_m0.json | 3 ++- boards/adafruit_itsybitsy_m0.json | 3 ++- boards/adafruit_metro_m4.json | 3 ++- examples/cmsis-blink/platformio.ini | 21 +++++++++++++++++++++ 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/boards/adafruit_circuitplayground_m0.json b/boards/adafruit_circuitplayground_m0.json index 1555637..4ad35fb 100644 --- a/boards/adafruit_circuitplayground_m0.json +++ b/boards/adafruit_circuitplayground_m0.json @@ -27,7 +27,8 @@ "svd_path": "ATSAMD21G18A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Adafruit Circuit Playground Express", "upload": { diff --git a/boards/adafruit_itsybitsy_m0.json b/boards/adafruit_itsybitsy_m0.json index ff09877..1e5fbac 100644 --- a/boards/adafruit_itsybitsy_m0.json +++ b/boards/adafruit_itsybitsy_m0.json @@ -27,7 +27,8 @@ "svd_path": "ATSAMD21G18A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Adafruit ItsyBitsy M0", "upload": { diff --git a/boards/adafruit_metro_m4.json b/boards/adafruit_metro_m4.json index 7e4727f..9e94616 100644 --- a/boards/adafruit_metro_m4.json +++ b/boards/adafruit_metro_m4.json @@ -37,7 +37,8 @@ "svd_path": "ATSAMD51J19A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Adafruit Metro M4", "upload": { diff --git a/examples/cmsis-blink/platformio.ini b/examples/cmsis-blink/platformio.ini index 276e507..872a10a 100644 --- a/examples/cmsis-blink/platformio.ini +++ b/examples/cmsis-blink/platformio.ini @@ -1,4 +1,25 @@ +[env:adafruit_circuitplayground_m0] +platform = atmelsam +framework = cmsis +board = adafruit_circuitplayground_m0 + [env:adafruit_feather_m0] platform = atmelsam framework = cmsis board = adafruit_feather_m0 + +[env:adafruit_itsybitsy_m0] +platform = atmelsam +framework = cmsis +board = adafruit_itsybitsy_m0 + +[env:adafruit_metro_m4] +platform = atmelsam +framework = cmsis +board = adafruit_metro_m4 + +[env:moteino_zero] +platform = atmelsam +framework = cmsis +board = moteino_zero + From ca279122e8190997dd747144a6434088edbfb1d1 Mon Sep 17 00:00:00 2001 From: Frank Leon Rose Date: Sun, 27 Oct 2019 15:43:22 -0400 Subject: [PATCH 07/14] Added examples/cmsis-blink to CI scripts --- .travis.yml | 1 + appveyor.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 3ed1568..957d2cb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ env: - PLATFORMIO_PROJECT_DIR=examples/arduino-external-libs - PLATFORMIO_PROJECT_DIR=examples/arduino-internal-libs - PLATFORMIO_PROJECT_DIR=examples/arduino-web-thing-led + - PLATFORMIO_PROJECT_DIR=examples/cmsis-blink - PLATFORMIO_PROJECT_DIR=examples/mbed-blink - PLATFORMIO_PROJECT_DIR=examples/mbed-dsp # - PLATFORMIO_PROJECT_DIR=examples/mbed-events diff --git a/appveyor.yml b/appveyor.yml index d43fcf4..39671f0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,6 +6,7 @@ environment: - PLATFORMIO_PROJECT_DIR: "examples/arduino-external-libs" - PLATFORMIO_PROJECT_DIR: "examples/arduino-internal-libs" - PLATFORMIO_PROJECT_DIR: "examples/arduino-web-thing-led" + - PLATFORMIO_PROJECT_DIR: "examples/cmsis-blink" - PLATFORMIO_PROJECT_DIR: "examples/mbed-blink" - PLATFORMIO_PROJECT_DIR: "examples/mbed-dsp" # - PLATFORMIO_PROJECT_DIR: "examples/mbed-events" From 4f8e535e14fb5bbc6aaf62f14fc5d217bfd836fd Mon Sep 17 00:00:00 2001 From: Frank Leon Rose Date: Sun, 27 Oct 2019 17:25:06 -0400 Subject: [PATCH 08/14] Specify proposed CMSIS framework version by repo --- platform.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform.json b/platform.json index 5844f9a..3903190 100644 --- a/platform.json +++ b/platform.json @@ -49,7 +49,7 @@ "framework-cmsis": { "type": "framework", "optional": true, - "version": "~2.50400.191019" + "version": "https://github.com/frankleonrose/framework-cmsis" }, "framework-mbed": { "type": "framework", From cc34d9116e7e1875974eb2bb4b77a5246f41cc6f Mon Sep 17 00:00:00 2001 From: Frank Leon Rose Date: Mon, 28 Oct 2019 14:27:37 -0400 Subject: [PATCH 09/14] Replace verbose VARIANT_DIRS with terse MCU_FAMILY_SELECTORS --- builder/frameworks/cmsis.py | 507 +++++++----------------------------- 1 file changed, 89 insertions(+), 418 deletions(-) diff --git a/builder/frameworks/cmsis.py b/builder/frameworks/cmsis.py index e64b685..74fe7a3 100644 --- a/builder/frameworks/cmsis.py +++ b/builder/frameworks/cmsis.py @@ -43,427 +43,98 @@ FRAMEWORK_DIR = platform.get_package_dir("framework-cmsis") assert isdir(FRAMEWORK_DIR) -VARIANT_DIRS = { - 'sam3a8c': 'sam3a', - 'sam3xa': 'sam3x', - 'sam3a4c': 'sam3a', - 'sam3n2a': 'sam3n', - 'sam3n4a': 'sam3n', - 'sam3n00a': 'sam3n', - 'sam3n0b': 'sam3n', - 'sam3n0c': 'sam3n', - 'sam3n1b': 'sam3n', - 'sam3n1c': 'sam3n', - 'sam3n00b': 'sam3n', - 'sam3n0a': 'sam3n', - 'sam3n4b': 'sam3n', - 'sam3n4c': 'sam3n', - 'sam3n2b': 'sam3n', - 'sam3n2c': 'sam3n', - 'sam3n1a': 'sam3n', - 'sam3n': 'sam3n', - 'sam3s8c': 'sam3sd8', - 'sam3s8b': 'sam3sd8', - 'sam3sd8c': 'sam3sd8', - 'sam3sd8b': 'sam3sd8', - 'sam3sd8': 'sam3sd8', - 'sam3s1a': 'sam3s', - 'sam3s2b': 'sam3s', - 'sam3s2c': 'sam3s', - 'sam3s': 'sam3s', - 'sam3s4b': 'sam3s', - 'sam3s4c': 'sam3s', - 'sam3s1b': 'sam3s', - 'sam3s1c': 'sam3s', - 'sam3s4a': 'sam3s', - 'sam3s2a': 'sam3s', - 'sam3u': 'sam3u', - 'sam3u1e': 'sam3u', - 'sam3u1c': 'sam3u', - 'sam3u2c': 'sam3u', - 'sam3u4c': 'sam3u', - 'sam3u4e': 'sam3u', - 'sam3u2e': 'sam3u', - 'sam3x8e': 'sam3x', - 'sam3x4c': 'sam3x', - 'sam3x4e': 'sam3x', - 'sam3x8c': 'sam3x', - 'sam3x8h': 'sam3x', - 'sam4cms32c_0': 'sam4cm32', - 'sam4cms32c_1': 'sam4cm32', - 'sam4cmp32c_0': 'sam4cm32', - 'sam4cmp32c_1': 'sam4cm32', - 'sam4cm': 'sam4cm', - 'sam4c8c_1': 'sam4c', - 'sam4c8c_0': 'sam4c', - 'sam4c4c_0': 'sam4c', - 'sam4c4c_1': 'sam4c', - 'sam4c16c_1': 'sam4c', - 'sam4c16c_0': 'sam4c', - 'sam4c': 'sam4c', - 'sam4cmp16c_1': 'sam4cm', - 'sam4cmp16c_0': 'sam4cm', - 'sam4cmp8c_1': 'sam4cm', - 'sam4cmp8c_0': 'sam4cm', - 'sam4cms16c_1': 'sam4cm', - 'sam4cms16c_0': 'sam4cm', - 'sam4cms4c_1': 'sam4cm', - 'sam4cms4c_0': 'sam4cm', - 'sam4cms8c_0': 'sam4cm', - 'sam4cms8c_1': 'sam4cm', - 'sam4cp16b_0': 'sam4cp', - 'sam4cp16b_1': 'sam4cp', - 'sam4cp16c_1': 'sam4cp', - 'sam4cp16c_0': 'sam4cp', - 'sam4cp': 'sam4cp', - 'sam4c32c_0': 'sam4c32', - 'sam4c32c_1': 'sam4c32', - 'sam4c32e_0': 'sam4c32', - 'sam4c32e_1': 'sam4c32', - 'sam4c32': 'sam4c32', - 'sam4e': 'sam4e', - 'sam4e8cb': 'sam4ecb', - 'sam4e16cb': 'sam4ecb', - 'sam4e8e': 'sam4e', - 'sam4e16e': 'sam4e', - 'sam4e16c': 'sam4e', - 'sam4e8c': 'sam4e', - 'sam4ls4c': 'sam4l4', - 'sam4ls4b': 'sam4l4', - 'sam4ls2c': 'sam4l4', - 'sam4ls2b': 'sam4l4', - 'sam4lc4a': 'sam4l4', - 'sam4lc2a': 'sam4l4', - 'sam4ls2a': 'sam4l4', - 'sam4ls4a': 'sam4l4', - 'sam4lc2c': 'sam4l4', - 'sam4lc2b': 'sam4l4', - 'sam4lc4c': 'sam4l4', - 'sam4lc4b': 'sam4l4', - 'sam4lc8a': 'sam4l8', - 'sam4ls8b': 'sam4l8', - 'sam4ls8c': 'sam4l8', - 'sam4lc8b': 'sam4l8', - 'sam4lc8c': 'sam4l8', - 'sam4ls8a': 'sam4l8', - 'sam4n16c': 'sam4n', - 'sam4n16b': 'sam4n', - 'sam4n8b': 'sam4n', - 'sam4n8c': 'sam4n', - 'sam4n': 'sam4n', - 'sam4n8a': 'sam4n', - 'sam4sp': 'sam4sp', - 'sam4sp32a': 'sam4sp', - 'sam4s': 'sam4s', - 'sam4sd16b': 'sam4s', - 'sam4sd16c': 'sam4s', - 'sam4s2a': 'sam4s', - 'sam4sa16b': 'sam4s', - 'sam4sa16c': 'sam4s', - 'sam4s4a': 'sam4s', - 'sam4s4c': 'sam4s', - 'sam4s4b': 'sam4s', - 'sam4s2c': 'sam4s', - 'sam4s2b': 'sam4s', - 'sam4s16b': 'sam4s', - 'sam4s16c': 'sam4s', - 'sam4s8b': 'sam4s', - 'sam4s8c': 'sam4s', - 'sam4sd32c': 'sam4s', - 'sam4sd32b': 'sam4s', - 'samb11': 'samb11', - 'samc20e18a': 'samc20', - 'samc20e15a': 'samc20', - 'samc20g16a': 'samc20', - 'samc20j17au': 'samc20', - 'samc20j15a': 'samc20', - 'samc20j18a': 'samc20', - 'samc20g17a': 'samc20', - 'samc20j18au': 'samc20', - 'samc20j16a': 'samc20', - 'samc20e17a': 'samc20', - 'samc20j17a': 'samc20', - 'samc20g18a': 'samc20', - 'samc20g15a': 'samc20', - 'samc20e16a': 'samc20', - 'samc20n17a': 'samc20n', - 'samc20n18a': 'samc20n', - 'samc21n17a': 'samc21n', - 'samc21n18a': 'samc21n', - 'samc21e18a': 'samc21', - 'samc21g16a': 'samc21', - 'samc21e15a': 'samc21', - 'samc21j15a': 'samc21', - 'samc21j18a': 'samc21', - 'samc21g17a': 'samc21', - 'samc21j18au': 'samc21', - 'samc21j16a': 'samc21', - 'samc21e17a': 'samc21', - 'samc21j17au': 'samc21', - 'samc21j17a': 'samc21', - 'samc21g18a': 'samc21', - 'samc21e16a': 'samc21', - 'samc21g15a': 'samc21', - 'samd09c13a': 'samd09', - 'samd09d14a': 'samd09', - 'samd10d13as': 'samd10', - 'samd10d14au': 'samd10', - 'samd10d13am': 'samd10', - 'samd10c14a': 'samd10', - 'samd10d14am': 'samd10', - 'samd10c13a': 'samd10', - 'samd10d14as': 'samd10', - 'samd11c14a': 'samd11', - 'samd11d14as': 'samd11', - 'samd11d14am': 'samd11', - 'samd11d14au': 'samd11', - 'samd20g17': 'samd20', - 'samd20g16': 'samd20', - 'samd20j17': 'samd20', - 'samd20j16': 'samd20', - 'samd20e16': 'samd20', - 'samd20e17': 'samd20', - 'samd20g17u': 'samd20', - 'samd20e18': 'samd20', - 'samd20j14': 'samd20', - 'samd20j15': 'samd20', - 'samd20g14': 'samd20', - 'samd20g15': 'samd20', - 'samd20g18': 'samd20', - 'samd20j18': 'samd20', - 'samd20g18u': 'samd20', - 'samd20e15': 'samd20', - 'samd20e14': 'samd20', - 'samd20j16b': 'samd20b', - 'samd20g14b': 'samd20b', - 'samd20g15b': 'samd20b', - 'samd20e16b': 'samd20b', - 'samd20j14b': 'samd20b', - 'samd20e15b': 'samd20b', - 'samd20g16b': 'samd20b', - 'samd20j15b': 'samd20b', - 'samd20e14b': 'samd20b', - 'samd21e16bu': 'samd21b', - 'samd21e15bu': 'samd21b', - 'samd21g17l': 'samd21d', - 'samd21j17d': 'samd21d', - 'samd21e17d': 'samd21d', - 'samd21e17du': 'samd21d', - 'samd21g17d': 'samd21d', - 'samd21e17l': 'samd21d', - 'samd21j16b': 'samd21c', - 'samd21g16l': 'samd21c', - 'samd21e16b': 'samd21c', - 'samd21g15b': 'samd21c', - 'samd21e16cu': 'samd21c', - 'samd21e15l': 'samd21c', - 'samd21g16b': 'samd21c', - 'samd21e16l': 'samd21c', - 'samd21g15l': 'samd21c', - 'samd21e15b': 'samd21c', - 'samd21e15cu': 'samd21c', - 'samd21j15b': 'samd21c', - 'samd21g16a': 'samd21a', - 'samd21e15a': 'samd21a', - 'samd21e18a': 'samd21a', - 'samd21j18a': 'samd21a', - 'samd21g17a': 'samd21a', - 'samd21j15a': 'samd21a', - 'samd21g17au': 'samd21a', - 'samd21e17a': 'samd21a', - 'samd21j16a': 'samd21a', - 'samd21g18au': 'samd21a', - 'samd21e16a': 'samd21a', - 'samd21g15a': 'samd21a', - 'samd21j17a': 'samd21a', - 'samd21g18a': 'samd21a', - 'samd51j19a': 'samd51a', - 'samd51p19a': 'samd51a', - 'samd51j20a': 'samd51a', - 'samd51j18a': 'samd51a', - 'samd51p20a': 'samd51a', - 'samd51g19a': 'samd51a', - 'samd51n19a': 'samd51a', - 'samd51g18a': 'samd51a', - 'samd51n20a': 'samd51a', - 'samda1j14b': 'samda1b', - 'samda1e15b': 'samda1b', - 'samda1g16b': 'samda1b', - 'samda1j15b': 'samda1b', - 'samda1e14b': 'samda1b', - 'samda1j16b': 'samda1b', - 'samda1g14b': 'samda1b', - 'samda1g15b': 'samda1b', - 'samda1e16b': 'samda1b', - 'samda1g14a': 'samda1', - 'samda1j16a': 'samda1', - 'samda1g15a': 'samda1', - 'samda1e16a': 'samda1', - 'samda1e15a': 'samda1', - 'samda1g16a': 'samda1', - 'samda1j14a': 'samda1', - 'samda1e14a': 'samda1', - 'samda1j15a': 'samda1', - 'same51j19a': 'same51', - 'same51j18a': 'same51', - 'same51j20a': 'same51', - 'same51n19a': 'same51', - 'same51n20a': 'same51', - 'same53n20a': 'same53', - 'same53n19a': 'same53', - 'same53j18a': 'same53', - 'same53j20a': 'same53', - 'same53j19a': 'same53', - 'same54n20a': 'same54', - 'same54n19a': 'same54', - 'same54p20a': 'same54', - 'same54p19a': 'same54', - 'same70j20b': 'same70b', - 'same70j19b': 'same70b', - 'same70j21b': 'same70b', - 'same70n20b': 'same70b', - 'same70q20b': 'same70b', - 'same70q19b': 'same70b', - 'same70n19b': 'same70b', - 'same70n21b': 'same70b', - 'same70q21b': 'same70b', - 'same70n21': 'same70a', - 'same70n20': 'same70a', - 'same70n19': 'same70a', - 'same70q20': 'same70a', - 'same70q21': 'same70a', - 'same70j20': 'same70a', - 'same70j21': 'same70a', - 'same70j19': 'same70a', - 'same70q19': 'same70a', - 'samg51g18': 'samg51', - 'samg51n18': 'samg51', - 'samg55g19': 'samg55', - 'samg55j19': 'samg55', - 'samg53n19': 'samg53', - 'samg53g19': 'samg53', - 'samg54j19': 'samg54', - 'samg54g19': 'samg54', - 'samg54n19': 'samg54', - 'samha1g15a': 'samha1a', - 'samha1g14a': 'samha1a', - 'samha1g16a': 'samha1a', - 'samha1e16ab': 'samha1ab', - 'samha1g15ab': 'samha1ab', - 'samha1e14ab': 'samha1ab', - 'samha1g14ab': 'samha1ab', - 'samha1g16ab': 'samha1ab', - 'samha1e15ab': 'samha1ab', - 'saml10e15a': 'saml10', - 'saml10d16a': 'saml10', - 'saml10e14a': 'saml10', - 'saml10d15a': 'saml10', - 'saml10d14a': 'saml10', - 'saml10e16a': 'saml10', - 'saml11e15a': 'saml11', - 'saml11e14a': 'saml11', - 'saml11d16a': 'saml11', - 'saml11d15a': 'saml11', - 'saml11e16a': 'saml11', - 'saml11d14a': 'saml11', - 'saml21e18a': 'saml21a1', - 'saml21j18a': 'saml21a1', - 'saml21g18a': 'saml21a1', - 'saml21j16b': 'saml21b', - 'saml21j17bu': 'saml21b', - 'saml21e17b': 'saml21b', - 'saml21g18b': 'saml21b', - 'saml21j17b': 'saml21b', - 'saml21e16b': 'saml21b', - 'saml21j18bu': 'saml21b', - 'saml21e18b': 'saml21b', - 'saml21e15b': 'saml21b', - 'saml21g16b': 'saml21b', - 'saml21g17b': 'saml21b', - 'saml21j18b': 'saml21b', - 'saml22n18a': 'saml22', - 'saml22j17a': 'saml22', - 'saml22g18a': 'saml22', - 'saml22j16a': 'saml22', - 'saml22j18a': 'saml22', - 'saml22g17a': 'saml22', - 'saml22n17a': 'saml22', - 'saml22g16a': 'saml22', - 'saml22n16a': 'saml22', - 'samr21e17a': 'samr21', - 'samr21e16a': 'samr21', - 'samr21g18a': 'samr21', - 'samr21g16a': 'samr21', - 'samr21e18a': 'samr21', - 'samr21g17a': 'samr21', - 'samr21e19a': 'samr21', - 'samr30e18a': 'samr30', - 'samr30g18a': 'samr30', - 'samr34j18b': 'samr34', - 'samr34j16b': 'samr34', - 'samr34j17b': 'samr34', - 'samr35j18b': 'samr35', - 'samr35j16b': 'samr35', - 'samr35j17b': 'samr35', - 'sams70n20b': 'sams70b', - 'sams70q20b': 'sams70b', - 'sams70q19b': 'sams70b', - 'sams70n19b': 'sams70b', - 'sams70n21b': 'sams70b', - 'sams70q21b': 'sams70b', - 'sams70j20b': 'sams70b', - 'sams70j19b': 'sams70b', - 'sams70j21b': 'sams70b', - 'sams70n21': 'sams70a', - 'sams70n20': 'sams70a', - 'sams70n19': 'sams70a', - 'sams70j20': 'sams70a', - 'sams70j21': 'sams70a', - 'sams70q20': 'sams70a', - 'sams70q21': 'sams70a', - 'sams70q19': 'sams70a', - 'sams70j19': 'sams70a', - 'samv70q19b': 'samv70b', - 'samv70n19b': 'samv70b', - 'samv70n20b': 'samv70b', - 'samv70q20b': 'samv70b', - 'samv70j19b': 'samv70b', - 'samv70j20b': 'samv70b', - 'samv70j19': 'samv70', - 'samv70q19': 'samv70', - 'samv70q20': 'samv70', - 'samv70j20': 'samv70', - 'samv70n19': 'samv70', - 'samv70n20': 'samv70', - 'samv71n19': 'samv71', - 'samv71n20': 'samv71', - 'samv71n21': 'samv71', - 'samv71q19': 'samv71', - 'samv71j19': 'samv71', - 'samv71j21': 'samv71', - 'samv71j20': 'samv71', - 'samv71q21': 'samv71', - 'samv71q20': 'samv71', - 'samv71n19b': 'samv71b', - 'samv71q19b': 'samv71b', - 'samv71q21b': 'samv71b', - 'samv71n21b': 'samv71b', - 'samv71q20b': 'samv71b', - 'samv71n20b': 'samv71b', - 'samv71j19b': 'samv71b', - 'samv71j21b': 'samv71b', - 'samv71j20b': 'samv71b', +MCU_FAMILY_SELECTORS = { + 'sam3a': r'^sam3a.*$', + 'sam3n': r'^sam3n.*$', + 'sam3s': r'^sam3s[^8]*$', + 'sam3sd8': r'^sam3sd?[8].?$', + 'sam3x': r'^sam3x.*$', + 'sam3u': r'^sam3u.*$', + 'sam3x': r'^sam3x.*$', + 'sam4c32': r'^sam4c32.*$', + 'sam4cm32': r'^sam4cm.*32.*$', + 'sam4cm': r'^sam4cm[^3]*$', + 'sam4cp': r'^sam4cp.*$', + 'sam4c': r'^sam4c[^mp3]*$', + 'sam4e': r'^sam4e(.*[ce])?$', + 'sam4ecb': r'^sam4e\d+cb$', + 'sam4l4': r'^sam4l[cs][24][abc]$', + 'sam4l8': r'^sam4l[cs]8[abc]$', + 'sam4n': r'^sam4n.*$', + 'sam4sp': r'^sam4sp.*$', + 'sam4s': r'^sam4s[^p]*$', + 'samb11': r'^samb11$', + 'samc20': r'^samc20[^n]*$', + 'samc20n': r'^samc20n.*$', + 'samc21': r'^samc21[^n]*$', + 'samc21n': r'^samc21n.*$', + 'samd09': r'^samd09.*$', + 'samd10': r'^samd10.*$', + 'samd11': r'^samd11.*$', + 'samd20': r'^samd20[^b]*$', + 'samd21a': r'^samd21.1[5678].*au?$', + 'samd20b': r'^samd20.*b$', + 'samd21b': r'^samd21.*bu$', + 'samd21c': r'^samd21.1[56].*$', + 'samd21d': r'^samd21.17.*$', + 'samd51a': r'^samd51.*$', + 'samda1': r'^samda1.*a$', + 'samda1b': r'^samda1.*b$', + 'same51': r'^same51.*$', + 'same53': r'^same53.*$', + 'same54': r'^same54.*$', + 'same70a': r'^same70[^b]*$', + 'same70b': r'^same70.*b$', + 'samg51': r'^samg51.*$', + 'samg53': r'^samg53.*$', + 'samg54': r'^samg54.*$', + 'samg55': r'^samg55.*$', + 'samha1a': r'^samha1.*a$', + 'samha1ab': r'^samha1.*b$', + 'saml10': r'^saml10.*$', + 'saml11': r'^saml11.*$', + 'saml21a1': r'^saml21.*a$', + 'saml21b': r'^saml21.*bu?$', + 'saml22': r'^saml22.*$', + 'samr21': r'^samr21.*$', + 'samr30': r'^samr30.*$', + 'samr34': r'^samr34.*$', + 'samr35': r'^samr35.*$', + 'sams70a': r'^sams70[^b]+$', + 'sams70b': r'^sams70.*b$', + 'samv70': r'^samv70[^b]+$', + 'samv70b': r'^samv70.*b$', + 'samv71': r'^samv71[^b]+$', + 'samv71b': r'^samv71.*b$', } -def get_variant_dir(mcu): +def get_mcu_family(mcu): mcu = mcu.lower() - if mcu not in VARIANT_DIRS: - sys.stderr.write( - """Error: There is no variant dir for %s MCU! - Please add initialization code to your project manually!""" % mcu) - env.Exit(1) + for variant_family, match in MCU_FAMILY_SELECTORS.items(): + if re.match(match, mcu): + return variant_family + + return None + +# def check_variants(): +# """Ensure that map of family -> regexp (MCU_FAMILY_SELECTORS) correctly replicates +# map of mcu -> family (VARIANT_DIRS, generated by CMSIS downloader script.)""" +# for mcu, family in VARIANT_DIRS.items(): +# f = get_mcu_family(mcu) +# if family!=f: +# sys.stderr.write(f"Error: Failed to match family for: '{mcu}' -> '{f}' vs '{family}'") + +# check_variants() - return join(FRAMEWORK_DIR, "variants", PLATFORM_NAME, VARIANT_DIRS[mcu]) +def get_variant_dir(mcu): + family = get_mcu_family(mcu) + if family: + return join(FRAMEWORK_DIR, "variants", PLATFORM_NAME, family) + + sys.stderr.write( + """Error: There is no variant dir for %s MCU! + Please add initialization code to your project manually!""" % mcu) + env.Exit(1) def adjust_linker_offset(mcu, ldscript): offset_address = env.BoardConfig().get("upload.offset_address", None) @@ -514,7 +185,7 @@ def get_linker_script(mcu): # Target: Build Core Library # -# Sources because as Library the vector table doesn't get linked in. +# `BuildSources` because with `BuildLibrary` the vector table doesn't get linked in. env.BuildSources( join("$BUILD_DIR", "FrameworkCMSISVariant"), join(get_variant_dir(env.BoardConfig().get("build.mcu")), "gcc") From 40d6c6f505067ad8a7c5e14f9d1be2bc746da0e3 Mon Sep 17 00:00:00 2001 From: Frank Leon Rose Date: Mon, 28 Oct 2019 15:02:02 -0400 Subject: [PATCH 10/14] Updated framework config for all the boards that build cmsis-blink example --- boards/adafruit_crickit_m0.json | 3 +- boards/adafruit_feather_m0_express.json | 3 +- boards/adafruit_feather_m4.json | 3 +- boards/adafruit_gemma_m0.json | 3 +- boards/adafruit_grandcentral_m4.json | 3 +- boards/adafruit_hallowing.json | 3 +- boards/adafruit_hallowing_m4.json | 3 +- boards/adafruit_itsybitsy_m4.json | 3 +- boards/adafruit_metro_m0.json | 3 +- boards/adafruit_metro_m4_airliftlite.json | 3 +- boards/adafruit_monster_m4sk.json | 3 +- boards/adafruit_pirkey.json | 3 +- boards/adafruit_pybadge_airlift_m4.json | 3 +- boards/adafruit_pybadge_m4.json | 3 +- boards/adafruit_pygamer_advance_m4.json | 3 +- boards/adafruit_pygamer_m4.json | 3 +- boards/adafruit_pyportal_m4.json | 3 +- boards/adafruit_trellis_m4.json | 3 +- boards/adafruit_trinket_m0.json | 3 +- boards/current_ranger.json | 3 +- boards/minitronics20.json | 3 +- boards/mkr1000USB.json | 3 +- boards/mkrfox1200.json | 3 +- boards/mkrgsm1400.json | 3 +- boards/mkrnb1500.json | 3 +- boards/mkrvidor4000.json | 3 +- boards/mkrwan1300.json | 3 +- boards/mkrwifi1010.json | 3 +- boards/mkrzero.json | 3 +- boards/mzeroUSB.json | 3 +- boards/mzeropro.json | 3 +- boards/mzeroproUSB.json | 3 +- boards/nano_33_iot.json | 3 +- boards/seeeduino_lorawan.json | 3 +- boards/sparkfun_samd21_dev_usb.json | 3 +- boards/sparkfun_samd21_mini_usb.json | 3 +- boards/tian.json | 3 +- boards/tuinozero96.json | 3 +- boards/zero.json | 3 +- boards/zeroUSB.json | 3 +- examples/cmsis-blink/platformio.ini | 200 ++++++++++++++++++++++ 41 files changed, 280 insertions(+), 40 deletions(-) diff --git a/boards/adafruit_crickit_m0.json b/boards/adafruit_crickit_m0.json index 18b9f91..1115780 100644 --- a/boards/adafruit_crickit_m0.json +++ b/boards/adafruit_crickit_m0.json @@ -27,7 +27,8 @@ "svd_path": "ATSAMD21G18A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Adafruit Crickit M0", "upload": { diff --git a/boards/adafruit_feather_m0_express.json b/boards/adafruit_feather_m0_express.json index 545bf5a..d4bc53d 100644 --- a/boards/adafruit_feather_m0_express.json +++ b/boards/adafruit_feather_m0_express.json @@ -27,7 +27,8 @@ "svd_path": "ATSAMD21G18A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Adafruit Feather M0 Express", "upload": { diff --git a/boards/adafruit_feather_m4.json b/boards/adafruit_feather_m4.json index cdb08ba..445706f 100644 --- a/boards/adafruit_feather_m4.json +++ b/boards/adafruit_feather_m4.json @@ -41,7 +41,8 @@ "svd_path": "ATSAMD51J19A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Adafruit Feather M4 Express", "upload": { diff --git a/boards/adafruit_gemma_m0.json b/boards/adafruit_gemma_m0.json index c95e200..07da62c 100644 --- a/boards/adafruit_gemma_m0.json +++ b/boards/adafruit_gemma_m0.json @@ -27,7 +27,8 @@ "svd_path": "ATSAMD21E18A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Adafruit Gemma M0", "upload": { diff --git a/boards/adafruit_grandcentral_m4.json b/boards/adafruit_grandcentral_m4.json index 92243fb..9a6878a 100644 --- a/boards/adafruit_grandcentral_m4.json +++ b/boards/adafruit_grandcentral_m4.json @@ -37,7 +37,8 @@ "svd_path": "ATSAMD51P20A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Adafruit Grand Central M4", "upload": { diff --git a/boards/adafruit_hallowing.json b/boards/adafruit_hallowing.json index 07b4564..b64951e 100644 --- a/boards/adafruit_hallowing.json +++ b/boards/adafruit_hallowing.json @@ -27,7 +27,8 @@ "svd_path": "ATSAMD21G18A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Adafruit Hallowing M0", "upload": { diff --git a/boards/adafruit_hallowing_m4.json b/boards/adafruit_hallowing_m4.json index ee502f2..5c0c768 100644 --- a/boards/adafruit_hallowing_m4.json +++ b/boards/adafruit_hallowing_m4.json @@ -42,7 +42,8 @@ "svd_path": "ATSAMD51J19A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Adafruit Hallowing M4", "upload": { diff --git a/boards/adafruit_itsybitsy_m4.json b/boards/adafruit_itsybitsy_m4.json index a87304b..b7ed218 100644 --- a/boards/adafruit_itsybitsy_m4.json +++ b/boards/adafruit_itsybitsy_m4.json @@ -38,7 +38,8 @@ "svd_path": "ATSAMD51G19A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Adafruit ItsyBitsy M4", "upload": { diff --git a/boards/adafruit_metro_m0.json b/boards/adafruit_metro_m0.json index 03cc2cc..9378cd9 100644 --- a/boards/adafruit_metro_m0.json +++ b/boards/adafruit_metro_m0.json @@ -27,7 +27,8 @@ "svd_path": "ATSAMD21G18A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Adafruit Metro M0 Expresss", "upload": { diff --git a/boards/adafruit_metro_m4_airliftlite.json b/boards/adafruit_metro_m4_airliftlite.json index 3eb9c49..580e140 100644 --- a/boards/adafruit_metro_m4_airliftlite.json +++ b/boards/adafruit_metro_m4_airliftlite.json @@ -37,7 +37,8 @@ "svd_path": "ATSAMD51J19A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Adafruit Metro M4 AirLift Lite", "upload": { diff --git a/boards/adafruit_monster_m4sk.json b/boards/adafruit_monster_m4sk.json index 271f404..4fdb618 100644 --- a/boards/adafruit_monster_m4sk.json +++ b/boards/adafruit_monster_m4sk.json @@ -42,7 +42,8 @@ "svd_path": "ATSAMD51J19A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Adafruit MONSTER M4SK", "upload": { diff --git a/boards/adafruit_pirkey.json b/boards/adafruit_pirkey.json index add885d..31a6bad 100644 --- a/boards/adafruit_pirkey.json +++ b/boards/adafruit_pirkey.json @@ -27,7 +27,8 @@ "svd_path": "ATSAMD21E18A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Adafruit pIRkey", "upload": { diff --git a/boards/adafruit_pybadge_airlift_m4.json b/boards/adafruit_pybadge_airlift_m4.json index 3c4de90..56a0351 100644 --- a/boards/adafruit_pybadge_airlift_m4.json +++ b/boards/adafruit_pybadge_airlift_m4.json @@ -38,7 +38,8 @@ "svd_path": "ATSAMD51J20A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Adafruit pyBadge AirLift M4", "upload": { diff --git a/boards/adafruit_pybadge_m4.json b/boards/adafruit_pybadge_m4.json index c966b90..e3629b2 100644 --- a/boards/adafruit_pybadge_m4.json +++ b/boards/adafruit_pybadge_m4.json @@ -38,7 +38,8 @@ "svd_path": "ATSAMD51J19A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Adafruit pyBadge M4 Express", "upload": { diff --git a/boards/adafruit_pygamer_advance_m4.json b/boards/adafruit_pygamer_advance_m4.json index d16ed9f..8092bdc 100644 --- a/boards/adafruit_pygamer_advance_m4.json +++ b/boards/adafruit_pygamer_advance_m4.json @@ -38,7 +38,8 @@ "svd_path": "ATSAMD51J20A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Adafruit PyGamer Advance M4", "upload": { diff --git a/boards/adafruit_pygamer_m4.json b/boards/adafruit_pygamer_m4.json index 63a3bd9..50c2e14 100644 --- a/boards/adafruit_pygamer_m4.json +++ b/boards/adafruit_pygamer_m4.json @@ -38,7 +38,8 @@ "svd_path": "ATSAMD51J19A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Adafruit PyGamer M4 Express", "upload": { diff --git a/boards/adafruit_pyportal_m4.json b/boards/adafruit_pyportal_m4.json index e32fa94..a0b8b02 100644 --- a/boards/adafruit_pyportal_m4.json +++ b/boards/adafruit_pyportal_m4.json @@ -38,7 +38,8 @@ "svd_path": "ATSAMD51J20A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Adafruit PyPortal M4", "upload": { diff --git a/boards/adafruit_trellis_m4.json b/boards/adafruit_trellis_m4.json index 4a63158..1ff20f3 100644 --- a/boards/adafruit_trellis_m4.json +++ b/boards/adafruit_trellis_m4.json @@ -37,7 +37,8 @@ "svd_path": "ATSAMD51J19A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Adafruit Trellis M4", "upload": { diff --git a/boards/adafruit_trinket_m0.json b/boards/adafruit_trinket_m0.json index 64187f8..949fcf4 100644 --- a/boards/adafruit_trinket_m0.json +++ b/boards/adafruit_trinket_m0.json @@ -27,7 +27,8 @@ "svd_path": "ATSAMD21E18A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Adafruit Trinket M0", "upload": { diff --git a/boards/current_ranger.json b/boards/current_ranger.json index fb9fbcd..6106cc8 100644 --- a/boards/current_ranger.json +++ b/boards/current_ranger.json @@ -20,7 +20,8 @@ "variant": "current_ranger" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "LowPowerLab CurrentRanger", "upload": { diff --git a/boards/minitronics20.json b/boards/minitronics20.json index 0754181..94efd38 100644 --- a/boards/minitronics20.json +++ b/boards/minitronics20.json @@ -26,7 +26,8 @@ "svd_path": "ATSAMD21J18A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Minitronics v2.0", "upload": { diff --git a/boards/mkr1000USB.json b/boards/mkr1000USB.json index 4dfeeaf..cc832f9 100644 --- a/boards/mkr1000USB.json +++ b/boards/mkr1000USB.json @@ -37,7 +37,8 @@ "svd_path": "ATSAMD21G18A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Arduino MKR1000", "upload": { diff --git a/boards/mkrfox1200.json b/boards/mkrfox1200.json index 865e355..097d56a 100644 --- a/boards/mkrfox1200.json +++ b/boards/mkrfox1200.json @@ -26,7 +26,8 @@ "svd_path": "ATSAMD21G18A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Arduino MKR FOX 1200", "upload": { diff --git a/boards/mkrgsm1400.json b/boards/mkrgsm1400.json index 4d790c7..7aab453 100644 --- a/boards/mkrgsm1400.json +++ b/boards/mkrgsm1400.json @@ -26,7 +26,8 @@ "svd_path": "ATSAMD21G18A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Arduino MKR GSM 1400", "upload": { diff --git a/boards/mkrnb1500.json b/boards/mkrnb1500.json index 3bc7885..9fb4cf8 100644 --- a/boards/mkrnb1500.json +++ b/boards/mkrnb1500.json @@ -26,7 +26,8 @@ "svd_path": "ATSAMD21G18A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Arduino MKR NB 1500", "upload": { diff --git a/boards/mkrvidor4000.json b/boards/mkrvidor4000.json index 6263e1a..c19f450 100644 --- a/boards/mkrvidor4000.json +++ b/boards/mkrvidor4000.json @@ -26,7 +26,8 @@ "svd_path": "ATSAMD21G18A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "MKR Vidor 4000", "upload": { diff --git a/boards/mkrwan1300.json b/boards/mkrwan1300.json index 6cea487..4c1c77f 100644 --- a/boards/mkrwan1300.json +++ b/boards/mkrwan1300.json @@ -26,7 +26,8 @@ "svd_path": "ATSAMD21G18A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Arduino MKR WAN 1300", "upload": { diff --git a/boards/mkrwifi1010.json b/boards/mkrwifi1010.json index 8ee4711..f71af36 100644 --- a/boards/mkrwifi1010.json +++ b/boards/mkrwifi1010.json @@ -26,7 +26,8 @@ "svd_path": "ATSAMD21G18A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Arduino MKR WiFi 1010", "upload": { diff --git a/boards/mkrzero.json b/boards/mkrzero.json index 1558e85..14c0f1b 100644 --- a/boards/mkrzero.json +++ b/boards/mkrzero.json @@ -26,7 +26,8 @@ "svd_path": "ATSAMD21G18A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Arduino MKRZERO", "upload": { diff --git a/boards/mzeroUSB.json b/boards/mzeroUSB.json index b92efef..86f7a90 100644 --- a/boards/mzeroUSB.json +++ b/boards/mzeroUSB.json @@ -26,7 +26,8 @@ "svd_path": "ATSAMD21G18A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Arduino M0", "upload": { diff --git a/boards/mzeropro.json b/boards/mzeropro.json index 99cac00..d888b5a 100644 --- a/boards/mzeropro.json +++ b/boards/mzeropro.json @@ -29,7 +29,8 @@ "svd_path": "ATSAMD21G18A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Arduino M0 Pro (Programming/Debug Port)", "upload": { diff --git a/boards/mzeroproUSB.json b/boards/mzeroproUSB.json index 93841df..3066bc1 100644 --- a/boards/mzeroproUSB.json +++ b/boards/mzeroproUSB.json @@ -37,7 +37,8 @@ "svd_path": "ATSAMD21G18A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Arduino M0 Pro (Native USB Port)", "upload": { diff --git a/boards/nano_33_iot.json b/boards/nano_33_iot.json index d43429c..a6c2ed9 100644 --- a/boards/nano_33_iot.json +++ b/boards/nano_33_iot.json @@ -26,7 +26,8 @@ "svd_path": "ATSAMD21G18A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "NANO 33 IoT", "upload": { diff --git a/boards/seeeduino_lorawan.json b/boards/seeeduino_lorawan.json index d8ccd9e..14bbf77 100644 --- a/boards/seeeduino_lorawan.json +++ b/boards/seeeduino_lorawan.json @@ -30,7 +30,8 @@ "svd_path": "ATSAMD21G18A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Seeeduino LoRaWAN", "upload": { diff --git a/boards/sparkfun_samd21_dev_usb.json b/boards/sparkfun_samd21_dev_usb.json index a921732..2807570 100644 --- a/boards/sparkfun_samd21_dev_usb.json +++ b/boards/sparkfun_samd21_dev_usb.json @@ -26,7 +26,8 @@ "svd_path": "ATSAMD21G18A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "SparkFun SAMD21 Dev Breakout", "upload": { diff --git a/boards/sparkfun_samd21_mini_usb.json b/boards/sparkfun_samd21_mini_usb.json index ad88154..e8aa3db 100644 --- a/boards/sparkfun_samd21_mini_usb.json +++ b/boards/sparkfun_samd21_mini_usb.json @@ -26,7 +26,8 @@ "svd_path": "ATSAMD21G18A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "SparkFun SAMD21 Mini Breakout", "upload": { diff --git a/boards/tian.json b/boards/tian.json index 7b62748..f360664 100644 --- a/boards/tian.json +++ b/boards/tian.json @@ -29,7 +29,8 @@ "svd_path": "ATSAMD21G18A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Arduino Tian", "upload": { diff --git a/boards/tuinozero96.json b/boards/tuinozero96.json index c1668c2..a628462 100644 --- a/boards/tuinozero96.json +++ b/boards/tuinozero96.json @@ -26,7 +26,8 @@ "svd_path": "ATSAMD21G18A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Tuino 096", "upload": { diff --git a/boards/zero.json b/boards/zero.json index 1ea9d2e..51054f7 100644 --- a/boards/zero.json +++ b/boards/zero.json @@ -29,7 +29,8 @@ "svd_path": "ATSAMD21G18A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Arduino Zero (Programming/Debug Port)", "upload": { diff --git a/boards/zeroUSB.json b/boards/zeroUSB.json index 560f34b..ca29134 100644 --- a/boards/zeroUSB.json +++ b/boards/zeroUSB.json @@ -33,7 +33,8 @@ "svd_path": "ATSAMD21G18A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Arduino Zero (USB Native Port)", "upload": { diff --git a/examples/cmsis-blink/platformio.ini b/examples/cmsis-blink/platformio.ini index 872a10a..f49409b 100644 --- a/examples/cmsis-blink/platformio.ini +++ b/examples/cmsis-blink/platformio.ini @@ -3,23 +3,223 @@ platform = atmelsam framework = cmsis board = adafruit_circuitplayground_m0 +[env:adafruit_crickit_m0] +platform = atmelsam +framework = cmsis +board = adafruit_crickit_m0 + [env:adafruit_feather_m0] platform = atmelsam framework = cmsis board = adafruit_feather_m0 +[env:adafruit_feather_m0_express] +platform = atmelsam +framework = cmsis +board = adafruit_feather_m0_express + +[env:adafruit_feather_m4] +platform = atmelsam +framework = cmsis +board = adafruit_feather_m4 + +[env:adafruit_gemma_m0] +platform = atmelsam +framework = cmsis +board = adafruit_gemma_m0 + +[env:adafruit_grandcentral_m4] +platform = atmelsam +framework = cmsis +board = adafruit_grandcentral_m4 + +[env:adafruit_hallowing] +platform = atmelsam +framework = cmsis +board = adafruit_hallowing + +[env:adafruit_hallowing_m4] +platform = atmelsam +framework = cmsis +board = adafruit_hallowing_m4 + [env:adafruit_itsybitsy_m0] platform = atmelsam framework = cmsis board = adafruit_itsybitsy_m0 +[env:adafruit_itsybitsy_m4] +platform = atmelsam +framework = cmsis +board = adafruit_itsybitsy_m4 + +[env:adafruit_metro_m0] +platform = atmelsam +framework = cmsis +board = adafruit_metro_m0 + [env:adafruit_metro_m4] platform = atmelsam framework = cmsis board = adafruit_metro_m4 +[env:adafruit_metro_m4_airliftlite] +platform = atmelsam +framework = cmsis +board = adafruit_metro_m4_airliftlite + +[env:adafruit_monster_m4sk] +platform = atmelsam +framework = cmsis +board = adafruit_monster_m4sk + +[env:adafruit_pirkey] +platform = atmelsam +framework = cmsis +board = adafruit_pirkey + +[env:adafruit_pybadge_airlift_m4] +platform = atmelsam +framework = cmsis +board = adafruit_pybadge_airlift_m4 + +[env:adafruit_pybadge_m4] +platform = atmelsam +framework = cmsis +board = adafruit_pybadge_m4 + +[env:adafruit_pygamer_advance_m4] +platform = atmelsam +framework = cmsis +board = adafruit_pygamer_advance_m4 + +[env:adafruit_pygamer_m4] +platform = atmelsam +framework = cmsis +board = adafruit_pygamer_m4 + +[env:adafruit_pyportal_m4] +platform = atmelsam +framework = cmsis +board = adafruit_pyportal_m4 + +[env:adafruit_trellis_m4] +platform = atmelsam +framework = cmsis +board = adafruit_trellis_m4 + +[env:adafruit_trinket_m0] +platform = atmelsam +framework = cmsis +board = adafruit_trinket_m0 + +[env:current_ranger] +platform = atmelsam +framework = cmsis +board = current_ranger + +[env:minitronics20] +platform = atmelsam +framework = cmsis +board = minitronics20 + +[env:mkr1000USB] +platform = atmelsam +framework = cmsis +board = mkr1000USB + +[env:mkrfox1200] +platform = atmelsam +framework = cmsis +board = mkrfox1200 + +[env:mkrgsm1400] +platform = atmelsam +framework = cmsis +board = mkrgsm1400 + +[env:mkrnb1500] +platform = atmelsam +framework = cmsis +board = mkrnb1500 + +[env:mkrvidor4000] +platform = atmelsam +framework = cmsis +board = mkrvidor4000 + +[env:mkrwan1300] +platform = atmelsam +framework = cmsis +board = mkrwan1300 + +[env:mkrwifi1010] +platform = atmelsam +framework = cmsis +board = mkrwifi1010 + +[env:mkrzero] +platform = atmelsam +framework = cmsis +board = mkrzero + [env:moteino_zero] platform = atmelsam framework = cmsis board = moteino_zero +[env:mzeroUSB] +platform = atmelsam +framework = cmsis +board = mzeroUSB + +[env:mzeropro] +platform = atmelsam +framework = cmsis +board = mzeropro + +[env:mzeroproUSB] +platform = atmelsam +framework = cmsis +board = mzeroproUSB + +[env:nano_33_iot] +platform = atmelsam +framework = cmsis +board = nano_33_iot + +[env:seeeduino_lorawan] +platform = atmelsam +framework = cmsis +board = seeeduino_lorawan + +[env:sparkfun_samd21_dev_usb] +platform = atmelsam +framework = cmsis +board = sparkfun_samd21_dev_usb + +[env:sparkfun_samd21_mini_usb] +platform = atmelsam +framework = cmsis +board = sparkfun_samd21_mini_usb + +[env:tian] +platform = atmelsam +framework = cmsis +board = tian + +[env:tuinozero96] +platform = atmelsam +framework = cmsis +board = tuinozero96 + +[env:zero] +platform = atmelsam +framework = cmsis +board = zero + +[env:zeroUSB] +platform = atmelsam +framework = cmsis +board = zeroUSB + From 93f5c5195966755ace7300ec9d866506f7f16073 Mon Sep 17 00:00:00 2001 From: Frank Leon Rose Date: Mon, 28 Oct 2019 15:27:28 -0400 Subject: [PATCH 11/14] Build boards requiring ldscripts in LIBPATH, without offset_address, and `at91sam3x...` --- boards/digix.json | 3 +- boards/due.json | 1 + boards/dueUSB.json | 1 + boards/macchina2.json | 3 +- boards/sainSmartDue.json | 3 +- boards/sainSmartDueUSB.json | 3 +- boards/samd21g18a.json | 1 + boards/sodaq_autonomo.json | 3 +- boards/sodaq_explorer.json | 3 +- boards/sodaq_one.json | 3 +- boards/sodaq_sara.json | 3 +- boards/sodaq_sff.json | 3 +- builder/frameworks/cmsis.py | 21 ++++++---- examples/cmsis-blink/platformio.ini | 60 +++++++++++++++++++++++++++++ examples/cmsis-blink/src/main.cpp | 11 +++++- 15 files changed, 105 insertions(+), 17 deletions(-) diff --git a/boards/digix.json b/boards/digix.json index 32001a5..6540d76 100644 --- a/boards/digix.json +++ b/boards/digix.json @@ -25,7 +25,8 @@ "svd_path": "ATSAM3X8E.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Digistump DigiX", "upload": { diff --git a/boards/due.json b/boards/due.json index 21dfdce..4bc2609 100644 --- a/boards/due.json +++ b/boards/due.json @@ -34,6 +34,7 @@ }, "frameworks": [ "arduino", + "cmsis", "simba" ], "name": "Arduino Due (Programming Port)", diff --git a/boards/dueUSB.json b/boards/dueUSB.json index 4bc399e..890a4b6 100644 --- a/boards/dueUSB.json +++ b/boards/dueUSB.json @@ -30,6 +30,7 @@ }, "frameworks": [ "arduino", + "cmsis", "simba" ], "name": "Arduino Due (USB Native Port)", diff --git a/boards/macchina2.json b/boards/macchina2.json index e99c67e..049e665 100644 --- a/boards/macchina2.json +++ b/boards/macchina2.json @@ -29,7 +29,8 @@ "svd_path": "ATSAM3X8E.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "Macchina M2", "upload": { diff --git a/boards/sainSmartDue.json b/boards/sainSmartDue.json index b309cfa..2f9b5f1 100644 --- a/boards/sainSmartDue.json +++ b/boards/sainSmartDue.json @@ -25,7 +25,8 @@ "svd_path": "ATSAM3X8E.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "SainSmart Due (Programming Port)", "upload": { diff --git a/boards/sainSmartDueUSB.json b/boards/sainSmartDueUSB.json index 61c6e8c..36a608d 100644 --- a/boards/sainSmartDueUSB.json +++ b/boards/sainSmartDueUSB.json @@ -25,7 +25,8 @@ "svd_path": "ATSAM3X8E.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "SainSmart Due (USB Native Port)", "upload": { diff --git a/boards/samd21g18a.json b/boards/samd21g18a.json index 01541d2..2959d47 100644 --- a/boards/samd21g18a.json +++ b/boards/samd21g18a.json @@ -29,6 +29,7 @@ }, "frameworks": [ "arduino", + "cmsis", "mbed" ], "name": "Atmel ATSAMW25-XPRO", diff --git a/boards/sodaq_autonomo.json b/boards/sodaq_autonomo.json index dfc8cda..9e64a39 100644 --- a/boards/sodaq_autonomo.json +++ b/boards/sodaq_autonomo.json @@ -27,7 +27,8 @@ "svd_path": "ATSAMD21J18A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "SODAQ Autonomo", "upload": { diff --git a/boards/sodaq_explorer.json b/boards/sodaq_explorer.json index 1e73927..c048a84 100644 --- a/boards/sodaq_explorer.json +++ b/boards/sodaq_explorer.json @@ -31,7 +31,8 @@ "svd_path": "ATSAMD21J18A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "SODAQ ExpLoRer", "upload": { diff --git a/boards/sodaq_one.json b/boards/sodaq_one.json index 8678dce..acad7d3 100644 --- a/boards/sodaq_one.json +++ b/boards/sodaq_one.json @@ -31,7 +31,8 @@ "svd_path": "ATSAMD21G18A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "SODAQ ONE", "upload": { diff --git a/boards/sodaq_sara.json b/boards/sodaq_sara.json index 8fb739b..cbf3690 100644 --- a/boards/sodaq_sara.json +++ b/boards/sodaq_sara.json @@ -31,7 +31,8 @@ "svd_path": "ATSAMD21J18A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "SODAQ SARA", "upload": { diff --git a/boards/sodaq_sff.json b/boards/sodaq_sff.json index c7d405d..ce46e85 100644 --- a/boards/sodaq_sff.json +++ b/boards/sodaq_sff.json @@ -31,7 +31,8 @@ "svd_path": "ATSAMD21G18A.svd" }, "frameworks": [ - "arduino" + "arduino", + "cmsis" ], "name": "SODAQ SFF", "upload": { diff --git a/builder/frameworks/cmsis.py b/builder/frameworks/cmsis.py index 74fe7a3..33ccbcd 100644 --- a/builder/frameworks/cmsis.py +++ b/builder/frameworks/cmsis.py @@ -50,7 +50,7 @@ 'sam3sd8': r'^sam3sd?[8].?$', 'sam3x': r'^sam3x.*$', 'sam3u': r'^sam3u.*$', - 'sam3x': r'^sam3x.*$', + 'sam3x': r'^(at91)?sam3x.*$', 'sam4c32': r'^sam4c32.*$', 'sam4cm32': r'^sam4cm.*32.*$', 'sam4cm': r'^sam4cm[^3]*$', @@ -136,9 +136,9 @@ def get_variant_dir(mcu): Please add initialization code to your project manually!""" % mcu) env.Exit(1) -def adjust_linker_offset(mcu, ldscript): - offset_address = env.BoardConfig().get("upload.offset_address", None) - if offset_address is None or int(offset_address, 0)==0: +def adjust_linker_offset(script_name, ldscript): + offset_address = env.BoardConfig().get("upload.offset_address", "0") + if int(offset_address, 0)==0: return ldscript content = "" @@ -153,19 +153,23 @@ def adjust_linker_offset(mcu, ldscript): # offset_script = join("$BUILD_DIR", basename(ldscript)) offset_script = join(FRAMEWORK_DIR, "platformio", "ldscripts", PLATFORM_NAME, - "%s_flash_%s.ld" % (mcu, offset_address)) + "%s_flash_%s.ld" % (script_name, offset_address)) with open(offset_script, "w") as fp: fp.write(content) return offset_script +def remove_prefix(s, prefix): + return s[len(prefix):] if s.startswith(prefix) else s + def get_linker_script(mcu): + script_name = remove_prefix(mcu.lower(), 'at91') ldscript = join(FRAMEWORK_DIR, "platformio", "ldscripts", PLATFORM_NAME, - mcu.lower() + "_flash.ld") + script_name + "_flash.ld") if isfile(ldscript): - return adjust_linker_offset(mcu, ldscript) + return adjust_linker_offset(script_name, ldscript) sys.stderr.write( """Error: There is no linker script for %s MCU! @@ -177,6 +181,9 @@ def get_linker_script(mcu): join(get_variant_dir(env.BoardConfig().get("build.mcu")), "include") ]) +env.Append(LIBPATH=[ + join(FRAMEWORK_DIR, "platformio", "ldscripts", "atmelsam") +]) env.Replace( LDSCRIPT_PATH=get_linker_script(env.BoardConfig().get("build.mcu"))) diff --git a/examples/cmsis-blink/platformio.ini b/examples/cmsis-blink/platformio.ini index f49409b..6293eb1 100644 --- a/examples/cmsis-blink/platformio.ini +++ b/examples/cmsis-blink/platformio.ini @@ -118,6 +118,26 @@ platform = atmelsam framework = cmsis board = current_ranger +[env:digix] +platform = atmelsam +framework = cmsis +board = digix + +[env:due] +platform = atmelsam +framework = cmsis +board = due + +[env:dueUSB] +platform = atmelsam +framework = cmsis +board = dueUSB + +[env:macchina2] +platform = atmelsam +framework = cmsis +board = macchina2 + [env:minitronics20] platform = atmelsam framework = cmsis @@ -188,11 +208,51 @@ platform = atmelsam framework = cmsis board = nano_33_iot +[env:sainSmartDue] +platform = atmelsam +framework = cmsis +board = sainSmartDue + +[env:sainSmartDueUSB] +platform = atmelsam +framework = cmsis +board = sainSmartDueUSB + +[env:samd21g18a] +platform = atmelsam +framework = cmsis +board = samd21g18a + [env:seeeduino_lorawan] platform = atmelsam framework = cmsis board = seeeduino_lorawan +[env:sodaq_autonomo] +platform = atmelsam +framework = cmsis +board = sodaq_autonomo + +[env:sodaq_explorer] +platform = atmelsam +framework = cmsis +board = sodaq_explorer + +[env:sodaq_one] +platform = atmelsam +framework = cmsis +board = sodaq_one + +[env:sodaq_sara] +platform = atmelsam +framework = cmsis +board = sodaq_sara + +[env:sodaq_sff] +platform = atmelsam +framework = cmsis +board = sodaq_sff + [env:sparkfun_samd21_dev_usb] platform = atmelsam framework = cmsis diff --git a/examples/cmsis-blink/src/main.cpp b/examples/cmsis-blink/src/main.cpp index d455faf..bd06fbe 100644 --- a/examples/cmsis-blink/src/main.cpp +++ b/examples/cmsis-blink/src/main.cpp @@ -1,28 +1,37 @@ #include #include +#if defined(ADAFRUIT_METRO_M4_EXPRESS) +#define LED_PORT PORT_PA16 +const uint32_t CYCLES_PER_SEC = 48000000; // Initial speed of SAMD51 post reset +#else #define LED_PORT PORT_PA17 +const uint32_t CYCLES_PER_SEC = 1000000; // Initial speed of SAMD21 post reset +#endif void toggleLED() { static bool led = false; led = !led; +#if defined(REG_PORT_OUT0) if (led) { REG_PORT_OUT0 &= ~LED_PORT; } else { REG_PORT_OUT0 |= LED_PORT; } +#endif } void init() { SystemInit(); // Direct register manipulation, because CMSIS does not provide a GPIO abstraction. +#if defined(REG_PORT_OUT0) REG_PORT_DIR0 |= LED_PORT; +#endif } -const uint32_t CYCLES_PER_SEC = 1000000; // Initial speed of SAMD21 post reset const uint32_t CYCLES_PER_MS = CYCLES_PER_SEC / 1000; const uint32_t CYCLES_PER_LOOP = 6; const uint32_t LOOPS_PER_MS = CYCLES_PER_MS / CYCLES_PER_LOOP; From 2b93aeddfc28f7963381b1c3dae10849332429b7 Mon Sep 17 00:00:00 2001 From: Frank Leon Rose Date: Mon, 28 Oct 2019 15:39:43 -0400 Subject: [PATCH 12/14] Added MCU to `extra_flags` for CMSIS build --- boards/samd21_xpro.json | 2 ++ boards/saml21_xpro_b.json | 2 ++ boards/samr21_xpro.json | 2 ++ examples/cmsis-blink/platformio.ini | 15 +++++++++++++++ 4 files changed, 21 insertions(+) diff --git a/boards/samd21_xpro.json b/boards/samd21_xpro.json index 5aa14a3..6c8508d 100644 --- a/boards/samd21_xpro.json +++ b/boards/samd21_xpro.json @@ -1,6 +1,7 @@ { "build": { "cpu": "cortex-m0plus", + "extra_flags": "-D__SAMD21J18A__", "f_cpu": "48000000L", "mcu": "samd21j18a" }, @@ -14,6 +15,7 @@ "svd_path": "ATSAMD21J18A.svd" }, "frameworks": [ + "cmsis", "mbed" ], "name": "Atmel SAMD21-XPRO", diff --git a/boards/saml21_xpro_b.json b/boards/saml21_xpro_b.json index 887e0e6..263f764 100644 --- a/boards/saml21_xpro_b.json +++ b/boards/saml21_xpro_b.json @@ -1,6 +1,7 @@ { "build": { "cpu": "cortex-m0plus", + "extra_flags": "-D__SAML21J18B__", "f_cpu": "48000000L", "mcu": "saml21j18b" }, @@ -14,6 +15,7 @@ "svd_path": "ATSAML21J18B.svd" }, "frameworks": [ + "cmsis", "mbed" ], "name": "Atmel SAML21-XPRO-B", diff --git a/boards/samr21_xpro.json b/boards/samr21_xpro.json index b6715b6..767220a 100644 --- a/boards/samr21_xpro.json +++ b/boards/samr21_xpro.json @@ -1,6 +1,7 @@ { "build": { "cpu": "cortex-m0plus", + "extra_flags": "-D__SAMR21G18A__", "f_cpu": "48000000L", "mcu": "samr21g18a" }, @@ -14,6 +15,7 @@ "svd_path": "ATSAMR21G18A.svd" }, "frameworks": [ + "cmsis", "mbed" ], "name": "Atmel ATSAMR21-XPRO", diff --git a/examples/cmsis-blink/platformio.ini b/examples/cmsis-blink/platformio.ini index 6293eb1..f3dba2d 100644 --- a/examples/cmsis-blink/platformio.ini +++ b/examples/cmsis-blink/platformio.ini @@ -218,11 +218,26 @@ platform = atmelsam framework = cmsis board = sainSmartDueUSB +[env:samd21_xpro] +platform = atmelsam +framework = cmsis +board = samd21_xpro + [env:samd21g18a] platform = atmelsam framework = cmsis board = samd21g18a +[env:saml21_xpro_b] +platform = atmelsam +framework = cmsis +board = saml21_xpro_b + +[env:samr21_xpro] +platform = atmelsam +framework = cmsis +board = samr21_xpro + [env:seeeduino_lorawan] platform = atmelsam framework = cmsis From 5632ecda2668b6079439005300cbe8c04cc2d87b Mon Sep 17 00:00:00 2001 From: Frank Leon Rose Date: Mon, 28 Oct 2019 15:56:38 -0400 Subject: [PATCH 13/14] Added warning for untested devices --- examples/cmsis-blink/src/main.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/examples/cmsis-blink/src/main.cpp b/examples/cmsis-blink/src/main.cpp index bd06fbe..d1ba145 100644 --- a/examples/cmsis-blink/src/main.cpp +++ b/examples/cmsis-blink/src/main.cpp @@ -1,11 +1,15 @@ #include #include -#if defined(ADAFRUIT_METRO_M4_EXPRESS) -#define LED_PORT PORT_PA16 +#if defined(ADAFRUIT_METRO_M4_EXPRESS) || defined(ADAFRUIT_GRAND_CENTRAL_M4) +#define LED_PAD PORT_PA16 const uint32_t CYCLES_PER_SEC = 48000000; // Initial speed of SAMD51 post reset +#elif defined(ARDUINO_SAMD_FEATHER_M0) +#define LED_PAD PORT_PA17 +const uint32_t CYCLES_PER_SEC = 1000000; // Initial speed of SAMD21 post reset #else -#define LED_PORT PORT_PA17 +#warning Blink execution untested with this device. Please set LED_PAD, initial MCU clock speed, and control ports correctly. +#define LED_PAD PORT_PA17 const uint32_t CYCLES_PER_SEC = 1000000; // Initial speed of SAMD21 post reset #endif @@ -15,10 +19,10 @@ void toggleLED() { #if defined(REG_PORT_OUT0) if (led) { - REG_PORT_OUT0 &= ~LED_PORT; + REG_PORT_OUT0 &= ~LED_PAD; } else { - REG_PORT_OUT0 |= LED_PORT; + REG_PORT_OUT0 |= LED_PAD; } #endif } @@ -28,7 +32,7 @@ void init() { // Direct register manipulation, because CMSIS does not provide a GPIO abstraction. #if defined(REG_PORT_OUT0) - REG_PORT_DIR0 |= LED_PORT; + REG_PORT_DIR0 |= LED_PAD; #endif } From ce994e68ceaaf643db2588215cc01eb8469d07d4 Mon Sep 17 00:00:00 2001 From: Frank Leon Rose Date: Sat, 2 Nov 2019 09:33:22 -0400 Subject: [PATCH 14/14] Removed disabled code Put `check_variants()` in https://github.com/frankleonrose/framework-cmsis/blob/master/scripts/package.py . We will print a warning that `MCU_FAMILY_SELECTORS` needs to be updated if mapping fails. --- builder/frameworks/cmsis.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/builder/frameworks/cmsis.py b/builder/frameworks/cmsis.py index 33ccbcd..4fb6ee2 100644 --- a/builder/frameworks/cmsis.py +++ b/builder/frameworks/cmsis.py @@ -116,16 +116,6 @@ def get_mcu_family(mcu): return None -# def check_variants(): -# """Ensure that map of family -> regexp (MCU_FAMILY_SELECTORS) correctly replicates -# map of mcu -> family (VARIANT_DIRS, generated by CMSIS downloader script.)""" -# for mcu, family in VARIANT_DIRS.items(): -# f = get_mcu_family(mcu) -# if family!=f: -# sys.stderr.write(f"Error: Failed to match family for: '{mcu}' -> '{f}' vs '{family}'") - -# check_variants() - def get_variant_dir(mcu): family = get_mcu_family(mcu) if family: @@ -151,7 +141,6 @@ def adjust_linker_offset(script_name, ldscript): r"\1+%s\2-%s" % (offset_address, offset_address), content, flags=re.MULTILINE) - # offset_script = join("$BUILD_DIR", basename(ldscript)) offset_script = join(FRAMEWORK_DIR, "platformio", "ldscripts", PLATFORM_NAME, "%s_flash_%s.ld" % (script_name, offset_address))