sparkfun atmega168 w/ arduino bootloader

Can a m168 work with the blink sketch and have problems with a full program?

If a Flash cell is defective.

However, if the Bootloader verifies the uploaded Sketch then my theory is trash.

Does the bootloader now verify the uploaded sketch during a normal upload? Should the bootloader (or something) give an error msg if something didn't work correctly? even a defective chip?

Ken H>

The only thing I can think of is that something in the fuse settings is different on the Sparkfun chip than on the one from your Arduino. Either the Crystal Oscillator settings or the BrownOut detect could cause such failure to operate, I think. How sure are you of of the power supply and crystal circuitry on your external circuit?

I'm starting to get the impression that the SparkFun processor is defective.

Does your Sketch use the EEPROM?

Not that I know of. I don't have any read(), or write() functions in it.

[edit]The Sparkfun m168 "seems" to load the blink sketch ok, but nothing more complex?[/edit]

I did a test on the first page and the sparkfun processor did not have any problem running the blink sketch while outputting messages to the LCD.

However, if the Bootloader verifies the uploaded Sketch then my theory is trash.

Where would I see this? The arduino software doesn't give any errors when uploading.

The only thing I can think of is that something in the fuse settings is different on the Sparkfun chip than on the one from your Arduino. Either the Crystal Oscillator settings or the BrownOut detect could cause such failure to operate, I think. How sure are you of of the power supply and crystal circuitry on your external circuit?

I'm fairly certain my power supply is ok. I'm running it off a 12v sealed lead-acid battery, and there are caps on both the 12v and the 5v lines (as seen in the standalone arduino tutorial). I setup the crystal just like in the tutorial too, with one 22 pF capacitor running to ground from each pin.

I picked up a second sparkfun processor and i'm still having the same problem, so I don't think it's a defective chip.

to make simple without referring to the small board you have, just looking at the Arduino and the sparkfun m168.

The original m168 chip works good with all sketches in the Arduino - correct?

None of the Sparkfun chips will your complex sketch in the Arduino?

You mention the Sparkfun m168 will "run the blink sketch while outputting messages to the LCD" - what messages are you writing to the LCD? If you are writing things to the LCD it seems like it should be working, but you say the Sparkfun m168 does not run your sketch? Yet the Arduino m168 runs this sketch just fine?

Ken H>

Yes, the original chip works fine in both. The sparkfun chip wont work in the arduino with my sketch, but it will display text on the LCD and blink the led.

Since the sparkfun m168 will run most all sketches in the Arduino - except for your code, why don't you post it here? there are some really good code folks here that might have an idea.

Since the bootloader is loaded from Sparkfun the fuses "should" be set correctly - that would control the brownout function. I'm not sure how to check the fuses with the Arduino IDE - I use an external programmer with AVRdude or Studio4 to check fuses and normally use that to burn my sketches to a m168 without the bootloader for my project boards.

Good luck,

Ken H>

The code is in the topic for my project that I linked to on the first page. I uploaded the code here:

I'm not sure how to check the fuses with the Arduino IDE

I don't believe that it is possible to do so :frowning:
(nor is it documented that a program running on the AVR can read fuses, although it wouldn't surprise me if they show up at some undocumented register address.)

Does anyone have all of 1) Regular Arduino m168 chip 2) Sparkfun m168 chip 3) "real" programmer of some kind (capable of reading fuses.)

Which keypad library are you using?

I tried the one here but the Sketch won't compile...
http://www.arduino.cc/playground/Code/Keypad

Thats the library, but it looks like they changed some things from the version I am using.

Heres the new code that compiles with that library:

Thats the library, but it looks like they changed some things from the version I am using.

Thanks.

Following along westfw's idea, I had a theory and a method to prove / disprove the theory.

SparkFun calls the product "ATmega168 with Arduino Bootloader". In the comments area, Matthew says, "Comes with the Fast Bootloader, Not the normal bootloader." I've had problems with SparkFun's product descriptions so I think it's safe to assume Matthew is correct. Unfortunately, there is no such thing as a "Fast Bootloader" for the Arduino. I suspect he meant LadaAda's Bootloader.

LadyAda clearly states that, "Please note that the fuses are different for this chip because of the extended memory!"

http://www.ladyada.net/library/arduino/bootloader.html

wizdum stated, "I wrote and compiled the code for the duemilanove".

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1270072139/2#2

I assumed wizdum's Sketch was fairly large; big enough to use most of the Arduino Duemilanove's memory. Compiling for, uploading to, and running from the Duemilanove processor works without a problem.

But what would happen to this same program, compiled for the Duemilanove and uploaded to the LadyAda processor? My theory was that AVRDUDE would faithfully try to upload the program but would corrupt the image in the process.

However, the binary sketch size is 5450 bytes (of a 14336 byte maximum). I rather suspect that LadyAda's bootloader will accommodate a 5450 byte Sketch. Even if SparkFun used the wrong fuse settings, 1024 is the largest boot section. There's still plenty of room for a 5450 byte Sketch.

I hate to say it wizdum. I'm out of ideas.

You have done some research there.

Based on the comments from Sparkfun the bootloader is different than the normal bootloader, I'd sure be tempted to load a standard bootloader to the m168 chip an try that.

The chips "should" be the same, but perhaps something deep down inside the differences in bootloader code, fuses, etc is causing the problem? Load the standard Arduino bootloader for the m168 and try that?

Other than that, I'm fresh out of ideas myself.

Ken H>

I noticed something interesting on the ladyada page:

Here's a bootloader hack that will automatically start the sketch after it has been uploaded and will also only start the bootloader when the reset button is pressed

I tried pressing the reset button on the arduino with the sparkfun processor in it, and it loaded my sketch after a second. It seems that the arduino processor automatically loads the sketch, while the sparkfun one waits for the reset button to be pressed each time the unit is powered up. This is going to be a problem as my standalone board does not have a reset button (there was no room for it on the board, and I can't allow the end user to restart the device whenever they want).

So it looks like i'm going to have to pick up a avr programmer. Any recommendations? I know AdaFruit sells the usbTinyISP, and I also saw this on sparkfun:

I really like this one...

But it's a bit expensive.

Here is one I am using - it's a kit, but only takes a few minutes to solder up - and it's $11 shipped - about the best price around.

http://www.fun4diy.com/AVRISP_mkII.htm

I do like the looks of the one linked by Coding - that scope function is interesting. C-B - how does the scope program work for you?

Ken H>

I do like the looks of the one linked by Coding - that scope function is interesting. C-B - how does the scope program work for you?

I have not yet had the need nor opportunity to use it. I've used everything else: the programmer, the TTL serial, and the "pass through" +5 volts. I soldered a male header into the six pins on the side so it can be plugged into a breadboard.

One of the things I really like about the Pololu programmer is the very small size. It's about the same size as the big USB connector. I roll up the programmer with a USB cable attached and pack it away for travel.

I think you should put the bootloader onto it yourself. Easy to do. I think the arduino18 IDE supports that as well. if not there is a something on geocities for a duemilanove bitbang programmer. can read, modify and write fuses with that.(it uses avrdude and FTDI bitbang mode)

This?

http://www.geocities.jp/arduino_diecimila/bootloader/index_en.html

yes. I was a bit lazy to google and post it :wink: thanks to you.