Reprap/AVRDUDE sketch upload error code  help!?

Hi,
I'm building a reprap Microcontroller firmware installation - RepRap and trying to upload a sketch to the ATMEGA168P on the extruder controller board.
I'm using this USB TO RS232 FT232RL module http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&item=270614731558&ssPageName=STRK:MEWNX:IT , arduino software 0019 on Ubuntu lucid but getting the following error code and I have no idea what it means! Can ANYBODY help?

Binary sketch size: 6962 bytes (of a 14336 byte maximum)
avrdude: stk500_getsync(): not in sync: resp=0x11
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x11

Thanks in advance!

Does the ATMEGA168P have a bootloader installed?

Hi, yes it has a bootloader. It took a while to get it on, but after editing the boards.txt and avrdude.conf files I managed (with a lot of help from the reprap forum) to upload it directly through avrdude (not the arduino software though) But now I've reached a dead end. :frowning:
Have you encountered these error codes or similar before?
Thanks.

I personally have not but this sort of question has been raised many times on this forum.

In the Arduino IDE, which board have you selected? Which serial port?

Well basically I followed this thread (http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1276164280/0) to get Arduino prog to recognise the 168P, also I had to add the 168p to the boards.txt file.
So I've added and chosen the 'Arduino Diecimila, Duemilanove, or Nano w/ ATmega168p' on /dev/ttyUSB0

As I mentioned, I've managed to upload the bootloader via avrdude through the terminal, so I believe the port/module is working, I'm just having difficulty uploading the firmware via Arduino?! :-?

Can you point me to any solutions, as I've searched around but I just seem to come across issues and no answers. :frowning:

Thanks for your help! :smiley:

When you disconnect the RS232 FT232RL from the computer does /dev/ttyUSB0 disappear?

When you connect the RS232 FT232RL to the computer does /dev/ttyUSB0 reappear?

Are the RS232 FT232RL ground and the processor grounds connected together? How are you powering the processor?

Is the RS232 FT232RL connected to pins 0 and 1 on the processor?

Sorry for the late reply!

In answer to your questions,
yes,
yes,
yes, it's powered via the usb,

However as far as pins 0 and 1 are concerned, I'm not sure, the pcb is pre-fab so I'm not sure where the pins are routed to. But I assume if they are meant to be connected, then they are (save for a dry connection)

the RS232 is connected to the pcb via a 6pin header.

I hate to ask so many questions but your setup is new to me. And, given the number of other forum members who've joined this thread, it appears I'm not the only one who's never worked with a RepRap.

When you burned the bootloader, was the RS232 FT232RL involved?

When you burned the bootloader, was it connected like this...

Ask away! I'm doing the same and you're the one who's helping me after all! If we get some answers then hopefully this can help more people. :sunglasses:

