Go Down

Topic: upload by OTA does not work on Wemos board ATmega2560+ESP8266+32Mb+USB-TTL CH340 (Read 301 times) previous topic - next topic

kock

Hello everybody,

I bought a chinese board Wemos® Mega +WiFi R3 Module ATmega2560+ESP8266 32Mb Memory USB-TTL CH340G. After installing WiFi Link firmware and WiFi Link Library with serial3 connection between Mega2560 and ESP8266, i can interact with ESP administration webpages at Myipnetwork : 80 and i can interact with webserver running inside Mega2560 at Myipnetwork : 81, all in WiFi. I can also upload a new firmware into ESP by OTA using python and Espota.py. So, all that is ok.
But i can't upload a new sketch into Atmega2560 by OTA. Strangely, IDE runs arduinoota.exe and not arduino_mcuota.exe as i expected. WindowsXP Pack3 and IDE 1.8.5 in "portable" version are running in my PC. In my hardware configuration, GPIO4 is wired to control Mega reset pin.
1) Running the upload by IDE. The IDE console displays :
C:\Program Files\Arduino\portable\packages\arduino\tools\arduinoOTA\1.1.1\bin\arduinoOTA
-address 192.168.1.15 -port (upload.network.port)
-sketch c:\docume~1\locals~1\temp\arduino_build_291171/wifiwebserver.ino.hex
-upload(upload.network.endpoint_upload)
-sync(upload.network.endpoint_sync)
-reset(upload.network.endpoint_reset)
-sync_exp(upload.network.sync_return)
Resetting the board
Failed to reset the board, upload failed

2) Running the upload by Python 2.7.11 and Arduino_mcuota.py with Windows line command :
C:\mcuota>python.exe arduino_mcuota.py -f c:\mcuota/test_mega_temp.ino.hex -i 192.168.1.15 -p 80
Sending c:\mcuota/test_mega_temp.ino.hex to host 192.168.1.15
('Connection aborted.', BadStatusLine("''",))

3) Running the upload by Avrdude 6.3 with Windows line command :
C:\avrdude>avrdude -v -v -DV -patmega2560 -Pnet:192.168.1.15:23 -c arduino -b115200 -Uflash:w:test_mega_temp.ino.hex:i
Avrdude : net_open() : Connect failed : target expressly refused

Without knowlegde of the interactions between the different components, without documentations, i hope the community can help me to solve my issues. So thanks for your help. I galley for three months, without finding a solution !!

Daniel

Juraj

how could you? bootloader of the Mega listens on UART0. but it doesn't matter, because the dfu library in WiFi Link is only for 328p with optiboot
You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

kock

I discover this limitation, incredible for me !

So, my questions are now : 

1) dfu library in wifi link is it used whatever the way of uploading ? IDE, Python, Avrdude ?
2) is there another version compatible with Mega2560 ?
3) how can we upload a sketch by OTA into Mega2560 ?
4) is it possible, easy, to modify the Mega bootloader to make it listen on both UART0 (cable case) and UART3 (wifi case) ?

Thanks for your help.

kock

concerning this chapter "Tool for OTA uploading the Atmega sketch is a python script available in arduino.org GitHub repository. To run it, you need Python 2.7, 3.x doesn't work. With python installed you can package the script as exe. Instructions are in the GitHub repository."

I followed these steps and got the executable arduino_mcuota.exe. Running it (way python + arduino_mcuota), i got an error.

Juraj

1) dfu library in wifi link is it used whatever the way of uploading ? IDE, Python, Avrdude ?
2) is there another version compatible with Mega2560 ?
3) how can we upload a sketch by OTA into Mega2560 ?
4) is it possible, easy, to modify the Mega bootloader to make it listen on both UART0 (cable case) and UART3 (wifi case) ?
1) mcuota was written by arduino.org for WiFiLink dfu. I made an ArduinoOTA addition to dfu. I think it is int the version in the zip on the link in the README of the firmware.

2) no

3) with WiFi Link a SPI connection would work for upload too, but the esp8266 on your board has the SPI pins not accessible. Other option is esp-link firmware, but the networking library is not good.

4) don't know. then the USB upload would not work

