2016-09-10 08:00:15 -07:00
|
|
|
# Copyright 2014-present PlatformIO <contact@platformio.org>
|
2016-09-10 07:21:29 -07:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
|
|
|
"""
|
|
|
|
Arduino
|
|
|
|
|
|
|
|
Arduino Wiring-based Framework allows writing cross-platform software to
|
|
|
|
control devices attached to a wide range of Arduino boards to create all
|
|
|
|
kinds of creative coding, interactive objects, spaces or physical experiences.
|
|
|
|
|
|
|
|
http://www.stm32duino.com
|
|
|
|
"""
|
|
|
|
|
2016-09-10 08:00:15 -07:00
|
|
|
from os.path import isdir, join
|
2016-09-10 07:21:29 -07:00
|
|
|
|
|
|
|
from SCons.Script import DefaultEnvironment
|
|
|
|
|
|
|
|
env = DefaultEnvironment()
|
|
|
|
platform = env.PioPlatform()
|
2016-09-13 09:55:31 -07:00
|
|
|
board = env.BoardConfig()
|
2016-09-10 07:21:29 -07:00
|
|
|
|
2016-09-13 09:55:31 -07:00
|
|
|
if board.id == "bluepill_f103c8":
|
|
|
|
board = env.BoardConfig("genericSTM32F103C8")
|
|
|
|
env['LDSCRIPT_PATH'] = board.get("build.ldscript")
|
|
|
|
env.ProcessFlags(board.get("build.extra_flags"))
|
|
|
|
|
2016-09-10 07:21:29 -07:00
|
|
|
|
2016-10-11 15:36:48 -07:00
|
|
|
FRAMEWORK_DIR = join(platform.get_package_dir(
|
|
|
|
"framework-arduinoststm32"), "STM32F1")
|
2016-09-10 07:21:29 -07:00
|
|
|
FRAMEWORK_VERSION = platform.get_package_version("framework-arduinoststm32")
|
|
|
|
assert isdir(FRAMEWORK_DIR)
|
|
|
|
|
|
|
|
env.Append(
|
2016-10-11 15:36:48 -07:00
|
|
|
CCFLAGS=[
|
|
|
|
"--param", "max-inline-insns-single=500",
|
|
|
|
"-march=armv7-m"
|
|
|
|
],
|
|
|
|
|
2016-09-10 07:21:29 -07:00
|
|
|
CPPDEFINES=[
|
2016-11-30 05:54:55 -08:00
|
|
|
("ARDUINO", 10610),
|
2016-10-11 15:36:48 -07:00
|
|
|
"BOARD_%s" % board.get("build.variant"),
|
2016-11-30 05:54:55 -08:00
|
|
|
("ERROR_LED_PORT", "GPIOB"),
|
|
|
|
("ERROR_LED_PIN", 1),
|
|
|
|
("DEBUG_LEVEL", "DEBUG_NONE"),
|
2016-10-11 15:36:48 -07:00
|
|
|
"__STM32F1__",
|
|
|
|
"ARDUINO_ARCH_STM32F1"
|
2016-09-10 07:21:29 -07:00
|
|
|
],
|
|
|
|
|
|
|
|
CPPPATH=[
|
2016-09-13 09:55:31 -07:00
|
|
|
join(FRAMEWORK_DIR, "cores", board.get("build.core")),
|
2016-09-10 07:21:29 -07:00
|
|
|
join(FRAMEWORK_DIR, "system", "libmaple"),
|
|
|
|
join(FRAMEWORK_DIR, "system", "libmaple", "include"),
|
|
|
|
join(FRAMEWORK_DIR, "system", "libmaple", "usb", "stm32f1"),
|
|
|
|
join(FRAMEWORK_DIR, "system", "libmaple", "usb", "usb_lib")
|
|
|
|
],
|
|
|
|
|
|
|
|
LIBPATH=[
|
2016-09-10 08:00:15 -07:00
|
|
|
join(FRAMEWORK_DIR, "variants",
|
2016-09-13 09:55:31 -07:00
|
|
|
board.get("build.variant"), "ld")
|
2016-10-14 04:26:21 -07:00
|
|
|
],
|
|
|
|
|
|
|
|
LIBS=["c"]
|
2016-09-10 07:21:29 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
for item in ("-nostartfiles", "-nostdlib"):
|
|
|
|
if item in env['LINKFLAGS']:
|
|
|
|
env['LINKFLAGS'].remove(item)
|
|
|
|
|
|
|
|
|
|
|
|
if env.subst("$UPLOAD_PROTOCOL") == "dfu":
|
2016-11-19 08:35:50 -08:00
|
|
|
if board.id in ("maple", "maple_mini_origin"):
|
2016-11-30 05:54:55 -08:00
|
|
|
env.Append(CPPDEFINES=[("VECT_TAB_ADDR", 0x8005000), "SERIAL_USB"])
|
2016-09-10 07:21:29 -07:00
|
|
|
else:
|
2016-09-10 08:00:15 -07:00
|
|
|
env.Append(CPPDEFINES=[
|
2016-11-30 05:54:55 -08:00
|
|
|
("VECT_TAB_ADDR", 0x8002000), "SERIAL_USB", "GENERIC_BOOTLOADER"])
|
2016-11-19 08:35:50 -08:00
|
|
|
|
|
|
|
if "stm32f103r" in board.get("build.mcu", ""):
|
|
|
|
env.Replace(LDSCRIPT_PATH="bootloader.ld")
|
|
|
|
elif board.get("upload.boot_version", 0) == 2:
|
|
|
|
env.Replace(LDSCRIPT_PATH="bootloader_20.ld")
|
2016-09-10 07:21:29 -07:00
|
|
|
else:
|
2016-11-30 05:54:55 -08:00
|
|
|
env.Append(CPPDEFINES=[("VECT_TAB_ADDR", 0x8000000)])
|
2016-09-13 09:55:31 -07:00
|
|
|
|
2016-09-10 07:21:29 -07:00
|
|
|
#
|
|
|
|
# Lookup for specific core's libraries
|
|
|
|
#
|
|
|
|
|
2016-09-13 09:55:31 -07:00
|
|
|
BOARD_CORELIBDIRNAME = board.get("build.core", "")
|
2016-09-10 07:21:29 -07:00
|
|
|
env.Append(
|
|
|
|
LIBSOURCE_DIRS=[
|
|
|
|
join(FRAMEWORK_DIR, "libraries", "__cores__", BOARD_CORELIBDIRNAME),
|
|
|
|
join(FRAMEWORK_DIR, "libraries")
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
|
|
|
#
|
|
|
|
# Target: Build Core Library
|
|
|
|
#
|
|
|
|
|
|
|
|
libs = []
|
|
|
|
|
2016-09-13 09:55:31 -07:00
|
|
|
if "build.variant" in board:
|
2016-09-10 07:21:29 -07:00
|
|
|
env.Append(
|
|
|
|
CPPPATH=[
|
2016-09-10 08:00:15 -07:00
|
|
|
join(FRAMEWORK_DIR, "variants",
|
2016-09-13 09:55:31 -07:00
|
|
|
board.get("build.variant"))
|
2016-09-10 07:21:29 -07:00
|
|
|
]
|
|
|
|
)
|
|
|
|
libs.append(env.BuildLibrary(
|
|
|
|
join("$BUILD_DIR", "FrameworkArduinoVariant"),
|
2016-09-13 09:55:31 -07:00
|
|
|
join(FRAMEWORK_DIR, "variants", board.get("build.variant"))
|
2016-09-10 07:21:29 -07:00
|
|
|
))
|
|
|
|
|
2016-09-13 09:55:31 -07:00
|
|
|
libs.append(env.BuildLibrary(
|
2016-09-10 07:21:29 -07:00
|
|
|
join("$BUILD_DIR", "FrameworkArduino"),
|
2016-09-13 09:55:31 -07:00
|
|
|
join(FRAMEWORK_DIR, "cores", board.get("build.core"))
|
2016-09-10 07:21:29 -07:00
|
|
|
))
|
|
|
|
|
|
|
|
env.Prepend(LIBS=libs)
|