After re-tracing my steps I've realised that I burned the bootloader using my USBtinyISP module, so I'm not even sure if the RS232 is working! :-[ not sure how to test that?!

So in answer to your connection question, no it wasn't connected like that, but that is how it should be connected when the sketch is being uploaded.

(BTW- that image shows the motherboard connected not the extruder pcb, which is a daughter-board, the reprap documentation isn't great!)

If you need me to clear anything up please just ask and I'll tell you what I (think I) know! :stuck_out_tongue:

After re-tracing my steps I've realised that I burned the bootloader using my USBtinyISP module, so I'm not even sure if the RS232 is working! not sure how to test that?!

Search the forum for loop back (or loopback) test. Let's make certain that adapter is working.

Right I think I've checked the loopback of the FTDI module:

I disconnected all the wires from it apart from the usb cable, then linked the tx and rx pins. When I send text via the Arduino serial monitor it scrolls it back in the lower window. :slight_smile:

So I'm assuming all is well, or are there further tests?

So I'm assuming all is well, or are there further tests?

All is well.

When you burned the bootloader, did you also set the FUSES?

Is the processor run from an external crystal?

Yes I used the following:

sudo avrdude -U flash:w:hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_diecimila.hex -p m168p -c usbtiny -U lfuse:w:0xff:m -U hfuse:w:0xdd:m -U efuse:w:0x00:m

It uses a 16Mhz ext crystal.

Yes I used the following:

And there's the problem!

lfuse:w:0xff:m  -->  Ext Crystal Osc. Frequency [glow][size=14]8.0 MHz[/size][/glow]; Start-up time PWRDDWN/RESET: 16K CK/14 CK + 65 ms

hfuse:w:0xdd:m  -->  SPIEN Enable Serial programming and Data Downloading; Brown-out detection level at VCC=2.7 V; 

efuse:w:0x00:m  -->  Boot Reset vector Enabled (default address=$0000); [BOOTRST=0]; Boot Flash section size = 1024 words Boot start address = $1C00

It uses a 16 Mhz ext crystal.

I use this for fuse settings...
http://www.engbedded.com/fusecalc

Ahh, now we're getting into dark magic!

I took a look at the calculator, there was no reference to 16Mhz but there was 'Frequency 8- Mhz' which I assume is anything 8 or above (upto 20Mhz?) but lfuse:w:0xff:m is correct for that setting (as far as I can tell?) by setting it to 0x7f it turns on the clock/8 (speed=2Mhz?)
Either way, neither of these works! :frowning: same error.

Aaaargh! grrr. This has stopped being amusing!

I don't understand why I'm having so much trouble! It's not as if I'm building from scratch- It's a pre designed pcb and components which every other reprap uses without problems.
I can only assume it's because I have an ATMEGA168P instead of a ATMEGA168, but are they not identical in operation and specification?

Is it possible that the USBtinyISP serial module isn't working/setup correctly. The reason I ask is that my motherboard (which is confirmed working (SANGUINO ATMEGA644A)) will not communicate with the reprap host software and it is this module which handles the coms.

Are there any other tests which I can do to check the functionality of the module with the motherboard/host software?

I'm going insane here as NOTHING seems to work!

Dang it! I am truly sorry. I've been working with Tiny processors where there are different fuse settings for 1 MHz and 8 MHz. I got it in my head that, if the setting didn't have "16 MHz" it was the wrong setting.

I took a look at the calculator, there was no reference to 16Mhz but there was 'Frequency 8- Mhz' which I assume is anything 8 or above (upto 20Mhz?)

You are absolutely correct. Your original fuse settings should be fine.

I can only assume it's because I have an ATMEGA168P instead of a ATMEGA168, but are they not identical in operation and specification?

Folks have used "P" processors without any problems so I doubt that's the culprit.

Is it possible that the USBtinyISP serial module isn't working/setup correctly

It's possible but doesn't seem very likely. In my experience, if anything goes wrong, that failure makes its way back to the software (AVRDUDE). I can't think of any sort of ICSP failure that would not be detected by AVRDUDE.

Are there any other tests which I can do to check the functionality of the module with the motherboard/host software?

I'll get back to you this evening. This time, I promise, I will not lead you astray!

I'm going insane here as NOTHING seems to work!

The ICSP seems to work which is actually a good sign.

Thanks for your help- I don't mind the occasional dead end, such is life! :wink:

I'm also contemplating that it might be a JAVA issue (hope not)?
It's all a bit daunting really as there are sooo many possibilities why it's not working and I'm a complete novice to it all! :-[

I've ordered a premade usb-ttl cable so hopefully I'll be able to eliminate that as a potential issue! If not at least I'll have a spare!

I thought of something... please locate and post the "boards.txt" file you modified. Please enclose it in "code tags" ([#] button above the edit window).

The whole .txt is too big to post so I've only included the original and copied/amended 168P code.
Do you need it all?

##############################################################



diecimila.name=Arduino Diecimila, Duemilanove, or Nano w/ ATmega168



diecimila.upload.protocol=stk500

diecimila.upload.maximum_size=14336

diecimila.upload.speed=19200



diecimila.bootloader.low_fuses=0xff

diecimila.bootloader.high_fuses=0xdd

diecimila.bootloader.extended_fuses=0x00

diecimila.bootloader.path=atmega

diecimila.bootloader.file=ATmegaBOOT_168_diecimila.hex

diecimila.bootloader.unlock_bits=0x3F

diecimila.bootloader.lock_bits=0x0F



diecimila.build.mcu=atmega168

diecimila.build.f_cpu=16000000L

diecimila.build.core=arduino



############################################################## 



diecimilaP.name=Arduino Diecimila, Duemilanove, or Nano w/ ATmega168p 



diecimilaP.upload.protocol=stk500 

diecimilaP.upload.maximum_size=14336 

diecimilaP.upload.speed=19200



diecimilaP.bootloader.low_fuses=0xff 

diecimilaP.bootloader.high_fuses=0xdd 

diecimilaP.bootloader.extended_fuses=0x00 

diecimilaP.bootloader.path=atmega 

diecimilaP.bootloader.file=ATmegaBOOT_168_diecimila.hex 

diecimilaP.bootloader.unlock_bits=0x3F 

diecimilaP.bootloader.lock_bits=0x0F



diecimilaP.build.mcu=atmega168p 

diecimila.build.f_cpu=16000000L

diecimila.build.core=arduino

##############################################################