jeelabs / esp-link

esp8266 wifi-serial bridge, outbound TCP, and arduino/AVR/LPC/NXP programmer
Other
2.82k stars 720 forks source link

Wemos ATmega 2560 + ESP8266 / Reset uC Error (Console Interface) #477

Closed baervers23 closed 4 years ago

baervers23 commented 4 years ago

Hello Dear esp-link community

first im running Windows 10,

i bought this board and i would like to use esp-link so I can OTA update the ATmega2560. Wemos Mega: https://www.banggood.com/Geekcreit-Mega-WiFi-R3-Module-ATmega2560ESP8266-32Mb-Memory-USB-TTL-CH340G-p-1205437.html?rmmds=search&cur_warehouse=CN schematics in the "documents"-tab

im sure the dip switches are set correctly and espt-RxTx goes to uart3

esp-link version: 3.2.47 alpha is working fine on the esp. WebInterface and RX/TX console work fine.

i think my problems are somehow related:

1) i connected the gpio12 to the reset of the atmega when i hit the Console>reset uC Button in the esplink web-interface i get a message "Error Resetting uc".

But i know for sure that the atmega resets fine, why doesnt the web interface show this correct? 1.1) if i remove the resetpin from esp to arduino the reset uC Button replies: reset ok. but i see no reset - as there is no connection between esp and atmega.

Need help please :)

i wish u a great new year and thank you

uzi18 commented 4 years ago

It should work without any error, it just send impulse to reset pin. Is it possible you have poor wifi connection?

baervers23 commented 4 years ago

wifi is fine. gpio12 is set as reset-pin.

i looked in the source, at least i know where the error is thrown now

when hitting the "reset uC"-button in the webinterfaces, esp-link calls the function

ajaxSpin('POST', "/console/reset",
function(resp) { showNotification("uC reset"); co.textEnd = 0; },
function(s, st) { showWarning("Error resetting uC"); }

which shows "uC reset" when the Status Code of the POST is between 200 and 300 (thats what i get when i havent hooked anything to GPIO12)

and "Error resetting uC" with every other status code. (thats what i get when i connect GPIO12->atmegaReset)

So it seems that the POST fails when i got the GPIO12 of the esp connected to the atmega Reset-Pin,

could the esp some get "disrupted" by the resetting atmega?

I got nothing else connted to the esp or atmega.

uzi18 commented 4 years ago

timeout also could execute warning "error resetting uC" or you have power issues (3V/5V) ?

baervers23 commented 4 years ago

Tried with USB 9V AlKALINE BATTERIE Power supply DC 5V Power supply DC 7V Power supply DC 9V

tve commented 4 years ago

im sure the dip switches are set correctly and espt-RxTx goes to uart3

I would be very surprised if the atmega bootloader listened on something other than uart0, something for you to check...

esp-link version: 3.2.47 alpha is working fine on the esp. WebInterface and RX/TX console work fine.

What do you mean by rx/tx console working? Can you interact with the atmega?

You need to make sure you choose the correct pins in the esp-link pin assignment. Be sure to read your board's user manual carefully. You may have to look at the schematic...

BTW, the board supposedly comes with the arduino bootloader, which is what you need.

baervers23 commented 4 years ago

Heres a Link from Pinout of Wemos ATmega2560 where u can see the switch from uart 3 to uart 0: Link of Shematics i tried switching from uart 3 to uart zero, still not working.

Yeah if i upload "Serial Read" Sketch on Arduino i can type "1" in console and get "1 and enter(ascii) from arduino back. My Board only need 1 pin this is reset pin. i found a guy who get it working with only the gpio pin from esp to reset from arduino. and i can see how arduino is resetting but console says Error

Which is right Bootloader ? Arduino IDE -> Programmer -> Arduino as ISP ?

Debug Console of ESP-LINK i init, mode=STA 228> Wifi uses DHCP, hostname=esp-link 228> "ip": "0.0.0.0" 228> "netmask": "0.0.0.0" 230> "gateway": "0.0.0.0" 233> "hostname": "esp-link" 236> sleep enable,type: 2 238> Httpd init, conn=0x3fff4128 242> No user file system found! 245> Serbridge pins: reset=12 isp=-1 tx_enable=-1 swap=0 259> Reset cause: 4=restart 259> exccause=0 epc1=0x0 epc2=0x0 epc3=0x0 excvaddr=0x0 depc=0x0 259> Flash map 4MB:512/512, manuf 0xEF chip 0x4016 263> ** esp-link v3.2.47-g9c6530d: ready, heap=18960 269> SNTP timesource set to us.pool.ntp.org with offset 0 274> initializing user application 277> Waiting for work to do... 280> mode : sta(ec:fa:bc:5e:d3:bd) + softAP(ee:fa:bc:5e:d3:bd) 286> add if0 288> add if1 289> dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1) 298> bcn 100 306> Wifi auth mode: 0 -> 3 after press Reset uC 2430> scandone 2430> state: 0 -> 2 (b0) 2433> state: 2 -> 3 (0) 2454> state: 3 -> 5 (10) 2454> add 0 2454> aid 1 2454> cnt 3563> 3563> connected with SSID, channel 1 3563> dhcp client start... 3564> Wifi connected to ssid SSID, ch 1 4431> ip:192.168.0.24,mask:255.255.255.0,gw:192.168.0.1 4431> Wifi got ip:192.168.0.24,mask:255.255.255.0,gw:192.168.0.1 4433> host_name = esp-link 4436> server_name = _arduino._tcp.local 2253> Syslog state: SYSLOG_INIT 2353> Syslog state: SYSLOG_INITDONE 2353> SYSLOG host=192.168.0.143:514 *host=0x31 2354> syslog_add_entry: Warning: queue filled up, halted 2357> Syslog state: SYSLOG_HALTED 2360> Syslog state: SYSLOG_READY 2374> Syslog state: SYSLOG_SENDING 2374> Syslog state: SYSLOG_SEND 2376> Syslog state: SYSLOG_SENDING 2376> Syslog state: SYSLOG_SEND 2380> Syslog state: SYSLOG_SENDING 2381> Syslog state: SYSLOG_SEND 2386> Syslog state: SYSLOG_SENDING 2387> Syslog state: SYSLOG_SEND 2392> Syslog state: SYSLOG_SENDING 2394> Syslog state: SYSLOG_SEND 2399> Syslog state: SYSLOG_SENDING 2400> Syslog state: SYSLOG_SEND 2405> syslog_udp_send: error -14 3491> HTTP GET /menu: 200, 126ms, h=10200 3613> HTTP GET /log/dbg: 200, 185ms, h=10624 3975> HTTP GET /log/text: 200, 257ms, h=10304 6277> HTTP GET /log/text: 200, 2344ms, h=11480

At Rebooting i was able to readout a lil bit serial communication esp8266<->atmega trough Microcontroller Console! If i type in "1" he say me recieved "1" 0, 2900ms, h=13800 8471> HTTP GET /console/text: 200, 99ms, h=13792 9357> HTTP GET /console/text: 200, 170ms, h=13792 10047> HTTP GET /console/text: 200, 147ms, h=13792 10960> HTTP GET /console/text: 200, 157ms, h=13792 11832> HTTP GET /console/text: 200, 162ms, h=13960 12621> HTTP GET /console/text: 200, 163ms, h=13976 13443> HTTP GET /console/text: 200, 235ms, h=13976 14247> HTTP GET /console/text: 200, 147ms, h=13976 /console/text: 200, 229ms, h=13976 15231> Wied: dfd 15316> Turning OFF uart log

Last Debug Try: Syslog Server User.Critical - esp-link SYSLOG 2.359156 8 queue filled up, halted User.Notice - esp-link SYSLOG 2.355482 7 syslogserver: 192.168.0.143:514 19653 User.Notice - esp-link esp_link 0.276135 6 Waiting for work to do... User.Notice - esp-link esp_link 0.272754 5 initializing user application User.Notice - esp-link esp_link 0.262429 4 ** esp-link v3.2.47-g9c6530d: ready, heap=15816 User.Notice - esp-link esp_link 0.257708 3 Flash map 4MB:512/512, manuf 0xEF chip 0x4016 User.Notice - esp-link esp_link 0.254809 2 exccause=0 epc1=0x0 epc2=0x0 epc3=0x0 excvaddr=0x0 depc=0x0 User.Notice - esp-link esp_link 0.254423 1 Reset cause: 6=external User.Notice - esp-link SYSLOG 4.359154 7 syslogserver: 192.168.0.143:514 44442 User.Notice - esp-link esp_link 0.279690 6 Waiting for work to do... User.Notice - esp-link SYSLOG 487.243909 1 syslogserver: 192.168.0.143:514 7117

