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.

Microcontroller Programming » Put the Bootloader on a blank Atmega328p chip with a Pololu USB AVR Programmer

March 13, 2011
by geeker234
geeker234's Avatar

I'm trying to flash the Nerdkits bootloader on a blank Atmega328p chip I got on Sparkfun and having some issues. I have it connected, set it to COM1, and in the Makefile I have AVRDUDEFLAGS= -c avrisp -p m328p, but when i try to make it I get:

avrdude -c avrisp -p m328p  -U lock:w:0x2f:m
avrdude: ser_open(): can't open device "com1": The system cannot find the file s
pecified.
    make: *** [fuses] Error 1

What do I do?

March 14, 2011
by Rick_S
Rick_S's Avatar

Make sure you have your programmer name correct in your makefile. I'm not 100% but I believe the AVRISP was a serial programmer. The AVRISP MkII was USB. That may be why you are getting the error because since you didn't define a com port, avrdude is using a default of com1.

I made a tutorial for installing the bootloader, if you haven't seen it, it may be of help. You can find it here http://www.nerdkits.com/forum/thread/1358/

Rick

March 14, 2011
by Ralphxyz
Ralphxyz's Avatar

Is Com1 your actual com port? Check Device Manager to make sure.

You can also load the foodloader.hex directly without needing to compile the bootloader code (which I have never been able to do).

Using AVR Studio (download from ATmel) it is very easy to program the bootloader to the mcu.

Ralph

March 14, 2011
by geeker234
geeker234's Avatar

It was at COM4 at first, but then i changed it to COM1.

March 14, 2011
by geeker234
geeker234's Avatar

Ok, I changed the programmer to avrispmkII and now I get this:

avrdude -c avrispmkII -p m328p -F  -U lock:w:0x2f:m

avrdude: stk500v2_command(): command failed
avrdude: stk500v2_command(): unknown status 0xc9
avrdude: stk500v2_program_enable(): cannot get connection status
avrdude: initialization failed, rc=-1
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.
avrdude: Expected signature for ATMEGA328P is 1E 95 0F

avrdude done.  Thank you.

make: *** [fuses] Error 1
March 14, 2011
by Rick_S
Rick_S's Avatar

What programmer do you have, and where did you get it?

March 14, 2011
by geeker234
geeker234's Avatar

I have a Pololu USB AVR Programmer and i got it here: http://www.pololu.com/catalog/product/1300.

March 14, 2011
by Rick_S
Rick_S's Avatar

From their website LINK you shoud be using avrispv2 as your programmer type. Their site also states that it has 2 com ports on it, one for programming, the other for communications. Make sure your com setting is for the correct one.

Rick

March 14, 2011
by geeker234
geeker234's Avatar

I changed the settings and got this:

avrdude -p m328p -P COM1 -c avrispv2 -e -U  -U lock:w:0x2f:m

avrdude: stk500v2_command(): command failed
avrdude: stk500v2_command(): unknown status 0xc9
avrdude: stk500v2_program_enable(): cannot get connection status
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

avrdude done.  Thank you.

make: *** [fuses] Error 1

So i changed -U to -F and got:

avrdude -p m328p -P COM1 -c avrispv2 -e -F  -U lock:w:0x2f:m

avrdude: stk500v2_command(): command failed
avrdude: stk500v2_command(): unknown status 0xc9
avrdude: stk500v2_program_enable(): cannot get connection status
avrdude: initialization failed, rc=-1
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.
avrdude: Expected signature for ATMEGA328P is 1E 95 0F
avrdude done.  Thank you.
make: *** [fuses] Error 1

I can tell it is comunicating with the programmer because the green light briefly flashes when I type make, and the red light is solid, but i am not sure what to do. I also tried changing Pololu USB AVR Programmer Programming Port (COM1) to Pololu USB AVR Programmer TTL Serial Port (COM6) to see what would happen and i got:

avrdude -p m328p -P COM6 -c avrispv2 -e -F  -U lock:w:0x2f:m
avrdude: stk500_2_ReceiveMessage(): timeout

and then

avrdude: stk500_2_ReceiveMessage(): timeout

just repeated every 10 seconds or so

March 15, 2011
by geeker234
geeker234's Avatar

Ok, i also tried replacing the chip with a new blank one to test if that is the problem, but i still have the same issue

