diff --git a/libraries/Arduino_H7_Video/src/anx7625.cpp b/libraries/Arduino_H7_Video/src/anx7625.cpp index 3cfefce47..1c06ea80d 100644 --- a/libraries/Arduino_H7_Video/src/anx7625.cpp +++ b/libraries/Arduino_H7_Video/src/anx7625.cpp @@ -475,8 +475,8 @@ int anx7625_dp_get_edid(uint8_t bus, struct edid *out) { ret = decode_edid(edid, (block_num + 1) * ONE_BLOCK_SIZE, out); if (ret != EDID_CONFORMANT) { - ANXERROR("Failed to decode EDID.\n"); - return -1; + ANXINFO("Non conformant EDID.\n"); + return 0; } return 0; diff --git a/libraries/Arduino_H7_Video/src/video_modes.c b/libraries/Arduino_H7_Video/src/video_modes.c index 16c90d2cf..3316ea930 100644 --- a/libraries/Arduino_H7_Video/src/video_modes.c +++ b/libraries/Arduino_H7_Video/src/video_modes.c @@ -63,7 +63,7 @@ struct envie_edid_mode envie_known_modes[NUM_KNOWN_MODES] = { enum edid_modes video_modes_get_edid(uint32_t h_check, uint32_t v_check) { int sum = 0; - int sel_mode = -1; + int sel_mode = EDID_MODE_AUTO; int sel_sum = 0; for (int i = 0; i= 0 && ((sel_mode == -1) || (sum < sel_sum))) { + if (sum >= 0 && ((sel_mode == EDID_MODE_AUTO) || (sum < sel_sum))) { sel_mode = i; sel_sum = sum; } @@ -88,14 +88,13 @@ enum edid_modes video_modes_get_edid(uint32_t h_check, uint32_t v_check) { sum = -1; } - if (sum >= 0 && ((sel_mode == -1) || (sum < sel_sum))) { + if (sum >= 0 && ((sel_mode == EDID_MODE_AUTO) || (sum < sel_sum))) { sel_mode = i; sel_sum = sum; } } - if (sel_mode == -1 || - sel_mode == EDID_MODE_1280x768_60Hz || + if (sel_mode == EDID_MODE_1280x768_60Hz || sel_mode == EDID_MODE_1280x720_60Hz || sel_mode == EDID_MODE_1920x1080_60Hz) { sel_mode = EDID_MODE_1024x768_60Hz; diff --git a/libraries/Portenta_SDRAM/src/ram_internal.c b/libraries/Portenta_SDRAM/src/ram_internal.c index e4deedd0c..0920af093 100644 --- a/libraries/Portenta_SDRAM/src/ram_internal.c +++ b/libraries/Portenta_SDRAM/src/ram_internal.c @@ -89,7 +89,7 @@ bool sdram_init(void) { /* Common GPIO configuration */ gpio_init_structure.Mode = GPIO_MODE_AF_PP; gpio_init_structure.Pull = GPIO_PULLUP; - gpio_init_structure.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + gpio_init_structure.Speed = GPIO_SPEED_FREQ_MEDIUM; gpio_init_structure.Alternate = GPIO_AF12_FMC; /* GPIOD configuration */ diff --git a/libraries/SE05X/src/WiFiSSLSE050Client.cpp b/libraries/SE05X/src/WiFiSSLSE050Client.cpp index 7a3b88555..b5c43852e 100644 --- a/libraries/SE05X/src/WiFiSSLSE050Client.cpp +++ b/libraries/SE05X/src/WiFiSSLSE050Client.cpp @@ -26,8 +26,8 @@ arduino::MbedSSLSE050Client::MbedSSLSE050Client() { void arduino::MbedSSLSE050Client::setEccSlot(int KeySlot, const byte cert[], int certLen) { _keySlot = KeySlot; - _client_cert_len = certLen; - _client_cert = cert; + _certLen = certLen; + _cert = cert; } void WiFiSSLSE050Client::setEccSlot(int KeySlot, const byte cert[], int certLen) { diff --git a/libraries/SE05X/src/WiFiSSLSE050Client.h b/libraries/SE05X/src/WiFiSSLSE050Client.h index 6d3409652..3aed4f4e3 100644 --- a/libraries/SE05X/src/WiFiSSLSE050Client.h +++ b/libraries/SE05X/src/WiFiSSLSE050Client.h @@ -37,37 +37,28 @@ class MbedSSLSE050Client : public arduino::MbedSSLClient { void setEccSlot(int KeySlot, const byte cert[], int certLen); private: - const byte* _client_cert; - const char* _ca_cert; - int _client_cert_len; + const byte* _cert; + int _certLen; int _keySlot; sss_object_t _keyObject; int setRootCAClientCertKey() { - if( NSAPI_ERROR_OK != ((TLSSocket*)sock)->set_root_ca_cert_path("/wlan/")) { - return 0; + int err = setRootCA(); + if (err != NSAPI_ERROR_OK) { + return err; } - if(_hostname && !_disableSNI) { - ((TLSSocket*)sock)->set_hostname(_hostname); + if(SE05X.getObjectHandle(_keySlot, &_keyObject) != NSAPI_ERROR_OK) { + return NSAPI_ERROR_DEVICE_ERROR; } - if( NSAPI_ERROR_OK != ((TLSSocket*)sock)->append_root_ca_cert(_ca_cert_custom)) { - return 0; + if(((TLSSocket*)sock)->set_client_cert_key((void*)_cert, + (size_t)_certLen, + &_keyObject, + SE05X.getDeviceCtx()) != NSAPI_ERROR_OK) { + return NSAPI_ERROR_DEVICE_ERROR; } - - if(!SE05X.getObjectHandle(_keySlot, &_keyObject)) { - return 0; - } - - if( NSAPI_ERROR_OK != ((TLSSocket*)sock)->set_client_cert_key((void*)_client_cert, - (size_t)_client_cert_len, - &_keyObject, - SE05X.getDeviceCtx())) { - return 0; - } - - return 1; + return NSAPI_ERROR_OK; } }; diff --git a/libraries/STM32H747_System/examples/QSPIFormat/QSPIFormat.ino b/libraries/STM32H747_System/examples/QSPIFormat/QSPIFormat.ino index 7aba71d8c..bf253bf9e 100644 --- a/libraries/STM32H747_System/examples/QSPIFormat/QSPIFormat.ino +++ b/libraries/STM32H747_System/examples/QSPIFormat/QSPIFormat.ino @@ -138,7 +138,7 @@ void setup() { Serial.println("\nDo you want to use LittleFS to format user data partition? Y/[n]"); Serial.println("If No, FatFS will be used to format user partition."); - Serial.println("Note: LittleFS is not supported by the OPTA PLC runtime."); + Serial.println("Note: Arduino PLC IDE is using LittleFS to store runtime data on this partition."); if (true == waitResponse()) { Serial.println("Formatting user partition with LittleFS."); user_data_fs = new mbed::LittleFileSystem("user"); @@ -219,7 +219,7 @@ void flashWiFiFirmwareMapped() { while (byte_count < file_size) { if (byte_count + chunk_size > file_size) chunk_size = file_size - byte_count; - int ret = root->program(wifi_firmware_image_data, offset + byte_count, chunk_size); + int ret = root->program(&wifi_firmware_image_data[byte_count], offset + byte_count, chunk_size); if (ret != 0) { Serial.println("Error writing memory mapped firmware"); break; diff --git a/libraries/STM32H747_System/examples/WiFiFirmwareUpdater/WiFiFirmwareUpdater.ino b/libraries/STM32H747_System/examples/WiFiFirmwareUpdater/WiFiFirmwareUpdater.ino index 1c655b85f..b894e07da 100644 --- a/libraries/STM32H747_System/examples/WiFiFirmwareUpdater/WiFiFirmwareUpdater.ino +++ b/libraries/STM32H747_System/examples/WiFiFirmwareUpdater/WiFiFirmwareUpdater.ino @@ -107,12 +107,18 @@ void setup() { byte_count = 0; const uint32_t offset = 15 * 1024 * 1024 + 1024 * 512; + // Make sure QSPI is erased before programming + Serial.println("Erasing memory mapped firmware area..."); + err = root.erase(14 * 1024 * 1024, 2 * 1024 * 1024); + if (err != 0) { + Serial.println("Error erasing memory mapped firmware area"); + } Serial.println("Flashing memory mapped firmware"); printProgress(byte_count, file_size, 10, true); while (byte_count < file_size) { if(byte_count + chunck_size > file_size) chunck_size = file_size - byte_count; - int ret = root.program(wifi_firmware_image_data, offset + byte_count, chunck_size); + int ret = root.program(&wifi_firmware_image_data[byte_count], offset + byte_count, chunck_size); if (ret != 0) { Serial.println("Error writing firmware data"); break; diff --git a/libraries/SocketWrapper/src/AClient.cpp b/libraries/SocketWrapper/src/AClient.cpp index 9ffa9137a..96a22585b 100644 --- a/libraries/SocketWrapper/src/AClient.cpp +++ b/libraries/SocketWrapper/src/AClient.cpp @@ -143,3 +143,24 @@ void arduino::ASslClient::appendCustomCACert(const char* ca_cert) { } static_cast(client.get())->appendCustomCACert(ca_cert); } + +void arduino::ASslClient::setCACert(const char* rootCA) { + if (!client) { + newMbedClient(); + } + static_cast(client.get())->setCACert(rootCA); +} + +void arduino::ASslClient::setCertificate(const char* clientCert) { + if (!client) { + newMbedClient(); + } + static_cast(client.get())->setCertificate(clientCert); +} + +void arduino::ASslClient::setPrivateKey(const char* privateKey) { + if (!client) { + newMbedClient(); + } + static_cast(client.get())->setPrivateKey(privateKey); +} diff --git a/libraries/SocketWrapper/src/AClient.h b/libraries/SocketWrapper/src/AClient.h index 4f72020ee..b9c1e8a1e 100644 --- a/libraries/SocketWrapper/src/AClient.h +++ b/libraries/SocketWrapper/src/AClient.h @@ -71,9 +71,16 @@ class ASslClient : public AClient { ASslClient() {} + /* The disableSNI function needs to be called prior to connect */ void disableSNI(bool statusSNI); - + /* The appendCustomCACert function needs to be called prior to connect */ void appendCustomCACert(const char* ca_cert); + /* The setCACert function needs to be called prior to connect */ + void setCACert(const char* rootCA); + /* The setCertificate function needs to be called prior to connect */ + void setCertificate(const char* clientCert); + /* The setPrivateKey function needs to be called prior to connect */ + void setPrivateKey(const char* privateKey); protected: virtual void newMbedClient(); diff --git a/libraries/SocketWrapper/src/MbedSSLClient.cpp b/libraries/SocketWrapper/src/MbedSSLClient.cpp index ce4cc9fca..0823bf781 100644 --- a/libraries/SocketWrapper/src/MbedSSLClient.cpp +++ b/libraries/SocketWrapper/src/MbedSSLClient.cpp @@ -1,9 +1,12 @@ #include "MbedSSLClient.h" arduino::MbedSSLClient::MbedSSLClient() - : _ca_cert_custom(nullptr), + : _rootCA(nullptr), _hostname(nullptr), - _disableSNI(false) { + _clientCert(nullptr), + _privateKey(nullptr), + _disableSNI(false), + _appendCA(true) { onBeforeConnect(mbed::callback(this, &MbedSSLClient::setRootCA)); }; diff --git a/libraries/SocketWrapper/src/MbedSSLClient.h b/libraries/SocketWrapper/src/MbedSSLClient.h index d4c48fc82..372dbf5bf 100644 --- a/libraries/SocketWrapper/src/MbedSSLClient.h +++ b/libraries/SocketWrapper/src/MbedSSLClient.h @@ -48,19 +48,48 @@ class MbedSSLClient : public arduino::MbedClient { _disableSNI = statusSNI; } - void appendCustomCACert(const char* ca_cert) { - _ca_cert_custom = ca_cert; + void appendCustomCACert(const char* rootCA) { + _rootCA = rootCA; + _appendCA = true; + } + void setCACert(const char* rootCA) { + _rootCA = rootCA; + _appendCA = false; + } + void setCertificate(const char* clientCert) { + _clientCert = clientCert; + } + void setPrivateKey(const char* privateKey) { + _privateKey = privateKey; } -protected: - const char* _ca_cert_custom; +private: + const char* _rootCA; const char* _hostname; + const char* _clientCert; + const char* _privateKey; bool _disableSNI; + bool _appendCA; -private: +protected: int setRootCA() { int err = 0; + if(_hostname && !_disableSNI) { + ((TLSSocket*)sock)->set_hostname(_hostname); + } + + if(_clientCert && _privateKey) { + err = ((TLSSocket*)sock)->set_client_cert_key(_clientCert, _privateKey); + if( err != NSAPI_ERROR_OK) { + return err; + } + } + + if(!_appendCA && _rootCA) { + return ((TLSSocket*)sock)->set_root_ca_cert(_rootCA); + } + #if defined(MBEDTLS_FS_IO) mbed::BlockDevice* root = mbed::BlockDevice::get_default_instance(); err = root->init(); @@ -82,12 +111,8 @@ class MbedSSLClient : public arduino::MbedClient { } #endif - if(_hostname && !_disableSNI) { - ((TLSSocket*)sock)->set_hostname(_hostname); - } - - if(_ca_cert_custom != NULL) { - err = ((TLSSocket*)sock)->append_root_ca_cert(_ca_cert_custom); + if(_rootCA != NULL) { + err = ((TLSSocket*)sock)->append_root_ca_cert(_rootCA); } return err; } diff --git a/libraries/WiFi/src/WiFi.cpp b/libraries/WiFi/src/WiFi.cpp index 6ad89d619..ae242a866 100644 --- a/libraries/WiFi/src/WiFi.cpp +++ b/libraries/WiFi/src/WiFi.cpp @@ -67,6 +67,7 @@ int arduino::WiFiClass::begin(const char* ssid, const char* passphrase, wl_enc_t return _currentNetworkStatus; } } else { + connected_ap = SSID_MAX_COUNT; _security = enum2sec(security); } @@ -213,12 +214,13 @@ int arduino::WiFiClass::setSSID(const char* ssid) { int8_t arduino::WiFiClass::scanNetworks() { connected_ap = SSID_MAX_COUNT; - uint8_t count = SSID_MAX_COUNT; if (ap_list != nullptr) { - free(ap_list); + delete[]ap_list; + ap_list = nullptr; } - ap_list = new WiFiAccessPoint[count]; - return wifi_if->scan(ap_list, count); + + ap_list = new WiFiAccessPoint[SSID_MAX_COUNT]; + return wifi_if->scan(ap_list, SSID_MAX_COUNT); } char* arduino::WiFiClass::SSID(uint8_t networkItem) { diff --git a/mbed-os-to-arduino b/mbed-os-to-arduino index d919715ee..af734c8b0 100755 --- a/mbed-os-to-arduino +++ b/mbed-os-to-arduino @@ -221,6 +221,17 @@ generate_flags () { sed -i "s?.heap (COPY)?.heap (NOLOAD)?g" $ARDUINOVARIANT/linker_script.ld sed -i "s?.stack_dummy (COPY)?.stack_dummy (NOLOAD)?g" $ARDUINOVARIANT/linker_script.ld fi + + if [[ $ARDUINOVARIANT == *OPTA* ]]; then + echo "Adding PLC section to $ARDUINOVARIANT/linker_script.ld" + PLC_SECTION=".plc_d3_section 0x3800F000 (NOLOAD): {\n \ + *(.plc_buffer)\n \ + } > RAM_D3\n \ + .plc_d2_section 0x30000000 (NOLOAD): {\n \ + *(.plc_code)\n \ + } > RAM_D2\n" + sed -i "s?.heap (COPY):?${PLC_SECTION} .heap (COPY):?g" $ARDUINOVARIANT/linker_script.ld + fi fi echo "Patching linker scripts" sed -i 's/0x8100000/CM4_BINARY_START/g' "$ARDUINOVARIANT"/linker_script.ld diff --git a/patches/0264-BLE-remove-blocking-loop-for-error-handling.patch b/patches/0264-BLE-remove-blocking-loop-for-error-handling.patch new file mode 100644 index 000000000..984841ebe --- /dev/null +++ b/patches/0264-BLE-remove-blocking-loop-for-error-handling.patch @@ -0,0 +1,25 @@ +From f5b74a5ac71cd1e01ad713ffdbb3f6601604816c Mon Sep 17 00:00:00 2001 +From: fabik111 +Date: Tue, 29 Oct 2024 15:20:53 +0100 +Subject: [PATCH] BLE: remove blocking loop for error handling + +--- + .../drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/HCIDriver.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/HCIDriver.cpp b/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/HCIDriver.cpp +index ff389c9f81..6a2d51eca5 100644 +--- a/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/HCIDriver.cpp ++++ b/connectivity/drivers/ble/FEATURE_BLE/COMPONENT_CYW43XXX/HCIDriver.cpp +@@ -408,7 +408,7 @@ private: + if (cmd_opcode != opcode) { + // DO something in case of error + +- while (true); ++ return; + + } + +-- +2.51.0 + diff --git a/patches/0265-littlefs2-Properly-init-class-variables-451.patch b/patches/0265-littlefs2-Properly-init-class-variables-451.patch new file mode 100644 index 000000000..2422ec8b7 --- /dev/null +++ b/patches/0265-littlefs2-Properly-init-class-variables-451.patch @@ -0,0 +1,45 @@ +From 4c7dfb1748407146b5bc0a4fe05a35aec56918db Mon Sep 17 00:00:00 2001 +From: Jamie Smith +Date: Thu, 17 Apr 2025 00:37:26 -0700 +Subject: [PATCH] littlefs2: Properly init class variables (#451) + +* littlefs2: Properly init class variables + +* Style fix +--- + .../littlefsv2/include/littlefsv2/LittleFileSystem2.h | 6 +++--- + storage/filesystem/littlefsv2/source/LittleFileSystem2.cpp | 1 - + 2 files changed, 3 insertions(+), 4 deletions(-) + +diff --git a/storage/filesystem/littlefsv2/include/littlefsv2/LittleFileSystem2.h b/storage/filesystem/littlefsv2/include/littlefsv2/LittleFileSystem2.h +index d753b3fb11..0d13ef7fb5 100644 +--- a/storage/filesystem/littlefsv2/include/littlefsv2/LittleFileSystem2.h ++++ b/storage/filesystem/littlefsv2/include/littlefsv2/LittleFileSystem2.h +@@ -289,9 +289,9 @@ protected: + #endif //!(DOXYGEN_ONLY) + + private: +- lfs2_t _lfs; // The actual file system +- struct lfs2_config _config; +- mbed::BlockDevice *_bd; // The block device ++ lfs2_t _lfs{}; // The actual file system ++ struct lfs2_config _config {}; ++ mbed::BlockDevice *_bd = nullptr; // The block device + + // thread-safe locking + PlatformMutex _mutex; +diff --git a/storage/filesystem/littlefsv2/source/LittleFileSystem2.cpp b/storage/filesystem/littlefsv2/source/LittleFileSystem2.cpp +index ea270a48d3..f5ac519e0b 100644 +--- a/storage/filesystem/littlefsv2/source/LittleFileSystem2.cpp ++++ b/storage/filesystem/littlefsv2/source/LittleFileSystem2.cpp +@@ -149,7 +149,6 @@ LittleFileSystem2::LittleFileSystem2(const char *name, BlockDevice *bd, + lfs2_size_t cache_size, lfs2_size_t lookahead_size) + : FileSystem(name) + { +- memset(&_config, 0, sizeof(_config)); + _config.block_size = block_size; + _config.block_cycles = block_cycles; + _config.cache_size = cache_size; +-- +2.51.0 + diff --git a/variants/STELLA/variant.cpp b/variants/STELLA/variant.cpp index cbeb7fc76..e7893c20d 100644 --- a/variants/STELLA/variant.cpp +++ b/variants/STELLA/variant.cpp @@ -105,10 +105,10 @@ PinDescription g_APinDescription[] = { { P0_3, NULL, NULL, NULL }, // A7 // LEDs - { P0_24, NULL, NULL, NULL }, // LED R - { P0_16, NULL, NULL, NULL }, // LED G - { P0_6, NULL, NULL, NULL }, // LED B - { P1_9, NULL, NULL, NULL }, // LED PWR + { P1_4, NULL, NULL, NULL }, // LED R + { P1_3, NULL, NULL, NULL }, // LED G + { P1_2, NULL, NULL, NULL }, // LED B + { P1_5, NULL, NULL, NULL }, // LED PWR { P0_19, NULL, NULL, NULL }, // INT APDS @@ -118,8 +118,8 @@ PinDescription g_APinDescription[] = { { P0_25, NULL, NULL, NULL }, // PDM DIN // Internal I2C - { P0_14, NULL, NULL, NULL }, // SDA2 - { P0_15, NULL, NULL, NULL }, // SCL2 + { P1_9, NULL, NULL, NULL }, // SDA2 + { P0_11, NULL, NULL, NULL }, // SCL2 // Internal I2C { P1_0, NULL, NULL, NULL }, // I2C_PULL @@ -139,7 +139,7 @@ extern "C" { void initVariant() { // turn power LED on pinMode(LED_PWR, OUTPUT); - digitalWrite(LED_PWR, HIGH); + digitalWrite(LED_PWR, LOW); // Errata Nano33BLE - I2C pullup is controlled by the SWO pin. // Configure the TRACEMUX to disable routing SWO signal to pin.