Welcome! Log In Create A New Profile

Advanced

Problem trying to program fuses on Melzi w/avrdude

Posted by virgodave61 
Problem trying to program fuses on Melzi w/avrdude
July 24, 2016 11:48PM
I have a new Melzi board that has issues with the endstops.
So I found this article that suggests its a fuse issue. [www.geeetech.com]
I setup a Arduino Uno as a ArduinoISP.
I navigated with the windows cmd tool to the folder where avrdude resides then typed:
avrdude -B 8 -ATMEGA1284P -c usbtiny -U lfuse:w:0xFF:m -U hfuse:w:0xDC:m -U efuse:w:0xFD:m
to reset the fuses as described in the Geeetech article, and all I get back is a message that says avrdude: invalid option "-- A" Im not see me entering a -A
option unless its in reference to the -ATMEGA1284P part.
In the avrdude tutorial I don't see a listing for ATMEGA1284P as a supported part is this the issue? Then why would the article say to use this command line, and what do I do?
Anyone have any ideas whats wrong?
Thanks in advance!
Dave

Edited 1 time(s). Last edit at 07/24/2016 11:56PM by virgodave61.
Re: Problem trying to program fuses on Melzi w/avrdude
July 25, 2016 04:04AM
-ATMEGA1284P isn’t correct, should be -p m1284p or -p atmega1284p

The example on geeetech is just wrong....

Also for a arduinoisp you need -c avrisp not -c usbtiny

you probably also need something like -P com18 -b 19200 to set the com port and baud rate

Edited 6 time(s). Last edit at 07/25/2016 04:39AM by Dust.
Re: Problem trying to program fuses on Melzi w/avrdude
July 25, 2016 08:17AM
Thanks again Dust for coming to my rescue, you have no idea how much I appreciate it.
I'm a bit confused on the com port issue because I'm not using one,all I want to do is make the fuse settings correct, the Uno is connected directly to the Melzi as described in the articles.
I also wonder if the Geeetech article is correct about the fuse settings, I looked at your link to the fuse settings and have no idea what is correct, like all the clock setup etc.
Also when I search the app's in my Arduino directory I cannot find any avrisp or usbtiny, but have found one called avrtiny.
Dave

Oh. I found this on a site and will try it when I get a chance: avrdude -p atmega1284p -c stk500v1 -b 19200 -V -e -U lfuse:w:0xD6:m -U hfuse:w:0xDA:m -U efuse:w:0xFD:m -U flash:w:ATmegaBOOT_168_atmega1284p.hex:i

Edited 2 time(s). Last edit at 07/25/2016 01:30PM by virgodave61.
Re: Problem trying to program fuses on Melzi w/avrdude
July 25, 2016 05:26PM
the -c parameter sets the hardware programmer that avrdude expects to find, they are not files. But you should find them in a txt file called programmers.txt

Your plug the UNO into the computer and it is seen by the computer as a com port, this is the com port that must be specified in the -P option. This is how the computer sends data threw the UNO to the Melzi

Edited 1 time(s). Last edit at 07/25/2016 05:26PM by Dust.
Re: Problem trying to program fuses on Melzi w/avrdude
July 25, 2016 11:37PM
Ok, I get it, thanks. I'll play with it again tomorrow after work and post the results.
You haven't given me your opinion about what coarse of action I should take, do you think I just need to reset the fuses to the proper condition, or do I need to do more? Do you offer any input on this?
Your help is appreciated!
Dave
Re: Problem trying to program fuses on Melzi w/avrdude
July 25, 2016 11:50PM
The example you give has

-U flash:w:ATmegaBOOT_168_atmega1284p.hex:i this is uploading the bootloader. I would not recommend this if the bootloader is working (ie you can upload new firmware without using the UNO)

-U lfuse:w:0xD6:m -U hfuse:w:0xDA:m -U efuse:w:0xFD:m Should work fine


What I think you need to do is firstly read the current fuses

-U lfuse:r:-:h -U hfuse:r:-:h -U efuse:r:-:h

Once you have these work out what they are set to with [eleccelerator.com]
and check that jtag is enabled.

