Optiboot with FTDI Problems..

Actually it looks like more recent versions of avrdude can handle odd baud rates ok. Try using the v1.0r1 IDE.

WiredUp:
uno.upload.speed=115200 Is this the line I am changing in the boards.txt file?

Yes.

I changed the value to 144000, and now I can upload to a chip.. well it completes the upload, but it responds back: avrdude: serial_baud_lookup(): unknown baud rate: 144000

I suggest trying a newer version of avrdude...

Or a newer version of the GCC AVR toolset...

Brilliant! I will try it out, and post back.. thanks guys!

Ok, so I tried the installing WinAVR and grabbing the avr directory and swapping it with the ones for the Arduino's toolset.. well, now the IDE will respond:

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

Any other suggestions?

There is a possibility that one of the previous problems is still a problem...

Does auto-reset appear to be working?

Are you confident you have TX and RX the right way around?

Did you leave the baud rate at 144000 or put it back to 115200?

Was that a rhetorical question?

If not, then the answer is still yes. The serial speed is hard-coded into the bootloader and depends on clock frequency.

Edit: what just happened here... so many posts before this one. Seems like I've lost half an hour... Odd.

Did @WiredUp delete something?

I don't know. Maybe I was distracted with something else for waaay too long.

Well I am thoroughly confused.. I tried moving over the avr toolset from winavr, and using it didn't solve my problem.. it actually caused some issues with uploading to a regular UNO board.. I dunno, but I made sure while I was using that toolset I checked out my wiring making sure tx/rx were in their respective places.. and the auto-reset circuit was setup properly.. but no dice still. I switched back to the original toolset.. and broke down..

I built a barebones circuit with a 16 MHz. crystal and (2) 22pF caps instead of the 20MHz. resonator. I checked the boards.txt file and made sure it was back at a baud rate of 115200.. and I can't upload to the chip via the FTDI cable.. same errors in the IDE as before..

I'm not a great programmer and all this information I am finding about recompiling the optiboot is severely confusing.. working and in school I just need a working solution.. it doesn't make since at this point. I just need a working solution without having to swap the chip back and forth to the arduino each time.

If I can accomplish my goal in another IDE.. thats an option.. AVRstudio looks cool, but learning curve seems a little fun, and figuring out how to reuse all my arduino libraries in AVRstudio seems like another problem in itself.

I'm just lost at this point.. I have tried so much and not accomplished anything.. ever got lost in what your doing and don't know where to go next?... yyeeppp.. thats me.

It sounds like you've got in a muddle, so it's time to simplify! You can do everything you need with the latest version of the Arduino IDE, so I suggest getting rid of all other Arduino or AVR software (for now) and installing Arduino IDE v1.0r1 from Google Code Archive - Long-term storage for Google Code Project Hosting..

Since you've got the pieces to make a 16MHz breadboard-Arduino, I recommend starting with that: no recompiling bootloaders, and no strange baud rates. Firstly, I suggest re-loading the bootloader in case something went wrong the first time. The easiest (and best) way to do that is with Bill Westfield's Optiloader sketch, from GitHub - WestfW/OptiLoader: Arduino sketch for burning new bootloaders. You'll need to change the first line of optiLoader.h from #include <WProgram.h> to #include <Arduino.h>, then compile the sketch and load it onto your Uno.

Then connect up the Uno as an ISP programmer, as shown here:

One everything is connected, hit reset on the Uno and wait a few seconds for it to do its thing. Note that you are not using the IDE to load the bootloader - the Uno will do everything itself. However you can monitor output from the Uno on the serial terminal window.

With that done you can remove the programmer, connect the breadboard to a serial interface, and try uploading a sketch. You can use the Uno board (with microcontroller removed), as in the image below. Or you can use your FTDI cable - don't forget to connect power, and Reset (pin 1) to DTR. In both cases, select "Uno" as the board in the IDE and try uploading the Blink sketch.

Let us know if you get things working at 16MHz, and then we'll have a go at 20MHz.

