Atmega 168 Make File error

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

I am new to this, so I hope I selected the correct forum. I bought this kit for learning to program Atmega microcontrollers. I think I downloaded everything and connected everything correctly. The C++ program is very simple. When I try to make the file using "MFile[WinAVR]" I get the error message: main.c:15 fatal error: opening dependency file .dep/main.o.d: No such file or directory. I also need to change this editor so I can show the messages better. I believe the dependencies are defined in the Makefile that I downloaded, so I cannot follow it very well. Can someone point me in the right direction to resolve this or ask for more information. I am trying to program the AtMega 168 PU to just turn on an LED (hey - I am just starting out).

 

 

 

 

Carl Carter

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

WinAVR is (IIRC) over 7 years old.

There are several much more recent (some free) tools available for working with AVRs (e.g. Atmel Studio).

If you post the code you are attempting to build perhaps someone here can help...

David (aka frog_jr)

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

Show the complete output of the build attempt, please.

Happy 75th anniversary to one of the best movies ever made! Rick Blane [Bogart]: "Of all the gin joints, in all the towns, in all the world, she walks into mine."

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

Also if it is a C++ program why is main() in main.c and not main.cpp?

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

Carl Carter wrote:
I bought this kit

What Kit, exactly?

 

As already noted, if you're just starting out - why not start with current tools:

 

Atmel Studio 7: http://www.atmel.com/microsite/atmel-studio/

 

Note that there's a whole load of tutorials, videos, etc linked from that page

 

EDIT

 

For some reason, the Atmel site - http://www.atmel.com/microsite/atmel-studio/ - seemed to open waaaaaaaaaay faster that the microchip version - http://www.microchip.com/development-tools/atmel-studio-7 

 

It also seems that the two are not identical - so probably worth exploring both to get the full picture.

 