Maybe i found something: `// Generate a reset pulse for the attached microcontroller void ICACHE_FLASH_ATTR serbridgeReset() { if (mcu_reset_pin >= 0) {

ifdef SERBR_DBG

os_printf("MCU reset gpio%d\n", mcu_reset_pin);

endif

GPIO_OUTPUT_SET(mcu_reset_pin, 0);
os_delay_us(2000L); // esp8266 needs at least 1ms reset pulse, it seems...
GPIO_OUTPUT_SET(mcu_reset_pin, 1);

}

ifdef SERBR_DBG

else { os_printf("MCU reset: no pin\n"); }

endif

}`

baervers23 commented 4 years ago

Ok Guys, thank you for your aswers. I got my Problem fixed.

Solution of troubles with: (in my case)

1) Stability ESP & ESP-Link Software: I figured out that Windows (nobody could know that haha) is shit. I have to flash about 10 times for getting working ESP-Link a Access Point i could connect. Since the Windows "Linux Kernel implementation" this could maybe change. I flashed one time with linux kernel and there is a working ESP with ESP-Link! Never flashing more than 1 time to get work. Awesome

2) ESP "Reset uC" Interface button dont working: This was very tricky! While i was trying fix my Problem i was reflashing (before i discovered linux kernel on WIN) i got much connection errors. Then i found out that immediately if i connect ESP lost his RSSI Signal. My error connecting to network was a flash problem but i just realized thats maybe my Problem on "Resetting uC". I knowed the ESP reset my Arduino but got error on OTA & Reset uC because ESP resets together with uC and the access point is restarting to so i get no answer from ESP and the interface "Error Reset uC" appears. But its not my fail and maybe its no ones fail.

3) Why ESP reset Arduino and ESP: I told u i got a "Wemos ATmega 2560 & ESP8266". The ESP is built in and i figured out that both reset pins are combined for the case if reset button onboard is pressed. So the board working perfectly without OTA because this function is was not planned in this board platine. Indifferent which pin will be pulled to ground both modules reset. So maybe this board only needs a rev1.1 or something. 20200111_164305

4) So what to do? What i've done? I soldered one pin from this diode out and put some heatglue on it to isolate. This make it unpossible for ESP to reset. This means without this diode. But thats no Problem. Once u flashed the ESP-LINK you can do Updates and Reset ESP's Interface is possible too. See the big heatglue bubble below the ESP extern pins. 20200111_171529

5) But i dont want to solder a SMD out/ to solder it back if i want to reflash ESP No Problems! Take a diode and clamp pins on it. Connect both resets with the diode between. BUT CAREFUL!!! THE WHITE LINE MUST SHOW TO ARDUINO RESET PIN OR THE ESP WILL BURN OFF AND U MAKE A ARDUINO INSTEAD OF WEMOS Untitled

For me this post can be closed. Thanks to tve & uzi18!

Greetings

tve commented 4 years ago

I'm glad you sorted things out, windows has longer hiccups when it comes to ACKing TCP packets and that causes having in esp-link because of the buffer requirements.

Your analysis of the reset problem looks correct. It's designed with the idea that the ATmega is the master: it can reset the esp8266 by toggling its reset line (I believe it can do that) but the esp8266 can't reset the ATmega. With esp-link you want the inverse behavior.

uzi18 commented 4 years ago

By the way, Mega Core has available bootloader for other uarts numbers. But we need to add support to optiboot part of esp-link first.

baervers23 commented 4 years ago

@tve i dont want to ask why because its windows.. but i was very wondering its happend to esp link firmware but not to original AT firmware. Maybe GITbash was the problem. On WIN i even cant connect hostname.local so i must not wonder. Im happy to get ur awesome software working with this board. but i wonder why nobody else had this problem before ...

@uzi18 This will be awesome then i can reflow the normal diode back :) But i think im not a help for you. I still got problems with coding in arduino ide. But whats the todo? Maybe i can help with little parts so u dont waste time of them :)