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.