Refactor support for STM32Duino // Resolve #9
This commit is contained in:
parent
012d7eb939
commit
3f6dbd1b74
|
@ -2,7 +2,7 @@
|
|||
"build": {
|
||||
"core": "maple",
|
||||
"cpu": "cortex-m3",
|
||||
"extra_flags": "-DMCU_STM32F103C8",
|
||||
"extra_flags": "-DARDUINO_GENERIC_STM32F103C -DMCU_STM32F103C8",
|
||||
"f_cpu": "72000000L",
|
||||
"hwids": [
|
||||
["0x1EAF", "0x0003"],
|
||||
|
@ -18,7 +18,7 @@
|
|||
"disable_flushing": false,
|
||||
"maximum_ram_size": 20480,
|
||||
"maximum_size": 65536,
|
||||
"protocol": "maple_serial",
|
||||
"protocol": "serial",
|
||||
"require_upload_port": true,
|
||||
"use_1200bps_touch": false,
|
||||
"wait_for_upload_port": false
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"build": {
|
||||
"core": "maple",
|
||||
"cpu": "cortex-m3",
|
||||
"extra_flags": "-DMCU_STM32F103CB",
|
||||
"extra_flags": "-DARDUINO_GENERIC_STM32F103C -DMCU_STM32F103CB",
|
||||
"f_cpu": "72000000L",
|
||||
"hwids": [
|
||||
["0x1EAF", "0x0003"],
|
||||
|
@ -18,7 +18,7 @@
|
|||
"disable_flushing": false,
|
||||
"maximum_ram_size": 20480,
|
||||
"maximum_size": 131072,
|
||||
"protocol": "maple_serial",
|
||||
"protocol": "serial",
|
||||
"require_upload_port": true,
|
||||
"use_1200bps_touch": false,
|
||||
"wait_for_upload_port": false
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"build": {
|
||||
"core": "maple",
|
||||
"cpu": "cortex-m3",
|
||||
"extra_flags": "-DMCU_STM32F103R8",
|
||||
"extra_flags": "-DARDUINO_GENERIC_STM32F103R -DMCU_STM32F103R8",
|
||||
"f_cpu": "72000000L",
|
||||
"hwids": [
|
||||
["0x1EAF", "0x0003"],
|
||||
|
@ -18,7 +18,7 @@
|
|||
"disable_flushing": false,
|
||||
"maximum_ram_size": 20480,
|
||||
"maximum_size": 65536,
|
||||
"protocol": "maple_serial",
|
||||
"protocol": "serial",
|
||||
"require_upload_port": true,
|
||||
"use_1200bps_touch": false,
|
||||
"wait_for_upload_port": false
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"build": {
|
||||
"core": "maple",
|
||||
"cpu": "cortex-m3",
|
||||
"extra_flags": "-DMCU_STM32F103RB",
|
||||
"extra_flags": "-DARDUINO_GENERIC_STM32F103R -DMCU_STM32F103RB",
|
||||
"f_cpu": "72000000L",
|
||||
"hwids": [
|
||||
["0x1EAF", "0x0003"],
|
||||
|
@ -18,7 +18,7 @@
|
|||
"disable_flushing": false,
|
||||
"maximum_ram_size": 20480,
|
||||
"maximum_size": 131072,
|
||||
"protocol": "maple_serial",
|
||||
"protocol": "serial",
|
||||
"require_upload_port": true,
|
||||
"use_1200bps_touch": false,
|
||||
"wait_for_upload_port": false
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"build": {
|
||||
"core": "maple",
|
||||
"cpu": "cortex-m3",
|
||||
"extra_flags": "-DMCU_STM32F103RC",
|
||||
"extra_flags": "-DARDUINO_GENERIC_STM32F103R -DMCU_STM32F103RC",
|
||||
"f_cpu": "72000000L",
|
||||
"hwids": [
|
||||
["0x1EAF", "0x0003"],
|
||||
|
@ -18,7 +18,7 @@
|
|||
"disable_flushing": false,
|
||||
"maximum_ram_size": 49152,
|
||||
"maximum_size": 262144,
|
||||
"protocol": "maple_serial",
|
||||
"protocol": "serial",
|
||||
"require_upload_port": true,
|
||||
"use_1200bps_touch": false,
|
||||
"wait_for_upload_port": false
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"build": {
|
||||
"core": "maple",
|
||||
"cpu": "cortex-m3",
|
||||
"extra_flags": "-DMCU_STM32F103RE",
|
||||
"extra_flags": "-DARDUINO_GENERIC_STM32F103R -DMCU_STM32F103RE",
|
||||
"f_cpu": "72000000L",
|
||||
"hwids": [
|
||||
["0x1EAF", "0x0003"],
|
||||
|
@ -18,7 +18,7 @@
|
|||
"disable_flushing": false,
|
||||
"maximum_ram_size": 65536,
|
||||
"maximum_size": 524288,
|
||||
"protocol": "maple_serial",
|
||||
"protocol": "serial",
|
||||
"require_upload_port": true,
|
||||
"use_1200bps_touch": false,
|
||||
"wait_for_upload_port": false
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"build": {
|
||||
"core": "maple",
|
||||
"cpu": "cortex-m3",
|
||||
"extra_flags": "-DMCU_STM32F103RB",
|
||||
"extra_flags": "-DARDUINO_MAPLE_REV3 -DMCU_STM32F103RB",
|
||||
"f_cpu": "72000000L",
|
||||
"hwids": [
|
||||
["0x1EAF", "0x0003"],
|
||||
|
|
|
@ -35,38 +35,30 @@ if board.id == "bluepill_f103c8":
|
|||
env['LDSCRIPT_PATH'] = board.get("build.ldscript")
|
||||
env.ProcessFlags(board.get("build.extra_flags"))
|
||||
|
||||
if "stm32f103" in board.get("build.mcu", ""):
|
||||
|
||||
FRAMEWORK_DIR = join(platform.get_package_dir(
|
||||
"framework-arduinoststm32"), "STM32F1")
|
||||
env.Append(
|
||||
CPPDEFINES=[
|
||||
"ERROR_LED_PORT=GPIOB",
|
||||
"ERROR_LED_PIN=1",
|
||||
"ARDUINO_ARCH_STM32F1"
|
||||
]
|
||||
)
|
||||
if "stm32f103r8" or "stm32f103rb" in board.get(
|
||||
"build.mcu", ""):
|
||||
env.Append(CPPDEFINES=[
|
||||
"BOARD_generic_stm32f103r8", "ARDUINO_GENERIC_STM32F103R"])
|
||||
elif "stm32f103rc" or "stm32f103re" in board.get(
|
||||
"build.mcu", ""):
|
||||
env.Append(CPPDEFINES=[
|
||||
"BOARD_generic_stm32f103r", "ARDUINO_GENERIC_STM32F103R"])
|
||||
elif "stm32f103c" in board.get("build.mcu", ""):
|
||||
env.Append(CPPDEFINES=[
|
||||
"BOARD_generic_stm32f103c", "ARDUINO_GENERIC_STM32F103C"])
|
||||
elif "stm32f103rb_maple" in board.get("build.mcu", ""):
|
||||
env.Append(CPPDEFINES=["BOARD_maple", "ARDUINO_MAPLE_REV3"])
|
||||
|
||||
FRAMEWORK_VERSION = platform.get_package_version("framework-arduinoststm32")
|
||||
assert isdir(FRAMEWORK_DIR)
|
||||
|
||||
ARDUINO_VERSION = int(FRAMEWORK_VERSION.replace(".", "").strip())
|
||||
env.Replace(
|
||||
LIBS=["m", "gcc"]
|
||||
)
|
||||
|
||||
env.Append(
|
||||
CCFLAGS=[
|
||||
"--param", "max-inline-insns-single=500",
|
||||
"-march=armv7-m"
|
||||
],
|
||||
|
||||
CPPDEFINES=[
|
||||
"ARDUINO=%s" % FRAMEWORK_VERSION.split(".")[1]
|
||||
"ARDUINO=10611",
|
||||
"BOARD_%s" % board.get("build.variant"),
|
||||
"ERROR_LED_PORT=GPIOB",
|
||||
"ERROR_LED_PIN=1",
|
||||
"DEBUG_LEVEL=DEBUG_NONE",
|
||||
"__STM32F1__",
|
||||
"ARDUINO_ARCH_STM32F1"
|
||||
],
|
||||
|
||||
CPPPATH=[
|
||||
|
@ -80,10 +72,7 @@ env.Append(
|
|||
LIBPATH=[
|
||||
join(FRAMEWORK_DIR, "variants",
|
||||
board.get("build.variant"), "ld")
|
||||
],
|
||||
|
||||
# hook for https://github.com/platformio/platform-ststm32/issues/10
|
||||
LIBS=["c"]
|
||||
]
|
||||
)
|
||||
|
||||
for item in ("-nostartfiles", "-nostdlib"):
|
||||
|
|
|
@ -12,12 +12,11 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from os.path import isfile, join
|
||||
from os.path import basename, isfile, join
|
||||
|
||||
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Builder, Default,
|
||||
DefaultEnvironment)
|
||||
|
||||
from platformio import util
|
||||
|
||||
env = DefaultEnvironment()
|
||||
|
||||
|
@ -139,34 +138,18 @@ if env.subst("$UPLOAD_PROTOCOL") == "gdb":
|
|||
)
|
||||
|
||||
if "arduino" in env.subst("$PIOFRAMEWORK"):
|
||||
uploadProtocol = ""
|
||||
uploadParams = ""
|
||||
if "linux" in util.get_systype():
|
||||
uploadPlatform = "linux"
|
||||
elif "darwin" in util.get_systype():
|
||||
uploadPlatform = "macosx"
|
||||
else:
|
||||
uploadPlatform = "win"
|
||||
|
||||
if env.subst("$UPLOAD_PROTOCOL") == "dfu":
|
||||
uploadProtocol = "maple_upload"
|
||||
usbids = env.BoardConfig().get("build.hwids")
|
||||
usbid = '2 %s:%s' % (usbids[0][0], usbids[0][1])
|
||||
env.Replace(UPLOADERFLAGS=usbid)
|
||||
uploadParams = usbid
|
||||
else:
|
||||
uploadProtocol = "serial_upload"
|
||||
uploadParams = "{upload.altID} {upload.usbID} $PROJECT_DIR/$SOURCES"
|
||||
_upload_tool = "serial_upload"
|
||||
_upload_flags = ["{upload.altID}", "{upload.usbID}"]
|
||||
if "dfu" in env.subst("$UPLOAD_PROTOCOL"):
|
||||
_upload_tool = "maple_upload"
|
||||
_usbids = env.BoardConfig().get("build.hwids")
|
||||
_upload_flags = ["2", "%s:%s" % (_usbids[0][0][2:], _usbids[0][1][2:])]
|
||||
|
||||
env.Replace(
|
||||
UPLOADER=join(
|
||||
env.PioPlatform().get_package_dir(
|
||||
"framework-arduinoststm32") or "",
|
||||
"tools", uploadPlatform, uploadProtocol),
|
||||
UPLOADERFLAGS=["$UPLOAD_PORT"],
|
||||
UPLOADERPARAMS=uploadParams,
|
||||
UPLOADER=_upload_tool,
|
||||
UPLOADERFLAGS=["$UPLOAD_PORT"] + _upload_flags,
|
||||
UPLOADCMD=(
|
||||
'$UPLOADER $UPLOADERFLAGS $UPLOADERPARAMS $PROJECT_DIR/$SOURCES'))
|
||||
'$UPLOADER $UPLOADERFLAGS $PROJECT_DIR/$SOURCES'))
|
||||
|
||||
#
|
||||
# Target: Build executable and linkable firmware
|
||||
|
@ -202,9 +185,14 @@ if "mbed" in env.subst("$PIOFRAMEWORK") and not env.subst("$UPLOAD_PROTOCOL"):
|
|||
"Looking for upload disk..."),
|
||||
env.VerboseAction(env.UploadToDisk, "Uploading $SOURCE")])
|
||||
elif "arduino" in env.subst("$PIOFRAMEWORK"):
|
||||
|
||||
def BeforeUpload(target, source, env):
|
||||
env.AutodetectUploadPort()
|
||||
env.Replace(UPLOAD_PORT=basename(env.subst("$UPLOAD_PORT")))
|
||||
|
||||
target_upload = env.Alias(
|
||||
"upload", target_firm,
|
||||
[env.VerboseAction(env.AutodetectUploadPort,
|
||||
[env.VerboseAction(BeforeUpload,
|
||||
"Looking for upload disk..."),
|
||||
env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")])
|
||||
else:
|
||||
|
|
|
@ -13,21 +13,11 @@
|
|||
"type": "git",
|
||||
"url": "https://github.com/platformio/platform-ststm32.git"
|
||||
},
|
||||
"version": "1.2.0",
|
||||
"version": "1.3.0-alpha1",
|
||||
"packageRepositories": [
|
||||
"https://dl.bintray.com/platformio/dl-packages/manifest.json",
|
||||
"https://sourceforge.net/projects/platformio-storage/files/packages/manifest.json/download",
|
||||
"http://dl.platformio.org/packages/manifest.json",
|
||||
{
|
||||
"framework-arduinoststm32": [
|
||||
{
|
||||
"url": "https://github.com/ubis/Arduino_STM32/archive/v1.0.0.tar.gz",
|
||||
"sha1": "36f26069b70ef6b7ceae2a91e3c23be74cc79337",
|
||||
"version": "1.0.0",
|
||||
"system": "*"
|
||||
}
|
||||
]
|
||||
}
|
||||
"http://dl.platformio.org/packages/manifest.json"
|
||||
],
|
||||
"frameworks": {
|
||||
"mbed": {
|
||||
|
@ -79,12 +69,17 @@
|
|||
"framework-arduinoststm32": {
|
||||
"type": "framework",
|
||||
"optional": true,
|
||||
"version": "~1.0.0"
|
||||
"version": "~2.0.0"
|
||||
},
|
||||
"tool-stlink": {
|
||||
"type": "uploader",
|
||||
"optional": true,
|
||||
"version": "~1.10200.0"
|
||||
},
|
||||
"tool-stm32duino": {
|
||||
"type": "uploader",
|
||||
"optional": true,
|
||||
"version": "~1.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue