Finalize with Atmel SAM platform

This commit is contained in:
Valeriy Koval
2015-02-06 18:12:56 +02:00
parent 2280c01dc7
commit 14355cb7d4
5 changed files with 78 additions and 84 deletions

View File

@ -536,5 +536,29 @@
"via_ssh": true, "via_ssh": true,
"wait_for_upload_port": true "wait_for_upload_port": true
} }
} },
"due": {
"build": {
"core": "arduino",
"extra_flags": "-D__SAM3X8E__ -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM",
"f_cpu": "84000000L",
"mcu": "cortex-m3",
"pid": "0x003e",
"usb_product": "Arduino Due",
"variant": "arduino_due_x",
"vid": "0x2341",
"ldscript": "sam3x8e.ld"
},
"name": "Arduino Due (Programming Port)",
"platform": "sam",
"upload": {
"disable_flushing": true,
"maximum_ram_size": 524288,
"maximum_size": 28672,
"protocol": "sam-ba",
"speed": 57600,
"use_1200bps_touch": true,
"wait_for_upload_port": false
}
}
} }

View File

@ -1,25 +0,0 @@
{
"Due": {
"build": {
"core": "arduino",
"extra_flags": "-D__SAM3X8E__ -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM",
"f_cpu": "84000000L",
"mcu": "cortex-m3",
"pid": "0x003e",
"usb_product": "Arduino Due",
"variant": "arduino_due_x",
"vid": "0x2341"
},
"name": "Arduino Due",
"platform": "sam",
"upload": {
"disable_flushing": true,
"maximum_ram_size": 524288,
"maximum_size": 28672,
"protocol": "sam-ba",
"speed": 57600,
"use_1200bps_touch": true,
"wait_for_upload_port": false
}
}
}

View File

@ -2,7 +2,7 @@
# See LICENSE for details. # See LICENSE for details.
""" """
Build script for Android Framework (based on Wiring). Build script for Arduino Framework (based on Wiring).
""" """
from os.path import join from os.path import join
@ -49,6 +49,33 @@ if "variant" in env.get("BOARD_OPTIONS", {}).get("build", {}):
] ]
) )
if env.get("BOARD_OPTIONS", {}).get("platform", None) == "sam":
env.VariantDir(
join("$BUILD_DIR", "FrameworkCMSISInc"),
join("$PLATFORMFW_DIR", "system", "CMSIS", "CMSIS", "include")
)
env.VariantDir(
join("$BUILD_DIR", "FrameworkLibSamInc"),
join("$PLATFORMFW_DIR", "system", "libsam")
)
env.VariantDir(
join("$BUILD_DIR", "FrameworkDeviceInc"),
join("$PLATFORMFW_DIR", "system", "CMSIS", "Device", "ATMEL")
)
env.Append(
CPPPATH=[
join("$BUILD_DIR", "FrameworkCMSISInc"),
join("$BUILD_DIR", "FrameworkLibSamInc"),
join("$BUILD_DIR", "FrameworkDeviceInc")
]
)
env.Append(
LINKFLAGS=[
"-T", join("$PIOHOME_DIR", "packages", "ldscripts",
"${BOARD_OPTIONS['build']['ldscript']}")
]
)
# #
# Target: Build Core Library # Target: Build Core Library
# #

View File

