diff --git a/boards/genericSTM32F103C8.json b/boards/genericSTM32F103C8.json index f5843ff..93d7c86 100644 --- a/boards/genericSTM32F103C8.json +++ b/boards/genericSTM32F103C8.json @@ -1,28 +1,28 @@ { "build": { - "core": "maple", - "cpu": "cortex-m3", - "extra_flags": "-DMCU_STM32F103C8", - "f_cpu": "72000000L", + "core": "maple", + "cpu": "cortex-m3", + "extra_flags": "-DARDUINO_GENERIC_STM32F103C -DMCU_STM32F103C8", + "f_cpu": "72000000L", "hwids": [ ["0x1EAF", "0x0003"], ["0x1EAF", "0x0004"] ], - "ldscript": "jtag_c8.ld", - "mcu": "stm32f103c8", + "ldscript": "jtag_c8.ld", + "mcu": "stm32f103c8", "variant": "generic_stm32f103c" - }, - "frameworks": ["arduino"], - "name": "STM32F103C8 (20k RAM. 64k Flash)", + }, + "frameworks": ["arduino"], + "name": "STM32F103C8 (20k RAM. 64k Flash)", "upload": { - "disable_flushing": false, - "maximum_ram_size": 20480, - "maximum_size": 65536, - "protocol": "maple_serial", - "require_upload_port": true, - "use_1200bps_touch": false, + "disable_flushing": false, + "maximum_ram_size": 20480, + "maximum_size": 65536, + "protocol": "serial", + "require_upload_port": true, + "use_1200bps_touch": false, "wait_for_upload_port": false - }, - "url": "http://www.st.com/content/st_com/en/products/microcontrollers/stm32-32-bit-arm-cortex-mcus/stm32f1-series/stm32f103/stm32f103c8.html", + }, + "url": "http://www.st.com/content/st_com/en/products/microcontrollers/stm32-32-bit-arm-cortex-mcus/stm32f1-series/stm32f103/stm32f103c8.html", "vendor": "Generic" } \ No newline at end of file diff --git a/boards/genericSTM32F103CB.json b/boards/genericSTM32F103CB.json index 47ef822..7132a0b 100644 --- a/boards/genericSTM32F103CB.json +++ b/boards/genericSTM32F103CB.json @@ -1,28 +1,28 @@ { "build": { - "core": "maple", - "cpu": "cortex-m3", - "extra_flags": "-DMCU_STM32F103CB", - "f_cpu": "72000000L", + "core": "maple", + "cpu": "cortex-m3", + "extra_flags": "-DARDUINO_GENERIC_STM32F103C -DMCU_STM32F103CB", + "f_cpu": "72000000L", "hwids": [ ["0x1EAF", "0x0003"], ["0x1EAF", "0x0004"] ], - "ldscript": "jtag.ld", - "mcu": "stm32f103cb", + "ldscript": "jtag.ld", + "mcu": "stm32f103cb", "variant": "generic_stm32f103c" - }, - "frameworks": ["arduino"], - "name": "STM32F103CB (20k RAM. 128k Flash)", + }, + "frameworks": ["arduino"], + "name": "STM32F103CB (20k RAM. 128k Flash)", "upload": { - "disable_flushing": false, - "maximum_ram_size": 20480, - "maximum_size": 131072, - "protocol": "maple_serial", - "require_upload_port": true, - "use_1200bps_touch": false, + "disable_flushing": false, + "maximum_ram_size": 20480, + "maximum_size": 131072, + "protocol": "serial", + "require_upload_port": true, + "use_1200bps_touch": false, "wait_for_upload_port": false - }, - "url": "http://www.st.com/content/st_com/en/products/microcontrollers/stm32-32-bit-arm-cortex-mcus/stm32f1-series/stm32f103/stm32f103cb.html", + }, + "url": "http://www.st.com/content/st_com/en/products/microcontrollers/stm32-32-bit-arm-cortex-mcus/stm32f1-series/stm32f103/stm32f103cb.html", "vendor": "Generic" } \ No newline at end of file diff --git a/boards/genericSTM32F103R8.json b/boards/genericSTM32F103R8.json index 5fd9c9a..878c478 100644 --- a/boards/genericSTM32F103R8.json +++ b/boards/genericSTM32F103R8.json @@ -1,28 +1,28 @@ { "build": { - "core": "maple", - "cpu": "cortex-m3", - "extra_flags": "-DMCU_STM32F103R8", - "f_cpu": "72000000L", + "core": "maple", + "cpu": "cortex-m3", + "extra_flags": "-DARDUINO_GENERIC_STM32F103R -DMCU_STM32F103R8", + "f_cpu": "72000000L", "hwids": [ ["0x1EAF", "0x0003"], ["0x1EAF", "0x0004"] ], - "ldscript": "stm32f103r8.ld", - "mcu": "stm32f103r8", + "ldscript": "stm32f103r8.ld", + "mcu": "stm32f103r8", "variant": "generic_stm32f103r8" - }, - "frameworks": ["arduino"], - "name": "STM32F103R8 (20k RAM. 64 Flash)", + }, + "frameworks": ["arduino"], + "name": "STM32F103R8 (20k RAM. 64 Flash)", "upload": { - "disable_flushing": false, - "maximum_ram_size": 20480, - "maximum_size": 65536, - "protocol": "maple_serial", - "require_upload_port": true, - "use_1200bps_touch": false, + "disable_flushing": false, + "maximum_ram_size": 20480, + "maximum_size": 65536, + "protocol": "serial", + "require_upload_port": true, + "use_1200bps_touch": false, "wait_for_upload_port": false - }, - "url": "http://www.st.com/content/st_com/en/products/microcontrollers/stm32-32-bit-arm-cortex-mcus/stm32f1-series/stm32f103/stm32f103r8.html", + }, + "url": "http://www.st.com/content/st_com/en/products/microcontrollers/stm32-32-bit-arm-cortex-mcus/stm32f1-series/stm32f103/stm32f103r8.html", "vendor": "Generic" } \ No newline at end of file diff --git a/boards/genericSTM32F103RB.json b/boards/genericSTM32F103RB.json index 051898e..5d3a3bc 100644 --- a/boards/genericSTM32F103RB.json +++ b/boards/genericSTM32F103RB.json @@ -1,28 +1,28 @@ { "build": { - "core": "maple", - "cpu": "cortex-m3", - "extra_flags": "-DMCU_STM32F103RB", - "f_cpu": "72000000L", + "core": "maple", + "cpu": "cortex-m3", + "extra_flags": "-DARDUINO_GENERIC_STM32F103R -DMCU_STM32F103RB", + "f_cpu": "72000000L", "hwids": [ ["0x1EAF", "0x0003"], ["0x1EAF", "0x0004"] ], - "ldscript": "stm32f103rb.ld", - "mcu": "stm32f103rb", + "ldscript": "stm32f103rb.ld", + "mcu": "stm32f103rb", "variant": "generic_stm32f103r8" - }, - "frameworks": ["arduino"], - "name": "STM32F103RB (20k RAM. 128k Flash)", + }, + "frameworks": ["arduino"], + "name": "STM32F103RB (20k RAM. 128k Flash)", "upload": { - "disable_flushing": false, - "maximum_ram_size": 20480, - "maximum_size": 131072, - "protocol": "maple_serial", - "require_upload_port": true, - "use_1200bps_touch": false, + "disable_flushing": false, + "maximum_ram_size": 20480, + "maximum_size": 131072, + "protocol": "serial", + "require_upload_port": true, + "use_1200bps_touch": false, "wait_for_upload_port": false - }, - "url": "http://www.st.com/content/st_com/en/products/microcontrollers/stm32-32-bit-arm-cortex-mcus/stm32f1-series/stm32f103/stm32f103rb.html", + }, + "url": "http://www.st.com/content/st_com/en/products/microcontrollers/stm32-32-bit-arm-cortex-mcus/stm32f1-series/stm32f103/stm32f103rb.html", "vendor": "Generic" } \ No newline at end of file diff --git a/boards/genericSTM32F103RC.json b/boards/genericSTM32F103RC.json index ad90515..ca3d9ca 100644 --- a/boards/genericSTM32F103RC.json +++ b/boards/genericSTM32F103RC.json @@ -1,28 +1,28 @@ { "build": { - "core": "maple", - "cpu": "cortex-m3", - "extra_flags": "-DMCU_STM32F103RC", - "f_cpu": "72000000L", + "core": "maple", + "cpu": "cortex-m3", + "extra_flags": "-DARDUINO_GENERIC_STM32F103R -DMCU_STM32F103RC", + "f_cpu": "72000000L", "hwids": [ ["0x1EAF", "0x0003"], ["0x1EAF", "0x0004"] ], - "ldscript": "stm32f103rc.ld", - "mcu": "stm32f103rc", + "ldscript": "stm32f103rc.ld", + "mcu": "stm32f103rc", "variant": "generic_stm32f103r" - }, - "frameworks": ["arduino"], - "name": "STM32F103RC (48k RAM. 256k Flash)", + }, + "frameworks": ["arduino"], + "name": "STM32F103RC (48k RAM. 256k Flash)", "upload": { - "disable_flushing": false, - "maximum_ram_size": 49152, - "maximum_size": 262144, - "protocol": "maple_serial", - "require_upload_port": true, - "use_1200bps_touch": false, + "disable_flushing": false, + "maximum_ram_size": 49152, + "maximum_size": 262144, + "protocol": "serial", + "require_upload_port": true, + "use_1200bps_touch": false, "wait_for_upload_port": false - }, - "url": "http://www.st.com/content/st_com/en/products/microcontrollers/stm32-32-bit-arm-cortex-mcus/stm32f1-series/stm32f103/stm32f103rc.html", + }, + "url": "http://www.st.com/content/st_com/en/products/microcontrollers/stm32-32-bit-arm-cortex-mcus/stm32f1-series/stm32f103/stm32f103rc.html", "vendor": "Generic" } \ No newline at end of file diff --git a/boards/genericSTM32F103RE.json b/boards/genericSTM32F103RE.json index 3599f26..d8b0cdf 100644 --- a/boards/genericSTM32F103RE.json +++ b/boards/genericSTM32F103RE.json @@ -1,28 +1,28 @@ { "build": { - "core": "maple", - "cpu": "cortex-m3", - "extra_flags": "-DMCU_STM32F103RE", - "f_cpu": "72000000L", + "core": "maple", + "cpu": "cortex-m3", + "extra_flags": "-DARDUINO_GENERIC_STM32F103R -DMCU_STM32F103RE", + "f_cpu": "72000000L", "hwids": [ ["0x1EAF", "0x0003"], ["0x1EAF", "0x0004"] ], - "ldscript": "stm32f103re.ld", - "mcu": "stm32f103re", + "ldscript": "stm32f103re.ld", + "mcu": "stm32f103re", "variant": "generic_stm32f103r" - }, - "frameworks": ["arduino"], - "name": "STM32F103RE (64k RAM. 512k Flash)", + }, + "frameworks": ["arduino"], + "name": "STM32F103RE (64k RAM. 512k Flash)", "upload": { - "disable_flushing": false, - "maximum_ram_size": 65536, - "maximum_size": 524288, - "protocol": "maple_serial", - "require_upload_port": true, - "use_1200bps_touch": false, + "disable_flushing": false, + "maximum_ram_size": 65536, + "maximum_size": 524288, + "protocol": "serial", + "require_upload_port": true, + "use_1200bps_touch": false, "wait_for_upload_port": false - }, - "url": "http://www.st.com/content/st_com/en/products/microcontrollers/stm32-32-bit-arm-cortex-mcus/stm32f1-series/stm32f103/stm32f103re.html", + }, + "url": "http://www.st.com/content/st_com/en/products/microcontrollers/stm32-32-bit-arm-cortex-mcus/stm32f1-series/stm32f103/stm32f103re.html", "vendor": "Generic" } \ No newline at end of file diff --git a/boards/maple.json b/boards/maple.json index 4f913bd..33212c5 100644 --- a/boards/maple.json +++ b/boards/maple.json @@ -1,28 +1,29 @@ { "build": { - "core": "maple", - "cpu": "cortex-m3", - "extra_flags": "-DMCU_STM32F103RB", - "f_cpu": "72000000L", + "core": "maple", + "cpu": "cortex-m3", + "extra_flags": "-DARDUINO_MAPLE_REV3 -DMCU_STM32F103RB", + "f_cpu": "72000000L", "hwids": [ ["0x1EAF", "0x0003"], ["0x1EAF", "0x0004"] ], - "ldscript": "flash.ld", - "mcu": "stm32f103rb_maple", + "ldscript": "flash.ld", + "mcu": "stm32f103rb_maple", "variant": "maple" - }, - "frameworks": ["arduino"], - "name": "Olimexino STM32", + }, + "frameworks": ["arduino"], + "name": "Olimexino STM32 (Maple)", "upload": { - "disable_flushing": false, - "maximum_ram_size": 17000, - "maximum_size": 108000, - "protocol": "dfu", - "require_upload_port": true, - "use_1200bps_touch": false, + "disable_flushing": false, + "maximum_ram_size": 17000, + "maximum_size": 108000, + "protocol": "dfu", + "boot_version": 1, + "require_upload_port": true, + "use_1200bps_touch": false, "wait_for_upload_port": false - }, - "url": "https://www.olimex.com/Products/Duino/STM32/OLIMEXINO-STM32/", + }, + "url": "https://www.olimex.com/Products/Duino/STM32/OLIMEXINO-STM32/", "vendor": "Olimex" } diff --git a/builder/frameworks/arduino.py b/builder/frameworks/arduino.py index baab9aa..88bc910 100644 --- a/builder/frameworks/arduino.py +++ b/builder/frameworks/arduino.py @@ -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_DIR = join(platform.get_package_dir( + "framework-arduinoststm32"), "STM32F1") 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=[ diff --git a/builder/main.py b/builder/main.py index ff628f6..e41d8d7 100644 --- a/builder/main.py +++ b/builder/main.py @@ -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,32 +138,19 @@ 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") == "serial": - uploadProtocol = "serial_upload" - uploadParams = "{upload.altID} {upload.usbID} $PROJECT_DIR/$SOURCES" - elif 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 + _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 = [env.BoardConfig().get("upload.boot_version", 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 @@ -200,9 +186,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: diff --git a/platform.json b/platform.json index ebe125e..00f25f7 100644 --- a/platform.json +++ b/platform.json @@ -13,21 +13,11 @@ "type": "git", "url": "https://github.com/platformio/platform-ststm32.git" }, - "version": "1.2.0", + "version": "1.3.0", "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" } } }