JAndrassy / ArduinoOTA

Arduino library to upload sketch over network to Arduino board with WiFi or Ethernet libraries
GNU Lesser General Public License v2.1
438 stars 89 forks source link

Arduino Mega 2560 - OTA failed #6

Closed peros550 closed 5 years ago

peros550 commented 5 years ago

I tried to push a new firmware using the Arduino GUI on a Arduino Mega 2560 board. I had already flashed a code with your example, therefore I found a new network port on the GUI successfully.

During the OTA flashing a new window came up asking my password. I gave the correct password but then the password window came up again and again like I had given a wrong password.

It looks that for me the process cannot complete successfully.

In the Arduino GUI there was the following error message (in orange)

Resetting the board
Failed to reset the board, upload failed
Resetting the board
Failed to reset the board, upload failed
Resetting the board
Failed to reset the board, upload failed
JAndrassy commented 5 years ago

tools.avrdude.upload.network_pattern is not set right. Do you try it with official AVR package? it will not work. Did you change the bootloader? https://github.com/jandrassy/ArduinoOTA#atmega-support I recommend to use "my_boards" custom hardware configuration to burn the special bootloader and to use the board with it.

peros550 commented 5 years ago

many thanks for your quick response. Is it mandatory to switch bootloader?

JAndrassy commented 5 years ago

many thanks for your quick response. Is it mandatory to switch bootloader?

yes.

peros550 commented 5 years ago

I will try it after 2 weeks time and let you know. I will close the issue for now and if I need more help I will get back to you. Many thanks for your work,

VitorCSoares commented 4 years ago

Hi all,

What was the solution for this? I think I'm having the exact same problem. I already burn a new bootloader. Now I'm receiving the following log error message (after introducing the password)

C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/arduinoOTA -address 192.168.1.177 -port 65280 -username arduino -password password -sketch C:\Users\Skine\AppData\Local\Temp\arduino_build_137800/OTA_Ethernet_v01_20200421.ino.bin -upload /sketch -b flag provided but not defined: -username Usage of C:\Program Files (x86)\Arduino\hardware\tools\avr\bin\arduinoOTA: -address string The address of the board (default "localhost") -port string The board needs to be listening on this port (default "80") -q Quiet flag -reset string Upload endpoint -sketch string Sketch path -ssl string SSL flag -sync string Upload endpoint -sync_exp string sync expected return code in format code:string -upload string Upload endpoint -v Verbose flag (default true) -version Prints program version

JAndrassy commented 4 years ago

you have old version of arduinoOTA upload tool. I see you have one copied in sketches folder's hardware subbofolder. delete it and/or install a new version of AVR boards package

VitorCSoares commented 4 years ago

Hi,

I already tried multiple approaches, so I would like to ask for your help in the next steps. I always have some difficulty with copy the platform.local.txt file step.

Thank you


De: Juraj Andrássy notifications@github.com Enviado: 22 de abril de 2020 05:05 Para: jandrassy/ArduinoOTA ArduinoOTA@noreply.github.com Cc: VitorCSoares Skiner_vitor@hotmail.com; Comment comment@noreply.github.com Assunto: Re: [jandrassy/ArduinoOTA] Arduino Mega 2560 - OTA failed (#6)

you have old version of ArduinoOTA. I see you have one copied in sketches folder's hardware subbofolder. delete it and/or install a new version of AVR boards package

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/jandrassy/ArduinoOTA/issues/6#issuecomment-617552189, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AISW3EJUJOPTERNYFCLY25DRNZ3IFANCNFSM4HMJ6E3Q.

JAndrassy commented 4 years ago

ok. not very efficient way, but it did install the latest upload tool because it is part of the AVR boards package installed with the IDE. now the AVR boards package is in C:\Program Files (x86)\Arduino\hardware\arduino\avr (but if you update or downgrade the AVR boards package it will be installed in %userprofile%\AppData\Local\Arduino15\packages\)

VitorCSoares commented 4 years ago

Yes, Now I have the installation of the tool again in the C:\Program Files (x86)\Arduino\hardware\arduino\avr. I already have one Mega 2560 with Optiboot bootloader.

I copied my_boards to the hardware folder and I can select the board ( Optiboot ) in the IDE.

I can upload the sketch to my Mega 2560 board through USB but still the same problem when using OTA. Resetting the board Failed to reset the board, upload failed

when introducing "password"

JAndrassy commented 4 years ago

the upload tool sometimes times-out even if the update is successful.

you can add in WiFiOTA.cpp to sendHttpResponse

  Serial.print("OTA upload response: ");
  Serial.println(status);

to see if the upload was successful.

VitorCSoares commented 4 years ago

I got the solution. It was already presented by you multiple times. just copy the platform.local.txt to C:\Program Files (x86)\Arduino\hardware\arduino\avr. We will end with platform.txt and platform.local.txt in the same folder. Thank you :)

I did not understand your last comment about WiFiOTA.cpp

VitorCSoares commented 4 years ago

Hi Jandrassy,

After multiple success tests now I'm having the following problem:

Connecting to board ... done Uploading sketch ... done Flashing sketch ... done Error flashing the sketch: Error flashing the sketch:

Can you help me please?

JAndrassy commented 4 years ago

does it update the sketch? did you try to add the status print?

VitorCSoares commented 4 years ago

No. The Sketch remains the same.

Can you give a more detailed explanation of add the status Print? I did not get your point above in the previous message.

VitorCSoares commented 4 years ago

I added the Status Code in the WiFiOTA.cpp. I'm connecting the board via USB to check the Serial Port and I'm doing the update via IP address.

I'm getting "Unauthorized" as Status. The prompt to insert the password is not appearing now.

Thank you

JAndrassy commented 4 years ago

try to set the password in the command in platform.local.txt

VitorCSoares commented 4 years ago

Hi,

It's saying Unauthorized, but the problem seems to be related to the Ethernet Switch I'm using. If I connect the board (via ethernet) to the same switch my computer is connected I can upload the code. If I connect the board (via ethernet) to another switch that is connected to the switch my computer is connected I can't see the board Port nether reach it through Program upload.

Maybe one of the switches is blocking some specific port needed.

Thank you

Fristi10 commented 3 years ago

HI,

I have read and followed previous comments:

  1. added my-boards to Arduino hardware
  2. burned the Optiboot to the Arduino Mega 2560
  3. copied platform.local.txt to /Users/bart/Documents/Arduino/hardware/my_boards/avr so I have a platform.local.txt and a platform.txt file in the samen directory.
  4. changed the password in platform.local.txt to the one in the sketchfile.

But I still get this error _Users/bart/Library/Arduino15/packages/arduino/tools/arduinoOTA/1.3.0/bin/arduinoOTA -address 192.168.0.150 -port {upload.network.port} -sketch /var/folders/xm/r4mp8nvn7xd7_mrcm7qfhq2r0000gn/T/arduino_build_187044/sketch_oct27a.ino.hex -upload {upload.network.endpoint_upload} -sync {upload.network.endpoint_sync} -reset {upload.network.endpoint_reset} -sync_exp {upload.network.syncreturn} Resetting the board Failed to reset the board, upload failed

Screenshot 2020-10-28 at 18 45 26

Is their a way I can check if the Optiboot loader is burned correctly? What other checks can I do to know what the problem can be?

JAndrassy commented 3 years ago

platform.local.txt goes to 'official' AVR boards package in IDE installation folder or in Arduino15 folder

platform.txt in my_boards is the same as platform.local.txt, but IDE doesn't read the OTA command here. (I use Exlipse Sloeber and it uses the OTA command from platform.txt from my_boards)

Fristi10 commented 3 years ago

I have moved platform.local.txt to Arduino15, restarted the ide and arduino but still the same error. Any other suggestions i can try?

JAndrassy commented 3 years ago

I have moved platform.local.txt to Arduino15, restarted the ide and arduino but still the same error. Any other suggestions i can try?

to Users/bart/Library/Arduino15/packages/arduino/hardware/avr?

Fristi10 commented 3 years ago

My mistake, in the correct folder as you specified it works, thnx!

VitorCSoares commented 3 years ago

Hi @jandrassy. I realized when I do the upload of the code using the programmer I get a success message although the code remains the same. Did you faced this behaviour already?

Thank you

JAndrassy commented 3 years ago

https://github.com/jandrassy/ArduinoOTA#upload-returns-ok-but-the-sketch-is-not-replaced

VitorCSoares commented 3 years ago

Does that mean I need to burn a new bootloader again? If I understood correctly this copy_flash_pages function is not present in the bootload I loaded in the past. Am I understanding this correctly?

Sorry for the detailed question.

JAndrassy commented 3 years ago

sorry, the discussion in this issue is too long to read it again. how do you burn the bootloader?

VitorCSoares commented 3 years ago

using your code extracted in May2020

JAndrassy commented 3 years ago

you meant my_boards. then the bootloader should be OK. do you use watchdog in your sketch?

VitorCSoares commented 3 years ago

no Watchdog. Can you point me how to add it?

JAndrassy commented 3 years ago

no Watchdog. Can you point me how to add it?

I asked because it could reset the MCU before copy_flash_pages finished

try to burn the bootloader again. I have no better idea

matiasAS commented 3 years ago

Hello @jandrassy

Sorry to ask again for the same. I have copied the platforms.local.txt file to Arduino / hardware / arduino / avr and got this result: Connecting to board ... done Uploading sketch ... done Flashing sketch ... Error flashing the sketch no protocol:

What I have not done because I understand well how to do it is burn the optiboot bootloader, could you help me please?

I tried to copy the avr folder inside my_board to the original folder, arduino mega optiboot appears but no programmer, and the Arduino library does not recognize Arduino.h

Extra information: Operating system: Linux, Ubuntu 16 Arduino mega

Thank you I am waiting for you to help me

JAndrassy commented 3 years ago

do you have the folder structure in sketchbook's hardware folder like this "hardware/my_boards/avr"?

matiasAS commented 3 years ago

@jandrassy yes I from Chile

structure folder: image

list of boards image

platform.local.txt into Arduino/hardware/arduino/avr:

image

result upload code: image

regards

matiasAS commented 3 years ago

@jandrassy no, sorry

my sketchbook is this:

image regards

matiasAS commented 3 years ago

after change sketchbook path as this:

image

i need copied and install libraries: arduinoota, arduinojson and pubsubclient (mqtt)

results:

image

@jandrassy It is the same original error, I think I am missing an intermediate step which is to burn the bootloader

can you help me with this please?

JAndrassy commented 3 years ago

your sketchbook folder is /home/Matias/Arduino and this should be in Preferences. so the location of my_boards folder is right (/home/Matias/Arduino/hardware/my_boards) do you have avr subfolder in my_boards?

matiasAS commented 3 years ago

@jandrassy yes I have cloned your repository https://github.com/jandrassy/my_boards.git and copied the my_boards folder inside the hardware folder

image

JAndrassy commented 3 years ago

select "Arduino Mega 2560 (Optiboot)" in Tools menu. why does your screenshot show ESP32 board selected?

btw:what is the libraries folder in my_boards?

matiasAS commented 3 years ago

image

Arduino Mega 2560 (Optiboot) does not appear

JAndrassy commented 3 years ago

scroll the Tools Board menu down to the end.

or update the IDE to 1.8.15 to have boards grouped by package

matiasAS commented 3 years ago

I have checked and nothing that says optiboot. It only appears if I replace the avr folder inside my_boards with the avr in hardware / arduino / avr, but if I do that I lose the programmers, none appear. Also it does not recognize the Arduino.h library

Do you speak Spanish?

matiasAS commented 3 years ago

@jandrassy after update to 1.8.15:

image

matiasAS commented 3 years ago

@jandrassy I have managed to get the optiboot boards to appear, but when loading the sketch I get the following result

image

timeout

matiasAS commented 3 years ago

There is the possibility that we speak (writing because I do not speak English), by skype, whatsapp, email, more direct so as not to fill out this issue, I have more questions that I would like to ask you

JAndrassy commented 3 years ago

I don't speak Spanish you have to burn the bootloader (Optiboot) to be able to upload with Optiboot

matiasAS commented 3 years ago

@jandrassy Can you please tell me how do I burn the bootloader? And another very important thing, can I go back to the original?

JAndrassy commented 3 years ago

https://www.arduino.cc/en/hacking/bootloader https://www.arduino.cc/en/Tutorial/BuiltInExamples/ArduinoISP

matiasAS commented 3 years ago

@jandrassy I see that the process is not so easy and since I have arduinos in production which is the ones I would like to load the bootloader to, I think it is not convenient for something to fail and run out of arduino. Thank you very much for your help, but I will keep it in mind.

matiasAS commented 3 years ago

one more thing, I have an arduino mega that when loading the sketch appears timeout, that is a problem with the bootloader ?, and I have another that the usb port is not recognizable

matiasAS commented 3 years ago

@jandrassy I took a risk with a mega arduino that I thought was dead and done, I see that it is not difficult. I give you a challenge: load the sketch binary from the browser in arduino mega like this for esp32: https://lastminuteengineers.com/esp32-ota-web-updater-arduino-ide/amp/

can it be done in e arduino mega?