loading

compiler wont compile, cant figure out the errors, help please?

i have a problem programming my stealth USB caps locker (link
the PCB is ready, the components soldered on, and ive made connections to my ghetto programmer.
now, i opened programmers notepad and wanted to program it, but now it just gives a whole load of errors:

> "make.exe" program

Linking: main.elf
avr-gcc -mmcu=attiny45 -I. -g -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=main.o  -std=gnu99 main.o   --output main.elf -Wl,-Map=main.map,--cref -lm
main.o: In function `usbFunctionSetup':
I:\portableapps\programmers notepad\programma's\CapsLocker/main.c:108: undefined reference to `usbMsgPtr'
I:\portableapps\programmers notepad\programma's\CapsLocker/main.c:108: undefined reference to `usbMsgPtr'
I:\portableapps\programmers notepad\programma's\CapsLocker/main.c:115: undefined reference to `usbMsgPtr'
I:\portableapps\programmers notepad\programma's\CapsLocker/main.c:115: undefined reference to `usbMsgPtr'
main.o: In function `main':
I:\portableapps\programmers notepad\programma's\CapsLocker/main.c:211: undefined reference to `usbInit'
I:\portableapps\programmers notepad\programma's\CapsLocker/main.c:215: undefined reference to `usbPoll'
I:\portableapps\programmers notepad\programma's\CapsLocker/main.c:222: undefined reference to `usbTxLen1'
I:\portableapps\programmers notepad\programma's\CapsLocker/main.c:224: undefined reference to `usbSetInterrupt'
main.o: In function `calibrateOscillator':
I:\portableapps\programmers notepad\programma's\CapsLocker/main.c:150: undefined reference to `usbMeasureFrameLength'
I:\portableapps\programmers notepad\programma's\CapsLocker/main.c:160: undefined reference to `usbMeasureFrameLength'
make.exe: *** [main.elf] Error 1

> Process Exit Code: 2
> Time Taken: 00:01


i believe its a problem with the makefile, but i cant find out what it is anyway.
heres the complete zip file: zip file
the makefile in that zip doesnt work (for me) so i use one of another program, and with that i get the errors placed above.
if you need that makefile, please leave a reply, il try to get it online.




sort by: active | newest | oldest
gmoon7 years ago
The suite of programs that constitute "AVR-GCC" (which has been repackaged as WinAVR for Windows), is a whole LOT of different, smaller programs. Each one does a single, specific task.

They are all "shell," or command-line programs. Think "DOS" style--the programs don't have GUIs. It also means that it's VERY easy to port the programs to different operating systems (such as Windows.)

This approach follows the Unix (or Linux) philosophy, rather than the Microsoft way. A Linux machine can be anything from a minimalist router to a full-featured desktop.

All those component programs work together to compile, link, debug, etc. the "C" source code.

Since the operation of each individual program is quite complex, Unix programmers created a tool that would remember, and do the hard work for them: make is that tool.

However, if you're a glutton for punishment, you could enter the arguments for each program by hand (I wouldn't recommend it.)

But avrdude is pretty simple, and using it to transfer binary code to the AVR doesn't effect ANY of the preceeding steps. Like many of the other programs, it has only a single task, and it's the last one in the chain.

Let's see how this might work:
-------------------------------

Opening a CMD line (shell) in Windows

(I'm still using XP, but you should be able to find this...)

C:\WINDOWS\system32\cmd.exe

Or

"Run" menu (from the Start button), and type "cmd.exe"

This will open a DOS style window. That's the "shell."
-------------------------------

Changing the current DIR

Usually, the CMD line will open to a location like:
C:\Documents and Settings\Bob

You must "navigate" to where your .hex file is. Use the "chdir" command. For instance, if the file is located on the "Desktop\misc" directory:

chdir Desktop\misc

Of course, yours will be somewhere else. You should be able to see the files in the current DIR by typing:

dir

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

Running avrdude

With everything connected to your DAPA programmer, try typing in the following into the CMD line:

avrdude -p t45 -c dapa -e -U flash:w:capslocker.hex

That should do the trick...

It will only work with an ATtiny45 and the DAPA interface...
---------------------------------

Here are all the avrdude CMD arguments:
http://www.nongnu.org/avrdude/user-manual/avrdude_4.html#SEC4

You can explore the different commands; see the other partno's (part numbers for AVR chips), etc...
godofal (author)  gmoon7 years ago
nice, il try this tomorow, at this time im at my dad's, he has windows 7
(thank god for free upgrade from windows vista, it was a nightmare, rebooting every time couse there was an error, giving admin permission to change the friggin name of a folder, etc, etc, etc, etc, etc, etc, etc, etc on the etc...)
anyway, my own computer uses windows XP service pack3, its really great i havent really explored windows 7 yet, but what ive seen, XP still kicks all windows versions... (just realised i uses  "anyway," again :D)
so, il get back to u tomorow if it worked/didnt work.

anyway, thank u so much for helping me :D
i must take up alot of ur time with this simple thingie :)
where do u live, maybe i could send u one of those capslockers if theyr done...
gmoon godofal7 years ago
You're welcome--good luck. It's frustrating to work with a CMD line, but that's what you've got...

Later we could work on creating a batch file to simplify the process...maybe even edit the Makefiles.

I live in a far-away, magical land called "Ohio" ;-)
(you don't need to send me anything, I'm happy to help...)
godofal (author)  gmoon7 years ago
ohio? US?
anyway, happy newyear, we got 15 minutes left on 2009 at this moment

dmnit, again "anyway"
i always realise such things just a bit to late :D
wow, i was on the point of writing it again but catched myself now XD

maybe we should get eachothers MSN, then we can use that, its about the same right now, just a bit quicker i think :)
anyway, (dmnit) PM me ur MSN if u want, il be on in about 14 hours from now (14:00 in holland) i think (with the help of internet of course) that it would be 19:00 for u then.
so, if u PM me ur MSN, il be on on that time tomorow (1-1-2010)

bye the way, if u dont for whatever reason, i understand, im not that easy with trusting ppl over the net myself either :D
godofal (author)  godofal7 years ago
yay! succes!
avrdude verified 2590 bytes of flash :)
gonna test it now :D
test test, make this text capslocked....
cmon
damn! USB device is  not recognized :(
gmoon godofal7 years ago
Ah, cool!

Hmm. I don't know too much about the capslocker, but it might require resetting the clock speed on the ATtiny45 to work at USB speeds.

Those are changed via the "fuse" settings--which is also done with avrdude...

If it's necessary, best to be careful here--you can reset the fuses in such a way as to "brick" the chip.

For instance, changing to an external crystal setting. If no crystal is present, the device won't work, and can't easily be reprogrammed...
godofal (author)  gmoon7 years ago
those fuse thingies is the time it takes between pulses or something like that right?
like if it needs to send 00100 (just gibberish) to the USB port to activate the capslock, it would take like a second between the 2 digits (i know its ALOT shorter than that) but it actually needs to take like 2 seconds?

and if so, how would i know what the right/safe speed is that i need?
gmoon godofal7 years ago
Not exactly. The "fuse bits" on an AVR can be programmed like the internal memory, but instead they configure the device.

They change things like:
-- speed of the internal clock oscillator
-- instruct the chip to use an external crystal or oscillator

For your project, it looks like 16.5 MHz is the correct clock speed. But that's not the default speed (12 MHz), so you need to change it.

How do I know this?

(1) From the source files (usbconfig.h):

#define USB_CFG_CLOCK_KHZ       (F_CPU/1000)
/* Clock rate of the AVR in MHz. Legal values are 12000, 16000 or 16500.
 * The 16.5 MHz version of the code requires no crystal, it tolerates +/- 1%
 * deviation from the nominal frequency. All other rates require a precision
 * of 2000 ppm and thus a crystal!
 * Default if not specified: 12 MHz
 */

(2) And from AVR Studio configuration:

-DF_CPU=16500000UL

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

From those two clues, we know that the clock speed should be 16.5 MHz (16500000), using the internal oscillator.

WARNING!
Changing fuse bits fundamentally changes the operational characteristics of the device. And that includes how it responds to programming.

It's very possible (in fact, it's common with beginners) to render an AVR unresponsive if a fuse bit is changed erroneously.

Like I said, if you change the clock to an external crystal, but no crystal is connected. Well, then it won't work at all--it will perpetually be waiting for a clock signal, and no internal instructions will execute.

gmoon gmoon7 years ago
There's very little documentation about fuses on the Capslocker webpage, and he's using a programmer that's supported by AVR Studio, so it doesn't use avrdude.

But he does indicate it's based on Easylogger, which includes a Makefile that has avrdude "fuse" programming. And the Easylogger is also configured for 16.5 MHz.

So it's highly likely that the "fuse bit" information in Easylogger will work with your project.

If you're feeling brave, try this (using the same cmd.exe method as before)--

avrdude -p t45 -c dapa -U hfuse:w:0xdd:m -U lfuse:w:0xe1:m
gmoon gmoon7 years ago
And make sure you type it in EXACTLY. One letter off in the hfuse or lfuse instructions could brick the AVR...
godofal (author)  gmoon7 years ago
im testing it on this PC right now. so if u see caps, it works!
i just found 1 big problem, i needed to solder some extra leads to the AVR to program it, and while i transported the device, one of those leads broke off, with the AVR lead with it...
so, im missing 1 lead for programming >.<
anyway, i dont have any "USB device not detected" or anything, so it should work *crosses fingers*
what is the time for the first capslock? its in the code right?
gmoon godofal7 years ago
I'm not what capslocker actually does...maybe you'll see the "caps lock" light change periodically? But the signs sound hopeful...

Anyway, to your other questions:

-- Changing the "fuse bits" is separate. No, you don't need to reprogram the AVR again.

-- Is it a "one shot deal?" No, you've only changed the CPU clock from 12 MHz to 16.5 MHz. I'm not sure how well the DAPA cable will work at the higher speed, but theoretically, it should still function.

There probably is a speed limitation with DAPA, but I'm not sure what that is. The length of the cable could also effect it's performance at higher rates.

Try the "test" I mentioned before, just to see if the PC and the AVR are communicating...
gmoon gmoon7 years ago
One way to see if it's functioning is to search the system for any USB connections. Try checking the "system information" under windows. Then look for USB devices.

(under Start / Accessories / System tools / System Information in XP)

Or Control Panel / Hardware.
godofal (author)  gmoon7 years ago
u say same method, but does that include that
avrdude -p t45 -c dapa -e -U flash:w:capslocker.hex
line for programming the chip?
if so, what order? first program and then change the fuse (wich would be my guess since changins fuse settings (if i read correctly) makes it impossible to reprogram)
godofal (author)  gmoon7 years ago
so, i have 1 shot at this? if i mess up i cant reprogram?
gmoon7 years ago
The dependency locations (include files, etc.) in the Makefile are set for their original directories. When you download it, the Makefile can't find them.

I followed the "Stealth USB" page link above. The author created it in AVR Studio.

So I downloaded and unzipped the source, then clicked on the "capslocker.aps" file. That loaded AVR Studio (yes, I already have that installed, along with win-avr.)

I clicked Debug. AVR Studio then asked me 5 or 6 times to select where the different include files, and the Capslocker source code were now located.

Once that was finished, I was able to select Build successfully. The source compiled without errors.

So using AVR Studio is the easiest way to reconfigure the Makefile. I suppose it could be edited by hand, but Makefiles are harder to grok than C source...
gmoon gmoon7 years ago
One more thing:
In normal operation, make is invoked simply by typing "make" (or "make.exe" in windoz) in the shell. And there must be a Makefile in the current directory. Anything you type after "make.exe" is instructing make to follow that "rule."

I don't see any rule in the Makefile for "program" -- some Makefiles do include code to program the AVR, but this one does not.

So even if you compile the code correctly, you'll need to write a "programming" script, or just use AVR Studio to upload to the chip.
godofal (author)  gmoon7 years ago
im not experienced enough (yet :D) in programming to figure out what u just said in these last 2 replys (only that avr studio doesnt work with that programmer im using, and that the makefiles that im using dont work either)

about those 2 options, what should be in that  makefile/batch?

id like that batch file, but il probably need step to step instructions on how to use it :P

about that make stuff, ur saying that i can make a regular makefile, just type the right stuff (make.exe?) say include X for everything it needs and then it works?

and if avrstudio doesnt work with that programmer of mine, its pretty much useless for me (at this point)
does it  support the USBtiny from  ladyada.net? im going to make one of those soon :)
godofal (author)  godofal7 years ago
ive downloaded avr studio, but it wont open the project...
i use project>open project>capslocker.aps and it just stops responding, i have  to shut down the process, just to get it shut down...
godofal (author)  godofal7 years ago
btw,  just clicking capslocker.aps doesnt work either
gmoon godofal7 years ago
You've been moving source files around, though? Maybe that messes up AVR Studio. Try it again by unzipping the original archive.

Do you have win-avr installed correctly?

Let me dig up the batchfile tomorrow...we celebrated Xmas today, and I'm beat. It's not hard to use.

Of course, it won't be much use if you can't compile the code.

Using gcc (the open source C compilter) is frustrating at first, especially if you don't have experience in unix or linux...
godofal (author)  gmoon7 years ago
i already did that beforehand, redownloaded the zip, extracted it  somewhere else, and used that with avrstudio...


merry Xmas then ;D we dont do alot, mostly  just a nice meal, and a nice breakfast, thats about it :)

anyway, i cant even open the code,  then i cant compile it, and then i cant program it >.<

problems are stacking and stacking >.<"
godofal (author)  godofal7 years ago
ive just reinstalled avrstudio, still the same problem...
gmoon godofal7 years ago
Bummer.

Oh, well. Until you get the compiler to work, you can still program the ATtiny45 with the .hex file in the "default" directory (it's already compiled by the author.)

This should work with the "ghetto" programmer:

avrdude -p t45 -c dapa -e -U flash:w:capslocker.hex

Obviously, the .hex file ("capslocker.hex") should be in the current directory.

Important for Windows users: I seem to recall there is a batch in Winavr you NEED to run to access the parallel ports. The avrdude program won't work with a DAPA cable unless you do this. From the AVRDUDE site:

On Win32 platforms, parallel port access requires the previous installation of a driver (giveio.sys) that grants a user process direct access to the IO registers.

You can reuse this code for other projects by editing the .hex file name ("capslocker" in this case.) You can spruce it up by writing a batch file with a variable--so the .hex file name can be typed in when invoking the batch.

Generally I just wrote a separate batch for each project with the file name included. That way I could minimize typing--just entering the batch name did all the work.

If you'd like to test the DAPA (ghetto) programmer WITHOUT programming the AVR, I think the following code should get a response from the chip:

avrdude -p t45 -c dapa -v
godofal (author)  gmoon7 years ago
so, i dont HAVE to  compile? couldnt u have said that sooner :D now i have to clean up and get going and i wont be able to work on it the next 5 days :P

btw, ive tried that, but it still says stuff like  "no rule to make.exe"
so, with that .hex file, how do i program that into my attiny45? what makefile do i need?

anyway, ive already programmed other chips via my printer port, ive used that batch file long ago :)

i dont really get much of the last 3 parts of ur text... can u clear that up for me?

gmoon godofal7 years ago
OK, cool. Then your programmer works fine. Test the connection if you wish (THAT'S what the last line is for...)

The capslocker program was already compiled by the author. You don't need to recompile unless you change the source code..

And you don't need make to program the chip. A Makefile is just a script--it orchestrates the work all the other programs do; programs like avr-gcc, avrdude, etc.

All you need to program the AVR is the "capslocker.hex" file (that's what gets transferred to the AVR), and a working copy of avrdude (which you have--you've done it successfully before.)

So this line, entered in to the cmd shell:

avrdude -p t45 -c dapa -e -U flash:w:capslocker.hex

should load the "capslocker.hex" file into the ATtiny45.
godofal (author)  gmoon7 years ago
i dunno about avrdude, i always just load the .C file in programmers notepad, make sure theres a good makefile and hit tools>program,  then it compiles, and programs the chip (im guessing that means putting the .hex file into the chip?)
never used AVRdude...

but, if i can get AVRdude working, i can simply load the .hex into the attiny45??
gmoon godofal7 years ago
Well, you have used avrdude, you just didn't know it.

Look at the contents of the Makefile, you'll find the avrdude code. Again--make just runs the script in the Makefile.

Instead of programming the device with avrdude via the Makefile script, you'd be using avrdude directly.
godofal (author)  gmoon7 years ago
can you be more precise on this? like what i need to open, type and that kinda stuff.
as u said, i used it without knowing, using software that automatically did this, and i have close to no knowledge/experience in programming :D
i recently got the C++ for dummies book, for sinterklaas, thats a tradition here in holland, looks a bit like Xmas, just no decorations, and i like it alot more than Xmas :)
anyway, what i mean is that im completely clueless :P
gmoon godofal7 years ago
Sure. I'll enter it up at the top of this thread.

The threads on Instructables get narrower and narrower as you go. Which doesn't work well for instructions.

Your English is quite good, BTW...
godofal (author)  gmoon7 years ago
is it? well, im dutch, so the languages are in the same family, so its not that hard for me, and i play MMORPG's all the time. and the most (read: 99,99%) used language in public chats is english :D

anyway, im gonna look at that step-to-step thingie now, il reply again on that

i just realised how often i use  "anyway," :D look back, its quite often, mostly one in every reply XD
godofal (author)  gmoon7 years ago
and then i can program my chip trough my printer port?
il look at it asap :)

ty for the efforts!
gmoon godofal7 years ago
One step at a time ;-). Get the code compiled first, then work on programming the device.

The AVR "ghetto" programmer uses a DAPA type cable. I just checked, and AVR Studio doesn't seem to support it.

The program that's part of the win-avr open-source suite that actually uploads the code is called avrdude.

You've got a few options:
-- edit an existing Makefile that includes it (remove all the code for compiling and just keep the avrdude code.)
-- create a separate batch file that runs avrdude.

If you like, I can probably dig up a batch file I've used.

I'm also certain this has been discussed here on Instructables before. You might find the forum topic in a search...
Not my language, but I'd look for just where the code is looking for the USB library.  Have we got some problem with / or \ types ?
godofal (author)  steveastrouk7 years ago
no, the errors are about some stuff that isnt defined, but it should be (i think) becouse i didnt alter the code i downloaded.
Yes well isn't that code expecting to find stuff in specific places on your disk, via its make file? 
godofal (author)  steveastrouk7 years ago
maybe, but if i use the original makefile, it wont even try to compile, saying that there is no rule  for make.exe
Well, I'm with you on the C++ thing - I ain't worked in it either....

hsandford7 years ago
As I said in your other thread:

"Check that you've got the usbdrvasm.s file in the right directory, try putting it in the same directory as the .h files you had problems with previously.  Or if you already have it there, then make sure it's in the ./usbdrv/ directory instead."

Cheers, H.
http://howardsandford.com
godofal (author)  hsandford7 years ago
i have it in both directorys, before these problems, i had alot  more,  this thing already solved 2/3 of the errors, and the files are all in both directorys, so that cant be the problem (i think)
Jayefuu7 years ago
Looks like you haven't declared your variables in the functions you've created. You've passed values to them, but when you first use the variables you don't declare them.

For example... in function "usbFunctionSetup", you don't declare usbMsgPtr as a pointer to whatever it should be....

Same with usbInit, usbTxLen1, usbSetInterrupt in main
Same with
usbMeasureFrameLength in function calibrateOscillator
Jayefuu Jayefuu7 years ago
PS if you wanted to make a software version of what you're trying to do and can sneak it onto your friend's computer, it will be a lot harder for them to find, as there won't be any hardware poking out the back of their machine! Take a look at autohotkey.com, allows you to make macros for windows. If you want, I'll write you something to do the same as the hardware thing you're creating. =]
godofal (author)  Jayefuu7 years ago
well, im trying to replicate something someone else made, and i already figured out the fact that its looking for definitions that just aren't there, but, i dont know what it should define.
perhaps i should have made it clear    that  i have not written this program myself (in fact, i dont know C++ really), nor have i designed the PCB/schematics, im just following instructions (like an instructable) the bad part is, those instructions just say something like "etch the board" "solder the parts on it" "program the chip" and such, no real details, just general guidelines and some tips.

as for that software part,  im mostly interested in the learning. this is the first time im etching a PCB, using SMD components, and trying to program a microchip this small...
the effect  it gives really is just an extra.