Arduino Forum

Using Arduino => Microcontrollers => Topic started by: Texy on Sep 05, 2011, 09:23 am

Title: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: Texy on Sep 05, 2011, 09:23 am
Hi,
I have a Pro Mini 3V3 on order for a specific project I am working on, but I also would like the ability to program the bootloader to blank chips in order to keep costs down (I intend to build future project using an arduino chip rather than an arduino module). I would prefer NOT to buy a specific programmer if I can.
With the above in mind I think my next step is to buy either a duemilanove, or the newer Uno. I,m thinking I will not be able to program blank chips with the Pro Mini as its the 3V3 version - correct me if I am wrong in that assumption.
Now the next question is, can the Uno be used in the same way as the duemilanove to program the bootloader in a blank chip, using the wiring to the ISP header pins?
TIA
Texy
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: CrossRoads on Sep 05, 2011, 09:58 am
I have used this method will work to burn blank chips, taking advantage of the FTDI chip on the deumilanove
http://www.geocities.jp/arduino_diecimila/bootloader/index_en.html

Altho if you're gonna buy more hardware just to use as a programmer, why not just get a programmer? They're cheaper, and can be used for any of the ATMEL AVRs (I use it to program my Bobuino's, which are 1284 based, see my link below, and will be using it to program Mini-uino's when the boards come in
I've been using this one
http://www.mdfly.com/index.php?main_page=product_info&cPath=5&products_id=415
and I have this one too but have not used it yet
http://www.sparkfun.com/products/9825
Mini-uino- ordered 50 bare PCBs, 27 spoken for so far (selling them at cost plus postage, $2 each)
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: Texy on Sep 05, 2011, 10:24 am

I have used this method will work to burn blank chips, taking advantage of the FTDI chip on the deumilanove
http://www.geocities.jp/arduino_diecimila/bootloader/index_en.html

Yes I have seen that, and my question specifically is 'can the Uno be used to do the same thing, ie does it have the X3 pads/header as the diecimila'?


Altho if you're gonna buy more hardware just to use as a programmer

I,m not, that why I don't want to buy just a programmer, I want the flexibility of having another arduino for developement/experimenting, but also for it to be used to program bootloader into blank chips.

They're cheaper, and can be used for any of the ATMEL AVRs (I use it to program my Bobuino's, which are 1284 based, see my link below, and will be using it to program Mini-uino's when the boards come in
I've been using this one
http://www.mdfly.com/index.php?main_page=product_info&cPath=5&products_id=415
and I have this one too but have not used it yet
http://www.sparkfun.com/products/9825
Mini-uino- ordered 50 bare PCBs, 27 spoken for so far (selling them at cost plus postage, $2 each)

Yes they are relatively cheap, but I,d rather spend the cash on arduino product/chips TBH. Also things are not so cheap here in the UK, lol
Appreciate your response,
Texy
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: Coding Badly on Sep 05, 2011, 11:00 am
Quote
I,m thinking I will not be able to program blank chips with the Pro Mini as its the 3V3 version - correct me if I am wrong in that assumption.


You can program any Arduino compatible processor at 3.3 volts.  But using a Pro Mini as a programmer is probably going to be more trouble that it is worth.

Quote
Now the next question is, can the Uno be used in the same way as the duemilanove to program the bootloader in a blank chip, using the wiring to the ISP header pins?


Yes.  You will need either a 10?F capacitor, a knife, or a bootloader upgrade.
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: Texy on Sep 05, 2011, 12:12 pm
Could you explain further? Perhaps its more trouble than its worth (to use a Uno).

Texy
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: dc42 on Sep 05, 2011, 01:00 pm
I use a Uno as an ISP to program my chips, see http://miscsolutions.wordpress.com/2011/08/09/prototyping-small-embedded-projects-with-arduino/ (http://miscsolutions.wordpress.com/2011/08/09/prototyping-small-embedded-projects-with-arduino/) for how I do it. I don't bother burning the bootloader, I prototype using Arduino + breadboard, then I include a 6-pin ICSP header in my target hardware and program the sketch directly into it.
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: Texy on Sep 05, 2011, 01:35 pm
Hi dc42,
your page is interesting, but I have a Q or 2 :-
"2.Locate and edit the preferences file (under Windows 7 this will be in C:\Users\<your user name>\AppData\Roaming\Arduino\preferences.txt). Change the line "upload.using=bootloader" to "upload.using=arduinoisp".

I,m a little confuse by this regarding bootloading. If I am using a brand new blank ATMega328P chip with no bootloader pre-loaded,
do I not need to program the bootloader before downloading a sketch, or does the "upload.using=arduinoisp" option also program the bootloader at the same time? If the answer is 'no' then I,m missing the part where the bootloader is downloaded into the target chip, or perhaps the answer is that the bootloader is not required for all arduino projects, only if programming via the TX/RX lines, not the ISP pins.

Texy
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: dc42 on Sep 05, 2011, 01:37 pm

...or perhaps the answer is that the bootloader is not required for all arduino projects, only if programming via the TX/RX lines, not the ISP pins.


That is correct.
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: Texy on Sep 05, 2011, 11:34 pm
Many thanks guys. I also ordered an UNO and some blank atmega328 chips today.
I'll be sure to report back with my findings.
Texy
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: VE7BDF on Sep 14, 2011, 01:13 am
I have run into a strange situation when trying to load the bootloader program on a couple of new processors I purchased from Sparkfun.

I have an Arduino Duemilanove board using an Atmega 328P processor running the Arduino software Ver 0022.  I also purchased and constructed a USBtiny programmer which is working well.

I thought that programming the bootloader program on to the new 328P processors should be straight forward.  I guess I neglected to take Murphy into consideration!  After trying to load several different bootloader programs on the new processors using the USBtiny programmer and AVRDUDE without success I started doing a bit more research and downloaded the article titled "From Arduino to a Microcontroller on a Breadboard". I  followed the process described in the article and breadboarded one of the new Atmega 328P chips on a breadboard using a 16 MHz external oscillator (Operation checked with an oscilloscope).

Prior to connecting the Duemilanove board to the chip on the breadboard I ran the Arduino 0022 software and loaded the following ----> Examples ---> ArduinoISP ---> ArduinoISP.ide and uploaded this sketch to the  Duemilanove board.  I then connected the Duemilanove board to the new breadboarded 328 processor as described in the article.  With the Arduino 0022 program I selected the correct board --->Tools ----> Board ---> Arduino Duemilanove or Nano w/ Atmega 328.  Then Tools ---> Burn Bootloader ---> w/ Arduino as ISP.  I received the following error:

(http://)

I'm not certain if the screen capture uploaded so this was the error message received:

avrdude: stk500_getsync (): not in sync: resp = 0x15

An ideas what I have done incorrectly or am missing here?

Thanks,

Martin
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: Coding Badly on Sep 14, 2011, 01:35 am

At what point did you disable auto-reset on the Duemilanove?
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: VE7BDF on Sep 14, 2011, 02:02 am
I wasn't aware that I would have to disable auto-reset on the Duemilanove, It certainly wasn't mentioned in the article.   How do I do that?
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: CrossRoads on Sep 14, 2011, 02:14 am
Use  a low value resistor to pull the reset pin high - overrides the DTR signal trying pulse the line low via the series cap.
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: Coding Badly on Sep 14, 2011, 02:52 am

Some details to CrossRoads' post...
http://www.arduino.cc/playground/Main/DisablingAutoResetOnSerialConnection

http://arduino.cc/en/Tutorial/ArduinoISP
...Add step "1.5 Disable auto-reset"
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: VE7BDF on Sep 14, 2011, 03:33 am
I did as you suggested and added a low value resistor on the reset pin of the 328P I was programming.  Unfortunately, I received the same error.

Martin
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: JoeO on Sep 14, 2011, 04:09 am
What was the value of the low value resistor you used?
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: VE7BDF on Sep 14, 2011, 05:38 am
120 Ohms
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: Coding Badly on Sep 14, 2011, 05:42 am

A resistor does not always work.  Try a 10 ?F capacitor between RESET and GND.
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: VE7BDF on Sep 14, 2011, 06:20 am
I tried a 10uF and a 22uF capacitor and received the same error message.  I'm beginning to wonder if there is something else screwed up here.
I have checked both of the 328P chips using the USBtiny programmer and avrdude and even erased the chips before starting to try and load the bootloader program.
I could upload the results of the 328p test if that will help.

Martin
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: Coding Badly on Sep 14, 2011, 06:25 am

With each test, did you re-upload the Arduino ISP sketch before trying to disable auto-reset?
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: Texy on Sep 14, 2011, 08:24 am


With each test, did you re-upload the Arduino ISP sketch before trying to disable auto-reset?


..is your theory here that if it wasn't the 328p in the duemilanove board had its bootloader re-flashed instead of on the target 328p? And if it was, does the sketch also get erased because the complete flash area get erased before the bootloader is programmed?
Texy

Texy
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: Coding Badly on Sep 14, 2011, 09:02 am

My theory is that, if the Duemilanove's bootloader gets control, it may have erased the Arduino ISP sketch.
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: VE7BDF on Sep 14, 2011, 07:15 pm
To be certain, I went through the whole process again this morning and loaded the Arduino ISO sketch each time I tried to defeat the reset function using a 120 ohm resistor for one test and the 10uF capacitor for the other.  I could also see that the Arduino ISP sketch was loading each time.  I quickly received the same error message for both tests.

Just to confirm, the test configuration I am using consists of the USB connection between the Duemilanove board with a confirmed Atmega 328P processor installed.  The Duemilanove board is connected to the blank 328P on the breadboard with the external 16MHz oscillator.  The connections are exactly as described in the "From Arduino to a Microcontroller on a Breadboard" article.  The only difference between my configuration and the one in the article is that the breadboard is powered from another 5V power supply.  Both 328P chips were erased using avrdude and the USBtiny programmer before I attempted to burn the bootloader program.  That probably wasn't required, but I was at a loss to figure out what was happening or not happening.

Since we know both processors are OK and the configuration appears to be correct, I find this very confusing.  I must be missing something, but I can't think of what it might be.  I have been researching this issue for several days and have found several different blogs on this particular problem with fairly complex solutions suggested. Some were suggesting a modification to the Make file ete., etc, but the dates of these blogs caused me to wonder if some of the bugs they were discussing might have been corre4cted in the latest Arduino software.  With this in mind, I felt that the simplest and most straightforward solution would be to download the latest Arduino software (0022) and follow the instructions provided in the article.

I greatly appreciate your help with this!

Martin
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: dc42 on Sep 14, 2011, 07:27 pm

I did as you suggested and added a low value resistor on the reset pin of the 328P I was programming.  Unfortunately, I received the same error.


The resistor from reset to to +5v (or the capacitor to ground) goes on the Arduino board you are using as ISP, NOT on the target chip you are programming.
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: VE7BDF on Sep 14, 2011, 07:59 pm
Excellent point.  I tried both the resistor and capacitor on the Duemilaove board as suggested, but on the breadboard left the 10K resistor between +5V and reset.  Again, I reloaded the Arduino ISP sketch to the 328p on the Duemilaove board prior to each test, then placed either the 120 ohm resistor between +5V and reset, or the 10uF capacitor between reset and ground.  I still received an error message, but not until around 10 seconds had passed.  Error Messages as below:

120 Ohm resistor, +5V to reset

(http://)

10uF Capacitor, reset to ground

(http://)

Are we getting closer?

Martin
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: CrossRoads on Sep 14, 2011, 08:04 pm
Just to be sure, your blank chip, you have that set up with a crystal/22 pf caps or similar?
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: VE7BDF on Sep 14, 2011, 08:16 pm
Yes, that is correct a 16MHz crystal with two 22pf capacitors.  In fact I just checked the oscillator again with an oscilloscope.  It is working correctly.
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: VE7BDF on Sep 16, 2011, 06:51 pm
Since my last post I downloaded Arduino 0022 on an older desktop using XP professional to see if the problem might have originated in the Windows 7 O/S.  I am grasping at straws as you can see.  However, the result was the same as previously experienced.

My next thought was; what about the blank Atmega 328p processor?  I connected the USBtiny programmer to the 328P chip on the breadboard and with avrdude tried to find out if there was a problem with the processor.  The results were as follows:

(http://)

I am curious about the comment "Yikes, Invalid device signature".  Does anyone have any insight into these results?

I would greatly appreciate comments.

Martin

Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: Coding Badly on Sep 16, 2011, 07:51 pm

The all zero device signature indicates that the programmer (USBtiny) is not communicating with the target (328P).  The typical culprits are wiring and clocking.
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: CrossRoads on Sep 16, 2011, 08:05 pm
Course, in the 11 days that this been going on, you could have ordered & received an AVR ISP and have working parts already...
http://store.nkcelectronics.com/pocket-avr-programmer.html
or
http://www.mdfly.com/index.php?main_page=product_info&cPath=5&products_id=415

Ok, maybe 2 bad site suggestions (temporary tho, I have purchased these 2 items from both these places)

http://www.sparkfun.com/products/9825

https://www.adafruit.com/products/26 with a USB/RS2323 adapter cable/dongle?
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: VE7BDF on Sep 16, 2011, 08:19 pm
I appreciate the comments and will certainly order the pocket AVR programmer.  However, they are currently out of stock, so I am on the waiting list.

However, the USBtiny programmer came well recommended and arrived with both dongles built.  My background is electronics, but not software, which I am attempting to learn, so there were no problems constructing the USBtiny programmer.

I am currently rechecking all of the wiring between the programmer and the breadboard just to be certain that all is OK.

Thanks
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: Coding Badly on Sep 16, 2011, 08:22 pm

Other than the programmer, do you have anything connected to the target's SCK, MISO, or MOSI lines?
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: VE7BDF on Sep 16, 2011, 08:32 pm
No
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: VE7BDF on Sep 16, 2011, 08:46 pm
I have double checked all of the wiring including the connections between the ZIP socket on the breadboard.  I am assuming that the 6 pun dongle on the USBtiny is OK and cetainly looks OK by inspection.  The plug orientations are also correct, both on the USBtiny and the breadboard.

Another check on the oscillator with the oscilloscope confirms correct operation of the 16 MHz oscillator.  Other than the oscillator, power and ground connections and USB tiny connections, there are no other connections to the 328P on the breadboard.
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: VE7BDF on Sep 16, 2011, 09:00 pm
It would appear that the wiring is OK, although I haven't yet checked to be certain that the USBtiny circuit board has any problems on it.  My assumption is that it is OK as the USBtiny does appear to be trying to communicate with the 328P.

I noticed that avrdude offers the option of changing the clocking and baud rate etc.  Any suggestions as to what changes could or should be tried?
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: CrossRoads on Sep 16, 2011, 09:03 pm
Blank chips need to be slow speed the first time, can be higher speed after that.
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: Coding Badly on Sep 16, 2011, 09:18 pm
Quote
I noticed that avrdude offers the option of changing the clocking and baud rate etc.  Any suggestions as to what changes could or should be tried?


Leave it alone.

By "clocking" I mean the target's clocking.  If you have switched the clocking to an external source, then a clock signal has to be present on XTAL1.  For the vast majority of applications this means a crystal+capacitors or a resonator.  Your oscilloscope test indicates that clocking is very likely not the problem.
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: VE7BDF on Sep 16, 2011, 09:24 pm
Yes, I realized that but was thinking about reducing the baud rate using avrdude. Any suggestions?
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: Coding Badly on Sep 16, 2011, 09:33 pm
Quote
what about the blank Atmega 328p processor?


Blank?  As in unaltered from the factory?

By USBtiny, do you mean this...
http://www.ladyada.net/make/usbtinyisp/

Earlier, we were trying to get Arduino ISP working correctly.  Now, we are trying to get a USBtinyISP working correctly.  Correct?

Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: Coding Badly on Sep 16, 2011, 09:34 pm
Yes, I realized that but was thinking about reducing the baud rate using avrdude. Any suggestions?


The baud rate determines the speed at which avrdude communicates with the programmer.  As long as the two are communicating (and they appear to be) then you should leave the baud rate as it is.
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: VE7BDF on Sep 16, 2011, 09:48 pm
I decided to see what I could do with the USBtiny programmer as I'm not certain what else can be done using the Arduino board.  I felt that more information was provided using avrdude and the USBtiny programmer but am open to anything that might work to solve the problem, particularly since the Pocket AVR programmer is not currently available.
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: alah on Sep 18, 2011, 12:55 am
To disable the auto reset a 10uF (or larger up to say 100uF)  elecrolytic capacitor between reset and ground
works better than the brute force and ignorance resistor method.
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: max891 on Sep 18, 2011, 03:11 pm
Use 10uF cap between GND and RESET
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: VE7BDF on Sep 18, 2011, 05:53 pm
Thanks for the suggestions using the capacitor.  I have tried several capacitor values without success and my checks using a USBtiny programmer and avrdude appear to indicate that the programmer and the Arduino board are not communicating with the 328P.
I have been busy but will try a couple more things today and post the results.

Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: VE7BDF on Sep 18, 2011, 07:14 pm
I was concerned that the USBtiny programmer was not communicating with the 328P or the Arduino board so decided to use the USBtiny programmer with avrdude.  I chose this process as tests using the Arduino board didn't provide very much information unless I am missing something.  The results are as attached and after viewing the results, the only possible problem I could see was the line: "avrdude:programmer operation not supported."  I'm not certain what this means.

(http://)
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: EmilyJane on Sep 19, 2011, 06:30 am
Why does it list the port as lpt1? The USBtinyISP is a serial device. Don't you have to specify a serial port with -P ?
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: VE7BDF on Sep 19, 2011, 05:43 pm
That is an interesting point.  I wondered about that when I first started using the USBtiny programmer with avrdude.  Evidently parallel operation is the default.  Since it appeared to work OK I didn't question it.  Following your comment I tried it both ways and received exactly the same results.

Thanks for the comment.
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: EmilyJane on Sep 19, 2011, 05:52 pm
Well, that seems pretty strange. I have a USBtinyISP on order so I haven't used one yet. I would probably never have noticed anything because I am accustomed to specifying the port when using the Arduino as ISP.
Title: Re: Duemilanove or Uno, for programming bootloader into blank chips, etc
Post by: VE7BDF on Sep 19, 2011, 06:02 pm
I am very happy with the USBtiny and it certainly appears to work well.  As you can see from the last attachment, the USBtiny appears to be working and communicating with the 328P.
My concern is the weird problems that have arisen around programming the bootloader on the 328P.  I have tried using two different 328P's with no success.  On the surface this would seem to be a trivial project, but obviously I am missing something.