Broken avrdude on Linux

Go To Last Post
37 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm in the process of setting up the AVR stuff on Linux and am struggling with avrdude. The current version (5.8) is broken (segfaults) when used with a Dragon:

markus@T60:~/Downloads/avrdude/trunk/avrdude$ sudo avrdude -cdragon_isp -pt861 -Pusb -v

avrdude: Version 5.8, compiled on Jul 20 2009 at 13:58:01
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/etc/avrdude.conf"
         User configuration file is "/home/markus/.avrduderc"

         Using Port                    : usb
         Using Programmer              : dragon_isp
avrdude: usbdev_open(): Found AVRDRAGON, serno: 00A2000053CF
Segmentation fault

It looks like the problem is known since September, the bug report (#27507), even proposes a fix. But it looks like the problem is not taken care of officially (nobody assigned).

However, so I decide to compile and patch myself to get it working, but the current source (without patch) fails to compile somewhere in the yacc stuff. As I don't know yacc at all am lost here:

markus@T60:/markus-orig/avrdude/avrdude-5.8$ make
make  all-recursive
make[1]: Entering directory `/markus-orig/avrdude/avrdude-5.8'
make[2]: Entering directory `/markus-orig/avrdude/avrdude-5.8'
/bin/bash ./ylwrap config_gram.y y.tab.c config_gram.c y.tab.h config_gram.h y.output config_gram.output -- bison -y  -d
updating config_gram.h
gcc -DHAVE_CONFIG_H -I.  -DCONFIG_DIR=\"/usr/local/etc\"  -Wall -g -O2 -MT libavrdude_a-config_gram.o -MD -MP -MF .deps/libavrdude_a-config_gram.Tpo -c -o libavrdude_a-config_gram.o `test -f 'config_gram.c' || echo './'`config_gram.c
config_gram.y: In function "˜parse_cmdbits':
config_gram.y:1373: warning: "˜brkt' may be used uninitialized in this function
mv -f .deps/libavrdude_a-config_gram.Tpo .deps/libavrdude_a-config_gram.Po
/bin/bash ./ylwrap lexer.l .c lexer.c -- :  
make[2]: *** [lexer.c] Error 1
make[2]: Leaving directory `/markus-orig/avrdude/avrdude-5.8'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/markus-orig/avrdude/avrdude-5.8'
make: *** [all] Error 2

Help !

Markus

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I compile successfully on Ubuntu 9.10 with flex/bison installed instead of lex/yacc. You may want to try that.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Most Linux distro's just have symbolic links for lex and yacc that point to flex and bison anyway.

It looks like yacc (bison) is happy, +/- a warning. Nothing seems to go seriously wrong until the ylwrap call that should build the lexer, but there isn't any meaningful message in your output, so it's hard to tell.

ylwrap is a script that configure creates in order to deal with the astounding variety of lex/yacc-like tools, and their quirky command lines. I'm thinking the problem lies in there some where. Maybe the configure log will shed some light on things.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

AdamWozniak wrote:
I compile successfully on Ubuntu 9.10 with flex/bison installed instead of lex/yacc. You may want to try that.

I'm on Ubuntu 9.10 too and have bison installed, but had flex missing (not installed). The error message was because 'configure' wires a botched makefile instead complaining that flex is missing.

Still, the current avrdude is broken and requires manual patching for all Dragon users. Are there so few people with Dragons on Linux that this has such a low priority ?

Markus

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It looks like my post here has drawn attention to the problem and the fix has been added to the current avrdude codebase. Thanks Jörg !

Edit: I misinterpreted the savannah messages. There is no official fix yet, probably due to missing feedback for the proposed patch and because, while the patched avrdude works, it still terminates with an error message.

So you'll need to apply the fix from bug #27507 by hand for now.
/Edit

Still one last question: During my struggles I've fetched the latest version from SVN (svn co svn://svn.savannah.nongnu.org/avrdude/trunk .), but found that configure is missing. Is the correct procedure to fetch the latest tarball and fetch the SVN code on top ?

Markus

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you run 'bootstrap' from the SVN sources, this should generate 'configure' for you..

Regards,
Jon

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I just upgraded to 9.10 and now I get the segmentation fault with the AVR Dragon. I hope this problem can be solved soon!

Also, could someone provide a few more details about how to apply the patch listed in bug 27507?

Thanks,

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've got some fresh experience now :-)

I did have to install: (in addition to many things already there)
- bison
- flex
- libusb-devel

The you do the following stuff:
- Fetch the latest 5.8 tarball and unpack it into a directory.
- Edit the stk500v2.c file:
- - Go to line 3586
- - add stk500v2_ in front of the jtagmkII lines as shown in the bug (manual patching)
- - save and quit
- run './configure' or './configure --prefix=/' depending if you want avrdude in /usr/local or in /
- - For example the config file will be in /usr/local/etc/avrdude.conf or /etc/avrdude.conf
- - It looks like the Ubuntu packages are in / and the freaks packages in /usr/local
- run 'make'
- run 'sudo make install'
- - You can just copy 'avrdude' over your current binary manually too

That's all folks :-)

Markus

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the details. This is very helpful.

I also have to wonder is anyone else seeing this bug? It seems like it should be impacting lots of users.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, I believe it effects everyone using avrdude 5.8 with a Dragon. (Perhaps it's a good candidate to get rolled into Bingo's build scripts until the fix is upstream?)

While I say 'everyone', who knows how many Dragon users there are using Linux/avrdude, perhaps not that many - as it's been ongoing for a while?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

good candidate to get rolled into Bingo's build scripts

Just to say that the difference between the 01Dec and 17Dec versions on www.wrightflyer.co.uk/avr-gcc/ IS an avrdude fix. Hopefully Bing600 can confirm that it's the issue being discussed here?

PS the release notes say:

Quote:
Rebuild avrdude 5.8 with the PDI patch from here
https://www.avrfreaks.net/index.p...

Last Edited: Wed. Jan 6, 2010 - 01:40 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

When I was looking early this week there were two bugs open against this (now down to one as one is removed as duplicate). The earlier bug dates back to September. Nobody seems to be assigned to look into it, so I doubt it is getting fixed fast.

The proposed patch, while fixing the problem, causes an error message on exit and should be improved. It looks to me like the person who knows avrdude well enough to create a good fix is out since September and nobody else has mustered courage to tackle it.

I would prefer the patch to be added to the code, even if this error message is popping up. The error message is a cosmetic problem, but without the patch avrdude is broken and unusable for the linux&dragon users.

Markus

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

It looks to me like the person who knows avrdude well enough to create a good fix is out since September and nobody else has mustered courage to tackle it.

That's surely Joerg? I know he's not been in evidence so much here recently but I don't think he's been totally inactive since September either. Has anyone checked his work on Free BSD to see if anything has been posted there?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
Quote:

good candidate to get rolled into Bingo's build scripts

Just to say that the difference between the 01Dec and 17Dec versions on www.wrightflyer.co.uk/avr-gcc/ IS an avrdude fix. Hopefully Bing600 can confirm that it's the issue being discussed here?

PS the release notes say:

Quote:
Rebuild avrdude 5.8 with the PDI patch from here
https://www.avrfreaks.net/index.p...

The 17-Dec build was supposed to fix the PDI bug.
And the avrdude buils isn't taken from SVN , but from here
wget -c http://download.savannah.gnu.org...

I'm running Ubuntu 8.04 (always uses LTS) on my devel machines. And haven't seen a crash , using my homebuild "Dude".

If there is a problem with the "stock" 5.8 , i'll see what i can do.

Could someone post a direct URL to the "Bug" ?

Could someone try to build "Dude" using the above source ?

Or download the 17-Dec .deb from Cliff's site , and try on an Ubuntu 9.10

/Bingo

Ps: I have mailed Jörg

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Here's a link to the bug report http://savannah.nongnu.org/bugs/?27507

Vanilla 5.8 fails with that error for me on Fedora, and applying the patch resolves it (other that the cosmetic error message mentioned in the bug report)..

Regards,
Jon

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@jone

You all might be right ....
Me not seing the err could be that i only have used the dragon in jtag mode , not isp.

I'll cook something up :-)

/Bingo

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For starters ...

Here is a combined PDI & bug#27507 patch for avrdude 5.8

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
That's surely Joerg?

Joerg did close the duplicate bug early this week, but he did not assign it to anybody to fix. So he is certainly aware of the issue, but decided not to act.

Browsing the SVN tree it looks like there were 6 developers/contributors in total. Three of them have contributed last year. So manpower is limited and all of them have two hands only.

Markus

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

New dude 5.8 linux executable with PDI and the above bug fixed .. well the patch applied.

Please test it , and report success or failure.

/Bingo

Attachment(s): 

Last Edited: Wed. Jan 6, 2010 - 07:41 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

New buildscript with the above patches

I'll just drop it here , as the new patches aren't official yet

And Jörg has replied , that he hopes to release a new avrdude version very soon.

/Bingo

Last Edited: Sat. Jan 16, 2010 - 12:24 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

> And Jörg has replied , that he hopes to release a new avrdude version very soon.

I verified the fix was indeed the correct thing to do (it's merely been an
oversight by me to not use it that way in the first place, both Dragon_PP
and Dragon_HVSP were already correct). The fix is in SVN now.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks Jörg !

I've latest SVN revision (889). It works nicely now with my dragon on my Linux.

There is still the cosmetic bug with the error message on shutdown. More details in my upcoming bug report.

Markus

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

> There is still the cosmetic bug with the error message on shutdown.

Yes, I know :), just not completely analyzed. There are more bug and patch
tracker items sitting in the queue. But thanks for filing it anyway!

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I spend some time trying to find the problem, but walked away confused. Even when I changed the call to the jtagmkII_close() into stk500v2_close() the -vvv trace showed the jtagmkII_close() being called. It did look to me that this could be the solution, but it did not work and I'm confused why. I was lost once I'd have to look into the yacc stuff. Ouch !

Markus

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

> I was lost once I'd have to look into the yacc stuff.

Oh, if you can read BNF syntax, then you can also read yacc source
files. If you want to write just the syntax, yacc is plain BNF.
Suppose you want to parse an English sentence, and your lexical
scanner can return you just a token named WORD:

sentence: subject predicate object '.';

subject: WORD;

predicate: WORD;

object: WORD
        | /* nothing */;

Once the basic grammar has been written that way as BNF, you can
start adding C code behind each syntactical entity, in curly
braces. The C code can refer to the left-hand side of the rule
as $$, and to the right-hand side entities as $1, $2, etc.

That's all about it. ;-)

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

>> There is still the cosmetic bug with the error message on shutdown.

> Yes, I know :), just not completely analyzed.

Analyzed and fixed. See the comment in the bug tracker.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I just never had the opportunity/need to try. I'm sure it is not terribly difficult, but one needs to wrap the mind around. And the way it is used in avrdude is not trivial.

I did try to find where the routines were called to see why it called the avrispmkII_close instead of the stk200v2_close, but this is sort of hidden in the yacc-generated code. For now I don't see the forest because of the trees in there :-).

Markus

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

And I just saw you fixed it, wonderful. Thanks !

Markus

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes! Thank you! This has been plaguing me for quite some time (well, since I installed 9.10, Karmic Koala). I've been booting into an older version of Ubuntu on a thumb drive to do my programming in order to use the AVR Dragon.

I used Bingo's patch from his earlier post:
https://www.avrfreaks.net/index.p...
and compiled with a method just a bit different than Markus used.

First, unzip the patch in your working directory, then run these commands from the shell in that directory. This will patch the Ubuntu distribution files, then compile and install them:

apt-get source avrdude
cd avrdude-5.8/
patch -p0 < ../new.patch
./configure
make
sudo make install

That did it for me. Thanks!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

An even better solution is now to check out the latest version of avrdude from svn and compile that one.

The effort is about the same, but you get all the latest fixes (and Jörg was very diligent, thanks !).

$ svn co svn://svn.savannah.nongnu.org/avrdude/trunk .
$ cd avrdude
$ ./bootstrap
$ ./configure
$ ./make
$ sudo ./make install
$ avrdude -cdragon_isp -pt861 -Pusb -v

Markus

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Slightly OT:

Markus wrote:
I just never had the opportunity/need to try.

I understand that as an answer to
Jörg wrote:
Oh, if you can read BNF syntax, then you can also read yacc source
files.

If so, then you could make "Learning the basics of Bison and Flex" your next hobby project. Bison is the GNU version of YACC, a parser generator. Flex is a free "lexical analyzer generator" (not GNU, but free). Simply put, Flex helps you tokenize an input (eg for a C compiler it can tokenize the source into reserved words, identifiers, literal values etc). Bison helps you i) check the syntax (ie that the tokens are combined in a way that follows the rules of the langiage), and ii) do some of the translation (or whatever should happend as a cause of the strem of input tokens). "Syntax Directed Translation" is a central concept.

Once you have gained a basic understanding of how Bison works, your wolrd will never be the same. Even if I never had used Bison for anything serious it still would have given me plenty of insights and new views on programming. (As it turned out I was involved in using Bison for a very serious project - a "little language" for describing certain aspects, eg data sources, input control etc, for dialogues and their widgets).

You can stay off Flex if you want, for many things you can write your lexer by hand.

I consider knowing a bit about Bison, and the spinoffs of this knowledge, as one of my core competences. Kind of like knowing about regular expressions. I feel empowered in a way similar to having one or two cross-platform scripting languages (eg Perl, Python, Ruby, AWK or ...) under your belt. There is a whole class of programming problems that I need not fear thanks to Bison.

Let me know if you need Bison reading tips!

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Johan, thanks for great motivation on getting to know those beasts better. At this time I know them as part of the Unix programming environment and that they are used under many circumstances. I try to use the 'best tool for the job', but I did not come across a need for them yet. My professional programming is spent with ksh and perl and it compromises a small part of my job, usually to glue some stuff together or some automation. My only involvement with C is on the AVR, and this is hobby only.

Just immediately now I stay on the sidelines of the bison stampede, but keep in mind: If case of need its a worthwhile investment of time to learn !

Markus

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Here is a fresh build of the new avrdude 5.9 , for witch Jörg just released sources.

Grab it if you like.

I'll be updating the buildscript & .deb package during next week.

Edit: Full Toolchain , build ok. so releasing it for "beta"
Will move to sticky during the week

/Bingo

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Bingo600 wrote:
Here is a fresh build of the new avrdude 5.9 , for witch Jörg just released sources.

Grab it if you like.

I'll be updating the buildscript & .deb package during next week.

Edit: Full Toolchain , build ok. so releasing it for "beta"
Will move to sticky during the week

/Bingo

what libusb is used? Reason I ask is because I tried to compile avrdude from SVN right now but for some reason it fails to compile with USB support (seems like configure dont find libusb) even if libusb-dev is installed.

Reason I want the SVN version is because I want to try to make PDI work with MKII and I cant get your binary to work in this mode. So I want to try to tweek with the code to make it work...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

> Reason I ask is because I tried to compile avrdude from SVN right
> now but for some reason it fails to compile with USB support (seems
> like configure dont find libusb) even if libusb-dev is installed.

If the configure script does not find usb.h and libusb.a (or .so) in
the "usual places" (whatever that means to your compiler), it has to
disable USB support.

For example, I'm sourcing the following script before running
./configure on my FreeBSD:

LIBUSB=/usr/local
export CPPFLAGS="-I $(LIBUSB)/include"
export LDFLAGS="-L $(LIBUSB)/lib"

Remember to *source* it, that's done by the dot command:

. env.sh

Note that a variant of that will also help MinGW finding the library:

LIBUSB="/c/Program Files/LibUSB-Win32"
export CPPFLAGS="-I '$(LIBUSB)'/include"
export LDFLAGS="-L '$(LIBUSB)'/lib/gcc"

> Reason I want the SVN version is because I want to try to make PDI
> work with MKII and I cant get your binary to work in this mode. So I
> want to try to tweek with the code to make it work...

That ought to work. If it doesn't, please subscribe to the
avrdude-devel mailing list (at nongnu.org), and let's discuss it over
there.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

tielie wrote:

what libusb is used? Reason I ask is because I tried to compile avrdude from SVN right now but for some reason it fails to compile with USB support (seems like configure dont find libusb) even if libusb-dev is installed.

Reason I want the SVN version is because I want to try to make PDI work with MKII and I cant get your binary to work in this mode. So I want to try to tweek with the code to make it work...

If you look in pre-reqs.txt you'll see the packages i have installed on ubuntu to compile it (it was written before i got an Atmel USB device)
.

Quote:

#For usb support (dragon & Jtag MKII) , i'd suppose you need those , but i'm not sure
sudo apt-get install libusb-0.1-4 libusb-dev

/Bingo

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The lucid package (avrdude 5.10) works on ubuntu 9.10 and fixes this bug: http://packages.ubuntu.com/lucid...