Some help with .elf file

Go To Last Post
20 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi there, I was just trying to set up the AS7 to see if everything's about alright to use the atmega32 but (I guess, I don't really know if I understand the issue here) every time I try to debug the program I get the same error "recipe for target 'theproject.elf' failed" and the output

 

------ Build started: Project: GccApplication4, Configuration: Debug AVR ------
Build started.
Project "GccApplication4.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\julio\Documents\Atmel Studio\7.0\GccApplication4\GccApplication4\GccApplication4.cproj" (target "Build" depends on it):
    Using "RunCompilerTask" task from assembly "C:\Program Files (x86)\Atmel\Studio\7.0\Extensions\Application\AvrGCC.dll".
    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 all --jobs 4 --output-sync 
        Building file: .././main.c
        Invoking: AVR/GNU C Compiler : 5.4.0
        "C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe"  -x c -funsigned-char -funsigned-bitfields -DDEBUG  -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATmega_DFP\2.0.401\include"  -Og -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -g2 -Wall -mmcu=atmega32 -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATmega_DFP\2.0.401\gcc\dev\atmega32" -c -std=gnu99 -MD -MP -MF "main.d" -MT"main.d" -MT"main.o"   -o "main.o" ".././main.c" 
        Finished building: .././main.c
c:\users\julio\Documents\Atmel Studio\7.0\GccApplication4\GccApplication4\Debug\Makefile(106,1): error: recipe for target 'GccApplication4.elf' failed
        make: *** [GccApplication4.elf] Error 1
    Done executing task "RunCompilerTask" -- FAILED.
Done building target "CoreBuild" in project "GccApplication4.cproj" -- FAILED.
Done building project "GccApplication4.cproj" -- FAILED.

Build FAILED.
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========

 

 

(this is the code just in case, but it doesn't matter what I type in there it always displays the same error, so I guess that's not the problem right?)

/*
 * GccApplication4.c
 *
 * Created: 5/5/2022 9:18:37 AM
 * Author : Julio
 */ 

#include <avr/io.h>

int main(void)
{
    /* Replace with your application code */
    while (1) 
    {
    }
}

 

I tried repairing and reinstalling the atmel studio. It works just fine in assembler and I was able to write to the microcontroller with the mplab snap but I understand that's bc it doesn't need any .elf file in that case.

I also tried creating a .elf file myself from Tools>Device Programming>Production file but I definitely didn't know what I was doing because it didn't fly. I may be omitting some basic step along the way since I'm extremely new to programming avr.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Welcome to AVRFreaks!

 

The gcc compiler is an "optimizing" compiler which seems to baffle most beginners and "simple" programs they create.

Since your program above does not do anything, the compiler has optimized away any code, so your output .elf file is empty!

I would suggest using a more complex example file, or learn to program C on a PC rather then a resource limited micro....

 

Any way your off to a good start, keep going!

 

Jim

 

 

 

 

FF = PI > S.E.T

 

Last Edited: Thu. May 5, 2022 - 01:14 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

What does line 106 of the Makefile actually say ? In this error:

c:\users\julio\Documents\Atmel Studio\7.0\GccApplication4\GccApplication4\Debug\Makefile(106,1): error: recipe for target 'GccApplication4.elf' failed

it's saying that the issue is something wrong in column 1 of line 106 of the named file.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I thought that clearing out the code would maybe fix something, that's why the code's empty (there wasn't much to see before tho, just tried to blink an led). It also displayed a (based on what my untrained eye was able to see) similar error in AVR XC8 C application project, like the avr didn't generate a .elf in the debug folder. It might also just be out of my reach so I suppose I'll stick with assembler for a while. ty :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is what I found in line 106     

@echo Building target: $@

 

Sorry I didn't think of looking for that from the beginning, thx.

 

################################################################################
# Automatically-generated file. Do not edit!
################################################################################

SHELL := cmd.exe
RM := rm -rf

USER_OBJS :=

LIBS := 
PROJ := 

O_SRCS := 
C_SRCS := 
S_SRCS := 
S_UPPER_SRCS := 
OBJ_SRCS := 
ASM_SRCS := 
PREPROCESSING_SRCS := 
OBJS := 
OBJS_AS_ARGS := 
C_DEPS := 
C_DEPS_AS_ARGS := 
EXECUTABLES := 
OUTPUT_FILE_PATH :=
OUTPUT_FILE_PATH_AS_ARGS :=
AVR_APP_PATH :=$$$AVR_APP_PATH$$$
QUOTE := "
ADDITIONAL_DEPENDENCIES:=
OUTPUT_FILE_DEP:=
LIB_DEP:=
LINKER_SCRIPT_DEP:=

# Every subdirectory with source files must be described here
SUBDIRS := 

# Add inputs and outputs from these tool invocations to the build variables 
C_SRCS +=  \
../main.c

PREPROCESSING_SRCS += 

ASM_SRCS += 

OBJS +=  \
main.o

OBJS_AS_ARGS +=  \
main.o

C_DEPS +=  \
main.d

C_DEPS_AS_ARGS +=  \
main.d

OUTPUT_FILE_PATH +=GccApplication4.elf

OUTPUT_FILE_PATH_AS_ARGS +=GccApplication4.elf

ADDITIONAL_DEPENDENCIES:=

OUTPUT_FILE_DEP:= ./makedep.mk

LIB_DEP+= 

LINKER_SCRIPT_DEP+= 

# AVR32/GNU C Compiler
./main.o: .././main.c
    @echo Building file: $<
    @echo Invoking: AVR/GNU C Compiler : 5.4.0
    $(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe$(QUOTE)  -x c -funsigned-char -funsigned-bitfields -DDEBUG  -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATmega_DFP\2.0.401\include"  -Og -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -g2 -Wall -mmcu=atmega32 -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATmega_DFP\2.0.401\gcc\dev\atmega32" -c -std=gnu99 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)"   -o "$@" "$<" 
    @echo Finished building: $<
    

# AVR32/GNU Preprocessing Assembler

# AVR32/GNU Assembler

ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(C_DEPS)),)
-include $(C_DEPS)
endif
endif

# Add inputs and outputs from these tool invocations to the build variables 

# All Target
all: $(OUTPUT_FILE_PATH) $(ADDITIONAL_DEPENDENCIES)