Once you confirm that jtag is enabled disable jtag in the fuse calculator site and compare the new calculated values with the recommenced ones. If they match, write them back, if not work out whats different and if its important to you.

or post the value here for more comments
Re: Problem trying to program fuses on Melzi w/avrdude
July 27, 2016 02:02AM
Hey thanks for telling me how to read the fuses that resulted in a real let down, so now what?
I was able to get it working by entering: avrdude -p atmega1284p -c avrisp -P com4 -b 19200 -U lfuse:r:-:h -U hfuse:r-:h -U efuse:r:-:h
My new board said the fuses are: Low=D6 High=FD and Extended=DC, so I plugged in my old controller and read that and they are all set the same, what a let down.
To recap the problem with my new controller when I try to home an axis the stepper will move a few steps and stop and one of the axis does the same but moves away from the home position, don't remember which one.
What now?
My understanding is that the bootloader should be fine if you can communicate with the board using your PC.
If I need to reinstall the firmware is there a way to copy the good firmware from my old Melzi to the new one?
If I need to download new firmware I have to uncomment the line:
//#define REPRAPPRO_MELZI
//#define REPRAPPRO_SANGUINOLOLU
I'm confused by the Melzi wiki that says There is a version of the Marlin RepRap firmware for Melzi on RepRapPro Ltd's Github repository here. It contains the extra files needed for the Arduino IDE to talk to a Sanguino (and hence to the Melzi).
which one to uncomment?
Your help has been priceless!
Dave'

Edited 3 time(s). Last edit at 07/27/2016 03:17AM by virgodave61.
Re: Problem trying to program fuses on Melzi w/avrdude
July 27, 2016 04:17AM
ok, well at least you know its not the fuses now.


lets take a step back.


You can talk to the controller, this is a good start

If you position your printer so that no endstops are being hit, then send the printer the command M119 (display endstop status) what does it tell you
now hold down the X endstop and send annother M119 at the printer, then do Y and Z endstop

The first command should tell you all endstops are open, then as you press each endstop, that endstop should report that it is triggered,

I suspect this is not working correctly for you.