Running it (way python + arduino_mcuota), i got an error.
did you compile the WiFi Link firmware with the MCU_OTA define?
You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

kock



"  3) with WiFi Link a SPI connection would work for upload too, but the esp8266 on your board has the SPI pins not accessible."

HSPI pins (GPIO12, 13, 14) seem to be unused. I have already made hardware modifications on the board to have a reset controled by GPIO4. I can add a wire connection between ESP HSPI pins and Mega2560 SPI pins.

What about this way to interact by wifi with a webserver running in Mega2560 and upload sketch by OPA ?

My project concerns an full automatic mower. During the first step of my project, i use an Arduino Uno Wifi R3 dev rev. Unfortunately, its ram is too small. I think to use a mega2560 board integrating an ESP8266.

" did you compile the WiFi Link firmware with the MCU_OTA define? " yes, i do.

Juraj

if you make the SPI connection. there is a better firmware and library then WiFi Link.
use WiFiSpiESP. I added OTA support to it.
https://github.com/JiriBilek/WiFiSpiESP/tree/OTA_AVR_ISP_(optional)
You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

kock

I am going to spent two weeks of holidays and I will wire a HSPI link and test solution when i will be back.

Thanks a lot for your help. See you soon for results.
Daniel.

kock

About using GPIO15 for SS in WiFiSpiESP :

In Wemos board, GPIO15 is fixed to ground and you note "If the ESP is booting at the moment when the SPI Master (i.e. Arduino) has the Select line HIGH (deselected), the ESP8266 WILL FAIL to boot!

So that is two reasons not to use GPIO 15. Is it possible to choose a different GPIO ? where is that defined ?

Daniel

Juraj

So that is two reasons not to use GPIO 15. Is it possible to choose a different GPIO ? where is that defined ?
no because the esp8266 is slave, so we must use the SS pin.

the best workaround is to reset the esp8266 after the Atmega sketch started.

https://github.com/JiriBilek/WiFiSpi/issues/6 (read only OP.  the rest of the thread was hijacked)
You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

kock

With my mega 2560 board, i use two shields with SPI. I must use pins like in an UNO board (11,12, 13 and SS).

For the SD card, i set SD.begin(9,11,12,13). In the WiFiSpiESP usage, how can i make the same ?

Juraj

With my mega 2560 board, i use two shields with SPI. I must use pins like in an UNO board (11,12, 13 and SS).

For the SD card, i set SD.begin(9,11,12,13). In the WiFiSpiESP usage, how can i make the same ?

I am sure you do not use 11, 12, 13 for SPI on Mega. because on this pins there is no SPI on Mega. same for SD card. you try to connect the esp8266 over SPI? connect to ICSP header

You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

kock

1) Below is the beginning of my SD sketch running in my Mega2560. You can see that Mega SPI pins is not 50, 51.... in my configuration.

2) i do not use ICSP connector

3) SD card is shorter than Mega (pin 50, 51 .. are not physical accessible)

So, Mega SPI pins can be chosen by users ! SDcard library by Spark allows that. I think it is much better to use 11, 12, 13 because ICSP connector is not always available.


I would like the WiFiSpiESP library to do it too. But i don't know how.

-----------------------------------------------------------------

#define PIN_LED 13
String inString;

#include <Wire.h>
#include <SPI.h>
#include <SD.h>

const int chipSelect = 9;
unsigned long fin;
int i = 0;

void setup()
{
  Serial.begin(115200);
  Serial3.begin(115200);
  Wire.begin();
  pinMode(PIN_LED, OUTPUT);
  while (i <10)
  {
    digitalWrite(PIN_LED, LOW);
    delay (1000);
    digitalWrite(PIN_LED, HIGH);
    delay (300);
  }
  delay(500);
  Serial.println("echange pret");

  while (!SD.begin(chipSelect,11,12,13))        // only avaliable with Spark version
  {
    Serial.println(F("problem with SD card")); 
    delay (1000);
  }
}

void loop()
{
  digitalWrite(PIN_LED, HIGH);

  File dataFile = SD.open("capture.txt", FILE_WRITE);
 

Juraj

You can't write an Arduino sketch if you didn't learn programming. Not the language, but the concepts of programming - algorithms and data types.

Go Up