(in case you weren't aware, Microchip took over Atmel early last year; so there is an ongoing process of everything "Atmel" becoming "Microchip" - it is not finished yet ... )

Last Edited: Fri. Oct 6, 2017 - 10:23 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I will do that. It is on another PC, so I will have to wait until this evening.

Carl Carter

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

I did not know there is a main.cpp. I have not seen that in any of the material I have read. Could you elaborate?

Carl Carter

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

The kit was from Newbiehack. I actually bought it over a year ago. It came with tutorials. The programmer in the kit is different than what is shown in the tutorials. The tutorial uses a USBtiny programmer. The one delivered looks different. I tried to communicate with avrdude and found that it was recognized using avrasp.

Carl Carter

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

Carl Carter wrote:
The C++ program is very simple. When I try to make the file using "MFile[WinAVR]" I get the error message: main.c:15 fatal error

If you're writing a C++ program, then your source files should have the .cpp extension ("file type")

 

Files with a .c extension will be taken by the compile to be plain 'C' - not C++

 

 

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

I tried Atmel Studio 6.2 about a year ago and was  not making any progress. So I put it aside for a while and then decided to start over. I have a new PC and will get Studio 7 as suggested. Thanks.

Carl Carter

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

Carl Carter wrote:
The kit was from Newbiehack.

Please give a link to the specific kit.

 

The programmer in the kit is different than what is shown in the tutorials.

Oh dear.

 

Have you taken this up with "Newbiehack" ?

 

I would strongly suggest that you set it aside and get an ATmega328P Xplained mini (or similar):

http://www.atmel.com/tools/mega328p-xmini.aspx

 

It will be immediately recognised by Atmel Studio, which will present you with a set of specifically made examples for that board.

 

And it has a built-in debugger.

 

 

Alternatively, why not just use Arduino?

 

 

EDIT

 

Just to be clear: the "built-in debugger" also does the programming - so there is no other equipment required.

 

 

 

 

Last Edited: Fri. Oct 6, 2017 - 03:26 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Carl Carter wrote:
I did not know there is a main.cpp.

Maybe there isn't. What made Cliff intrigued was that you said that it was a C++ project, as opposed to a C project: It is completely possible for a C++ project to have a mix of C++ and C source files, but it would be somewhat odd (although not completely impossible) for a C++ project to have main() in a .c file rather than a .cpp file.

 

It is not very clear to us at all how the project is organized source-file wise, but the complete build output will hopefully shed some light on that.

 

Carl Carter wrote:
The kit was from Newbiehack.

Link, please?

Happy 75th anniversary to one of the best movies ever made! Rick Blane [Bogart]: "Of all the gin joints, in all the towns, in all the world, she walks into mine."

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

Carl Carter wrote:
I am new to this

So what, exactly, do you mean by "this" ?

 

Just new to AVRs - or also new to microcontrollers in general?

 

New to any form of programming?

 

It helps in order to know the level of detail to give in replies ...

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

I will try to answer several of your responses in one post. By "this" I mean programming microcontrollers. I am using programmers notepad (I think I downloaded it from SourceForge) last week. I assumed that .c was the correct extension. I just tried changing the extension to .cpp and received the same error message. I think I will purchase the programmer shown above, but want to keep working on the project until it arrives. Here is the complete Build(Make) attempt followed by the C file

 

> "make.exe" all
      0 [main] sh 5016 sync_with_child: child 9736(0x1A8) died before initialization with status code 0xC0000142
  40781 [main] sh 5016 sync_with_child: *** child state waiting for longjmp
/usr/bin/sh: fork: Resource temporarily unavailable
      0 [main] sh 8452 sync_with_child: child 11164(0x1A8) died before initialization with status code 0xC0000142
    795 [main] sh 8452 sync_with_child: *** child state waiting for longjmp
/usr/bin/sh: fork: Resource temporarily unavailable

-------- begin --------
avr-gcc (WinAVR 20100110) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Compiling C: main.c
avr-gcc -c -mmcu=atmega168 -I. -gdwarf-2 -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=./main.lst  -std=gnu99 -MMD -MP -MF .dep/main.o.d main.c -o main.o
main.c:15: fatal error: opening dependency file .dep/main.o.d: No such file or directory
compilation terminated.
make.exe: *** [main.o] Error 1

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

 

This is the program file as shown in the tutorial:

 

#include <avr/io.h>

int main(void)

{

DDRB = 0b00000001; // data direction register and assigning pin 0 on port b to output

PORTB = 0b00000001; // assigning 5V to pin 0

 

while (1)

{

 

 

}

 

}

 

Carl Carter

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

You still haven't given links to the kit & the tutorial that you're using.

 

Carl Carter wrote:
 By "this" I mean programming microcontrollers.

So do you have experience with programming in general ?

 

Do you know the 'C' (or C++) programming language, and how to build  'C' (or C++) program?

 

The general advice is that it's easier to start by learning the basic language skills on a PC, and only move onto microcontrollers once you've got that foundation solid.

 

I assumed that .c was the correct extension

It is the "correct" (as in, customary) extension for a 'C' program - but you said you were doing a C++ program.

 

So which is it: 'C' or C++ ?

 

In terms of the volume of available support, tutorials, and other resources, 'C' is currently the more widespread - especially for small microcontrollers like the AVR.

 

I am using programmers notepad

You are rather making life hard for yourself there, I think.

 

Why not use some thing that is specifically made & set up for the AVR?

 

Atmel Studio being the obvious example.

 

I think I will purchase the programmer shown above

You mean the XPlained Mini?

That is far more than just a programmer! It is a complete development board plus a full debugger!

 

Here is the complete Build(Make) attempt

Where did the makefile come from?

 

This is the program file as shown in the tutorial:

How to post source code: http://www.avrfreaks.net/comment...

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

Some of this has been previously asked, but this will help us help you...

  • What kit did you get from Newbiehack?
  • What tutorials are you using?
  • How do you have the ATmega168 wired/connected (a schematic would be useful)

 

The more we know, the better we can point you in the right direction.

David (aka frog_jr)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
I am just following the instructions for posting source code following the link provided above' Let me know how well I did.

Also - let's say that I do not have experience in in programming, electronics and microcontrollers. I may be making life hard for myself, but that's part of learning. More on Newbie Hack to come.


"make.exe" all
      0 [main] sh 5016 sync_with_child: child 9736(0x1A8) died before initialization with status code 0xC0000142
  40781 [main] sh 5016 sync_with_child: *** child state waiting for longjmp
/usr/bin/sh: fork: Resource temporarily unavailable
      0 [main] sh 8452 sync_with_child: child 11164(0x1A8) died before initialization with status code 0xC0000142
    795 [main] sh 8452 sync_with_child: *** child state waiting for longjmp
/usr/bin/sh: fork: Resource temporarily unavailable

-------- begin --------
avr-gcc (WinAVR 20100110) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


Compiling C: main.c
avr-gcc -c -mmcu=atmega168 -I. -gdwarf-2 -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=./main.lst  -std=gnu99 -MMD -MP -MF .dep/main.o.d main.c -o main.o 
main.c:15: fatal error: opening dependency file .dep/main.o.d: No such file or directory
compilation terminated.
make.exe: *** [main.o] Error 1

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

 

Carl Carter

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

 

 

The kit and tutorial that I purchased came from:

 

https://newbiehack.com/categorie...

 

This was purchased over a year ago, so it may have changed since then. And as stated before, the programmer that came in the kit was not the same as in the tutorial.

 

If I recall, the Make file came from SourceForge.net or following links from that site. I was referring to the Xplained Mini and just placed the order with Mouser.com. I went to the Atmel site first (about 20 minutes ago) and then clicked on a link to distributors. That led to a blank screen, so I went to Mouser.

 

I will have to review how to provide the schematic before posting that. It was a very simple set up and I tested it using AVR Dude. It may take some time to catch up to all of your questions. I am going to download Studio 7 next.

 

 

 

 

 

 

 

 

Carl Carter

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

I see several problems and other things. Let's try to split them up:

 

Error at start of build

> "make.exe" all
      0 [main] sh 5016 sync_with_child: child 9736(0x1A8) died before initialization with status code 0xC0000142
  40781 [main] sh 5016 sync_with_child: *** child state waiting for longjmp
/usr/bin/sh: fork: Resource temporarily unavailable
      0 [main] sh 8452 sync_with_child: child 11164(0x1A8) died before initialization with status code 0xC0000142
    795 [main] sh 8452 sync_with_child: *** child state waiting for longjmp
/usr/bin/sh: fork: Resource temporarily unavailable

I did a quick Google for the error message ("sync_with_child died before initialization"). A quick look seems to indicate that this is a problem with "Cygwin". That "Cygwin" is a software "layer" that can be used in Windows to get some of the functionality that a Unix/Linux system offers. From one article I quickly browsed there seems to be no easy remedy to this:

A workaround for this bug is known and is also explained in this bug report for MingW but since WinAVR uses a much older version (and the bugfix is probably not included in the main release yet anyway) the bug is still present in WinAVR 20071221. I have made a modified msys-1.0.dll that fixes this bug and should allow you to use WinAVR on Vista 64-bits.

Yes, that quote talks about ancient versions of WinAVR and Windows but it might well hold true for your WinAVR version and your Windows version too.

 

Given just this, I chime in with previous posters and recommend to move to newer tools. Atmel Studio is the obvious tool for managing your project, editing source files and build the binary. You can then use e.g. AVRDUDE to program/burn that binary to the AVR flash memory.

 

The next build error

main.c:15: fatal error: opening dependency file .dep/main.o.d: No such file or directory

might be a consequence of the previous error - or not.

 

C or C++ project?

If the only file in your project is the main.c file we are hinted about from the build output then it would be most correct to call this a "C project". Same holds if there are more source files than we see from the (failed) build output and they all have the file type .c .

 

"[Tried Atmel Studio but] didn't make any progress..."

If the tutorial you got came with, or recommended, WinAVR (any version) then that tutorial is quite dated. This means that fewer people in the AVRfreaks community will be interested in helping you out. I speculate that many don't even have WinAVR installed anymore.

 

If you instead move to the current version of Atmel Studio (which comes with a new and shiny compiler / tool-chain) your chances of getting good help increases immensely.

 

There will be an initial learning curve, not in any way extremely steep though, getting up to speed with Atmel Studio - and it will probably be less steep than Programmers Notepad and WinAVR. The obvious advantage to Atmel Studio is that you are learning something contemporary rather than something ancient.

 

You have already felt the pain of trying to follow outdated tutorial material, and it won't get better. Instead rely on being up-to-date and help from us here. This will work better if you get some ground rules nailed right away, which brings us to...

 

Getting good help at AVRfreaks

Pro primo: Realize that you are in a competition for attention, and that we are free to care or care not about any individuals problem(s). This means that the better your posts are the greater the chances are that you will get our attention. Here's some points to ponder:

 

  • Please do answer questions we are asking. We most often pose those questions as explicit and to the point we can. Your answer should be the same - to the point. Example: When we asked "What kit?" you could have supplied a web link, not just "The kit was from Newbiehack". I went over to Newbiehacks site and there where several kits. We don't want to guess. We want the hardest facts we can get.

 

  • When posting code, learn right away how to make it keep its formatting. See the difference between this:
#include <avr/io.h>

int main(void)
{
DDRB = 0b00000001; // data direction register and assigning pin 0 on port b to output
PORTB = 0b00000001; // assigning 5V to pin 0

while (1)
{

}

}

and this

#include <avr/io.h>

int main(void)
{
    DDRB = 0b00000001; // data direction register and assigning pin 0 on port b to output
    PORTB = 0b00000001; // assigning 5V to pin 0

    while (1)
    {
    }

}

Instructions for how to get code posted like that are (short version) to use the button marked "<>" just above the post editor. For a longer version, awneil will soon probably link to something.. ;-) 

 

  • When you do post code that you have problems with, post an actual copy of the exact source code. Do not type code into a post, but actually do a copy/paste from your editor to the post here. Things go wrong when code is posted directly into a post and we're in  the confusing guesswork situation again.

 

  • In general, do everything you can to be structured, precise and to the point. The better you succeed with this the more we like to talk to you.

 

