Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arduino Mega 2560 - OTA failed #6

Closed
peros550 opened this issue May 12, 2019 · 75 comments
Closed

Arduino Mega 2560 - OTA failed #6

peros550 opened this issue May 12, 2019 · 75 comments

Comments

@peros550
Copy link

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
Copy link
Owner

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
Copy link
Author

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

@JAndrassy
Copy link
Owner

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

yes.

@peros550
Copy link
Author

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
Copy link

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
Copy link
Owner

JAndrassy commented Apr 22, 2020

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
Copy link

VitorCSoares commented Apr 22, 2020 via email

@JAndrassy
Copy link
Owner

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
Copy link

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
Copy link
Owner

JAndrassy commented Apr 22, 2020

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
Copy link

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
Copy link

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
Copy link
Owner

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

@VitorCSoares
Copy link

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
Copy link

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
Copy link
Owner

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

@VitorCSoares
Copy link

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
Copy link

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.sync_return}
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
Copy link
Owner

JAndrassy commented Oct 28, 2020

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
Copy link

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
Copy link
Owner

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
Copy link

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

@VitorCSoares
Copy link

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

@VitorCSoares
Copy link

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
Copy link
Owner

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

@VitorCSoares
Copy link

using your code extracted in May2020

@JAndrassy
Copy link
Owner

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

@VitorCSoares
Copy link

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

@matiasAS
Copy link

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

@matiasAS
Copy link

@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
Copy link

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
Copy link

@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?

@JAndrassy
Copy link
Owner

@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?

see the Advanced examples. they show how to use InternalStorage to store and apply the update binary.

@matiasAS
Copy link

@JAndrassy When changing the bootloader, is compatibility with any library lost or is everything the same?

@JAndrassy
Copy link
Owner

@JAndrassy When changing the bootloader, is compatibility with any library lost or is everything the same?

no other library cares about bootloader. bootloader is only there to write the application to flash memory.

@matiasAS
Copy link

@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?

see the Advanced examples. they show how to use InternalStorage to store and apply the update binary.

from the browser with the arduino mega I mean this:

image

that's in an esp32, can it be done in arduino mega, upload the sketch from a url?

@matiasAS
Copy link

@JAndrassy When changing the bootloader, is compatibility with any library lost or is everything the same?

no other library cares about bootloader. bootloader is only there to write the application to flash memory.

ok, thanks

@JAndrassy
Copy link
Owner

@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?

see the Advanced examples. they show how to use InternalStorage to store and apply the update binary.

from the browser with the arduino mega I mean this:

that's in an esp32, can it be done in arduino mega, upload the sketch from a url?

where do you see a problem?

@matiasAS
Copy link

My question is because with at least 2 esp32 it has happened to me that when selecting the port (the ip of the esp32) to upload the sketch it does not appear even though it is connected. In order for it to appear again, I must connect it with the usb cable, upload the sketch and there it appears. So that there is that problem, it does not assure me that I can update the sketch if I require it remotely and that is why I think it is much better and safe to do it from a url like the image, because having a connection with the arduino / esp32, if there will be access to upload the sketch binary

do you understand me?

@matiasAS
Copy link

I want to make a clarification, the esp32 that does not appear to me is connected to a wifi that is created in a raspberry as an access point in a subnet. The ip of the raspberry is 192.168.10.80 and the ip of the esp32 is 192.168.80.10, and that esp32 with the ip 192.168.80.10 does not appear in the list of ports

@matiasAS
Copy link

hello @JAndrassy , I have burned the optiboot bootloader in the arduino mega, loaded my sketch and everything fine, what is the difference between ArduinoOTA.poll () and ArduinoOTA.handle ()?

@JAndrassy
Copy link
Owner

hello @JAndrassy , I have burned the optiboot bootloader in the arduino mega, loaded my sketch and everything fine, what is the difference between ArduinoOTA.poll () and ArduinoOTA.handle ()?

the WiFi101OTA library which I extended to ArduinoOTA had poll().
ESP ArduinoOTA libraries have handle() so I added it as alias of poll()

@Trilife
Copy link

Trilife commented May 6, 2022

Hello @JAndrassy;

So, I'm having some setup related issues, which popped up after I rebuilt my harddrive and reinstalled the Arduino IDE environment. I now have both, V1.8.13 and the newer V2.0.0.0 rc6.

My arduino Mega 2560 has the optiboot loader burnt from before and I already installed your version of the AVR boards in a subdirectory of Documents/Arduino/hardware/my_boards-master (next to the standard my_boards).

Programming via USB works well.

The Network port shows up as well.

When I try to upload files to the 2560, it asks for a password (I tried leaving it blank, "password" and "myoldpassword") and then I get the following message:
Resetting the board Failed to reset the board, upload failed

Scanning through this thread from the beginning, I see various references to platform.tx and platform.local.txt.

