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 » OS X ATmega328p

April 20, 2010
by Ralphxyz
Ralphxyz's Avatar

In trying to load a program to the ATmega328p I get he message:

avrdude: AVR Part "m328p" not found.

Then a big list of all supported devices.

I have modified the MakeFile and the libnerdkits MakeFile as instructed in the

ATmega328p Upgrade Nano guide.

I have the two bars on the LCD with the switch in the programming position.

Thanks for the help,

Ralph

April 21, 2010
by hevans
(NerdKits Staff)

hevans's Avatar

Hi Ralph,

I think this error points to your having an old version of avrdude that doesn't know about the Atmega328 yet. Try installing the latest version of AVR CrossPack. That should get you up and running.

Humberto

April 22, 2010
by Ralphxyz
Ralphxyz's Avatar

I have two ATmega328p MCUs.

I get completely different errors when trying to load the same program to both MCUs.

Will the AVR Cross Pack overwrite the existing gcc compiler? How would I know?

I know as little about the mac as I do about programming the ATmega, of course I was not able to program the ATmega328p with Windows 7 either.

I was able to get a program on one of the MCUs using XP but the other MCU would never load the program even using XP.

I was not able to reload a program on the MCU that did load once so that was a one time affair.

I'll try just installing the AVR CrossPack.

Thanks, this really shoul not be so difficult.

Ralph

April 22, 2010
by Ralphxyz
Ralphxyz's Avatar

I installed the AVR CrossPack now I get this for both MCUs:

Last login: Thu Apr 22 09:43:02 on console
miniMac:~ root# cd /developer/nerdkits/code/tempsensor
miniMac:tempsensor root# make
make -C ../libnerdkits
avr-gcc -g -Os -Wall -mmcu=atmega328p  -o delay.o -c delay.c
delay.c:6:19: error: delay.h: No such file or directory
delay.c: In function 'delay_us':
delay.c:14: error: 'NOP' undeclared (first use in this function)
delay.c:14: error: (Each undeclared identifier is reported only once
delay.c:14: error: for each function it appears in.)
make[1]: *** [delay.o] Error 1
make: *** [tempsensor.hex] Error 2
miniMac:tempsensor root#

delay.c is in the libnerdkit folder.

Ralph

April 22, 2010
by bretm
bretm's Avatar

But how about delay.h? That's the file it's complaining about.

April 22, 2010
by Ralphxyz
Ralphxyz's Avatar

Exactly, what about delay.h??

For some reason "it" is not finding delay.h so what does that mean?

Just to confuse myself more I loaded a 168 program onto my ATmega168 MCU and it works as expected.

Then I attempted to load another program onto the 168 and it is getting the exact same error missing the delay.h file.

Both of the make files are the same the libnerdkit folder is in the same relative position for each program folder.

So what is happening with delay.h?

Here is the MakeFile that works:

# tempsensor-copy
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 /dev/cu.PL2303-0000101D
LINKOBJECTS=../libnerdkits/delay.o ../libnerdkits/lcd.o ../libnerdkits/uart.o

all:    tempsensor-upload

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

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

tempsensor-upload:  tempsensor.hex
avrdude ${AVRDUDEFLAGS} -U flash:w:tempsensor.hex:a

Here is the MakeFile that fails with the missing delay.h reference:

#SCROLL
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 /dev/cu.PL2303-0000101D
LINKOBJECTS=../libnerdkits/delay.o ../libnerdkits/lcd.o ../libnerdkits/uart.o

all:    scroll-upload

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

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

scroll-upload:  scroll.hex
avrdude ${AVRDUDEFLAGS} -U flash:w:scroll.hex:a

What else should I be looking at?

Thanks appreciate the help,

Ralph

April 22, 2010
by treymd
treymd's Avatar

alongside your project folder should be a folder/directory called libnerdkits. in this directory should be delay.c delay.h and a few other files with the .c and .h pairings. They are all available in the download section here in a zip file.

April 22, 2010
by Ralphxyz
Ralphxyz's Avatar

Yes, I am able to load other programs!!

The libnerdkit is there with the .c and .h files!

That is why I published the "Working" MakeFile and the not working one.

Thanks for the replies,

Ralph

April 22, 2010
by Ralphxyz
Ralphxyz's Avatar

If I rename the working 168 program folder and load the .c file it works!

