0

Basically my project requires to program Arduino Board wirelessly and I have found ESP-link which seems to match my purpose.

I tried to follow the instructions in documentations on the github page https://github.com/jeelabs/esp-link I am using Arduino UNO and ESP8266-01 by the way.

Flashing ESP-link into ESP8266 was successful. I followed the configuration page and successfully connect the ESP8266 to an MQTT Server. I connect my Arduino UNO to computer via USB Serial. Connected UNO to ESP8266 using the default settings (TX - TX, RX - RX, GPIO0 - RST). When I checked the Microcontroller Console page, I could send and received messages to/from UNO as well as resetting the UNO (I programmed blink sketch into my UNO, so I can see every time I reset it, it works)

However, the next step is not that successful. I tried to program UNO via ESP8266 but it does not work out quite well. There are several methods posted on the documentation https://github.com/jeelabs/esp-link/blob/master/UC-FLASHING.md and I have tried them to some extent.

1.Use Avrdude to program. Basically I copied the command when Arduino IDE programmed UNO using avrdude, and change the port to net:{localIP_of_ESP8266}:23 By the way I tested the code by set the port to local Serial port and it works I get the error and below is what cmd shows:

avrdude.exe: 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 "C:\Users\ktz001\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino9/etc/avrdude.conf"

             Using Port                    : net:192.168.10.97:23
             Using Programmer              : arduino
             Overriding Baud Rate          : 115200
avrdude.exe: ser_drain(): read error: The parameter is incorrect

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

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

avrdude.exe: stk500_recv(): programmer is not responding
avrdude.exe: stk500_getsync() attempt 1 of 10: not in sync: resp=0xa4
avrdude.exe: stk500_recv(): programmer is not responding
avrdude.exe: stk500_getsync() attempt 2 of 10: not in sync: resp=0xa4
avrdude.exe: stk500_recv(): programmer is not responding
avrdude.exe: stk500_getsync() attempt 3 of 10: not in sync: resp=0xa4
avrdude.exe: stk500_recv(): programmer is not responding
avrdude.exe: stk500_getsync() attempt 4 of 10: not in sync: resp=0xa4
avrdude.exe: stk500_recv(): programmer is not responding
avrdude.exe: stk500_getsync() attempt 5 of 10: not in sync: resp=0xa4
avrdude.exe: stk500_recv(): programmer is not responding
avrdude.exe: stk500_getsync() attempt 6 of 10: not in sync: resp=0xa4
avrdude.exe: stk500_recv(): programmer is not responding
avrdude.exe: stk500_getsync() attempt 7 of 10: not in sync: resp=0xa4
avrdude.exe: stk500_recv(): programmer is not responding
avrdude.exe: stk500_getsync() attempt 8 of 10: not in sync: resp=0xa4
avrdude.exe: stk500_recv(): programmer is not responding
avrdude.exe: stk500_getsync() attempt 9 of 10: not in sync: resp=0xa4
avrdude.exe: stk500_recv(): programmer is not responding
avrdude.exe: stk500_getsync() attempt 10 of 10: not in sync: resp=0xa4
avrdude.exe: ser_drain(): read error: The parameter is incorrect


avrdude.exe done.  Thank you.
  1. Then I tried the post http method. Basically I sent a post request to http://{IP_of_ESP8266}/pgm/sync in my case:

POST http://192.168.10.97/pgm/sync

I get 204 OK as response Then I tried:

GET http://192.168.10.97/pgm/sync

It returns "sync abandoned after 8 attempts" So I am stuck again

  1. I tried also a small tool called avr-link https://gitlab.com/bc547-playground/avr-link Someone used it to program a pro mini via esp8266-01 which I think is close enough to my situation. I ran it on the powershell (I am using Windos 10 btw) The result is
PS C:\> .\avr-link.exe flash --esp 192.168.10.97 --file C:/Blink.ino.hex
AVR reset initiated...waiting for SYNC status
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
FATAL ERROR: Unexpected response:
00000000  73 79 6e 63 20 61 62 61  6e 64 6f 6e 65 64 20 61  |sync abandoned a|
00000010  66 74 65 72 20 38 20 61  74 74 65 6d 70 74 73     |fter 8 attempts|
  1. using avrflash script. I am not sure how to run it in Windows OS so I did not use the script. If anyone could tell me about this, I appreciate it as well.

So to conclude, the problem seems to happen in getting sync after resetting the UNO (Although I am not 100% sure what does it mean - I am not familiar with the hardware process when flashing a UNO) There is a paragraph actually in documentation suggesting the problem. Here is the quote:

If you are having trouble with the built-in programmer and see something like this:

./avrflash 192.168.3.104 blink.hex Error checking sync: FAILED to SYNC: abandoned after timeout, got: :\xF/\x00\xCj\xCz\xCJ\xCZ\xC\xAÜ\xC\xAä\xC\xAÜ\xC\xAä\xC\xBì\xC\xBô\xC\xBì\xC\xBô\xC\xAÜ\xC\xAä\xC

the most likely cause is a baud rate mismatch and/or a bad connection from the esp8266 to the AVRs reset line. The baud rate used by esp-link is set on the uC Console web page and, as mentioned above, it will automatically try 9600, 57600, and 115200 as well. The above garbage characters are most likely due to optiboot timing out and starting the sketch and then the sketch sending data at a different baud rate than configured into esp-link. Note that sketches don't necessarily use the same baud rate as optiboot, so you may have the correct baud rate configured but reset isn't functioning, or reset may be functioning but the baud rate may be incorrect.

I tried to change the baud rate (both in command and microController Console page) but it still does not work. And in Arduino IDE it programs the board in 115200 so I should be okay with this baud rate imo, but anyway it did not work even when I change it. As for the reset connection, I could reset the UNO by pressing reset in the Microcrontroller Console page so It shouldn't be the problem (and I don't know how to change it anyway).

Thank you for your patience reading through all this crap.. So what do you think the problem is? Any suggestion would help :D

  • I have found out the problem: I connected TX and RX wrong way around. It should be TX - RX and RX -TX. ------ However, I still cannot access ESP-Link by host name, but I think the reason is : 1.I don't have mDNS service on my computer (or more precisely a properly functioned one) 2. The mDNS service on ESP-Link is not stable. The other computer can access esp-link server some time but cannot some other time. – Jin.J Mar 28 '18 at 9:03
  • @JnJ, In the answer I write about the esp-link mdns bug – Juraj Mar 28 '18 at 9:39
1

I tested it some weeks ago again after a year. The default upload from IDE should work, but mDNS in esp-link has now a bug and propagates the service only in AP mode so in STA mode the IDE doesn't show the network port.

from command line you can upload OTA with arduinoOTA tool used by IDE

example:

/home/duro/.arduino15/packages/arduino/tools/arduinoOTA/1.1.1/bin/arduinoOTA -address 192.168.1.104 -port 80 -sketch /tmp/arduino_build_89762/Blink.ino.hex -upload /pgm/upload -sync /pgm/sync -reset /log/reset -sync_exp 204:SYNC

If the mdns bug was fixed, for upload from IDE some settings must be added to board.txt

uno.upload.network.endpoint_upload=/pgm/upload
uno.upload.network.endpoint_sync=/pgm/sync
uno.upload.network.sync_return=204:SYNC
uno.upload.network.endpoint_reset=/log/reset
uno.upload.network.port=80

Uno WiFi uses an old version of esp-link so the settings and tutorial apply

enter image description here

  • Thank you for replying.. I succeeded last week but forgot to update the question. It was the connection between ESP and Arduino board. Should be TX - RX and RX - TX while I connected them wrong way around. – Jin.J Mar 28 '18 at 9:01
1

I didn't test the avrdude network upload with esp-link. I used it with esp8266 AVRISP library. I configured the Arduino toolchain for network upload in platform.txt.

tools.avrdude.upload.network_pattern="{cmd.path}" "-C{config.path}" -p{build.mcu} -c{upload.protocol} "-Pnet:{serial.port}:328" "-Uflash:w:{build.path}/{build.project_name}.hex:i"

Warning: the use case in my other answer uses the original setting of tools.avrdude.upload.network_pattern

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.