Upload BOOTLOADER + APPLICATION via JTATG for debugging in AtmelStudio

Hi!

I’ve edited a atmel studio project based on: optiboot/optiboot/AtmelStudio at supermaster · majekw/optiboot · GitHub

I’v have made only this changes: contribute fix for hardware UART 1, 2, and 3 by dmjlambert · Pull Request #130 · Optiboot/optiboot · GitHub

Most significant one in “Makefile.extras”:

#
# 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

But when I try to compile with the CommandLine: “atmega32u4”, I obtain this:

------ 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'
		make: *** No rule to make target 'C:/Program', needed by 'atmega32u4'.  Stop.
		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 ==========

QUESTION:
I want know how to merge this project with another one where is my application. I know how to merge it. But I think that due to “how makefile is made” I can’t upload directly via JTAG as I’m doing with mi sketch without the bootloader.

All that I want Is compile both, sketch and bootloader and upload those merged to my arduino for debugging via JTAG (using AVR Dragon in Atmel Studio).

I'm pretty clueless with makefiles and know nothing about Atmel Studio but I'll give it a try.

The first thing that jumps out at me is:

daberrrio:

 make: *** No rule to make target 'C:/Program', needed by 'atmega32u4'.  Stop.

This indicates you needed to put that path in quotes.

I've never used Atmel Studio so maybe you're already doing this but if I was running this from the command line it would be something like:

make -f Makefile.extras atmega32u4

The reason for the -f is the makefile with your target doesn't have a standard name. Normally you could just do "make atmega32u4" but if you do that in this case it will try to run the file named "Makefile" which doesn't have the atmega32u4 target.

Just for Giggles, I cloned that github and ran make from Linux (Ubuntu 16.04).

rsutherland@straightneck:~/Samba/optiboot/optiboot/bootloaders/optiboot$ make atmega32u4
avr-gcc (GCC) 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.

BAUD RATE CHECK: Desired: 115200, Real: 117647, UBRRL = 16, Error=-2.1%
avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega32u4 -DF_CPU=16000000L  -DBAUD_RATE=115200 -DLED_START_FLASHES=3      -DUART=1   -c -o optiboot.o optiboot.c
optiboot.c:159:1: warning: "/*" within comment [-Wcomment]
 /* Aug 2014        */
 ^
In file included from optiboot.c:266:0:
pin_defs.h:824:2: error: #error -------------------------------------------
 #error -------------------------------------------
  ^
pin_defs.h:825:2: error: #error Unrecognized LED name. Should be like "B5"
 #error Unrecognized LED name.  Should be like "B5"
  ^
pin_defs.h:826:2: error: #error -------------------------------------------
 #error -------------------------------------------
  ^
optiboot.c:305:2: warning: #warning BAUD_RATE error greater than -2% [-Wcpp]
 #warning BAUD_RATE error greater than -2%
  ^
optiboot.c: In function âmainâ:
optiboot.c:481:3: error: âLED_DDRâ undeclared (first use in this function)
   LED_DDR |= _BV(LED);
   ^
optiboot.c:481:3: note: each undeclared identifier is reported only once for each function it appears in
In file included from /usr/lib/avr/include/avr/io.h:99:0,
                 from optiboot.c:247:
optiboot.c:481:18: error: âLEDâ undeclared (first use in this function)
   LED_DDR |= _BV(LED);
                  ^
optiboot.c: In function âflash_ledâ:
optiboot.c:788:5: error: âLED_PINâ undeclared (first use in this function)
     LED_PIN |= _BV(LED);
     ^
In file included from /usr/lib/avr/include/avr/io.h:99:0,
                 from optiboot.c:247:
optiboot.c:788:20: error: âLEDâ undeclared (first use in this function)
     LED_PIN |= _BV(LED);
                    ^
<builtin>: recipe for target 'optiboot.o' failed
make: *** [optiboot.o] Error 1

WestfW seems to have made the LED into an option so:

rsutherland@straightneck:~/Samba/optiboot/optiboot/bootloaders/optiboot$ make atmega32u4 LED=B5
avr-gcc (GCC) 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.

BAUD RATE CHECK: Desired: 115200, Real: 117647, UBRRL = 16, Error=-2.1%
avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega32u4 -DF_CPU=16000000L  -DBAUD_RATE=115200 -DLED_START_FLASHES=3    -DLED=B5  -DUART=1   -c -o optiboot.o optiboot.c
optiboot.c:159:1: warning: "/*" within comment [-Wcomment]
 /* Aug 2014        */
 ^
optiboot.c:305:2: warning: #warning BAUD_RATE error greater than -2% [-Wcpp]
 #warning BAUD_RATE error greater than -2%
  ^
avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -mmcu=atmega32u4 -DF_CPU=16000000L  -DBAUD_RATE=115200 -DLED_START_FLASHES=3    -DLED=B5  -DUART=1 -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe -Wl,--relax -nostartfiles -nostdlib -o optiboot_atmega32u4.elf optiboot.o -lc
avr-size optiboot_atmega32u4.elf
   text    data     bss     dec     hex filename
    470       0       0     470     1d6 optiboot_atmega32u4.elf
avr-objcopy -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex optiboot_atmega32u4.elf optiboot_atmega32u4.hex
avr-objdump -h -S optiboot_atmega32u4.elf > optiboot_atmega32u4.lst
rm optiboot.o optiboot_atmega32u4.elf
#
# 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:

if I was running this from the command line it would be something like:

make -f Makefile.extras atmega32u4

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 :frowning:

westfw:
No, in this case, the main Makefile includes the extra makefiles itself, so you should never have to use "-f"

