JAndrassy / ArduinoOTA

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

Arduino Nano RP2040 Connect #123

Closed rocrail closed 2 years ago

rocrail commented 2 years ago

Hi, trying to use the example WiFi101_OTA brings a link error:

WiFi101_OTA.ino:57: undefined reference to `InternalStorage'
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino Nano RP2040 Connect.

How to solve this?

Used Library version: 1.0.7 (Latest update in the Arduino IDE)

JAndrassy commented 2 years ago

the RP2040 support is not in a released version yet. you have to download a zip from GitHub (use the green "Code" button)

rocrail commented 2 years ago

Thanks, but this brings another error:

Documents/Arduino/libraries/ArduinoOTA/src/utility/rp2_flash_boot.c:25:10: fatal error: RP2040.h: No such file or directory
 #include <RP2040.h> // CMSIS
          ^~~~~~~~~~
compilation terminated.
exit status 1
Error compiling for board Arduino Nano RP2040 Connect.
JAndrassy commented 2 years ago

do you use some older version of the Pico core?

rocrail commented 2 years ago

No, the target is an Arduino Nano RP2040 Connect. So I did not install the Pico Core SDK.

JAndrassy commented 2 years ago

ArduinoOTA for RP2040 doesn't work with the Arduino mbed core.

from README

RP2040 boards with Pico core

rocrail commented 2 years ago

OK. But the Raspberry Pi Pico has no WiFi...

JAndrassy commented 2 years ago

OK. But the Raspberry Pi Pico has no WiFi...

how is that a problem?

rocrail commented 2 years ago

Is not a problem. My issue title is "Arduino Nano RP2040 Connect" The Arduino Nano RP2040 Connect has the same CPU as the Pico. The Pico I have, does not feature any WiFi, so it makes no sense for me to support Pico "Over The Air". Or did I miss something?

JAndrassy commented 2 years ago

nor does MKR Zero have WiFi mkrzero-esp-01S

jmdodd95682 commented 2 years ago

Do you know if the Nano RP2040 Connect (with the mbed core) will ever be supported by ArduinoOTA? Just curious. I'm ripping out the code for supporting OTA and I want to know if its worth preserving the code or not.

Thanks!

JAndrassy commented 2 years ago

RP2040 is supported with the earlephilhower/arduino-pico core with ArduinoOTA library.

With mbed core Nano RP2040 Connect can be OTA updated from IoT Cloud. It stores the binary to file system on the flash and then after reset it is read and applied with the SFU library. You can use the SFU library the same way. I don't have Nano RP2040 Connect so I can't develop OTA upload to mbed file system.

lcoffin commented 1 year ago

Sorry if this feels like being pestered, but any plans on supporting the stock Arduino Nano RP2040 Connect? Without having to mess around with changing the core? I'm happy to support the acquisition of a board if that would help! :)

JAndrassy commented 1 year ago

using arlephilhower/arduino-pico core is not messing up. it is the primary Arduino core for the RP2040. the Arduino mbed core for Nano Connect only supports Nano Connect

lcoffin commented 1 year ago

Sorry, I didn't mean to imply that switching to the Philhower Core was "messing up". Just that the out of the box core that comes with the Nano RP2040 Connect is the mbed one, so having to change the core is an extra step. For microcontroller newbies like myself, with my code written using the mbed core, I'm not particularly eager to go through the steps of switching cores, possibly breaking my existing code. I'd much more prefer finding an OTA solution that works with what I have -- the default core that comes with the board. (And that doesn't require the Arduino IOT cloud.) So far, your OTA library appears to be the closest to a working solution for that, it just doesn't support the RP2040 Connect flash storage -- if I understand the issue correctly.

Alain-Godo commented 11 months ago

Hi everyone!!! Are there any plans on supporting Nano RP2040 Connect with MbedOS in the process?

JAndrassy commented 11 months ago

https://github.com/JAndrassy/ArduinoOTA/blob/master/examples/Advanced/CustomStorageNanoConnect/CustomStorageNanoConnect.ino

lcoffin commented 11 months ago

@Alain-Godo Let me know if you run into any issues. I have it working on a few RP2040 Connects. The WiFi on the board seems to be a bit wonky at times (esp on reconnects) so I've found the OTA can be tricky -- best bet is to try to do the OTA soon after starting the board. You might need to upgrade the arduinoOTA executable over what gets installed usually (though that may have changed since I did it several months ago) and increase the upload timeout. And use the Programmer to do the upload rather than the standard way.

BrettLHolmes commented 11 months ago

@lcoffin great to hear, did you have some working sample code, and anything special to get it working. can you explain what you mean by upgrade the arduinoOTA executable over what gets installed usually.

Alain-Godo commented 11 months ago

@BrettLHolmes Using the Arduino IoT Cloud code philosophy is possible to make the OTA update. I finally did it. I can't share code due to professional issues but I can tell you how if u want. Let me know.

JAndrassy commented 11 months ago

@BrettLHolmes https://github.com/JAndrassy/ArduinoOTA/blob/master/examples/Advanced/CustomStorageNanoConnect/CustomStorageNanoConnect.ino

lcoffin commented 11 months ago

@BrettLHolmes The example code that Juraj linked to should work and should be a good place to start. I started with that code then merged it into my larger project that I'd been working on for a few months prior to adding OTA support.

For upgrading the arduinoOTA executable... I'm not sure if it installs as part of the IDE or as part of a separate package, but there is an executable in:

C:\Users\<UserName>\AppData\Local\Arduino15\packages\arduino\tools\arduinoOTA
(i.e. ...\1.3.0\bin\arduinoOTA.exe)

I renamed that executable to x_arduinoOTA.exe to disable it, then installed the 1.4.1 version (...\1.4.1\bin\arduinoOTA.exe) that is found here: https://github.com/arduino/arduinoOTA/releases/tag/1.4.1 (there may be a more recent version but that's the one I used...). Version 1.4.0 and on supports a longer timeout for the OTA install to succeed. To use this feature, you update the programmers.txt file (more on that below) and add the '-t 30' parameters to the arduinoOTA command used to push the code to the board.

To push your code via OTA, you need to use a "programmer" to do it: image image

To set that up, you need to update the "programmers.txt" file here:

NOTE:
NOTE: Make sure you keep a backup of this!! It gets wiped out when mbed_nano gets upgraded!!
NOTE:
C:\Users\<UserName>\AppData\Local\Arduino15\packages\arduino\hardware\mbed_nano\4.0.6\programmers.txt

Add in sections like the following, using the IP address for your board:

arduinoOTA245.name=Arduino OTA (10.0.0.245)
arduinoOTA245.program.tool=arduinoOTA
arduinoOTA245.program.default=arduinoOTA
arduinoOTA245.cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
arduinoOTA245.program.tool.network=
arduinoOTA245.program.pattern="{cmd}" -t 30 -address {ip} -port 65280 -username arduino -password password -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
arduinoOTA245.ip=10.0.0.245

These changes are not automatically applied to the Arduino IDE! To see the changes in the IDE, once programmers.txt has been updated, you need to delete this folder (you can also rename it to x-arduio-ide if you are worried about what else is deleted...):

C:\Users\<UserName>\AppData\Roaming\arduino-ide

NOT the "Arduino IDE" folder that is also in Roaming.

Then restart the Arduino IDE. You should now see the programmer listed in the Tools > Programmer menu. Select the one for your board, then upload using Sketch > Upload Using Programmer

BrettLHolmes commented 10 months ago

Thankyou @JAndrassy and @lcoffin for your time to respond - i will be attempting this soon because I have a few in production use

BrettLHolmes commented 10 months ago

Hi both A little feedback from me

i have all the configuration done, the ide compiles and starts the upload, it says it completes but then it says failed to flash and exits

i have tried to run from the command line and even extended the timeouts

in looking at a packet trace (for which i have no basis for a good trace) there are a lot of retransmits right at the end befor the flashing fails

it could be something to do with the size of the binary file which i do not know what the max can be or how to calculate. I plan on trying to upload a small sketch because the one i am currently trying to upload may be a little bloated tft display (with some icons)and a 433 mhz radio driver along with mqtt but this may take me a while to try because i lack the time

lcoffin commented 10 months ago

@BrettLHolmes Have you tried the CustomStorageNanoConnect example sketch referenced above?

BrettLHolmes commented 9 months ago

Hi @lcoffin yes i was using that and thats where i was receiving the erro, had no time in the last 2 weeks to investigate further, but the fact it compiled, connected and sent the file was a good start, i will be reviewing more in next few weeks.

ps any ideas on how to see more information on whats goinging on or expected even at a network layer/protocol

BrettLHolmes commented 9 months ago

@lcoffin , i apologies i did not look at your question.

it said was i using the 3xample but i was upkntegrating it into my own sketch which could have cause other issues.

i have since used the example verbatim and still not succeeded.

two issues I do not get the programmer menu to be able to push to the board from the menus I have however pushed the image to the board via the command line which still fails after xonnexting and uploading but it fails toward the end

in the last part there is no clear indication why it failed

BrettLHolmes commented 9 months ago

Hello both

I wanted to let you know that I had success with using the OTA updates Library on the RP2040 Nano there were 2 issues: (and for anyone else trying)

1) the IDE gives an Error with the "programmers.txt" definitions as they are above: i had to change the line : arduinoOTA245.program.default=arduinoOTA ,-- This line did not work gives error ("Upload error: Property 'program.tool.default' is undefined") when trying to upload arduinoOTA245.program.tool.default=arduinoOTA <--Changing to this seems to work

2) I also had to change to running a nightly build of version 2.2.2 of Arduino IDE 2.2 for the mac which also seems to fix the error with the programmers items not appearing from the Tools menu. - A note the above error was even on the released version of the IDE Version 2.2.1

Thank you both for your help and guidance - much appreciated.

BrettLHolmes commented 9 months ago

Adding another note based on further Testing

I was using the Wacthdog timer which creates issues when the watchdog is invoked (seemingly before the script finishes flashing) - I have more work/testing to do if I load the watchdog back in but thought it was worth adding this to the comment (because it seems that the watchdog stays invoked/running across resets (not across power off/on) which i was not aware of and on the RP2040 specifically cannot be disabled once enabled and only a power cycle disables the Watchdog. - More testing on this to come.

JAndrassy commented 9 months ago

arduinoOTA245.program.tool.default=arduinoOTA

README has it since August