$(OUTPUT_FILE_PATH): $(OBJS) $(USER_OBJS) $(OUTPUT_FILE_DEP) $(LIB_DEP) $(LINKER_SCRIPT_DEP)
//the line of the error//    @echo Building target: $@
    @echo Invoking: AVR/GNU Linker : 5.4.0
    $(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe$(QUOTE) -o$(OUTPUT_FILE_PATH_AS_ARGS) $(OBJS_AS_ARGS) $(USER_OBJS) $(LIBS) -Wl,-Map="GccApplication4.map" -Wl,--start-group -Wl,-lm  -Wl,--end-group -Wl,--gc-sections -mmcu=atmega32 -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATmega_DFP\2.0.401\gcc\dev\atmega32"  
    @echo Finished building target: $@
    "C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -O ihex -R .eeprom -R .fuse -R .lock -R .signature -R .user_signatures  "GccApplication4.elf" "GccApplication4.hex"
    "C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -j .eeprom  --set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0  --no-change-warnings -O ihex "GccApplication4.elf" "GccApplication4.eep" || exit 0
    "C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objdump.exe" -h -S "GccApplication4.elf" > "GccApplication4.lss"
    "C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -O srec -R .eeprom -R .fuse -R .lock -R .signature -R .user_signatures "GccApplication4.elf" "GccApplication4.srec"
    "C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-size.exe" "GccApplication4.elf"
    
    

# Other Targets
clean:
    -$(RM) $(OBJS_AS_ARGS) $(EXECUTABLES)  
    -$(RM) $(C_DEPS_AS_ARGS)   
    rm -rf "GccApplication4.elf" "GccApplication4.a" "GccApplication4.hex" "GccApplication4.lss" "GccApplication4.eep" "GccApplication4.map" "GccApplication4.srec" "GccApplication4.usersignatures"

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Are you sure you counted 106 correctly? (an editor like Notepad++ that shows line numbers is a good idea!). It seems unlikely "echo" is returning ERRORLEVEL!=0 could it be the line after:

$(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe$(QUOTE) -o$(OUTPUT_FILE_PATH_AS_ARGS) $(OBJS_AS_ARGS) $(USER_OBJS) $(LIBS) -Wl,-Map="GccApplication4.map" -Wl,--start-group -Wl,-lm  -Wl,--end-group -Wl,--gc-sections -mmcu=atmega32 -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATmega_DFP\2.0.401\gcc\dev\atmega32" 

in which case I would be checking details of this line. Like is that an avr-gcc.exe at the path location given? Is the a 2.0.401 device pack for mega32 at the location given and so on.

 

Oh and if you do a "clean all" first then try to build does the error persist?

Last Edited: Thu. May 5, 2022 - 02:20 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Copy Paste the Output tab after doing a clean build and post your results

 

FF = PI > S.E.T

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I don't know if I understood correctly, but if the idea was to check if those directions were correct then yes, they appear to be in the addresses that the makefile specifies. 

I did a rebuild and this was the output (the error does persist tho, but perhaps I did smth wrong so tell me if so)

 

------ Rebuild All started: Project: GccApplication4, Configuration: Debug AVR ------
Build started.
Project "GccApplication4.cproj" (Clean target(s)):
Target "Clean" in file "C:\Program Files (x86)\Atmel\Studio\7.0\Vs\Compiler.targets" from project "C:\Users\Julio\Documents\Atmel Studio\7.0\GccApplication4\GccApplication4\GccApplication4.cproj" (entry point):
    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 clean 
        rm -rf  main.o   
        rm -rf  main.d   
        rm -rf "GccApplication4.elf" "GccApplication4.a" "GccApplication4.hex" "GccApplication4.lss" "GccApplication4.eep" "GccApplication4.map" "GccApplication4.srec" "GccApplication4.usersignatures"
    Done executing task "RunCompilerTask".
Done building target "Clean" in project "GccApplication4.cproj".
Done building project "GccApplication4.cproj".

Build succeeded.
------ Rebuild All started: Project: GccApplication4, Configuration: Debug AVR ------
Build started.
Project "GccApplication4.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\Julio\Documents\Atmel Studio\7.0\GccApplication4\GccApplication4\GccApplication4.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 all --jobs 4 --output-sync 
        Building file: .././main.c
        Invoking: AVR/GNU C Compiler : 5.4.0
        "C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe"  -x c -funsigned-char -funsigned-bitfields -DDEBUG  -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATmega_DFP\2.0.401\include"  -Og -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -g2 -Wall -mmcu=atmega32 -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATmega_DFP\2.0.401\gcc\dev\atmega32" -c -std=gnu99 -MD -MP -MF "main.d" -MT"main.d" -MT"main.o"   -o "main.o" ".././main.c" 
        Finished building: .././main.c
C:\Users\Julio\Documents\Atmel Studio\7.0\GccApplication4\GccApplication4\Debug\Makefile(106,1): error: recipe for target 'GccApplication4.elf' failed
        make: *** [GccApplication4.elf] Error 1
    Done executing task "RunCompilerTask" -- FAILED.
Done building target "CoreBuild" in project "GccApplication4.cproj" -- FAILED.
Done building project "GccApplication4.cproj" -- FAILED.

Build FAILED.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

 

Last Edited: Thu. May 5, 2022 - 03:15 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Still not obvious what the issue is, can you zip up your project dir and post it here (you will need to change the .zip ext to .txt before uploading). 

then one of the gcc freaks can help debug whats wrong.....

 

 

 

FF = PI > S.E.T

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi, sorry I was out for a while

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


ki0bk wrote:
(you will need to change the .zip ext to .txt before uploading). 
Err? Why?

That list includes zip and rar.

 

Anyway I downloaded the file and changed it back to a .rar and ended up with:

 

 

So basically i built without issue.

 

However it is true that I did not have the right device pack and when it loaded and said "you need to download pack n.n.n" I just skipped that (don't have Admin rights on this PC) so it may have worked because it reverted to using the native device support rather than the -B option to use 2.0.401

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry for my ignorance here. So based on that I should delete the 2.0.401 version or is there a way to tune it up in the atmel studio?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The project is not complex so I'd just create the whole thing from scratch again and see if the problem goes away. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The thing is that the error (that "recipe for target '...' failed") remains no matter what type of project I attempt to build in C or C++. Is there something that you need to set up before you are able create a project in atmel studio?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

No it sounds like there is something wrong in your installation. I'd uninstall it, remove all traces then reinstall. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, that didn't do it but thank you anyway. Would you recommend mplabx for avr then or I'm better off looking for some other ide?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I wouldn't touch MPLABX with a long pole but that's just me.

 

Never had a moment's worry with Studio 7.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


Reading the elf file:

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I understand there should be some more files but this is all I get in the debug folder

Attachment(s): 

Last Edited: Sun. May 8, 2022 - 02:02 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just in case anyone who reads this has the same issue. I don't really know why it is so, but by importing the project from AS7 to MPLABX I was able to get the .hex file and program to the mcu just like it was the same project. If I try and create the project directly into MPLABX I get the exact same error I previously received in AS7 tho, so if anyone knows why that was or wants to share you're welcome to do so.