forked from platformio/platformio-core
Finalize with Atmel SAM platform
This commit is contained in:
@@ -28,22 +28,25 @@ env.Replace(
|
||||
"-c",
|
||||
"-g", # include debugging info (so errors include line numbers)
|
||||
"-x", "assembler-with-cpp",
|
||||
"-mmcu=$BOARD_MCU"
|
||||
"-Wall",
|
||||
"-mthumb",
|
||||
"-mcpu=${BOARD_OPTIONS['build']['mcu']}"
|
||||
],
|
||||
|
||||
CCFLAGS=[
|
||||
"-g", # include debugging info (so errors include line numbers)
|
||||
"-Os", # optimize for size
|
||||
# "-Wall", # show warnings
|
||||
"-Wall", # show warnings
|
||||
"-ffunction-sections", # place each function in its own section
|
||||
"-fdata-sections",
|
||||
"-MMD", # output dependency info
|
||||
"-mmcu=$BOARD_MCU"
|
||||
"-mcpu=${BOARD_OPTIONS['build']['mcu']}",
|
||||
"-mthumb"
|
||||
],
|
||||
|
||||
CXXFLAGS=[
|
||||
"-fno-exceptions",
|
||||
"-fno-threadsafe-statics"
|
||||
"-fno-rtti",
|
||||
"-fno-exceptions"
|
||||
],
|
||||
|
||||
CPPDEFINES=[
|
||||
@@ -52,54 +55,34 @@ env.Replace(
|
||||
|
||||
LINKFLAGS=[
|
||||
"-Os",
|
||||
"-mmcu=$BOARD_MCU",
|
||||
"-Wl,--gc-sections",
|
||||
"-Wl,--start-group"
|
||||
"-mcpu=${BOARD_OPTIONS['build']['mcu']}",
|
||||
"-mthumb"
|
||||
],
|
||||
|
||||
UPLOADER=join("$PIOPACKAGES_DIR", "tool-sam", "bossac"),
|
||||
UPLOADER=join("$PIOPACKAGES_DIR", "$PIOPACKAGE_UPLOADER", "bossac"),
|
||||
UPLOADERFLAGS=[
|
||||
"-i",
|
||||
"-d",
|
||||
"--info",
|
||||
"--debug",
|
||||
"--port", "$UPLOAD_PORT",
|
||||
"-U false", # @TODO "Native USB"?
|
||||
"-e",
|
||||
"-w",
|
||||
"-v",
|
||||
"-b"
|
||||
"--erase",
|
||||
"--write",
|
||||
"--verify",
|
||||
"--boot"
|
||||
],
|
||||
UPLOADBINCMD='"$UPLOADER" $UPLOADERFLAGS -U flash:w:$SOURCES:i',
|
||||
UPLOADEEPCMD='"$UPLOADER" $UPLOADERFLAGS -U eeprom:w:$SOURCES:i'
|
||||
UPLOADBINCMD='"$UPLOADER" $UPLOADERFLAGS $SOURCES'
|
||||
)
|
||||
|
||||
env.Append(
|
||||
BUILDERS=dict(
|
||||
ElfToEep=Builder(
|
||||
ElfToBin=Builder(
|
||||
action=" ".join([
|
||||
"$OBJCOPY",
|
||||
"-O",
|
||||
"ihex",
|
||||
"-j",
|
||||
".eeprom",
|
||||
'--set-section-flags=.eeprom="alloc,load"',
|
||||
"--no-change-warnings",
|
||||
"--change-section-lma",
|
||||
".eeprom=0",
|
||||
"binary",
|
||||
"$SOURCES",
|
||||
"$TARGET"]),
|
||||
suffix=".eep"
|
||||
),
|
||||
|
||||
BUILDERS=dict(
|
||||
ElfToBin=Builder(
|
||||
action=" ".join([
|
||||
"$OBJCOPY",
|
||||
"-O",
|
||||
"binary",
|
||||
"$SOURCES",
|
||||
"$TARGET"]),
|
||||
suffix=".bin"
|
||||
)
|
||||
suffix=".bin"
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -110,7 +93,7 @@ CORELIBS = env.ProcessGeneral()
|
||||
# Target: Build executable and linkable firmware
|
||||
#
|
||||
|
||||
target_elf = env.BuildFirmware(CORELIBS + ["m"])
|
||||
target_elf = env.BuildFirmware(CORELIBS + ["m", "gcc"])
|
||||
|
||||
#
|
||||
# Target: Build the .bin file
|
||||
@@ -121,13 +104,6 @@ if "uploadlazy" in COMMAND_LINE_TARGETS:
|
||||
else:
|
||||
target_bin = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf)
|
||||
|
||||
#
|
||||
# Target: Extract EEPROM data (from EEMEM directive) to .eep file
|
||||
#
|
||||
|
||||
target_eep = env.Alias("eep", env.ElfToEep(join("$BUILD_DIR", "firmware"),
|
||||
target_elf))
|
||||
|
||||
#
|
||||
# Target: Upload by default .bin file
|
||||
#
|
||||
@@ -135,20 +111,11 @@ target_eep = env.Alias("eep", env.ElfToEep(join("$BUILD_DIR", "firmware"),
|
||||
upload = env.Alias(["upload", "uploadlazy"], target_bin, ("$UPLOADBINCMD"))
|
||||
AlwaysBuild(upload)
|
||||
|
||||
#
|
||||
# Target: Upload .eep file
|
||||
#
|
||||
|
||||
uploadeep = env.Alias(["uploadeep"], target_eep, ("$UPLOADEEPCMD"))
|
||||
AlwaysBuild(uploadeep)
|
||||
|
||||
|
||||
#
|
||||
# Check for $UPLOAD_PORT variable
|
||||
#
|
||||
|
||||
is_uptarget = (set(["upload", "uploadlazy", "uploadeep"]) &
|
||||
set(COMMAND_LINE_TARGETS))
|
||||
is_uptarget = (set(["upload", "uploadlazy"]) & set(COMMAND_LINE_TARGETS))
|
||||
|
||||
if is_uptarget:
|
||||
# try autodetect upload port
|
||||
|
||||
Reference in New Issue
Block a user