Re: [RESOLVED] Re: timeouts on USB ISP programmer

2022-04-21 Thread Tomek CEDRO
On Thu, Apr 21, 2022 at 7:05 PM Axel Rau  wrote:
> With the trace, recorded by Joerg Wunsch (author of avrdude),
> Hans found the implementation bug in the device.
> He wrote to Joerg:
> 
> I see from the Ellisys .png's what is wrong. The device doesn't support
> resetting the data-toogle (CLEAR ENDPOINT HALT) which is a mandatory USB
> control endpoint command. So the USB stack tries a couple of times and then
> gives up and resets the device!
>
> The device is not USB.org class compliant! :-(
>
> Probably setting:
>
> sysctl hw.usb.no_cs_fail=1
>
> may help.
> 
> Indeed with this setting the device works perfectly:
> (..)
> diamex.de has been notified about the bug.
>
> Man thanks to all, who responded, especially Hans and Tomek,
> Axel

WOW! That was quite a journey! Thanks for the sysctl hint this may
come handy! :-)

I just wonder if this is the Diamex-only problem or all STK500v2
interfaces.. maybe they are just using public firmware on their own
hardware.. in that case all STK500v2 devices could be affected :-)

Hans is also my hero, I am rooting for the battle against some XHCI
controller on ARM hardware on the freebsd-usb list, man, patches are
already in the kernel :-) :-)

Have fun and take care! :-)
Tomek

-- 
CeDeROM, SQ7MHZ, http://www.tomek.cedro.info



[RESOLVED] Re: timeouts on USB ISP programmer

2022-04-21 Thread Axel Rau

Hi Hans, Tomek, all

Am 07.04.22 um 13:33 schrieb Axel Rau:

my DIAMEX-AVR-USB gets timeouts while talking to the target:
- - -


With the trace, recorded by Joerg Wunsch (author of avrdude),
Hans found the implementation bug in the device.
He wrote to Joerg:

I see from the Ellisys .png's what is wrong. The device doesn't support
resetting the data-toogle (CLEAR ENDPOINT HALT) which is a mandatory USB
control endpoint command. So the USB stack tries a couple of times and then
gives up and resets the device!

The device is not USB.org class compliant! :-(

Probably setting:

sysctl hw.usb.no_cs_fail=1

may help.

Indeed with this setting the device works perfectly:
- - -
root@home2l:/usr/local/home2l/share/brownies # avrdude -c stk500v2 \
-p t85 -P /dev/cuaU0  \
-U hfuse:w:init.t85.elf \
-U efuse:w:init.t85.elf \
-U eeprom:w:init.t85.elf \
-U flash:w:init.t85.elf

avrdude: AVR device initialized and ready to accept instructions

Reading | ## | 100% 0.00s

avrdude: Device signature = 0x1e930b (probably t85)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be 
performed

 To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "init.t85.elf"
avrdude: input file init.t85.elf auto detected as ELF
avrdude: writing hfuse (1 bytes):

Writing | ## | 100% 0.01s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against init.t85.elf:
avrdude: load data hfuse data from input file init.t85.elf:
avrdude: input file init.t85.elf auto detected as ELF
avrdude: input file init.t85.elf contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: reading input file "init.t85.elf"
avrdude: input file init.t85.elf auto detected as ELF
avrdude: writing efuse (1 bytes):

Writing | ## | 100% 0.01s

avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against init.t85.elf:
avrdude: load data efuse data from input file init.t85.elf:
avrdude: input file init.t85.elf auto detected as ELF
avrdude: input file init.t85.elf contains 1 bytes
avrdude: reading on-chip efuse data:

Reading | ## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of efuse verified
avrdude: reading input file "init.t85.elf"
avrdude: input file init.t85.elf auto detected as ELF
avrdude: writing eeprom (50 bytes):

Writing | ## | 100% 0.07s

avrdude: 50 bytes of eeprom written
avrdude: verifying eeprom memory against init.t85.elf:
avrdude: load data eeprom data from input file init.t85.elf:
avrdude: input file init.t85.elf auto detected as ELF
avrdude: input file init.t85.elf contains 50 bytes
avrdude: reading on-chip eeprom data:

Reading | ## | 100% 0.02s

avrdude: verifying ...
avrdude: 50 bytes of eeprom verified
avrdude: reading input file "init.t85.elf"
avrdude: input file init.t85.elf auto detected as ELF
avrdude: writing flash (1976 bytes):

Writing | ## | 100% 0.86s

avrdude: 1976 bytes of flash written
avrdude: verifying flash memory against init.t85.elf:
avrdude: load data flash data from input file init.t85.elf:
avrdude: input file init.t85.elf auto detected as ELF
avrdude: input file init.t85.elf contains 1976 bytes
avrdude: reading on-chip flash data:

Reading | ## | 100% 0.71s

avrdude: verifying ...
avrdude: 1976 bytes of flash verified

avrdude: safemode: Fuses OK (E:FE, H:D7, L:62)

avrdude done.  Thank you.
- - -
diamex.de has been notified about the bug.

Man thanks to all, who responded, especially Hans and Tomek,
Axel
--
PGP-Key: CDE74120  ☀  computing @ chaos claudius



Re: timeouts on USB ISP programmer

2022-04-12 Thread Tomek CEDRO
On Tue, Apr 12, 2022 at 12:25 PM Axel Rau wrote:
> Am 11.04.22 um 17:51 schrieb Tomek CEDRO:
> > If that does not work I am out of ideas, sorry, maybe opening an Issue
> > on the project github repo could help?
> >
> https://github.com/avrdudes/avrdude/issues/935

Perfect reporting :-) :-) Hope someone with greater knowledge will help :-)

Without the actual hardware this is all I can do :-)

Good luck :-)

-- 
CeDeROM, SQ7MHZ, http://www.tomek.cedro.info



Re: timeouts on USB ISP programmer

2022-04-12 Thread Axel Rau

Am 11.04.22 um 17:51 schrieb Tomek CEDRO:

If that does not work I am out of ideas, sorry, maybe opening an Issue
on the project github repo could help?


https://github.com/avrdudes/avrdude/issues/935

Axel
--
PGP-Key: CDE74120  ☀  computing @ chaos claudius



Re: timeouts on USB ISP programmer

2022-04-11 Thread Tomek CEDRO
On Mon, Apr 11, 2022 at 7:35 AM Axel Rau  wrote:
> root@home2l:~ # cat ~/.avrduderc
> default_programmer = "diamex-avr-usb";
> programmer
>  id= "diamex-avr-usb";
>  desc  = "Diamex AVR USB Programmer";
>  type  =  "stk500v2";
>  connection_type = usb;
>  usbvid = 0x16c0;
>  usbpid = 0x2a9b;
> ;
>
> root@home2l:~ # avrdude -p t85 -vvv -t
>
> avrdude: Version 6.4
>  Copyright (c) Brian Dean, http://www.bdmicro.com/
>  Copyright (c) Joerg Wunsch
>
>  System wide configuration file is "/usr/local/etc/avrdude.conf"
>  User configuration file is "/root/.avrduderc"
>
>  Using Port: usb
>  Using Programmer  : diamex-avr-usb
> avrdude: usbdev_open(): did not find any USB device "usb" (0x03eb:0x2104)

Wow, this is strange, the programmer is clearly defined with different
VID:PID than avrdude expects :-(

Maybe try full call:

avrdude -c diamex-avr-usb -P usb:/dev/cuaU0 -p t85 -vvv -t

or

avrdude -c stk500v2 -P usb:/dev/cuaU0 -p t85 -vvv -t

or

avrdude -c avrispmkII -P usb:/dev/cuaU0 -p t85 -vvv -t


If that does not work I am out of ideas, sorry, maybe opening an Issue
on the project github repo could help?

Are you sure that diamex-avr-usb is not defined anywhere else (for
instance in /usr/local/etc/avrdude.conf)? We are missing some small
important detail here :-P

What I did at some point was building avrdude port WITH_DEBUG=1 flag
to make, then it is possible to debug it, setting breakpoint at
`usbdev_open` helped me understand -P handling.. maybe that would also
help finding the issue here :-)

-- 
CeDeROM, SQ7MHZ, http://www.tomek.cedro.info



Re: timeouts on USB ISP programmer

2022-04-10 Thread Axel Rau


> Am 11.04.2022 um 01:28 schrieb Tomek CEDRO :
> 
> On Mon, Apr 11, 2022 at 1:08 AM Axel Rau  wrote:
>> Am 10.04.2022 um 23:59 schrieb Tomek CEDRO :
>>> Okay, your local `~/.avrduderc` configuration needs an update. Remove
>>> all from file and put only this:
>>> 
>>> default_programmer = "diamex-avr-usb";
>>> programmer
>>> id= "diamex-avr-usb";
>>> desc  = "Diamex AVR USB Programmer";
>>> type  =  "stk500v2";
>>> connection_type = usb;
>>> usbvid = 0x16c0;
>>> usbpid = 0x2a9b;
>>> ;
>>> 
>>> Then run:
>> avrdude -c diamex-avr-usb -p t85 -vvv -t
>> 
>> root@home2l:~ # avrdude -c diamex-avr-usb -p t85 -vvv -t
>> 
>> avrdude: Version 6.4
>> Copyright (c) Brian Dean, http://www.bdmicro.com/
>> Copyright (c) Joerg Wunsch
>> 
>> System wide configuration file is "/usr/local/etc/avrdude.conf"
>> User configuration file is "/root/.avrduderc"
>> 
>> Using Port: usb
>> Using Programmer  : diamex-avr-usb
>> avrdude: usbdev_open(): did not find any USB device "usb" (0x03eb:0x2104)
>> 
>> avrdude done.  Thank you.
>> 
>> root@home2l:~ # avrdude  -p t85 -vvv -t
>> 
>> avrdude: Version 6.4
>> Copyright (c) Brian Dean, http://www.bdmicro.com/
>> Copyright (c) Joerg Wunsch
>> 
>> System wide configuration file is "/usr/local/etc/avrdude.conf"
>> User configuration file is "/root/.avrduderc"
>> 
>> Using Port: usb
>> Using Programmer  : diamex-avr-usb
>> avrdude: usbdev_open(): did not find any USB device "usb" (0x03eb:0x2104)
>> 
>> avrdude done.  Thank you.
>> 
>> root@home2l:~ # cat ~/.avrduderc
>> default_programmer = "diamex-avr-usb";
>> programmer
>> id= "diamex-avr-usb";
>> desc  = "Diamex AVR USB Programmer";
>> type  =  "stk500v2";
>> connection_type = usb;
>> usbvid = 0x03eb;
>> usbpid = 0x2104;
>> ;
>> - - -
>> usbvid and usbpid are ignored:
>> - - -
> 
> Why do you think VID:PID is ignored?
Because it does not matter, what I put into usbvid/usbpid, the resulting error 
message is always:
- - -
avrdude: usbdev_open(): did not find any USB device "usb" (0x03eb:0x2104)
- - -
Why that 0x03eb:0x2104 in the error message?

> You have entered different
> VID:PID in the configuration than I have provided.

I provided 3 results with different usbvid/usbpid, the 1st one was your advice. 
Sorry, if I was unclear.
Again this is the variant, you provided with the result:
- - -
root@home2l:~ # cat ~/.avrduderc
default_programmer = "diamex-avr-usb";
programmer
 id= "diamex-avr-usb";
 desc  = "Diamex AVR USB Programmer";
 type  =  "stk500v2";
 connection_type = usb;
 usbvid = 0x16c0;
 usbpid = 0x2a9b;
;

root@home2l:~ # avrdude -p t85 -vvv -t

avrdude: Version 6.4
 Copyright (c) Brian Dean, http://www.bdmicro.com/
 Copyright (c) Joerg Wunsch

 System wide configuration file is "/usr/local/etc/avrdude.conf"
 User configuration file is "/root/.avrduderc"

 Using Port: usb
 Using Programmer  : diamex-avr-usb
avrdude: usbdev_open(): did not find any USB device "usb" (0x03eb:0x2104)

avrdude done.  Thank you.

> 
> default_programmer = "diamex-avr-usb";
> programmer
>  id= "diamex-avr-usb";
>  desc  = "Diamex AVR USB Programmer";
>  type  =  "stk500v2";
>  connection_type = usb;
>  usbvid = 0x16c0;
>  usbpid = 0x2a9b;
> ;
> 
> You need to provide VID:PID of Your Diamex interface that is
> VID=0x16c0 PID=0x2a9b. Your configuration contains VID=0x03eb
> PID=0x2104 this is why interface cannot be found. Please copy-paste
> exactly as provided above.
> 
> Where I know VID:PID of your interface? From previous message.
> 
> root@home2l:/ # usbconfig -d 0.4 dump_device_desc
> ugen0.4:  at usbus0, cfg=0 md=HOST spd=FULL (12Mbps)
> pwr=ON (500mA)
> 
>  bLength = 0x0012
>  bDescriptorType = 0x0001
>  bcdUSB = 0x0200
>  bDeviceClass = 0x0002  
>  bDeviceSubClass = 0x
>  bDeviceProtocol = 0x
>  bMaxPacketSize0 = 0x0040
>  idVendor = 0x16c0 <-- THIS IS USB VID
>  idProduct = 0x2a9b  <-- THIS IS USB PID
>  bcdDevice = 0x4340
>  iManufacturer = 0x0001  
>  iProduct = 0x0002  
>  iSerialNumber = 0x0003  <19331-49101-552>
>  bNumConfigurations = 0x0001


OK. Thanks for the explanation.

Axel
---
PGP-Key: CDE74120  ☀  computing @ chaos claudius



Re: timeouts on USB ISP programmer

2022-04-10 Thread Tomek CEDRO
On Mon, Apr 11, 2022 at 1:08 AM Axel Rau  wrote:
> Am 10.04.2022 um 23:59 schrieb Tomek CEDRO :
>> Okay, your local `~/.avrduderc` configuration needs an update. Remove
>> all from file and put only this:
>>
>> default_programmer = "diamex-avr-usb";
>> programmer
>>  id= "diamex-avr-usb";
>>  desc  = "Diamex AVR USB Programmer";
>>  type  =  "stk500v2";
>>  connection_type = usb;
>>  usbvid = 0x16c0;
>>  usbpid = 0x2a9b;
>> ;
>>
>> Then run:
> avrdude -c diamex-avr-usb -p t85 -vvv -t
>
> root@home2l:~ # avrdude -c diamex-avr-usb -p t85 -vvv -t
>
> avrdude: Version 6.4
>  Copyright (c) Brian Dean, http://www.bdmicro.com/
>  Copyright (c) Joerg Wunsch
>
>  System wide configuration file is "/usr/local/etc/avrdude.conf"
>  User configuration file is "/root/.avrduderc"
>
>  Using Port: usb
>  Using Programmer  : diamex-avr-usb
> avrdude: usbdev_open(): did not find any USB device "usb" (0x03eb:0x2104)
>
> avrdude done.  Thank you.
>
> root@home2l:~ # avrdude  -p t85 -vvv -t
>
> avrdude: Version 6.4
>  Copyright (c) Brian Dean, http://www.bdmicro.com/
>  Copyright (c) Joerg Wunsch
>
>  System wide configuration file is "/usr/local/etc/avrdude.conf"
>  User configuration file is "/root/.avrduderc"
>
>  Using Port: usb
>  Using Programmer  : diamex-avr-usb
> avrdude: usbdev_open(): did not find any USB device "usb" (0x03eb:0x2104)
>
> avrdude done.  Thank you.
>
> root@home2l:~ # cat ~/.avrduderc
> default_programmer = "diamex-avr-usb";
> programmer
>  id= "diamex-avr-usb";
>  desc  = "Diamex AVR USB Programmer";
>  type  =  "stk500v2";
>  connection_type = usb;
> usbvid = 0x03eb;
> usbpid = 0x2104;
> ;
> - - -
> usbvid and usbpid are ignored:
> - - -

Why do you think VID:PID is ignored? You have entered different
VID:PID in the configuration than I have provided.

default_programmer = "diamex-avr-usb";
programmer
  id= "diamex-avr-usb";
  desc  = "Diamex AVR USB Programmer";
  type  =  "stk500v2";
  connection_type = usb;
  usbvid = 0x16c0;
  usbpid = 0x2a9b;
;

You need to provide VID:PID of Your Diamex interface that is
VID=0x16c0 PID=0x2a9b. Your configuration contains VID=0x03eb
PID=0x2104 this is why interface cannot be found. Please copy-paste
exactly as provided above.

Where I know VID:PID of your interface? From previous message.

root@home2l:/ # usbconfig -d 0.4 dump_device_desc
ugen0.4:  at usbus0, cfg=0 md=HOST spd=FULL (12Mbps)
pwr=ON (500mA)

  bLength = 0x0012
  bDescriptorType = 0x0001
  bcdUSB = 0x0200
  bDeviceClass = 0x0002  
  bDeviceSubClass = 0x
  bDeviceProtocol = 0x
  bMaxPacketSize0 = 0x0040
  idVendor = 0x16c0 <-- THIS IS USB VID
  idProduct = 0x2a9b  <-- THIS IS USB PID
  bcdDevice = 0x4340
  iManufacturer = 0x0001  
  iProduct = 0x0002  
  iSerialNumber = 0x0003  <19331-49101-552>
  bNumConfigurations = 0x0001

-- 
CeDeROM, SQ7MHZ, http://www.tomek.cedro.info



Re: timeouts on USB ISP programmer

2022-04-10 Thread Axel Rau


> Am 10.04.2022 um 23:59 schrieb Tomek CEDRO :
> 
> On Sun, Apr 10, 2022 at 10:46 PM Axel Rau  wrote:
>> root@home2l:~ # avrdude -c stk500v2 -p t85 -vvv -t -P usb
>> 
>> avrdude: Version 6.4
>> Copyright (c) Brian Dean, http://www.bdmicro.com/
>> Copyright (c) Joerg Wunsch
>> 
>> System wide configuration file is "/usr/local/etc/avrdude.conf"
>> User configuration file is "/root/.avrduderc"
>> User configuration file does not exist or is not a regular file, 
>> skipping
>> 
>> Using Port: usb
>> Using Programmer  : stk500v2
>> avrdude: usbdev_open(): did not find any USB device "usb" (0x03eb:0x2104)
> 
> Okay, your local `~/.avrduderc` configuration needs an update. Remove
> all from file and put only this:
> 
> default_programmer = "diamex-avr-usb";
> programmer
>  id= "diamex-avr-usb";
>  desc  = "Diamex AVR USB Programmer";
>  type  =  "stk500v2";
>  connection_type = usb;
>  usbvid = 0x16c0;
>  usbpid = 0x2a9b;
> ;
> 
> Then run:
> 
> avrdude -c diamex-avr-usb -p t85 -vvv -t
> 
> Configuration will define a new Programmer, that is STK500v2
> compatible (not FT2232), will provide VID:PID pair, and will tell to
> use USB connection as default :-)
> 
> Because default_programmer is set to diamex-avr-usb it may not be even
> necessary to provide `-c diamex-avr-usb` just `avrdude -p t85 -t` :-)
> 

- - -
root@home2l:~ # avrdude -c diamex-avr-usb -p t85 -vvv -t

avrdude: Version 6.4
 Copyright (c) Brian Dean, http://www.bdmicro.com/
 Copyright (c) Joerg Wunsch

 System wide configuration file is "/usr/local/etc/avrdude.conf"
 User configuration file is "/root/.avrduderc"

 Using Port: usb
 Using Programmer  : diamex-avr-usb
avrdude: usbdev_open(): did not find any USB device "usb" (0x03eb:0x2104)

avrdude done.  Thank you.

root@home2l:~ # avrdude  -p t85 -vvv -t

avrdude: Version 6.4
 Copyright (c) Brian Dean, http://www.bdmicro.com/
 Copyright (c) Joerg Wunsch

 System wide configuration file is "/usr/local/etc/avrdude.conf"
 User configuration file is "/root/.avrduderc"

 Using Port: usb
 Using Programmer  : diamex-avr-usb
avrdude: usbdev_open(): did not find any USB device "usb" (0x03eb:0x2104)

avrdude done.  Thank you.

root@home2l:~ # avrdude -p t85 -vvv -t

avrdude: Version 6.4
 Copyright (c) Brian Dean, http://www.bdmicro.com/
 Copyright (c) Joerg Wunsch

 System wide configuration file is "/usr/local/etc/avrdude.conf"
 User configuration file is "/root/.avrduderc"

 Using Port: usb
 Using Programmer  : diamex-avr-usb
avrdude: usbdev_open(): did not find any USB device "usb" (0x03eb:0x2104)

avrdude done.  Thank you.

root@home2l:~ #
root@home2l:~ #
root@home2l:~ # cat ~/.avrduderc
default_programmer = "diamex-avr-usb";
programmer
 id= "diamex-avr-usb";
 desc  = "Diamex AVR USB Programmer";
 type  =  "stk500v2";
 connection_type = usb;
usbvid = 0x03eb;
usbpid = 0x2104;
;
- - -
usbvid and usbpid are ignored:
- - -
root@home2l:~ # cat ~/.avrduderc
default_programmer = "diamex-avr-usb";
programmer
 id= "diamex-avr-usb";
 desc  = "Diamex AVR USB Programmer";
 type  =  "stk500v2";
 connection_type = usb;
;

root@home2l:~ # avrdude -p t85 -vvv -t

avrdude: Version 6.4
 Copyright (c) Brian Dean, http://www.bdmicro.com/
 Copyright (c) Joerg Wunsch

 System wide configuration file is "/usr/local/etc/avrdude.conf"
 User configuration file is "/root/.avrduderc"

 Using Port: usb
 Using Programmer  : diamex-avr-usb
avrdude: usbdev_open(): did not find any USB device "usb" (0x03eb:0x2104)

avrdude done.  Thank you.
- - -

Axel
ps: All this is inside a jail, but I see no difference on the host.
devfs.rules are
- - -
[devfsrules_jail_home2l=100]
add include $devfsrules_jail
add path 'ugen*' unhide
add path 'usb/*' unhide
add path 'usbctl' unhide
add path 'cuaU*' unhide
add path 'cuau*' unhide
- - -

---
PGP-Key: CDE74120  ☀  computing @ chaos claudius



Re: timeouts on USB ISP programmer

2022-04-10 Thread Tomek CEDRO
On Sun, Apr 10, 2022 at 10:46 PM Axel Rau  wrote:
> root@home2l:~ # avrdude -c stk500v2 -p t85 -vvv -t -P usb
>
> avrdude: Version 6.4
>  Copyright (c) Brian Dean, http://www.bdmicro.com/
>  Copyright (c) Joerg Wunsch
>
>  System wide configuration file is "/usr/local/etc/avrdude.conf"
>  User configuration file is "/root/.avrduderc"
>  User configuration file does not exist or is not a regular file, 
> skipping
>
>  Using Port: usb
>  Using Programmer  : stk500v2
> avrdude: usbdev_open(): did not find any USB device "usb" (0x03eb:0x2104)

Okay, your local `~/.avrduderc` configuration needs an update. Remove
all from file and put only this:

default_programmer = "diamex-avr-usb";
programmer
  id= "diamex-avr-usb";
  desc  = "Diamex AVR USB Programmer";
  type  =  "stk500v2";
  connection_type = usb;
  usbvid = 0x16c0;
  usbpid = 0x2a9b;
;

Then run:

avrdude -c diamex-avr-usb -p t85 -vvv -t

Configuration will define a new Programmer, that is STK500v2
compatible (not FT2232), will provide VID:PID pair, and will tell to
use USB connection as default :-)

Because default_programmer is set to diamex-avr-usb it may not be even
necessary to provide `-c diamex-avr-usb` just `avrdude -p t85 -t` :-)


-- 
CeDeROM, SQ7MHZ, http://www.tomek.cedro.info



Re: timeouts on USB ISP programmer

2022-04-10 Thread Axel Rau


> Am 10.04.2022 um 22:07 schrieb Tomek CEDRO :
> 
> On Sun, Apr 10, 2022 at 6:59 PM Axel Rau  wrote:
>> root@home2l:~ # avrdude -c stk500v2 -p t85 -vvv -t
>> 
>> avrdude: Version 6.4
>> Copyright (c) Brian Dean, http://www.bdmicro.com/
>> Copyright (c) Joerg Wunsch
>> 
>> System wide configuration file is "/usr/local/etc/avrdude.conf"
>> User configuration file is "/root/.avrduderc"
>> 
>> Using Port: /dev/cuad0
>> Using Programmer  : stk500v2
>> avrdude: ser_open(): can't open device "/dev/cuad0": No such file or 
>> directory
> 
> avrdude -c stk500v2 -p 85 -vvv -t -P usb


root@home2l:~ # avrdude -c stk500v2 -p t85 -vvv -t -P usb

avrdude: Version 6.4
 Copyright (c) Brian Dean, http://www.bdmicro.com/
 Copyright (c) Joerg Wunsch

 System wide configuration file is "/usr/local/etc/avrdude.conf"
 User configuration file is "/root/.avrduderc"
 User configuration file does not exist or is not a regular file, 
skipping

 Using Port: usb
 Using Programmer  : stk500v2
avrdude: usbdev_open(): did not find any USB device "usb" (0x03eb:0x2104)

avrdude done.  Thank you.

---
PGP-Key: CDE74120  ☀  computing @ chaos claudius



Re: timeouts on USB ISP programmer

2022-04-10 Thread Tomek CEDRO
On Sun, Apr 10, 2022 at 6:59 PM Axel Rau  wrote:
> root@home2l:~ # avrdude -c stk500v2 -p t85 -vvv -t
>
> avrdude: Version 6.4
>  Copyright (c) Brian Dean, http://www.bdmicro.com/
>  Copyright (c) Joerg Wunsch
>
>  System wide configuration file is "/usr/local/etc/avrdude.conf"
>  User configuration file is "/root/.avrduderc"
>
>  Using Port: /dev/cuad0
>  Using Programmer  : stk500v2
> avrdude: ser_open(): can't open device "/dev/cuad0": No such file or directory

avrdude -c stk500v2 -p 85 -vvv -t -P usb

-- 
CeDeROM, SQ7MHZ, http://www.tomek.cedro.info



Re: timeouts on USB ISP programmer

2022-04-10 Thread Tomek CEDRO
Okay so the KT-LINK (FT2232H based) interface is ready :-)

avrdude did not forsee the buffer switch between read / write, that
would allow only one pin connection to Tiny10, but connecting with
external resistors works too ;-)

TDO --[470R]-- TPIDATA --[470]-- TDI


Example run below:



hexagon% avrdude -c ktlink -p t10 -B 100khz

avrdude: AVR device initialized and ready to accept instructions

Reading | ## | 100% 0.00s

avrdude: Device signature = 0x1e9003 (probably t10)

avrdude done.  Thank you.



hexagon% avrdude -c ktlink -p t10 -B 100khz -vvv

avrdude: Version 6.4
 Copyright (c) Brian Dean, http://www.bdmicro.com/
 Copyright (c) Joerg Wunsch

 System wide configuration file is "/usr/local/etc/avrdude.conf"
 User configuration file is "/XXX/.avrduderc"

 Using Port: usb
 Using Programmer  : ktlink
 Setting bit clk period: 10.0
I avrftdi_open(713): Using device VID:PID 0403:bbe2 and SN '(null)' on
interface A.
D write_flush(478): Setting pin direction (0x) and value (0x)
I set_frequency(210): Using frequency: 10
I set_frequency(211): Clock divisor: 0x003b
D avrftdi_check_pins_mpsse(570): Using valid mask mpsse: 0xfff8
D avrftdi_check_pins_bb(534): Using valid mask bibanging: 0x
I avrftdi_pin_setup(644): Pin direction mask: e523
I avrftdi_pin_setup(645): Pin value mask: 6400
D set_pin(243): Setting pin 15 (ACBUS15) as PGMLED: high (high active)
D write_flush(478): Setting pin direction (0xe523) and value (0xe400)
 AVR Part  : ATtiny10
 Chip Erase delay  : 0 us
 PAGEL : P00
 BS2   : P00
 RESET disposition : dedicated
 RETRY pulse   : SCK
 serial program mode   : yes
 parallel program mode : yes
 Timeout   : 0
 StabDelay : 0
 CmdexeDelay   : 0
 SyncLoops : 0
 ByteDelay : 0
 PollIndex : 0
 PollValue : 0x00
 Memory Detail :

  Block Poll   Page
   Polled
   Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages
MinW  MaxW   ReadBack
   ---  - -  -- --  --
- - -
   signature  0 0 00 no  3   16  0
0 0 0x00 0x00
  Block Poll   Page
   Polled
   Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages
MinW  MaxW   ReadBack
   ---  - -  -- --  --
- - -
   fuse   0 0 40 no  1   16  0
0 0 0x00 0x00
  Block Poll   Page
   Polled
   Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages
MinW  MaxW   ReadBack
   ---  - -  -- --  --
- - -
   calibration0 0 00 no  1   16  0
0 0 0x00 0x00
  Block Poll   Page
   Polled
   Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages
MinW  MaxW   ReadBack
   ---  - -  -- --  --
- - -
   lockbits   0 0 00 no  1   16  0
0 0 0x00 0x00
  Block Poll   Page
   Polled
   Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages
MinW  MaxW   ReadBack
   ---  - -  -- --  --
- - -
   flash  0 0   1280 no   1024   16  0
0 0 0x00 0x00

 Programmer Type : avrftdi
 Description : KT-LINK FT2232H based interface.

D set_pin(243): Setting pin 5,10,13-14 (ADBUS5, ACBUS10, ACBUS13,
ACBUS14) as BUFF: high (low active)
D write_flush(478): Setting pin direction (0xe523) and value (0x8020)
D set_pin(243): Setting pin 15 (ACBUS15) as PGMLED: low (high active)
D write_flush(478): Setting pin direction (0xe523) and value (0x0020)
I avrftdi_tpi_initialize(73): Using TPI interface
I avrftdi_tpi_initialize(83): Setting /Reset pin low
D set_pin(243): Setting pin 8 (ACBUS8) as RESET: low (high active)
D write_flush(478): Setting pin direction (0xe523) and value (0x0020)
D set_pin(243): Setting pin 0 (ADBUS0) as SCK: low (high active)
D write_flush(478): Setting pin direction (0xe523) and value (0x0020)
D set_pin(243): Setting pin 1 (ADBUS1) as MOSI: high (high 

Re: timeouts on USB ISP programmer

2022-04-10 Thread Tomek CEDRO
On Sun, Apr 10, 2022 at 12:37 PM Axel Rau  wrote:
> Am 09.04.2022 um 01:39 schrieb Tomek CEDRO :
> > Long story short:
> > * Put both dip-switches to OFF if you use external board (no VCC
> > connection required). They may stay ON if you program "bare" AVR (you
> > need to connect VCC, SW1=ON, SW2 OFF=3.3V ON=5V).
>
> My switches are always on; my MCU is in the ZIFF socket. (-:

Okay ZIF, good :-) 5V is required for programing from what I read from
datasheet.


> > * Try `avrdude -c stk500v2 -p 85 -vvv -t` and see of that connects to
> > Programmer.
>
> That’s what I did.
>
> root@home2l:/ # avrdude -c stk500v2 -p t85 -P /dev/cuau1 -t -vvv -B 250 -i 90
> . . .
> avrdude: Version 6.4
>  Copyright (c) Brian Dean, http://www.bdmicro.com/
>  Copyright (c) Joerg Wunsch
>
>  System wide configuration file is "/usr/local/etc/avrdude.conf"
>  User configuration file is "/root/.avrduderc"
>  User configuration file does not exist or is not a regular file, 
> skipping
>
>  Using Port: /dev/cuau1
>  Using Programmer  : stk500v2
>  Setting bit clk period: 250.0
>  Setting isp clock delay:  90
> avrdude: ser_recv(): programmer is not responding
> avrdude: stk500v2_ReceiveMessage(): timeout
> avrdude: ser_recv(): programmer is not responding
> avrdude: stk500v2_ReceiveMessage(): timeout
> avrdude: ser_recv(): programmer is not responding
> avrdude: stk500v2_ReceiveMessage(): timeout

Not exactly what I wrote. You used again `-P /dev/cuau1` which is
INVALID syntax. Use no `-P` at all.

STEP 1:

Get a connection to the programmer:

avrdude -c stk500v2 -p 85 -vvv -t

Nothing more. You should get a connection to the Programmer.


STEP 2:

Get Programmer talking with PC by setting serial port BAUDRATE (-b).

For that you may need to set `-b` (baudrate, not SMALL b). You can
attach serial terminal program like `minicom` and set various port
baudrates to see when you get a readable response (i.e. 9600, 57600,
115200, etc). For instance with ATtiny104XNANO I had to use `-b 9600`
parameter.

avrdude -c stk500v2 -p 85 -vvv -t -b 9600

You must end this step with working Programmer talking fine to avrdude.


STEP 3:

Set talking to AVR speed (BITCLOCK -B parameter).

If Diamex works fine with avrdude, but you cannot program AVR, you may
need to tune bitclock with `-B` (note BIG B). You can use frequency
suffix here (i.e. 40khz, 100khz). Try slower and faster speeds.

Example: avrdude -c stk500v2 -p 85 -vvv -B 100khz


That should make it. Assuming STK500V2 will use DebugWIRE ;-)


> I think, the DIAMEX is defective, I try to get another one.
> Perhaps the drivers are gone.
>
> How can I verify this?

Well this avrdude is not that easy to use as it turns out at first
steps even for me so do not worry just try until it works ;-)

It turns out my ATtiny104XNANO does not support TPI protocol so I
cannot program ATtiny10. I am writing now configuration for FT2232H
based KT-LINK. Oscilloscope is mandatory here. I guess you can verify
your Diamex with oscilloscope too.

Here is the detailed deocumentation of avrdude:
https://quantum-mirror.hu/mirrors/pub/gnusavannah/avrdude/avrdude-doc-6.4.pdf

Here is the PR for fixing the build out-of-the-box on FreeBSD:
https://github.com/avrdudes/avrdude/pull/925


-- 
CeDeROM, SQ7MHZ, http://www.tomek.cedro.info



Re: timeouts on USB ISP programmer

2022-04-10 Thread Axel Rau
There are also reports of DIAMEX devices not working on linux (in German):
https://www.mikrocontroller.net/topic/508937 

I should better try to get an original ATmel tool.
Unfortunately they no longer produce simple programmers.

A

> Am 10.04.2022 um 12:37 schrieb Axel Rau :
> 
> 
> 
>> Am 09.04.2022 um 01:39 schrieb Tomek CEDRO > >:
>> 
>> 
>> Long story short:
>> * Put both dip-switches to OFF if you use external board (no VCC
>> connection required). They may stay ON if you program "bare" AVR (you
>> need to connect VCC, SW1=ON, SW2 OFF=3.3V ON=5V).
> My switches are always on; my MCU is in the ZIFF socket. (-:
>> * Try `avrdude -c stk500v2 -p 85 -vvv -t` and see of that connects to
>> Programmer.
> That’s what I did.
> 
>> * If programmer is connected but AVR communication problems you may
>> slow down the STK500v2 bit clock with `-B` parameter or ISP clock with
>> `-i` according to [4] (i.e. `-B 250` will result in 4kHz bit clock).
>> 
>> Good luck and let us know if that works :-)
> 
> 
> root@home2l:/ #   avrdude -c stk500v2 -p t85 -P /dev/cuau1 -t -vvv -B 250 
> -i 90
> . . .
> avrdude: Version 6.4
>  Copyright (c) Brian Dean, http://www.bdmicro.com/ 
> 
>  Copyright (c) Joerg Wunsch
> 
>  System wide configuration file is "/usr/local/etc/avrdude.conf"
>  User configuration file is "/root/.avrduderc"
>  User configuration file does not exist or is not a regular file, 
> skipping
> 
>  Using Port: /dev/cuau1
>  Using Programmer  : stk500v2
>  Setting bit clk period: 250.0
>  Setting isp clock delay:  90
> avrdude: ser_recv(): programmer is not responding
> avrdude: stk500v2_ReceiveMessage(): timeout
> avrdude: ser_recv(): programmer is not responding
> avrdude: stk500v2_ReceiveMessage(): timeout
> avrdude: ser_recv(): programmer is not responding
> avrdude: stk500v2_ReceiveMessage(): timeout
> 
> I think, the DIAMEX is defective, I try to get another one.
> Perhaps the drivers are gone.
> 
> How can I verify this?
> ---
> PGP-Key: CDE74120  ☀  computing @ chaos claudius
> 

---
PGP-Key: CDE74120  ☀  computing @ chaos claudius



Re: timeouts on USB ISP programmer

2022-04-10 Thread Axel Rau


> Am 09.04.2022 um 01:39 schrieb Tomek CEDRO :
> 
> 
> Long story short:
> * Put both dip-switches to OFF if you use external board (no VCC
> connection required). They may stay ON if you program "bare" AVR (you
> need to connect VCC, SW1=ON, SW2 OFF=3.3V ON=5V).
My switches are always on; my MCU is in the ZIFF socket. (-:
> * Try `avrdude -c stk500v2 -p 85 -vvv -t` and see of that connects to
> Programmer.
That’s what I did.

> * If programmer is connected but AVR communication problems you may
> slow down the STK500v2 bit clock with `-B` parameter or ISP clock with
> `-i` according to [4] (i.e. `-B 250` will result in 4kHz bit clock).
> 
> Good luck and let us know if that works :-)


root@home2l:/ # avrdude -c stk500v2 -p t85 -P /dev/cuau1 -t -vvv -B 250 -i 90
. . .
avrdude: Version 6.4
 Copyright (c) Brian Dean, http://www.bdmicro.com/
 Copyright (c) Joerg Wunsch

 System wide configuration file is "/usr/local/etc/avrdude.conf"
 User configuration file is "/root/.avrduderc"
 User configuration file does not exist or is not a regular file, 
skipping

 Using Port: /dev/cuau1
 Using Programmer  : stk500v2
 Setting bit clk period: 250.0
 Setting isp clock delay:  90
avrdude: ser_recv(): programmer is not responding
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_recv(): programmer is not responding
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_recv(): programmer is not responding
avrdude: stk500v2_ReceiveMessage(): timeout

I think, the DIAMEX is defective, I try to get another one.
Perhaps the drivers are gone.

How can I verify this?
---
PGP-Key: CDE74120  ☀  computing @ chaos claudius



Re: timeouts on USB ISP programmer

2022-04-09 Thread Tomek CEDRO
Two importan things I have noted while reading AVR datasheets:

1. Programming voltage is 5V. Unless reset is disabled then 12V is required
on reset line. This is important if we program bare chip or chip on the
board surrounded by components (that may not be 5V tolerant).

2. There are various programming protocols and interfaces for various avr
chips. For instance Xplained416XNANO uses DebugWIRE protocol and connection
to target MCU. From ATTiny85 datasheet it also looks it uses DebugWIRE for
flashing and debug. But Xplained104XNANO uses TWI connection and protocol
(the same as ATTiny10).

I am working on using Xplained104XNANO to program ATtiny10, I have
connection to Programmer, but simple rewire does not work (yet) to
communicate with ATtiny10.

Looks like knowing datasheet details and schematics of the hardware should
not be skipped :-)

--
CeDeROM, SQ7MHZ, https://www.tomek.cedro.info


Re: timeouts on USB ISP programmer

2022-04-08 Thread Tomek CEDRO
On Fri, Apr 8, 2022 at 11:02 PM Axel Rau  wrote:
> Am 08.04.2022 um 20:39 schrieb Tomek CEDRO :
>
> Is it possible to disassemble your interface and take photos of the
> electronics inside? We need to make sure what exact chip is inside :-)
> https://www.chaos1.de/downloads/diamex_photos.tar.gz

This is not an FT2232H based device this is why libftdi could not reset it :-)

What I can see is from the photo:
1. 74HC125 Quad Buffer Line Driver [1].
2. STM32F042F6P6 ARM-Cortex-M0 MCU [2].

As stated on product website [3] this Diamex-Avr-USB supports STK500v2
and AVRISPV2 protocols. Details on internal dip switch configuration
and available functions is provided in product documentation [4].
Documentation does not mention Debug, only Flashing.

>From the default avrdude.conf we can read that AVRISPV2 programmer
also uses STK500V2 protocol. There is no VID:PID provided in STK500V2
programmer definition so there may be some autodetection mechanism
implemented.

Just try `avrdude -c stk500v2 -p 85 -vvv -t` :-)


It also matters on how you connect to the Target AVR - is it already
powered on some working board or you are connecting to a "bare" AVR?
Also what is the Target i85 or t861?

>From the configuration of your dip switches it looks like you are
providing 5V from the programmer to the Target, so you are connecting
to a "bare" AVR..? Both ATtiny85 [5] and ATtiny861 [6] are up to 5.5V
tolerant so it should not burn them "alone". But if you are connecting
to some board with other components it is critical to first verify
what is the acceptable maximum voltage that components can work with.
Old electronics used 5V. New electronics use 1,8..3.3V. If you provide
5V from the programmer to the board working with 3.3V or 1.8V you can
burn the board components. If you use some bigger board with its own
power supply both dip-switches should be in position OFF. VCC
connection from Programmer to AVR does not seem required. Here is an
extract from Diamex-Avr-USB documentation [4]:

Switch position for normal programming in user’s switching= both switch OFF
If voltage supply of the target is needed.
For a single AVR controller only without own switching 5V are required
(for example Diamex program
adapter/pivot lever) 1=on 2=on
General: 3.3V max. 120mA, 5V 150-500mA. Depending on which computer is used.
Switch 1 off= target voltage off/on, switch 2 off= 3.3V / on=5.0V. The
programmer doesn’t need a
power supply from the target for the programming operation.

Long story short:
* Put both dip-switches to OFF if you use external board (no VCC
connection required). They may stay ON if you program "bare" AVR (you
need to connect VCC, SW1=ON, SW2 OFF=3.3V ON=5V).
* Try `avrdude -c stk500v2 -p 85 -vvv -t` and see of that connects to
Programmer.
* If programmer is connected but AVR communication problems you may
slow down the STK500v2 bit clock with `-B` parameter or ISP clock with
`-i` according to [4] (i.e. `-B 250` will result in 4kHz bit clock).

Good luck and let us know if that works :-)
Tomek

[1] https://assets.nexperia.com/documents/data-sheet/74HC_HCT125.pdf
[2] https://www.st.com/en/microcontrollers-microprocessors/stm32f042f6.html
[3] https://www.diamex.de/dxshop/DIAMEX-USB-ISP-Programmer-Stick-fuer-AVR
[4] https://www.diamex.de/dxshop/mediafiles/Sonstiges/ENG%20ISP%20Programmer.pdf
[5] 
https://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-2586-AVR-8-bit-Microcontroller-ATtiny25-ATtiny45-ATtiny85_Datasheet-Summary.pdf
[6] 
https://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-2588-8-bit-AVR-Microcontrollers-tinyAVR-ATtiny261-ATtiny461-ATtiny861_Datasheet-Summary.pdf

-- 
CeDeROM, SQ7MHZ, http://www.tomek.cedro.info



Re: timeouts on USB ISP programmer

2022-04-08 Thread Axel Rau


> Am 08.04.2022 um 20:39 schrieb Tomek CEDRO :
> 
> Is it possible to disassemble your interface and take photos of the
> electronics inside? We need to make sure what exact chip is inside :-)
https://www.chaos1.de/downloads/diamex_photos.tar.gz

Axel
---
PGP-Key: CDE74120  ☀  computing @ chaos claudius



Re: timeouts on USB ISP programmer

2022-04-08 Thread Tomek CEDRO
On Fri, Apr 8, 2022 at 8:02 PM Axel Rau  wrote:
> Am 08.04.2022 um 18:04 schrieb Tomek CEDRO :
> My 1st trial gives this (more trials in 2 hours):
>
> root@home2l:/ # avrdude -p t85 -t -vvv
>
> avrdude: Version 6.4
>  Copyright (c) Brian Dean, http://www.bdmicro.com/
>  Copyright (c) Joerg Wunsch
>
>  System wide configuration file is "/usr/local/etc/avrdude.conf"
>  User configuration file is "/root/.avrduderc"
>
>  Using Port: usb
>  Using Programmer  : diamex-avr-usb
> E avrftdi_open(706): Error -6 occurred: ftdi_usb_reset failed
>
> avrdude done.  Thank you.

Hmm now there is a problem with ftdi open / reset. You are running as
root so it is not a permission problem.

Is it possible to disassemble your interface and take photos of the
electronics inside? We need to make sure what exact chip is inside :-)

-- 
CeDeROM, SQ7MHZ, http://www.tomek.cedro.info



Re: timeouts on USB ISP programmer

2022-04-08 Thread Axel Rau
Hi Tomek,

> Am 08.04.2022 um 18:04 schrieb Tomek CEDRO :
> 
> Here is an example `~/.avrduderc` to try out. It should work out of


Thanks a lot.

My 1st trial gives this (more trials in 2 hours):

root@home2l:/ # avrdude -p t85 -t -vvv

avrdude: Version 6.4
 Copyright (c) Brian Dean, http://www.bdmicro.com/
 Copyright (c) Joerg Wunsch

 System wide configuration file is "/usr/local/etc/avrdude.conf"
 User configuration file is "/root/.avrduderc"

 Using Port: usb
 Using Programmer  : diamex-avr-usb
E avrftdi_open(706): Error -6 occurred: ftdi_usb_reset failed

avrdude done.  Thank you.

root@home2l:/ # avrdude -p t85 -P usb -t -vvv

avrdude: Version 6.4
 Copyright (c) Brian Dean, http://www.bdmicro.com/
 Copyright (c) Joerg Wunsch

 System wide configuration file is "/usr/local/etc/avrdude.conf"
 User configuration file is "/root/.avrduderc"

 Using Port: usb
 Using Programmer  : diamex-avr-usb
E avrftdi_open(706): Error -3 occurred: device not found

avrdude done.  Thank you.

Axel
---
PGP-Key: CDE74120  ☀  computing @ chaos claudius



Re: timeouts on USB ISP programmer

2022-04-08 Thread Tomek CEDRO
On Fri, Apr 8, 2022 at 6:04 PM Tomek CEDRO  wrote:
> Good news is that you can only provide `-P usb` if you have one
> Programmer Interface and it is defined in the configuration. In your
> case if you want to use specific serial number that would probably be
> `-P usb:552` parameter.

Turns out when you have valid Programmer Interface configuration and
it is provided with `-c` then no need to use `-P` at all if you only
use one interface :-)

-- 
CeDeROM, SQ7MHZ, http://www.tomek.cedro.info



Re: timeouts on USB ISP programmer

2022-04-08 Thread Tomek CEDRO
On Fri, Apr 8, 2022 at 6:04 PM Tomek CEDRO  wrote:
> This is not the problem. It uses "real USB mode" to transport commands
> between PC and FT2232 too. Most of those Programmer dongles uses
> Virtual-COM-Port-over-USB (aka VCP / USB CDC). No matter if you use
> dedicated IC like FT2232H that you can simply put in your design and
> control with a predefined command sequences using libraries like
> LibUSB+LibFTDI, or you use a microcontroller with embedded USB Device
> silicon that puts additional burden on you to create a base firmware
> for that in the first place just then to get the commands to control
> it like FT2232.
>
> Using FT2232H is cheaper when you consider firmware + software
> developer time cost and you need no extra functionalities beyond GPIO
> control. This is really powerful chip and I still keep my KT-LINK in
> my backpack every day :-)

Just a curiosity, if you wonder what is the difference between generic
FT2232 and MCU+USB, then in practice you can construct almost any
protocol on both, the difference is overall speed.

However, you need to send single commands to FT2232 to control its
GPIO, that goes over USB with a predefined latency, and that low level
USB protocol latency is a killer bottleneck that limits the overall
interface speed. It depends on the USB Transfer mode and with LibUSB
1.0 asynchronous operations showed up but still the USB latency is the
limit here. Especially when you bitbang single GPIO pins, change input
to output, send small chunks of data, etc, that results in kHz/Kbps
speed.

On the other hand with MCU+USB design you are limited only with the
GPIO port speed (usually single MHz/Mbps). There may be even
on-silicon peripherals like SPI with speeds far greater than GPIO
itself (tens or hundreds of MHz/Mbps). But you need to create a
firmware that will handle on-silicon USB Device peripheral and then
some protocol between PC and the MCU. Then you send high-level command
quickly to the MCU, the firmware handles the bit operations, and MCU
returns single or packed data with higher USB utilization.

If you go down below to the silicon, for instance in ARM-Cortex, you
will notice that Debug Ports can access almost any peripheral inside
MCU including RAM and Flash. However, handling on-chip Flash Memory
from the DP is different and more complicated than handling it by the
CPU itself. CPU has fast access to simply read/write Flash Memory. DP
needs to perform dozens of operations at low level to drive Flash
Controller in the first place. RAM is usually mapped to the main bus
and can be written even faster than Flash. This is why in modern
solutions like Open-Sourcee OpenSDA/DAPLink and commercial Interfaces
so called Flash Algorithms are used. At first Interface detects the
Target MCU, then it uploads chunk of binary (so called Flash
Algorithm) to RAM, then FlashAlgo takes over the CPU and control the
flashing process from within the MCU. This is the fastest possible
way. PC with dedicated software called Debug Bridge like pyOCD or
OpenOCD connects to Debug Probe over USB, that connects to MCU Debug
Port over GPIO, that launches FlashAlgo binary from MCU's RAM, then
Debug Bridge simply sends request and takes data to/from FlashAlgo
(for instance using CMSIS-DAP protocol).

Kind of interesting :-)

-- 
CeDeROM, SQ7MHZ, http://www.tomek.cedro.info



Re: timeouts on USB ISP programmer

2022-04-08 Thread Axel Rau
Hi Tomek,

> Am 08.04.2022 um 05:33 schrieb Tomek CEDRO :
> 
> Mystery solved ;-)
> 
> For avrdude `-P` parameter defines the the programmer port __BUT__ (as
> obviously stated in man page) if you use `usb:` device then you need
> to provide programmer SERIAL NUMBER last bytes not the OS serial port
> device ;-)
I have no such serial number on the outside of my DIAMEX-ISP-USB. )-:
All I have is this:

root@home2l:/ # usbconfig -d 0.4 dump_device_desc
ugen0.4:  at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON 
(500mA)

  bLength = 0x0012 
  bDescriptorType = 0x0001 
  bcdUSB = 0x0200 
  bDeviceClass = 0x0002  
  bDeviceSubClass = 0x 
  bDeviceProtocol = 0x 
  bMaxPacketSize0 = 0x0040 
  idVendor = 0x16c0 
  idProduct = 0x2a9b 
  bcdDevice = 0x4340 
  iManufacturer = 0x0001  
  iProduct = 0x0002  
  iSerialNumber = 0x0003  <19331-49101-552>
  bNumConfigurations = 0x0001 

Would it help to create a section for programmer diamex-isp-usb ?
> 
> If you run avrdude with `-vvv` switch then you get increased
> verbosity. It will tell you what it found. You will notice that it
> found a device that matches VID:PID pair but not Serial NUMBER of the
> device (not the port) ;-)
> 
> Details here: https://github.com/avrdudes/avrdude/issues/920
> 

All I got with -vvv:

avrdude: usbdev_open(): did not find any (matching) USB device "usb:552" 
(0x03eb:0x2104)
avrdude: usbdev_open(): did not find any (matching) USB device "usb:0552" 
(0x03eb:0x2104)
avrdude: usbdev_open(): did not find any (matching) USB device "usb:0003" 
(0x03eb:0x2104)
avrdude: usbdev_open(): did not find any (matching) USB device "usb:1552" 
(0x03eb:0x2104)

I’m still not convinced that this stick does real USB mode (instead of serial 
emulation via ftdi.

I’m willing to buy a quality programmer from ATmel to move on.
Any recommendations?
Please advice.

All I currently need, is burning/flashing/fusing ATtinys:

 avrdude -c stk500v2 -p t861 -P /dev/ttyU1 \
-U hfuse:w:init.t861.elf \
-U efuse:w:init.t861.elf \
-U eeprom:w:init.t861.elf \
-U flash:w:init.t861.elf

But debugging support would be helpful in the future.

Sorry, I'm a newbie in the MCU business.

Thank you so much for all the time you did spend to help me,
Axel


---
---
PGP-Key: CDE74120  ☀  computing @ chaos claudius



Re: timeouts on USB ISP programmer

2022-04-07 Thread Tomek CEDRO
Mystery solved ;-)

For avrdude `-P` parameter defines the the programmer port __BUT__ (as
obviously stated in man page) if you use `usb:` device then you need
to provide programmer SERIAL NUMBER last bytes not the OS serial port
device ;-)

If you run avrdude with `-vvv` switch then you get increased
verbosity. It will tell you what it found. You will notice that it
found a device that matches VID:PID pair but not Serial NUMBER of the
device (not the port) ;-)

Details here: https://github.com/avrdudes/avrdude/issues/920

Because avrdude keeps all its Programmer and Target definitions in a
configuration file it is possible to define completely new Programmer
and Target MCU with a simple commands in `~/.avrduderc` (see
`/usr/local/etc/avrdude.conf` for reference).

It is also possible to build the port with `cd
/usr/ports/devel/avrdude; make WITH_DEBUG=1; make reinstall` to obtain
binary that can be easily debugged with `lldb` (btw I just discovered
`gui` option). `usbhid_open()` and/or `usbdev_open()` is the place
where VID:PID and serial is handled.

I hope that helps move things forward :-)

Tomek


% avrdude -c xplainedmini -p t416 -P usb:3537 -vvv

avrdude: Version 6.4
 Copyright (c) Brian Dean, http://www.bdmicro.com/
 Copyright (c) Joerg Wunsch

 System wide configuration file is "/usr/local/etc/avrdude.conf"
 User configuration file is "/home/XXX/.avrduderc"

 Using Port: usb:3537
 Using Programmer  : xplainedmini
avrdude: stk500v2_jtag3_open()
avrdude: usbhid_open(): Found mEDBG CMSIS-DAP, serno: ATML279504273537
avrdude: usbhid_open(): Opening path 0-3.4.4:1.0
avrdude: usbhid_open(): Probing for max. packet size
avrdude: usbhid_open(): Setting max_xfer from DAP_Info response to 64
avrdude: Found CMSIS-DAP compliant device, using EDBG protocol
avrdude: jtag3_getsync()
avrdude: Sending sign-on command:
avrdude: jtag3_edbg_send(): sending 3 bytes
avrdude: jtag3_recv(): Got message seqno 0 (command_sequence == 0)

[general] OK
 AVR Part  : ATtiny416
 Chip Erase delay  : 0 us
 PAGEL : P00
 BS2   : P00
 RESET disposition : dedicated
 RETRY pulse   : SCK
 serial program mode   : yes
 parallel program mode : yes
 Timeout   : 0
 StabDelay : 0
 CmdexeDelay   : 0
 SyncLoops : 0
 ByteDelay : 0
 PollIndex : 0
 PollValue : 0x00
 Memory Detail :


-- 
CeDeROM, SQ7MHZ, http://www.tomek.cedro.info



Re: timeouts on USB ISP programmer

2022-04-07 Thread Tomek CEDRO
On Thu, Apr 7, 2022 at 8:35 PM Tomek CEDRO  wrote:
> Also I noticed that we have two ports devel/arduino-avrdude-6.3 and
> devel/avrdude-6.4.

My first remarks on avrdude port were in fact made on
devel/arduino-avrdude-6.3, sorry, it may require some more patches to
work with Adruino.

The port of our interest devel/avrdude-6.4 only needs a fix with
libftdi location. Will try to create a patch to the upstream :-)

Also I noticed that avrdude is CONFIGRATION centric and all Interface
and Target definitions are located in the configuration file, so no
rebuild may be even necessary, just a local configuration update.
System wide default configuration is in `/usr/local/etc/avrdude.conf
`. Will report back with working ATtiny416XNANO and ATtiny104XNANO.

-- 
CeDeROM, SQ7MHZ, http://www.tomek.cedro.info



Re: timeouts on USB ISP programmer

2022-04-07 Thread Tomek CEDRO
The problem is Diamex does not provide schematics for their interface.
That could make things easier to compare with other interfaces to
search for similar one. Are you sure it is FT2232H based? LibFTDI as
dependency to avrdude may also some from other interfaces :-)

But we both have VID:PID issue. I have original DevKit from
Michrochip/Atmel. Schematics is here:
https://ww1.microchip.com/downloads/en/DeviceDoc/ATtiny416_Xplained_Nano_Schematics.pdf

Also when connecting to my devkit over serial port with Minicom
(9600-8-N-1) i get "nak" from the board. So the board and connection
to the board works fine.

This clearly indicates problem with avrdude. Probably it has hardcoded
VID:PID pairs. Maybe they are part of the configuration files.

Also I noticed that we have two ports devel/arduino-avrdude-6.3 and
devel/avrdude-6.4.

Work in progress :-)

-- 
CeDeROM, SQ7MHZ, http://www.tomek.cedro.info



Re: timeouts on USB ISP programmer

2022-04-07 Thread Tomek CEDRO
I have reported an issue on avrdude github project, hope they give us
some hints and we all make our devices operational on FreeBSD :-)

https://github.com/avrdudes/avrdude/issues/920

Regarding Diamex interface I would try one after another from the list
of `-c "?"` until one of them works, then configuration file can be
created. If none of them works then a configuration needs to be
created from scratch based on existing configuration files. I guess
this should be in the vendor interest to have that configuration
working out of the box :-)

Regarding FT2232H chip I have used that one long ago (~10 years) and
created driver for first implementations of SWD for ARM-Cortex devices
(under LibSWD project). I even created SPI interface on that chip. I
was using KT-LINK interface. FT2232H has two channels, can be used for
UART or serial/parallel bitbang. It uses sort of commands to
read/write GPIO ports. Technical specification is here:

https://www.ftdichip.com/Support/Documents/DataSheets/ICs/DS_FT2232H.pdf

-- 
CeDeROM, SQ7MHZ, http://www.tomek.cedro.info



Re: timeouts on USB ISP programmer

2022-04-07 Thread Tomek CEDRO
Sorry, this time a reply that is subscribed to the list :-)

Hello world :-)

Short story:
* Try `-P usb:/dev/cuaU0` parameter. You need to use `usb:` prefix for
the USB adapter.
* Did that interface worked well on other OS with avrdude 6.4 (we
currently have 6.3 port on FreeBSD)?
* I have encountered similar issue with VID:PID pair on my
ATtiny416XNANO board. This needs patching the upstream. But port uses
several local patched to build on FreeBSD that are not part of the
upstream. We have to make upstream build cleanly on FreeBSD in the
first place :-)

Long story:
I have some Attiny104XplainedNano and Attiny416XplainedNano develkits
we can play with. I will provide example step by step documentation
that helps solving problems and that got me into conslusions presented
above :-)

Best regards :-)
Tomek


== OS ==

FreeBSD hexagon 13.1-STABLE FreeBSD 13.1-STABLE #0
stable/13-n250096-4f69c575996: Fri Mar 25 03:50:58 CET 2022
root@hexagon:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64


== ATtiny416XplainedNano ==

# dmesg | tail
ugen0.8:  at usbus0
usbhid4 on uhub15
usbhid4:  on usbus0
hidbus4:  on usbhid4
umodem0 on uhub15
umodem0:  on usbus0
umodem0: data interface 2, has CM over data, has break

 # usbconfig -d 0.8 dump_device_desc
ugen0.8:  at usbus0, cfg=0 md=HOST spd=FULL
(12Mbps) pwr=ON (100mA)
  bLength = 0x0012
  bDescriptorType = 0x0001
  bcdUSB = 0x0200
  bDeviceClass = 0x00ef  
  bDeviceSubClass = 0x0002
  bDeviceProtocol = 0x0001
  bMaxPacketSize0 = 0x0020
  idVendor = 0x03eb
  idProduct = 0x2145
  bcdDevice = 0x1000
  iManufacturer = 0x0001  
  iProduct = 0x0002  
  iSerialNumber = 0x0003  
  bNumConfigurations = 0x0001


== ATtiny416XplainedNano ==

# dmesg | tail
ugen0.8:  at usbus0 (disconnected)
usbhid4: at uhub15, port 4, addr 7 (disconnected)
hidbus4: detached
usbhid4: detached
umodem0: at uhub15, port 4, addr 7 (disconnected)
umodem0: detached
ugen0.8:  at usbus0
usbhid4 on uhub15
usbhid4:  on usbus0
hidbus4:  on usbhid4
umodem0 on uhub15
umodem0:  on usbus0
umodem0: data interface 2, has CM over data, has break

# usbconfig -d 0.8 dump_device_desc
ugen0.8:  at usbus0, cfg=0 md=HOST spd=FULL
(12Mbps) pwr=ON (100mA)

  bLength = 0x0012
  bDescriptorType = 0x0001
  bcdUSB = 0x0200
  bDeviceClass = 0x00ef  
  bDeviceSubClass = 0x0002
  bDeviceProtocol = 0x0001
  bMaxPacketSize0 = 0x0020
  idVendor = 0x03eb
  idProduct = 0x2145
  bcdDevice = 0x1000
  iManufacturer = 0x0001  
  iProduct = 0x0002  
  iSerialNumber = 0x0003  
  bNumConfigurations = 0x0001


== AVRDUDE PART ==

% avrdude -c "?"

Valid programmers are:
  2232HIO  = FT2232H based generic programmer
  4232h= FT4232H based generic programmer
  arduino  = Arduino
  arduino-ft232r   = Arduino: FT232R connected to ISP
  atmelice = Atmel-ICE (ARM/AVR) in JTAG mode
  atmelice_dw  = Atmel-ICE (ARM/AVR) in debugWIRE mode
  atmelice_isp = Atmel-ICE (ARM/AVR) in ISP mode
  atmelice_pdi = Atmel-ICE (ARM/AVR) in PDI mode
  atmelice_updi= Atmel-ICE (ARM/AVR) in UPDI mode
  avr109   = Atmel AppNote AVR109 Boot Loader
  avr910   = Atmel Low Cost Serial Programmer
  avr911   = Atmel AppNote AVR911 AVROSP
  avrftdi  = FT2232D based generic programmer
  avrisp   = Atmel AVR ISP
  avrisp2  = Atmel AVR ISP mkII
  avrispmkII   = Atmel AVR ISP mkII
  avrispv2 = Atmel AVR ISP V2
  buspirate= The Bus Pirate
  buspirate_bb = The Bus Pirate (bitbang interface, supports TPI)
  butterfly= Atmel Butterfly Development Board
  butterfly_mk = Mikrokopter.de Butterfly
  bwmega   = BitWizard ftdi_atmega builtin programmer
  C232HM   = FT232H based module from FTDI and Glyn.com.au
  c2n232i  = serial port banging, reset=dtr sck=!rts mosi=!txd miso=!cts
  dasa = serial port banging, reset=rts sck=dtr mosi=txd miso=cts
  dasa3= serial port banging, reset=!dtr sck=rts mosi=txd miso=cts
  diecimila= alias for arduino-ft232r
  dragon_dw= Atmel AVR Dragon in debugWire mode
  dragon_hvsp  = Atmel AVR Dragon in HVSP mode
  dragon_isp   = Atmel AVR Dragon in ISP mode
  dragon_jtag  = Atmel AVR Dragon in JTAG mode
  dragon_pdi   = Atmel AVR Dragon in PDI mode
  dragon_pp= Atmel AVR Dragon in PP mode
  ehajo-isp= avr-isp-programmer from eHaJo, http://www.eHaJo.de
  flip1= FLIP USB DFU protocol version 1 (doc7618)
  flip2= FLIP USB DFU protocol version 2 (AVR4023)
  ft232r   = FT232R Synchronous BitBang
  ft245r   = FT245R Synchronous BitBang
  iseavrprog   = USBtiny-based USB programmer,
https://github.com/IowaScaledEngineering/ckt-avrp
  jtag1= Atmel JTAG ICE (mkI)
  jtag1slow= Atmel JTAG ICE (mkI)
  jtag2= Atmel JTAG ICE mkII
  jtag2avr32   = Atmel JTAG ICE mkII im AVR32 mode
  jtag2dw  = Atmel JTAG ICE mkII in debugWire mode
  jtag2fast= Atmel JTAG 

Re: timeouts on USB ISP programmer

2022-04-07 Thread Hans Petter Selasky

On 4/7/22 15:46, Axel Rau wrote:




Am 07.04.2022 um 15:26 schrieb Hans Petter Selasky :

On 4/7/22 14:12, Hans Petter Selasky wrote:

On 4/7/22 13:33, Axel Rau wrote:

Hi all,

my DIAMEX-AVR-USB gets timeouts while talking to the target:
- - -
root@home2l:/ #avrdude -c stk500v2 -p t85 -P /dev/cuau1 -t -v -i 10

avrdude: Version 6.4
   Copyright (c) Brian Dean, http://www.bdmicro.com/
   Copyright (c) Joerg Wunsch



Try:

-P usb

See manual page:

port can alternatively be
   specified as usb[:serialno].  This will  cause avrdude to
   search the programmer on USB.



Hmm. What mewans ’serial’ in this case?

avrdude: usbdev_open(): did not find any (matching) USB device "usb:0" 
(0x03eb:0x2104)
avrdude: usbdev_open(): did not find any (matching) USB device "usb:4" 
(0x03eb:0x2104)
avrdude: usbdev_open(): did not find any (matching) USB device "usb:" 
(0x03eb:0x2104)

The avrdude package did install libftdi1, so I think its just an USB-to-serial 
converter?
usbconfig said: ‚communication device



Hi Tomek,

Do you see what is wrong here?

Maybe he needs to use "avrisp2" instead of "stk500v2"?

--HPS



Re: timeouts on USB ISP programmer

2022-04-07 Thread Hans Petter Selasky

On 4/7/22 15:46, Axel Rau wrote:

Hmm. What mewans ’serial’ in this case?


Serial is this:

  iSerialNumber = 0x0003  <19331-49101-552>

usb:19331-49101-552

--HPS



Re: timeouts on USB ISP programmer

2022-04-07 Thread Axel Rau


> Am 07.04.2022 um 15:26 schrieb Hans Petter Selasky :
> 
> On 4/7/22 14:12, Hans Petter Selasky wrote:
>> On 4/7/22 13:33, Axel Rau wrote:
>>> Hi all,
>>> 
>>> my DIAMEX-AVR-USB gets timeouts while talking to the target:
>>> - - -
>>> root@home2l:/ #avrdude -c stk500v2 -p t85 -P /dev/cuau1 -t -v -i 10
>>> 
>>> avrdude: Version 6.4
>>>   Copyright (c) Brian Dean, http://www.bdmicro.com/
>>>   Copyright (c) Joerg Wunsch
>>> 
> 
> Try:
> 
> -P usb
> 
> See manual page:
> > port can alternatively be
> >   specified as usb[:serialno].  This will  cause avrdude to
> >   search the programmer on USB.


Hmm. What mewans ’serial’ in this case?

avrdude: usbdev_open(): did not find any (matching) USB device "usb:0" 
(0x03eb:0x2104)
avrdude: usbdev_open(): did not find any (matching) USB device "usb:4" 
(0x03eb:0x2104)
avrdude: usbdev_open(): did not find any (matching) USB device "usb:" 
(0x03eb:0x2104)

The avrdude package did install libftdi1, so I think its just an USB-to-serial 
converter?
usbconfig said: ‚communication device

A.
---
PGP-Key: CDE74120  ☀  computing @ chaos claudius



Re: timeouts on USB ISP programmer

2022-04-07 Thread Hans Petter Selasky

On 4/7/22 14:12, Hans Petter Selasky wrote:

On 4/7/22 13:33, Axel Rau wrote:

Hi all,

my DIAMEX-AVR-USB gets timeouts while talking to the target:
- - -
root@home2l:/ #    avrdude -c stk500v2 -p t85 -P /dev/cuau1 -t -v -i 10

avrdude: Version 6.4
  Copyright (c) Brian Dean, http://www.bdmicro.com/
  Copyright (c) Joerg Wunsch



Try:

-P usb

See manual page:
>port can alternatively be
>   specified as usb[:serialno].  This will  cause 
avrdude to

>   search the programmer on USB.


--HPS



Re: timeouts on USB ISP programmer

2022-04-07 Thread Hans Petter Selasky

On 4/7/22 13:33, Axel Rau wrote:

Hi all,

my DIAMEX-AVR-USB gets timeouts while talking to the target:
- - -
root@home2l:/ # avrdude -c stk500v2 -p t85 -P /dev/cuau1 -t -v -i 10

avrdude: Version 6.4
  Copyright (c) Brian Dean, http://www.bdmicro.com/
  Copyright (c) Joerg Wunsch

  System wide configuration file is "/usr/local/etc/avrdude.conf"
  User configuration file is "/root/.avrduderc"
  User configuration file does not exist or is not a regular file, 
skipping

  Using Port: /dev/cuau1
  Using Programmer  : stk500v2
  Setting isp clock delay:  10
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
  AVR Part  : ATtiny85
  Chip Erase delay  : 4500 us
  PAGEL : P00
  BS2   : P00
  RESET disposition : possible i/o
  RETRY pulse   : SCK
  serial program mode   : yes
  parallel program mode : yes
  Timeout   : 200
  StabDelay : 100
  CmdexeDelay   : 25
  SyncLoops : 32
  ByteDelay : 0
  PollIndex : 3
  PollValue : 0x53
  Memory Detail :

   Block Poll   Page
   Polled
Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  
MaxW   ReadBack
---  - -  -- --  -- - 
- -
eeprom65 6 40 no5124  0  4000  
4500 0xff 0xff
flash 65 6320 yes  8192   64128  4500  
4500 0xff 0xff
signature  0 0 00 no  31  0 0   
  0 0x00 0x00
lock   0 0 00 no  11  0  9000  
9000 0x00 0x00
lfuse  0 0 00 no  11  0  9000  
9000 0x00 0x00
hfuse  0 0 00 no  11  0  9000  
9000 0x00 0x00
efuse  0 0 00 no  11  0  9000  
9000 0x00 0x00
calibration0 0 00 no  11  0 0   
  0 0x00 0x00

  Programmer Type : STK500V2
  Description : Atmel STK500 Version 2.x firmware
  Programmer Model: Unknown
avrdude: stk500v2_ReceiveMessage(): timeout
. . .
avrdude: stk500v2_getsync(): timeout communicating with programmer
avrdude: stk500v2_command(): failed miserably to execute command 0x11
avrdude: stk500v2_disable(): failed to leave programming mode

root@home2l:/ # usbconfig
ugen0.1: <0x8086 XHCI root HUB> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) 
pwr=SAVE (0mA)
ugen0.2:  at usbus0, cfg=0 md=HOST spd=LOW 
(1.5Mbps) pwr=ON (100mA)
ugen0.3:  at usbus0, cfg=0 md=HOST spd=LOW 
(1.5Mbps) pwr=ON (100mA)
ugen0.4:  at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON 
(500mA)
root@home2l:/ # usbconfig -d ugen0.4 dump_device_desc
ugen0.4:  at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON 
(500mA)

   bLength = 0x0012
   bDescriptorType = 0x0001
   bcdUSB = 0x0200
   bDeviceClass = 0x0002  
   bDeviceSubClass = 0x
   bDeviceProtocol = 0x
   bMaxPacketSize0 = 0x0040
   idVendor = 0x16c0
   idProduct = 0x2a9b
   bcdDevice = 0x4340
   iManufacturer = 0x0001  
   iProduct = 0x0002  
   iSerialNumber = 0x0003  <19331-49101-552>
   bNumConfigurations = 0x0001
- - -

Loading uftdi.ko did not help.



Try:

usbdump -i usbus0 -f 4 -s 65536 -vvv

To see exactly what is going on.

Maybe some other kernel driver is attached at the same time, consuming 
the response from the programmer.


BTW:

/dev/cuau1 is not a USB port!

Maybe try:

/dev/cuaU1

--HPS