Problem programming Arduino UNO in Atmel Studio 7

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


I'm trying to use my Arduino UNO as a regular ATmega328p uC. So I installed the lattest version of Arduino IDE to be able to configure my Arduino Uno as an external tool.

For the external tool I used these routes:

Command: C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude.exe

Arguments: -C"C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf" -v -patmega328p -carduino -PCOM4 -b115200 -D -Uflash:w:"$(ProjectDir)Debug\$(TarjetName).hex":i

 

I have already verified the folder and the .hex file does exist, and the AVRdude is able to detect and read the Arduino because in the Output window I get this:

 

avrdude.exe: Version 6.3-20190619

             Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

             Copyright (c) 2007-2014 Joerg Wunsch

             System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

             Using Port                    : COM4

             Using Programmer              : arduino

             Overriding Baud Rate          : 115200

             AVR Part                      : ATmega328P

             Chip Erase delay              : 9000 us

             PAGEL                         : PD7

             BS2                           : PC2

             RESET disposition             : dedicated

             RETRY pulse                   : SCK

             serial program mode           : yes

             parallel program mode         : yes

             Timeout                       : 200

             StabDelay                     : 100

             CmdexeDelay                   : 25

             SyncLoops                     : 32

             ByteDelay                     : 0

             PollIndex                     : 3

             PollValue                     : 0x53

             Memory Detail                 :

                                      Block Poll               Page                       Polled

               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack

               ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------

               eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff

               flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff

               lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00

               hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00

               efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00

               lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00

               calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00

               signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

             Programmer Type : Arduino

             Description     : Arduino

             Hardware Version: 3

             Firmware Version: 4.4

             Vtarget         : 0.3 V

             Varef           : 0.3 V

             Oscillator      : 28.800 kHz

             SCK period      : 3.3 us

avrdude.exe: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude.exe: Device signature = 0x1e950f (probably m328p)

avrdude.exe: safemode: lfuse reads as 0

avrdude.exe: safemode: hfuse reads as 0

avrdude.exe: safemode: efuse reads as 0

avrdude.exe: reading input file "C:\Users\Public\Atmel\GccApplication1\GccApplication1\Debug\.hex"

avrdude.exe: can't open input file C:\Users\Public\Atmel\GccApplication1\GccApplication1\Debug\.hex: No such file or directory

avrdude.exe: read from file 'C:\Users\Public\Atmel\GccApplication1\GccApplication1\Debug\.hex' failed

avrdude.exe: safemode: lfuse reads as 0

avrdude.exe: safemode: hfuse reads as 0

avrdude.exe: safemode: efuse reads as 0

avrdude.exe: safemode: Fuses OK (E:00, H:00, L:00)

avrdude.exe done.  Thank you.

 

The real problem comes here:

avrdude.exe: reading input file "C:\Users\Public\Atmel\GccApplication1\GccApplication1\Debug\.hex"

avrdude.exe: can't open input file C:\Users\Public\Atmel\GccApplication1\GccApplication1\Debug\.hex: No such file or directory

avrdude.exe: read from file 'C:\Users\Public\Atmel\GccApplication1\GccApplication1\Debug\.hex' failed

 

And in the device name:

...Debug\.hex: No such file or directory

Because it doesn't get the right name of the .hex file, it just search for one "noname".hex file

I tried to modify the param $(ProjectDir)Debug\$(TarjetName).hex

with (ProjectName) because the .hex file has the same name than the project.

also tried $GccApplication1.hex (the current file name and nothing).

 

So I think the could be another parameter that could replace (TarjetName).hex

Here is the simple code I'm trying to run:

 

/*
 * GccApplication1.c
 *
 * Created: 05/04/2020 07:56:35 p. m.
 * Author : Abraham Macías
 */ 

#include <avr/io.h>

int main(void)
{
	DDRB |= (1<<DDB5);
    /* Replace with your application code */
    while (1)
    {
		PORTB |= (1<<PORTB5);
    }
}

And here is the route and files in the folder:

 

Atmel Studio 7:

This topic has a solution.
Last Edited: Mon. Apr 6, 2020 - 02:13 PM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

My Arguments are:

-carduino -Pcom55 -pm328p -Uflash:w:$(TargetName).hex:i

And Initial Directory is:

$(TargetDir)

Your Tool is finding the avrdude.conf file successfully.   I assume the COM4 suits your PC.

But you have a convoluted (but correct) way of specifying the HEX file:

-patmega328p -carduino -PCOM4 -b115200 -D -Uflash:w:"$(ProjectDir)Debug\$(TarjetName).hex":i

The problem is:

C:\Users\Public\Atmel\GccApplication1\GccApplication1\Debug\.hex

i.e. it does not expand $(TargetName) correctly.

You appear to come from Ireland.   So I would expect $(TargetName) to be spelled with a g and not with a j

 

Note that you should make sure that your project is selected in the Solution Explorer for the macros to expand properly.

 

David.

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

WOW!!!! Indeed that was the problem!!! Thanks soo much!!! Solved!!!

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

 

Just a tip for the future but you should never need to (mis)type things like $(TargetName) anyway. When you are editing commands like this note the arrow at the end of the "Arguments" line:

 

If you select "Target Name" off this list it auto inserts:

 

 

So I never had to type any of that.

Last Edited: Mon. Apr 6, 2020 - 02:22 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What nationality is this ?

Author : Abraham Macías

The screenshots show directories in Spanish.    I just assumed that Tarjet was a valid word in another language.

 

Google suggests "target" is objetivo

 

David.

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

david.prentice wrote:
I just assumed that Tarjet was a valid word in another language.

That's Cliff's point (I think)  - by using the menu selections, you cannot possibly select something that isn't valid in Atmel Studio's language.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Mon. Apr 6, 2020 - 02:44 PM