I scanned my disc for these files and they show up in your my_boards-master, as well as in the Program Files (x86) (these seem older though, platform.local being yours, platform being generic).

Now, I vaguely remember having put my username and password in one of these files, but I cannot remember where that file was placed and searching for it in my Gdrive backup of the previous build produces nothing.

So, here are a couple of questions for you, please:

1- in which file do I need to put my username and password in order to secure the upload process?

2- where do I need to place this/these files, in order for the upload to work via Network

3- do we really need to duplicate all these files in Program Files(x86) and in the Document paths?

#3 reminds me of something: during the compile process, I do get a couple of references to duplicate libraries:

Multiple libraries were found for "Ethernet.h" Used: C:\Users\jr\Documents\Arduino\libraries\Ethernet Not used: C:\Program Files (x86)\Arduino\libraries\Ethernet Multiple libraries were found for "SD.h" Used: C:\Users\jr\Documents\Arduino\libraries\SD Not used: C:\Program Files (x86)\Arduino\libraries\SD
no refernce to multiple platform and platform.local though.

Thanks Juray!

@Trilife
Copy link

Trilife commented May 6, 2022

Hello @JAndrassy;

So, I'm having some setup related issues, which popped up after I rebuilt my harddrive and reinstalled the Arduino IDE environment. I now have both, V1.8.13 and the newer V2.0.0.0 rc6.

My arduino Mega 2560 has the optiboot loader burnt from before and I already installed your version of the AVR boards in a subdirectory of Documents/Arduino/hardware/my_boards-master (next to the standard my_boards).

Programming via USB works well.

The Network port shows up as well.

When I try to upload files to the 2560, it asks for a password (I tried leaving it blank, "password" and "myoldpassword") and then I get the following message: Resetting the board Failed to reset the board, upload failed

Scanning through this thread from the beginning, I see various references to platform.tx and platform.local.txt.

I scanned my disc for these files and they show up in your my_boards-master, as well as in the Program Files (x86) (these seem older though, platform.local being yours, platform being generic).

Now, I vaguely remember having put my username and password in one of these files, but I cannot remember where that file was placed and searching for it in my Gdrive backup of the previous build produces nothing.

So, here are a couple of questions for you, please:

1- in which file do I need to put my username and password in order to secure the upload process?

2- where do I need to place this/these files, in order for the upload to work via Network

3- do we really need to duplicate all these files in Program Files(x86) and in the Document paths?

#3 reminds me of something: during the compile process, I do get a couple of references to duplicate libraries:

Multiple libraries were found for "Ethernet.h" Used: C:\Users\jr\Documents\Arduino\libraries\Ethernet Not used: C:\Program Files (x86)\Arduino\libraries\Ethernet Multiple libraries were found for "SD.h" Used: C:\Users\jr\Documents\Arduino\libraries\SD Not used: C:\Program Files (x86)\Arduino\libraries\SD no refernce to multiple platform and platform.local though.

Thanks Juray!

Forgot to say that I did copy platform.local.txt from the extras in the library to the my_boards-master/avr/ next to platform.txt

@JAndrassy
Copy link
Owner

JAndrassy commented May 6, 2022

https://github.com/JAndrassy/ArduinoOTA#arduinoota-tool-returns-failed-to-reset-the-board-upload-failed

Forgot to say that I did copy platform.local.txt from the extras in the library to the my_boards-master/avr/ next to platform.txt

my_boards it is not the right place

@Trilife
Copy link

Trilife commented May 6, 2022

https://github.com/JAndrassy/Arduino

OTA#arduinoota-tool-returns-failed-to-reset-the-board-upload-failed

Forgot to say that I did copy platform.local.txt from the extras in the library to the my_boards-master/avr/ next to platform.txt

my_boards it is not the right place

Hi Juraj;

Not quite sure what you mean by "my_boards it is not the right place".

I'm guessing you don't mean the my_boards.png file...

I currently have the following setup:
Documents/Arduino/hardware/my_boards the /avr subdirectory contains boards, platform.local, platform and programmers.

Documents/Arduino/hardware/my_boards-master contains what I downloaded from your github.

I also replaced "arduino" and "password" with my values in both platform and platform.local. And ArduinoOTA.begin() has the same values.

Do you mean by your comment that I should replace the my_boards folder with the contents of my_boards-master?

Cheers

@Trilife
Copy link

Trilife commented May 6, 2022

Follow up:

After I looked closer into the preferences, I ended up placing platform.local into
Users/me/AppData/Local/Arduino15/packages/arduino/hardware/avr/1.8.5/.

I also had to return the platform and platform.local to remove my custom username/password and return it to arduino/password.

It now is WORKING with Arduino IDE 1.8.13! Thanks for that Juraj.

It still is failing to upload with Arduino IDE 2.0.0. rc6 with the following error:
`Compilation complete.
avrdude: ser_open(): can't open device "192.168.10.249": The system cannot find the file specified.

Upload error: Failed uploading: uploading error: exit status 1
`

Follow-up questions:

1- I see hardware/avr folders in multiple locations: Under Documents/... and AppData/... and Programs(x86)... Is this because of multiple installs 1.8.13 and 2.0.0. rc6?

2- Can I delete some of these, or is it better to do an uninstall and potentially manually remove all things ARDUINO before attempting a new install?

Thanks

@JAndrassy
Copy link
Owner

arduino/arduino-ide#740

  1. AVR platform is bundled with IDE 1 installations. it is used until you update it. then it is in then Arduino15 folder
  2. the Arduino15 folder is used by all Arduino IDE installations

@Trilife
Copy link

Trilife commented May 9, 2022

Thanks Juraj;

I have things working for Arduino 1.8.13 now. It asks me for my password and properly uploads it to the Mega2560 via ethernet. (also via com3/USB)

The Arduino 2.0.0 rc6 is still refusing to upload via Ethernet. It works via USB

I tried to use the <> code brackets, but for some reason it didn't want to take them. error messages between __________ lines instead. Sorry.

Ethernet Upload Error message:


Compilation complete.
"C:\Users\jr\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\jr\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega2560 -carduino "-P192.168.10.249" -b115200 -D "-Uflash:w:C:\Users\jr\AppData\Local\Temp\arduino-sketch-D14456268B98148D7304BC273534F216/A00_Orientes_V21.ino.hex:i"

avrdude: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

     System wide configuration file is "C:\Users\jr\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

     Using Port                    : 192.168.10.249
     Using Programmer              : arduino
     Overriding Baud Rate          : 115200

avrdude: ser_open(): can't open device "192.168.10.249": The system cannot find the file specified.

avrdude done. Thank you.

Upload error: Failed uploading: uploading error: exit status 1


I'm using AVR ISP as programmer (same in Arduino 1.8.13, btw).

Any ideas?

Thanks Juraj!

@JAndrassy
Copy link
Owner

why does it upload with avrdude to IP? it is a wrong command. it should use arduinoOTA upload tool.

@Trilife
Copy link

Trilife commented May 10, 2022

Hi Juraj;

Looking at the choice of programmers both in 1.8.13 and 2.0.0, I can see two:
Arduino OTA ( 192.168.1.104) and
Arduino OTA (192.168.10.102)

My LAN is on 192.168.10.XXX, with my desktop used for programming at x.109.

I have no idea from where the IDE got these IP addresses for the Arduino OTA.

Thanks

@JAndrassy
Copy link
Owner

IDE 2 always uses the arduino15 folder for platforms. did you copy platform.local.txt there?

@Trilife
Copy link

Trilife commented May 10, 2022

IDE 2 always uses the arduino15 folder for platforms. did you copy platform.local.txt there?

Yes I did. Here is the contents.
`

This configuration file supports the general ArduinoOTA library https://github.com/jandrassy/ArduinoOTA

Create output (bin file)

recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" -O binary {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin"

tools.avrdude.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
tools.avrdude.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password "{network.password}" -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b

arduinoOTA as programmer. add entries with {ip} into programmers.txt

tools.arduinoOTA.cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
tools.arduinoOTA.program.params.verbose=
tools.arduinoOTA.program.params.quiet=
tools.arduinoOTA.program.pattern="{cmd}" -address {ip} -port 65280 -username arduino -password password -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b`

I did find the x.1.104 etc in the programmers file in Documents/Arduino. When I changed it to 10.249 (Arduino IP address) and 10.190 (my desktop IP), the 1.8.13 shows the change, but not 2.0.0.

Do I need to replace the programmers file in Arduino15 as well, or append the arduinoOTA elements?

Thanks

@JAndrassy
Copy link
Owner

IDE 2.0 rc 5 had a different error with OTA upload. I check the rc 6

@Trilife
Copy link

Trilife commented May 10, 2022

Ok, Thanks.

In the meantime, I'm thinking of removing both 1.8.13 and 2.0.0 and deleting all references to Arduino from Program Files (x86), Arduino15 and Documents. Then starting from scratch. Does that make sense?

I had the Arduino IDE Windows app installed at one point too. This had caused problems with ArduinoOTA in the beginning. You and I had a ton of back and forths until I finally dumped the Windows app. I'm guessing some of those extra files are a remnant of the App.

@JAndrassy
Copy link
Owner

JAndrassy commented May 11, 2022

so the IDE 2 has a different OTA configuration in platform.txt and boards.txt
I made a commit in my_boards JAndrassy/my_boards@259ee60
and it looks like it doesn't need platform.local.txt from extras in avr package if you use my_boards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants