Open GoogleCodeExporter opened 9 years ago
I don't know if you CAN do the burn in one step. the current process changes
the fuses, burns the bootloader, and then changes the fuses again (just the
lock bits?)
Does AVRDUDE preserve the ordering of program memory commands? (note that the
makefile in the bootloader source directory uses the same process.)
Original comment by wes...@gmail.com
on 23 Sep 2011 at 1:29
According to the avrdude usage message:
-U <memtype>:r|w|v:<filename>[:format]
Memory operation specification.
Multiple -U options are allowed, each request
is performed in the order specified.
While I can't be sure if the initial lock fuse value was written as well
as the final lock fuse value vs just the last one, but does it really matter?
-e should reset all the lock bits so isn't writing a value of 0x3f a NOP?
(upper 2 bits are ignored for atmega328p)
And then it is the final lock bits value that matters.
I see a value of FE reported for the final lock bits by the fusebytes sketch
(0x2e as reported by the dragon)
whether I use the two separate avrdude commands with a delay of a few seconds
between
them or if it is run as single avrdude command as in the attached makefile
above.
OR whether I use the -U lock:w:0x3f:m in the initial fuse setting or leave it
out
completely with either two commands or the single command.
Why set the lock bits in two steps?
Especially when the initial setting is the same as using the -e option which
is being used.
Is there some kind of workaround for some devices in play here?
Original comment by bperry...@gmail.com
on 23 Sep 2011 at 3:48
Ok so I have verified that if multiple fuse/lock updates are requested that
avrdude will process all of them in the order they are requested.
So for example:
avrdude -c dragon_isp -P usb -p atmega328p -e -u -U lock:w:0x3f:m -U
lock:w:0x2f:m
will work where:
avrdude -c dragon_isp -P usb -p atmega328p -e -u -U lock:w:0x2f:m -U
lock:w:0x3f:m
will fail because you can't unclear bits.
But I am still wondering why do the initial lock bits set to 0x3f ?
Original comment by bperry...@gmail.com
on 23 Sep 2011 at 8:19
Hi,
I can confirm your problem also exists with version : arduino-1.0-RC1 (Ubuntu
11.04)
I did some testing and as a workaround raising the timeout between the two
avrdude commands from 1 to 2 seconds solved the problem for the time being.
But you are right, burning the bootloader can be done in a single call to
avrdude.
At least it works with the AVR-Dragon and the AVRIspMKII.
Attached a file that shows the single call upload command that works on my
machine.
Eberhard
Original comment by e.fa...@wayoda.org
on 23 Sep 2011 at 3:24
Attachments:
The file from mthe previous comment I made was for testing the AVRispmkII.
For the dragon the programmer has to be specified as '-cdragon_isp'
Eberhard
PLEASE !!!!!
Move this issues list over to github where we can EDIT comments, and don't have
to write a new one all the time.
Original comment by e.fa...@wayoda.org
on 23 Sep 2011 at 3:32
Yes that is essentially doing the same thing as the modified optiboot Makefile
attachment I attached in the initial post.
I also have an updated atmega makefile as I have a tested one of those as well
but to recompile the atmega bootloader, the atmega bootloader code itself
also needs a small patch to compile with latest
gcc tools. - which I also have.
================================================================================
==
As mentioned in the first post, there are essentially 3 options that can be
used to work around this issue:
1) update the Makefiles & Java IDE code to do blind sleeps between the two
commands
2) update the Makefiles & Java IDE code to do a single command vs two commands.
3) update the avrdude code to poll for the USB devices.
All of them work (at least with Dragon on Ubuntu) and are very small
modifications.
One thing I didn't realize is that the Arduino IDE for linux already ships its
own avrdude
and does not use the avrdude on the system. I had to overwrite the Arduino
version
of avrdude in {installdir}hardware/tools
So given Arduino already ships its own avrdude, it might be an option
to ship a patched avrdude that eliminates the back to back problem.
(It is only 7 lines of code to add this functionality)
================================================================================
===
Here is more background information from an arduino optiboot thread that I am
duplicating here for completeness (trying to keep all the information here)
I tracked things down further and found that avrdude is using the libusb 0.1
API vs the current
1.0 API. It is using a 0.1 to 1.0 mapping layer. The older API isn't an issue,
the real gotchya is that libusb uses usbfs and makes ioctl calls into it.
The linux usbfs documentation says that there are kernel issues
with the usb reset ioctl and recommends not using it since the device state is
not restored.
They do however return a status indicating this and
the libusb documentation recommends re-scanning for your device if you get this
particular error status.
The issue is that when an application disconnects from the USB device, the
device is unavailable
until it re-enumerates.
As far as this being solved in libusb, it is kind of tough because the
application running
has no knowledge of this interrium state created by a previous application
and you don't really want hold up the previous
applications device close and termination on the happenstance that another
application will need to talk
to the same device.
My guess is that the libusb guys will say that there are still outstanding
kernel issues in usbfs
related to usb_reset() and that there is enough status information and enough
existing API calls to
poll for the device at the application layer
if you want/need a more robust solution because the polling really needs to be
handled
on the front end device open and device scan - which is under control of the
application
not libusb.
So that would push any solution back into avrdude or even higher into
the IDE or Makefiles.
Original comment by bperry...@gmail.com
on 23 Sep 2011 at 6:40
Original issue reported on code.google.com by
bperry...@gmail.com
on 22 Sep 2011 at 8:33Attachments: