Go Down

Topic: [Solved] Please add in the IDE a TCP client connection to upload (Read 2275 times) previous topic - next topic

rtek1000

Today we have many possibilities to create a TCP link, with the help of a small board ESP8266 (ESP-01) we can have a powerful remote programmer.

The ESP-Link Firmware allows a server to wait for a TCP connection. When the Client connects, a reset signal is made on the microcontroller.

The problem is that the user still relies on third party software, and they are expensive in view of the cost of a basic Arduino board.

ESP-Link Project (and instructions)

Thank you!

The Solution: Program from Arduino IDE - #394

Note: I tested with Linux Lubuntu 18.04 and IDE (1.8.5) was much faster than Windows 7
Please avoid private messages, your question may be someone's answer in the future!

Delta_G

Quote
relies on third party software, and they are expensive
If you paid anything for any software for your Arduino then you got duped.

If you put together the code and put in the pull request then maybe it will get added.
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

rtek1000

Flashing an attached Microcontroller

Quote
In order to connect through the esp-link to a microcontroller use port 23. For example, on linux you can use nc esp-hostname 23 or telnet esp-hostname 23.

Note that multiple connections to port 23 and 2323 can be made simultaneously. Esp-link will intermix characters received on all these connections onto the serial TX and it will broadcast incoming characters from the serial RX to all connections. Use with caution!
Flashing an attached AVR/Arduino

There are multiple options for reprogramming an attached AVR/Arduino microcontroller:

    Use avrdude and point it at port 23 of esp-link. Esp-link automatically detects the programming sequence and issues a reset to the AVR.
    Use avrdude and point it at port 2323 of esp-link. This is the same as port 23 except that the autodectection is not used and the reset happens because port 2323 is used
    Use curl or a similar tool to HTTP POST the firmware to esp-link. This uses the built-in programmer, which only works for AVRs/Arduinos with the optiboot bootloader (which is std).
    Use some serial port forwarding software, such as com2com, or hwvsp (you have to uncheck nvt in the settings when using the latter).

To reprogram an Arduino / AVR microcontroller by pointing avrdude at port 23 or 2323 you specify a serial port of the form net:esp-link:23 in avrdude's -P option, where esp-link is either the hostname of your esp-link or its IP address). This is instead of specifying a serial port of the form /dev/ttyUSB0. Esp-link detects that avrdude starts its connection with a flash synchronization sequence and sends a reset to the AVR microcontroller so it can switch into flash programming mode.

Note for Windows users: very recent avrdude versions on Windows support the -P option, while older ones don't. See the second-to-last bullet in the [avrdude 6.3 release notes]http://savannah.nongnu.org/forum/forum.php?forum_id=8461).
If I use the "ping esp-link" command at the prompt, the IP address will be displayed, I think it would be nice to have in IDE some way to inform this host name so that the correct avrdude command runs without the user needing to be reporting the IP address, because if the network operates with DHCP, IP can change.
Please avoid private messages, your question may be someone's answer in the future!

rtek1000

This works:
(You need to leave the port speed selected in the esp-link settings)

Quote
D:\Arduino\hardware\tools\avr\bin>avrdude -v -p atmega328p -c arduino -P net:esp-link:23 -b 57600 -D -U flash:w:file.hex:i
Result:
Quote
D:\Arduino\hardware\tools\avr\bin>avrdude -v -p atmega328p -c arduino -P net:esp-link:23 -b 57600 -D -U flash:w:file.hex:i

avrdude: 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 "D:\Arduino\1- IDE\arduino-1.8.5-wind
ows1\Arduino A\hardware\tools\avr\bin\avrdude.conf"

         Using Port                    : net:esp-link:23
         Using Programmer              : arduino
         Overriding Baud Rate          : 57600
avrdude: ser_drain(): read error: ParÔmetro incorreto.

avrdude: ser_drain(): read error: ParÔmetro incorreto.

avrdude: ser_drain(): read error: ParÔmetro incorreto.

avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
         AVR Part                      : ATmega328P
         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  Max
W   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ---
-- ---------
           eeprom        65    20     4    0 no       1024    4      0  3600  36
00 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  45
00 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  45
00 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  45
00 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  45
00 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  45
00 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0
 0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0
 0 0x00 0x00

         Programmer Type : Arduino
         Description     : Arduino
         Hardware Version: 2
         Firmware Version: 1.16
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: safemode: hfuse reads as 0
avrdude: safemode: efuse reads as 0
avrdude: reading input file "file.hex"
avrdude: writing flash (12176 bytes):

Writing | ################################################## | 100% 5.62s

avrdude: 12176 bytes of flash written
avrdude: verifying flash memory against file.hex:
avrdude: load data flash data from input file file.hex:
avrdude: input file file.hex contains 12176 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 24.07s

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

avrdude: safemode: hfuse reads as 0
avrdude: safemode: efuse reads as 0
avrdude: safemode: Fuses OK (E:00, H:00, L:00)

avrdude done.  Thank you.


D:\Arduino\hardware\tools\avr\bin>
(file.hex is the compiled file to be programmed into Arduino flash memory)

So perhaps all that is needed is to add a field there in the port selection part where the user can enter the Hostname so that avrdude can be configured with the correct command.
Please avoid private messages, your question may be someone's answer in the future!

Juraj

he only problem is that the esp-link has an error and doesn't propagate the mDns record as it should. otherwise you would see the network port in arduino IDE. the next problem is that Arduino IDE doesn't allow to enter the IP Address.


rtek1000

Hey, with the help of some messages I found on forums, I bundled a batch file to automatically send the file when exporting.

This is not the best way to resolve this, but you already avoid additional programs.

1- The file must be in the same folder as the sketch (INO file).

2- In "Hostname" should be the same as your ESP-link, use the ping command to test the esp-link, if it is dripping, it must be online.

3- In "AVRDUDE" Need to indicate avrdude.exe folder (full path in my case, IDE in zip file)

Note 1: The commands are tab sensitive, if it does not work try downloading the file.

Note 2: The *ino.eightanaloginputs.hex file, that was generated in the export will be erased, to wait for the next export. Backup: file.hex.

Note 3: To stop using Ctrl+C and confirm. Or close it.

Note 4: Sending data through the serial port made by arduino will cause the esp-link to block, but you can access the esp-link through the browser and reset the arduino at the time of upload. If you need to send data constantly, it may be best to use a second esp-link on ports other than the one used in programming.

Attention: Careful! Can not connect the esp8266 directly to 5V, I used a resistor / zener diode. In a test, by connecting directly to the arduino reset, my esp8266 has been permanently damaged.

file.bat (will run at a command prompt)
Quote
rem Hostname of your esp-link, you can change it
SET Hostname="esp-link"
rem
rem Location of avrdude.exe, need avrdude.conf in this folder too
SET AVRDUDE="D:\Arduino185\hardware\tools\avr\bin\avrdude"
rem
@echo off
:loop
 for %%a in (*ino.eightanaloginputs.hex) do (
    @echo %%a
    @echo Trying to upload ...
    @echo Please wait...
    copy /Y %%a file.hex
    %AVRDUDE% -p atmega328p -c arduino -P net:esp-link:23 -b 57600 -D -U flash:w:file.hex:i
    @echo Deleting hex file...
    del %%a
 )
 timeout /t 5
 goto loop
Result:
Quote
Blink.ino.eightanaloginputs.hex
Trying to upload ...
Please wait...
        1 file (s) copied.
avrdude: ser_drain(): read error: Incorrect parameter. (Previous scketch was blocking the esp-link)

avrdude: ser_drain(): read error: Incorrect parameter.

avrdude: ser_drain(): read error: Incorrect parameter.

avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file "file.hex"
avrdude: writing flash (948 bytes):

Writing | ################################################## | 100% 0.39s

avrdude: 948 bytes of flash written
avrdude: verifying flash memory against file.hex:
avrdude: load data flash data from input file file.hex:
avrdude: input file file.hex contains 948 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 1.96s

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

avrdude: safemode: Fuses OK (E:00, H:00, L:00)

avrdude done.  Thank you.

Deleting hex file...
Please avoid private messages, your question may be someone's answer in the future!

rtek1000

Sorry, the batch file has a problem:

The variable "Hostname" is not used:

Quote
SET Hostname="esp-link"
To use the variable you must use the percentage symbol "%" delimiting the word,

From:
Quote
%AVRDUDE% -p atmega328p -c arduino -P net:esp-link:23 -b 57600 -D -U flash:w:file.hex:i
To:
Quote
%AVRDUDE% -p atmega328p -c arduino -P net:%Hostname%:23 -b 57600 -D -U flash:w:file.hex:i
Please avoid private messages, your question may be someone's answer in the future!

rtek1000

Please avoid private messages, your question may be someone's answer in the future!

Go Up