Coder Social home page Coder Social logo

arduino_portenta_ota's Introduction

Arduino_Portenta_OTA

Compile Examples Arduino Lint Spell Check

This library allows OTA (Over-The-Air) firmware updates for the Arduino Portenta H7. OTA binaries are downloaded via WiFi and stored on a SD card or on the Portenta H7's QSPI flash storage. Next, all information relevant to the firmware update is stored in non-volatile memory. After a reset the Portenta H7 bootloader accesses this information and uses it to perform the firmware update.

Example

#include <Arduino_Portenta_OTA.h>
#include <WiFi.h>
#include "arduino_secrets.h"
/* ... */
void setup()
{
  if (WiFi.status() == WL_NO_SHIELD)
    return;

  int status = WL_IDLE_STATUS;
  while (status != WL_CONNECTED)
  {
    status = WiFi.begin(SSID, PASS);
    delay(10000);
  }

  Arduino_Portenta_OTA_QSPI ota(QSPI_FLASH_FATFS_MBR, 2);
  Arduino_Portenta_OTA::Error ota_err = Arduino_Portenta_OTA::Error::None;

  if (!ota.isOtaCapable())
    return;

  if ((ota_err = ota.begin()) != Arduino_Portenta_OTA::Error::None)
    return;

  int const ota_download = ota.download("http://downloads.arduino.cc/ota/OTA_Usage_Portenta.ino.PORTENTA_H7_M7.ota", false /* is_https */);
  if (ota_download <= 0)
    return;

  int const ota_decompress = ota.decompress();
  if (ota_decompress < 0)
    return;

  if ((ota_err = ota.update()) != Arduino_Portenta_OTA::Error::None)
    return;

  ota.reset();
}

void loop()
{

}

arduino_portenta_ota's People

Contributors

aentinger avatar andreagilardoni avatar dependabot[bot] avatar facchinm avatar giulcioffi avatar pennam avatar per1234 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

arduino_portenta_ota's Issues

Unable to download large sketch

Hi,

I've hit a problem using the download function which returns a negative result with large sketches. I've done some testing and found the sketch footprint at the 'tipping point' between success and failure is:

Sketch uses 532732 bytes (27%) of program storage space. Maximum is 1966080 bytes.
Global variables use 331976 bytes (63%) of dynamic memory, leaving 191648 bytes for local variables. Maximum is 523624 bytes.

The download for this sketch works but if I then add, let's say, delay(1) then I get a negative return from the download function.

Interestingly, the return code from download is +32756 without the delay(1) and -32768 with the delay added. Is there a 32KB limit in the download code?

Thanks

MCUBoot compatible?

I have tried to use this OTA library with MCUBoot as bootloader but I have the following error message:

Higher version bootloader required to perform OTA.
Please update the bootloader.
File -> Examples -> Portenta_System -> PortentaH7_updateBootloader

Is this library compatible with MCUboot?
If not, is there an example sketch to do OTA with MCUBoot?

Trouble trying to OTA update M4 core

Hi!
I was trying to update M4 core with this library using an Arduino GIGA and it seems that it doesn´t work for me, maybe I'm not doing it in the right way. I want to upload the following sketch (that works fine if I upload it through USB) to both cores:

#include <RPC.h>
String currentCPU() {
  if (HAL_GetCurrentCPUID() == CM7_CPUID) {
    return "M7";
  } else {
    return "M4";
  }
}
void setup() {
  if(currentCPU() == "M7") {
    Serial.begin(9600);
    while(!Serial);
    RPC.begin();
  }
  if(currentCPU() == "M4") {
    RPC.begin();
  }
}
void loop() {
  if(currentCPU() == "M7") {
    String buffer = "";
    while (RPC.available()) {
      buffer += (char)RPC.read();
    }
    if (buffer.length() > 0) {
      Serial.print(buffer);
    }
  }
  if(currentCPU() == "M4") {
    delay(1000);
    RPC.println("Message to M7 from M4");
  }
}

I have done all the steps without any problem and it seems that M7 downloads the code and updates fine. That's not the case for M4. If I upload "OTA on M4" code on M7, it uploads only for M7 but if I upload it on M4, it seems to be not working because it doesn't reset (I can't see Serial monitor because Serial.println() only works for M7, so I deleted the part that asks for Serial to read a response). What I have to do to upload the same sketch into both cores?

Thanks!

Add more documentation for Arduino Giga R1 WiFi

I feel like a there is a lot lacking documentation about the Giga R1 WiFi and how to use it with this library. Also the fact the library is called Portenta OTA makes this even more confusing.

Maybe a new library for the Giga R1 WiFi is needed or a rename of the existing library including more documentation to cover Giga R1 aswell and explain the differences (if any) and how to use it on Giga R1 aswell.

Other stuff like MCUBoot and STM32H747_System might also need more documentation for the Giga R1.

Overall lack of documentation and i would apreaciate if we could do something about it?

ota.update() failed with error code -4 because of name case

I have tried to run the OTA_Qspi_Flash example with the default Arduino Bootloader.

But the process failed with this error:

ota.update() failed with error code -4

I have added some debug logs to understand the issue and in this loop:
https://github.com/arduino-libraries/Arduino_Portenta_OTA/blob/main/src/Arduino_Portenta_OTA.cpp#L111-L113

If I add:

Serial.print("Found file: ");
Serial.println(entry->d_name);

I get this output:

Found file: scratch.bin
Found file: update.bin

So the filename is lowercase instead of uppercase.

By adding a second test case:

else if (String(entry->d_name) == "update.bin")
{
  struct stat stat_buf;
   stat("/fs/update.bin", &stat_buf);
   program_length = stat_buf.st_size;
  return true;
}

The update succeeds.

OTA on M4

Hello,

Is there a way to update flash for M4 core with this OTA library?

Maybe using the _data_offset parameter of the Arduino_Portenta_OTA_QSPI constructor? But which value to use when flash repartition is 1MB per core? (By the way, why 2 us used in the example for the M7 core?)

Or maybe something like M7 core connects to wifi, downloads the M4 ota file to QSPI, then use an RPC call so that M4 core finishes the process to update its flash?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.