Replace Leonardo detection with Caterina detection

Checks bootloader.path for "caterina", instead of checking only for
leonardo

Fix #96
Fix #97
Fix #102
This commit is contained in:
Sudar 2013-07-09 22:10:46 +05:30
commit 6936a1dcfd
3 changed files with 44 additions and 48 deletions

View file

@ -16,6 +16,7 @@ The following is the rough list of changes that went into different versions. I
- Add support for the Digilent chipKIT platform. (https://github.com/peplin)
- Implement ard-parse-boards with shell scripting instead of Perl (https://github.com/peplin)
- Compile with debugging symbols only when DEBUG=1 (https://github.com/peplin)
- Replace Leonardo detection with Caterina detection (https://github.com/sej7278)
### 0.12.0 (2013-06-20)
- Fix "generated_assembly" target, which got broken earlier. Fix issue #76 (https://github.com/matthijskooijman)

View file

@ -465,33 +465,6 @@ else
$(call show_config_variable,USER_LIB_PATH,[USER])
endif
########################################################################
# Reset
#
ifeq ($(BOARD_TAG),leonardo)
LEO_RESET = 1
endif
ifeq ($(BOARD_TAG),micro)
LEO_RESET = 1
endif
ifndef RESET_CMD
ifdef LEO_RESET
RESET_CMD = $(ARDMK_PATH)/ard-reset-arduino --leonardo \
$(ARD_RESET_OPTS) $(call get_arduino_port)
else
RESET_CMD = $(ARDMK_PATH)/ard-reset-arduino \
$(ARD_RESET_OPTS) $(call get_arduino_port)
endif
endif
ifeq ($(BOARD_TAG),leonardo)
ERROR_ON_LEONARDO = $(error On leonardo, raw_xxx operation is not supported)
else
ERROR_ON_LEONARDO =
endif
########################################################################
# boards.txt parsing
@ -520,6 +493,9 @@ ifeq ($(strip $(NO_CORE)),)
VARIANT = $(call PARSE_BOARD,$(BOARD_TAG),build.variant)
endif
# see if we are a caterina device like leonardo or micro
CATERINA = $(findstring caterina,$(call PARSE_BOARD,$(BOARD_TAG),bootloader.path))
# processor stuff
ifndef MCU
MCU = $(call PARSE_BOARD,$(BOARD_TAG),build.mcu)
@ -529,8 +505,8 @@ ifeq ($(strip $(NO_CORE)),)
F_CPU = $(call PARSE_BOARD,$(BOARD_TAG),build.f_cpu)
endif
ifeq ($(VARIANT),leonardo)
# USB IDs for the Leonardo
ifneq ($(CATERINA),)
# USB IDs for the caterina devices like leonardo or micro
ifndef USB_VID
USB_VID = $(call PARSE_BOARD,$(BOARD_TAG),build.vid)
endif
@ -584,6 +560,27 @@ else
$(call show_config_variable,OBJDIR,[USER])
endif
########################################################################
# Reset
#
ifndef RESET_CMD
ifneq ($(CATERINA),)
RESET_CMD = $(ARDMK_PATH)/ard-reset-arduino --caterina \
$(ARD_RESET_OPTS) $(call get_arduino_port)
else
RESET_CMD = $(ARDMK_PATH)/ard-reset-arduino \
$(ARD_RESET_OPTS) $(call get_arduino_port)
endif
endif
ifneq ($(CATERINA),)
ERROR_ON_CATERINA = $(error On $(BOARD_TAG), raw_xxx operation is not supported)
else
ERROR_ON_CATERINA =
endif
########################################################################
# Local sources
#
@ -773,8 +770,8 @@ else
CPPFLAGS += -O$(OPTIMIZATION_LEVEL)
endif
# USB IDs for the Leonardo
ifeq ($(VARIANT),leonardo)
# USB IDs for the Caterina devices like leonardo or micro
ifneq ($(CATERINA),)
CPPFLAGS += -DUSB_VID=$(USB_VID) -DUSB_PID=$(USB_PID)
endif
@ -1012,8 +1009,8 @@ $(TARGET_ELF): $(LOCAL_OBJS) $(CORE_LIB) $(OTHER_OBJS)
$(CORE_LIB): $(CORE_OBJS) $(LIB_OBJS) $(USER_LIB_OBJS)
$(AR) rcs $@ $(CORE_OBJS) $(LIB_OBJS) $(USER_LIB_OBJS)
error_on_leonardo:
$(ERROR_ON_LEONARDO)
error_on_caterina:
$(ERROR_ON_CATERINA)
# Use submake so we can guarantee the reset happens
# before the upload, even with make -j
@ -1022,7 +1019,7 @@ upload: $(TARGET_HEX) verify_size
$(MAKE) do_upload
raw_upload: $(TARGET_HEX) verify_size
$(MAKE) error_on_leonardo
$(MAKE) error_on_caterina
$(MAKE) do_upload
do_upload:
@ -1038,11 +1035,9 @@ eeprom: $(TARGET_HEX) verify_size
$(MAKE) do_eeprom
raw_eeprom: $(TARGET_HEX) verify_size
$(MAKE) error_on_leonardo
$(MAKE) error_on_caterina
$(MAKE) do_eeprom
# the last part is for leonardo.
# wait until leonardo reboots and establish a new connection.
reset:
$(call arduino_output,Resetting Arduino...)
$(RESET_CMD)
@ -1101,7 +1096,7 @@ generate_assembly: $(OBJDIR)/$(TARGET).s
generated_assembly: generate_assembly
@$(ECHO) "generated_assembly" target is deprecated. Use "generate_assembly" target instead
.PHONY: all upload raw_upload raw_eeprom error_on_leonardo reset reset_stty ispload clean depends size show_boards monitor disasm symbol_sizes generated_assembly generate_assembly verify_size
.PHONY: all upload raw_upload raw_eeprom error_on_caterina reset reset_stty ispload clean depends size show_boards monitor disasm symbol_sizes generated_assembly generate_assembly verify_size
# added - in the beginning, so that we don't get an error if the file is not present
-include $(DEPS)

View file

@ -13,12 +13,12 @@ my %Opt =
);
GetOptions(\%Opt,
"period=f", # width of reset pulse in seconds
"verbose!",
"help!",
"info!",
"leonardo!",
);
"period=f", # width of reset pulse in seconds
"verbose!",
"help!",
"info!",
"caterina!",
);
if ($Opt{help} || $Opt{info})
{
@ -33,7 +33,7 @@ foreach my $dev (@ARGV)
my $p = Device::SerialPort->new($dev)
or die "Unable to open $dev: $!\n";
if ($Opt{leonardo})
if ($Opt{caterina})
{
$p->baudrate(1200);
$p->write_settings;
@ -86,7 +86,7 @@ ard-reset-arduino - Reset an Arduino
$ ard-reset-arduino --verbose --period=0.1 /dev/cu.usb*
$ ard-reset-arduino --verbose --leonardo /dev/ttyUSB0
$ ard-reset-arduino --verbose --caterina /dev/ttyUSB0
=head1 DESCRIPTION
@ -108,9 +108,9 @@ Watch what's going on on STDERR.
Specify the DTR pulse width in seconds.
=item --leonardo
=item --caterina
Reset a Leonardo or Micro.
Reset a Leonardo, Micro, Robot or LilyPadUSB.
=back