March 16, 2011
by Rick_S
Rick_S's Avatar

Ok, From what you stated, COM1 appears to be the correct port. Now would probably be a good time to take some good photos of your setup and post them so we can see how you wired your programmer to the chip and what is connected to your chip in the programming circuit.

Did you read the tutorial I posted the link to in my first reply? There are a lot of pointers there to help. My guess is that since you are running make first, you haven't read it thru. But that aside, lets see some pics.

Rick

March 16, 2011
by geeker234
geeker234's Avatar

I did read it through but i am still having the issues. Instead of typing make i started using avrdude -p m328p -P COM1 -c avrispv2 -e -U flash:w:foodloader.hex like it says in the tutorial, but still having the issue. I set up the chip exactley how it is supposed to be in the nerdkits guide, plus the programmer so im not sure if thats the issue. Here are a few pics: Pic 1 Pic 2 Pic 3

March 16, 2011
by geeker234
geeker234's Avatar

Oh sorry, i thought you meant the pololu avrdude tutorial, yes i have read through that, but not your tutorial yet. Sorry for the confusion

March 16, 2011
by Rick_S
Rick_S's Avatar

If you had read my tutorial you would have noticed this paragraph,

To program the bootloader you will need to build your breadboard very similar to how the initial setup in the guide describes. If your programmer supplies power, you can leave the regulator portion off the board. The main difference is that you MUST replace the jumper wire at pin1 with a resistor (I use 10k).

with photos like this.

photo

Your programmer cannot toggle the reset if you have it hard wired to VCC. That is why you MUST have a resistor at pin 1.

There may be other issues, but that one is glaring. Had you read the tutorial I gave you the link for, you'd have known that right away. You would have also seen the basic line for doing a chip erase prior to trying to program the fuse bytes.

Give it a good read thru, you might figure out your problems.

Rick

March 19, 2011
by geeker234
geeker234's Avatar

ok, i got 5 2.2k resistors and put them in series to make 11k so i think it is close enough. i also noticed that you had a capacitor between pins 7 and 8, so i added that. im still getting the issue:

c avrispv2 -e -U flash:w:foodloader.hex

avrdude: stk500v2_command(): command failed
avrdude: stk500v2_command(): unknown status 0xc9
avrdude: stk500v2_program_enable(): cannot get connection status
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

avrdude done.  Thank you.

when i use -p m328p -P COM1 -c avrispv2 -e -U flash:w:foodloader.hex. So i am really confused about this, because i dont know anything else to check. i even tried erasing the chip and got the same issue.

March 20, 2011
by Rick_S
Rick_S's Avatar

Well, normally I'd pop in and try a bit more to help, but as I'm basking in the sunlight of central Florida this week, I'll have to let someone else take a swing. If it were me though I'd check wiring to the programmer closely. It's easy to get that turned around.

Rick

March 20, 2011
by Ralphxyz
Ralphxyz's Avatar

Now this makes me worry:

"i also noticed that you had a capacitor between pins 7 and 8,"

Have you ever setup a working Nerdkit? That might be a good first step to make sure you know how to follow directions.

Hey, I didn't know we get to vacation.

Ralph

March 20, 2011
by Rick_S
Rick_S's Avatar

Yes Ralph, this is a long overdue vacation. Even though with a smart phone the forum. Is still pretty close. ;)

March 20, 2011
by geeker234
geeker234's Avatar

well sort of. i attempted the lcd project when i first got my nerdkit a few years ago but it didn't work, and i didn't feel like trying to fix it. However, i have programmed the chip that came with the kit with my own stuff. The reason i got the blank chips was because i had broken the atmega168, but yes i have used the nerdkit.

March 20, 2011
by Noter
Noter's Avatar

I agree with Rick, you probably have some wires crossed. Consider ordering another chip from Nerdkits that has the bootloader already on it and go back to the LCD project. The skills you develop getting that one to work will help you get your programmer going.

February 23, 2012
by RevMoses
RevMoses's Avatar

I get the same error message on mine. However, its probably because i'm using the AVRISP MKII.

The software and drivers installed without a problem...however the device does not show up as a com...it shows up as a USB...to be more specific Port_#0001.Hub_#0004

