-->
Page 1 of 2

ESP8266 AVR ISP usage issues

PostPosted: Mon Jul 05, 2021 10:32 am
by beic
Hi there,

I'm trying to use ESP8266AVRISP example sketch, but without any luck.
https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266AVRISP

Using Arduino IDE v1.8.2 with ESP8266 Core v2.3.0 and Avrdude v6.3 on Windows 7 SP1 64-bit.

After connecting WeMos D1 mini with Arduino Uno over ICSP header like this:
Code: Select allD1 = RESET
D5 = SCK
D6 = MISO
D7 = MOSI


I'm using Avrdude command like this:
Code: Select allavrdude -v -C avrdude.conf -c arduino -p m328p -P net:192.168.0.230:328 -U flash:w:Blink.hex:i


I'm getting this output from Avrdude:

Code: Select allavrdude: Version 6.3, compiled on Feb 17 2016 at 09:25:53
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "avrdude.conf"

         Using Port                    : net:192.168.0.230:328
         Using Programmer              : arduino
avrdude: ser_drain(): read error: The parameter is incorrect.

avrdude: ser_drain(): read error: The parameter is incorrect.

avrdude: ser_drain(): read error: The parameter is incorrect.

         AVR Part                      : ATmega328
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         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
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0    00  0x00 0x00
           signature      0     0     0    0 no          3    0      0    00  0x00 0x00

         Programmer Type : Arduino
         Description     : Arduino

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x14

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x10
         Hardware Version: 4669920
         Firmware Version: 0.2
         Topcard         : STK502
         Vtarget         : 1.8 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: stk500_initialize(): (b) protocol error, expect=0x10, resp=0x01
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x10

avrdude done.  Thank you.


The output from the ESP8266 (WeMos D1 mini):

Code: Select allArduino AVR-ISP over TCP
IP address: 192.168.0.230
Use your avrdude:
avrdude -c arduino -p <device> -P net:192.168.0.230:328 -t # or -U ...
[AVRISP] connection pending
[AVRISP] programming mode
[AVRISP] now idle


Any help would be greatly appreciated!

Thank You!

Re: ESP8266 AVR ISP usage issues

PostPosted: Tue Jul 06, 2021 1:06 pm
by JurajA
did you wire ground between the devices?

Re: ESP8266 AVR ISP usage issues

PostPosted: Tue Jul 06, 2021 2:15 pm
by beic
JurajA wrote:did you wire ground between the devices?


Yes, WeMos D1 mini is getting power from the ICSP (ISP) header.

Re: ESP8266 AVR ISP usage issues

PostPosted: Sun Jul 11, 2021 1:25 am
by rippatec
Hi,
After trying to get this to work for some time (in windows) I eventually found that it is actually a windows issue. (issue is probably not the right term, maybe 'lack')
The example sketch works fine in Linux (I installed a virtual machine to test) but in windows the network feature to allow serial-redirection to a network port simply does not exist so lots of unhelpful errors get produced from AVRdude instead.

To get around this (in an ugly way), I changed the supplied wifi sketch to use port-23 (for telnet) then made a minimal telnet client on another ESP (serial-to-telnet) that connects to the server in the ESP-ISP.
This then allows AVRdude to 'see' the ESP-ISP programmer down a serial port (telnet link), not directly on the network. Its horribly inefficient but it does work (most of the time).
If AVRdude manages to connect to the programmer, it then programs (and verifies) the AVR OK.
I only did this to see if it would work but its clunky and rough. I'm not actually going to use it like this as I worked out another method for my combined ESP and AVR board. Just to embed the AVR binary into the ESP binary. It will check the AVR version when it starts, if its older than the version in the ESP, it will update it.

I think the supplied ESP sketch Arduino_Wifi_AVRISP should have a note at the top informing that it only works with Linux. It would save people a lot of frustrating time. I think I'll suggest that...

Enjoy!