Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update files to be equal to the board package
  • Loading branch information
XuGuohui committed Jun 21, 2016
1 parent 4ced44d commit 35785a7
Show file tree
Hide file tree
Showing 4 changed files with 271 additions and 81 deletions.
145 changes: 74 additions & 71 deletions Arduino/hardware/blend/avr/boards.txt
@@ -1,97 +1,100 @@
# RedBearLab Blend Boards Configuration
#
# For more information see:
# - https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification
# - https://github.com/arduino/Arduino/wiki/Arduino-Hardware-Cores-migration-guide-from-1.0-to-1.6
#

##############################################################

##############################################################

blend.name=Blend
blend.build.board=BLEND
blend.upload.protocol=avr109
blend.upload.maximum_size=28672
blend.upload.speed=57600
blend.upload.disable_flushing=true
blend.upload.use_1200bps_touch=true
blend.upload.wait_for_upload_port=true
blend.upload.tool=arduino:avrdude
blend.bootloader.tool=arduino:avrdude
blend.bootloader.low_fuses=0xff
blend.bootloader.high_fuses=0xd8
blend.bootloader.extended_fuses=0xcb
blend.bootloader.file=caterina/Caterina-Blend.hex
blend.bootloader.unlock_bits=0x3F
blend.bootloader.lock_bits=0x2F
blend.build.mcu=atmega32u4
blend.build.f_cpu=16000000L

blend.build.vid=0x2341
blend.build.pid=0x8036
blend.build.usb_product="Blend"
blend.name=Blend
blend.vid.0=0x2341
blend.pid.0=0x0036
blend.vid.1=0x2341
blend.pid.1=0x8036

blend.upload.tool=arduino:avrdude
blend.upload.protocol=avr109
blend.upload.maximum_size=28672
blend.upload.maximum_data_size=2560
blend.upload.speed=57600
blend.upload.disable_flushing=true
blend.upload.use_1200bps_touch=true
blend.upload.wait_for_upload_port=true

blend.bootloader.tool=arduino:avrdude
blend.bootloader.low_fuses=0xff
blend.bootloader.high_fuses=0xd8blend.bootloader.extended_fuses=0xcb
blend.bootloader.file=caterina/Caterina-Blend.hexblend.bootloader.unlock_bits=0x3F
blend.bootloader.lock_bits=0x2Fblend.build.mcu=atmega32u4blend.build.f_cpu=16000000Lblend.build.vid=0x2341blend.build.pid=0x8036
blend.build.usb_product="Blend"
blend.build.board=BLENDblend.build.core=arduino:arduinoblend.build.variant=Blend
blend.build.extra_flags={build.usb_flags}
blend.build.core=arduino:arduino
blend.build.variant=Blend

blend.vid.0=0x03EB
blend.pid.0=0x2404

##############################################################

blendmicro8.name=Blend Micro 3.3V/8MHz
blendmicro8.build.board=BLEND_MICRO
blendmicro8.upload.protocol=avr109
blendmicro8.upload.maximum_size=28672
blendmicro8.upload.speed=57600
blendmicro8.upload.disable_flushing=true
blendmicro8.upload.use_1200bps_touch=true
blendmicro8.upload.wait_for_upload_port=true
blendmicro8.upload.tool=arduino:avrdude
blendmicro8.name=Blend Micro 3.3V/8MHz
blendmicro8.vid.0=0x03EB
blendmicro8.pid.0=0x2404

blendmicro8.upload.tool=arduino:avrdude
blendmicro8.upload.protocol=avr109
blendmicro8.upload.maximum_size=28672
blendmicro8.upload.maximum_data_size=2560
blendmicro8.upload.speed=57600
blendmicro8.upload.disable_flushing=true
blendmicro8.upload.use_1200bps_touch=true
blendmicro8.upload.wait_for_upload_port=true

blendmicro8.bootloader.tool=arduino:avrdude
blendmicro8.bootloader.low_fuses=0xff
blendmicro8.bootloader.high_fuses=0xd8
blendmicro8.bootloader.extended_fuses=0xcf
blendmicro8.bootloader.file=caterina/Caterina-BlendMicro.hex
blendmicro8.bootloader.file=caterina/Caterina-BlendMicro.hex
blendmicro8.bootloader.unlock_bits=0x3F
blendmicro8.bootloader.lock_bits=0x2F
blendmicro8.build.mcu=atmega32u4
blendmicro8.bootloader.lock_bits=0x2F

blendmicro8.build.mcu=atmega32u4
blendmicro8.build.f_cpu=8000000L

blendmicro8.build.vid=0x03EB
blendmicro8.build.pid=0x2404
blendmicro8.build.usb_product="Blend Micro"
blendmicro8.build.extra_flags={build.usb_flags}
blendmicro8.build.pid=0x2404
blendmicro8.build.usb_product="BlendMicro 8MHz"
blendmicro8.build.board=BLEND_MICRO_8MHZ
blendmicro8.build.core=arduino:arduino
blendmicro8.build.variant=BlendMicro-8MHz

blendmicro8.vid.0=0x03EB
blendmicro8.pid.0=0x2404

blendmicro8.build.variant=BlendMicro-8MHz
blendmicro8.build.extra_flags={build.usb_flags}

##############################################################

blendmicro16.name=Blend Micro 3.3V/16MHz (overclock)
blendmicro16.build.board=BLEND_MICRO
blendmicro16.upload.protocol=avr109
blendmicro16.upload.maximum_size=28672
blendmicro16.upload.speed=57600
blendmicro16.upload.disable_flushing=true
blendmicro16.upload.use_1200bps_touch=true
blendmicro16.upload.wait_for_upload_port=true
blendmicro16.upload.tool=arduino:avrdude

blendmicro16.name=Blend Micro 3.3V/16MHz (overclock)
blendmicro16.vid.0=0x03EB
blendmicro16.pid.0=0x2404

blendmicro16.upload.tool=arduino:avrdude
blendmicro16.upload.protocol=avr109
blendmicro16.upload.maximum_size=28672
blendmicro16.upload.maximum_data_size=2560
blendmicro16.upload.speed=57600
blendmicro16.upload.disable_flushing=true
blendmicro16.upload.use_1200bps_touch=true
blendmicro16.upload.wait_for_upload_port=true

blendmicro16.bootloader.tool=arduino:avrdude
blendmicro16.bootloader.low_fuses=0xff
blendmicro16.bootloader.high_fuses=0xd8
blendmicro16.bootloader.extended_fuses=0xcf
blendmicro16.bootloader.file=caterina/Caterina-BlendMicro.hex
blendmicro16.bootloader.file=caterina/Caterina-BlendMicro.hex
blendmicro16.bootloader.unlock_bits=0x3F
blendmicro16.bootloader.lock_bits=0x2F
blendmicro16.build.mcu=atmega32u4
blendmicro16.bootloader.lock_bits=0x2F

blendmicro16.build.mcu=atmega32u4
blendmicro16.build.f_cpu=16000000L

blendmicro16.build.vid=0x03EB
blendmicro16.build.pid=0x2404
blendmicro16.build.usb_product="Blend Micro"
blendmicro16.build.extra_flags={build.usb_flags}
blendmicro16.build.pid=0x2404
blendmicro16.build.usb_product="BlendMicro 16MHz"
blendmicro16.build.board=BLEND_MICRO_16MHZ
blendmicro16.build.core=arduino:arduino
blendmicro16.build.variant=BlendMicro-16MHz

blendmicro16.vid.0=0x03EB
blendmicro16.pid.0=0x2404
blendmicro16.build.variant=BlendMicro-16MHz
blendmicro16.build.extra_flags={build.usb_flags}

##############################################################
Expand Down
119 changes: 117 additions & 2 deletions Arduino/hardware/blend/avr/platform.txt
@@ -1,3 +1,118 @@
name=RedBearLab Blend Boards
# RedBearLab Blend, BlenMicro Platform Configuration
#
# For more information see:
# - https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification
# - https://github.com/arduino/Arduino/wiki/Arduino-Hardware-Cores-migration-guide-from-1.0-to-1.6
#
name=RedBearLab AVR Boards
version=1.0.1

build.usb_manufacturer="RBL"
# AVR compile variables
# ---------------------

compiler.warning_flags=-w
compiler.warning_flags.none=-w
compiler.warning_flags.default=
compiler.warning_flags.more=-Wall
compiler.warning_flags.all=-Wall -Wextra

# Default "compiler.path" is correct, change only if you want to overidde the initial value
compiler.path={runtime.tools.avr-gcc.path}/bin/
compiler.c.cmd=avr-gcc
compiler.c.flags=-c -g -Os {compiler.warning_flags} -std=gnu11 -ffunction-sections -fdata-sections -MMD
# -w flag added to avoid printing a wrong warning http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59396
# This is fixed in gcc 4.8.3 and will be removed as soon as we update the toolchain
compiler.c.elf.flags={compiler.warning_flags} -Os -Wl,--gc-sections
compiler.c.elf.cmd=avr-gcc
compiler.S.flags=-c -g -x assembler-with-cpp
compiler.cpp.cmd=avr-g++
compiler.cpp.flags=-c -g -Os {compiler.warning_flags} -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD
compiler.ar.cmd=avr-ar
compiler.ar.flags=rcs
compiler.objcopy.cmd=avr-objcopy
compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0
compiler.elf2hex.flags=-O ihex -R .eeprom
compiler.elf2hex.cmd=avr-objcopy
compiler.ldflags=
compiler.size.cmd=avr-size

# This can be overriden in boards.txt
build.extra_flags=