NI suggested checking the registry to see where a usb device is mapped: http://digital.ni.com/public.nsf/allkb/B7AC81CD11B9243B862574FA005BCE03

so i checked HKEY_LOCAL_MACHINE>SYSTEM>CONTORLSET001>ENUM>USB.

wasn't able to get much from there though.

I am unable to do much through the command prompt. However, I am able to connect to the chip with AVR studio. I can see the fuses, voltage levels etc...

It has a gui for the user to put in different informatoin. I was hoping i could get a verification on a few things.

1) I'm not sure which of the files go in the fields: It asks for a hex file to be loaded to the Flash Then it asks for a hex file to be loaded to the EEPROM It also asks for an input ELF File ...I'm not sure if all of the above files are optional or required.

2) rather than list the fuses and all their options, guess i'll just list the hex values for the following. EXTENDED: 0xF9 HIGH: 0xDF LOW: 0x62

do these look good?

3)Lock bits secion i have: LB: No memory lock feature enabled BLB0: No lock on SPM and LPM in application section BLB1: No lock on SPM and LPM in Boot Section

February 24, 2012
by Rick_S
Rick_S's Avatar

I'm pretty sure the avrisp mkII should also behave as a serial port to a computer. I believe ( I don't have one so I cannot verify ) that it should be assigned a com port by windows if the drivers are installed correctly.

That being said, I did have a clone avrisp mkII at one time but I never could get the avrisp mkII firmware to behave right with my windows 7 pc. That was one reason I use the USBASP. It just works and works well for me. Did you read my bootloader installation guide? It's in the Library HERE

Depending on the microcontroller you are installing a bootloader to, your fuses will be different.

They are listed in each of the bootloader install folders from the code download. Here are the settings for the 168 from that file.

EFUSE = 0x00
0   -
0   -
0   -
0   -
0   -
0   BOOTSZ1 (1024 word boot size)
0   BOOTSZ0     ""
0   BOOTRST (jump to bootloader)

HFUSE = 0xd5
1   RSTDISBL
1   DWEN
0   SPIEN
1   WDTON
0   EESAVE
1   BODLEVEL2   (sets V_BOT=2.7)
0   BODLEVEL1       ""
1   BODLEVEL0       ""

LFUSE = 0xf7
1   CKDIV8
1   CKOUT
1   SUT1    (65ms start-up delay)
1   SUT0        ""
0   CKSEL3  (full swing crystal oscillator)
1   CKSEL2      ""
1   CKSEL1      ""
1   CKSEL0      ""

