File tree Expand file tree Collapse file tree 3 files changed +36
-7
lines changed
Expand file tree Collapse file tree 3 files changed +36
-7
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,14 @@ void setup()
6666 Arduino_Portenta_OTA_QSPI ota (QSPI_FLASH_FATFS_MBR, 2 );
6767 Arduino_Portenta_OTA::Error ota_err = Arduino_Portenta_OTA::Error::None;
6868
69+ if (!ota.isOtaCapable ())
70+ {
71+ Serial.println (" Higher version bootloader required to perform OTA." );
72+ Serial.println (" Please update the bootloader." );
73+ Serial.println (" File -> Examples -> Portenta_System -> PortentaH7_updateBootloader" );
74+ return ;
75+ }
76+
6977 Serial.println (" Initializing OTA storage" );
7078 if ((ota_err = ota.begin ()) != Arduino_Portenta_OTA::Error::None)
7179 {
Original file line number Diff line number Diff line change @@ -50,10 +50,29 @@ Arduino_Portenta_OTA::~Arduino_Portenta_OTA()
5050 * PUBLIC MEMBER FUNCTIONS
5151 ******************************************************************************/
5252
53+ bool Arduino_Portenta_OTA::isOtaCapable ()
54+ {
55+ #define BOOTLOADER_ADDR (0x8000000 )
56+ uint32_t bootloader_data_offset = 0x1F000 ;
57+ uint8_t * bootloader_data = (uint8_t *)(BOOTLOADER_ADDR + bootloader_data_offset);
58+ uint8_t currentBootloaderVersion = bootloader_data[1 ];
59+ if (currentBootloaderVersion < 22 )
60+ return false ;
61+ else
62+ return true ;
63+ }
64+
5365Arduino_Portenta_OTA::Error Arduino_Portenta_OTA::begin ()
5466{
5567 Serial1.begin (115200 );
56- return (init () == false ) ? Error::OtaStorageInit : Error::None;
68+
69+ if (!isOtaCapable ())
70+ return Error::NoCapableBootloader;
71+
72+ if (!init ())
73+ return Error::OtaStorageInit;
74+
75+ return Error::None;
5776}
5877
5978Arduino_Portenta_OTA::Error Arduino_Portenta_OTA::update ()
Original file line number Diff line number Diff line change @@ -67,18 +67,20 @@ class Arduino_Portenta_OTA
6767 enum class Error : int
6868 {
6969 None = 0 ,
70- NoOtaStorage = -1 ,
71- OtaStorageInit = -2 ,
72- OtaStorageOpen = -3 ,
73- OtaHeaderLength = -4 ,
74- OtaHeaderCrc = -5 ,
75- OtaHeaterMagicNumber = -6 ,
70+ NoCapableBootloader = -1 ,
71+ NoOtaStorage = -2 ,
72+ OtaStorageInit = -3 ,
73+ OtaStorageOpen = -4 ,
74+ OtaHeaderLength = -5 ,
75+ OtaHeaderCrc = -6 ,
76+ OtaHeaterMagicNumber = -7 ,
7677 };
7778
7879 Arduino_Portenta_OTA (StorageTypePortenta const storage_type, uint32_t const data_offset);
7980 virtual ~Arduino_Portenta_OTA ();
8081
8182
83+ bool isOtaCapable ();
8284 Error begin ();
8385 Error update ();
8486 void reset ();
You can’t perform that action at this time.
0 commit comments