forked from platformio/platformio-core
Initial support for Microchip PIC32 platform // Issue #438
This commit is contained in:
1 parent
bfdc425e7c
commit
360024af38
5 files changed
+820
-1
No files matched your search
@@ -97,6 +97,23 @@ elif env.get("PLATFORM") == "nordicnrf51":
|
||||
LIBS=["RFduino", "RFduinoBLE", "RFduinoGZLL", "RFduinoSystem"]
|
||||
)
|
||||
|
||||
elif env.get("PLATFORM") == "microchippic32":
|
||||
PLATFORMFW_DIR = join(
|
||||
"$PIOPACKAGES_DIR",
|
||||
"framework-arduinomicrochippic32"
|
||||
)
|
||||
env.Prepend(
|
||||
LIBPATH=[
|
||||
join(
|
||||
"$PLATFORMFW_DIR", "cores",
|
||||
"${BOARD_OPTIONS['build']['core']}"
|
||||
),
|
||||
join(
|
||||
"$PLATFORMFW_DIR", "variants",
|
||||
"${BOARD_OPTIONS['build']['variant']}"
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
env.Replace(PLATFORMFW_DIR=PLATFORMFW_DIR)
|
||||
|
||||
|
||||
@@ -0,0 +1,169 @@
|
||||
# Copyright 2014-2016 Ivan Kravets <me@ikravets.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""
|
||||
Builder for Microchip PIC32 microcontrollers
|
||||
"""
|
||||
|
||||
from os.path import join
|
||||
|
||||
from SCons.Script import (
|
||||
COMMAND_LINE_TARGETS, AlwaysBuild, Builder, Default, DefaultEnvironment)
|
||||
|
||||
|
||||
env = DefaultEnvironment()
|
||||
|
||||
env.Replace(
|
||||
AR="pic32-ar",
|
||||
AS="pic32-as",
|
||||
CC="pic32-gcc",
|
||||
CXX="pic32-g++",
|
||||
OBJCOPY="pic32-objcopy",
|
||||
RANLIB="pic32-ranlib",
|
||||
SIZETOOL="pic32-size",
|
||||
|
||||
ARFLAGS=["rcs"],
|
||||
|
||||
ASFLAGS=[
|
||||
"-g1",
|
||||
"-O2",
|
||||
"-Wa,--gdwarf-2",
|
||||
"-mprocessor=$BOARD_MCU"
|
||||
],
|
||||
|
||||
CCFLAGS=[
|
||||
"-w",
|
||||
"-g",
|
||||
"-O2",
|
||||
"-MMD",
|
||||
"-mdebugger",
|
||||
"-mno-smart-io",
|
||||
"-mprocessor=$BOARD_MCU",
|
||||
"-ffunction-sections",
|
||||
"-fdata-sections",
|
||||
"-Wcast-align",
|
||||
"-fno-short-double",
|
||||
"-ftoplevel-reorder"
|
||||
],
|
||||
|
||||
CXXFLAGS=["-fno-exceptions"],
|
||||
|
||||
CPPDEFINES=[
|
||||
"F_CPU=$BOARD_F_CPU",
|
||||
"MPIDEVER=16777998",
|
||||
"MPIDE=150",
|
||||
"IDE=Arduino"
|
||||
],
|
||||
|
||||
LINKFLAGS=[
|
||||
"-w",
|
||||
"-Os",
|
||||
"-mdebugger",
|
||||
"-mprocessor=$BOARD_MCU",
|
||||
"-mno-peripheral-libs",
|
||||
"-nostartfiles",
|
||||
"-Wl,--gc-sections",
|
||||
"-Wl,--script=chipKIT-application-COMMON%s.ld" % (
|
||||
"-MZ" if "MZ" in env.get("BOARD_OPTIONS", {}).get(
|
||||
"build", {}).get("mcu") else "")
|
||||
],
|
||||
|
||||
LIBS=["m"],
|
||||
|
||||
SIZEPRINTCMD='"$SIZETOOL" -B -d $SOURCES',
|
||||
|
||||
UPLOADER=join("$PIOPACKAGES_DIR", "tool-pic32prog", "pic32prog"),
|
||||
UPLOADERFLAGS=[
|
||||
"-d", '"$UPLOAD_PORT"'
|
||||
"-b", "$UPLOAD_SPEED",
|
||||
],
|
||||
UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS $SOURCES',
|
||||
|
||||
PROGNAME="firmware",
|
||||
PROGSUFFIX=".elf"
|
||||
)
|
||||
|
||||
if int(env.get("BOARD_OPTIONS", {}).get(
|
||||
"upload", {}).get("maximum_ram_size", 0)) < 65535:
|
||||
env.Append(
|
||||
CCFLAGS=["-G1024"]
|
||||
)
|
||||
|
||||
|
||||
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"
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
#
|
||||
# Target: Build executable and linkable firmware
|
||||
#
|
||||
|
||||
target_elf = env.BuildProgram()
|
||||
|
||||
#
|
||||
# Target: Build the .hex
|
||||
#
|
||||
|
||||
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_size = env.Alias("size", target_elf, "$SIZEPRINTCMD")
|
||||
AlwaysBuild(target_size)
|
||||
|
||||
#
|
||||
# Target: Upload firmware
|
||||
#
|
||||
|
||||
upload = env.Alias(["upload", "uploadlazy"], target_firm, "$UPLOADCMD")
|
||||
AlwaysBuild(upload)
|
||||
|
||||
#
|
||||
# Target: Define targets
|
||||
#
|
||||
|
||||
Default([target_firm, target_size])
|
||||
Reference in new issue
Block a user