LOCK = 0x2f
0   -
0   -
1   BLB12   (can't self-program over bootloader)
0   BLB11       ""
1   BLB02   (no restrictions on programming application code area)
1   BLB01       ""
1   LB2 (no memory lock)
1   LB1     ""

So to answer your question, those settings are not correct for bootloader installation.

Rick

February 24, 2012
by dgikuljot
dgikuljot's Avatar

Hey Guys, I had a similar queston. I am going to program a blank Atmega 328 without a bootloader. If I dont try to set any fuses will the chip automatically use the external crystal or will I actually how to change that and how? I am going to use USBASP ISP. Thanks, Kuljot Dhami

February 24, 2012
by RevMoses
RevMoses's Avatar

Thanks for the heads up Rick!!

Finally got the AVRISP MKII working with the chip (this took a while, but i hope what i have written here will help others out) I used the ATMEGA168A Windows XP AVRISP MK serial: 0155089839 you will need the last 2 digits of your serial number later (mine wont work for you, the serial number is embedded in your registry when you connect the device)

If you installed the AVR studio 4, uninstaill the Jungo drivers that came with it (i used device manager).

When it asks you for location of drivers, give it the ones found at the WinAVR-20090313bin directory

then this will work: avrdude -c avrispmkII -p m168 -P usb:39 -e

39 depends on the serial # of your device

change syntax inside of makefile to AVRDUDEFLAGS=-c avrispmkII -p m168 -P usb:39 -pm168

if you don't have XP, dload virtual machine software and run it under 7. will test it on windows 7 eventually....cheerz

February 25, 2012
by Rick_S
Rick_S's Avatar

Kuljot,

If you follow the instructions in the library link I made above, you will see exactly how to do it. You will need to set the fuses but that is a painless process and is built into the makefile.

Give it a try, and if you get stuck, let me know.

Rick

February 25, 2012
by dgikuljot
dgikuljot's Avatar

Rick_S, It seems as if in the tutorial the fuses were already set in the makefile. I am trying to basically program a Atmega 328 without any bootloader and a makefile made with the winavr mfile maker. So how do I know what fuses to set to what.

Thanks, Kuljot Dhami

February 25, 2012
by Rick_S
Rick_S's Avatar

Are you trying to install a bootloader or just program the chip via ISP and not use a bootloader at all? Either way, the fuses on a stock chip will not use an external crystal for the clock. Instead they are set to the internal RC oscillator (8MHz) with the divide by 8 turned on. Which means it is running by default at 1MHz. Let me know what you are doing, and I'll try to help out with the fuses.

Rick

February 25, 2012
by Ralphxyz
Ralphxyz's Avatar

If your are just trying to put a bootloader onto a ATmega 328 all you have to do is to load the 328 foodloader.hex from the Code/bootloader folder using AVRStudio.

As good as Rick's tutorial is it is for loading a bootloader onto a different ATmega chip not the ATmega168 or ATmega328.

For those if you have a working Nerdkit setup just load the appropriate foodloader.hex.

Ralph

February 25, 2012
by dgikuljot
dgikuljot's Avatar

I am just trying to put a program via isp onto the chip. I want to set up the chip with an external crystal so I am confused about how I would set the fuse for that. I do not want to use a bootloader.

Thanks, Kuljot

February 25, 2012
by Rick_S
Rick_S's Avatar

@Ralph:

I don't know what tutorial you are talking about Ralph, but the one I have in the library is for installing on a 328P.

@Kuljot:

You can use the makefile in the bootloader328P folder to set your fuses but you will need to edit it first so you can write to all of memory.... Actually I think it will work as is but to be sure change the lock fuse setting from 0x2f to 0x3f (default)

In the original makefile, the fuses section looks like this:

fuses:
    avrdude ${AVRDUDEFLAGS} -U lock:w:0x2f:m
    avrdude ${AVRDUDEFLAGS} -U efuse:w:0x05:m
    avrdude ${AVRDUDEFLAGS} -U hfuse:w:0xd2:m
    avrdude ${AVRDUDEFLAGS} -U lfuse:w:0xf7:m

You will want to change it to this:

fuses:
    avrdude ${AVRDUDEFLAGS} -U lock:w:0x3f:m
    avrdude ${AVRDUDEFLAGS} -U efuse:w:0x05:m
    avrdude ${AVRDUDEFLAGS} -U hfuse:w:0xd2:m
    avrdude ${AVRDUDEFLAGS} -U lfuse:w:0xf7:m

Since you are using a USBASP as your programmer, you will also need to change the programmer type in the AVRDUDFLAGS line from dapa to usbasp.

If your programmer has a low speed jumper, make sure it is in place. Also, build the circuit as I did in the bootloader tutorial. Actually, you can follow the instructions in the bootloader tutorial I linked above EXCEPT, modify the fuses like above and skip the last step where the bootloader is loaded. (Don't do "make install")

Rick

February 25, 2012
by Ralphxyz
Ralphxyz's Avatar

Shows you what I know.

I thought your tutorial was about loading a bootloader on different ATmega mcus.

Obviously I never look at your nice work to actually do it.

It is so easy to put the foodloader (bootloader) on a ATmega168 or ATmega328 using the standard Nerdkit USB cable and AVRStudio

that I assumed your work was about doing something extra.

Ralph

February 25, 2012
by Ralphxyz
Ralphxyz's Avatar

Kuljot, you can load a .hex (program) file to the mcu using AVRStudio and the Nerdkit USB cable!

That is any .hex file so that you do not need a bootloader.

You also can use AVRStudio to set your fuse settings!

This is a two second operation.

Ralph

February 25, 2012
by Rick_S
Rick_S's Avatar

I hadn't read where he was using AVR STUDIO. Not everyone does. The reason I did my tutorial the way I did was to show the methods with the tools provided with the kit. AVR Studio is one tool of many. He doesn't have an Atmel programmer, he has a USBASP. The same I used in the tutorial. I thought that might be why he was asking.

February 25, 2012
by Rick_S
Rick_S's Avatar

Also as far as I know, out of the box, the USBASP programmer does not work with AVR Studio. I will admit I haven't tried in a while though.

February 25, 2012
by Ralphxyz
Ralphxyz's Avatar

Well the thing is you do not need another "programer" to put a program or a bootloader onto a ATmega168 or ATmega328 you can just use your Nerdkit USB/serial cable.

I have various "programmers" (ATmel Dragon, STK600 and ISP but if all I want to do is to put a program (.hex) file on a 168 or 328 mcu I just use my Nerdkit USB cable and AVRStudio (without a bootloader).

I really thought all of the discussions were about putting the boot loader onto a different variety of ATmel processors, I would have questioned this earlier if I realized the discussion was about just getting the bootloader onto a 328.

That as I said, is a two second operation using AVRStudio and the Nerdkit USB cable. No need to muck around with the/a Makefile or anything but setting the fuse settings, again with AVRStudio and loading the .hex file.

Ralph

February 26, 2012
by Rick_S
Rick_S's Avatar

How do you install a program or bootloader on an ATMEGA168 or ATMEGA328P with the Nerdkit USB cable and AVR Studio?? Confused I've never heard of that being done. To my knowledge, you have to have some other interface (Programmer) to connect to the microcontrollers SPI port and reset line to program the bootloader, and as far as I know, programs as well, with AVR Studio.

I realize you have an AVR Dragon and STK600 from Atmel. While they have JTAG Support and HV Programming capabilities, I have yet to find myself needing those functions for what I have done. Maybe someday. There are many of us though who don't want to shell out the $100+ it would require to buy those two when a simple $9 ISP programmer will do the job for what we need.

I don't want to get into a what is better debate, because as far as I'm concerned, what is better is relative to who you are, what your preferences are, what tools you have, and what you are more comfortable with.

You like AVR Studio as do some others here... Great, I have no problem with that. However, while I see some benefit to it in certain situations, Most of the time it is simpler for me to open programmers notepad, do what I want, and let make do it's thing with a basic makefile.

I come from DOS days and still find some GUI's cumbersome and overly complicated for simple tasks. I quit using microsoft compliers when they went GUI. Yes, that means the last Microsoft compiler I used -- until recent years -- was Visual Basic for DOS -- The predecessor to VB. I will also admit I somewhat regret that at times.

Back to my question though... got sidetracked there for a moment... could you please explain how, with just the NK cable, a blank "New" ATMEGA328P, and AVR Studio, you can update fuses and install either a bootloader or other ".hex" file to the microcontroller.

I've never heard of this and would be eager to learn something new.

Cheers

Rick

February 26, 2012
by Ralphxyz
Ralphxyz's Avatar

DUH DUH duh, some people. I know better than to make replies off the top of my head, SORRY, in order to "PROGRAM" a mcu you have to use a PROGRAMMER!!! Duh, I am so ashamed and feeling really stupid at the moment.

I haven't done anything recently with my Nerdkit especially putting a bootloader or program directly onto the mcu and had totally forgotten how I do it "USING MY DRAGON and AVRStudio" duh.

Sorry Rick, Kuljot and the community at large I totally blew it.

Deeply ashamed,

Ralph

February 26, 2012
by Rick_S
Rick_S's Avatar

No need to be ashamed Ralph, we all blunder at times. I thought maybe I had been missing something all along.

The biggest problem I tend to have is coming off like I'm talking down to people and sounding like an a$$ in general. Embarrassed If I did that here, I sincerely apologise. I try to work on that but it still comes out sometimes.

Rick

February 26, 2012
by Ralphxyz
Ralphxyz's Avatar

No you were cool all along.

One thing I discovered after the fact was that I really did not need to spend the $500.00 plus that I spent on the STK600.

I purchased it specifically because ATmel had a ZigBee development module with a mcu with built in ZigBee that used the STK600.

Turns out the zigbee mcu was never released to production so that was a dead end street, besides learning zigbee it was a waste for production, thanks ATmel.

The Dragon programmer for $50.00+ really is all that was needed.

I suppose I should do a "Loading Bootloader" using AVRStudio for the library just so that it would be recorded and others would see another method.

Ralph

July 25, 2012
by live4the1
live4the1's Avatar

Ralph, what is the proper way to load the bootloader and set the fuses with AVRStudio 6? I have an AVRISPMKII type programmer that I have successfully connected to and erased a new blank ATMEGA328P. There are several different options so I just want to make sure that I don't mess something up. I at first tried using the programmer with AVRDUDE from the C-Prompt but for some reason the programmer was never recognized as being connected so after reading several post about the issue and trying different things, I installed AVRStudio. It looks pretty interesting. I may also ask for some coaching on how to program using it.

July 26, 2012
by Ralphxyz
Ralphxyz's Avatar

Wow, I just looked at AVRStudio 6.

So far I only see loading a .ELF file not a .HEX.

That will be a problem, now I have to learn how to make a .ELF. I know it is something in the Makefile, darn more stupid things to learn :-) Has anyone recompiled the bootloader and made a .ELF file?

live4the1, what version of AVRStudio are you using?

AVRStudio 4 is probable the most solid version, I have not been using AVR Studio lately in fact now I have to learn how to load programs (using a programer) from the command line.

Ralph

July 26, 2012
by live4the1
live4the1's Avatar

Studio 6. I know that within the same area as where you can set your fuses and erase the memory there is an option to load a .hex file.

July 26, 2012
by Ralphxyz
Ralphxyz's Avatar

I am looking at:

Tools
    Device Programming
        Tool
            AVR Simulator
                Device
                    ATmega168P
                        Apply
                            Production File

Production File will not except a .HEX file only a .ELF!

Where do you see the option to load a .hex file?

I have not looked around much yet.

Ralph

July 26, 2012
by live4the1
live4the1's Avatar

Tools-> Device Programming-> Memories

July 26, 2012
by Ralphxyz
Ralphxyz's Avatar

Ah, I found it in:

Device Programming
    Memories

Ralph

July 26, 2012
by live4the1
live4the1's Avatar

Ok, so is there an order of operation to setting the fuses and loading the bootloader .hex file? What would I have to do to use the nerdkits library but program from the Studio software. I'm guessing that I would avoid having to deal with the makefile and c-promt if I use AVR Studio.

July 26, 2012
by Ralphxyz
Ralphxyz's Avatar

All I ever do is to load the bootloader.hex file.

I have never set the fuses!!

Well I have played around with them and I have tried to understand the fuses_mike.txt file but that just leaves me more confused!!

Of course you can really get confused if you read the fuse section in the specsheet.

But you really should read that.

The thing to watch out for with setting the fuses is that 0 means on 1 means off!

But generally I just leave them alone.

Ralph

July 26, 2012
by live4the1
live4the1's Avatar
fuses:
    avrdude ${AVRDUDEFLAGS} -U lock:w:0x3f:m (This is a lock bit)
    avrdude ${AVRDUDEFLAGS} -U efuse:w:0x05:m (extended)
    avrdude ${AVRDUDEFLAGS} -U hfuse:w:0xd2:m (high)
    avrdude ${AVRDUDEFLAGS} -U lfuse:w:0xf7:m (low)

These are the changes that I made. I guess I'll have to try a program on it now.

July 26, 2012
by live4the1
live4the1's Avatar

I've tried to compile and load a blink led program using AVR Studio 6 but I get an error

Error   1   ../libnerdkits/delay.h: No such file or directory

I wonder how I tell AVR Studio to look for the nerdkit library folder?

July 26, 2012
by Ralphxyz
Ralphxyz's Avatar

Are you on the correct Path?

If you have Code/project folder with your blink_led.c cod in your project folder under Code

and code has you libnerdkits folder then:

#include "../libnerdkits/delay.h"

will find your delay.

If you made up a new project in AVR Studio then you might not be in the Code fold hierarchy.

Also with AVR Studio 4 I used to have to tell it where to find external libraries, I have not see how to do that in AVR Studio 6 yet, but that could be your answer.

So did you understand how to load the bootloader?

Ralph

July 26, 2012
by Ralphxyz
Ralphxyz's Avatar

re: External Libraries

You might try

Project
    Properties
        Project Dependencies

Put the path to your libnerkits in the Depends on:

Ralph

July 26, 2012
by live4the1
live4the1's Avatar

I do believe that the bootloader is loaded, at least the process completed. I don't seem to have anything that says dependencies.

July 26, 2012
by live4the1
live4the1's Avatar

I have copied the nerdkits library .h files to the AVR directory that holds the standard functions and changed the #include line but I am getting

Error   1   undefined reference to `delay_ms'

so I'm guessing that it just is not reading it correctly for some reason? The sample program is

#define F_CPU 14745600

#include <avr/io.h>
#include <inttypes.h>

#include <delay.h>

// PIN DEFINITIONS:
//
// PC4 -- LED anode

int main() {
    // LED as output
    DDRC |= (1<<PC4);

    // loop keeps looking forever
    while(1) {
        // turn on LED
        PORTC |= (1<<PC4);

        //delay for 500 milliseconds to let the light stay on
        delay_ms(500);

        // turn off LED
        PORTC &= ~(1<<PC4);

        //delay for 500 milliseconds to let the light stay off
        delay_ms(500);

    }

    return 0;
}
August 16, 2012
by thinairart
thinairart's Avatar

I'm glad I found this thread! I was using the wrong fuse settings that were copied from a shell script found out there on the Interwebs. I had no trouble flashing the bootloader using an AVRISPMK2 programmer, but could not then upload programs using the NK cable. When I switched to the Makefile in the bootloader168 directory of the Nerdkits source, the NK cable worked like a charm. :)

January 01, 2013
by kryton9
kryton9's Avatar

@live4the1

change: #include <delay.h> to #include <util/delay.h>

I deleted #include <inttypes.h> as we are now using Atmel Studio 6 libraries and includes.

change: delay_ms to _delay_ms

I got the same error and that fixed it.

November 04, 2013
by Jer
Jer's Avatar

OK After resolving the USB driver problems it started to show signs of life. Plus the CD I received from Atmel did not Auto Install the USB Driver It just sent me to a web site. I figured out that I needed to install the studio but it does not load the USB driver. Here is the link provided Kevin Xiong from Atmel Technical Support Team http://gallery.atmel.com/Products/Details/30543dd1-3e5b-4b2d-943a-8e53a5ab9d33? Of course I had to do the typical thing with windows Uninstal Re-Install until it started to work. The next key thing to do is to set the Fuses correctly for the 328P. So Step by step: 1) Load the Atmel-Studio 2) Install the USB Driver 3) Select the "Device Programing" from the Tools menu. 4) Select the Tool "AVRISP mkII" in the dropdown, (upper RT). If not seen might be something wrong with the driver. Recheck Device Manager and Reload Driver. 4) Select the device to be program from the drop down: "ATmega328P" 5) Select the Interface: "ISP" This is the only valid selection so it's preselected. 6) Press the [Apply] button. If an Error MSG pop-up does not show up the driver is ok. 7) Connect the "AVRISP mkII" to the device via the programming connector. 8) Select the “Interface settings” menu from the left hand side. Note: I selected the ISP Clock to be 125KHz. 9) Click on both [Read] buttons for "Device signature" and "Target Voltage" Note: The board that has the uC 328P needs to supply the 5Volts power. 10) Next Set the Fuses by Clicking on the "Fuses" menu on the left hand side. 10.1) On the bottom of this page you will see a “Fuse Register” and “Value” columns. 10.2) Manually enter these values: Extended = 0xFD High = 0xD2 Low = 0xF7 10.3) Click the [Program] button. You should see the the following: Starting operation verify registers Verify register EXTENDED...OK Verify register HIGH...OK Verify register LOW...OK Verify registers ...OK

 11)Select the HEX file to flash with.
     11.1) click the “Memories” menu on the left hand side.
 11.2) Click the […] button to navigate to the hex file to program the 328P with.
     “C:\WinAVR-20090313\avr\Code\ZSenSim\sensim20121126m.hex”
     11.3) Click the [Program] button.
           You should see the following:
        Erasing device... OK
               Programming Flash...OK
               Verifying Flash...OK
        “This should be it I have verified my programed 328P and it WORKED!”
        “My project uses the RS-232 and the LCD and delay functions and its all seems to be perfect!”
November 04, 2013
by Jer
Jer's Avatar

the reseeding note failed to format the way I intended. Just Select all the text and paste it into a text editor to view it correctly.

Post a Reply

Please log in to post a reply.

Did you know that a flyback diode is important when driving a motor or any inductive load? Learn more...