# These can be overridden in platform.local.txt
compiler.c.extra_flags=
compiler.c.elf.extra_flags=
compiler.S.extra_flags=
compiler.cpp.extra_flags=
compiler.ar.extra_flags=
compiler.objcopy.eep.extra_flags=
compiler.elf2hex.extra_flags=

# AVR compile patterns
# --------------------

## Compile c files
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"

## Compile c++ files
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"

## Compile S files
recipe.S.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.S.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"

## Create archives
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"

## Combine gc-sections, archives, and objects
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -mmcu={build.mcu} {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" "-L{build.path}" -lm

## Create output files (.eep and .hex)
recipe.objcopy.eep.pattern="{compiler.path}{compiler.objcopy.cmd}" {compiler.objcopy.eep.flags} {compiler.objcopy.eep.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.eep"
recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"

## Save hex
recipe.output.tmp_file={build.project_name}.hex
recipe.output.save_file={build.project_name}.{build.variant}.hex

## Compute size
recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"
recipe.size.regex=^(?:\.text|\.data|\.bootloader)\s+([0-9]+).*
recipe.size.regex.data=^(?:\.data|\.bss|\.noinit)\s+([0-9]+).*
recipe.size.regex.eeprom=^(?:\.eeprom)\s+([0-9]+).*

## Preprocessor
preproc.includes.flags=-w -x c++ -M -MG -MP
recipe.preproc.includes="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} {preproc.includes.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}"

preproc.macros.flags=-w -x c++ -E -CC
recipe.preproc.macros="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} {preproc.macros.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}"

# AVR Uploader/Programmers tools
# ------------------------------

tools.avrdude.path={runtime.tools.avrdude.path}
tools.avrdude.cmd.path={path}/bin/avrdude
tools.avrdude.config.path={path}/etc/avrdude.conf

tools.avrdude.upload.params.verbose=-v
tools.avrdude.upload.params.quiet=-q -q
tools.avrdude.upload.pattern="{cmd.path}" "-C{config.path}" {upload.verbose} -p{build.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} -D "-Uflash:w:{build.path}/{build.project_name}.hex:i"

tools.avrdude.program.params.verbose=-v
tools.avrdude.program.params.quiet=-q -q
tools.avrdude.program.pattern="{cmd.path}" "-C{config.path}" {program.verbose} -p{build.mcu} -c{protocol} {program.extra_params} "-Uflash:w:{build.path}/{build.project_name}.hex:i"

tools.avrdude.erase.params.verbose=-v
tools.avrdude.erase.params.quiet=-q -q
tools.avrdude.erase.pattern="{cmd.path}" "-C{config.path}" {erase.verbose} -p{build.mcu} -c{protocol} {program.extra_params} -e -Ulock:w:{bootloader.unlock_bits}:m -Uefuse:w:{bootloader.extended_fuses}:m -Uhfuse:w:{bootloader.high_fuses}:m -Ulfuse:w:{bootloader.low_fuses}:m

tools.avrdude.bootloader.params.verbose=-v
tools.avrdude.bootloader.params.quiet=-q -q
tools.avrdude.bootloader.pattern="{cmd.path}" "-C{config.path}" {bootloader.verbose} -p{build.mcu} -c{protocol} {program.extra_params} "-Uflash:w:{runtime.platform.path}/bootloaders/{bootloader.file}:i" -Ulock:w:{bootloader.lock_bits}:m


# USB Default Flags
# Default blank usb manufacturer will be filled it at compile time
# - from numeric vendor ID, set to Unknown otherwise
build.usb_manufacturer="Unknown"
build.usb_flags=-DUSB_VID={build.vid} -DUSB_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}'
44 changes: 40 additions & 4 deletions Arduino/hardware/blend/avr/variants/BlendMicro-16MHz/main.cpp
@@ -1,24 +1,60 @@
/*
main.cpp - Main loop for Arduino sketches
Copyright (c) 2005-2013 Arduino Team. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include <Arduino.h>

//Declared weak in Arduino.h to allow user redefinitions.
int atexit(void (*func)()) { return 0; }

// Weak empty variant initialization function.
// May be redefined by variant files.
void initVariant() __attribute__((weak));
void initVariant() { }

int main(void)
{
init();

initVariant();

#if defined(USBCON)
USBDevice.attach();
#endif


#if defined(BLEND_MICRO_8MHZ)
// As the F_CPU = 8000000UL, the USB core make the PLLCSR = 0x02
// But the external xtal is 16000000Hz, so correct it here.
PLLCSR |= 0x10; // Need 16 MHz xtal
while (!(PLLCSR & (1<<PLOCK))); // wait for lock pll
#elif defined(BLEND_MICRO_16MHZ)
// The CPU clock in bootloader is 8MHz, change to 16MHz for sketches to run (i.e. overclock running at 3.3v).
CLKPR = 0x80;
CLKPR = 0;

#endif

setup();

for (;;) {
loop();
if (serialEventRun) serialEventRun();
}

return 0;
}

0 comments on commit 35785a7

Please sign in to comment.