@ -28,22 +28,25 @@ env.Replace(
"-c", "-c",
"-g", # include debugging info (so errors include line numbers) "-g", # include debugging info (so errors include line numbers)
"-x", "assembler-with-cpp", "-x", "assembler-with-cpp",
"-mmcu=$BOARD_MCU" "-Wall",
"-mthumb",
"-mcpu=${BOARD_OPTIONS['build']['mcu']}"
], ],
CCFLAGS=[ CCFLAGS=[
"-g", # include debugging info (so errors include line numbers) "-g", # include debugging info (so errors include line numbers)
"-Os", # optimize for size "-Os", # optimize for size
# "-Wall", # show warnings "-Wall", # show warnings
"-ffunction-sections", # place each function in its own section "-ffunction-sections", # place each function in its own section
"-fdata-sections", "-fdata-sections",
"-MMD", # output dependency info "-MMD", # output dependency info
"-mmcu=$BOARD_MCU" "-mcpu=${BOARD_OPTIONS['build']['mcu']}",
"-mthumb"
], ],
CXXFLAGS=[ CXXFLAGS=[
"-fno-exceptions", "-fno-rtti",
"-fno-threadsafe-statics" "-fno-exceptions"
], ],
CPPDEFINES=[ CPPDEFINES=[
@ -52,54 +55,34 @@ env.Replace(
LINKFLAGS=[ LINKFLAGS=[
"-Os", "-Os",
"-mmcu=$BOARD_MCU",
"-Wl,--gc-sections", "-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=[ UPLOADERFLAGS=[
"-i", "--info",
"-d", "--debug",
"--port", "$UPLOAD_PORT", "--port", "$UPLOAD_PORT",
"-U false", # @TODO "Native USB"? "--erase",
"-e", "--write",
"-w", "--verify",
"-v", "--boot"
"-b"
], ],
UPLOADBINCMD='"$UPLOADER" $UPLOADERFLAGS -U flash:w:$SOURCES:i', UPLOADBINCMD='"$UPLOADER" $UPLOADERFLAGS $SOURCES'
UPLOADEEPCMD='"$UPLOADER" $UPLOADERFLAGS -U eeprom:w:$SOURCES:i'
) )
env.Append( env.Append(
BUILDERS=dict( BUILDERS=dict(
ElfToEep=Builder( ElfToBin=Builder(
action=" ".join([ action=" ".join([
"$OBJCOPY", "$OBJCOPY",
"-O", "-O",
"ihex", "binary",
"-j",
".eeprom",
'--set-section-flags=.eeprom="alloc,load"',
"--no-change-warnings",
"--change-section-lma",
".eeprom=0",
"$SOURCES", "$SOURCES",
"$TARGET"]), "$TARGET"]),
suffix=".eep" suffix=".bin"
),
BUILDERS=dict(
ElfToBin=Builder(
action=" ".join([
"$OBJCOPY",
"-O",
"binary",
"$SOURCES",
"$TARGET"]),
suffix=".bin"
)
) )
) )
) )
@ -110,7 +93,7 @@ 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(CORELIBS + ["m", "gcc"])
# #
# Target: Build the .bin file # Target: Build the .bin file
@ -121,13 +104,6 @@ if "uploadlazy" in COMMAND_LINE_TARGETS:
else: else:
target_bin = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf) 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 # 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")) upload = env.Alias(["upload", "uploadlazy"], target_bin, ("$UPLOADBINCMD"))
AlwaysBuild(upload) AlwaysBuild(upload)
#
# Target: Upload .eep file
#
uploadeep = env.Alias(["uploadeep"], target_eep, ("$UPLOADEEPCMD"))
AlwaysBuild(uploadeep)
# #
# Check for $UPLOAD_PORT variable # Check for $UPLOAD_PORT variable
# #
is_uptarget = (set(["upload", "uploadlazy", "uploadeep"]) & is_uptarget = (set(["upload", "uploadlazy"]) & set(COMMAND_LINE_TARGETS))
set(COMMAND_LINE_TARGETS))
if is_uptarget: if is_uptarget:
# try autodetect upload port # try autodetect upload port

View File

@ -8,6 +8,7 @@ class SamPlatform(BasePlatform):
""" """
An embedded platform for Atmel SAM microcontrollers An embedded platform for Atmel SAM microcontrollers
(with Arduino Framework)
""" """
PACKAGES = { PACKAGES = {
@ -26,7 +27,7 @@ class SamPlatform(BasePlatform):
"default": True "default": True
}, },
"tool-sam": { "tool-bossac": {
"alias": "uploader", "alias": "uploader",
"default": True "default": True
} }