Re copying existing firmware, yes you can copy it from the old to the new, as long as they are the same board and processor.
This might get you working, but means you wont be able to update your firmware (as you don't know all your settings)
But maybe you in a rush and just need it working...

To do this you need to use the Uno again as a avrisp

the command would be

avrdude -p atmega1284p -c avrisp -P com4 -b 19200 -U flash:r:melziflash.hex:i

This creates a hex file melziflash.hex of your current firmware

You should also copy the eeprom

avrdude -p atmega1284p -c avrisp -P com4 -b 19200 -U eeprom:r:melzieeprom.hex:i

You then put it back into the new board with

avrdude -p atmega1284p -c avrisp -P com4 -b 19200 -U flash:w:melziflash.hex:i
and
avrdude -p atmega1284p -c avrisp -P com4 -b 19200 -U eeprom:w:melzieeprom.hex:i

Edited 1 time(s). Last edit at 07/27/2016 04:19AM by Dust.
Re: Problem trying to program fuses on Melzi w/avrdude
July 27, 2016 09:09PM
I'm totally fed up and thinking I need to fork out the $100 reprap wants for a Melzi.
Reading the old Melzi seamed to go great and writing to the new one seamed to go great, but now my PC won't connect to it anymore.
Any ideas?
From tired Daveconfused smiley
Re: Problem trying to program fuses on Melzi w/avrdude
July 29, 2016 04:22AM
that should work, if it was the same board... and processor

You only have one choice now (other than throwing money at it)

First check you can still upload new firmware without the UNO, just using the ardunio IDE
ie compile and upload the example blink (it probably wont blink, but your just testing that you can uploading to your board over the usb)

If that works, just start with a new copy of marlin, and go threw one of the many tutorial on how to configure it.

Any chance your machine provider provided firmware in particular a configuration.h ? As that would help a lot.
Re: Problem trying to program fuses on Melzi w/avrdude
August 02, 2016 01:21PM
Just an update.
I've been trying to get my Arduino software setup and had many problems, like Sanguino not showing up under tools, searched and searched, then OMG wow Dust to the rescue again, the guy is blow away awesome!

http://dustsreprap.blogspot.co.nz/2015/06/better-way-to-install-sanguino-in.html
Re: Problem trying to program fuses on Melzi w/avrdude
August 02, 2016 01:49PM
Just tried uploading Blink to Melzi.
The Melzi LED is red not Green.
Upload gives error: avrdude: ser_open() : can't open device "\\.\com5": Access is denied.
Com5 is the USB it's attached to, or assigned to rather.
I also searched the net and people suggest it could be a driver issue, so I tried to update the drive by pointing to the Arduino drivers folder and it said that windows says the driver is up to date

Edited 1 time(s). Last edit at 08/02/2016 02:01PM by virgodave61.
Re: Problem trying to program fuses on Melzi w/avrdude
August 02, 2016 02:17PM
Dah, guess I had a blonde moment, checked and noticed I had the wrong processor selected, so now I'm uploading and it seams to be hung up with error messages "not in sync" "can't communicate with device: resp-0x1e"
I can't post the actual errors because its hung up and doesn't give the copy errors button.
Bootloader bad? Get the uno out again?

Edited 1 time(s). Last edit at 08/02/2016 02:47PM by virgodave61.
Re: Problem trying to program fuses on Melzi w/avrdude
August 02, 2016 05:46PM
You have a boards.txt that has all Sanguino definitions including the boot loader, this defines the baud rate and protocol that the boot loader uses

Sadly there are many different boot loaders and your configuration has to match the installed boot loader

There is no way to determine what the requirements of your boot loader are (presuming one is installed)
Other than trial and error

I tend to try a few baud rates then give up and install a new boot loader that you know the baud rate and protocol on.
The main one I try is older boot loaders used 38400 baud while newer boot loaders seem to favor 57600

Nb remember to restart the arduino IDE after each edit of the boards.txt file, or it simply doesn't notice its been changed.
Re: Problem trying to program fuses on Melzi w/avrdude
August 07, 2016 03:47PM
I checked the boarts.txt file and set fuses as above and noted the baud was set at 57600, then restarted the Arduino IDE then when I try to upload the bootloader I get an error:

Arduino: 1.6.8 (Windows 7), Board: "Sanguino, ATmega1284 or ATmega1284P (16 MHz)"

avrdude: Error: Could not find USBtiny device (0x2341/0x49)
Error while burning bootloader.

I checked my connections and everything seams ok, whats up with this?
Dave
Re: Problem trying to program fuses on Melzi w/avrdude
August 07, 2016 05:46PM
You don't have a usbtiny, you have a avrisp
Re: Problem trying to program fuses on Melzi w/avrdude
August 08, 2016 01:27AM
I know this but the Ardrunio IDE is looking for usbtiny, its not my doing its the IDE what do I do?
I do haver Arduino ISP selected in the tools menu.

Edited 1 time(s). Last edit at 08/08/2016 05:46AM by virgodave61.
Re: Problem trying to program fuses on Melzi w/avrdude
August 08, 2016 06:42AM
himm might be a bug in ardunio

find the programmers.txt file

find the line protocol=usbtiny in the usbtiny section
change it to protocol=arduinoisp

restart the ardunio ide

This will force it to talk the correct protocol even when it decides to try and use the wrong programmer.
Re: Problem trying to program fuses on Melzi w/avrdude
August 09, 2016 07:04PM
Thanks again Dust I'm confused on how to edit this.

# See: [code.google.com]

avrisp.name=AVR ISP
avrisp.communication=serial
avrisp.protocol=stk500v1

avrispmkii.name=AVRISP mkII
avrispmkii.communication=usb
avrispmkii.protocol=stk500v2

usbtinyisp.name=USBtinyISP
usbtinyisp.protocol=usbtiny

usbasp.name=USBasp
usbasp.communication=usb
usbasp.protocol=usbasp

parallel.name=Parallel Programmer
parallel.protocol=dapa
parallel.force=true
# parallel.delay=200

arduinoisp.name=Arduino as ISP
arduinoisp.communication=serial
arduinoisp.protocol=stk500v1
arduinoisp.speed=19200

avrispv2.name=AVR ISP v2
avrispv2.communication=serial
avrispv2.protocol=avrispv2
Re: Problem trying to program fuses on Melzi w/avrdude
August 10, 2016 12:20AM
change

usbtinyisp.name=USBtinyISP
usbtinyisp.protocol=usbtiny

to

usbtinyisp.name=USBtinyISP
usbtinyisp.communication=serial
usbtinyisp.protocol=stk500v1


darn those captcha's are long!, and hard to read ... bet the computer can read it easier than I can!
Re: Problem trying to program fuses on Melzi w/avrdude
August 12, 2016 12:08AM
I edited the file and restarted the IDE and had the same error as before.

Then I went to my tools menu and changed "ArduinoISP" to "Arduino as ISP", then tried again and it said the boot loader loaded successfully.
Then I noticed the LED on the Melzi was no longer coming on, then I also noticed that I failed to set the reset jumper on the Melzi properly, before I did it.
Then I had to go to work.
I will update when I'm awake long enough to try some more, if you have any comments on which direction to take this I'd appreciate it.
Thanks again Dust! Your help has been priceless!
Dave
Re: Problem trying to program fuses on Melzi w/avrdude
August 12, 2016 01:23AM
I tried uploading the boot loader again with the reset jumper on and it said it was successful.
Still no light on Melzi.
Then tried to connect with pronterface (with the correct baud rate in file) and my computer was totally locked up.
Next I guess I will try to load blink to it with USB and see what happens, when I have more waking time.
Dave
Re: Problem trying to program fuses on Melzi w/avrdude
August 19, 2016 11:29PM
I tried uploading blink to the Melzi using the USB port and it said that uploading completed.
So I assume the bootloader is ok.
Next I will try uploading the firmware.
Re: Problem trying to program fuses on Melzi w/avrdude
August 19, 2016 11:45PM
I tried uploading the firmware and have the error:

Arduino: 1.6.8 (Windows 7), Board: "Sanguino, ATmega1284 or ATmega1284P (16 MHz)"

Marlin:590: error: declaration of C function 'bool code_seen(char)' conflicts with

bool code_seen(char code)

^

Marlin:585: error: previous declaration 'bool code_seen(char*)' here

bool code_seen(char code_string[]) //Return True if the string was found

^

exit status 1
declaration of C function 'bool code_seen(char)' conflicts with
Re: Problem trying to program fuses on Melzi w/avrdude
August 20, 2016 12:33AM
I tried uploading the Melzi test program found here:

http://reprap.org/wiki/RepRapPro_Mendel_maintenance

And the upload worked and the LED started flashing.

Any ideas whats going on?

Dave
Re: Problem trying to program fuses on Melzi w/avrdude
August 20, 2016 03:04AM
The "upload" is actually more than just uploading, it also compiles the C code (structured txt) into assembly (bytes) that can be understood by the controller. This is then uploaded after it compiles without serious errors.

The above error is a compile error

Its saying that the code defines function bool code_seen(char code) at line 590
but the function has already been defined as bool code_seen(char*) at line 585

The latter expects a string while the former expects a single character parameter, you can't have both (not like this anyways)

Where did you download marlin from? as it looks to be broken

I would also get a newer Arduino, 1.6.8 had some weird bugs...

Edited 1 time(s). Last edit at 08/20/2016 03:08AM by Dust.
Re: Problem trying to program fuses on Melzi w/avrdude
August 20, 2016 05:09AM
Thanks again Dust II will get a new IDE and a different firmware and try that.
I don't remember where I got it.
Dave
Re: Problem trying to program fuses on Melzi w/avrdude
August 20, 2016 05:28AM
I downloaded the firmware from:
github.com/reprappro/Marlin/tree/master
What is the correct site to get it from?
What about Repetier firmware?
Dave

Edited 2 time(s). Last edit at 08/20/2016 05:42AM by virgodave61.
Re: Problem trying to program fuses on Melzi w/avrdude
August 20, 2016 05:33AM
If marlin doesn’t come from here [github.com] then its not maintained by the authors, so its not official and I would stay away from those versions.
Re: Problem trying to program fuses on Melzi w/avrdude
August 20, 2016 05:48AM
Great, I will try to get all this done after work tonight and see what happens.
Dave
Sorry, only registered users may post in this forum.

Click here to login