Question / Idea: AVRDUDE

Hi all,

As we all know, one of the required parameters passed to AVRDUDE is
** **-p <partno>** **
, for example "-p atmega328p" to tell it what chip it's programming.

AVRDUDE checks the cpu signature bytes and reports an error if they can't be read of if they are wrong (i.e. trying to program the wrong chip).

So, my idea is, why can't AVRDUDE read the cpu signature first, then use it IN PLACE OF the -p parameter?

What I was thinking was to hack AVRDUDE to auto-select the proper cpu type, and make the "-p" parameter OPTIONAL (that is, for whatever reason that I can't imagine you wanted to override the chip type).

Thoughts or reasons why this can't work or won't work?

I'm assuming that someone here is a lot more familiar with the AVRDUDE code than I am and could think of a reason NOT to do this and save me time hacking the source.

So, ideas please...... thanks!

-- Roger

AVRDUDE checks the cpu signature bytes and reports an error if they can't be read of if they are wrong (i.e. trying to program the wrong chip).

It does that long after the compiler has built code for a specific chip.

Maybe it's communication process relies on CPU type?
I suppose that the avrdude guy has thought of that before!?

PaulS:
It does that long after the compiler has built code for a specific chip.

I'm not talking about the IDE... just AVRDUDE itself.

Well, think of the -p option as specifying what processor the code you're uploading is written/compiled for. AVRDude has no other way of figuring THAT out. Having the command-line option allows avrdude to figure out whether the code cpu and the hardware cpu match...

westfw:
Well, think of the -p option as specifying what processor the code you're uploading is written/compiled for. AVRDude has no other way of figuring THAT out. Having the command-line option allows avrdude to figure out whether the code cpu and the hardware cpu match...

AVRDUDE doesn't care what bytes I'm uploading. All it cares about is which processor it's talking to. And the only reason it even cares about that is it needs to know how much flash and eeprom the part has, what timings the part needs when being programmed, etc...

AVRDUDE certainly doesn't check the code itself to see if it's "compatible" with the processor. How could it know? What if the data is a graphics bitmap? That isn't even "code" at all.

You have to remember that I am talking about AVRDUDE ONLY. No compiler, no IDE, no Arduino stuff... but simply the program that sends bytes of data to an AVR chip.

I've been playing with it and so far I've got it working, but it's a kludge and certainly there is a better way to do it.

AVRDUDE has several different functions which iterate through the list of processors and processor specs (found in the avrdude.conf file) and returns a pointer to a struct that contains all the processor info.

My first working attempt simply reads the processor signature from the cpu, then goes through each entry of the config file until it finds a match, then returns to the start of the AVRDUDE code and "plugs in" the proper cpu name.

It does work, but my gut feeling is that it's a complicated and dirty way to do it and if I knew the code design better, I could probably make it work easily.

Looking at the clock... I've been up all night messing with this. No wonder my mind is blanked out. Gotta get some sleep......