JAndrassy / ArduinoOTA

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

Support for Arduino DUE (Atmel SAM3X8E ARM Cortex-M3) #26

Open anklimov opened 4 years ago

anklimov commented 4 years ago

Hi! Is it possible to extend OTA support for Atmel SAM3X8E ARM Cortex-M3 ? The architecture is quite similar with already supported platforms and from the first look, it should be possible to do, but lays behind my skills I will appreciated for any kind help or advises

JAndrassy commented 4 years ago

best example of flash operations is for any MCU architecture the eeprom emulation library. https://github.com/PhiJu5/DueFlashStorage

details are in the datasheet of the MCU. https://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-11057-32-bit-Cortex-M3-Microcontroller-SAM3X-SAM3A_Datasheet.pdf

InternalStorage.cpp should be enhanced for ARM MCUs

anklimov commented 4 years ago

Thank you for direction for investigations I've just added SAM3X8E to Internal storage Currently it was compiled successfully.

UPDATE: Now i'm trying to test it

I've find arduinoOTA tool in Arduino IDE distribution, it becomes at least, starting and connecting to lib after update to recent IDE release

(Other OTA flashing tools ether "ESP oriented" (espota) or didn't understand OTA: the usual DUE flasher "bossac" )

So Arduino IDE itself, even not trying to start arduinoOTA, starting bossac instead.

Have you idea to integrate ArduinoOTA to PlatformIO framework? This might be optimal way to use it across all supported platforms.

JAndrassy commented 4 years ago

for Arduino IDE setup arduinoOTA in platform.local.txt similar to this https://github.com/jandrassy/ArduinoOTA/blob/master/extras/avr/platform.local.txt

gcharles81 commented 4 years ago

Hello I would like to know id @anklimov managed to get it working on Arduino DUE Thanks

anklimov commented 4 years ago

@gcharles81 - yes, it working pretty well. PR is not merged here (some cleanup needed, but I still out of time to manage it), but you can try my fork of ArduinoOTA... Also will be good if smbdy find some time to clean & merge DUE OTA to upstream

gcharles81 commented 4 years ago

@anklimov Thanks will use your fork

gcharles81 commented 4 years ago

@anklimov

Hello I am testing your fork and managed to get it working with Arduino IDE & Command line I encountered an issue only with .bin file that has a size of 165kb while it is working fine with a .bin file of 30kb

below is serial output for one successful and one fail upload

Successful Erase flash

Received bytes:30000 Flashing bytes:30000 From:C0000 To:80000 PageSize:256


Failed

Erase flash

Received bytes:130855

anklimov commented 4 years ago

@gcharles81 - thanks for testing, but result is little bit unexpected. In my case, lib working against 139680 bytes binary The maximum firmware size is 50% of flash. Did you use SAM3X8E with 512K flash?

gcharles81 commented 4 years ago

@anklimov Thanks its also strange to me Yes I use SAM3X8E

Today I try ti did a bit deeper and modified in WiFiOTA.cpp the sendHttpResponse function and I add there a Serial.println(status) ; So I get a better understanding what is failing

The message I get on the Serial monitor after the fail is Payload size wrong , I have to google a bit maybe I find something

Open flash for write

Erase flash

Received bytes:126759 Payload size wrong

gcharles81 commented 4 years ago

Solved Issue by using Baud rate of 250000 instead of 115200 , now I can upload sucsessfully

anklimov commented 4 years ago

@gcharles81 - as far as firmware upload going through LAN connection, not thought serial, that is not looks like root cause of failures. May you share more details?

gcharles81 commented 4 years ago

@anklimov - In my case I am using ESP-01 connected via serial to my Arduino DUE and using WiFiEspAT library that is why was failing with 115200 Baud.

Why it was failing I do not know maybe some sort of timeout. Thanks Charles

StybiPL commented 3 years ago

@anklimov Your fork works perfectly on Ethernet Shield V1

If you want to upload sketches directly from Arduino IDE place my platform.local.txt to PREFERENCES_FOLDER\packages\arduino\hardware\sam\1.6.12

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

## arduinoOTA as programmer. add entries with {ip} into programmers.txt
tools.bossac.network_cmd={runtime.tools.arduinoOTA.path}/bin/arduinoOTA
tools.bossac.upload.network_pattern="{network_cmd}" -address {serial.port} -port 65280 -username arduino -password password -sketch "{build.path}/{build.project_name}.bin" -upload /sketch -b
nanitook commented 2 years ago

Any updates on this? Is @anklimov 's fork working for OTA updates from http servers?

anklimov commented 2 years ago

@nanitook - my fork have basic logic, derived from @JAndrassy ' s project - sketch act as http server, not client (you need POST firmware to controller using external routine) Only differences of my fork:

nanitook commented 2 years ago

sketch act as http server, not client (you need POST firmware to controller using external routine)

I'm talking about something like this. Downloading the new sketch from a remote http server and make the upgrade. If that's not possible, the only way to upgrade using OTA is using the arduino IDE?

anklimov commented 2 years ago

Hello The provided example is quite relevant. It should be possible to use InternalStorage to upgrade FW, retrieved from any source. NB - the example using ESP http(s) libs. If you will migrate this on another platform - some effort required here and not every platform is supported https.

Andrey Klimov

8 мая 2022 г., в 22:59, nanitook @.***> написал(а):

 sketch act as http server, not client (you need POST firmware to controller using external routine)

I'm talking about something like this. Downloading the new sketch from a remote http server and make the upgrade. If that's not possible, the only way to upgrade using OTA is using the arduino IDE?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.