Update installed code by downloading .bin file from web server via Ethernet connection on Nano RP2040 Connect with mbed ? #245
-
By cobbling together bits from the examples for this library I thought I was going to pull this off: downloading an update .bin file from a web server to update a Nano RP2040 Connect running mbed and using an SPI-connected W5500 Ethernet shield for network connection. Should this be possible to do? Or are there obstacles/conflicts that make this particular combination -- NanoRP2040/mbed/SPI/ethernet/etc -- a non-starter? I combined the download part of a download example with the "custom storage" example for the Nano RP2040 to get a file from a web server and save it to the on-board flash storage. Almost everything appears to be working: I get the .bin file and write it to flash without any errors, and then successfully restart/reboot the system, but it continues to run the existing sketch, not the new one it downloaded. The download examples (and the ArduinoIoTCloud library which the CustomStorage example mentions) all perform some kind of .apply() and/or reset/reboot after downloading and saving the file. I've tried calling mbed_watchdog_trigger_reset(), NVIC_SystemReset(), and a reset method given here: https://gershnik.github.io/2024/02/12/rp2040-prog-reset.html -- all of these successfully reset/restart/reboot the system, but when it comes up it runs the same code it was already running, not the downloaded update. I looked at the SFU library but its apply() method is empty (only a return statement), and the .begin() method looks like it clears/reformats the area where the download goes; I tried calling each of those (in separate trials and together) but got the same result -- the existing sketch restarted. I feel like the part I'm missing is, having downloaded the new .bin file to flash, somehow causing it to be loaded into the working-program area where it will be executed on restart. Or perhaps I need to reconfigure things before restarting, like turning off the ethernet SPI or something? Or perhaps I'm not downloading the correct file? When I "Export Compiled Binary" I wind up with several files: .bin, .elf, .uf2, .elf.uf2, .hex, .map... I've been using the .bin version because the FileSystemStorage.h file in the CustomStorage example writes to "/ota/UPDATE.BIN", and the ArduinoIoTCloud library writes a compressed version of the .bin file. Is that the correct file to download for an update? If it's not obvious already, all of this is pretty new terrain for me, so apologies if I'm expressing things unclearly or overlooking some obvious obstacle or solution. Thanks in advance for any assistance or clarification. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 16 replies
-
PS -- I did do this step mentioned in the README: "platform.local.txt from extras folder has to be copied into boards package installation folder. On my Ubuntu system, that meant copying from here: I also noted the instruction "For RP2040 the bundled ArduinoOTA library must be deleted" but I did not find any ArduinoOTA other than the one installed when I asked for it in the IDE. |
Beta Was this translation helpful? Give feedback.
-
This ArduinoOTA library only works with the Pico Core (and the ArduinoOTA in Pico Core must be deleted). The CustomStorage example is for the Mbed Core, which has the SFU library to boot load from file system in flash memory. |
Beta Was this translation helpful? Give feedback.
does the CustomStorageNanoConnect example work for you?
do both sketches, the running and the update have the SFU?