NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Support Forum » issue with address for makefile (LCD kit)

June 17, 2011
by Arica
Arica's Avatar

when i try to run the "make" command in the command prompt it says "avrdude: ser_open(): can't open device "COM2": the system cannot find the file specified" "make:*** [initialload-upload] Error 1"...

i changed the makefile from "/dev/ttyUSB0" to "Com2" (switched from Com11 that i was arbitrarily assigned) per the instructions. the avrdudeflags line in the makefile reads: "AVRDUDEFLAGS=-c avr109 -p m168 -b 115200 -P COM2"

i see the troubleshooting guide says that my address is bad, but i am not sure how to fix it. any help would be appreciated.

June 18, 2011
by Rick_S
Rick_S's Avatar

That error would indicate that COM2 doesn't exist on your PC.

First, I assume you are running windows since you changed the makefile to the COMx format.

What version of Windows are you running? XP, Vista, 7? When you plugged in your programming cable, did Windows show it detected new hardware? If so, what COM port does your device manager in Windows say it assigned it?

BTW, I've never had a problem using the default assignment by Windows. Mine usualy pops in at COM10. So if Windows assigned a higher number, I'd try using it.

Rick

June 18, 2011
by Arica
Arica's Avatar

Hi Rick, Yes, I am running Windows 7. Windows did detect the new hardware and assigned it Com11 originally. I went into the device mgr and switched the port to Com2 (which was an option in the port tab--i assumed that meant that com2 existed, but i've never really messed with that)...when that didn't work, i switched back to com11...then to com1...then com2...and then back to com11 again for good measure...each time i changed the makefile to match the port, but i consistently get the same message....

i'll keep fiddling with it...if you think of something else, let me know. :) thanks.

June 18, 2011
by Rick_S
Rick_S's Avatar

With windows 7 you may need a different driver. Search the forum and you'll find a link.

June 18, 2011
by Ralphxyz
Ralphxyz's Avatar

Arica, try this driver from the Nerdkit Library

Reboot and use the default com port Windows 7 assigns do not try to switch ports.

Ralph

June 18, 2011
by Arica
Arica's Avatar

Yes, the original downloaded driver didn't work, so I googled for the new driver yesterday (tackled that problem before the "make" problem). I found a current one on the manufacturer's website and that seemed to fix the driver issue. I did go ahead and uninstall the one I found and tried the one in the link (from Ralph) but it didn't fix the problem either. I also re-downloaded the Code file just in case I accidentally did something crazy in the makefile when i had adjusted the port. That didn't do anything either. Hmm. Open to other suggestions. Thanks. :)

June 18, 2011
by Ralphxyz
Ralphxyz's Avatar

So what port is Device Manager showing?

You have to have the Nerdkit plugged in before it wil show.

Show us your initialload Makefile (use the Indent Selection as Code Block button).

Ralph

June 18, 2011
by Arica
Arica's Avatar

Device Manager shows COM11. Makefile (line 3 has the change--at the end):

GCCFLAGS=-g -Os -Wall -mmcu=atmega168 
LINKFLAGS=-Wl,-u,vfprintf -lprintf_flt -Wl,-u,vfscanf -lscanf_flt -lm
AVRDUDEFLAGS=-c avr109 -p m168 -b 115200 -P COM11
LINKOBJECTS=../libnerdkits/delay.o ../libnerdkits/lcd.o ../libnerdkits/uart.o

all:    initialload-upload

initialload.hex:    initialload.c
    make -C ../libnerdkits
    avr-gcc ${GCCFLAGS} ${LINKFLAGS} -o initialload.o initialload.c ${LINKOBJECTS}
    avr-objcopy -j .text -O ihex initialload.o initialload.hex

initialload.ass:    initialload.hex
    avr-objdump -S -d initialload.o > initialload.ass

initialload-upload: initialload.hex
    avrdude ${AVRDUDEFLAGS} -U flash:w:initialload.hex:a
June 18, 2011
by Ralphxyz
Ralphxyz's Avatar

And now what exactly are you getting? or not getting?

You can do some screen shots.

Ralph

June 18, 2011
by Arica
Arica's Avatar

this is what i am getting when i type "make" in the command prompt (per the instructions): command prompt

this is what i SHOULD be getting according to the instructions: should get this

So, my Device Mgr shows the port at Com11, the makefile has com11, but everything derails here, at the command prompt.

June 18, 2011
by Arica
Arica's Avatar

I GOT IT! ha!...i had to google makefile troubleshooting (god bless google) :)...i had to add some backslashes in front of COM11 in the makefile...the site said special syntax is required for ports higher than 9 when you are dealing with avrdude...so, i had to put "\\.\COM11" instead of just "COM11"...i ran it in the command prompt and it worked! yea!

