gshokk
September 9, 2023, 10:40pm
1
Hello, I need to purchase an Arduino Giga R1 WiFi. Does the board currently support updates through the Arduino IoT Cloud? I've noticed that the Arduino R1 has the same processor as the Portenta H7, but the H7 officially supports OTA updates while the Arduino R1 does not.
Additionally, does OTA with IoT Cloud work even if the two devices (PC and Arduino) are on different WiFi networks?
(sorry for my not perfect english)
Hi.
Technically the Giga can support, but is a coin in the air.
The OTA documentation dont says nothing about the GIGA, so, officialy i think GIGA cant upload sketch usingOTA
pennam
September 11, 2023, 9:24am
3
@gshokk OTA is supported by the GIGA R1 and yes OTA works even if the two devices are on different WiFi networks. If you want to try OTA on the GIGA r1 you can use this example:
/*
* This example demonstrates how to use to update the firmware of the Arduino Portenta H7 using
* a firmware image stored on the QSPI.
*
* Steps:
* 1) Create a sketch for the Portenta H7 and verify
* that it both compiles and works on a board.
* 2) In the IDE select: Sketch -> Export compiled Binary.
* 3) Create an OTA update file utilising the tools 'lzss.py' and 'bin2ota.py' stored in
* https://github.com/arduino-libraries/ArduinoIoTCloud/tree/master/extras/tools .
* A) ./lzss.py --encode SKETCH.bin SKETCH.lzss
* B) ./bin2ota.py PORTENTA_H7_M7 SKETCH.lzss SKETCH.ota
* 4) Upload the OTA file to a network reachable location, e.g. OTA_Usage_Portenta.ino.PORTENTA_H7_M7.ota
* has been uploaded to: http://downloads.arduino.cc/ota/OTA_Usage_Portenta.ino.PORTENTA_H7_M7.ota
* 5) Perform an OTA update via steps outlined below.
*/
/******************************************************************************
* INCLUDE
******************************************************************************/
This file has been truncated. show original
2 Likes
Hi,
I have some questions regarding OTA for Giga R1 that relate to this topic.
I have a solution with both M7 and M4 running so an OTA needs to update both, or at least I need to be able to OTA the M7 or OTA the M4 independently.
Where are the details for the Giga R1 boot loader? I see in the Portenta H7 OTA example it writes storage type and data offset to some registers. I assume these are part of the boot loader "API"? Is there some documentation for this?
Can you use the external flash on the Giga for a firmware update?
pennam
February 8, 2024, 7:56am
6
@schnoberts
I have a solution with both M7 and M4 running so an OTA needs to update both, or at least I need to be able to OTA the M7 or OTA the M4 independently.
You can take a look here:
arduino-libraries:main
← pennam:m4_ota
opened 02:28PM - 15 May 23 UTC
Constraints:
* only 1MB M7 + 1MB M4 flash split is supported ([:eyes:](https:/… /github.com/arduino/mcuboot-arduino-stm32h7/blob/622f750b15bb2f12d41ba1ae162cf7855860a217/app/ota/ota.cpp#LL37C42-L37C42))
Notes:
* run ./bin2ota.py PORTENTA_H7_M7 SKETCH.lzss SKETCH.ota even if you are creating an OTA file for the M4
opened 08:51AM - 17 Nov 23 UTC
type: imperfection
topic: documentation
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!
Where are the details for the Giga R1 boot loader? I see in the Portenta H7 OTA example it writes storage type and data offset to some registers. I assume these are part of the boot loader "API"? Is there some documentation for this?
Bootloader sourcecode is here:
OTA relevant stuff is here:
HAL_Delay(10);
usb_reset = 0;
HAL_Delay(10);
usb_reset = 1;
HAL_Delay(10);
#endif
if (magic != 0xDF59) {
if (boot_empty_keys()) {
BOOT_LOG_INF("Secure keys not configured");
if ( magic == 0x07AA ) {
/* Start OTA */
int ota_result = start_ota();
if (ota_result == 0) {
// clean reboot with success flag
BOOT_LOG_INF("Sketch updated");
RTCSetBKPRegister(RTC_BKP_DR0, 0);
HAL_FLASH_Lock();
// wait for external reboot (watchdog)
while (1) {}
} else {
/*
Copyright (c) 2022 Arduino SA. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "mbed.h"
#include "BlockDevice.h"
This file has been truncated. show original
Can you use the external flash on the Giga for a firmware update?
This is how it works. OTA binary is downloaded inside external flash filesystem. Binary can be both lzss compressed + ota header or siply a plain binary. Then bootloader is configured through RTC backup registers and at reset applies the update.
@pennam . Thank you very much for this. I really appreciate the fact you took the time to provide all this info.
Ok, so the firmware downloaded on say the Giga R1 is downloaded to the 16MB external Flash and the loader copies that onto the 2GB internal flash. Do I understand correctly?
pennam
February 8, 2024, 11:05am
9
Yes this is correct. By default the file is downloaded in the QSPI MBR partition 2
See here how the flash can be partitioned:
#include "QSPIFBlockDevice.h"
#include "MBRBlockDevice.h"
#include "LittleFileSystem.h"
#include "FATFileSystem.h"
#ifndef CORE_CM7
#error Format QSPI flash by uploading the sketch to the M7 core instead of the M4 core.
#endif
QSPIFBlockDevice root(QSPI_SO0, QSPI_SO1, QSPI_SO2, QSPI_SO3, QSPI_SCK, QSPI_CS, QSPIF_POLARITY_MODE_1, 40000000);
mbed::MBRBlockDevice wifi_data(&root, 1);
mbed::MBRBlockDevice ota_data(&root, 2);
mbed::MBRBlockDevice user_data(&root, 3);
mbed::FATFileSystem wifi_data_fs("wlan");
mbed::FATFileSystem ota_data_fs("fs");
mbed::FileSystem * user_data_fs;
bool waitResponse() {
bool confirmation = false;
This file has been truncated. show original
Then once downloded configuration is stored in RTC backup registers:
}
}
return false;
}
/******************************************************************************
* PRIVATE MEMBER FUNCTIONS
******************************************************************************/
void Arduino_Portenta_OTA::write()
{
HAL_RTCEx_BKUPWrite(&RTCHandle, RTC_BKP_DR0, 0x07AA);
HAL_RTCEx_BKUPWrite(&RTCHandle, RTC_BKP_DR1, _storage_type);
HAL_RTCEx_BKUPWrite(&RTCHandle, RTC_BKP_DR2, _data_offset);
HAL_RTCEx_BKUPWrite(&RTCHandle, RTC_BKP_DR3, _program_length);
}
bool Arduino_Portenta_OTA::caStorageInit()
{
_bd_raw_qspi = mbed::BlockDevice::get_default_instance();
Finally after reboot the bootloader copy the binary from QSPI flash to internal flash.
Thanks again. One final question, can I use any M7/M4 split (like 0.75/.25)?
Again, your responses have been very much appreciated.
pennam
February 9, 2024, 1:22pm
11
Unfortunately no, only 1/1 flash split is supported by default because of this hardcoded value
#include "ota.h"
#include "bootutil/bootutil_log.h"
BlockDevice* bd = NULL;
mbed::FileSystem* fs = NULL;
extern FlashIAP flash;
const uint32_t M7_FLASH_BASE = 0x8040000;
const uint32_t M4_FLASH_BASE = 0x8100000;
uint32_t getOTABinaryBase(uint32_t firstWord) {
BOOT_LOG_DBG("First OTA binary word: %lx", firstWord);
if ((firstWord & 0xFF000000) == 0x20000000
|| (firstWord & 0xFF000000) == 0x24000000
|| (firstWord & 0xFF000000) == 0x30000000
|| (firstWord & 0xFF000000) == 0x38000000) {
BOOT_LOG_DBG("Flashing on M7");
return M7_FLASH_BASE;
but you can chage the value according your needs and rebuild the bootloader.
system
Closed
August 7, 2024, 1:22pm
12
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.