(images taken from the Arduino web pages at http://arduino.cc/en/Tutorial/ArduinoISP and http://arduino.cc/en/Tutorial/ArduinoToBreadboard)

Thanks alot.. that really unwound my mind a little.. should have seemed obvious that I could use the UNO straight up to program a chip.. but it works!

So I downloaded IDE v1.0r1, and the Optiloader sketch and followed the instructions.. works great with the UNO itself, but I still can't get the FDTI cable to work.. with a LED on pin 19 I can see it trying to upload the sketch. It blinks a couple of times and then is off until the IDE gives up and errors.. then it blinks again.

At least I have a solution that will save me the one thing I have too little of.. time :slight_smile: All the help is greatly appreciated!

I do wish I could figure out how to get the FTDI working.. but if its going to be that much trouble I don't know if it is really worth using.

I still can't get the 20 MHz. resonator to work even with the UNO.. I went into the boards.txt folder and changed the baud rate to 144000, and nothing. So hopefully there is more to that..

Thanks again :slight_smile:

The FTDI holds DTR low during communication rather than sending a pulse, so you'll need a 0.1uF capacitor between DTR and Reset. Otherwise the ATmega328 is being held in Reset whilst avrdude is trying to upload a new sketch.

If 144000 baud doesn't work, you can try recompiling Optiboot for 115200 baud at 20MHz. Thanks (again) to Bill Westfield, this is rather easy. Go to the hardware/arduino/bootloaders/ folder in the IDE, create a new directory, and into it download the files from https://github.com/WestfW/Arduino/tree/master/hardware/arduino/bootloaders/optiboot. In the Makefile change the line atmega328: AVR_FREQ = 16000000L to atmega328: AVR_FREQ = 20000000L, and run the commands

..\..\..\tools\avr\utils\bin\make OS=windows ENV=arduino clean
..\..\..\tools\avr\utils\bin\make OS=windows ENV=arduino atmega328

Hopefully you'll then have a new file called optiboot_atmega328.hex. Open this file and the Optiloader sketch in a text editor, and locate the image_t PROGMEM image_328p section in Optiloader. Replace the hex data in Optiloader with the data from the new .hex file, taking care to conserve the formatting (actually you only need to replace the lines starting :107E20 and :107E30, as the rest is unchanged). Once this is done, follow the previous recipe for uploading the bootloader. Before trying to upload a sketch you'll also need to create a new section in the boards.txt file, with all the same settings as for the Uno except with f_cpu set to 20000000L.

Excellent news on recompiling optiboot! I will try this out when I get home later today... as for the FTDI.. I had the 0.1uF capacitor between DTR and Reset, and still had no luck.. I will double check, and try it again..

Thanks again, tim7

The breadboard Arduino resembles very much the minimalist Arduino-Pro boards made by Sparkfun Electronics. To double check the connections required for programming via an FTDI cable, take a look at Sparkfun's schematics at FTDI Cable 5V - DEV-09718 - SparkFun Electronics and Arduino Pro 328 - 5V/16MHz - DEV-10915 - SparkFun Electronics.

As an aside, Sparkfun is extremely good about publishing schematics and firmware, and I like their Pro-series Arduino boards a lot.

Well, it was long day today so I'm just now getting around to working with recompiling Optiboot.. I'm a little confused on where the makefile is that I am suppose to edit.. what directory is it in? I found several makefiles, and I want to be sure I'm changing the right one.

go to hardware/arduino/bootloaders/ (inside the arduino installed directory) and create a NEW directory (say "optiboot20")
Then when you copy the files from https://github.com/WestfW/Arduino/tree/master/hardware/arduino/bootloaders/optiboot in to that directory, you'll be getting a new makefile, and that's the one to edit.) (Actually, you can probably use the existing "pro_20mhz" target.) It'll look like this, more or less:

C:\Documents and Settings\Bill Westfield>[color=brown]cd \bin\arduino-0022\hardware\arduino\bootloaders\[/color]

C:\bin\arduino-0022\hardware\arduino\bootloaders>[color=brown]mkdir optiboot20[/color]

C:\bin\arduino-0022\hardware\arduino\bootloaders>[color=brown]rem copy files using web browser[/color]

C:\bin\arduino-0022\hardware\arduino\bootloaders>[color=brown]cd optiboot20[/color]

C:\bin\arduino-0022\hardware\arduino\bootloaders\optiboot20>[color=brown]dir[/color]
 Volume in drive C has no label.
 Volume Serial Number is C818-E05C

 Directory of C:\bin\arduino-0022\hardware\arduino\bootloaders\optiboot20

10/03/2011  11:57 PM    <DIR>          .
10/03/2011  11:57 PM    <DIR>          ..
10/03/2011  11:40 PM            34,011 boot.h
10/03/2011  11:39 PM            13,063 Makefile
10/03/2011  11:40 PM                60 omake.bat
10/03/2011  11:40 PM            22,344 optiboot.c
10/03/2011  11:41 PM             1,932 pin_defs.h
10/03/2011  11:54 PM             1,636 stk500.h
               6 File(s)         73,046 bytes
               2 Dir(s)  10,761,437,184 bytes free

C:\bin\arduino-0022\hardware\arduino\bootloaders\optiboot20>[color=brown].\omake pro20[/color]

C:\bin\arduino-0022\hardware\arduino\bootloaders\optiboot20>..\..\..\tools\avr\utils\bin\make OS=windows ENV=arduino pro20
../../../tools/avr/bin/avr-gcc -g -Wall -Os -fno-inline-small-functions -fno-split-wide-types -mshort-calls -mmcu=atmega168 -DF_CPU=20000000L  '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'   -c -o optiboot.o optiboot.c ../../../tools/avr/bin/avr-gcc -g -Wall -Os -fno-inline-small-functions -fno-split-wide-types -mshort-calls -mmcu=atmega168 -DF_CPU=20000000L  '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' -Wl,--section-start=.text=0x3e00 -Wl,--section-start=.version=0x3ffe -Wl,--relax -Wl,--gc-sections -nostartfiles -nostdlib -o optiboot_pro_20mhz.elf optiboot.o ../../../tools/avr/bin/avr-size optiboot_pro_20mhz.elf
   text    data     bss     dec     hex filename
    500       0       0     500     1f4 optiboot_pro_20mhz.elf
../../../tools/avr/bin/avr-objcopy -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex optiboot_pro_20mhz.elf optiboot_pro_20mhz.hex
..\..\..\tools\avr\bin\avr-objdump -h -S optiboot_pro_20mhz.elf > optiboot_pro_2
0mhz.lst
[color=red]/usr/bin/sh: ......toolsavrbinavr-objdump: command not found
make: *** [optiboot_pro_20mhz.lst] Error 127[/color]
rm optiboot.o optiboot_pro_20mhz.elf

C:\bin\arduino-0022\hardware\arduino\bootloaders\optiboot20>[color=brown]dir *.hex[/color]
 Volume in drive C has no label.
 Volume Serial Number is C818-E05C

 Directory of C:\bin\arduino-0022\hardware\arduino\bootloaders\optiboot20

10/03/2011  11:57 PM             1,467 optiboot_pro_20mhz.hex
               1 File(s)          1,467 bytes
               0 Dir(s)  10,761,433,088 bytes free

C:\bin\arduino-0022\hardware\arduino\bootloaders\optiboot20>

the part in red looks like a bug. In a spot that worked before; I'll have to look into that. Grr. It still produces a valid .hex file you can load into your AVR, though; the error is in generating the .lst file...

the part in red looks like a bug. In a spot that worked before; I'll have to look into that. Grr.

It looks likely that this is because I installed WINAVR, which results in there being a "sh.exe" in my path, which make then uses as a first choice over cmd.exe. If you don't have a sh.exe in your path, it should work fine.

grr. how am I supposed to make THAT work automatically? (and if make will run either cmd.exe that needs backslashes, or sh.exe that can't have backslashes, why doesn't IT fix the filename?! Grrrr.)

Just force everyone to use a wrapper batch/script file to start the make rather than start make directly
from the commandline.

Then in the wrapper force the PATH variable to include the path to the arduino supplied WinAVR/unix
tool directory by adding to the front of PATH.
Then set TMPDIR, then crank up make and you will never have to have worry about
all the screwy backward slash stuff anymore and can remove all that DOS specific
stuff inside the makefile.

The wrapper can be smart enough to look in a few places for the tools rather
than just assume that they are always in a specfic location relative to the current directory.
i.e. pre 0018 relative paths are different from now. and WinAVR might be installed. It is easy
to look around for them and then pick one based on a priority and you can also
us an environment variable to override this search for special uses.

This is what I do to allow building the glcd library on both windows and linux.

--- bill

WiredUp:
Arduino IDE.. I don't have a lot of experience with avrdude..

I believe the Arduino IDE uses avrdude behind-the-scenes.