Finally: Welcome to AVRfreaks!

Happy 75th anniversary to one of the best movies ever made! Rick Blane [Bogart]: "Of all the gin joints, in all the towns, in all the world, she walks into mine."

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

Last Edited: Fri. Oct 6, 2017 - 05:22 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

JohanEkdahl wrote:
 For a longer version, awneil will soon probably link to something.. ;-) 

He already has - see the last line of #15

 

Note also that the posted link includes instructions on how to post pictures/images ...

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

I may be making life hard for myself, but that's part of learning.

But deliberately making things harder than they need to be will just lead to frustration!

 

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

Thanks to everyone for their help.

 

I just loaded Atmel Studio7 and will get familiar with that.

 

I also want to follow the advice on learning C programming before moving on to programming the Microcontroller. I see that there is a forum for books/instructions on programming. I will explore that next (any suggestions on which C programming books to read are welcome).

 

I used the "<>" button in post #17, but it did not appear on the screen as expected. I will go back and read the instructions more carefully. I might do some tests just to get the appearance correct.

 

Thanks again for all of the advice and please allow me some time to get up to speed on posting.

 

 

Carl Carter

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

This is a test for posting code using the "<>" button:

 

#include <avr/io.h>

int main(void)
{
   DDRB = 0b00000001;  // data direction register and assigning pin 0 on port b to output
   PORTB = 0b00000001;  // assigning 5V to pin 0
   
   while (1)
   {
   
   
   }


}

