westfw:
#
atmega32u4 for Pro Micro and Leonardo
atmega32u4: CHIP = atmega32u4
atmega32u4: TARGET = atmega32u4
atmega32u4: MCU_TARGET = atmega32u4
atmega32u4: CFLAGS += (COMMON_OPTIONS) -DUART=1
atmega32u4: AVR_FREQ ?= 16000000L
atmega32u4: LDSECTIONS = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe
atmega32u4: (MAKE) (CHIP) LED_DATA_FLASH=1 LED_START_FLASHES=3 LED=B0 BAUD_RATE=57600
atmega32u4: (PROGRAM)_atmega32u4.hex
atmega32u4: $(PROGRAM)_atmega32u4.lst
Uggh. Makefile language ugliness.
First, make is sensitive to leading spaces in lines, much of the time. Remove those. (I'm not really sure how this interacts with the colons, but...)
Second, the "daughter" make line:
atmega32u4: (MAKE) (CHIP) LED_DATA_FLASH=1 LED_START_FLASHES=3 LED=B0 BAUD_RATE=57600
isn't appropriate here, and isn't formatted correctly either. The idea of those is that if you have a board that is different from an existing target chip only in options, then you don't need to duplicate all the chip-level definitions, only recurse with the options you need changed. So "luminet" is just an ATtiny84 with some specific options, and it's rules look like:
luminet: TARGET = @
luminet: CHIP = attiny84
luminet:
(MAKE) (CHIP) AVR_FREQ=1000000L LED_START_FLASHES=0 BAUD_RATE=9600
mv (PROGRAM)(CHIP).hex (PROGRAM)(TARGET).hex
mv (PROGRAM)(CHIP).lst (PROGRAM)$(TARGET).lst
Note that the 'recipe' part is on a separate line, which is what makes it "commands" rather than "dependencies." I think this is the main problem with your modified makefile. You've managed to say that "make" is a dependency for the 32u4, rather than part of the rule to build it.
Since this "existing target" doesn't really apply, you should delete the entire line, leaving you with something like:
atmega32u4 for Pro Micro and Leonardo
atmega32u4: CHIP = atmega32u4
atmega32u4: TARGET = atmega32u4
atmega32u4: MCU_TARGET = atmega32u4
atmega32u4: CFLAGS += (COMMON_OPTIONS) -DUART=1
atmega32u4: AVR_FREQ ?= 16000000L
atmega32u4: LDSECTIONS = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe
atmega32u4: (PROGRAM)_atmega32u4.hex
atmega32u4: $(PROGRAM)_atmega32u4.lst
Give that a try and let us know if it works.
Other comments:
No, in this case, the main Makefile includes the extra makefiles itself, so you should never have to use "-f"
I hadn't noticed this "style conflict" till now :-(
I tried this:
#
# atmega32u4 for Pro Micro and Leonardo
#
atmega32u4: CHIP = atmega32u4
atmega32u4: TARGET = atmega32u4
atmega32u4: MCU_TARGET = atmega32u4
atmega32u4: CFLAGS += $(COMMON_OPTIONS) -DUART=1
atmega32u4: AVR_FREQ ?= 16000000L
atmega32u4: LDSECTIONS = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe
atmega32u4: $(PROGRAM)_atmega32u4.hex
atmega32u4: $(PROGRAM)_atmega32u4.lst
And the output was…
------ Build started: Project: xplained328p, Configuration: Debug AVR ------
Build started.
Project "xplained328p.cproj" (default targets):
Target "PreBuildEvent" skipped, due to false condition; ('$(PreBuildEvent)'!='') was evaluated as (''!='').
Target "CoreBuild" in file "C:\Program Files (x86)\Atmel\Studio\7.0\Vs\Compiler.targets" from project "C:\Users\bg-po\Downloads\optiboot-supermaster\optiboot\AtmelStudio\xplained328p.cproj" (target "Build" depends on it):
Task "RunCompilerTask"
Shell Utils Path C:\Program Files (x86)\Atmel\Studio\7.0\shellUtils
C:\Program Files (x86)\Atmel\Studio\7.0\shellUtils\make.exe -C "C:\Users\bg-po\Downloads\optiboot-supermaster\optiboot\AtmelStudio\..\bootloaders\optiboot" -f "makefile" atmega32u4
make: Entering directory 'C:/Users/bg-po/Downloads/optiboot-supermaster/optiboot/bootloaders/optiboot'
avr-gcc (AVR_8_bit_GNU_Toolchain_3.5.3_1700) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
C:\Users\bg-po\Downloads\optiboot-supermaster\optiboot\AtmelStudio\makefile(520,1): error: recipe for target 'baudcheck' failed
process_begin: CreateProcess(NULL, bash baudcheck.tmp.sh, ...) failed.
make (e=2): El sistema no puede encontrar el archivo especificado.
make: [baudcheck] Error 2 (ignored)
avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -fno-caller-saves -mmcu=atmega32u4 -DF_CPU=16000000L -DBAUD_RATE=115200 -DLED_START_FLASHES=3 -DUART=1 -c -o optiboot.o optiboot.c
In file included from optiboot.c:263:0:
C:\Users\bg-po\Downloads\optiboot-supermaster\optiboot\AtmelStudio\pin_defs.h(824,2): error: #error -------------------------------------------
#error -------------------------------------------
^
C:\Users\bg-po\Downloads\optiboot-supermaster\optiboot\AtmelStudio\pin_defs.h(825,2): error: #error Unrecognized LED name. Should be like "B5"
#error Unrecognized LED name. Should be like "B5"
^
C:\Users\bg-po\Downloads\optiboot-supermaster\optiboot\AtmelStudio\pin_defs.h(826,2): error: #error -------------------------------------------
#error -------------------------------------------
^
C:\Users\bg-po\Downloads\optiboot-supermaster\optiboot\AtmelStudio\optiboot.c(305,6): warning: #warning BAUD_RATE error greater than 2% [-Wcpp]
#warning BAUD_RATE error greater than 2%
^
optiboot.c: In function 'main':
C:\Users\bg-po\Downloads\optiboot-supermaster\optiboot\AtmelStudio\optiboot.c(553,3): error: 'LED_DDR' undeclared (first use in this function)
LED_DDR |= _BV(LED);
^
C:\Users\bg-po\Downloads\optiboot-supermaster\optiboot\AtmelStudio\optiboot.c(553,3): info: each undeclared identifier is reported only once for each function it appears in
In file included from c:\program files (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\io.h:99:0,
from optiboot.c:244:
C:\Users\bg-po\Downloads\optiboot-supermaster\optiboot\AtmelStudio\optiboot.c(553,18): error: 'LED' undeclared (first use in this function)
LED_DDR |= _BV(LED);
^
optiboot.c: In function 'flash_led':
C:\Users\bg-po\Downloads\optiboot-supermaster\optiboot\AtmelStudio\optiboot.c(886,5): error: 'LED_PIN' undeclared (first use in this function)
LED_PIN |= _BV(LED);
^
In file included from c:\program files (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\io.h:99:0,
from optiboot.c:244:
C:\Users\bg-po\Downloads\optiboot-supermaster\optiboot\AtmelStudio\optiboot.c(886,20): error: 'LED' undeclared (first use in this function)
LED_PIN |= _BV(LED);
^
make: *** [optiboot.o] Error 1
<builtin>: recipe for target 'optiboot.o' failed
make: Leaving directory 'C:/Users/bg-po/Downloads/optiboot-supermaster/optiboot/bootloaders/optiboot'
Done executing task "RunCompilerTask" -- FAILED.
Done building target "CoreBuild" in project "xplained328p.cproj" -- FAILED.
Done building project "xplained328p.cproj" -- FAILED.
Build FAILED.
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========
So, it seems that I have to declare the LED and the BAUD_RATE values… I’ve attached an image with the errors in Atmel Studio
Thank You!