Thanks for correcting me on that! I haven't used an optiboot makefile with the various targets split off. That's a very good system!

I should clarify that I cloned from GitHub - dmjlambert/optiboot: Small and Fast Bootloader for Arduino and other Atmel AVR chips

So that is why it worked. The OP linked to that pull request and I followed it up to that repo... cloned and... well Github is a little confusing.

Thanks for going through that @westfw, I am struggling with Makefiles, but they are too useful to be ignored.

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!

Your baudrate stuff is OK; you just don't have a shell installed, so you can't run the shell script that pretty-prints baud rate statistics. The error message about baudcheck.tmp.sh can be ignored (and the build did continue...)

The error about LED is because there is no section in pin_defs.h that defines the default value for LED on a 32u4 chip. All of the existing defaults are inside of "#if defined(AVR_ATmega1280)" and similar. The easiest fix is probably to change the line

atmega32u4: CFLAGS += $(COMMON_OPTIONS) -DUART=1

To

atmega32u4: CFLAGS += $(COMMON_OPTIONS) -DUART=1 -DLED=B1

(or whatever pin you wanted.)
(Or you can modify the pin_defs.h file, or as you suggested, set up the recursive make. But that would be more difficult.)

westfw:
Your baudrate stuff is OK; you just don’t have a shell installed, so you can’t run the shell script that pretty-prints baud rate statistics. The error message about baudcheck.tmp.sh can be ignored (and the build did continue…)

The error about LED is because there is no section in pin_defs.h that defines the default value for LED on a 32u4 chip. All of the existing defaults are inside of “#if defined(AVR_ATmega1280)” and similar. The easiest fix is probably to change the line

atmega32u4: CFLAGS += $(COMMON_OPTIONS) -DUART=1

To

atmega32u4: CFLAGS += $(COMMON_OPTIONS) -DUART=1 -DLED=B1

(or whatever pin you wanted.)
(Or you can modify the pin_defs.h file, or as you suggested, set up the recursive make. But that would be more difficult.)

Thank you!!

I’ve changed the following line in makefile.extras:

atmega32u4: CFLAGS += $(COMMON_OPTIONS) -DUART=1 -DLED=B0

And when I compile, i get:

------ 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 -DLED=B0   -c -o optiboot.o optiboot.c
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%
      ^
 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 -DLED=B0 -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe -Wl,--relax -nostartfiles -nostdlib -o optiboot_atmega32u4.elf optiboot.o -lc
      0 [main] sh 1312 sync_with_child: child 5800(0x154) died before initialization with status code 0xC0000142
 avr-size optiboot_atmega32u4.elf
   text   data    bss    dec    hex filename
    508      0      0    508    1fc optiboot_atmega32u4.elf
 avr-objcopy -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex optiboot_atmega32u4.elf optiboot_atmega32u4.hex
 avr-objdump -h -S optiboot_atmega32u4.elf > optiboot_atmega32u4.lst
     15 [main] sh 1312 sync_with_child: *** child state waiting for longjmp
 /usr/bin/sh: fork: Resource temporarily unavailable
C:\Users\bg-po\Downloads\optiboot-supermaster\optiboot\AtmelStudio\makefile(539,1): error: recipe for target 'optiboot_atmega32u4.lst' failed
 make: *** [optiboot_atmega32u4.lst] Error 128
 rm optiboot.o optiboot_atmega32u4.elf
 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 ==========

I’ve attached the error in png format.

Looks like the compile worked, and generated the .hex file.
I'm not sure why it had troubles with the .LST file - I haven't seen that one before.

Edit: repetead post

westfw:
Looks like the compile worked, and generated the .hex file.
I'm not sure why it had troubles with the .LST file - I haven't seen that one before.

It looks like... But I can't find the hex file in any path... EDIT: i found it in "optiboot-supermaster\optiboot\bootloaders\optiboot"

I'll have to investigate more to fix the lst error.

Thank you very much!

westfw:
Looks like the compile worked, and generated the .hex file.
I'm not sure why it had troubles with the .LST file - I haven't seen that one before.

Yes! I did it! I fixed like in this post: http://www.avrfreaks.net/forum/windows-81-compilation-error?page=all

Now, I can compile and I can generate both .hex and .lst files.

Another question, I want know how to merge this project with another one where is my application. I know how to merge it. But I think that due to "how makefile is made" I can't upload directly via JTAG as I'm doing with mi sketch without the bootloader.

All that I want Is compile both, sketch and bootloader and upload those merged to my arduino for debugging via JTAG (using AVR Dragon in Atmel Studio).

Probably better start with uploading your application to the bootloader, are you able to do that?

If not then have a look at the Tools->External_Tools, that can be made to work with "avrdude -c arduino ...", but I did not keep notes. I hope your AVR_Dragon is better than the one I got, I fear my USB connector is going to fall off, so I use ArduinoISP mostly.

ron_sutherland:
Probably better start with uploading your application to the bootloader, are you able to do that?

If not then have a look at the Tools->External_Tools, that can be made to work with "avrdude -c arduino ...", but I did not keep notes. I hope your AVR_Dragon is better than the one I got, I fear my USB connector is going to fall off, so I use ArduinoISP mostly.

What do you mean?

Via JTAG using AVR Dragon, in Tools>Device Programming>Memories I can program any hex file that I want. All that I've made and works it's: erasing memory, program the bootloader, and then program the application without erasing memory.

But I want to debug my full program (application + bootloader) step by step. And if I do it of that way, I can't do it. I only know program the application (without de bootloader) and debug it step by step.

Thank you man!

You are trying to do things beyond my understanding, good luck.