1
\$\begingroup\$

I just followed all the instructions to set up Atmel Studio on a new computer for the ATmega2560. Bare in mind that I have already had Atmel Studio installed on another computer where it worked fine, so I am not a total newbie. I did the following in "External Tools":

enter image description here

I also installed the drivers and generally did the recommended instructions.

However, when I compile a GCC C++ Executable Project, I get the following error every time in any project: avrdude.exe: ser_open(): can't open device "\\.\": The filename, directory name, or volume label syntax is incorrect.. Keep in mind that I have unplugged all other cables from my laptop, as well as from my Arduino.

And YES the COM ports are matching.

\$\endgroup\$
8
  • \$\begingroup\$ What exact evidence is the basis of your belief that it should be COM6? Can you open that device with a serial terminal program? Does something else have it open? \$\endgroup\$ Commented Nov 28, 2019 at 14:01
  • \$\begingroup\$ Also show the entire arguments line - we can only see COM6 in the title line which is meaningless \$\endgroup\$ Commented Nov 28, 2019 at 14:02
  • \$\begingroup\$ @ChrisStratton First time I plugged the Arduino into my laptop, device manager showed me COM3. So at that time I set the arguments line to COM3 like this: -CC:\Arduino\avrdude.conf -patmega2560 -cstk500v2 -P\\.\ COM3 -b115200 -Uflash:w:"$(ProjectDir)Debug\$(TargetName).hex":i Since that didn't work, I went to device manager and right clicked on "USB Serial Device (COM3)" and clicked on "Properties". Then once I was in the "Properties" window I clicked on "Port Settings" and then on "Advanced". Then I changed COM3 to COM6, which I did as well on the Arguments line. \$\endgroup\$
    – user164324
    Commented Nov 28, 2019 at 14:12
  • \$\begingroup\$ @ChrisStratton However, after having changed it to COM6 the error is still the same. \$\endgroup\$
    – user164324
    Commented Nov 28, 2019 at 14:13
  • \$\begingroup\$ Try it without the backslashes and dot, unclear why you would want that at all but the error message seems to show those escape sequences are not being interpreted here and it is mistakenly trying to use those literal characters as the port. \$\endgroup\$ Commented Nov 28, 2019 at 14:38

2 Answers 2

2
\$\begingroup\$

I set the arguments line to COM3 like this:

-CC:\Arduino\avrdude.conf -patmega2560 -cstk500v2 -P\\.\ COM3 -b115200 -Uflash:w:"$(ProjectDir)Debug\$(TargetName).hex":i 

This seems to have a mistaken shell escape sequence in the port specification.

Typically the specification to avrdude would be of the form -P COM3

For unclear reasons, you are inserting into this the escape sequence \\.\ which would typically be interpreted as \.\ however in, your case it seems not to be being interpreted by a shell (or else to be being escaped again by Atmel Studio before being passed to one).

The result is clear in your error message:

avrdude.exe: ser_open(): can't open device "\\.\": The filename, directory name, or volume label syntax is incorrect.

avrdude has been lead to believe that the name of the serial device you want to open is the first word following -P which is to say \\.\ - obviously not what you want.

The solution should simply be to specify -P COM3 or whatever the correct port is.

It's unclear what lead to the belief that the prefixing sequence you were trying to use would be appropriate elsewhere, but it is clearly inappropriate in this setting.

\$\endgroup\$
1
\$\begingroup\$

I have used tools that required the DOS device path, for example my own (using win32 createFile, setCommState and related calls), and certain other tools (e.g., pymcuprog, when I used it briefly, before serial UPDI support was integrated into AVRDude). This format is needed to access nontraditional / extended COM ports (beyond COM1-9), and other devices, through these calls.

The path shown is not correctly formed: the path specifier is \\.\ and the "file" is COMnn, all together \\.\COMnn. There is no space: that creates a new token, which AVRDude parses as an unknown option (though it doesn't seem to error out as such, unfortunately -- instead, it seems it breaks subsequent options).

I don't think AVRDude has ever needed this specifier (at least as of versions I've been using). Likely they access the port through more complicated/reliable means.

Just -P COMnn will do.

(TIL: a space after the option isn't needed. -PCOMnn also works, and similarly for other options!)

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.