Files
platformio-core/platformio/builder/scripts/baseavr.py

100 lines
2.4 KiB
Python
Raw Normal View History

# Copyright 2014-2015 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.
"""
Base for Atmel AVR series of microcontrollers
"""
from SCons.Script import Builder, DefaultEnvironment
env = DefaultEnvironment()
env.Replace(
AR="avr-ar",
2015-02-24 18:15:17 +02:00
AS="avr-as",
CC="avr-gcc",
CXX="avr-g++",
OBJCOPY="avr-objcopy",
RANLIB="avr-ranlib",
SIZETOOL="avr-size",
2015-02-23 22:36:57 +02:00
ARFLAGS=["rcs"],
2015-02-24 18:15:17 +02:00
ASPPFLAGS=["-x", "assembler-with-cpp"],
CPPFLAGS=[
"-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"
],
2015-02-24 18:15:17 +02:00
CPPDEFINES=[
"F_CPU=$BOARD_F_CPU"
],
CXXFLAGS=[
"-fno-exceptions",
"-fno-threadsafe-statics"
],
LINKFLAGS=[
"-Os",
"-mmcu=$BOARD_MCU",
2015-04-06 21:16:10 +03:00
"-Wl,--gc-sections,--relax"
],
2015-03-09 12:22:24 +02:00
LIBS=["m"],
SIZEPRINTCMD='"$SIZETOOL" --mcu=$BOARD_MCU -C -d $SOURCES',
PROGNAME="firmware",
PROGSUFFIX=".elf"
)
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"
)
)
)