I am guessing that this was done correct, but the colors are not the same as the source in programmers notepad.

Carl Carter

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

Carl Carter wrote:
any suggestions on which C programming books to read are welcome

Well, the canonical book - on paper - is "The C programming language" by Kernighan and Ritchie, the creators of the language. You'll often see it being referred to as just "K&R" which every seasoned C programmer will recognize immediately.

 

For a legit/legal online book, go here: https://www.amazon.com/Programmi... . Perhaps not as good as K&R but not bad.

 


 

As for the learning process..

 

Several of us here recommend to do the bulk of the C learning on a PC, targeting a PC - rather than doing the "generic" C learning on an AVR. There are several good IDEs and compilers out there. It might be a good point to go for GCC as a compiler - in the same family as AVR-GCC (that targets AVRs). Here's some IDEs that handles GCC:

 

Both Eclipse and NetBeans are more or less "generic" IDEs  that can handle many different programming languages and environments. You either pick a variant for C/C++ when downloading, or coonfigure the IDE (after installtion) for C/C++ development (the procedure has varied over time, and I'm not sure which holds for current versions). They are both based on Java so you'll need to have a Java runtime environment (JRE) installed. You do not need to download or configure for developing in Java (i.e. no "Java Development Kit" / JDK), you only need the JRE so that Eclipse / NetBeans as such can run.

 

CodeBlocks is written in C++ and requires no JRE.

 

I'm not sure ATM if you need to download and install the C/C++ compiler/toolchain separately or if it comes bundled with any of those IDEs. Let me know if you're interested in a specific one and I can check it out for you.

 

You could also go for Visual Studio from Microsoft. The advantage here is that the IDE is very similar to Atmel Studio (AS builds on the same "IDE framework" as Visual Studio). It comes in a variant with Microsofts compiler for C++/C. VS comes in a "Community Edition" that is free for non-commercial development (you'll find a download link here). The different compilers should not be a big problem - the C standard is very stable and compilers generally adhere to the standard quite well.

 

The big advantage of learning C targeting a PC rather than an AVR is that you remove a lot of complications (programming flash, getting an on-chip debugger which will take anything from $50 and up out of your pocket), and your debugging experience in any of these IDEs will be smoother than using an AVR.

 

Having said that you can of-course do the bulk of the C learning targeting the PC, and in parallel learn the specifics of programming for AVR microcontrollers using Atmel Studio. Indeed, some of us seasoned AVR coders still develop and test the parts of an AVR program that is not dependent on the AVR hardware by targeting a PC to begin with.

 

At any cost, stay away from MikroeC. Period. Don't ask why and forget you ever heard of it ;-)

 

Do come back with specific questions/follow-ups on any of the above!

Happy 75th anniversary to one of the best movies ever made! Rick Blane [Bogart]: "Of all the gin joints, in all the towns, in all the world, she walks into mine."

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

Carl Carter wrote:
the colors are not the same as the source in programmers notepad.

There is no standard for those colours - it is each to their own taste.

 

And this forum loses the colours anyhow - it all just turns out as green.

 

Here are some 'C' learning & reference materials - including a free, online textbook: http://blog.antronics.co.uk/2011...