forked from platformio/platformio-core
Merge pull request #85 from valeros/develop
Refactor build scripts for development platforms
This commit is contained in:
@ -542,7 +542,8 @@
|
||||
"core": "arduino",
|
||||
"extra_flags": "-D__SAM3X8E__ -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM",
|
||||
"f_cpu": "84000000L",
|
||||
"mcu": "cortex-m3",
|
||||
"mcu": "at91sam3x8e",
|
||||
"cpu": "cortex-m3",
|
||||
"pid": "0x003e",
|
||||
"usb_product": "Arduino Due",
|
||||
"variant": "arduino_due_x",
|
||||
|
@ -80,7 +80,8 @@
|
||||
"core": "digispark_digix",
|
||||
"extra_flags": "-w -D__SAM3X8E__ -DARDUINO_SAM_DIGIX -DARDUINO_ARCH_SAM",
|
||||
"f_cpu": "84000000L",
|
||||
"mcu": "cortex-m3",
|
||||
"mcu": "at91sam3x8e",
|
||||
"cpu": "cortex-m3",
|
||||
"ldscript": "sam3x8e.ld",
|
||||
"pid": "0x078A",
|
||||
"usb_product": "Digistump DigiX",
|
||||
|
@ -5,7 +5,8 @@
|
||||
"extra_flags": "-DSTM32F40_41xxx",
|
||||
"f_cpu": "168000000L",
|
||||
"ldscript": "stm32f405x6.ld",
|
||||
"mcu": "cortex-m4",
|
||||
"cpu": "cortex-m4",
|
||||
"mcu": "stm32f407vgt6",
|
||||
"variant": "stm32f4"
|
||||
},
|
||||
"name": "STM32F4Discovery (168 MHz) with digital accelerometer, digital microphone, audio DAC",
|
||||
@ -21,7 +22,8 @@
|
||||
"extra_flags": "-DSTM32L1XX_MD",
|
||||
"f_cpu": "32000000L",
|
||||
"ldscript": "stm32l15xx6.ld",
|
||||
"mcu": "cortex-m3",
|
||||
"cpu": "cortex-m3",
|
||||
"mcu": "stm32l152rbt6",
|
||||
"variant": "stm32l1"
|
||||
},
|
||||
"name": "STM32LDiscovery (32 MHz) ultra low-power development kit",
|
||||
@ -37,7 +39,8 @@
|
||||
"extra_flags": "-DSTM32F303xC",
|
||||
"f_cpu": "72000000L",
|
||||
"ldscript": "stm32f30xx.ld",
|
||||
"mcu": "cortex-m4",
|
||||
"cpu": "cortex-m4",
|
||||
"mcu": "stm32f303vct6",
|
||||
"variant": "stm32f3"
|
||||
},
|
||||
"name": "STM32F3Discovery (72 MHz) with accelerometer, gyroscope and e-compass",
|
||||
|
@ -33,7 +33,8 @@
|
||||
"extra_flags": "-D__MK20DX128__",
|
||||
"f_cpu": "48000000L",
|
||||
"ldscript": "mk20dx128.ld",
|
||||
"mcu": "mk20dx128"
|
||||
"mcu": "mk20dx128",
|
||||
"cpu": "cortex-m4"
|
||||
},
|
||||
"name": "Teensy 3.0",
|
||||
"platform": "teensy",
|
||||
@ -49,7 +50,8 @@
|
||||
"extra_flags": "-D__MK20DX256__",
|
||||
"f_cpu": "72000000L",
|
||||
"ldscript": "mk20dx256.ld",
|
||||
"mcu": "mk20dx256"
|
||||
"mcu": "mk20dx256",
|
||||
"cpu": "cortex-m4"
|
||||
},
|
||||
"name": "Teensy 3.1",
|
||||
"platform": "teensy",
|
||||
|
@ -4,7 +4,8 @@
|
||||
"core": "lm4f",
|
||||
"f_cpu": "80000000L",
|
||||
"ldscript": "lm4fcpp_blizzard.ld",
|
||||
"mcu": "cortex-m4",
|
||||
"cpu": "cortex-m4",
|
||||
"mcu": "lplm4f120h5qr",
|
||||
"variant": "stellarpad"
|
||||
},
|
||||
"name": "LaunchPad (Stellaris) w/ lm4f120 (80MHz)",
|
||||
@ -19,7 +20,8 @@
|
||||
"core": "lm4f",
|
||||
"f_cpu": "80000000L",
|
||||
"ldscript": "lm4fcpp_blizzard.ld",
|
||||
"mcu": "cortex-m4",
|
||||
"cpu": "cortex-m4",
|
||||
"mcu": "lptm4c1230c3pm",
|
||||
"variant": "stellarpad"
|
||||
},
|
||||
"name": "LaunchPad (Tiva C) w/ tm4c123 (80MHz)",
|
||||
@ -34,7 +36,8 @@
|
||||
"core": "lm4f",
|
||||
"f_cpu": "120000000L",
|
||||
"ldscript": "lm4fcpp_snowflake.ld",
|
||||
"mcu": "cortex-m4",
|
||||
"cpu": "cortex-m4",
|
||||
"mcu": "lptm4c1294ncpdt",
|
||||
"variant": "launchpad_129"
|
||||
},
|
||||
"name": "LaunchPad (Tiva C) w/ tm4c129 (120MHz)",
|
||||
|
@ -89,6 +89,13 @@ if "BOARD" in env:
|
||||
if "UPLOAD_SPEED" not in env:
|
||||
env.Replace(
|
||||
UPLOAD_SPEED="${BOARD_OPTIONS['upload'].get('speed', None)}")
|
||||
if "ldscript" in env.get("BOARD_OPTIONS", {}).get("build", {}):
|
||||
env.Replace(
|
||||
LDSCRIPT_PATH=join(
|
||||
"$PIOHOME_DIR", "packages", "ldscripts",
|
||||
"${BOARD_OPTIONS['build']['ldscript']}"
|
||||
)
|
||||
)
|
||||
|
||||
if "IGNORE_LIBS" in env:
|
||||
env['IGNORE_LIBS'] = [l.strip() for l in env['IGNORE_LIBS'].split(",")]
|
||||
|
@ -8,108 +8,11 @@
|
||||
from os.path import join
|
||||
from time import sleep
|
||||
|
||||
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Builder, Default,
|
||||
DefaultEnvironment, Exit)
|
||||
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default,
|
||||
DefaultEnvironment, Exit, SConscript)
|
||||
|
||||
from platformio.util import get_serialports
|
||||
|
||||
env = DefaultEnvironment()
|
||||
|
||||
env.Replace(
|
||||
AR="avr-ar",
|
||||
AS="avr-gcc",
|
||||
CC="avr-gcc",
|
||||
CXX="avr-g++",
|
||||
OBJCOPY="avr-objcopy",
|
||||
RANLIB="avr-ranlib",
|
||||
SIZETOOL="avr-size",
|
||||
|
||||
ARFLAGS=["rcs"],
|
||||
|
||||
ASFLAGS=[
|
||||
"-c",
|
||||
"-g", # include debugging info (so errors include line numbers)
|
||||
"-x", "assembler-with-cpp",
|
||||
"-mmcu=$BOARD_MCU"
|
||||
],
|
||||
|
||||
CCFLAGS=[
|
||||
"-g", # include debugging info (so errors include line numbers)
|
||||
"-Os", # optimize for size
|
||||
# "-Wall", # show warnings
|
||||
"-ffunction-sections", # place each function in its own section
|
||||
"-fdata-sections",
|
||||
"-MMD", # output dependency info
|
||||
"-mmcu=$BOARD_MCU"
|
||||
],
|
||||
|
||||
CXXFLAGS=[
|
||||
"-fno-exceptions",
|
||||
"-fno-threadsafe-statics"
|
||||
],
|
||||
|
||||
CPPDEFINES=[
|
||||
"F_CPU=$BOARD_F_CPU"
|
||||
],
|
||||
|
||||
LINKFLAGS=[
|
||||
"-Os",
|
||||
"-mmcu=$BOARD_MCU",
|
||||
"-Wl,--gc-sections"
|
||||
],
|
||||
|
||||
SIZEPRINTCMD='"$SIZETOOL" --mcu=$BOARD_MCU -C -d $SOURCES',
|
||||
|
||||
UPLOADER=join("$PIOPACKAGES_DIR", "tool-avrdude", "avrdude"),
|
||||
UPLOADERFLAGS=[
|
||||
"-q", # suppress progress output
|
||||
"-D", # disable auto erase for flash memory
|
||||
"-p", "$BOARD_MCU",
|
||||
"-C",
|
||||
'"%s"' % join("$PIOPACKAGES_DIR", "tool-avrdude", "avrdude.conf"),
|
||||
"-c", "$UPLOAD_PROTOCOL"
|
||||
],
|
||||
UPLOADHEXCMD='"$UPLOADER" $UPLOADERFLAGS -U flash:w:$SOURCES:i',
|
||||
UPLOADEEPCMD='"$UPLOADER" $UPLOADERFLAGS -U eeprom:w:$SOURCES:i'
|
||||
)
|
||||
|
||||
if "UPLOAD_SPEED" in env:
|
||||
env.Append(UPLOADERFLAGS=["-b", "$UPLOAD_SPEED"])
|
||||
if env.subst("$UPLOAD_PROTOCOL") != "usbtiny":
|
||||
env.Append(UPLOADERFLAGS=["-P", "$UPLOAD_PORT"])
|
||||
|
||||
env.Append(
|
||||
BUILDERS=dict(
|
||||
ElfToEep=Builder(
|
||||
action=" ".join([
|
||||
"$OBJCOPY",
|
||||
"-O",
|
||||
"ihex",
|
||||
"-j",
|
||||
".eeprom",
|
||||
'--set-section-flags=.eeprom="alloc,load"',
|
||||
"--no-change-warnings",
|
||||
"--change-section-lma",
|
||||
".eeprom=0",
|
||||
"$SOURCES",
|
||||
"$TARGET"]),
|
||||
suffix=".eep"
|
||||
),
|
||||
|
||||
ElfToHex=Builder(
|
||||
action=" ".join([
|
||||
"$OBJCOPY",
|
||||
"-O",
|
||||
"ihex",
|
||||
"-R",
|
||||
".eeprom",
|
||||
"$SOURCES",
|
||||
"$TARGET"]),
|
||||
suffix=".hex"
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def before_upload(target, source, env): # pylint: disable=W0613,W0621
|
||||
|
||||
@ -155,13 +58,32 @@ def before_upload(target, source, env): # pylint: disable=W0613,W0621
|
||||
env.Replace(UPLOAD_PORT=env.WaitForNewSerialPort(before_ports))
|
||||
|
||||
|
||||
env = DefaultEnvironment()
|
||||
env = SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "baseavr.py")),
|
||||
exports="env")
|
||||
|
||||
env.Replace(
|
||||
UPLOADER=join("$PIOPACKAGES_DIR", "tool-avrdude", "avrdude"),
|
||||
UPLOADERFLAGS=[
|
||||
"-q", # suppress progress output
|
||||
"-D", # disable auto erase for flash memory
|
||||
"-p", "$BOARD_MCU",
|
||||
"-C",
|
||||
'"%s"' % join("$PIOPACKAGES_DIR", "tool-avrdude", "avrdude.conf"),
|
||||
"-c", "$UPLOAD_PROTOCOL"
|
||||
],
|
||||
|
||||
UPLOADHEXCMD='"$UPLOADER" $UPLOADERFLAGS -U flash:w:$SOURCES:i',
|
||||
UPLOADEEPCMD='"$UPLOADER" $UPLOADERFLAGS -U eeprom:w:$SOURCES:i'
|
||||
)
|
||||
|
||||
CORELIBS = env.ProcessGeneral()
|
||||
|
||||
#
|
||||
# Target: Build executable and linkable firmware
|
||||
#
|
||||
|
||||
target_elf = env.BuildFirmware(CORELIBS + ["m"])
|
||||
target_elf = env.BuildFirmware(["m"] + CORELIBS)
|
||||
|
||||
#
|
||||
# Target: Extract EEPROM data (from EEMEM directive) to .eep file
|
||||
@ -175,9 +97,9 @@ target_eep = env.Alias("eep", env.ElfToEep(join("$BUILD_DIR", "firmware"),
|
||||
#
|
||||
|
||||
if "uploadlazy" in COMMAND_LINE_TARGETS:
|
||||
target_hex = join("$BUILD_DIR", "firmware.hex")
|
||||
target_firm = join("$BUILD_DIR", "firmware.hex")
|
||||
else:
|
||||
target_hex = env.ElfToHex(join("$BUILD_DIR", "firmware"), target_elf)
|
||||
target_firm = env.ElfToHex(join("$BUILD_DIR", "firmware"), target_elf)
|
||||
|
||||
#
|
||||
# Target: Print binary size
|
||||
@ -190,7 +112,7 @@ AlwaysBuild(target_size)
|
||||
# Target: Upload by default .hex file
|
||||
#
|
||||
|
||||
upload = env.Alias(["upload", "uploadlazy"], target_hex, [
|
||||
upload = env.Alias(["upload", "uploadlazy"], target_firm, [
|
||||
before_upload, "$UPLOADHEXCMD"])
|
||||
AlwaysBuild(upload)
|
||||
|
||||
@ -206,4 +128,4 @@ AlwaysBuild(uploadeep)
|
||||
# Setup default targets
|
||||
#
|
||||
|
||||
Default([target_hex, target_size])
|
||||
Default([target_firm, target_size])
|
||||
|
@ -7,69 +7,16 @@
|
||||
|
||||
from os.path import join
|
||||
|
||||
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Builder, Default,
|
||||
DefaultEnvironment)
|
||||
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default,
|
||||
DefaultEnvironment, SConscript)
|
||||
|
||||
from platformio.util import get_serialports
|
||||
|
||||
env = DefaultEnvironment()
|
||||
env = SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py")),
|
||||
exports="env")
|
||||
|
||||
env.Replace(
|
||||
AR="arm-none-eabi-ar",
|
||||
AS="arm-none-eabi-gcc",
|
||||
CC="arm-none-eabi-gcc",
|
||||
CXX="arm-none-eabi-g++",
|
||||
OBJCOPY="arm-none-eabi-objcopy",
|
||||
RANLIB="arm-none-eabi-ranlib",
|
||||
SIZETOOL="arm-none-eabi-size",
|
||||
|
||||
ARFLAGS=["rcs"],
|
||||
|
||||
ASFLAGS=[
|
||||
"-c",
|
||||
"-g", # include debugging info (so errors include line numbers)
|
||||
"-x", "assembler-with-cpp",
|
||||
"-Wall",
|
||||
"-mthumb",
|
||||
"-mcpu=${BOARD_OPTIONS['build']['mcu']}"
|
||||
],
|
||||
|
||||
CPPFLAGS=[
|
||||
"-g", # include debugging info (so errors include line numbers)
|
||||
"-Os", # optimize for size
|
||||
"-fdata-sections",
|
||||
"-ffunction-sections", # place each function in its own section
|
||||
"-Wall",
|
||||
"-MMD", # output dependancy info
|
||||
"-mcpu=${BOARD_OPTIONS['build']['mcu']}",
|
||||
"-mthumb",
|
||||
"-ffunction-sections", # place each function in its own section
|
||||
"-fdata-sections",
|
||||
"-nostdlib"
|
||||
],
|
||||
|
||||
CXXFLAGS=[
|
||||
"-fno-rtti",
|
||||
"-felide-constructors",
|
||||
"-fno-exceptions"
|
||||
],
|
||||
|
||||
CPPDEFINES=[
|
||||
"F_CPU=$BOARD_F_CPU",
|
||||
"printf=iprintf"
|
||||
],
|
||||
|
||||
LINKFLAGS=[
|
||||
"-Os",
|
||||
"-Wl,--gc-sections",
|
||||
"-mcpu=${BOARD_OPTIONS['build']['mcu']}",
|
||||
"-mthumb",
|
||||
"-Wl,--entry=Reset_Handler",
|
||||
"-Wl,--start-group"
|
||||
],
|
||||
|
||||
SIZEPRINTCMD='"$SIZETOOL" -B -d $SOURCES',
|
||||
|
||||
UPLOADER=join("$PIOPACKAGES_DIR", "$PIOPACKAGE_UPLOADER", "bossac"),
|
||||
UPLOADERFLAGS=[
|
||||
"--info",
|
||||
@ -84,17 +31,14 @@ env.Replace(
|
||||
)
|
||||
|
||||
env.Append(
|
||||
BUILDERS=dict(
|
||||
ElfToBin=Builder(
|
||||
action=" ".join([
|
||||
"$OBJCOPY",
|
||||
"-O",
|
||||
"binary",
|
||||
"$SOURCES",
|
||||
"$TARGET"]),
|
||||
suffix=".bin"
|
||||
)
|
||||
)
|
||||
CPPDEFINES=[
|
||||
"printf=iprintf"
|
||||
],
|
||||
|
||||
LINKFLAGS=[
|
||||
"-Wl,--entry=Reset_Handler",
|
||||
"-Wl,--start-group"
|
||||
]
|
||||
)
|
||||
|
||||
CORELIBS = env.ProcessGeneral()
|
||||
@ -103,16 +47,16 @@ CORELIBS = env.ProcessGeneral()
|
||||
# Target: Build executable and linkable firmware
|
||||
#
|
||||
|
||||
target_elf = env.BuildFirmware(CORELIBS + ["m", "gcc"])
|
||||
target_elf = env.BuildFirmware(["m", "gcc"] + CORELIBS)
|
||||
|
||||
#
|
||||
# Target: Build the .bin file
|
||||
#
|
||||
|
||||
if "uploadlazy" in COMMAND_LINE_TARGETS:
|
||||
target_bin = join("$BUILD_DIR", "firmware.bin")
|
||||
target_firmware = join("$BUILD_DIR", "firmware.bin")
|
||||
else:
|
||||
target_bin = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf)
|
||||
target_firmware = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf)
|
||||
|
||||
#
|
||||
# Target: Print binary size
|
||||
@ -125,7 +69,8 @@ AlwaysBuild(target_size)
|
||||
# Target: Upload by default .bin file
|
||||
#
|
||||
|
||||
upload = env.Alias(["upload", "uploadlazy"], target_bin, ("$UPLOADBINCMD"))
|
||||
upload = env.Alias(
|
||||
["upload", "uploadlazy"], target_firmware, ("$UPLOADBINCMD"))
|
||||
AlwaysBuild(upload)
|
||||
|
||||
#
|
||||
@ -151,4 +96,4 @@ if is_uptarget:
|
||||
# Setup default targets
|
||||
#
|
||||
|
||||
Default([target_bin, target_size])
|
||||
Default([target_firmware, target_size])
|
||||
|
97
platformio/builder/scripts/basearm.py
Normal file
97
platformio/builder/scripts/basearm.py
Normal file
@ -0,0 +1,97 @@
|
||||
# Copyright (C) Ivan Kravets <me@ikravets.com>
|
||||
# See LICENSE for details.
|
||||
|
||||
"""
|
||||
Base for ARM microcontrollers.
|
||||
"""
|
||||
|
||||
from SCons.Script import Builder, Import, Return
|
||||
|
||||
env = None
|
||||
Import("env")
|
||||
|
||||
env.Replace(
|
||||
AR="arm-none-eabi-ar",
|
||||
AS="arm-none-eabi-gcc",
|
||||
CC="arm-none-eabi-gcc",
|
||||
CXX="arm-none-eabi-g++",
|
||||
OBJCOPY="arm-none-eabi-objcopy",
|
||||
RANLIB="arm-none-eabi-ranlib",
|
||||
SIZETOOL="arm-none-eabi-size",
|
||||
|
||||
ARFLAGS=["rcs"],
|
||||
|
||||
ASFLAGS=[
|
||||
"-c",
|
||||
"-g", # include debugging info (so errors include line numbers)
|
||||
"-x", "assembler-with-cpp",
|
||||
"-Wall",
|
||||
"-mthumb",
|
||||
"-mcpu=${BOARD_OPTIONS['build']['cpu']}"
|
||||
],
|
||||
|
||||
CPPFLAGS=[
|
||||
"-g", # include debugging info (so errors include line numbers)
|
||||
"-Os", # optimize for size
|
||||
"-ffunction-sections", # place each function in its own section
|
||||
"-fdata-sections",
|
||||
"-Wall",
|
||||
"-mthumb",
|
||||
"-mcpu=${BOARD_OPTIONS['build']['cpu']}",
|
||||
"-nostdlib",
|
||||
"-MMD" # output dependancy info
|
||||
],
|
||||
|
||||
CXXFLAGS=[
|
||||
"-fno-rtti",
|
||||
"-fno-exceptions"
|
||||
],
|
||||
|
||||
CPPDEFINES=[
|
||||
"F_CPU=$BOARD_F_CPU"
|
||||
],
|
||||
|
||||
LINKFLAGS=[
|
||||
"-Os",
|
||||
"-Wl,--gc-sections",
|
||||
"-mthumb",
|
||||
"-mcpu=${BOARD_OPTIONS['build']['cpu']}"
|
||||
],
|
||||
|
||||
SIZEPRINTCMD='"$SIZETOOL" -B -d $SOURCES'
|
||||
)
|
||||
|
||||
if env.get("BOARD_OPTIONS", {}).get("build", {}).get("cpu")[-2:] == "m4":
|
||||
env.Append(
|
||||
ASFLAGS=[
|
||||
"-mfloat-abi=hard",
|
||||
"-mfpu=fpv4-sp-d16",
|
||||
"-fsingle-precision-constant"
|
||||
],
|
||||
CCFLAGS=[
|
||||
"-mfloat-abi=hard",
|
||||
"-mfpu=fpv4-sp-d16",
|
||||
"-fsingle-precision-constant"
|
||||
],
|
||||
LINKFLAGS=[
|
||||
"-mfloat-abi=hard",
|
||||
"-mfpu=fpv4-sp-d16",
|
||||
"-fsingle-precision-constant"
|
||||
]
|
||||
)
|
||||
|
||||
env.Append(
|
||||
BUILDERS=dict(
|
||||
ElfToBin=Builder(
|
||||
action=" ".join([
|
||||
"$OBJCOPY",
|
||||
"-O",
|
||||
"binary",
|
||||
"$SOURCES",
|
||||
"$TARGET"]),
|
||||
suffix=".bin"
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
Return("env")
|
96
platformio/builder/scripts/baseavr.py
Normal file
96
platformio/builder/scripts/baseavr.py
Normal file
@ -0,0 +1,96 @@
|
||||
# Copyright (C) Ivan Kravets <me@ikravets.com>
|
||||
# See LICENSE for details.
|
||||
|
||||
"""
|
||||
Base for Atmel AVR series of microcontrollers
|
||||
"""
|
||||
|
||||
from SCons.Script import Builder, Import, Return
|
||||
|
||||
env = None
|
||||
Import("env")
|
||||
|
||||
env.Replace(
|
||||
AR="avr-ar",
|
||||
AS="avr-gcc",
|
||||
CC="avr-gcc",
|
||||
CXX="avr-g++",
|
||||
OBJCOPY="avr-objcopy",
|
||||
RANLIB="avr-ranlib",
|
||||
SIZETOOL="avr-size",
|
||||
|
||||
ARFLAGS=["rcs"],
|
||||
|
||||
ASFLAGS=[
|
||||
"-c",
|
||||
"-g", # include debugging info (so errors include line numbers)
|
||||
"-x", "assembler-with-cpp",
|
||||
"-mmcu=$BOARD_MCU"
|
||||
],
|
||||
|
||||
CCFLAGS=[
|
||||
"-g", # include debugging info (so errors include line numbers)
|
||||
"-Os", # optimize for size
|
||||
"-Wall", # show warnings
|
||||
"-ffunction-sections", # place each function in its own section
|
||||
"-fdata-sections",
|
||||
"-MMD", # output dependency info
|
||||
"-mmcu=$BOARD_MCU"
|
||||
],
|
||||
|
||||
CXXFLAGS=[
|
||||
"-fno-exceptions",
|
||||
"-fno-threadsafe-statics"
|
||||
],
|
||||
|
||||
CPPDEFINES=[
|
||||
"F_CPU=$BOARD_F_CPU"
|
||||
],
|
||||
|
||||
LINKFLAGS=[
|
||||
"-Os",
|
||||
"-mmcu=$BOARD_MCU",
|
||||
"-Wl,--gc-sections"
|
||||
],
|
||||
|
||||
SIZEPRINTCMD='"$SIZETOOL" --mcu=$BOARD_MCU -C -d $SOURCES'
|
||||
)
|
||||
|
||||
if "UPLOAD_SPEED" in env:
|
||||
env.Append(UPLOADERFLAGS=["-b", "$UPLOAD_SPEED"])
|
||||
if env.subst("$UPLOAD_PROTOCOL") != "usbtiny":
|
||||
env.Append(UPLOADERFLAGS=["-P", "$UPLOAD_PORT"])
|
||||
|
||||
env.Append(
|
||||
BUILDERS=dict(
|
||||
ElfToEep=Builder(
|
||||
action=" ".join([
|
||||
"$OBJCOPY",
|
||||
"-O",
|
||||
"ihex",
|
||||
"-j",
|
||||
".eeprom",
|
||||
'--set-section-flags=.eeprom="alloc,load"',
|
||||
"--no-change-warnings",
|
||||
"--change-section-lma",
|
||||
".eeprom=0",
|
||||
"$SOURCES",
|
||||
"$TARGET"]),
|
||||
suffix=".eep"
|
||||
),
|
||||
|
||||
ElfToHex=Builder(
|
||||
action=" ".join([
|
||||
"$OBJCOPY",
|
||||
"-O",
|
||||
"ihex",
|
||||
"-R",
|
||||
".eeprom",
|
||||
"$SOURCES",
|
||||
"$TARGET"]),
|
||||
suffix=".hex"
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
Return("env")
|
@ -7,129 +7,16 @@
|
||||
|
||||
from os.path import join
|
||||
|
||||
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Builder, Default,
|
||||
DefaultEnvironment)
|
||||
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default,
|
||||
DefaultEnvironment, SConscript)
|
||||
|
||||
env = DefaultEnvironment()
|
||||
|
||||
if env.get("BOARD_OPTIONS", {}).get("build", {}).get("mcu") != "cortex-m3":
|
||||
if "cortex" in env.get("BOARD_OPTIONS").get("build").get("cpu", ""):
|
||||
env = SConscript(
|
||||
env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py")),
|
||||
exports="env")
|
||||
env.Replace(
|
||||
AR="avr-ar",
|
||||
AS="avr-gcc",
|
||||
CC="avr-gcc",
|
||||
CXX="avr-g++",
|
||||
OBJCOPY="avr-objcopy",
|
||||
RANLIB="avr-ranlib",
|
||||
SIZETOOL="avr-size",
|
||||
|
||||
ARFLAGS=["rcs"],
|
||||
|
||||
CPPFLAGS=[
|
||||
"-mmcu=$BOARD_MCU"
|
||||
],
|
||||
|
||||
LINKFLAGS=[
|
||||
"-mmcu=$BOARD_MCU"
|
||||
],
|
||||
|
||||
SIZEPRINTCMD='"$SIZETOOL" --mcu=$BOARD_MCU -C -d $SOURCES'
|
||||
)
|
||||
|
||||
else:
|
||||
env.Replace(
|
||||
AR="arm-none-eabi-ar",
|
||||
AS="arm-none-eabi-gcc",
|
||||
CC="arm-none-eabi-gcc",
|
||||
CXX="arm-none-eabi-g++",
|
||||
OBJCOPY="arm-none-eabi-objcopy",
|
||||
RANLIB="arm-none-eabi-ranlib",
|
||||
SIZETOOL="arm-none-eabi-size",
|
||||
|
||||
ARFLAGS=["rcs"],
|
||||
|
||||
ASFLAGS=[
|
||||
"-mcpu=${BOARD_OPTIONS['build']['mcu']}",
|
||||
"-mthumb"
|
||||
# "-nostdlib"
|
||||
],
|
||||
|
||||
CXXFLAGS=[
|
||||
"-fno-rtti",
|
||||
],
|
||||
|
||||
CPPFLAGS=[
|
||||
"-mcpu=${BOARD_OPTIONS['build']['mcu']}",
|
||||
"-mthumb",
|
||||
"-ffunction-sections", # place each function in its own section
|
||||
"-fdata-sections"
|
||||
# "-nostdlib"
|
||||
],
|
||||
|
||||
CPPDEFINES=[
|
||||
"printf=iprintf"
|
||||
],
|
||||
|
||||
LINKFLAGS=[
|
||||
"-mcpu=cortex-m3",
|
||||
"-mthumb",
|
||||
"-Wl,--gc-sections",
|
||||
"-Wl,--entry=Reset_Handler"
|
||||
# "-nostartfiles",
|
||||
# "-nostdlib",
|
||||
],
|
||||
|
||||
SIZEPRINTCMD='"$SIZETOOL" -B -d $SOURCES'
|
||||
)
|
||||
|
||||
env.Append(
|
||||
BUILDERS=dict(
|
||||
ElfToHex=Builder(
|
||||
action=" ".join([
|
||||
"$OBJCOPY",
|
||||
"-O",
|
||||
"ihex",
|
||||
"-R",
|
||||
".eeprom",
|
||||
"$SOURCES",
|
||||
"$TARGET"]),
|
||||
suffix=".hex"
|
||||
)
|
||||
),
|
||||
|
||||
ASFLAGS=[
|
||||
"-c",
|
||||
"-g", # include debugging info (so errors include line numbers)
|
||||
"-x", "assembler-with-cpp",
|
||||
"-Wall"
|
||||
],
|
||||
|
||||
CPPFLAGS=[
|
||||
"-g", # include debugging info (so errors include line numbers)
|
||||
"-Os", # optimize for size
|
||||
"-fdata-sections",
|
||||
"-ffunction-sections", # place each function in its own section
|
||||
"-Wall",
|
||||
"-MMD" # output dependancy info
|
||||
],
|
||||
|
||||
CPPDEFINES=[
|
||||
"F_CPU=$BOARD_F_CPU"
|
||||
],
|
||||
|
||||
CXXFLAGS=[
|
||||
"-felide-constructors",
|
||||
"-fno-exceptions"
|
||||
],
|
||||
|
||||
LINKFLAGS=[
|
||||
"-Os",
|
||||
"-Wl,--start-group"
|
||||
|
||||
]
|
||||
)
|
||||
|
||||
if env.get("BOARD_OPTIONS", {}).get("build", {}).get("mcu") == "cortex-m3":
|
||||
env.Append(
|
||||
UPLOADER=join("$PIOPACKAGES_DIR", "$PIOPACKAGE_UPLOADER", "bossac"),
|
||||
UPLOADERFLAGS=[
|
||||
"--info",
|
||||
@ -142,8 +29,21 @@ if env.get("BOARD_OPTIONS", {}).get("build", {}).get("mcu") == "cortex-m3":
|
||||
],
|
||||
UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS $SOURCES'
|
||||
)
|
||||
else:
|
||||
|
||||
env.Append(
|
||||
CPPDEFINES=[
|
||||
"printf=iprintf"
|
||||
],
|
||||
|
||||
LINKFLAGS=[
|
||||
"-Wl,--entry=Reset_Handler",
|
||||
"-Wl,--start-group"
|
||||
]
|
||||
)
|
||||
else:
|
||||
env = SConscript(env.subst(
|
||||
join("$PIOBUILDER_DIR", "scripts", "baseavr.py")), exports="env")
|
||||
env.Replace(
|
||||
UPLOADER=join("$PIOPACKAGES_DIR", "tool-avrdude", "avrdude"),
|
||||
UPLOADERFLAGS=[
|
||||
"-q", # suppress progress output
|
||||
@ -164,16 +64,22 @@ CORELIBS = env.ProcessGeneral()
|
||||
# Target: Build executable and linkable firmware
|
||||
#
|
||||
|
||||
target_elf = env.BuildFirmware(CORELIBS + ["m"])
|
||||
target_elf = env.BuildFirmware(["m"] + CORELIBS)
|
||||
|
||||
#
|
||||
# Target: Build the .hex file
|
||||
# Target: Build the firmware file
|
||||
#
|
||||
|
||||
if "uploadlazy" in COMMAND_LINE_TARGETS:
|
||||
target_hex = join("$BUILD_DIR", "firmware.hex")
|
||||
if "cortex" in env.get("BOARD_OPTIONS").get("build").get("cpu", ""):
|
||||
if "uploadlazy" in COMMAND_LINE_TARGETS:
|
||||
target_firm = join("$BUILD_DIR", "firmware.bin")
|
||||
else:
|
||||
target_firm = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf)
|
||||
else:
|
||||
target_hex = env.ElfToHex(join("$BUILD_DIR", "firmware"), target_elf)
|
||||
if "uploadlazy" in COMMAND_LINE_TARGETS:
|
||||
target_firm = join("$BUILD_DIR", "firmware.hex")
|
||||
else:
|
||||
target_firm = env.ElfToHex(join("$BUILD_DIR", "firmware"), target_elf)
|
||||
|
||||
#
|
||||
# Target: Print binary size
|
||||
@ -183,14 +89,14 @@ target_size = env.Alias("size", target_elf, "$SIZEPRINTCMD")
|
||||
AlwaysBuild(target_size)
|
||||
|
||||
#
|
||||
# Target: Upload by default .hex file
|
||||
# Target: Upload by default firmware file
|
||||
#
|
||||
|
||||
upload = env.Alias(["upload", "uploadlazy"], target_hex, ("$UPLOADCMD"))
|
||||
upload = env.Alias(["upload", "uploadlazy"], target_firm, ("$UPLOADCMD"))
|
||||
AlwaysBuild(upload)
|
||||
|
||||
#
|
||||
# Target: Define targets
|
||||
#
|
||||
|
||||
Default([target_hex, target_size])
|
||||
Default([target_firm, target_size])
|
||||
|
@ -28,7 +28,7 @@ if env.get("PLATFORM") == "digistump":
|
||||
PLATFORMFW_DIR = join(
|
||||
"$PIOPACKAGES_DIR",
|
||||
"framework-arduino%s" % (
|
||||
"sam" if BOARD_BUILDOPTS.get("mcu") == "cortex-m3" else "avr")
|
||||
"sam" if BOARD_BUILDOPTS.get("cpu") == "cortex-m3" else "avr")
|
||||
)
|
||||
|
||||
env.Replace(PLATFORMFW_DIR=PLATFORMFW_DIR)
|
||||
@ -98,12 +98,6 @@ if env.subst("${PLATFORMFW_DIR}")[-3:] == "sam":
|
||||
join("$BUILD_DIR", "FrameworkDeviceInc", "sam3xa", "include")
|
||||
]
|
||||
)
|
||||
env.Append(
|
||||
LINKFLAGS=[
|
||||
"-T", join("$PIOHOME_DIR", "packages", "ldscripts",
|
||||
"${BOARD_OPTIONS['build']['ldscript']}")
|
||||
]
|
||||
)
|
||||
|
||||
# search relative includes in lib SAM directories
|
||||
core_dir = join(env.subst("$PLATFORMFW_DIR"), "system", "libsam")
|
||||
|
@ -154,8 +154,10 @@ merge_ld_scripts(ldscript_path)
|
||||
generate_nvic_files()
|
||||
|
||||
# override ldscript by opencm3
|
||||
assert "-T" in env['LINKFLAGS']
|
||||
env['LINKFLAGS'][env['LINKFLAGS'].index("-T") + 1] = ldscript_path
|
||||
assert "LDSCRIPT_PATH" in env
|
||||
env.Replace(
|
||||
LDSCRIPT_PATH=ldscript_path
|
||||
)
|
||||
|
||||
libs = []
|
||||
env.VariantDir(
|
||||
|
@ -8,63 +8,14 @@
|
||||
|
||||
from os.path import join
|
||||
|
||||
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Builder, Default,
|
||||
DefaultEnvironment)
|
||||
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default,
|
||||
DefaultEnvironment, SConscript)
|
||||
|
||||
env = DefaultEnvironment()
|
||||
env = SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py")),
|
||||
exports="env")
|
||||
|
||||
env.Replace(
|
||||
AR="arm-none-eabi-ar",
|
||||
AS="arm-none-eabi-gcc",
|
||||
CC="arm-none-eabi-gcc",
|
||||
CXX="arm-none-eabi-g++",
|
||||
OBJCOPY="arm-none-eabi-objcopy",
|
||||
RANLIB="arm-none-eabi-ranlib",
|
||||
SIZETOOL="arm-none-eabi-size",
|
||||
|
||||
ARFLAGS=["rcs"],
|
||||
|
||||
ASFLAGS=[
|
||||
"-c",
|
||||
"-g", # include debugging info (so errors include line numbers)
|
||||
"-x", "assembler-with-cpp",
|
||||
"-Wall",
|
||||
"-mthumb",
|
||||
"-mcpu=${BOARD_OPTIONS['build']['mcu']}"
|
||||
],
|
||||
|
||||
CCFLAGS=[
|
||||
"-g", # include debugging info (so errors include line numbers)
|
||||
"-Os", # optimize for size
|
||||
"-ffunction-sections", # place each function in its own section
|
||||
"-fdata-sections",
|
||||
"-Wall",
|
||||
"-mthumb",
|
||||
"-mcpu=${BOARD_OPTIONS['build']['mcu']}",
|
||||
"-MMD" # output dependancy info
|
||||
],
|
||||
|
||||
CXXFLAGS=[
|
||||
"-fno-rtti",
|
||||
"-fno-exceptions"
|
||||
],
|
||||
|
||||
CPPDEFINES=[
|
||||
"F_CPU=$BOARD_F_CPU",
|
||||
"${BOARD_OPTIONS['build']['variant'].upper()}"
|
||||
],
|
||||
|
||||
LINKFLAGS=[
|
||||
"-Os",
|
||||
"-nostartfiles",
|
||||
"-nostdlib",
|
||||
"-Wl,--gc-sections",
|
||||
"-mthumb",
|
||||
"-mcpu=${BOARD_OPTIONS['build']['mcu']}"
|
||||
],
|
||||
|
||||
SIZEPRINTCMD='"$SIZETOOL" -B -d $SOURCES',
|
||||
|
||||
UPLOADER=join("$PIOPACKAGES_DIR", "tool-stlink", "st-flash"),
|
||||
UPLOADERFLAGS=[
|
||||
"write", # write in flash
|
||||
@ -75,37 +26,16 @@ env.Replace(
|
||||
UPLOADCMD="$UPLOADER $UPLOADERFLAGS"
|
||||
)
|
||||
|
||||
if env.get("BOARD_OPTIONS", {}).get("build", {}).get("mcu")[-2:] == "m4":
|
||||
env.Append(
|
||||
ASFLAGS=[
|
||||
"-mfloat-abi=hard",
|
||||
"-mfpu=fpv4-sp-d16",
|
||||
"-fsingle-precision-constant"
|
||||
],
|
||||
CCFLAGS=[
|
||||
"-mfloat-abi=hard",
|
||||
"-mfpu=fpv4-sp-d16",
|
||||
"-fsingle-precision-constant"
|
||||
],
|
||||
LINKFLAGS=[
|
||||
"-mfloat-abi=hard",
|
||||
"-mfpu=fpv4-sp-d16",
|
||||
"-fsingle-precision-constant"
|
||||
]
|
||||
)
|
||||
|
||||
env.Append(
|
||||
BUILDERS=dict(
|
||||
ElfToBin=Builder(
|
||||
action=" ".join([
|
||||
"$OBJCOPY",
|
||||
"-O",
|
||||
"binary",
|
||||
"$SOURCES",
|
||||
"$TARGET"]),
|
||||
suffix=".bin"
|
||||
)
|
||||
)
|
||||
CPPDEFINES=[
|
||||
"${BOARD_OPTIONS['build']['variant'].upper()}"
|
||||
],
|
||||
|
||||
LINKFLAGS=[
|
||||
"-nostartfiles",
|
||||
"-nostdlib"
|
||||
]
|
||||
)
|
||||
|
||||
CORELIBS = env.ProcessGeneral()
|
||||
@ -114,16 +44,16 @@ CORELIBS = env.ProcessGeneral()
|
||||
# Target: Build executable and linkable firmware
|
||||
#
|
||||
|
||||
target_elf = env.BuildFirmware(CORELIBS + ["c", "gcc", "m", "nosys"])
|
||||
target_elf = env.BuildFirmware(["c", "gcc", "m", "nosys"] + CORELIBS)
|
||||
|
||||
#
|
||||
# Target: Build the .bin file
|
||||
#
|
||||
|
||||
if "uploadlazy" in COMMAND_LINE_TARGETS:
|
||||
target_bin = join("$BUILD_DIR", "firmware.bin")
|
||||
target_firm = join("$BUILD_DIR", "firmware.bin")
|
||||
else:
|
||||
target_bin = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf)
|
||||
target_firm = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf)
|
||||
|
||||
#
|
||||
# Target: Print binary size
|
||||
@ -136,11 +66,11 @@ AlwaysBuild(target_size)
|
||||
# Target: Upload by default .bin file
|
||||
#
|
||||
|
||||
upload = env.Alias(["upload", "uploadlazy"], target_bin, ("$UPLOADCMD"))
|
||||
upload = env.Alias(["upload", "uploadlazy"], target_firm, ("$UPLOADCMD"))
|
||||
AlwaysBuild(upload)
|
||||
|
||||
#
|
||||
# Target: Define targets
|
||||
#
|
||||
|
||||
Default([target_bin, target_size])
|
||||
Default([target_firm, target_size])
|
||||
|
@ -7,113 +7,21 @@
|
||||
|
||||
from os.path import isfile, join
|
||||
|
||||
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Builder, Default,
|
||||
DefaultEnvironment)
|
||||
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default,
|
||||
DefaultEnvironment, SConscript)
|
||||
|
||||
env = DefaultEnvironment()
|
||||
|
||||
if env.get("BOARD_OPTIONS", {}).get("build", {}).get("core") == "teensy":
|
||||
env.Replace(
|
||||
AR="avr-ar",
|
||||
AS="avr-gcc",
|
||||
CC="avr-gcc",
|
||||
CXX="avr-g++",
|
||||
OBJCOPY="avr-objcopy",
|
||||
RANLIB="avr-ranlib",
|
||||
SIZETOOL="avr-size",
|
||||
|
||||
ARFLAGS=["rcs"],
|
||||
|
||||
CXXFLAGS=[
|
||||
"-std=c++0x"
|
||||
],
|
||||
|
||||
CPPFLAGS=[
|
||||
"-mmcu=$BOARD_MCU"
|
||||
],
|
||||
|
||||
LINKFLAGS=[
|
||||
"-mmcu=$BOARD_MCU"
|
||||
],
|
||||
|
||||
SIZEPRINTCMD='"$SIZETOOL" --mcu=$BOARD_MCU -C -d $SOURCES'
|
||||
)
|
||||
env = SConscript(env.subst(
|
||||
join("$PIOBUILDER_DIR", "scripts", "baseavr.py")), exports="env")
|
||||
|
||||
elif env.get("BOARD_OPTIONS", {}).get("build", {}).get("core") == "teensy3":
|
||||
env.Replace(
|
||||
AR="arm-none-eabi-ar",
|
||||
AS="arm-none-eabi-gcc",
|
||||
CC="arm-none-eabi-gcc",
|
||||
CXX="arm-none-eabi-g++",
|
||||
OBJCOPY="arm-none-eabi-objcopy",
|
||||
RANLIB="arm-none-eabi-ranlib",
|
||||
SIZETOOL="arm-none-eabi-size",
|
||||
|
||||
ARFLAGS=["rcs"],
|
||||
|
||||
ASFLAGS=[
|
||||
"-mcpu=cortex-m4",
|
||||
"-mthumb",
|
||||
# "-nostdlib"
|
||||
],
|
||||
|
||||
CXXFLAGS=[
|
||||
"-std=gnu++0x",
|
||||
"-fno-rtti",
|
||||
],
|
||||
|
||||
CPPFLAGS=[
|
||||
"-mcpu=cortex-m4",
|
||||
"-mthumb",
|
||||
"-ffunction-sections", # place each function in its own section
|
||||
"-fdata-sections",
|
||||
# "-nostdlib"
|
||||
],
|
||||
|
||||
LINKFLAGS=[
|
||||
"-mcpu=cortex-m4",
|
||||
"-mthumb",
|
||||
"-Wl,--gc-sections",
|
||||
# "-nostartfiles",
|
||||
# "-nostdlib",
|
||||
],
|
||||
|
||||
SIZEPRINTCMD='"$SIZETOOL" -B -d $SOURCES'
|
||||
)
|
||||
env = SConscript(env.subst(
|
||||
join("$PIOBUILDER_DIR", "scripts", "basearm.py")), exports="env")
|
||||
|
||||
env.Append(
|
||||
BUILDERS=dict(
|
||||
ElfToHex=Builder(
|
||||
action=" ".join([
|
||||
"$OBJCOPY",
|
||||
"-O",
|
||||
"ihex",
|
||||
"-R",
|
||||
".eeprom",
|
||||
"$SOURCES",
|
||||
"$TARGET"]),
|
||||
suffix=".hex"
|
||||
)
|
||||
),
|
||||
|
||||
ASFLAGS=[
|
||||
"-c",
|
||||
"-g", # include debugging info (so errors include line numbers)
|
||||
"-x", "assembler-with-cpp",
|
||||
"-Wall"
|
||||
],
|
||||
|
||||
CPPFLAGS=[
|
||||
"-g", # include debugging info (so errors include line numbers)
|
||||
"-Os", # optimize for size
|
||||
"-fdata-sections",
|
||||
"-ffunction-sections", # place each function in its own section
|
||||
"-Wall",
|
||||
"-MMD" # output dependancy info
|
||||
],
|
||||
|
||||
CPPDEFINES=[
|
||||
"F_CPU=$BOARD_F_CPU",
|
||||
"USB_PID=null",
|
||||
"USB_VID=null",
|
||||
"USB_SERIAL",
|
||||
@ -121,19 +29,15 @@ env.Append(
|
||||
],
|
||||
|
||||
CXXFLAGS=[
|
||||
"-felide-constructors",
|
||||
"-fno-exceptions"
|
||||
],
|
||||
|
||||
LINKFLAGS=[
|
||||
"-Os"
|
||||
"-std=gnu++0x"
|
||||
]
|
||||
)
|
||||
|
||||
if isfile(env.subst(join(
|
||||
"$PIOPACKAGES_DIR", "tool-teensy", "teensy_loader_cli"))):
|
||||
env.Append(
|
||||
UPLOADER=join("$PIOPACKAGES_DIR", "tool-teensy", "teensy_loader_cli"),
|
||||
UPLOADER=join(
|
||||
"$PIOPACKAGES_DIR", "tool-teensy", "teensy_loader_cli"),
|
||||
UPLOADERFLAGS=[
|
||||
"-mmcu=$BOARD_MCU",
|
||||
"-w", # wait for device to apear
|
||||
@ -159,16 +63,22 @@ CORELIBS = env.ProcessGeneral()
|
||||
# Target: Build executable and linkable firmware
|
||||
#
|
||||
|
||||
target_elf = env.BuildFirmware(CORELIBS + ["m"])
|
||||
target_elf = env.BuildFirmware(["m"] + CORELIBS)
|
||||
|
||||
#
|
||||
# Target: Build the .hex file
|
||||
# Target: Build the firmware file
|
||||
#
|
||||
|
||||
if "uploadlazy" in COMMAND_LINE_TARGETS:
|
||||
target_hex = join("$BUILD_DIR", "firmware.hex")
|
||||
if "cortex" in env.get("BOARD_OPTIONS").get("build").get("cpu", ""):
|
||||
if "uploadlazy" in COMMAND_LINE_TARGETS:
|
||||
target_firm = join("$BUILD_DIR", "firmware.bin")
|
||||
else:
|
||||
target_firm = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf)
|
||||
else:
|
||||
target_hex = env.ElfToHex(join("$BUILD_DIR", "firmware"), target_elf)
|
||||
if "uploadlazy" in COMMAND_LINE_TARGETS:
|
||||
target_firm = join("$BUILD_DIR", "firmware.hex")
|
||||
else:
|
||||
target_firm = env.ElfToHex(join("$BUILD_DIR", "firmware"), target_elf)
|
||||
|
||||
#
|
||||
# Target: Print binary size
|
||||
@ -178,14 +88,14 @@ target_size = env.Alias("size", target_elf, "$SIZEPRINTCMD")
|
||||
AlwaysBuild(target_size)
|
||||
|
||||
#
|
||||
# Target: Upload by default .hex file
|
||||
# Target: Upload by default firmware file
|
||||
#
|
||||
|
||||
upload = env.Alias(["upload", "uploadlazy"], target_hex, ("$UPLOADHEXCMD"))
|
||||
upload = env.Alias(["upload", "uploadlazy"], target_firm, ("$UPLOADHEXCMD"))
|
||||
AlwaysBuild(upload)
|
||||
|
||||
#
|
||||
# Target: Define targets
|
||||
#
|
||||
|
||||
Default([target_hex, target_size])
|
||||
Default([target_firm, target_size])
|
||||
|
@ -85,16 +85,16 @@ CORELIBS = env.ProcessGeneral()
|
||||
# Target: Build executable and linkable firmware
|
||||
#
|
||||
|
||||
target_elf = env.BuildFirmware(CORELIBS + ["m"])
|
||||
target_elf = env.BuildFirmware(["m"] + CORELIBS)
|
||||
|
||||
#
|
||||
# Target: Build the .hex
|
||||
#
|
||||
|
||||
if "uploadlazy" in COMMAND_LINE_TARGETS:
|
||||
target_hex = join("$BUILD_DIR", "firmware.hex")
|
||||
target_frim = join("$BUILD_DIR", "firmware.hex")
|
||||
else:
|
||||
target_hex = env.ElfToHex(join("$BUILD_DIR", "firmware"), target_elf)
|
||||
target_frim = env.ElfToHex(join("$BUILD_DIR", "firmware"), target_elf)
|
||||
|
||||
#
|
||||
# Target: Print binary size
|
||||
@ -107,11 +107,11 @@ AlwaysBuild(target_size)
|
||||
# Target: Upload firmware
|
||||
#
|
||||
|
||||
upload = env.Alias(["upload", "uploadlazy"], target_hex, "$UPLOADCMD")
|
||||
upload = env.Alias(["upload", "uploadlazy"], target_frim, "$UPLOADCMD")
|
||||
AlwaysBuild(upload)
|
||||
|
||||
#
|
||||
# Target: Define targets
|
||||
#
|
||||
|
||||
Default([target_hex, target_size])
|
||||
Default([target_frim, target_size])
|
||||
|
@ -8,88 +8,23 @@
|
||||
|
||||
from os.path import join
|
||||
|
||||
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Builder, Default,
|
||||
DefaultEnvironment)
|
||||
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default,
|
||||
DefaultEnvironment, SConscript)
|
||||
|
||||
env = DefaultEnvironment()
|
||||
env = SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py")),
|
||||
exports="env")
|
||||
|
||||
env.Replace(
|
||||
AR="arm-none-eabi-ar",
|
||||
AS="arm-none-eabi-gcc",
|
||||
CC="arm-none-eabi-gcc",
|
||||
CXX="arm-none-eabi-g++",
|
||||
OBJCOPY="arm-none-eabi-objcopy",
|
||||
RANLIB="arm-none-eabi-ranlib",
|
||||
SIZETOOL="arm-none-eabi-size",
|
||||
|
||||
ARFLAGS=["rcs"],
|
||||
|
||||
ASFLAGS=[
|
||||
"-c",
|
||||
"-g", # include debugging info (so errors include line numbers)
|
||||
"-x", "assembler-with-cpp",
|
||||
"-Wall",
|
||||
"-mthumb",
|
||||
"-mcpu=cortex-m4",
|
||||
"-mfloat-abi=hard",
|
||||
"-mfpu=fpv4-sp-d16",
|
||||
"-fsingle-precision-constant"
|
||||
],
|
||||
|
||||
CCFLAGS=[
|
||||
"-g", # include debugging info (so errors include line numbers)
|
||||
"-Os", # optimize for size
|
||||
# "-Wall", # show warnings
|
||||
"-ffunction-sections", # place each function in its own section
|
||||
"-fdata-sections",
|
||||
"-Wall",
|
||||
"-mthumb",
|
||||
"-mcpu=cortex-m4",
|
||||
"-mfloat-abi=hard",
|
||||
"-mfpu=fpv4-sp-d16",
|
||||
"-fsingle-precision-constant",
|
||||
"-MMD" # output dependancy info
|
||||
],
|
||||
|
||||
CXXFLAGS=[
|
||||
"-fno-rtti",
|
||||
"-fno-exceptions"
|
||||
],
|
||||
|
||||
CPPDEFINES=[
|
||||
"F_CPU=$BOARD_F_CPU"
|
||||
],
|
||||
|
||||
LINKFLAGS=[
|
||||
"-Os",
|
||||
"-nostartfiles",
|
||||
"-nostdlib",
|
||||
"-Wl,--gc-sections",
|
||||
"-mthumb",
|
||||
"-mcpu=cortex-m4",
|
||||
"-mfloat-abi=hard",
|
||||
"-mfpu=fpv4-sp-d16",
|
||||
"-fsingle-precision-constant"
|
||||
],
|
||||
|
||||
SIZEPRINTCMD='"$SIZETOOL" -B -d $SOURCES',
|
||||
|
||||
UPLOADER=join("$PIOPACKAGES_DIR", "tool-lm4flash", "lm4flash"),
|
||||
UPLOADCMD="$UPLOADER $SOURCES"
|
||||
)
|
||||
|
||||
env.Append(
|
||||
BUILDERS=dict(
|
||||
ElfToBin=Builder(
|
||||
action=" ".join([
|
||||
"$OBJCOPY",
|
||||
"-O",
|
||||
"binary",
|
||||
"$SOURCES",
|
||||
"$TARGET"]),
|
||||
suffix=".bin"
|
||||
)
|
||||
)
|
||||
LINKFLAGS=[
|
||||
"-nostartfiles",
|
||||
"-nostdlib"
|
||||
]
|
||||
)
|
||||
|
||||
CORELIBS = env.ProcessGeneral()
|
||||
@ -98,16 +33,16 @@ CORELIBS = env.ProcessGeneral()
|
||||
# Target: Build executable and linkable firmware
|
||||
#
|
||||
|
||||
target_elf = env.BuildFirmware(CORELIBS + ["c", "gcc", "m"])
|
||||
target_elf = env.BuildFirmware(["c", "gcc", "m"] + CORELIBS)
|
||||
|
||||
#
|
||||
# Target: Build the .bin file
|
||||
#
|
||||
|
||||
if "uploadlazy" in COMMAND_LINE_TARGETS:
|
||||
target_bin = join("$BUILD_DIR", "firmware.bin")
|
||||
target_file = join("$BUILD_DIR", "firmware.bin")
|
||||
else:
|
||||
target_bin = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf)
|
||||
target_file = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf)
|
||||
|
||||
#
|
||||
# Target: Print binary size
|
||||
@ -120,11 +55,11 @@ AlwaysBuild(target_size)
|
||||
# Target: Upload firmware
|
||||
#
|
||||
|
||||
upload = env.Alias(["upload", "uploadlazy"], target_bin, "$UPLOADCMD")
|
||||
upload = env.Alias(["upload", "uploadlazy"], target_file, "$UPLOADCMD")
|
||||
AlwaysBuild(upload)
|
||||
|
||||
#
|
||||
# Target: Define targets
|
||||
#
|
||||
|
||||
Default([target_bin, target_size])
|
||||
Default([target_file, target_size])
|
||||
|
@ -15,20 +15,13 @@ from platformio.util import get_serialports
|
||||
|
||||
|
||||
def ProcessGeneral(env):
|
||||
corelibs = []
|
||||
# specific linker script
|
||||
if "ldscript" in env.get("BOARD_OPTIONS", {}).get("build", {}):
|
||||
env.Append(
|
||||
LINKFLAGS=["-T", join(
|
||||
"$PIOHOME_DIR", "packages", "ldscripts",
|
||||
"${BOARD_OPTIONS['build']['ldscript']}")]
|
||||
)
|
||||
if "extra_flags" in env.get("BOARD_OPTIONS", {}).get("build", {}):
|
||||
env.MergeFlags(env.subst("${BOARD_OPTIONS['build']['extra_flags']}"))
|
||||
|
||||
if "BUILD_FLAGS" in env:
|
||||
env.MergeFlags(env['BUILD_FLAGS'])
|
||||
|
||||
corelibs = []
|
||||
if "FRAMEWORK" in env:
|
||||
if env['FRAMEWORK'] in ("arduino", "energia"):
|
||||
env.ConvertInoToCpp()
|
||||
@ -49,20 +42,27 @@ def BuildFirmware(env, corelibs):
|
||||
|
||||
# build dependent libs
|
||||
deplibs = firmenv.BuildDependentLibraries(join("$PROJECT_DIR", "src"))
|
||||
if deplibs:
|
||||
firmenv.Prepend(
|
||||
_LIBFLAGS="-Wl,--start-group "
|
||||
)
|
||||
|
||||
# append specified LD_SCRIPT
|
||||
if "LDSCRIPT_PATH" in firmenv:
|
||||
firmenv.Append(
|
||||
_LIBFLAGS=" -Wl,--end-group "
|
||||
LINKFLAGS=["-T", "$LDSCRIPT_PATH"]
|
||||
)
|
||||
|
||||
# enable "cyclic reference" for linker
|
||||
firmenv.Prepend(
|
||||
_LIBFLAGS="-Wl,--start-group ",
|
||||
)
|
||||
firmenv.Append(
|
||||
_LIBFLAGS=" -Wl,--end-group"
|
||||
)
|
||||
|
||||
firmenv.MergeFlags(getenv("PIOSRCBUILD_FLAGS", "$SRCBUILD_FLAGS"))
|
||||
|
||||
return firmenv.Program(
|
||||
join("$BUILD_DIR", "firmware"),
|
||||
[firmenv.GlobCXXFiles(vdir) for vdir in vdirs],
|
||||
LIBS=deplibs + corelibs,
|
||||
LIBS=corelibs + deplibs,
|
||||
LIBPATH="$BUILD_DIR",
|
||||
PROGSUFFIX=".elf"
|
||||
)
|
||||
|
@ -49,7 +49,7 @@ class DigistumpPlatform(BasePlatform):
|
||||
continue
|
||||
_, board = v.split("=")
|
||||
bdata = get_boards(board)
|
||||
if bdata['build']['mcu'] == "cortex-m3":
|
||||
if "cpu" in bdata['build']:
|
||||
tpackage = "toolchain-gccarmnoneeabi"
|
||||
tuploader = "tool-bossac"
|
||||
else:
|
||||
|
Reference in New Issue
Block a user