diff --git a/boards.txt b/boards.txt index ee8018487..048ca551d 100644 --- a/boards.txt +++ b/boards.txt @@ -444,7 +444,7 @@ nicla_sense.upload.native_usb=true nicla_sense.upload.maximum_size=527616 nicla_sense.upload.maximum_data_size=64288 nicla_sense.programmer.protocol=cmsis-dap -nicla_sense.programmer.transport_script={runtime.platform.path}/debugger/select_swd.cfg +nicla_sense.programmer.transport_script="{runtime.platform.path}/debugger/select_swd.cfg" nicla_sense.bootloader.tool=openocd nicla_sense.bootloader.tool.default=openocd @@ -499,7 +499,7 @@ nicla_voice.upload.native_usb=true nicla_voice.upload.maximum_size=527616 nicla_voice.upload.maximum_data_size=64288 nicla_voice.programmer.protocol=cmsis-dap -nicla_voice.programmer.transport_script={runtime.platform.path}/debugger/select_swd.cfg +nicla_voice.programmer.transport_script="{runtime.platform.path}/debugger/select_swd.cfg" nicla_voice.bootloader.tool=openocd nicla_voice.bootloader.tool.default=openocd @@ -767,6 +767,9 @@ giga.menu.split.100_0=2MB M7 + M4 in SDRAM giga.menu.split.75_25=1.5MB M7 + 0.5MB M4 giga.menu.split.50_50=1MB M7 + 1MB M4 +giga.menu.security.none=None +giga.menu.security.sien=Signature + Encryption + giga.menu.target_core.cm7.build.variant=GIGA giga.menu.target_core.cm7.build.mcu=cortex-m7 giga.menu.target_core.cm7.build.fpu=-mfpu=fpv5-d16 @@ -792,6 +795,14 @@ giga.build.board=GIGA giga.build.ldscript=linker_script.ld giga.build.extra_ldflags=-DCM4_BINARY_START=0x08180000 giga.compiler.mbed.arch.define= +giga.build.slot_size=0x1E0000 +giga.build.header_size=0x20000 +giga.build.alignment=32 +giga.build.version=1.2.3+4 +giga.menu.security.sien.recipe.hooks.objcopy.postobjcopy.1.pattern="{tools.imgtool.path}/{tools.imgtool.cmd}" {tools.imgtool.flags} +giga.menu.security.sien.build.keys.keychain={runtime.platform.path}/libraries/MCUboot/default_keys +giga.menu.security.sien.build.keys.sign_key=ecdsa-p256-signing-priv-key.pem +giga.menu.security.sien.build.keys.encrypt_key=ecdsa-p256-encrypt-pub-key.pem giga.compiler.mbed.defines={build.variant.path}/defines.txt giga.compiler.mbed.ldflags={build.variant.path}/ldflags.txt giga.compiler.mbed.cflags={build.variant.path}/cflags.txt @@ -825,7 +836,12 @@ giga.upload.native_usb=true giga.upload.maximum_size=1966080 giga.upload.maximum_data_size=523624 -giga.menu.target_core.cm7.upload.address=0x08040000 +giga.menu.security.none.upload.interface=0 +giga.menu.security.sien.upload.interface=2 + +giga.menu.security.none.upload.address_m7=0x08040000 +giga.menu.security.sien.upload.address_m7=0xA0000000 +giga.menu.target_core.cm7.upload.address={upload.address_m7} giga.menu.target_core.cm7.menu.split.50_50.upload.maximum_size=786432 giga.menu.target_core.cm7.menu.split.75_25.upload.maximum_size=1441792 diff --git a/cores/arduino/mbed/connectivity/cellular/include/cellular/framework/API/CellularDevice.h b/cores/arduino/mbed/connectivity/cellular/include/cellular/framework/API/CellularDevice.h index 0c8d1a2db..69455e156 100644 --- a/cores/arduino/mbed/connectivity/cellular/include/cellular/framework/API/CellularDevice.h +++ b/cores/arduino/mbed/connectivity/cellular/include/cellular/framework/API/CellularDevice.h @@ -201,6 +201,17 @@ class CellularDevice { */ virtual nsapi_error_t soft_power_off() = 0; + /** Resets the modem via AT command + * + * @remark CellularStateMachine disconnect or destruct does not reset the modem, + * but you need to do that yourself. + * + * @pre You must call shutdown to prepare the modem for reset. + * + * @return NSAPI_ERROR_OK on success + */ + virtual nsapi_error_t soft_reset() = 0; + /** Open the SIM card by setting the pin code for SIM. * * @param sim_pin PIN for the SIM card diff --git a/cores/arduino/mbed/connectivity/cellular/include/cellular/framework/AT/AT_CellularDevice.h b/cores/arduino/mbed/connectivity/cellular/include/cellular/framework/AT/AT_CellularDevice.h index fa011a096..0006b6c39 100755 --- a/cores/arduino/mbed/connectivity/cellular/include/cellular/framework/AT/AT_CellularDevice.h +++ b/cores/arduino/mbed/connectivity/cellular/include/cellular/framework/AT/AT_CellularDevice.h @@ -80,6 +80,8 @@ class AT_CellularDevice : public CellularDevice { virtual nsapi_error_t soft_power_off(); + virtual nsapi_error_t soft_reset(); + virtual nsapi_error_t set_pin(const char *sim_pin); virtual nsapi_error_t get_sim_state(SimState &state); diff --git a/cores/arduino/mbed/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION.h b/cores/arduino/mbed/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION.h index 21d588838..edc980209 100644 --- a/cores/arduino/mbed/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION.h +++ b/cores/arduino/mbed/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION.h @@ -55,6 +55,9 @@ class GEMALTO_CINTERION : public AT_CellularDevice { protected: virtual nsapi_error_t init(); + virtual nsapi_error_t shutdown(); + virtual nsapi_error_t soft_power_off(); + virtual nsapi_error_t soft_reset(); private: static Module _module; diff --git a/cores/arduino/mbed/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.h b/cores/arduino/mbed/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.h index f89da8c31..159ea68aa 100644 --- a/cores/arduino/mbed/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.h +++ b/cores/arduino/mbed/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.h @@ -43,6 +43,7 @@ class GEMALTO_CINTERION_CellularStack : public AT_CellularStack { void stopGNSS(); void PSMEnable(); void PSMDisable(); + int ping(const char *host, int ttl); protected: diff --git a/libraries/Arduino_H7_Video/docs/api.md b/libraries/Arduino_H7_Video/docs/api.md index 356144b49..923393173 100644 --- a/libraries/Arduino_H7_Video/docs/api.md +++ b/libraries/Arduino_H7_Video/docs/api.md @@ -14,6 +14,7 @@ The main class for managing the video controller and the display. | `public ` [`Arduino_H7_Video`](#public-arduino_h7_videoint-width-int-height-h7displayshield-shield) | Construct a new Arduino_H7_Video object with the specified width, height, and display shield. | | `public int` [`begin`](#public-int-begin) | Initialize the video controller and display. | | `public void` [`end`](#public-void-end) | De-initialize the video controller and display. | +| `public bool` [`detect`](#public-bool-detect) | Checks if the display is connected. | | `public int` [`width`](#public-int-width) | Get the width of the display. | | `public int` [`height`](#public-int-height) | Get the height of the display. | | `public bool` [`isRotated`](#public-bool-isrotated) | Check if the display is rotated. | @@ -54,6 +55,15 @@ De-initialize the video controller and display. --- +### `public bool` [`detect`](#)`()` + +Checks if the display is connected. + +#### Returns +`bool`: True if the display is connected, False otherwis. + +--- + ### `public int` [`width`](#)`()` Get the width of the display. diff --git a/libraries/Arduino_H7_Video/src/Arduino_H7_Video.cpp b/libraries/Arduino_H7_Video/src/Arduino_H7_Video.cpp index 460a1793a..68ee9b01f 100644 --- a/libraries/Arduino_H7_Video/src/Arduino_H7_Video.cpp +++ b/libraries/Arduino_H7_Video/src/Arduino_H7_Video.cpp @@ -111,10 +111,6 @@ int Arduino_H7_Video::begin() { if (buf1 == NULL) { return 2; /* Insuff memory err */ } - static lv_color_t * buf2 = (lv_color_t*)malloc((width() * height() / 10)); /* Declare a buffer for 1/10 screen size */ - if (buf2 == NULL) { - return 2; /* Insuff memory err */ - } lv_display_t *display; if(_rotated) { @@ -179,6 +175,11 @@ bool Arduino_H7_Video::isRotated() { return _rotated; } +bool Arduino_H7_Video::detect() +{ + return (_shield->getStatus() > 0); +} + void Arduino_H7_Video::end() { #ifdef HAS_ARDUINOGRAPHICS ArduinoGraphics::end(); diff --git a/libraries/Arduino_H7_Video/src/Arduino_H7_Video.h b/libraries/Arduino_H7_Video/src/Arduino_H7_Video.h index 9f05f5ea0..8f40d37a0 100644 --- a/libraries/Arduino_H7_Video/src/Arduino_H7_Video.h +++ b/libraries/Arduino_H7_Video/src/Arduino_H7_Video.h @@ -106,6 +106,13 @@ class Arduino_H7_Video */ bool isRotated(); + /** + * @brief Checks if the display is connected. + * + * @return true if the display is connected, false otherwise. + */ + bool detect(); + #ifdef HAS_ARDUINOGRAPHICS /** * @brief Clear the display. diff --git a/libraries/Arduino_H7_Video/src/H7DisplayShield.cpp b/libraries/Arduino_H7_Video/src/H7DisplayShield.cpp index e045f5abe..b6010f3f0 100644 --- a/libraries/Arduino_H7_Video/src/H7DisplayShield.cpp +++ b/libraries/Arduino_H7_Video/src/H7DisplayShield.cpp @@ -18,6 +18,10 @@ int GigaDisplayShieldClass::getEdidMode(int h, int v) { return EDID_MODE_480x800_60Hz; } +int GigaDisplayShieldClass::getStatus() { + return 1; // TODO: Not implemented; +} + int USBCVideoClass::init(int edidmode) { struct edid recognized_edid; int err_code = 0; @@ -57,5 +61,11 @@ int USBCVideoClass::getEdidMode(int h, int v) { return edidmode; } +int USBCVideoClass::getStatus() { + int detected = anx7625_get_hpd_event(0); + + return detected; +} + GigaDisplayShieldClass GigaDisplayShield; USBCVideoClass USBCVideo; \ No newline at end of file diff --git a/libraries/Arduino_H7_Video/src/H7DisplayShield.h b/libraries/Arduino_H7_Video/src/H7DisplayShield.h index c29f9d7eb..541c2c632 100644 --- a/libraries/Arduino_H7_Video/src/H7DisplayShield.h +++ b/libraries/Arduino_H7_Video/src/H7DisplayShield.h @@ -5,18 +5,21 @@ class H7DisplayShield { public: virtual int init(int edidmode) = 0; virtual int getEdidMode(int h, int v); + virtual int getStatus(); }; class GigaDisplayShieldClass : public H7DisplayShield { public: int init(int edidmode); int getEdidMode(int h, int v); + int getStatus(); }; class USBCVideoClass : public H7DisplayShield { public: int init(int edidmode); int getEdidMode(int h, int v); + int getStatus(); }; extern GigaDisplayShieldClass GigaDisplayShield; diff --git a/libraries/Arduino_H7_Video/src/anx7625.cpp b/libraries/Arduino_H7_Video/src/anx7625.cpp index 5f06e96c7..3cfefce47 100644 --- a/libraries/Arduino_H7_Video/src/anx7625.cpp +++ b/libraries/Arduino_H7_Video/src/anx7625.cpp @@ -630,6 +630,11 @@ bool anx7625_is_power_provider(uint8_t bus) { } } +int anx7625_get_hpd_event(uint8_t bus) { + int ret = anx7625_hpd_change_detect(bus); + return ret; +} + int i2c_writeb(uint8_t bus, uint8_t saddr, uint8_t offset, uint8_t val) { char cmd[2]; cmd[0] = offset; diff --git a/libraries/Arduino_H7_Video/src/anx7625.h b/libraries/Arduino_H7_Video/src/anx7625.h index e6f8de7f2..146d09ec1 100644 --- a/libraries/Arduino_H7_Video/src/anx7625.h +++ b/libraries/Arduino_H7_Video/src/anx7625.h @@ -24,5 +24,6 @@ int anx7625_wait_hpd_event(uint8_t bus); int anx7625_get_cc_status(uint8_t bus, uint8_t *cc_status); int anx7625_read_system_status(uint8_t bus, uint8_t *sys_status); bool anx7625_is_power_provider(uint8_t bus); +int anx7625_get_hpd_event(uint8_t bus); #endif /* _ANX7625_H */ diff --git a/libraries/GSM/src/GSM.cpp b/libraries/GSM/src/GSM.cpp index cf5f5b975..513b7d0dc 100644 --- a/libraries/GSM/src/GSM.cpp +++ b/libraries/GSM/src/GSM.cpp @@ -46,10 +46,28 @@ mbed::CellularDevice *mbed::CellularDevice::get_default_instance() int arduino::GSMClass::begin(const char* pin, const char* apn, const char* username, const char* password, RadioAccessTechnologyType rat, uint32_t band, bool restart) { - if (restart || isCmuxEnable()) { - reset(); + /* Assume module is powered ON. Uncomment this line is you are using + * Edge Control without Arduino_ConnectionHandler + * #if defined (ARDUINO_EDGE_CONTROL) + * pinMode(ON_MKR2, OUTPUT); + * digitalWrite(ON_MKR2, HIGH); + * #endif + */ + + /* Ensure module is not under reset */ + pinMode(MBED_CONF_GEMALTO_CINTERION_RST, OUTPUT); + digitalWrite(MBED_CONF_GEMALTO_CINTERION_RST, LOW); + + /* Reset module if needed */ + const bool emergencyReset = restart || isCmuxEnable(); + DEBUG_INFO("Emergency reset %s", emergencyReset ? "enabled" : "disabled"); + if (emergencyReset) { + hardwareReset(); } + /* Create rising edge on pin ON */ + on(); + if (!_context) { _context = mbed::CellularContext::get_default_instance(); } @@ -59,20 +77,18 @@ int arduino::GSMClass::begin(const char* pin, const char* apn, const char* usern return 0; } - pinMode(MBED_CONF_GEMALTO_CINTERION_ON, INPUT_PULLDOWN); - +#if defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) + /* This is needed to wakeup module if hw flow control is enabled */ static mbed::DigitalOut rts(MBED_CONF_GEMALTO_CINTERION_RTS, 0); +#endif _device = _context->get_device(); _device->modem_debug_on(_at_debug); - if (!isReady()) { - DEBUG_ERROR("Cellular device not ready"); - return 0; - } - + DEBUG_INFO("CMUX %s", _cmuxGSMenable ? "enabled" : "disabled"); _device->set_cmux_status_flag(_cmuxGSMenable); _device->set_retry_timeout_array(_retry_timeout, sizeof(_retry_timeout) / sizeof(_retry_timeout[0])); + _device->set_timeout(_timeout); _device->attach(mbed::callback(this, &GSMClass::onStatusChange)); _device->init(); @@ -106,6 +122,10 @@ int arduino::GSMClass::begin(const char* pin, const char* apn, const char* usern return connect_status == NSAPI_ERROR_OK ? 1 : 0; } +void arduino::GSMClass::setTimeout(unsigned long timeout) { + _timeout = timeout; +} + void arduino::GSMClass::enableCmux() { _cmuxGSMenable = true; } @@ -115,13 +135,62 @@ bool arduino::GSMClass::isCmuxEnable() { } void arduino::GSMClass::end() { + if(_device) { + _device->shutdown(); + } +} + +void arduino::GSMClass::reset() { + if(_device) { + _device->soft_reset(); + } +} + +void arduino::GSMClass::off() { + if(_device) { + _device->soft_power_off(); + } +} + +int arduino::GSMClass::ping(const char* hostname, int ttl) { + + mbed::GEMALTO_CINTERION_CellularStack* stack = (mbed::GEMALTO_CINTERION_CellularStack*)_context->get_stack(); + if (!stack) { + return -1; + } + return stack->ping(hostname, ttl); +} + +int arduino::GSMClass::ping(const String &hostname, int ttl) +{ + return ping(hostname.c_str(), ttl); +} +int arduino::GSMClass::ping(IPAddress ip, int ttl) +{ + String host; + host.reserve(15); + + host += ip[0]; + host += '.'; + host += ip[1]; + host += '.'; + host += ip[2]; + host += '.'; + host += ip[3]; + + return ping(host, ttl); } int arduino::GSMClass::disconnect() { - if (_context) { + if (!_context) { + return 0; + } + + if (_context->is_connected()) { return _context->disconnect(); } + return 0; } @@ -158,11 +227,16 @@ NetworkInterface* arduino::GSMClass::getNetwork() { return _context; } -void arduino::GSMClass::reset() { +void arduino::GSMClass::hardwareReset() { + /* Reset logic is inverted */ pinMode(MBED_CONF_GEMALTO_CINTERION_RST, OUTPUT); digitalWrite(MBED_CONF_GEMALTO_CINTERION_RST, HIGH); delay(800); digitalWrite(MBED_CONF_GEMALTO_CINTERION_RST, LOW); +} + +void arduino::GSMClass::on() { + /* Module needs a rising edge to power on */ pinMode(MBED_CONF_GEMALTO_CINTERION_ON, OUTPUT); digitalWrite(MBED_CONF_GEMALTO_CINTERION_ON, LOW); delay(1); @@ -170,22 +244,5 @@ void arduino::GSMClass::reset() { delay(1); } -bool arduino::GSMClass::isReady(const int timeout) { - if (!_device) { - DEBUG_ERROR("No device found"); - return false; - } - - const unsigned int start = millis(); - while (_device->is_ready() != NSAPI_ERROR_OK) { - - if (millis() - start > timeout) { - DEBUG_WARNING("Timeout waiting device ready"); - return false; - } - delay(100); - } - return true; -} arduino::GSMClass GSM; diff --git a/libraries/GSM/src/GSM.h b/libraries/GSM/src/GSM.h index 0b724f284..9f19cd3e0 100644 --- a/libraries/GSM/src/GSM.h +++ b/libraries/GSM/src/GSM.h @@ -75,30 +75,47 @@ class GSMClass : public MbedSocketClass { } } - /* Start GSM connection. - * Configure the credentials into the device. - * - * param pin: Pointer to the pin string. - * param apn: Pointer to the apn string. - * param username: Pointer to the username string. - * param password: Pointer to the password string. - * param rat: Radio Access Technology. - * - * return: 0 in case of success, negative number in case of failure - */ - int begin(const char* pin, const char* apn, const char* username, const char* password, RadioAccessTechnologyType rat = CATNB, uint32_t band = BAND_20, bool restart = true); + /* + * Start GSM connection. Configure the credentials into the device. + * + * param pin: Pointer to the pin string. + * param apn: Pointer to the apn string. + * param username: Pointer to the username string. + * param password: Pointer to the password string. + * param rat: Radio Access Technology. + * + * return: 0 in case of success, negative number in case of failure + */ + int begin(const char* pin, const char* apn, const char* username, const char* password, RadioAccessTechnologyType rat = CATNB, uint32_t band = BAND_20, bool restart = false); /* - * Disconnect from the network - * - * return: one value of wl_status_t enum - */ + * Disconnect from the network + * + * return: one value of wl_status_t enum + */ int disconnect(void); + /* + * Reset internal state machine in order to be ready to reconnect again. + */ void end(void); - unsigned long getTime(); + /* + * Send AT+CFUN=1,1 command to trigger a software reset. To be called only after end(); + */ + void reset(); + /* + * Send AT^SMSO="fast command to power off the modem. To be called only after end(); + */ + void off(); + + /* + * Change cellular state timeouts. Needs to be called before GSM.begin() + */ + void setTimeout(unsigned long timeout); + + unsigned long getTime(); unsigned long getLocalTime(); bool setTime(unsigned long const epoch, int const timezone = 0); @@ -108,6 +125,9 @@ class GSMClass : public MbedSocketClass { void trace(Stream& stream); void setTraceLevel(int trace_level, bool timestamp = false, bool at_trace = false); #endif + int ping(const char* hostname, int ttl = 5000); + int ping(const String& hostname, int ttl = 5000); + int ping(IPAddress host, int ttl = 5000); bool isConnected(); friend class GSMClient; @@ -127,11 +147,12 @@ class GSMClass : public MbedSocketClass { mbed::CellularContext* _context = nullptr; mbed::CellularDevice* _device = nullptr; bool _at_debug = false; + unsigned long _timeout = 1000; /* Internal cellular state machine retries. Values are in seconds. - * This array also defines the maximum number of retries to 6 + * This array also defines the maximum number of retries to CELLULAR_RETRY_ARRAY_SIZE */ - const uint16_t _retry_timeout[6] = {1, 2, 4, 8, 16, 32}; + const uint16_t _retry_timeout[CELLULAR_RETRY_ARRAY_SIZE] = {1, 2, 4, 8, 8, 8, 8, 8, 8, 8}; static constexpr int RSSI_UNKNOWN = 99; static const char * const sim_state_str[]; @@ -146,8 +167,8 @@ class GSMClass : public MbedSocketClass { static const char * getRegistrationStateString(const mbed::CellularNetwork::RegistrationStatus state); void onStatusChange(nsapi_event_t ev, intptr_t in); - void reset(); - bool isReady(const int timeout = 5000); + void hardwareReset(); + void on(); }; } diff --git a/libraries/GSM/src/GSMClient.h b/libraries/GSM/src/GSMClient.h index f29292fb9..cf7d49af5 100644 --- a/libraries/GSM/src/GSMClient.h +++ b/libraries/GSM/src/GSMClient.h @@ -26,9 +26,29 @@ namespace arduino { class GSMClient : public AClient { +private: NetworkInterface *getNetwork() { return GSM.getNetwork(); } + +public: + size_t write(uint8_t b) { + int ret = 0; + do { + ret = client->write(b); + delay(0); + } while (ret == 0 && status()); + return ret; + } + + size_t write(const uint8_t *buf, size_t size) { + int ret = 0; + do { + ret = client->write(buf, size); + delay(0); + } while (ret == 0 && status()); + return ret; + } }; } diff --git a/libraries/GSM/src/GSMSSLClient.h b/libraries/GSM/src/GSMSSLClient.h index cc7d3c194..add77b900 100644 --- a/libraries/GSM/src/GSMSSLClient.h +++ b/libraries/GSM/src/GSMSSLClient.h @@ -32,6 +32,25 @@ class GSMSSLClient : public arduino::ASslClient { NetworkInterface *getNetwork() { return GSM.getNetwork(); } + +public: + size_t write(uint8_t b) { + int ret = 0; + do { + ret = client->write(b); + delay(0); + } while (ret == 0 && status()); + return ret; + } + + size_t write(const uint8_t *buf, size_t size) { + int ret = 0; + do { + ret = client->write(buf, size); + delay(0); + } while (ret == 0 && status()); + return ret; + } }; } diff --git a/libraries/STM32H747_System/examples/QSPIFormat/QSPIFormat.ino b/libraries/STM32H747_System/examples/QSPIFormat/QSPIFormat.ino index 8d2b537dc..b3ecbf222 100644 --- a/libraries/STM32H747_System/examples/QSPIFormat/QSPIFormat.ino +++ b/libraries/STM32H747_System/examples/QSPIFormat/QSPIFormat.ino @@ -1,23 +1,28 @@ -#include "QSPIFBlockDevice.h" +#include "BlockDevice.h" #include "MBRBlockDevice.h" #include "LittleFileSystem.h" #include "FATFileSystem.h" +#include "wiced_resource.h" +#include "certificates.h" -#ifndef CORE_CM7 +#ifndef CORE_CM7 #error Format QSPI flash by uploading the sketch to the M7 core instead of the M4 core. #endif +using namespace mbed; -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; +BlockDevice* root = BlockDevice::get_default_instance(); +MBRBlockDevice wifi_data(root, 1); +MBRBlockDevice ota_data(root, 2); +MBRBlockDevice kvstore_data(root, 3); +MBRBlockDevice user_data(root, 4); +FATFileSystem wifi_data_fs("wlan"); +FATFileSystem ota_data_fs("fs"); +FileSystem * user_data_fs; bool waitResponse() { bool confirmation = false; + bool proceed = false; while (confirmation == false) { if (Serial.available()) { char choice = Serial.read(); @@ -25,18 +30,33 @@ bool waitResponse() { case 'y': case 'Y': confirmation = true; - return true; + proceed = true; break; case 'n': case 'N': confirmation = true; - return false; + proceed = false; break; default: continue; } } } + return proceed; +} + +void printProgress(uint32_t offset, uint32_t size, uint32_t threshold, bool reset) { + static int percent_done = 0; + if (reset == true) { + percent_done = 0; + Serial.println("Flashed " + String(percent_done) + "%"); + } else { + uint32_t percent_done_new = offset * 100 / size; + if (percent_done_new >= percent_done + threshold) { + percent_done = percent_done_new; + Serial.println("Flashed " + String(percent_done) + "%"); + } + } } void setup() { @@ -44,69 +64,142 @@ void setup() { Serial.begin(115200); while (!Serial); - Serial.println("Available partition schemes:"); - Serial.println("\nPartition scheme 1"); - Serial.println("Partition 1: WiFi firmware and certificates 1MB"); - Serial.println("Partition 2: OTA and user data 13MB"); - Serial.println("\nPartition scheme 2"); + Serial.println("\nWARNING! Running the sketch all the content of the QSPI flash will be erased."); + Serial.println("The following partitions will be created:"); Serial.println("Partition 1: WiFi firmware and certificates 1MB"); Serial.println("Partition 2: OTA 5MB"); - Serial.println("Partition 3: User data 8MB"), - Serial.println("\nDo you want to use partition scheme 1? Y/[n]"); - Serial.println("If No, partition scheme 2 will be used."); - bool default_scheme = waitResponse(); - - Serial.println("\nWARNING! Running the sketch all the content of the QSPI flash will be erased."); + Serial.println("Partition 3: Provisioning KVStore 1MB"); + Serial.println("Partition 4: User data / OPTA PLC runtime 7MB"), Serial.println("Do you want to proceed? Y/[n]"); if (true == waitResponse()) { - mbed::MBRBlockDevice::partition(&root, 1, 0x0B, 0, 1024 * 1024); - if(default_scheme) { - mbed::MBRBlockDevice::partition(&root, 3, 0x0B, 14 * 1024 * 1024, 14 * 1024 * 1024); - mbed::MBRBlockDevice::partition(&root, 2, 0x0B, 1024 * 1024, 14 * 1024 * 1024); - // use space from 15.5MB to 16 MB for another fw, memory mapped + if (root->init() != BD_ERROR_OK) { + Serial.println(F("Error: QSPI init failure.")); + return; + } + + Serial.println("Do you want to perform a full erase of the QSPI flash before proceeding? Y/[n]"); + if (true == waitResponse()) { + root->erase(0x0, root->size()); } else { - mbed::MBRBlockDevice::partition(&root, 2, 0x0B, 1024 * 1024, 6 * 1024 * 1024); - mbed::MBRBlockDevice::partition(&root, 3, 0x0B, 6 * 1024 * 1024, 14 * 1024 * 1024); - // use space from 15.5MB to 16 MB for another fw, memory mapped + // Erase only the first sector containing the MBR + root->erase(0x0, root->get_erase_size()); + } + + MBRBlockDevice::partition(root, 1, 0x0B, 0, 1 * 1024 * 1024); + MBRBlockDevice::partition(root, 2, 0x0B, 1 * 1024 * 1024, 6 * 1024 * 1024); + MBRBlockDevice::partition(root, 3, 0x0B, 6 * 1024 * 1024, 7 * 1024 * 1024); + MBRBlockDevice::partition(root, 4, 0x0B, 7 * 1024 * 1024, 14 * 1024 * 1024); + // use space from 15.5MB to 16 MB for another fw, memory mapped + + bool reformat = true; + if(!wifi_data_fs.mount(&wifi_data)) { + Serial.println("\nPartition 1 already contains a filesystem, do you want to reformat it? Y/[n]"); + wifi_data_fs.unmount(); + + reformat = waitResponse(); } - int err = wifi_data_fs.reformat(&wifi_data); - if (err) { + if (reformat && wifi_data_fs.reformat(&wifi_data)) { Serial.println("Error formatting WiFi partition"); return; } - - err = ota_data_fs.reformat(&ota_data); - if (err) { + + bool restore = true; + if (reformat) { + Serial.println("\nDo you want to restore the WiFi firmware and certificates? Y/[n]"); + restore = waitResponse(); + } + + if (reformat && restore) { + flashWiFiFirmwareAndCertificates(); + } + + reformat = true; + if(!ota_data_fs.mount(&ota_data)) { + Serial.println("\nPartition 2 already contains a filesystem, do you want to reformat it? Y/[n]"); + ota_data_fs.unmount(); + + reformat = waitResponse(); + } + + if (reformat && ota_data_fs.reformat(&ota_data)) { Serial.println("Error formatting OTA partition"); return; } - if(!default_scheme) { - 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("\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."); + if (true == waitResponse()) { + Serial.println("Formatting user partition with LittleFS."); + user_data_fs = new mbed::LittleFileSystem("user"); + } else { + Serial.println("Formatting user partition with FatFS."); + user_data_fs = new mbed::FATFileSystem("user"); + } - if (true == waitResponse()) { - Serial.println("Formatting user partition with LittleFS."); - user_data_fs = new mbed::LittleFileSystem("user"); - } else { - Serial.println("Formatting user partition with FatFS."); - user_data_fs = new mbed::FATFileSystem("user"); - } + reformat = true; + if(!user_data_fs->mount(&user_data)) { + Serial.println("\nPartition 4 already contains a filesystem, do you want to reformat it? Y/[n]"); + user_data_fs->unmount(); - err = user_data_fs->reformat(&user_data); - if (err) { - Serial.println("Error formatting user partition"); - return; - } + reformat = waitResponse(); + } + + if (reformat && user_data_fs->reformat(&user_data)) { + Serial.println("Error formatting user partition"); + return; } + Serial.println("\nQSPI Flash formatted!"); } Serial.println("It's now safe to reboot or disconnect your board."); } +void flashWiFiFirmwareAndCertificates() { + extern const unsigned char wifi_firmware_image_data[]; + FILE* fp = fopen("/wlan/4343WA1.BIN", "wb"); + const uint32_t file_size = 421098; + uint32_t chunck_size = 1024; + uint32_t byte_count = 0; + + Serial.println("Flashing WiFi 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 = fwrite(&wifi_firmware_image_data[byte_count], chunck_size, 1, fp); + if (ret != 1) { + Serial.println("Error writing firmware data"); + break; + } + byte_count += chunck_size; + printProgress(byte_count, file_size, 10, false); + } + fclose(fp); + + fp = fopen("/wlan/cacert.pem", "wb"); + + Serial.println("Flashing certificates"); + chunck_size = 128; + byte_count = 0; + printProgress(byte_count, cacert_pem_len, 10, true); + while (byte_count < cacert_pem_len) { + if(byte_count + chunck_size > cacert_pem_len) + chunck_size = cacert_pem_len - byte_count; + int ret = fwrite(&cacert_pem[byte_count], chunck_size, 1 ,fp); + if (ret != 1) { + Serial.println("Error writing certificates"); + break; + } + byte_count += chunck_size; + printProgress(byte_count, cacert_pem_len, 10, false); + } + fclose(fp); +} + void loop() { } diff --git a/libraries/STM32H747_System/examples/QSPIFormat/certificates.h b/libraries/STM32H747_System/examples/QSPIFormat/certificates.h new file mode 120000 index 000000000..7b4170776 --- /dev/null +++ b/libraries/STM32H747_System/examples/QSPIFormat/certificates.h @@ -0,0 +1 @@ +../WiFiFirmwareUpdater/certificates.h \ No newline at end of file diff --git a/libraries/STM32H747_System/src/STM32H747_System.cpp b/libraries/STM32H747_System/src/STM32H747_System.cpp index e54736b95..8789dfae7 100644 --- a/libraries/STM32H747_System/src/STM32H747_System.cpp +++ b/libraries/STM32H747_System/src/STM32H747_System.cpp @@ -6,7 +6,6 @@ extern RTC_HandleTypeDef RTCHandle; uint8_t STM32H747::readReg(uint8_t subAddress) { - char response = 0xFF; Wire1.beginTransmission(PMIC_ADDRESS); Wire1.write(subAddress); Wire1.endTransmission(false); @@ -115,4 +114,4 @@ bool STM32H747::useInternalOscillator(bool lowspeed) { digitalWrite(PH_1, LOW); return true; -} \ No newline at end of file +} diff --git a/libraries/SocketWrapper/src/MbedClient.cpp b/libraries/SocketWrapper/src/MbedClient.cpp index 296b64943..d678b78db 100644 --- a/libraries/SocketWrapper/src/MbedClient.cpp +++ b/libraries/SocketWrapper/src/MbedClient.cpp @@ -71,7 +71,7 @@ void arduino::MbedClient::configureSocket(Socket *_s) { } mutex->lock(); if (reader_th == nullptr) { - reader_th = new rtos::Thread(osPriorityNormal - 2); + reader_th = new rtos::Thread(osPriorityNormal, OS_STACK_SIZE, nullptr, "readSocket"); reader_th->start(mbed::callback(this, &MbedClient::readSocket)); } mutex->unlock(); diff --git a/libraries/SocketWrapper/src/SocketHelpers.cpp b/libraries/SocketWrapper/src/SocketHelpers.cpp index b7e39b42c..591cd2f17 100644 --- a/libraries/SocketWrapper/src/SocketHelpers.cpp +++ b/libraries/SocketWrapper/src/SocketHelpers.cpp @@ -75,22 +75,22 @@ arduino::IPAddress arduino::MbedSocketClass::dnsIP(int n) { return ipAddressFromSocketAddress(ip); } -int arduino::MbedSocketClass::ping(const char *hostname, uint8_t ttl) +int arduino::MbedSocketClass::ping(const char *hostname, uint8_t ttl, uint32_t timeout) { SocketAddress socketAddress; gethostbyname(getNetwork(),hostname, &socketAddress); - return ping(socketAddress, ttl); + return ping(socketAddress, ttl, timeout); } -int arduino::MbedSocketClass::ping(const String &hostname, uint8_t ttl) +int arduino::MbedSocketClass::ping(const String &hostname, uint8_t ttl, uint32_t timeout) { - return ping(hostname.c_str(), ttl); + return ping(hostname.c_str(), ttl, timeout); } -int arduino::MbedSocketClass::ping(IPAddress host, uint8_t ttl) +int arduino::MbedSocketClass::ping(IPAddress host, uint8_t ttl, uint32_t timeout) { SocketAddress socketAddress = socketAddressFromIpAddress(host, 0); - return ping(socketAddress, ttl); + return ping(socketAddress, ttl, timeout); } void arduino::MbedSocketClass::config(arduino::IPAddress local_ip) { @@ -142,11 +142,14 @@ int arduino::MbedSocketClass::ping(SocketAddress &socketAddress, uint8_t ttl, ui { /* ttl is not supported by mbed ICMPSocket. Default value used is 255 */ (void)ttl; + int response = -1; +#if MBED_CONF_LWIP_RAW_SOCKET_ENABLED ICMPSocket s; s.set_timeout(timeout); s.open(getNetwork()); - int response = s.ping(socketAddress, timeout); + response = s.ping(socketAddress, timeout); s.close(); +#endif return response; } diff --git a/libraries/SocketWrapper/src/SocketHelpers.h b/libraries/SocketWrapper/src/SocketHelpers.h index e285d166c..428ab4a63 100644 --- a/libraries/SocketWrapper/src/SocketHelpers.h +++ b/libraries/SocketWrapper/src/SocketHelpers.h @@ -118,9 +118,9 @@ class MbedSocketClass { * * return: RTT in milliseconds or -1 on error */ - int ping(const char* hostname, uint8_t ttl = 255); - int ping(const String &hostname, uint8_t ttl = 255); - int ping(IPAddress host, uint8_t ttl = 255); + int ping(const char* hostname, uint8_t ttl = 255, uint32_t timeout = 5000); + int ping(const String &hostname, uint8_t ttl = 255, uint32_t timeout = 5000); + int ping(IPAddress host, uint8_t ttl = 255, uint32_t timeout = 5000); /* * Download a file from an HTTP endpoint and save it in the provided `target` location on the fs @@ -185,7 +185,7 @@ class MbedSocketClass { void body_callback(const char* data, uint32_t data_len); - int ping(SocketAddress &socketAddress, uint8_t ttl, uint32_t timeout = 5000); + int ping(SocketAddress &socketAddress, uint8_t ttl, uint32_t timeout); static arduino::IPAddress ipAddressFromSocketAddress(SocketAddress socketAddress); static SocketAddress socketAddressFromIpAddress(arduino::IPAddress ip, uint16_t port); static nsapi_error_t gethostbyname(NetworkInterface* interface, const char* aHostname, SocketAddress* socketAddress); diff --git a/libraries/Wire/Wire.cpp b/libraries/Wire/Wire.cpp index 9b345d3e1..155ab4fc8 100644 --- a/libraries/Wire/Wire.cpp +++ b/libraries/Wire/Wire.cpp @@ -124,7 +124,6 @@ size_t arduino::MbedI2C::write(const uint8_t* data, int len) { int arduino::MbedI2C::read() { int rv = -1; core_util_critical_section_enter(); - if (rxBuffer.available()) { rv = rxBuffer.read_char(); @@ -160,9 +159,12 @@ void arduino::MbedI2C::receiveThd() { } if (usedTxBuffer != 0) { core_util_critical_section_enter(); - slave->write((const char *) txBuffer, usedTxBuffer); - core_util_critical_section_exit(); + uint8_t tempTxBuffer[256]; + uint8_t usedTempTxBuffer = usedTxBuffer; + memcpy(tempTxBuffer, txBuffer, usedTempTxBuffer); usedTxBuffer = 0; + core_util_critical_section_exit(); + slave->write((const char *) tempTxBuffer, usedTempTxBuffer); } //slave->stop(); break; diff --git a/libraries/openamp_arduino/library.properties b/libraries/openamp_arduino/library.properties index 51525e1a6..d2ebd4a2a 100644 --- a/libraries/openamp_arduino/library.properties +++ b/libraries/openamp_arduino/library.properties @@ -6,5 +6,5 @@ sentence=Enables the communication between H747 cores via shared memory and open paragraph= category=Communication url= -architectures=mbed,mbed_portenta,mbed_nicla,mbed_opta +architectures=mbed,mbed_portenta,mbed_nicla,mbed_opta,mbed_giga dot_a_linkage=true diff --git a/opta.variables b/opta.variables index dc36376d6..ecafac369 100755 --- a/opta.variables +++ b/opta.variables @@ -1,5 +1,5 @@ export FLAVOUR="opta" export VARIANTS=("OPTA GENERIC_STM32H747_M4") export FQBNS=("opta") -export LIBRARIES=("Ethernet SPI WiFi openamp_arduino ThreadDebug KernelDebug RPC USBHID Wire rpclib USBHOST mbed-memory-status Scheduler USBMSD SocketWrapper STM32H747_System MRI") +export LIBRARIES=("Ethernet SPI WiFi openamp_arduino ThreadDebug KernelDebug RPC USBHID Wire rpclib USBHOST mbed-memory-status Scheduler USBMSD SocketWrapper STM32H747_System MRI MCUboot") export BOOTLOADERS=("OPTA") diff --git a/package_full.sh b/package_full.sh index e7fca45b2..2f9c1434e 100755 --- a/package_full.sh +++ b/package_full.sh @@ -1,5 +1,5 @@ #Get version from git(hub) tag -export VERSION="4.2.3" +export VERSION="4.2.4" FLAVOURS=`ls *.variables` diff --git a/patches/0248-GEMALTO-CINTERION-cleanup-stack-before-connection.patch b/patches/0248-GEMALTO-CINTERION-cleanup-stack-before-connection.patch new file mode 100644 index 000000000..d9cb9e31c --- /dev/null +++ b/patches/0248-GEMALTO-CINTERION-cleanup-stack-before-connection.patch @@ -0,0 +1,29 @@ +From f40d4a9d65ee9163921271697d316c1061aca946 Mon Sep 17 00:00:00 2001 +From: pennam +Date: Thu, 31 Oct 2024 11:05:18 +0100 +Subject: [PATCH] GEMALTO CINTERION: cleanup stack before connection + + Allows to re-connect after a disconnection +--- + .../GEMALTO/CINTERION/GEMALTO_CINTERION_CellularContext.cpp | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularContext.cpp b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularContext.cpp +index 78955c599e..76c788cdaf 100644 +--- a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularContext.cpp ++++ b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularContext.cpp +@@ -35,6 +35,11 @@ nsapi_error_t GEMALTO_CINTERION_CellularContext::connect(const char *sim_pin, co + { + nsapi_error_t error = NSAPI_ERROR_OK; + ++ if (_stack) { ++ delete _stack; ++ _stack = NULL; ++ } ++ + set_sim_pin(sim_pin); + set_credentials(apn, uname, pwd); + +-- +2.45.2 + diff --git a/patches/0249-GEMALTO-CINTERION-close-socket-on-timeout.patch b/patches/0249-GEMALTO-CINTERION-close-socket-on-timeout.patch new file mode 100644 index 000000000..1fbb4021a --- /dev/null +++ b/patches/0249-GEMALTO-CINTERION-close-socket-on-timeout.patch @@ -0,0 +1,25 @@ +From 4b6c6ad0554c88c369fc4e2e5ed543d52117aa3f Mon Sep 17 00:00:00 2001 +From: pennam +Date: Thu, 31 Oct 2024 12:00:51 +0100 +Subject: [PATCH] GEMALTO CINTERION: close socket on timeout + +--- + .../GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp +index ac2a54282a..41a01859e7 100644 +--- a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp ++++ b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp +@@ -59,7 +59,7 @@ void GEMALTO_CINTERION_CellularStack::urc_sis() + } + if (urc_code == 0) { + int urc_info_id = _at.read_int(); +- if (urc_info_id == 48) { ++ if (urc_info_id == 48 || urc_info_id == 20) { + tr_info("Socket closed %d", sock_id); + sock->closed = true; + if (sock->_cb) { +-- +2.45.2 + diff --git a/patches/0250-GEMALTO-CINTERION-add-debug-for-urc_sis.patch b/patches/0250-GEMALTO-CINTERION-add-debug-for-urc_sis.patch new file mode 100644 index 000000000..4c41b0918 --- /dev/null +++ b/patches/0250-GEMALTO-CINTERION-add-debug-for-urc_sis.patch @@ -0,0 +1,33 @@ +From 84e682a7f4c0c05dded7f12817f78c1cc9a66cfe Mon Sep 17 00:00:00 2001 +From: pennam +Date: Thu, 31 Oct 2024 12:01:47 +0100 +Subject: [PATCH] GEMALTO CINTERION: add debug for urc_sis + +--- + .../GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp +index 41a01859e7..9a3f22dc3c 100644 +--- a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp ++++ b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp +@@ -47,6 +47,8 @@ void GEMALTO_CINTERION_CellularStack::urc_sis() + int sock_id = _at.read_int(); + int urc_code = _at.read_int(); + CellularSocket *sock = find_socket(sock_id); ++ ++ tr_info("urc_sis socket id %d urc code %d\n\r", sock_id, urc_code); + if (sock) { + // Currently only UDP is supported so there is need to handle only some error codes here, + // and others are detected on sendto/recvfrom responses. +@@ -59,6 +61,7 @@ void GEMALTO_CINTERION_CellularStack::urc_sis() + } + if (urc_code == 0) { + int urc_info_id = _at.read_int(); ++ tr_info("urcInfoId %d\n\r", urc_info_id); + if (urc_info_id == 48 || urc_info_id == 20) { + tr_info("Socket closed %d", sock_id); + sock->closed = true; +-- +2.45.2 + diff --git a/patches/0251-GEMALTO-CINTERION-add-configuration-for-urcs-during-.patch b/patches/0251-GEMALTO-CINTERION-add-configuration-for-urcs-during-.patch new file mode 100644 index 000000000..290452457 --- /dev/null +++ b/patches/0251-GEMALTO-CINTERION-add-configuration-for-urcs-during-.patch @@ -0,0 +1,33 @@ +From 5cc2a1998d37bad69a0b4e75b7d6f7b92e95935c Mon Sep 17 00:00:00 2001 +From: pennam +Date: Thu, 31 Oct 2024 12:03:00 +0100 +Subject: [PATCH] GEMALTO CINTERION: add configuration for urcs during + read + +--- + .../CINTERION/GEMALTO_CINTERION_CellularStack.cpp | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +diff --git a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp +index 9a3f22dc3c..a96cb2b360 100644 +--- a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp ++++ b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp +@@ -527,8 +527,13 @@ sisw_retry: + return (_at.get_last_error() == NSAPI_ERROR_OK) ? accept_len : NSAPI_ERROR_DEVICE_ERROR; + } + +-#define DISABLE_URCs _at.at_cmd_discard("^SCFG", "=", "%s%s","Tcp/WithURCs","off") +-#define RESTORE_URCs_AND_RETURN(ret) do { _at.at_cmd_discard("^SCFG", "=", "%s%s","Tcp/WithURCs","on"); return ret; } while(0) ++#if defined GEMALTO_CINTERION_DISABLE_URC_READING ++ #define DISABLE_URCs _at.at_cmd_discard("^SCFG", "=", "%s%s","Tcp/WithURCs","off") ++ #define RESTORE_URCs_AND_RETURN(ret) do { _at.at_cmd_discard("^SCFG", "=", "%s%s","Tcp/WithURCs","on"); return ret; } while(0) ++#else ++ #define DISABLE_URCs ++ #define RESTORE_URCs_AND_RETURN(ret) do { return ret; } while(0) ++#endif + + nsapi_size_or_error_t GEMALTO_CINTERION_CellularStack::socket_recvfrom_impl(CellularSocket *socket, SocketAddress *address, + void *buffer, nsapi_size_t size) +-- +2.45.2 + diff --git a/patches/0252-GEMALTO-CINTERION-fix-enable-cmux-command.patch b/patches/0252-GEMALTO-CINTERION-fix-enable-cmux-command.patch new file mode 100644 index 000000000..711836c5d --- /dev/null +++ b/patches/0252-GEMALTO-CINTERION-fix-enable-cmux-command.patch @@ -0,0 +1,57 @@ +From a76136121ab8066a1ee4afab9254552752b96a5d Mon Sep 17 00:00:00 2001 +From: pennam +Date: Wed, 13 Nov 2024 08:28:13 +0100 +Subject: [PATCH] GEMALTO CINTERION: fix enable cmux command + +--- + .../cellular/source/framework/AT/AT_CellularDevice.cpp | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +diff --git a/connectivity/cellular/source/framework/AT/AT_CellularDevice.cpp b/connectivity/cellular/source/framework/AT/AT_CellularDevice.cpp +index 08229ba49b..3eccc4a5c0 100644 +--- a/connectivity/cellular/source/framework/AT/AT_CellularDevice.cpp ++++ b/connectivity/cellular/source/framework/AT/AT_CellularDevice.cpp +@@ -50,6 +50,7 @@ AT_CellularDevice::AT_CellularDevice(FileHandle *fh, char *delim): + _context_list(0), + _default_timeout(DEFAULT_AT_TIMEOUT), + _modem_debug_on(false), ++ _cmux_status(false), + _property_array(NULL) + { + MBED_ASSERT(fh); +@@ -243,10 +244,10 @@ nsapi_error_t AT_CellularDevice::get_sim_state(SimState &state) + + nsapi_error_t AT_CellularDevice::enable_cmux() + { +-setup_at_handler(); +- ++ setup_at_handler(); + _at.lock(); + for (int retry = 1; retry <= 3; retry++) { ++ is_ready(); + _at.clear_error(); + _at.flush(); + _at.at_cmd_discard("E0", ""); +@@ -259,10 +260,9 @@ setup_at_handler(); + tr_debug("Wait 100ms to init modem"); + rtos::ThisThread::sleep_for(100ms); // let modem have time to get ready + } +- return _at.unlock_return_error(); ++ return _at.unlock_return_error(); + } + +- + bool AT_CellularDevice::is_cmux_enabled() + { + return _cmux_status; +@@ -272,6 +272,7 @@ void AT_CellularDevice::set_cmux_status_flag(bool cmux_status) + { + _cmux_status = cmux_status; + } ++ + nsapi_error_t AT_CellularDevice::set_pin(const char *sim_pin) + { + // if SIM is already in ready state then settings the PIN +-- +2.45.2 + diff --git a/patches/0253-GEMALTO-CINTERION-override-shutdown-function.patch b/patches/0253-GEMALTO-CINTERION-override-shutdown-function.patch new file mode 100644 index 000000000..e100a7b01 --- /dev/null +++ b/patches/0253-GEMALTO-CINTERION-override-shutdown-function.patch @@ -0,0 +1,42 @@ +From 13bc587f70e1c4f9f61650cfd7c8ebc538bdcf09 Mon Sep 17 00:00:00 2001 +From: pennam +Date: Wed, 13 Nov 2024 08:29:14 +0100 +Subject: [PATCH] GEMALTO CINTERION: override shutdown function + +--- + .../cellular/GEMALTO/CINTERION/GEMALTO_CINTERION.cpp | 6 ++++++ + .../drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION.h | 1 + + 2 files changed, 7 insertions(+) + +diff --git a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION.cpp b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION.cpp +index 1f82199106..c00c1880e4 100644 +--- a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION.cpp ++++ b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION.cpp +@@ -92,6 +92,12 @@ nsapi_error_t GEMALTO_CINTERION::init() + return NSAPI_ERROR_OK; + } + ++nsapi_error_t GEMALTO_CINTERION::shutdown() ++{ ++ CellularDevice::shutdown(); ++ return NSAPI_ERROR_OK; ++} ++ + GEMALTO_CINTERION::Module GEMALTO_CINTERION::get_module() + { + return _module; +diff --git a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION.h b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION.h +index 21d5888383..e77078cb49 100644 +--- a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION.h ++++ b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION.h +@@ -55,6 +55,7 @@ protected: // AT_CellularDevice + + protected: + virtual nsapi_error_t init(); ++ virtual nsapi_error_t shutdown(); + + private: + static Module _module; +-- +2.45.2 + diff --git a/patches/0254-GEMALTO-CINTERION-use-default-timeout-to-close-socke.patch b/patches/0254-GEMALTO-CINTERION-use-default-timeout-to-close-socke.patch new file mode 100644 index 000000000..86975735d --- /dev/null +++ b/patches/0254-GEMALTO-CINTERION-use-default-timeout-to-close-socke.patch @@ -0,0 +1,32 @@ +From 62867abe6811f785373cae9e9b5cfe41774b846b Mon Sep 17 00:00:00 2001 +From: pennam +Date: Wed, 13 Nov 2024 08:30:47 +0100 +Subject: [PATCH] GEMALTO CINTERION: use default timeout to close + sockets + +--- + .../GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp | 4 ---- + 1 file changed, 4 deletions(-) + +diff --git a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp +index a96cb2b360..f96ae481f0 100644 +--- a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp ++++ b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp +@@ -252,14 +252,10 @@ nsapi_error_t GEMALTO_CINTERION_CellularStack::socket_close_impl(int sock_id) + { + tr_debug("Cinterion close %d", sock_id); + +- _at.set_at_timeout(FAILURE_TIMEOUT); +- + _at.at_cmd_discard("^SISC", "=", "%d", sock_id); + + _at.clear_error(); // clear SISS even though SISC fails + +- _at.restore_at_timeout(); +- + return _at.get_last_error(); + } + +-- +2.45.2 + diff --git a/patches/0255-GEMALTO-CINTERION-add-soft_power_off-and-soft_reset.patch b/patches/0255-GEMALTO-CINTERION-add-soft_power_off-and-soft_reset.patch new file mode 100644 index 000000000..82bd81c15 --- /dev/null +++ b/patches/0255-GEMALTO-CINTERION-add-soft_power_off-and-soft_reset.patch @@ -0,0 +1,102 @@ +From 7c789f289225ef631952f0ddb8ac46d2d1de9191 Mon Sep 17 00:00:00 2001 +From: pennam +Date: Thu, 14 Nov 2024 15:57:07 +0100 +Subject: [PATCH] GEMALTO CINTERION: add soft_power_off() and + soft_reset() + +--- + .../include/cellular/framework/API/CellularDevice.h | 11 +++++++++++ + .../include/cellular/framework/AT/AT_CellularDevice.h | 2 ++ + .../source/framework/AT/AT_CellularDevice.cpp | 5 +++++ + .../cellular/GEMALTO/CINTERION/GEMALTO_CINTERION.cpp | 10 ++++++++++ + .../cellular/GEMALTO/CINTERION/GEMALTO_CINTERION.h | 2 ++ + 5 files changed, 30 insertions(+) + +diff --git a/connectivity/cellular/include/cellular/framework/API/CellularDevice.h b/connectivity/cellular/include/cellular/framework/API/CellularDevice.h +index 0c8d1a2db2..69455e1567 100644 +--- a/connectivity/cellular/include/cellular/framework/API/CellularDevice.h ++++ b/connectivity/cellular/include/cellular/framework/API/CellularDevice.h +@@ -201,6 +201,17 @@ public: //Pure virtual functions + */ + virtual nsapi_error_t soft_power_off() = 0; + ++ /** Resets the modem via AT command ++ * ++ * @remark CellularStateMachine disconnect or destruct does not reset the modem, ++ * but you need to do that yourself. ++ * ++ * @pre You must call shutdown to prepare the modem for reset. ++ * ++ * @return NSAPI_ERROR_OK on success ++ */ ++ virtual nsapi_error_t soft_reset() = 0; ++ + /** Open the SIM card by setting the pin code for SIM. + * + * @param sim_pin PIN for the SIM card +diff --git a/connectivity/cellular/include/cellular/framework/AT/AT_CellularDevice.h b/connectivity/cellular/include/cellular/framework/AT/AT_CellularDevice.h +index fa011a0968..0006b6c391 100755 +--- a/connectivity/cellular/include/cellular/framework/AT/AT_CellularDevice.h ++++ b/connectivity/cellular/include/cellular/framework/AT/AT_CellularDevice.h +@@ -80,6 +80,8 @@ public: + + virtual nsapi_error_t soft_power_off(); + ++ virtual nsapi_error_t soft_reset(); ++ + virtual nsapi_error_t set_pin(const char *sim_pin); + + virtual nsapi_error_t get_sim_state(SimState &state); +diff --git a/connectivity/cellular/source/framework/AT/AT_CellularDevice.cpp b/connectivity/cellular/source/framework/AT/AT_CellularDevice.cpp +index 3eccc4a5c0..d7dae05aa2 100644 +--- a/connectivity/cellular/source/framework/AT/AT_CellularDevice.cpp ++++ b/connectivity/cellular/source/framework/AT/AT_CellularDevice.cpp +@@ -187,6 +187,11 @@ nsapi_error_t AT_CellularDevice::soft_power_off() + return NSAPI_ERROR_OK; + } + ++nsapi_error_t AT_CellularDevice::soft_reset() ++{ ++ return NSAPI_ERROR_OK; ++} ++ + ATHandler *AT_CellularDevice::get_at_handler() + { + return &_at; +diff --git a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION.cpp b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION.cpp +index c00c1880e4..40e74ab98f 100644 +--- a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION.cpp ++++ b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION.cpp +@@ -98,6 +98,16 @@ nsapi_error_t GEMALTO_CINTERION::shutdown() + return NSAPI_ERROR_OK; + } + ++nsapi_error_t GEMALTO_CINTERION::soft_power_off() ++{ ++ return _at.at_cmd_discard("^SMSO=", "fast"); ++} ++ ++nsapi_error_t GEMALTO_CINTERION::soft_reset() ++{ ++ return _at.at_cmd_discard("+CFUN", "=1,1"); ++} ++ + GEMALTO_CINTERION::Module GEMALTO_CINTERION::get_module() + { + return _module; +diff --git a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION.h b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION.h +index e77078cb49..edc980209e 100644 +--- a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION.h ++++ b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION.h +@@ -56,6 +56,8 @@ protected: // AT_CellularDevice + protected: + virtual nsapi_error_t init(); + virtual nsapi_error_t shutdown(); ++ virtual nsapi_error_t soft_power_off(); ++ virtual nsapi_error_t soft_reset(); + + private: + static Module _module; +-- +2.45.2 + diff --git a/patches/0256-GEMALTO-CINTERION-disable-runtime-model-detection.patch b/patches/0256-GEMALTO-CINTERION-disable-runtime-model-detection.patch new file mode 100644 index 000000000..886e626f3 --- /dev/null +++ b/patches/0256-GEMALTO-CINTERION-disable-runtime-model-detection.patch @@ -0,0 +1,71 @@ +From 1082631c2a418ce76d003cccf247141f90433736 Mon Sep 17 00:00:00 2001 +From: pennam +Date: Thu, 14 Nov 2024 15:57:44 +0100 +Subject: [PATCH] GEMALTO CINTERION: disable runtime model detection + + cellular_properties must be configured in ctor to properly configure all network urcs +--- + .../GEMALTO/CINTERION/GEMALTO_CINTERION.cpp | 39 ++++++------------- + 1 file changed, 11 insertions(+), 28 deletions(-) + +diff --git a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION.cpp b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION.cpp +index 40e74ab98f..3754ad50ec 100644 +--- a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION.cpp ++++ b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION.cpp +@@ -29,6 +29,17 @@ GEMALTO_CINTERION::Module GEMALTO_CINTERION::_module; + + GEMALTO_CINTERION::GEMALTO_CINTERION(FileHandle *fh) : AT_CellularDevice(fh) + { ++#if defined(MBED_CONF_GEMALTO_CINTERION_ELS61) ++ init_module_els61(); ++#elif defined(MBED_CONF_GEMALTO_CINTERION_BGS2) ++ init_module_bgs2(); ++#elif defined(MBED_CONF_GEMALTO_CINTERION_EMS31) ++ init_module_ems31(); ++#elif defined(MBED_CONF_GEMALTO_CINTERION_EHS5E) ++ init_module_ehs5e(); ++#else ++ init_module_tx62(); ++#endif + } + + AT_CellularContext *GEMALTO_CINTERION::create_context_impl(ATHandler &at, const char *apn, bool cp_req, bool nonip_req) +@@ -60,35 +71,7 @@ nsapi_error_t GEMALTO_CINTERION::init() + if (err != NSAPI_ERROR_OK) { + return err; + } +- +- CellularInformation *information = open_information(); +- if (!information) { +- return NSAPI_ERROR_NO_MEMORY; +- } +- char model[sizeof("EHS5-E") + 1]; // sizeof need to be long enough to hold just the model text +- nsapi_error_t ret = information->get_model(model, sizeof(model)); +- close_information(); +- if (ret != NSAPI_ERROR_OK) { +- tr_error("Cellular model not found!"); +- return NSAPI_ERROR_DEVICE_ERROR; +- } +- if (memcmp(model, "ELS61", sizeof("ELS61") - 1) == 0) { +- init_module_els61(); +- } else if (memcmp(model, "BGS2", sizeof("BGS2") - 1) == 0) { +- init_module_bgs2(); +- } else if (memcmp(model, "EMS31", sizeof("EMS31") - 1) == 0) { +- init_module_ems31(); +- } else if (memcmp(model, "EHS5-E", sizeof("EHS5-E") - 1) == 0) { +- init_module_ehs5e(); +- } else if (memcmp(model, "TX62", sizeof("TX62") - 1) == 0) { +- init_module_tx62(); +- } else { +- tr_error("Cinterion model unsupported %s", model); +- return NSAPI_ERROR_UNSUPPORTED; +- } +- tr_info("Cinterion model %s (%d)", model, _module); + set_at_urcs(); +- + return NSAPI_ERROR_OK; + } + +-- +2.45.2 + diff --git a/patches/0257-GEMALTO-CONTERION-add-ping.patch b/patches/0257-GEMALTO-CONTERION-add-ping.patch new file mode 100644 index 000000000..de6012bdc --- /dev/null +++ b/patches/0257-GEMALTO-CONTERION-add-ping.patch @@ -0,0 +1,53 @@ +From 09a4787109efd233aded2b960fcdfa10587eec9d Mon Sep 17 00:00:00 2001 +From: pennam +Date: Thu, 14 Nov 2024 15:59:37 +0100 +Subject: [PATCH] GEMALTO CONTERION: add ping + +--- + .../GEMALTO_CINTERION_CellularStack.cpp | 17 +++++++++++++++++ + .../CINTERION/GEMALTO_CINTERION_CellularStack.h | 1 + + 2 files changed, 18 insertions(+) + +diff --git a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp +index f96ae481f0..938cdbfef2 100644 +--- a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp ++++ b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp +@@ -224,6 +224,23 @@ void GEMALTO_CINTERION_CellularStack::PSMDisable() { + } + } + ++int GEMALTO_CINTERION_CellularStack::ping(const char *host, int ttl) ++{ ++ MBED_ASSERT(host); ++ ++ _at.lock(); ++ _at.set_at_timeout(ttl + 1000); ++ _at.cmd_start_stop("^SISX", "=", "%s%d%s%d%d", "Ping", _cid, host, 1, ttl); ++ _at.resp_start("^SISX: \"Ping\","); ++ _at.skip_param(3); //pingInfoType, conProfileId, ip-address ++ int rTT = _at.read_int(); //roundTripTime ++ _at.resp_stop(); ++ _at.clear_error(); ++ _at.restore_at_timeout(); ++ _at.unlock(); ++ return rTT; ++} ++ + nsapi_error_t GEMALTO_CINTERION_CellularStack::socket_stack_init() + { + _at.lock(); +diff --git a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.h b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.h +index f89da8c314..159ea68aa9 100644 +--- a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.h ++++ b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.h +@@ -43,6 +43,7 @@ public: + void stopGNSS(); + void PSMEnable(); + void PSMDisable(); ++ int ping(const char *host, int ttl); + + protected: + +-- +2.45.2 + diff --git a/patches/0258-GEMALTO-CINTERION-fix-gethostbyname.patch b/patches/0258-GEMALTO-CINTERION-fix-gethostbyname.patch new file mode 100644 index 000000000..730a4c690 --- /dev/null +++ b/patches/0258-GEMALTO-CINTERION-fix-gethostbyname.patch @@ -0,0 +1,25 @@ +From 46b1511db274990eb52e89c31e3e26af01d48d38 Mon Sep 17 00:00:00 2001 +From: pennam +Date: Thu, 14 Nov 2024 16:00:17 +0100 +Subject: [PATCH] GEMALTO CINTERION: fix gethostbyname() + + Add missing _at.unlock() +--- + .../GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp +index 938cdbfef2..8f7b44818a 100644 +--- a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp ++++ b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp +@@ -309,6 +309,7 @@ nsapi_error_t GEMALTO_CINTERION_CellularStack::gethostbyname(const char *host, S + } else { + //Null string received + tr_info("Read %d bytes. Null string", size); ++ _at.unlock(); + return NSAPI_ERROR_NO_ADDRESS; + } + } +-- +2.45.2 + diff --git a/patches/0259-CellularStateMachine-wait-and-retry-if-signal-qualit.patch b/patches/0259-CellularStateMachine-wait-and-retry-if-signal-qualit.patch new file mode 100644 index 000000000..ebe18ff8c --- /dev/null +++ b/patches/0259-CellularStateMachine-wait-and-retry-if-signal-qualit.patch @@ -0,0 +1,26 @@ +From fd40e55bb7b121a0485bec2159672673b6c9bbf4 Mon Sep 17 00:00:00 2001 +From: pennam +Date: Thu, 14 Nov 2024 16:03:10 +0100 +Subject: [PATCH] CellularStateMachine: wait and retry if signal + quality is unknown + +--- + .../cellular/source/framework/device/CellularStateMachine.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/connectivity/cellular/source/framework/device/CellularStateMachine.cpp b/connectivity/cellular/source/framework/device/CellularStateMachine.cpp +index 37416ca72e..a87c9e0d02 100644 +--- a/connectivity/cellular/source/framework/device/CellularStateMachine.cpp ++++ b/connectivity/cellular/source/framework/device/CellularStateMachine.cpp +@@ -458,7 +458,7 @@ void CellularStateMachine::state_signal_quality() + { + _cb_data.error = _network.get_signal_quality(_signal_quality.rssi, &_signal_quality.ber); + +- if (_cb_data.error != NSAPI_ERROR_OK) { ++ if ((_cb_data.error != NSAPI_ERROR_OK) || (_signal_quality.rssi == CellularNetwork::SignalQuality::SignalQualityUnknown)) { + retry_state_or_fail(); + } else { + _cb_data.data = &_signal_quality; +-- +2.45.2 + diff --git a/patches/0260-GEMALTO-CINTERION-fix-RECV-urc-while-reading-cornerc.patch b/patches/0260-GEMALTO-CINTERION-fix-RECV-urc-while-reading-cornerc.patch new file mode 100644 index 000000000..6a9a09835 --- /dev/null +++ b/patches/0260-GEMALTO-CINTERION-fix-RECV-urc-while-reading-cornerc.patch @@ -0,0 +1,26 @@ +From b1dabe5a8983493bab170e2d8b8f2a1ba40e4199 Mon Sep 17 00:00:00 2001 +From: pennam +Date: Fri, 15 Nov 2024 11:37:52 +0100 +Subject: [PATCH] GEMALTO CINTERION fix RECV urc while reading + cornercase + +--- + .../GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp +index 8f7b44818a..d164f85eb2 100644 +--- a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp ++++ b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp +@@ -598,6 +598,8 @@ sisr_retry: + if (len == 0) { + tr_debug("Socket %d no data", socket->id); + _at.resp_stop(); ++ _at.process_oob(); ++ socket->pending_bytes = 0; + RESTORE_URCs_AND_RETURN(NSAPI_ERROR_WOULD_BLOCK); + } + if (len == -1) { +-- +2.45.2 + diff --git a/patches/0261-GEMALTO-CINTERION-add-1ms-sleep-in-socket-sendto.patch b/patches/0261-GEMALTO-CINTERION-add-1ms-sleep-in-socket-sendto.patch new file mode 100644 index 000000000..41f843488 --- /dev/null +++ b/patches/0261-GEMALTO-CINTERION-add-1ms-sleep-in-socket-sendto.patch @@ -0,0 +1,33 @@ +From ec7cc4e660b366364d8b11e4ee6480c41141ff04 Mon Sep 17 00:00:00 2001 +From: pennam +Date: Wed, 26 Mar 2025 15:08:40 +0100 +Subject: [PATCH] GEMALTO CINTERION: add 1ms sleep in socket sendto + +--- + .../GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp +index d164f85eb2..898f81cf66 100644 +--- a/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp ++++ b/connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp +@@ -19,6 +19,7 @@ + #include "GEMALTO_CINTERION_CellularStack.h" + #include "GEMALTO_CINTERION.h" + #include "CellularLog.h" ++#include "platform/mbed_thread.h" + #include "rtos.h" + + using namespace std::chrono_literals; +@@ -538,6 +539,8 @@ sisw_retry: + socket->tx_ready = false; + } + ++ thread_sleep_for(1); // wait for modem to process the data; ++ + return (_at.get_last_error() == NSAPI_ERROR_OK) ? accept_len : NSAPI_ERROR_DEVICE_ERROR; + } + +-- +2.47.2 + diff --git a/variants/EDGE_CONTROL/defines.txt b/variants/EDGE_CONTROL/defines.txt index 4fd396229..ac0303327 100644 --- a/variants/EDGE_CONTROL/defines.txt +++ b/variants/EDGE_CONTROL/defines.txt @@ -38,7 +38,7 @@ -DFEATURE_STORAGE=1 -D__FPU_PRESENT=1 -D__MBED__=1 --DMBED_BUILD_TIMESTAMP=1738678638.4581091 +-DMBED_BUILD_TIMESTAMP=1746428391.1444259 -D__MBED_CMSIS_RTOS_CM -DMBED_MPU_CUSTOM -DMBED_TICKLESS diff --git a/variants/EDGE_CONTROL/libs/libmbed.a b/variants/EDGE_CONTROL/libs/libmbed.a index d42e1137e..5a06e5436 100644 Binary files a/variants/EDGE_CONTROL/libs/libmbed.a and b/variants/EDGE_CONTROL/libs/libmbed.a differ diff --git a/variants/OPTA/pins_arduino.h b/variants/OPTA/pins_arduino.h index 301ac30aa..107190dc8 100644 --- a/variants/OPTA/pins_arduino.h +++ b/variants/OPTA/pins_arduino.h @@ -68,6 +68,16 @@ static const uint8_t A6 = PIN_A6; static const uint8_t A7 = PIN_A7; #define ADC_RESOLUTION 12 +// Pin mapping to match serigraphy +static const uint8_t I1 = PIN_A0; +static const uint8_t I2 = PIN_A1; +static const uint8_t I3 = PIN_A2; +static const uint8_t I4 = PIN_A3; +static const uint8_t I5 = PIN_A4; +static const uint8_t I6 = PIN_A5; +static const uint8_t I7 = PIN_A6; +static const uint8_t I8 = PIN_A7; + // Digital pins // ----------- #define D0 (0u) diff --git a/variants/PORTENTA_H7_M7/defines.txt b/variants/PORTENTA_H7_M7/defines.txt index 24f4526bd..265592ef9 100644 --- a/variants/PORTENTA_H7_M7/defines.txt +++ b/variants/PORTENTA_H7_M7/defines.txt @@ -46,7 +46,7 @@ -D__FPU_PRESENT=1 -DLSE_STARTUP_TIMEOUT=200 -D__MBED__=1 --DMBED_BUILD_TIMESTAMP=1738678521.1974137 +-DMBED_BUILD_TIMESTAMP=1746428317.212161 -D__MBED_CMSIS_RTOS_CM -DMBED_TICKLESS -DMBEDTLS_FS_IO diff --git a/variants/PORTENTA_H7_M7/libs/libmbed.a b/variants/PORTENTA_H7_M7/libs/libmbed.a index 286f51da4..9503ff67e 100644 Binary files a/variants/PORTENTA_H7_M7/libs/libmbed.a and b/variants/PORTENTA_H7_M7/libs/libmbed.a differ