Thanks for your help! :)

June 18, 2011
by Arica
Arica's Avatar

it's 4 backslashes, a period, and then two more backslashes...not sure why that changed when i posted....

June 19, 2011
by Rick_S
Rick_S's Avatar

Arica,

Would you care to share the link that said to put "\\\\.\\" before the COMx in your makefile. I've never had to do anything like this, and couldn't find a reference to it online.

The only troubleshooting I found for this in the AVRDUDE documentation was this:

Problem: I’m using a serial programmer under Windows and get the following error:
avrdude: serial_open(): can’t set attributes for device "com1", 
Solution: This problem seems to appear with certain versions of Cygwin. 
Specifying "/dev/com1" instead of "com1" should help.

I'm just curious what the backslash sequence is supposed to do.

Thanks,

Rick

June 19, 2011
by Noter
Noter's Avatar

"For file I/O, the "\?" prefix to a path string tells the Windows APIs to disable all string parsing and to send the string that follows it straight to the file system."


the above quote is here -

http://msdn.microsoft.com/en-us/library/aa365247(v=vs.85).aspx

June 19, 2011
by Rick_S
Rick_S's Avatar

You lost me Noter?? The slash sequence wasn't in a path, it was placed before the com11 in his parameters to AVRDUDE. From what I read he was setting his communication port parameter to

-P \\\\.\\com11 Not Sure

I had never seen that before.

Rick

June 19, 2011
by Arica
Arica's Avatar

Hi Rick,

The website was a troubleshooter for a particular product so you might not find the "why" you are looking for...

http://homesupport.irobot.com/app/answers/detail/a_id/407/~/troubleshooting-winavr-with-create%E2%AE

:) Thanks again.

June 19, 2011
by Noter
Noter's Avatar

Oops, guess I got a little sidetracked on that one. Same link but look at Win32 Device Namespace heading for the full explaination ...

The "\." prefix will access the Win32 device namespace instead of the Win32 file namespace. This is how access to physical disks and volumes is accomplished directly, without going through the file system, if the API supports this type of access. You can access many devices other than disks this way (using the CreateFile and DefineDosDevice functions, for example).

June 19, 2011
by Rick_S
Rick_S's Avatar

I had read that in the text you linked, however it seems more for file access than port communications. Also, the prefix is not the same. I'm not quite sure where the \\\\.\\ prefix comes from. I followed Arica's link and found it interesting. It's a support thread for iRobot - apparantly they are controlled with atmega168's and can be programmed with winAVR. Thus the troubleshooting section. I wonder if this was a problem with older compiled versions of AVRDUDE as my pc defaults to COM10 when I use the usb-serial adapter but it works fine...

June 19, 2011
by Noter
Noter's Avatar

It is a little confusing is because the backslash is an escape character and it takes two in a row to actually have a single backslash in the target string. By the time the string is passed to createFile() by avrdude or any other program, it actually contains only two backslashes dot backslash as a prefix.

June 19, 2011
by Arica
Arica's Avatar

ah! good to know! thank you...i'm so green. :)

June 19, 2011
by Noter
Noter's Avatar

At some point avrdude must have been changed to put the prefix on the string for the user. I searched the sources and found this in ser_win32.c.

if (strncasecmp(port, "com", strlen("com")) == 0) {

    // prepend "\\\\.\\" to name, required for port # >= 10
    newname = malloc(strlen("\\\\.\\") + strlen(port) + 1);

    if (newname == 0) {
    fprintf(stderr,
        "%s: ser_open(): out of memory\n",
        progname);
    exit(1);
    }
    strcpy(newname, "\\\\.\\");
    strcat(newname, port);

    port = newname;
}
June 19, 2011
by Rick_S
Rick_S's Avatar

Ahh, That makes more sense, kinda like here to get the 4 slashes dot 2 slashes you have to type 8.4. So Arica most likely has an older compile of avrdude than I do thus the reason I've never had to do that.

Thanks Noter! Thumbs Up

April 10, 2012
by TY68
TY68's Avatar

I just had the same issue. i was hooked up to COM3 and keep getting the same response. looking here i took out the /dev/ttyUSB0 part and put in COM3 in its place and it worked just fine. Directions should maybe a little more clear on change and say Remove or Replace that part with COM3 ect.. Im running Win7. Thanks. The forums are great for figuring out things!

Post a Reply

Please log in to post a reply.

Did you know that microcontrollers have two different kinds of memory, program space (flash) and SRAM? Learn more...