forked from platformio/platformio-core
Refactor build scripts for development platforms
This commit is contained in:
@@ -8,108 +8,11 @@
|
|||||||
from os.path import join
|
from os.path import join
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Builder, Default,
|
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default,
|
||||||
DefaultEnvironment, Exit)
|
DefaultEnvironment, Exit, SConscript)
|
||||||
|
|
||||||
from platformio.util import get_serialports
|
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
|
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.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()
|
CORELIBS = env.ProcessGeneral()
|
||||||
|
|
||||||
#
|
#
|
||||||
# Target: Build executable and linkable firmware
|
# 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
|
# 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:
|
if "uploadlazy" in COMMAND_LINE_TARGETS:
|
||||||
target_hex = join("$BUILD_DIR", "firmware.hex")
|
target_firm = join("$BUILD_DIR", "firmware.hex")
|
||||||
else:
|
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
|
# Target: Print binary size
|
||||||
@@ -190,7 +112,7 @@ AlwaysBuild(target_size)
|
|||||||
# Target: Upload by default .hex file
|
# Target: Upload by default .hex file
|
||||||
#
|
#
|
||||||
|
|
||||||
upload = env.Alias(["upload", "uploadlazy"], target_hex, [
|
upload = env.Alias(["upload", "uploadlazy"], target_firm, [
|
||||||
before_upload, "$UPLOADHEXCMD"])
|
before_upload, "$UPLOADHEXCMD"])
|
||||||
AlwaysBuild(upload)
|
AlwaysBuild(upload)
|
||||||
|
|
||||||
@@ -206,4 +128,4 @@ AlwaysBuild(uploadeep)
|
|||||||
# Setup default targets
|
# Setup default targets
|
||||||
#
|
#
|
||||||
|
|
||||||
Default([target_hex, target_size])
|
Default([target_firm, target_size])
|
||||||
|
@@ -7,69 +7,16 @@
|
|||||||
|
|
||||||
from os.path import join
|
from os.path import join
|
||||||
|
|
||||||
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Builder, Default,
|
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default,
|
||||||
DefaultEnvironment)
|
DefaultEnvironment, SConscript)
|
||||||
|
|
||||||
from platformio.util import get_serialports
|
from platformio.util import get_serialports
|
||||||
|
|
||||||
env = DefaultEnvironment()
|
env = DefaultEnvironment()
|
||||||
|
env = SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py")),
|
||||||
|
exports="env")
|
||||||
|
|
||||||
env.Replace(
|
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"),
|
UPLOADER=join("$PIOPACKAGES_DIR", "$PIOPACKAGE_UPLOADER", "bossac"),
|
||||||
UPLOADERFLAGS=[
|
UPLOADERFLAGS=[
|
||||||
"--info",
|
"--info",
|
||||||
@@ -84,17 +31,14 @@ env.Replace(
|
|||||||
)
|
)
|
||||||
|
|
||||||
env.Append(
|
env.Append(
|
||||||
BUILDERS=dict(
|
CPPDEFINES=[
|
||||||
ElfToBin=Builder(
|
"printf=iprintf"
|
||||||
action=" ".join([
|
],
|
||||||
"$OBJCOPY",
|
|
||||||
"-O",
|
LINKFLAGS=[
|
||||||
"binary",
|
"-Wl,--entry=Reset_Handler",
|
||||||
"$SOURCES",
|
"-Wl,--start-group"
|
||||||
"$TARGET"]),
|
]
|
||||||
suffix=".bin"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
CORELIBS = env.ProcessGeneral()
|
CORELIBS = env.ProcessGeneral()
|
||||||
@@ -103,16 +47,16 @@ CORELIBS = env.ProcessGeneral()
|
|||||||
# Target: Build executable and linkable firmware
|
# 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
|
# Target: Build the .bin file
|
||||||
#
|
#
|
||||||
|
|
||||||
if "uploadlazy" in COMMAND_LINE_TARGETS:
|
if "uploadlazy" in COMMAND_LINE_TARGETS:
|
||||||
target_bin = join("$BUILD_DIR", "firmware.bin")
|
target_firmware = join("$BUILD_DIR", "firmware.bin")
|
||||||
else:
|
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
|
# Target: Print binary size
|
||||||
@@ -125,7 +69,8 @@ AlwaysBuild(target_size)
|
|||||||
# Target: Upload by default .bin file
|
# Target: Upload by default .bin file
|
||||||
#
|
#
|
||||||
|
|
||||||
upload = env.Alias(["upload", "uploadlazy"], target_bin, ("$UPLOADBINCMD"))
|
upload = env.Alias(
|
||||||
|
["upload", "uploadlazy"], target_firmware, ("$UPLOADBINCMD"))
|
||||||
AlwaysBuild(upload)
|
AlwaysBuild(upload)
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -151,4 +96,4 @@ if is_uptarget:
|
|||||||
# Setup default targets
|
# 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 os.path import join
|
||||||
|
|
||||||
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Builder, Default,
|
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default,
|
||||||
DefaultEnvironment)
|
DefaultEnvironment, SConscript)
|
||||||
|
|
||||||
env = DefaultEnvironment()
|
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(
|
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"),
|
UPLOADER=join("$PIOPACKAGES_DIR", "$PIOPACKAGE_UPLOADER", "bossac"),
|
||||||
UPLOADERFLAGS=[
|
UPLOADERFLAGS=[
|
||||||
"--info",
|
"--info",
|
||||||
@@ -142,8 +29,21 @@ if env.get("BOARD_OPTIONS", {}).get("build", {}).get("mcu") == "cortex-m3":
|
|||||||
],
|
],
|
||||||
UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS $SOURCES'
|
UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS $SOURCES'
|
||||||
)
|
)
|
||||||
else:
|
|
||||||
env.Append(
|
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"),
|
UPLOADER=join("$PIOPACKAGES_DIR", "tool-avrdude", "avrdude"),
|
||||||
UPLOADERFLAGS=[
|
UPLOADERFLAGS=[
|
||||||
"-q", # suppress progress output
|
"-q", # suppress progress output
|
||||||
@@ -164,16 +64,22 @@ CORELIBS = env.ProcessGeneral()
|
|||||||
# Target: Build executable and linkable firmware
|
# 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:
|
if "cortex" in env.get("BOARD_OPTIONS").get("build").get("cpu", ""):
|
||||||
target_hex = join("$BUILD_DIR", "firmware.hex")
|
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:
|
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
|
# Target: Print binary size
|
||||||
@@ -183,14 +89,14 @@ target_size = env.Alias("size", target_elf, "$SIZEPRINTCMD")
|
|||||||
AlwaysBuild(target_size)
|
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)
|
AlwaysBuild(upload)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Target: Define targets
|
# 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(
|
PLATFORMFW_DIR = join(
|
||||||
"$PIOPACKAGES_DIR",
|
"$PIOPACKAGES_DIR",
|
||||||
"framework-arduino%s" % (
|
"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)
|
env.Replace(PLATFORMFW_DIR=PLATFORMFW_DIR)
|
||||||
@@ -98,12 +98,6 @@ if env.subst("${PLATFORMFW_DIR}")[-3:] == "sam":
|
|||||||
join("$BUILD_DIR", "FrameworkDeviceInc", "sam3xa", "include")
|
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
|
# search relative includes in lib SAM directories
|
||||||
core_dir = join(env.subst("$PLATFORMFW_DIR"), "system", "libsam")
|
core_dir = join(env.subst("$PLATFORMFW_DIR"), "system", "libsam")
|
||||||
|
@@ -8,63 +8,14 @@
|
|||||||
|
|
||||||
from os.path import join
|
from os.path import join
|
||||||
|
|
||||||
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Builder, Default,
|
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default,
|
||||||
DefaultEnvironment)
|
DefaultEnvironment, SConscript)
|
||||||
|
|
||||||
env = DefaultEnvironment()
|
env = DefaultEnvironment()
|
||||||
|
env = SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py")),
|
||||||
|
exports="env")
|
||||||
|
|
||||||
env.Replace(
|
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"),
|
UPLOADER=join("$PIOPACKAGES_DIR", "tool-stlink", "st-flash"),
|
||||||
UPLOADERFLAGS=[
|
UPLOADERFLAGS=[
|
||||||
"write", # write in flash
|
"write", # write in flash
|
||||||
@@ -75,37 +26,16 @@ env.Replace(
|
|||||||
UPLOADCMD="$UPLOADER $UPLOADERFLAGS"
|
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(
|
env.Append(
|
||||||
BUILDERS=dict(
|
CPPDEFINES=[
|
||||||
ElfToBin=Builder(
|
"${BOARD_OPTIONS['build']['variant'].upper()}"
|
||||||
action=" ".join([
|
],
|
||||||
"$OBJCOPY",
|
|
||||||
"-O",
|
LINKFLAGS=[
|
||||||
"binary",
|
"-nostartfiles",
|
||||||
"$SOURCES",
|
"-nostdlib"
|
||||||
"$TARGET"]),
|
]
|
||||||
suffix=".bin"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
CORELIBS = env.ProcessGeneral()
|
CORELIBS = env.ProcessGeneral()
|
||||||
@@ -114,16 +44,16 @@ CORELIBS = env.ProcessGeneral()
|
|||||||
# Target: Build executable and linkable firmware
|
# 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
|
# Target: Build the .bin file
|
||||||
#
|
#
|
||||||
|
|
||||||
if "uploadlazy" in COMMAND_LINE_TARGETS:
|
if "uploadlazy" in COMMAND_LINE_TARGETS:
|
||||||
target_bin = join("$BUILD_DIR", "firmware.bin")
|
target_firm = join("$BUILD_DIR", "firmware.bin")
|
||||||
else:
|
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
|
# Target: Print binary size
|
||||||
@@ -136,11 +66,11 @@ AlwaysBuild(target_size)
|
|||||||
# Target: Upload by default .bin file
|
# Target: Upload by default .bin file
|
||||||
#
|
#
|
||||||
|
|
||||||
upload = env.Alias(["upload", "uploadlazy"], target_bin, ("$UPLOADCMD"))
|
upload = env.Alias(["upload", "uploadlazy"], target_firm, ("$UPLOADCMD"))
|
||||||
AlwaysBuild(upload)
|
AlwaysBuild(upload)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Target: Define targets
|
# Target: Define targets
|
||||||
#
|
#
|
||||||
|
|
||||||
Default([target_bin, target_size])
|
Default([target_firm, target_size])
|
||||||
|
@@ -7,113 +7,21 @@
|
|||||||
|
|
||||||
from os.path import isfile, join
|
from os.path import isfile, join
|
||||||
|
|
||||||
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Builder, Default,
|
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default,
|
||||||
DefaultEnvironment)
|
DefaultEnvironment, SConscript)
|
||||||
|
|
||||||
env = DefaultEnvironment()
|
env = DefaultEnvironment()
|
||||||
|
|
||||||
if env.get("BOARD_OPTIONS", {}).get("build", {}).get("core") == "teensy":
|
if env.get("BOARD_OPTIONS", {}).get("build", {}).get("core") == "teensy":
|
||||||
env.Replace(
|
env = SConscript(env.subst(
|
||||||
AR="avr-ar",
|
join("$PIOBUILDER_DIR", "scripts", "baseavr.py")), exports="env")
|
||||||
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'
|
|
||||||
)
|
|
||||||
|
|
||||||
elif env.get("BOARD_OPTIONS", {}).get("build", {}).get("core") == "teensy3":
|
elif env.get("BOARD_OPTIONS", {}).get("build", {}).get("core") == "teensy3":
|
||||||
env.Replace(
|
env = SConscript(env.subst(
|
||||||
AR="arm-none-eabi-ar",
|
join("$PIOBUILDER_DIR", "scripts", "basearm.py")), exports="env")
|
||||||
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.Append(
|
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=[
|
CPPDEFINES=[
|
||||||
"F_CPU=$BOARD_F_CPU",
|
|
||||||
"USB_PID=null",
|
"USB_PID=null",
|
||||||
"USB_VID=null",
|
"USB_VID=null",
|
||||||
"USB_SERIAL",
|
"USB_SERIAL",
|
||||||
@@ -121,19 +29,15 @@ env.Append(
|
|||||||
],
|
],
|
||||||
|
|
||||||
CXXFLAGS=[
|
CXXFLAGS=[
|
||||||
"-felide-constructors",
|
"-std=gnu++0x"
|
||||||
"-fno-exceptions"
|
|
||||||
],
|
|
||||||
|
|
||||||
LINKFLAGS=[
|
|
||||||
"-Os"
|
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
if isfile(env.subst(join(
|
if isfile(env.subst(join(
|
||||||
"$PIOPACKAGES_DIR", "tool-teensy", "teensy_loader_cli"))):
|
"$PIOPACKAGES_DIR", "tool-teensy", "teensy_loader_cli"))):
|
||||||
env.Append(
|
env.Append(
|
||||||
UPLOADER=join("$PIOPACKAGES_DIR", "tool-teensy", "teensy_loader_cli"),
|
UPLOADER=join(
|
||||||
|
"$PIOPACKAGES_DIR", "tool-teensy", "teensy_loader_cli"),
|
||||||
UPLOADERFLAGS=[
|
UPLOADERFLAGS=[
|
||||||
"-mmcu=$BOARD_MCU",
|
"-mmcu=$BOARD_MCU",
|
||||||
"-w", # wait for device to apear
|
"-w", # wait for device to apear
|
||||||
@@ -159,16 +63,22 @@ CORELIBS = env.ProcessGeneral()
|
|||||||
# Target: Build executable and linkable firmware
|
# 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:
|
if "cortex" in env.get("BOARD_OPTIONS").get("build").get("cpu", ""):
|
||||||
target_hex = join("$BUILD_DIR", "firmware.hex")
|
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:
|
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
|
# Target: Print binary size
|
||||||
@@ -178,14 +88,14 @@ target_size = env.Alias("size", target_elf, "$SIZEPRINTCMD")
|
|||||||
AlwaysBuild(target_size)
|
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)
|
AlwaysBuild(upload)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Target: Define targets
|
# 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: Build executable and linkable firmware
|
||||||
#
|
#
|
||||||
|
|
||||||
target_elf = env.BuildFirmware(CORELIBS + ["m"])
|
target_elf = env.BuildFirmware(["m"] + CORELIBS)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Target: Build the .hex
|
# Target: Build the .hex
|
||||||
#
|
#
|
||||||
|
|
||||||
if "uploadlazy" in COMMAND_LINE_TARGETS:
|
if "uploadlazy" in COMMAND_LINE_TARGETS:
|
||||||
target_hex = join("$BUILD_DIR", "firmware.hex")
|
target_frim = join("$BUILD_DIR", "firmware.hex")
|
||||||
else:
|
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
|
# Target: Print binary size
|
||||||
@@ -107,11 +107,11 @@ AlwaysBuild(target_size)
|
|||||||
# Target: Upload firmware
|
# Target: Upload firmware
|
||||||
#
|
#
|
||||||
|
|
||||||
upload = env.Alias(["upload", "uploadlazy"], target_hex, "$UPLOADCMD")
|
upload = env.Alias(["upload", "uploadlazy"], target_frim, "$UPLOADCMD")
|
||||||
AlwaysBuild(upload)
|
AlwaysBuild(upload)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Target: Define targets
|
# Target: Define targets
|
||||||
#
|
#
|
||||||
|
|
||||||
Default([target_hex, target_size])
|
Default([target_frim, target_size])
|
||||||
|
@@ -8,88 +8,23 @@
|
|||||||
|
|
||||||
from os.path import join
|
from os.path import join
|
||||||
|
|
||||||
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Builder, Default,
|
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default,
|
||||||
DefaultEnvironment)
|
DefaultEnvironment, SConscript)
|
||||||
|
|
||||||
env = DefaultEnvironment()
|
env = DefaultEnvironment()
|
||||||
|
env = SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py")),
|
||||||
|
exports="env")
|
||||||
|
|
||||||
env.Replace(
|
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"),
|
UPLOADER=join("$PIOPACKAGES_DIR", "tool-lm4flash", "lm4flash"),
|
||||||
UPLOADCMD="$UPLOADER $SOURCES"
|
UPLOADCMD="$UPLOADER $SOURCES"
|
||||||
)
|
)
|
||||||
|
|
||||||
env.Append(
|
env.Append(
|
||||||
BUILDERS=dict(
|
LINKFLAGS=[
|
||||||
ElfToBin=Builder(
|
"-nostartfiles",
|
||||||
action=" ".join([
|
"-nostdlib"
|
||||||
"$OBJCOPY",
|
]
|
||||||
"-O",
|
|
||||||
"binary",
|
|
||||||
"$SOURCES",
|
|
||||||
"$TARGET"]),
|
|
||||||
suffix=".bin"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
CORELIBS = env.ProcessGeneral()
|
CORELIBS = env.ProcessGeneral()
|
||||||
@@ -98,16 +33,16 @@ CORELIBS = env.ProcessGeneral()
|
|||||||
# Target: Build executable and linkable firmware
|
# 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
|
# Target: Build the .bin file
|
||||||
#
|
#
|
||||||
|
|
||||||
if "uploadlazy" in COMMAND_LINE_TARGETS:
|
if "uploadlazy" in COMMAND_LINE_TARGETS:
|
||||||
target_bin = join("$BUILD_DIR", "firmware.bin")
|
target_file = join("$BUILD_DIR", "firmware.bin")
|
||||||
else:
|
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
|
# Target: Print binary size
|
||||||
@@ -120,11 +55,11 @@ AlwaysBuild(target_size)
|
|||||||
# Target: Upload firmware
|
# Target: Upload firmware
|
||||||
#
|
#
|
||||||
|
|
||||||
upload = env.Alias(["upload", "uploadlazy"], target_bin, "$UPLOADCMD")
|
upload = env.Alias(["upload", "uploadlazy"], target_file, "$UPLOADCMD")
|
||||||
AlwaysBuild(upload)
|
AlwaysBuild(upload)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Target: Define targets
|
# Target: Define targets
|
||||||
#
|
#
|
||||||
|
|
||||||
Default([target_bin, target_size])
|
Default([target_file, target_size])
|
||||||
|
@@ -49,7 +49,7 @@ class DigistumpPlatform(BasePlatform):
|
|||||||
continue
|
continue
|
||||||
_, board = v.split("=")
|
_, board = v.split("=")
|
||||||
bdata = get_boards(board)
|
bdata = get_boards(board)
|
||||||
if bdata['build']['mcu'] == "cortex-m3":
|
if "cpu" in bdata['build']:
|
||||||
tpackage = "toolchain-gccarmnoneeabi"
|
tpackage = "toolchain-gccarmnoneeabi"
|
||||||
tuploader = "tool-bossac"
|
tuploader = "tool-bossac"
|
||||||
else:
|
else:
|
||||||
|
Reference in New Issue
Block a user