If I make the ATmega328p modifications to the working MakeFile and libnerdkits/MakeFile.

I get "delay.c:6:19: error: delay.h: No such file or directory".

delay.h should be made from delay.c correct?

I have previously posted all of the error message.

There has to be something that I am missing.

This is not just trying to program the ATmega328p but I get the same error trying to program the ATmega168

for certain folders with the same working .c program.

My Windows 7 box died so I can not test on that.

Sure would appreciate some help.

Ralph

April 22, 2010
by bretm
bretm's Avatar

"delay.h should be made from delay.c correct?"

I'm not sure what you mean by that. delay.h and delay.c are two separate files with separate but related content.

My folder and file layout looks like this:

Code
    libnerdkits
        Makefile
        delay.h
        delay.c
        io_328p.h  (added to make the 328p work)
        (other files)
    led_blink
        Makefile
        led_blink.c
        (other files, after running make)
    trafficlight
        Makefile
        trafficlight.c
    etc.

Is that how you have it set up?

April 23, 2010
by Ralphxyz
Ralphxyz's Avatar

Yes. I was confusing the .h file with a .hex file.

Now here is more information that goes back to Humberto's reply about updating to AVR CrossPack:

Apparently the AVRMacPack is still being referenced.

How do I make the compiler (gcc) reference CrossPack-AVR-20100115?

Can I/Should I remove the two AVRMacPack folders?

Of course that leads to the question of how to remove the folders since they are not visible in Finder I would have to do it from the Terminal I guess.


I re-downloaded the NerdKit code files and copied one of my (not working) project files to the CODE folder. Trying to load the .c project file is what got the above error referencing AVRMacPack.

Of course while trying all sorts of things to get this to work I have discovered a 9 volt battery cap that was not allowing 9 volts to pass and a annoying but not critical bug in OS X Snow Leopard 10.6.3.

Thanks for the help so far.

Ralph

April 25, 2010
by Ralphxyz
Ralphxyz's Avatar

Solution!!

It appears Humberto's suggestion to install the latest version of AVR CrossPack was what I needed to do.

What he didn't say was how to overwrite AVRMacPack in order to use AVR CrossPack. AVRMacPack is the package used if one downloads and installs the Mac programing environment from the NerdKit download page (AVRMacPack for Mac OS X). The AVRMacPack works fine for the ATmega168 but does not support the ATmega328p which is what this thread is about.

Just installing the AVR CrossPack does not mean you can use it if you have previously installed AVRMacPack.

Now anybody who knows what they are doing probable would have know what to do and most importantly HOW to do it. I on the other hand haven't the slightest idea what I am doing, Well even though I claim to not know what I am doing I actually have been around and had computers since I got a Timex Sinclair with a z81 processor in 1981 that was the "first" personal computer for less than $100.00. Later on I picked up one of the original Macintosh computers from Apple. So while I really try to not know anything beyond what I need to know, I have had forced in-depth workings with computers for 25 years.

Here is what I found out.

OS X (10.6.3 Snow Leopard) uses a PATH to run various programs, the PATH is stored in a file named .profile however in Snow Leopard it is not named .profile but profile and you can not use Finder or the Spotlight to find it.

After spending hours trying to find the PATH I re-read the CrossPack Installation and Removal page and it says:

"The installer adds a component to the PATH environment variable in the files /etc/profile and /etc/csh.login".

Ah ha says I, but how would I view or edit them? In my searching the web to find how to find the PATH I had come across references to TextEdit the default text editor in OS X (which of course I had never used) and all I had to do was to go to the /etc folder and enter [open profile]. That gives you the profile (PATH) file in TextEdit. The PATH is used by the shell when using the Terminal.

Here is what the PATH looked like:

# System-wide .profile for sh(1)

PATH="/bin:/sbin:/usr/bin:/usr/sbin"
export PATH

if [ "${BASH-no}" != "no" ]; then
[ -r /etc/bashrc ] && . /etc/bashrc
fi
if [ -e "/usr/local/AVRMacPack" ]; then
PATH="$PATH:/usr/local/AVRMacPack/bin"
export PATH
fi
if [ -e "/usr/local/CrossPack-AVR" ]; then
PATH="$PATH:/usr/local/CrossPack-AVR/bin"
export PATH
fi

While the CrossPack path was there the AVRMacPack was referenced first so the CrossPack was never called/used. I just removed the AVRMacPack reference:

fi
if [ -e "/usr/local/AVRMacPack" ]; then
PATH="$PATH:/usr/local/AVRMacPack/bin"
export PATH
fi

Saved and closed TextEdit. In hind sight I should have opened csh.login from TextEdit while I was there but didn't, I tend to do things the hard way or at least to force myself to learn more new things. Anyway [open csh.login] gets a error message saying "nothing knows how to open csh.login". So again from my searching the web I came up with [open -a TextEdit csh.login] that opens csh.login in TextEdit.

A quick way to check what AVR package you are using is to enter [avr-project] from the terminal that will get you:

miniMac:etc root# avr-project
usage: /usr/local/CrossPack-AVR/bin/avr-project <ProjectName>
miniMac:etc root#

You set the compiler you want to use like this:

miniMac:manual root# avr-gcc-select 3
Current default compiler: gcc 3
miniMac:manual root#

Apparently gcc 3 is more efficient than gcc 4. I have no idea what that means.

Thanks everyone for the help, sorry about the length of this post but it's a rainy Sunday morning and I wanted to list the details in case anyone else has the same experience.

Note to the NerdKit guys the User_Guide-USB_ATmega328P should have a note added about upgrading to AVR CrossPack from AVRMacPack for OS X programming.

Ralph

April 26, 2010
by Ralphxyz
Ralphxyz's Avatar

Here is more I have learned in the past 24 hours about OS X.

To uninstall AVRMacPack in a Terminal window. Type (or even better: copy/paste):

sudo /usr/local/AVRMacPack/uninstall

This will ask you for your (or an administrator's) password.

To view the PATH

echo $PATH

Learning everyday, Ralph

May 08, 2012
by Bluehawk
Bluehawk's Avatar

Ralphxyz - Thanks! Solved my problem. #1 on Google! Your posts have always been helpful or thought provoking. Thought I'd say thanks! Appreciate your contributions.

January 30, 2013
by dpc
dpc's Avatar

I am relatively new to NerdKits, and this is my first forum post.

I had the same problem with the toolchain not supporting the 328P when I tried to bring up my new "bare" 328P NerdKit tonight.

Maybe the 328P nano guide could be updated with the new CrossPack information, since the newer version is required on the Mac for the toolchain to recognize the hardware? The circa 2008 AVRMacPack for the Mac is kinda dated and does not even support the 328p out of the box, but there is no mention of that in the 328P Nano guide (i double-checked) nor the wiki as far as I could find.

The CrossPack installer may have fixed or updated the $PATH issue you encountered in the time since the above instructions in this thread were written, as all I need to do when the installer finished was to open a new terminal. Anyway, I had figured the CrossPack updated toolchain solution independently of finding this thread. This is probably a common problem for Mac users who get the upgrade kit.

If it is not added to the Nano guide, I think I will create a FAQ or wiki entry and reference this thread.

As an aside, I had earlier run into a problem on my MacBook Pro with Mountain Lion installed as the USB device driver that is on the downloads page for my kit also did not work. Fortunately, there was a link to a driver on the NerdKits wiki/FAQ that got me going on my original 168p NerdKit...

January 30, 2013
by Ralphxyz
Ralphxyz's Avatar

Maybe the 328P nano guide could be updated with the new CrossPack information

I do not know how much "updating" to expect, the NK guys have serious problems with their USB cable no longer supported in Windows 8 and we have not heard a peep from anybody on the NK team for a long time.

We still have the Nerdkit Community Library where your instructions would be most welcome.

The best way to learn how to publish a Library article is to sign in and then to open a similar page to edit (bottom right corner), then just copy the setup of that page for your new page.

The Library is driven by the same engine as this forum, Markdown there is a link at the bottom of this page.

Ralph

April 04, 2013
by xodin
xodin's Avatar

Thanks Ralph, I'm glad I searched the forums first when I got the same AVRDude m328p error. I uninstalled the AVRMacPack using the command you posted, and then installed the AVRCrossPack. Everything worked out fine after that.

April 04, 2013
by Ralphxyz
Ralphxyz's Avatar

This is the end of my OS X support.

My Mac Mini is too old and the newest OS X will not install, so once AGAIN Apple has deserted it's legacy computers.

Ralph

Post a Reply

Please log in to post a reply.

Did you know that Morse code is a compact way to transmit human-readable text over binary channels? Learn more...