Updated patch for Linux sysfs GPIO programmer type

classic Classic list List threaded Threaded
25 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Updated patch for Linux sysfs GPIO programmer type

Radoslav Kolev-3
Hi Joerg,

I've been meaning to update the the GPIO programmer patch for some
time now, but in the end Richard Nauber beat me to it and fixed it to
apply cleanly to the current SVN.

I have made some changes to the updated version, like renaming the
programmer type from gpio to linuxgpio, so it's clear it's Linux
specific. Also, I've included the changes to the documentation (man
page, info page and NEWS file) as you requested some time ago.

Please, have a look at the attached preliminary version and let me
know if it fits the requirements to be included in the official
avrdude release. If there's anything which needs to be changed just
let me know.

I'll wait for your feedback, and do some testing and possibly minor cleanups.

After I have the final version of the patch I'll upload it to the
patch tracker and hopefully you can apply it to the current SVN.

Best regards,
Radoslav

_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev

avrdude-linuxgpio-preview.patch (20K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Updated patch for Linux sysfs GPIO programmer type

Joerg Wunsch
Hi Radoslav,

> I have made some changes to the updated version, like renaming the
> programmer type from gpio to linuxgpio, so it's clear it's Linux
> specific.

This is a really good idea!

> Also, I've included the changes to the documentation (man
> page, info page and NEWS file) as you requested some time ago.

That's fine, yes.  (Please avoid putting unrelated changes into a
patch though.  I've rather fixed the small typo separately.)

> Please, have a look at the attached preliminary version and let me
> know if it fits the requirements to be included in the official
> avrdude release.

From an eyeball-review, it looks mostly good, thanks!

Two minor remarks:

. Better use 2013 as the copyright year for new files ;), and there's
  no need to attribute new files (like the header file) to Brian Dean
  rather than yourself (or any actual contributors).

. I'd prefer to reverse the autoconf logic for the enable option, so
  it is disabled by default.  The feature is only useful for a small
  subset of AVRDUDE users anyway, and all those who are candidate
  users of it are likely to compile their own version from sources
  anyway, so they can manually enable it without problems.

  If you don't want this for some reason, add more autoconf hacks to
  detect whether the environment is actually linuxgpio-ready.  As it
  is now, the feature would be enabled by default, thus breaking
  compilation for non-Linux systems, and adding unusable bloat into
  the resulting binary even for most normal PC-Linux users.

--
cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)

_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

Re: Updated patch for Linux sysfs GPIO programmer type

Peter Korsgaard
>>>>> "Joerg" == Joerg Wunsch <[hidden email]> writes:

Hi,

 Joerg>   If you don't want this for some reason, add more autoconf hacks to
 Joerg>   detect whether the environment is actually linuxgpio-ready.  As it
 Joerg>   is now, the feature would be enabled by default, thus breaking
 Joerg>   compilation for non-Linux systems, and adding unusable bloat into
 Joerg>   the resulting binary even for most normal PC-Linux users.

Why would it break compilation? It is just simple posix I/O. It would
have to be disabled on Windows naturally.

--
Bye, Peter Korsgaard

_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

Re: Updated patch for Linux sysfs GPIO programmer type

Peter Korsgaard
In reply to this post by Radoslav Kolev-3
>>>>> "Radoslav" == Radoslav Kolev <[hidden email]> writes:

 Radoslav> Hi Joerg,

 Radoslav> I've been meaning to update the the GPIO programmer patch for
 Radoslav> some time now, but in the end Richard Nauber beat me to it
 Radoslav> and fixed it to apply cleanly to the current SVN.

 Radoslav> I have made some changes to the updated version, like renaming the
 Radoslav> programmer type from gpio to linuxgpio, so it's clear it's Linux
 Radoslav> specific. Also, I've included the changes to the documentation (man
 Radoslav> page, info page and NEWS file) as you requested some time ago.

 Radoslav> Please, have a look at the attached preliminary version and let me
 Radoslav> know if it fits the requirements to be included in the official
 Radoslav> avrdude release. If there's anything which needs to be changed just
 Radoslav> let me know.

Thanks, looks fairly good. Notice that the URL you mention doesn't work:

+the 74HC244. Have a look at http://kolev.info/avrdude-linuxgpio for a more
+detailed tutorial about using this programmer type.

--
Bye, Peter Korsgaard

_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

Re: Updated patch for Linux sysfs GPIO programmer type

Joerg Wunsch
In reply to this post by Peter Korsgaard
As Peter Korsgaard wrote:

> Why would it break compilation? It is just simple posix I/O.

OK, I didn't look too close. ;-)  You're right.

> It would
> have to be disabled on Windows naturally.

Correct.  But nevertheless, it's useless code for 99.9 % of the
AVRDUDE users, so why enable it by default?
--
cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)

_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

Re: Updated patch for Linux sysfs GPIO programmer type

Peter Korsgaard
>>>>> "Joerg" == Joerg Wunsch <[hidden email]> writes:

 >> Why would it break compilation? It is just simple posix I/O.

 Joerg> OK, I didn't look too close. ;-)  You're right.

;)

 Joerg> Correct.  But nevertheless, it's useless code for 99.9 % of the
 Joerg> AVRDUDE users, so why enable it by default?

Agreed. I'm fine with it being disabled by default.

--
Bye, Peter Korsgaard

_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

Re: Updated patch for Linux sysfs GPIO programmer type

Radoslav Kolev-3
In reply to this post by Joerg Wunsch
On Wed, Jan 2, 2013 at 10:39 PM, Joerg Wunsch <[hidden email]> wrote:
>> Also, I've included the changes to the documentation (man
>> page, info page and NEWS file) as you requested some time ago.
>
> That's fine, yes.  (Please avoid putting unrelated changes into a
> patch though.  I've rather fixed the small typo separately.)

OK, agreed.

>> Please, have a look at the attached preliminary version and let me
>> know if it fits the requirements to be included in the official
>> avrdude release.
>
> From an eyeball-review, it looks mostly good, thanks!
>
> Two minor remarks:
>
> . Better use 2013 as the copyright year for new files ;), and there's
>   no need to attribute new files (like the header file) to Brian Dean
>   rather than yourself (or any actual contributors).

I have fixed these.

> . I'd prefer to reverse the autoconf logic for the enable option, so
>   it is disabled by default.  The feature is only useful for a small
>   subset of AVRDUDE users anyway, and all those who are candidate
>   users of it are likely to compile their own version from sources
>   anyway, so they can manually enable it without problems.

Actually, I had changed it to disabled by default a long time ago, but
had forgotten to update the description and it still said (default),
it's fixed now.

Before sending a final revised version of the patch I have some questions.

First, the patch increases the maximum pin number in config_gram.y to
255, since it's normal for modern SoCs to have a large number of
GPIOs. Just wanted to point it out in case you've missed it and would
prefer this as a separate patch/change, since it's not directly
related to the new programmer type.

The second thing also concerns pin numbers. As far as my understanding
goes, if a pin is not specified in a certain programmer entry in the
configuration file it will default to 0, which means not
available/used by this programmer. The problem is that GPIO numbering
in Linux starts from zero, so it's actually a valid value. To work
around this now the pin numbers specified in the config file are
actually off by one. For example if you mean GPIO5 (from the point of
view of Linux's sysfs interface) in avrdude.conf you have to put 6 as
the value.

That's kind of annoying and I would like to fix it somehow. Ideally,
if the default not assigned pin value was -1 and not 0 that would
solve it, but I have no idea how this will influence the rest of the
code. Another way would be to just assume that miso, mosi, reset and
sck pins are set in the config file and use their value, even if it's
zero. If any of those pins is not assigned there isn't much chance
programming will work anyway, but I didn't see an easy way to make
these parameters required just for a single programmer type.

The other change I'm thinking of is to set all pins as inputs after
programming is finished. Currently i've copied the behaviour of the
serial bit bang programmers which is to raise RESET high. At least for
MOSI and SCK I think configuring them as inputs will be better. This
way even if there are no buffer/current limiting resistors the chances
of burning a GPIO due to overcurrent is lowered. Reset should also
normally be pulled high somewhere on the board being programmed. Now
after programming is finished the GPIO is holding the RESET line high.
But if there's a reset button on the board, which pulls it low (like
there is on Arduinos for example) and its pressed with the ISP cable
still connected then it can cause problems.

What do you recommend for the above?

Best regards,
Rado

_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

Re: Updated patch for Linux sysfs GPIO programmer type

Radoslav Kolev-3
In reply to this post by Peter Korsgaard
On Wed, Jan 2, 2013 at 11:10 PM, Peter Korsgaard <[hidden email]> wrote:
> Thanks, looks fairly good. Notice that the URL you mention doesn't work:
>
> +the 74HC244. Have a look at http://kolev.info/avrdude-linuxgpio for a more
> +detailed tutorial about using this programmer type.

By doesn't work do you mean the server's not responding or you get
some error. You should see a page saying:

 "Hello!

Here you'll soon find a tutorial and example of how to connect an AVR
microcontroller to the GPIO pins of an embedded Linux system and use
avrdude with the linuxgpio programmer type to program it."

I'm working on this while testing the patch.

Regards,
Rado

_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

Re: Updated patch for Linux sysfs GPIO programmer type

Peter Korsgaard
>>>>> "Radoslav" == Radoslav Kolev <[hidden email]> writes:

 Radoslav> On Wed, Jan 2, 2013 at 11:10 PM, Peter Korsgaard <[hidden email]> wrote:
 >> Thanks, looks fairly good. Notice that the URL you mention doesn't work:
 >>
 >> +the 74HC244. Have a look at http://kolev.info/avrdude-linuxgpio for a more
 >> +detailed tutorial about using this programmer type.

 Radoslav> By doesn't work do you mean the server's not responding or you get
 Radoslav> some error. You should see a page saying:

 Radoslav>  "Hello!

 Radoslav> Here you'll soon find a tutorial and example of how to connect an AVR
 Radoslav> microcontroller to the GPIO pins of an embedded Linux system and use
 Radoslav> avrdude with the linuxgpio programmer type to program it."

 Radoslav> I'm working on this while testing the patch.

I don't. I get:

Page not found
The requested page "/avrdude-linuxgpio" could not be found.

--
Bye, Peter Korsgaard

_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

Re: Updated patch for Linux sysfs GPIO programmer type

Hannes Weisbach-2

Am 04.01.2013 um 23:45 schrieb Peter Korsgaard:

>>>>>> "Radoslav" == Radoslav Kolev <[hidden email]> writes:
>
> Radoslav> On Wed, Jan 2, 2013 at 11:10 PM, Peter Korsgaard <[hidden email]> wrote:
>>> Thanks, looks fairly good. Notice that the URL you mention doesn't work:
>>>
>>> +the 74HC244. Have a look at http://kolev.info/avrdude-linuxgpio for a more
>>> +detailed tutorial about using this programmer type.
>
> Radoslav> By doesn't work do you mean the server's not responding or you get
> Radoslav> some error. You should see a page saying:
>
> Radoslav>  "Hello!
>
> Radoslav> Here you'll soon find a tutorial and example of how to connect an AVR
> Radoslav> microcontroller to the GPIO pins of an embedded Linux system and use
> Radoslav> avrdude with the linuxgpio programmer type to program it."
>
> Radoslav> I'm working on this while testing the patch.
>
> I don't. I get:
>
> Page not found
> The requested page "/avrdude-linuxgpio" could not be found.
It does work for me.

Best regards,
Hannes
_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

Re: Updated patch for Linux sysfs GPIO programmer type

René Liebscher
In reply to this post by Radoslav Kolev-3
Am 04.01.2013 23:37, schrieb Radoslav Kolev:

> ...
>
> Before sending a final revised version of the patch I have some questions.
>
> First, the patch increases the maximum pin number in config_gram.y to
> 255, since it's normal for modern SoCs to have a large number of
> GPIOs. Just wanted to point it out in case you've missed it and would
> prefer this as a separate patch/change, since it's not directly
> related to the new programmer type.
>
> The second thing also concerns pin numbers. As far as my understanding
> goes, if a pin is not specified in a certain programmer entry in the
> configuration file it will default to 0, which means not
> available/used by this programmer. The problem is that GPIO numbering
> in Linux starts from zero, so it's actually a valid value. To work
> around this now the pin numbers specified in the config file are
> actually off by one. For example if you mean GPIO5 (from the point of
> view of Linux's sysfs interface) in avrdude.conf you have to put 6 as
> the value.
>
> That's kind of annoying and I would like to fix it somehow. Ideally,
> if the default not assigned pin value was -1 and not 0 that would
> solve it, but I have no idea how this will influence the rest of the
> code. Another way would be to just assume that miso, mosi, reset and
> sck pins are set in the config file and use their value, even if it's
> zero. If any of those pins is not assigned there isn't much chance
> programming will work anyway, but I didn't see an easy way to make
> these parameters required just for a single programmer type.
>
You have the same behaviour for ftdi based prgrammers, where you have to
write 4 when you actually mean ADBUS3.

I would prefer a much more general approach to this problem.

You have to remember that there are not only single pins but also list
of pins are possible for vcc and buf pin definitions. And these define
their pins as 1<< pin1 | 1 << pin2 | ... . So setting the default to -1
would set there all bits if there is no definition in the conf-file.

I would like to have the pin definition as follows:

typedef struct programmer_t {
...
  unsigned int pinno[N_PINS];
...
}

changed to

typedef struct programmer_t {
...
  pin_def_t pinno[N_PINS];
...
}

with pin_def_t defined as:

#define N_MAX_PINS 32 /* or 256 if GPIO is compiled in */

struct {
    uint32_t mask   [N_MAX_PINS/32];
    uint32_t inverse[N_MAX_PINS/32];
} pin_def_t;

Then you have a single pin defined as:
mask = { 0b0001000, .... }
inverse = { 0b0000000, .... }

an inverted pin as:

mask = { 0b0001000, .... }
inverse = { 0b0001000, .... }

pin lists as:

mask = { 0b0010110, .... }
inverse = { 0b0000000, .... }

and it would even be possible to define a mixed inverted pin list as
wished in bug #37727 Add support for LM3S811 dev board as a programmer

mask = { 0b0010110, .... }
inverse = { 0b0010010, .... }

However you had to change the code for the following programmer types
avrftdi, ftdi_syncbb, par and serbb. (These are the only ones which
currently use pin definitions in the config file.)

I would also propose to change then pin numbers of ftdi based
programmers to 0 based numbers in the config file. But leave them for
parallel and serial port 1-based as they correspond to real pins at
their connectors.

> What do you recommend for the above?
>
> Best regards,
> Rado
>
Kind regards,

René Liebscher

_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

Re: Updated patch for Linux sysfs GPIO programmer type

Hannes Weisbach-2
> You have the same behaviour for ftdi based prgrammers, where you have to
> write 4 when you actually mean ADBUS3.
>
> I would prefer a much more general approach to this problem.
>
> You have to remember that there are not only single pins but also list
> of pins are possible for vcc and buf pin definitions. And these define
> their pins as 1<< pin1 | 1 << pin2 | ... . So setting the default to -1
> would set there all bits if there is no definition in the conf-file.
>
> I would like to have the pin definition as follows:
>
> typedef struct programmer_t {
> ...
>  unsigned int pinno[N_PINS];
> ...
> }
>
> changed to
>
> typedef struct programmer_t {
> ...
>  pin_def_t pinno[N_PINS];
> ...
> }
>
> with pin_def_t defined as:
>
> #define N_MAX_PINS 32 /* or 256 if GPIO is compiled in */
>
> struct {
>    uint32_t mask   [N_MAX_PINS/32];
>    uint32_t inverse[N_MAX_PINS/32];
> } pin_def_t;
>
> Then you have a single pin defined as:
> mask = { 0b0001000, .... }
> inverse = { 0b0000000, .... }
>
> an inverted pin as:
>
> mask = { 0b0001000, .... }
> inverse = { 0b0001000, .... }
>
> pin lists as:
>
> mask = { 0b0010110, .... }
> inverse = { 0b0000000, .... }
>
> and it would even be possible to define a mixed inverted pin list as
> wished in bug #37727 Add support for LM3S811 dev board as a programmer
>
> mask = { 0b0010110, .... }
> inverse = { 0b0010010, .... }
>
> However you had to change the code for the following programmer types
> avrftdi, ftdi_syncbb, par and serbb. (These are the only ones which
> currently use pin definitions in the config file.)
>
> I would also propose to change then pin numbers of ftdi based
> programmers to 0 based numbers in the config file. But leave them for
> parallel and serial port 1-based as they correspond to real pins at
> their connectors.
I think it's a good idea and would provide the necessary changes to avrftdi, if this proposal is generally accepted and you provide the definitions.

Best regards,
Hannes
_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

Re: Updated patch for Linux sysfs GPIO programmer type

Radoslav Kolev-3
In reply to this post by René Liebscher
On Sat, Jan 5, 2013 at 6:18 PM, René Liebscher <[hidden email]> wrote:
> Am 04.01.2013 23:37, schrieb Radoslav Kolev:
> However you had to change the code for the following programmer types
> avrftdi, ftdi_syncbb, par and serbb. (These are the only ones which
> currently use pin definitions in the config file.)

Sounds good René, but I'm afraid I'm quite a newbie regarding avrdude
code and I don't think I can take on working on such a big change.
I've done a little bit of a hack to remove the off by one issue for
the linuxgpio programmer. If you or anyone implements this I can fix
my code to use the proper solution.

Regards,
Rado

_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

Re: Updated patch for Linux sysfs GPIO programmer type

Radoslav Kolev-3
In reply to this post by Joerg Wunsch
On Wed, Jan 2, 2013 at 10:39 PM, Joerg Wunsch <[hidden email]> wrote:
>> Please, have a look at the attached preliminary version and let me
>> know if it fits the requirements to be included in the official
>> avrdude release.
>
> From an eyeball-review, it looks mostly good, thanks!

I'm attaching an updated version of the patch incorporating all your
suggestions. Also I've fixed the off by one pin number issue by
assuming that MISO, MOSI, SCK and RESET are always set in the config
file, even if the value is zero. I've also added some error checking
and reporting for example if the configured pin is already exported
and used for somehting else.

I'll also put in in the web based patch tracking system.

Let me know if you think it requires any further changes.

Best regards,
Radoslav

_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev

linuxgpio-v2.patch (21K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Updated patch for Linux sysfs GPIO programmer type

René Liebscher
Hi,

in linuxgpio_open() you use linuxgpio_fds[pgm->pinno[i]]. However if some
one uses an inverse pin definition, pgm->pinno[i] has PIN_INVERSE set, which
is definitely out of bounds of your array.

Something similar can be found in linuxgpio_close with
linuxgpio_fds[pgm->pinno[PIN_AVR_RESET]].

In linuxgpio_export/unexport/dir/openfd you should use PIN_MASK.


I do not like the idea to have the "linuxgpio" entry in avrdude.conf. Almost
everyone who wants to use linuxgpio will probably have another configuration
of pins. I think it would be better to put a general template in the
documentation (or maybe also as comment in avrdude.conf).

This template could be look as follows:
--------------------------
# This programmer bitbangs GPIO lines using the Linux sysfs GPIO interface
#
# Set the configuration below to match the GPIO lines connected to the
# relevant ISP header pin. (pin number N corresponds to gpioN)
#
# Put it in a separate file <your name>.conf, to use it add this file
# with -C+<your name>.conf to the command line.
#
# If the Linux sysfs GPIO interface is compiled in, can be checked by
# -c?type on the command line (look for linuxgpio there)

programmer
  id    = "<your name>";
  desc  = "<your description>";
  type  = "linuxgpio";
  reset = ?;
  sck   = ?;
  mosi  = ?;
  miso  = ?;  
;
--------------------------------------------

If there is a special widely used combination of an embedded board with an
avr connected, then one could add for it a specific entry to avrdude.conf.


Kind regards

René

-----Ursprüngliche Nachricht-----
Von: avrdude-dev-bounces+r.liebscher=[hidden email]
[mailto:avrdude-dev-bounces+r.liebscher=[hidden email]] Im Auftrag von
Radoslav Kolev
Gesendet: Dienstag, 8. Januar 2013 17:31
An: Joerg Wunsch
Cc: [hidden email]
Betreff: Re: [avrdude-dev] Updated patch for Linux sysfs GPIO programmer
type

On Wed, Jan 2, 2013 at 10:39 PM, Joerg Wunsch <[hidden email]> wrote:
>> Please, have a look at the attached preliminary version and let me
>> know if it fits the requirements to be included in the official
>> avrdude release.
>
> From an eyeball-review, it looks mostly good, thanks!

I'm attaching an updated version of the patch incorporating all your
suggestions. Also I've fixed the off by one pin number issue by
assuming that MISO, MOSI, SCK and RESET are always set in the config
file, even if the value is zero. I've also added some error checking
and reporting for example if the configured pin is already exported
and used for somehting else.

I'll also put in in the web based patch tracking system.

Let me know if you think it requires any further changes.

Best regards,
Radoslav


_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

Re: Updated patch for Linux sysfs GPIO programmer type

Radoslav Kolev-3
Hi René, and thanks for the feedback!

On Tue, Jan 8, 2013 at 10:35 PM, René Liebscher <[hidden email]> wrote:
> In linuxgpio_export/unexport/dir/openfd you should use PIN_MASK.

I'm attaching a revised version where I mask the inverse bit before
using the pin number as parameter to the above functions. I haven't
tested this yet as I don't have the hardware with me right now, but
please have a quick glance and let me know if you see some other
obvious issue.

> I do not like the idea to have the "linuxgpio" entry in avrdude.conf. Almost
> everyone who wants to use linuxgpio will probably have another configuration
> of pins. I think it would be better to put a general template in the
> documentation (or maybe also as comment in avrdude.conf).

You're right. In the updated patch version attached I have used your
suggestion to comment out the entry in the default config file but
changed the wording a bit.

> If there is a special widely used combination of an embedded board with an
> avr connected, then one could add for it a specific entry to avrdude.conf.

For the moment I don't see such popular configuration to include.

Best regards,
Rado

_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev

linuxgpio-v3.patch (22K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Updated patch for Linux sysfs GPIO programmer type

Radoslav Kolev-3
On Tue, Jan 8, 2013 at 11:46 PM, René Liebscher <[hidden email]> wrote:
> Hi,
>
> I really meant to use -c?type at the command line. -c? lists all programmers
> as defined in the config files, -c?type lists all possible values for the
> type field.

Done.

> Also as the linuxgpio entry is now only a comment in avrdude.conf we also
> can remove the @HAVE_LINUXGPIO_BEGIN@ and @HAVE_LINUXGPIO_END@. So even if
> it is not compiled in, it can be found in the config file a hint how to do
> it.

Done.

> Everything else seems to be OK.

I tested it again on the hardware aftert the changes - still works.
Fine attached the updated patch version.

_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev

linuxgpio-v4.patch (22K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Updated patch for Linux sysfs GPIO programmer type

Radoslav Kolev-3
Thanks for committing this René!

I have tested once again starting from a clean SVN checkout. I have
also finished the more detailed write up and you can have a look at
http://kolev.info/avrdude-linuxgpio any corrections/suggestions for
improvement are welcome.

Thanks everyone for the feedback and help!

Best regards,
Rado

On Wed, Jan 9, 2013 at 1:35 PM, Radoslav Kolev <[hidden email]> wrote:

> On Tue, Jan 8, 2013 at 11:46 PM, René Liebscher <[hidden email]> wrote:
>> Hi,
>>
>> I really meant to use -c?type at the command line. -c? lists all programmers
>> as defined in the config files, -c?type lists all possible values for the
>> type field.
>
> Done.
>
>> Also as the linuxgpio entry is now only a comment in avrdude.conf we also
>> can remove the @HAVE_LINUXGPIO_BEGIN@ and @HAVE_LINUXGPIO_END@. So even if
>> it is not compiled in, it can be found in the config file a hint how to do
>> it.
>
> Done.
>
>> Everything else seems to be OK.
>
> I tested it again on the hardware aftert the changes - still works.
> Fine attached the updated patch version.

_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
Reply | Threaded
Open this post in threaded view
|

Re: Updated patch for Linux sysfs GPIO programmer type

René Liebscher
In reply to this post by Hannes Weisbach-2
Hi,

I have here now a patch which introduces the new pin definition format
into the programmer structure.

At the moment the config parser writes the new definitions and all
bitbanging programmers call in their initpgm
function a function which creates the corresponding values in the old
pinno elements of the programmers structure.

So all existing code should run as usual and we can start to convert one
programmer after another. If it uses the new format, we can remove then
the call to the converter function, and if the last programmer removed
it, we can also remove the old data field.

May be you want have a look in the patch if there are any obvious
problems. Otherwise I will check in it the next days.

I think all changes should be done before releasing version 6 as we have
changed already the config file format. When changing now the pin
numbers for some programmers from 1-based to 0-based this will result in
nobody having an old version 5 config file lying around which would be
parsed without the need to manually correcting it. (Also the new
programmers which would be 0-based (avrftdi,ftdi_syncbb,linuxgpio) would
all be new in version 6.)


Kind regards

René Liebscher


On 05.01.2013 17:35, Hannes Weisbach wrote:

>> You have the same behaviour for ftdi based prgrammers, where you have to
>> write 4 when you actually mean ADBUS3.
>>
>> I would prefer a much more general approach to this problem.
>>
>> You have to remember that there are not only single pins but also list
>> of pins are possible for vcc and buf pin definitions. And these define
>> their pins as 1<< pin1 | 1 << pin2 | ... . So setting the default to -1
>> would set there all bits if there is no definition in the conf-file.
>>
>> I would like to have the pin definition as follows:
>>
>> typedef struct programmer_t {
>> ...
>>   unsigned int pinno[N_PINS];
>> ...
>> }
>>
>> changed to
>>
>> typedef struct programmer_t {
>> ...
>>   pin_def_t pinno[N_PINS];
>> ...
>> }
>>
>> with pin_def_t defined as:
>>
>> #define N_MAX_PINS 32 /* or 256 if GPIO is compiled in */
>>
>> struct {
>>     uint32_t mask   [N_MAX_PINS/32];
>>     uint32_t inverse[N_MAX_PINS/32];
>> } pin_def_t;
>>
>> Then you have a single pin defined as:
>> mask = { 0b0001000, .... }
>> inverse = { 0b0000000, .... }
>>
>> an inverted pin as:
>>
>> mask = { 0b0001000, .... }
>> inverse = { 0b0001000, .... }
>>
>> pin lists as:
>>
>> mask = { 0b0010110, .... }
>> inverse = { 0b0000000, .... }
>>
>> and it would even be possible to define a mixed inverted pin list as
>> wished in bug #37727 Add support for LM3S811 dev board as a programmer
>>
>> mask = { 0b0010110, .... }
>> inverse = { 0b0010010, .... }
>>
>> However you had to change the code for the following programmer types
>> avrftdi, ftdi_syncbb, par and serbb. (These are the only ones which
>> currently use pin definitions in the config file.)
>>
>> I would also propose to change then pin numbers of ftdi based
>> programmers to 0 based numbers in the config file. But leave them for
>> parallel and serial port 1-based as they correspond to real pins at
>> their connectors.
> I think it's a good idea and would provide the necessary changes to avrftdi, if this proposal is generally accepted and you provide the definitions.
>
> Best regards,
> Hannes

_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev

pins.patch (10K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

New pin definition data structure, updated ftdi_syncbb to support buff

René Liebscher
Hi,

as I already mentioned I checked in now the new pin definitions data
structures.

All existing bitbang programmer should work as before as the convert the
new data into the existing data fields. (See their initpgm functions.)

For ftdi_syncbb I use now the new format internally, so it uses now the
pin numbers 0-based. Also it should now support the buff pins and
inverted pins for all its supported pins. (This needs to be tested as my
hardware has no need for a buff pin and any inverter.) Also there are
currently more exit() in the code than I really want, but this will be
changed next.

I guess avrftdi could be adapted very easy by changing the add_pins and
set_pins functions (add_pin and set_pin might be removed). Another place
to change is the pin setup in avrftdi_open. (Maybe looking at ft245r.c
and its usage of the SET_BITS_0 macro and its check_pins function might
help. )

BTW: I don't like the fact that in avrftdi the default pins are set if
MOSI,MISO,SCK, or RESET does not fit the expectations. If some one has
really connected the pins as he describes in the config file, than we
should rather exit because of wrong connections, instead to change it by
ourself and possible destroy the connected hardware. (Maybe he could
still use synchronous bitbanging using ftdi_syncbb in this configuration.)

Also the add_pin(s) and set_pin(s) functions seem to use different
return code for errors (1 vs. -1). Maybe we should introduce some
generic defines in avrdude.h so it is really clear what the value for OK
is, what values for error (any negative number? so you can code the
reason in it?)


Kind regards

René


On 29.04.2013 20:51, René Liebscher wrote:

> Hi,
>
> I have here now a patch which introduces the new pin definition format
> into the programmer structure.
>
> At the moment the config parser writes the new definitions and all
> bitbanging programmers call in their initpgm
> function a function which creates the corresponding values in the old
> pinno elements of the programmers structure.
>
> So all existing code should run as usual and we can start to convert
> one programmer after another. If it uses the new format, we can remove
> then the call to the converter function, and if the last programmer
> removed it, we can also remove the old data field.
>
> May be you want have a look in the patch if there are any obvious
> problems. Otherwise I will check in it the next days.
>
> I think all changes should be done before releasing version 6 as we
> have changed already the config file format. When changing now the pin
> numbers for some programmers from 1-based to 0-based this will result
> in nobody having an old version 5 config file lying around which would
> be parsed without the need to manually correcting it. (Also the new
> programmers which would be 0-based (avrftdi,ftdi_syncbb,linuxgpio)
> would all be new in version 6.)
>
>
> Kind regards
>
> René Liebscher
>
>
> On 05.01.2013 17:35, Hannes Weisbach wrote:
>>> You have the same behaviour for ftdi based prgrammers, where you
>>> have to
>>> write 4 when you actually mean ADBUS3.
>>>
>>> I would prefer a much more general approach to this problem.
>>>
>>> You have to remember that there are not only single pins but also list
>>> of pins are possible for vcc and buf pin definitions. And these define
>>> their pins as 1<< pin1 | 1 << pin2 | ... . So setting the default to -1
>>> would set there all bits if there is no definition in the conf-file.
>>>
>>> I would like to have the pin definition as follows:
>>>
>>> typedef struct programmer_t {
>>> ...
>>>   unsigned int pinno[N_PINS];
>>> ...
>>> }
>>>
>>> changed to
>>>
>>> typedef struct programmer_t {
>>> ...
>>>   pin_def_t pinno[N_PINS];
>>> ...
>>> }
>>>
>>> with pin_def_t defined as:
>>>
>>> #define N_MAX_PINS 32 /* or 256 if GPIO is compiled in */
>>>
>>> struct {
>>>     uint32_t mask   [N_MAX_PINS/32];
>>>     uint32_t inverse[N_MAX_PINS/32];
>>> } pin_def_t;
>>>
>>> Then you have a single pin defined as:
>>> mask = { 0b0001000, .... }
>>> inverse = { 0b0000000, .... }
>>>
>>> an inverted pin as:
>>>
>>> mask = { 0b0001000, .... }
>>> inverse = { 0b0001000, .... }
>>>
>>> pin lists as:
>>>
>>> mask = { 0b0010110, .... }
>>> inverse = { 0b0000000, .... }
>>>
>>> and it would even be possible to define a mixed inverted pin list as
>>> wished in bug #37727 Add support for LM3S811 dev board as a programmer
>>>
>>> mask = { 0b0010110, .... }
>>> inverse = { 0b0010010, .... }
>>>
>>> However you had to change the code for the following programmer types
>>> avrftdi, ftdi_syncbb, par and serbb. (These are the only ones which
>>> currently use pin definitions in the config file.)
>>>
>>> I would also propose to change then pin numbers of ftdi based
>>> programmers to 0 based numbers in the config file. But leave them for
>>> parallel and serial port 1-based as they correspond to real pins at
>>> their connectors.
>> I think it's a good idea and would provide the necessary changes to
>> avrftdi, if this proposal is generally accepted and you provide the
>> definitions.
>>
>> Best regards,
>> Hannes
>


_______________________________________________
avrdude-dev mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/avrdude-dev
12