diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index 645f35f96..6cb1406db 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -34,14 +34,25 @@ jobs: matrix: board: - fqbn: arduino:mbed:nano33ble + id: nano33ble - fqbn: arduino:mbed:envie_m7 + id: envie_m7 + - fqbn: arduino:mbed:envie_m7:target_core=cm4 + id: envie_m7_core_cm4 - fqbn: arduino:mbed:nanorp2040connect + id: nanorp2040connect - fqbn: arduino:mbed:nicla_sense + id: nicla_sense - fqbn: arduino:mbed:nicla_vision + id: nicla_vision - fqbn: arduino:mbed:opta + id: opta - fqbn: arduino:mbed:giga + id: giga - fqbn: arduino:mbed:nicla_voice + id: nicla_voice - fqbn: arduino:mbed:edge_control + id: edge_control # compile only the examples compatible with each board include: @@ -187,11 +198,11 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 # The source files are in a subfolder of the ArduinoCore-API repository, so it's not possible to clone it directly to the final destination in the core - name: Checkout ArduinoCore-API - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: repository: arduino/ArduinoCore-API path: ArduinoCore-API @@ -226,7 +237,7 @@ jobs: - name: Save memory usage change report as artifact if: github.event_name == 'pull_request' - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: path: ${{ env.SKETCHES_REPORTS_PATH }} - name: ${{ env.SKETCHES_REPORTS_PATH }} + name: ${{ env.SKETCHES_REPORTS_PATH }}-${{ matrix.board.id }} diff --git a/boards.txt b/boards.txt index ae6dd2246..cd3801c15 100644 --- a/boards.txt +++ b/boards.txt @@ -443,6 +443,8 @@ nicla_sense.upload.wait_for_upload_port=true 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.bootloader.tool=openocd nicla_sense.bootloader.tool.default=openocd @@ -496,6 +498,8 @@ nicla_voice.upload.wait_for_upload_port=true 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.bootloader.tool=openocd nicla_voice.bootloader.tool.default=openocd @@ -763,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 @@ -788,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 @@ -821,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 @@ -851,4 +871,58 @@ giga.debug.server.openocd.scripts.1={programmer.transport_script} giga.debug.server.openocd.scripts.2=target/stm32h7x_dual_bank.cfg giga.debug.cortex-debug.custom.request=attach giga.menu.target_core.cm7.debug.svd_file={runtime.platform.path}/svd/STM32H747_CM7.svd -giga.menu.target_core.cm4.debug.svd_file={runtime.platform.path}/svd/STM32H747_CM4.svd \ No newline at end of file +giga.menu.target_core.cm4.debug.svd_file={runtime.platform.path}/svd/STM32H747_CM4.svd + +############################################################## + +stella.name=Arduino Stella +stella.build.core=arduino +stella.build.crossprefix=arm-none-eabi- +stella.build.compiler_path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/ + +stella.build.variant=STELLA +stella.build.mcu=cortex-m4 +stella.build.extra_flags= +stella.build.architecture=cortex-m4 +stella.build.fpu=-mfpu=fpv4-sp-d16 +stella.build.float-abi=-mfloat-abi=softfp +stella.build.board=STELLA +stella.build.ldscript=linker_script.ld +stella.compiler.mbed.arch.define=-DARDUINO_ARCH_NRF52840 +stella.compiler.mbed.defines={build.variant.path}/defines.txt +stella.compiler.mbed.ldflags={build.variant.path}/ldflags.txt +stella.compiler.mbed.cflags={build.variant.path}/cflags.txt +stella.compiler.mbed.cxxflags={build.variant.path}/cxxflags.txt +stella.compiler.mbed.includes={build.variant.path}/includes.txt +stella.compiler.mbed.extra_ldflags=-lstdc++ -lsupc++ -lm -lc -lgcc -lnosys +stella.compiler.mbed="{build.variant.path}/libs/libmbed.a" "{build.variant.path}/libs/libcc_310_core.a" "{build.variant.path}/libs/libcc_310_ext.a" "{build.variant.path}/libs/libcc_310_trng.a" +stella.vid.0=0x2341 +stella.pid.0=0x005a +stella.vid.1=0x2341 +stella.pid.1=0x0076 +stella.upload_port.0.vid=0x2341 +stella.upload_port.0.pid=0x005a +stella.upload_port.1.vid=0x2341 +stella.upload_port.1.pid=0x0076 + +stella.upload.tool=bossac +stella.upload.tool.default=bossac +stella.upload.protocol= +stella.upload.transport= +stella.upload.use_1200bps_touch=true +stella.upload.wait_for_upload_port=true +stella.upload.native_usb=true +stella.upload.maximum_size=983040 +stella.upload.maximum_data_size=262144 + +stella.bootloader.tool=openocd +stella.bootloader.tool.default=openocd +stella.bootloader.extra_action.preflash=echo INFO:removed_mass-erase +stella.bootloader.config=-f target/nrf52.cfg +stella.bootloader.programmer=-f interface/cmsis-dap.cfg +stella.bootloader.file=nano33ble/bootloader.hex + +stella.debug.server.openocd.scripts.0=interface/{programmer.protocol}.cfg +stella.debug.server.openocd.scripts.1={programmer.transport_script} +stella.debug.server.openocd.scripts.2=target/nrf52.cfg +stella.debug.svd_file={runtime.platform.path}/svd/nrf52840.svd diff --git a/cores/arduino/Serial.h b/cores/arduino/Serial.h index f511256ad..2cdd7c0f4 100644 --- a/cores/arduino/Serial.h +++ b/cores/arduino/Serial.h @@ -76,7 +76,6 @@ class UART : public HardwareSerial { mbed_usb_serial* _usb_serial = NULL; PinName _tx, _rx, _rts, _cts; RingBufferN<256> rx_buffer; - uint8_t intermediate_buf[4]; bool is_usb = false; }; } 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/cores/arduino/mbed/connectivity/drivers/emac/COMPONENT_WHD/interface/WhdSTAInterface.h b/cores/arduino/mbed/connectivity/drivers/emac/COMPONENT_WHD/interface/WhdSTAInterface.h index 4dd109894..8d8f54075 100644 --- a/cores/arduino/mbed/connectivity/drivers/emac/COMPONENT_WHD/interface/WhdSTAInterface.h +++ b/cores/arduino/mbed/connectivity/drivers/emac/COMPONENT_WHD/interface/WhdSTAInterface.h @@ -119,6 +119,12 @@ class WhdSTAInterface : public WiFiInterface, public EMACInterface { return 0; } + nsapi_error_t set_timeout(uint32_t timeout) + { + _timeout = timeout; + return NSAPI_ERROR_OK; + } + /** Set blocking status of interface. * Nonblocking mode unsupported. * @@ -257,6 +263,7 @@ class WhdSTAInterface : public WiFiInterface, public EMACInterface { nsapi_security_t _security; WHD_EMAC &_whd_emac; OlmInterface *_olm; + uint32_t _timeout; whd_interface_shared_info_t &_iface_shared; }; diff --git a/cores/arduino/mbed/connectivity/drivers/emac/TARGET_STM/stm32xx_emac.h b/cores/arduino/mbed/connectivity/drivers/emac/TARGET_STM/stm32xx_emac.h index cfa675217..ecc280b2f 100644 --- a/cores/arduino/mbed/connectivity/drivers/emac/TARGET_STM/stm32xx_emac.h +++ b/cores/arduino/mbed/connectivity/drivers/emac/TARGET_STM/stm32xx_emac.h @@ -148,6 +148,13 @@ class STM32_EMAC : public EMAC { */ virtual void set_memory_manager(EMACMemoryManager &mem_mngr); + /* return the status of the interface as integer */ + int get_interface_status() override; + /* return true if the interface is in the correct state to transmit */ + bool is_ready_to_tx() override; + /* restart only if the interface is in error state */ + void restart() override; + // Called from driver functions ETH_HandleTypeDef EthHandle; osThreadId_t thread; /**< Processing thread */ diff --git a/cores/arduino/mbed/connectivity/drivers/wifi/COMPONENT_WHD/wifi-host-driver/inc/whd_version.h b/cores/arduino/mbed/connectivity/drivers/wifi/COMPONENT_WHD/wifi-host-driver/inc/whd_version.h index 1caef23b6..5f69d8c3e 100755 --- a/cores/arduino/mbed/connectivity/drivers/wifi/COMPONENT_WHD/wifi-host-driver/inc/whd_version.h +++ b/cores/arduino/mbed/connectivity/drivers/wifi/COMPONENT_WHD/wifi-host-driver/inc/whd_version.h @@ -15,6 +15,7 @@ * limitations under the License. */ -#define WHD_VERSION "v1.94.0" +/* This define is used by arduino::WiFiClass::firmwareVersion() do not prepend v */ +#define WHD_VERSION "1.94.0" #define WHD_BRANCH "v1.94.0" #define WHD_DATE "2021-04-27 16:54:34 +0800" diff --git a/cores/arduino/mbed/connectivity/drivers/wifi/COMPONENT_WHD/wifi-host-driver/inc/whd_wifi_api.h b/cores/arduino/mbed/connectivity/drivers/wifi/COMPONENT_WHD/wifi-host-driver/inc/whd_wifi_api.h index f3b73214c..291bd23de 100755 --- a/cores/arduino/mbed/connectivity/drivers/wifi/COMPONENT_WHD/wifi-host-driver/inc/whd_wifi_api.h +++ b/cores/arduino/mbed/connectivity/drivers/wifi/COMPONENT_WHD/wifi-host-driver/inc/whd_wifi_api.h @@ -281,7 +281,7 @@ extern uint32_t whd_wifi_stop_scan(whd_interface_t ifp); * Error code if an error occurred */ extern uint32_t whd_wifi_join(whd_interface_t ifp, const whd_ssid_t *ssid, whd_security_t auth_type, - const uint8_t *security_key, uint8_t key_length); + const uint8_t *security_key, uint8_t key_length, uint32_t timeout); /** Joins a specific Wi-Fi network * diff --git a/cores/arduino/mbed/connectivity/netsocket/include/netsocket/EMAC.h b/cores/arduino/mbed/connectivity/netsocket/include/netsocket/EMAC.h index 515629b5a..885bc92c0 100644 --- a/cores/arduino/mbed/connectivity/netsocket/include/netsocket/EMAC.h +++ b/cores/arduino/mbed/connectivity/netsocket/include/netsocket/EMAC.h @@ -176,6 +176,17 @@ class EMAC { * @param mem_mngr Pointer to memory manager */ virtual void set_memory_manager(EMACMemoryManager &mem_mngr) = 0; + + virtual bool is_ready_to_tx() { + return true; + } + + virtual void restart() { + } + + virtual int get_interface_status() { + return -1; + } }; diff --git a/cores/arduino/mbed/connectivity/netsocket/include/netsocket/EMACInterface.h b/cores/arduino/mbed/connectivity/netsocket/include/netsocket/EMACInterface.h index 8cf47cb70..c06aeb850 100644 --- a/cores/arduino/mbed/connectivity/netsocket/include/netsocket/EMACInterface.h +++ b/cores/arduino/mbed/connectivity/netsocket/include/netsocket/EMACInterface.h @@ -83,6 +83,12 @@ class EMACInterface : public virtual NetworkInterface { /** @copydoc NetworkInterface::disconnect */ nsapi_error_t disconnect() override; + /** @copydoc NetworkInterface::get_hostname */ + const char *get_hostname() override; + + /** @copydoc NetworkInterface::set_hostname */ + nsapi_error_t set_hostname(const char *hostname) override; + /** @copydoc NetworkInterface::get_mac_address */ const char *get_mac_address() override; @@ -146,6 +152,8 @@ class EMACInterface : public virtual NetworkInterface { OnboardNetworkStack::Interface *_interface = nullptr; bool _dhcp = true; bool _blocking = true; + bool _hostname_set = false; + char _hostname[NSAPI_HOSTNAME_SIZE]; bool _hw_mac_addr_set = false; char _mac_address[NSAPI_MAC_SIZE]; char _ip_address[NSAPI_IPv6_SIZE] {}; diff --git a/cores/arduino/mbed/connectivity/netsocket/include/netsocket/ICMPSocket.h b/cores/arduino/mbed/connectivity/netsocket/include/netsocket/ICMPSocket.h index 1837bc8e0..5e1ee8fb0 100644 --- a/cores/arduino/mbed/connectivity/netsocket/include/netsocket/ICMPSocket.h +++ b/cores/arduino/mbed/connectivity/netsocket/include/netsocket/ICMPSocket.h @@ -37,6 +37,10 @@ class ICMPSocket : public InternetDatagramSocket { */ ICMPSocket(); +#if MBED_CONF_LWIP_RAW_SOCKET_ENABLED + int ping(SocketAddress &socketAddress, uint32_t timeout); +#endif + #if !defined(DOXYGEN_ONLY) protected: diff --git a/cores/arduino/mbed/connectivity/netsocket/include/netsocket/NetworkInterface.h b/cores/arduino/mbed/connectivity/netsocket/include/netsocket/NetworkInterface.h index 9071a1e40..22355767c 100644 --- a/cores/arduino/mbed/connectivity/netsocket/include/netsocket/NetworkInterface.h +++ b/cores/arduino/mbed/connectivity/netsocket/include/netsocket/NetworkInterface.h @@ -90,6 +90,24 @@ class NetworkInterface: public DNS { */ virtual void set_as_default(); + /** Get hostname. + * + * @return Hostname if configured, null otherwise + */ + virtual const char *get_hostname(); + + /** Set hostname. + * + * @param hostname Hostname string + * @retval NSAPI_ERROR_OK on success + * @retval NSAPI_ERROR_UNSUPPORTED if this feature is not supported + * @retval NSAPI_ERROR_PARAMETER if hostname is not valid + * @retval NSAPI_ERROR_BUSY if hostname couldn't be set (e.g. for + * LwIP stack, hostname can only be set before calling + * \c EthernetInterface::connect method) + */ + virtual nsapi_error_t set_hostname(const char *hostname); + /** Get the local MAC address. * * Provided MAC address is intended for info or debug purposes and diff --git a/cores/arduino/mbed/connectivity/netsocket/include/netsocket/TLSSocketWrapper.h b/cores/arduino/mbed/connectivity/netsocket/include/netsocket/TLSSocketWrapper.h index 2dc3b4b00..79fe5c564 100644 --- a/cores/arduino/mbed/connectivity/netsocket/include/netsocket/TLSSocketWrapper.h +++ b/cores/arduino/mbed/connectivity/netsocket/include/netsocket/TLSSocketWrapper.h @@ -379,6 +379,10 @@ class TLSSocketWrapper : public Socket { Socket *_transport; int _timeout = -1; + // Event flags + static const int READ_FLAG = 0x1u; + static const int WRITE_FLAG = 0x2u; + #ifdef MBEDTLS_X509_CRT_PARSE_C mbedtls_x509_crt *_cacert = nullptr; mbedtls_x509_crt *_clicert = nullptr; diff --git a/cores/arduino/mbed/connectivity/netsocket/include/netsocket/WiFiInterface.h b/cores/arduino/mbed/connectivity/netsocket/include/netsocket/WiFiInterface.h index 4fd7fc6fb..c13cab431 100644 --- a/cores/arduino/mbed/connectivity/netsocket/include/netsocket/WiFiInterface.h +++ b/cores/arduino/mbed/connectivity/netsocket/include/netsocket/WiFiInterface.h @@ -59,6 +59,13 @@ class WiFiInterface: public virtual NetworkInterface { */ virtual nsapi_error_t set_channel(uint8_t channel) = 0; + /** Set the Wi-Fi network join timeout. + * + * @param timeout joint timeout in milliseconds (Default: 7000). + * @return NSAPI_ERROR_OK on success, or error code on failure. + */ + virtual nsapi_error_t set_timeout(uint32_t timeout) = 0; + /** Get the current radio signal strength for active connection. * * @return Connection strength in dBm (negative value), diff --git a/cores/arduino/mbed/connectivity/netsocket/include/netsocket/nsapi_types.h b/cores/arduino/mbed/connectivity/netsocket/include/netsocket/nsapi_types.h index 3b496d508..28dbcc9a3 100644 --- a/cores/arduino/mbed/connectivity/netsocket/include/netsocket/nsapi_types.h +++ b/cores/arduino/mbed/connectivity/netsocket/include/netsocket/nsapi_types.h @@ -196,6 +196,16 @@ typedef enum nsapi_security { */ #define NSAPI_IP_BYTES NSAPI_IPv6_BYTES +/** Maximum size of hostname + * + * According to RFC 1034 [1], Section 3.1 "Name space specifications and + * terminology", 63 is the maximum size of a hostname. +1 for the string + * terminator. + * + * [1] https://www.rfc-editor.org/rfc/rfc1034 + */ +#define NSAPI_HOSTNAME_SIZE 64 + /** Maximum size of MAC address representation */ #define NSAPI_MAC_SIZE 18 diff --git a/cores/arduino/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/TARGET_STELLA/PinNames.h b/cores/arduino/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/TARGET_STELLA/PinNames.h new file mode 100644 index 000000000..b4ef8a160 --- /dev/null +++ b/cores/arduino/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/TARGET_STELLA/PinNames.h @@ -0,0 +1,246 @@ +/* + * Copyright (c) 2019 Arduino SA + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* MBED TARGET LIST: ARDUINO_NANO33BLE */ + +#ifndef MBED_PINNAMES_H +#define MBED_PINNAMES_H + +#include "cmsis.h" +#include "nrf_gpio.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + PIN_INPUT, + PIN_OUTPUT +} PinDirection; + +///> define macro producing for example Px_y = NRF_GPIO_PIN_MAP(x, y) +#define PinDef(port_num, pin_num) P##port_num##_##pin_num = NRF_GPIO_PIN_MAP(port_num, pin_num) + + +typedef enum { + PinDef(0 , 0), // P0_0 = 0... + PinDef(0 , 1), + PinDef(0 , 2), + PinDef(0 , 3), + PinDef(0 , 4), + PinDef(0 , 5), + PinDef(0 , 6), + PinDef(0 , 7), + PinDef(0 , 8), + PinDef(0 , 9), + PinDef(0 , 10), + PinDef(0 , 11), + PinDef(0 , 12), + PinDef(0 , 13), + PinDef(0 , 14), + PinDef(0 , 15), + PinDef(0 , 16), + PinDef(0 , 17), + PinDef(0 , 18), + PinDef(0 , 19), + PinDef(0 , 20), + PinDef(0 , 21), + PinDef(0 , 22), + PinDef(0 , 23), + PinDef(0 , 24), + PinDef(0 , 25), + PinDef(0 , 26), + PinDef(0 , 27), + PinDef(0 , 28), + PinDef(0 , 29), + PinDef(0 , 30), + PinDef(0 , 31), + + PinDef(1 , 0), //P1_1 = 32... + PinDef(1 , 1), + PinDef(1 , 2), + PinDef(1 , 3), + PinDef(1 , 4), + PinDef(1 , 5), + PinDef(1 , 6), + PinDef(1 , 7), + PinDef(1 , 8), + PinDef(1 , 9), + PinDef(1 , 10), + PinDef(1 , 11), + PinDef(1 , 12), + PinDef(1 , 13), + PinDef(1 , 14), + PinDef(1 , 15), + + // Port0 + p0 = P0_0, + p1 = P0_1, + p2 = P0_2, + p3 = P0_3, + p4 = P0_4, + p5 = P0_5, + p6 = P0_6, + p7 = P0_7, + p8 = P0_8, + p9 = P0_9, + p10 = P0_10, + p11 = P0_11, + p12 = P0_12, + p13 = P0_13, + p14 = P0_14, + p15 = P0_15, + p16 = P0_16, + p17 = P0_17, + p18 = P0_18, + p19 = P0_19, + p20 = P0_20, + p21 = P0_21, + p22 = P0_22, + p23 = P0_23, + p24 = P0_24, + p25 = P0_25, + p26 = P0_26, + p27 = P0_27, + p28 = P0_28, + p29 = P0_29, + p30 = P0_30, + p31 = P0_31, + + // Port1 + p32 = P1_0, + p33 = P1_1, + p34 = P1_2, + p35 = P1_3, + p36 = P1_4, + p37 = P1_5, + p38 = P1_6, + p39 = P1_7, + p40 = P1_8, + p41 = P1_9, + p42 = P1_10, + p43 = P1_11, + p44 = P1_12, + p45 = P1_13, + p46 = P1_14, + p47 = P1_15, + + RX_PIN_NUMBER = P1_10, + TX_PIN_NUMBER = P1_3, + + LED_BUILTIN = P0_13, + LED_POWER = P1_9, + + LED_RED = p24, + LED_GREEN = p16, + LED_BLUE = p6, + + LED1 = LED_BUILTIN, + LED2 = LED_RED, + LED3 = LED_GREEN, + LED4 = LED_BLUE, + + // mBed interface Pins + CONSOLE_TX = TX_PIN_NUMBER, + CONSOLE_RX = RX_PIN_NUMBER, +#if defined(MBED_CONF_TARGET_STDIO_UART_TX) + STDIO_UART_TX = MBED_CONF_TARGET_STDIO_UART_TX, +#else + STDIO_UART_TX = CONSOLE_TX, +#endif +#if defined(MBED_CONF_TARGET_STDIO_UART_RX) + STDIO_UART_RX = MBED_CONF_TARGET_STDIO_UART_RX, +#else + STDIO_UART_RX = CONSOLE_RX, +#endif + + SPI_PSELMOSI0 = P1_1, + SPI_PSELMISO0 = P1_8, + SPI_PSELSS0 = P1_2, + SPI_PSELSCK0 = P0_13, + + SPIS_PSELMOSI = P1_1, + SPIS_PSELMISO = P1_8, + SPIS_PSELSS = P1_2, + SPIS_PSELSCK = P0_13, + + I2C_SDA0 = p31, + I2C_SCL0 = p2, + +#ifndef ARDUINO_ARCH_MBED + // Digital Pins + D2 = P1_11, + D3 = P1_12, + D4 = P1_15, + D5 = P1_13, + D6 = P1_14, + D7 = P0_23, + D8 = P0_21, + D9 = P0_27, + D10 = P1_2, + D11 = P1_1, + D12 = P1_8, + D13 = P0_13, + + // Analog Pins + A0 = p4, + A1 = p5, + A2 = p30, + A3 = p29, + A4 = p31, + A5 = p2, + A6 = p28, + A7 = p3, +#endif + + AIN0 = p4, + AIN1 = p5, + AIN2 = p30, + AIN3 = p29, + AIN6 = p28, + AIN7 = p3, + + // Arduino Nano 33 BLE Sense Pins + VDD_ENV = p22, + INT_APDS = p19, + + I2C_SDA1 = p14, + I2C_SCL1 = p15, + + MIC_PWR = p17, + PDM_CLK = p26, + PDM_DIN = p25, + + // Not connected + NC = (int)0xFFFFFFFF, + + STDIO_UART_RTS = NC, + STDIO_UART_CTS = NC, + +} PinName; + +typedef enum { + PullNone = 0, + PullDown = 1, + PullUp = 3, + PullDefault = PullUp +} PinMode; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cores/arduino/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/TARGET_STELLA/device.h b/cores/arduino/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/TARGET_STELLA/device.h new file mode 100644 index 000000000..a086e5b7f --- /dev/null +++ b/cores/arduino/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/TARGET_STELLA/device.h @@ -0,0 +1,39 @@ +// The 'features' section in 'target.json' is now used to create the device's hardware preprocessor switches. +// Check the 'features' section of the target description in 'targets.json' for more details. +/* mbed Microcontroller Library + * Copyright (c) 2006-2013 ARM Limited + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef MBED_DEVICE_H +#define MBED_DEVICE_H + + + + + + + + + + + + + + + + +#include "objects.h" + +#endif diff --git a/extras/mbed_edge-tag.template.json b/extras/mbed_edge-tag.template.json new file mode 100644 index 000000000..edbf719e8 --- /dev/null +++ b/extras/mbed_edge-tag.template.json @@ -0,0 +1,53 @@ +{ + "packages": [ + { + "platforms": [ + { + "name": "Arduino Mbed OS Edge Boards", + "architecture": "mbed_edge", + "version": "%%VERSION%%", + "category": "Arduino", + "url": "http://downloads.arduino.cc/cores/staging/%%EDGE_FILENAME%%", + "archiveFileName": "%%EDGE_FILENAME%%", + "checksum": "SHA-256:%%EDGE_CHECKSUM%%", + "size": "%%EDGE_SIZE%%", + "help": { + "online": "https://github.com/arduino/ArduinoCore-mbed/issues" + }, + "boards": [ + { + "name": "Arduino Edge Control" + } + ], + "toolsDependencies": [ + { + "packager": "arduino", + "name": "arm-none-eabi-gcc", + "version": "7-2017q4" + }, + { + "packager": "arduino", + "name": "bossac", + "version": "1.9.1-arduino2" + }, + { + "packager": "arduino", + "name": "dfu-util", + "version": "0.10.0-arduino1" + }, + { + "packager": "arduino", + "name": "openocd", + "version": "0.11.0-arduino2" + }, + { + "packager": "arduino", + "name": "rp2040tools", + "version": "1.0.6" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/extras/mbed_giga-tag.template.json b/extras/mbed_giga-tag.template.json new file mode 100644 index 000000000..a63c6576f --- /dev/null +++ b/extras/mbed_giga-tag.template.json @@ -0,0 +1,48 @@ +{ + "packages": [ + { + "platforms": [ + { + "name": "Arduino Mbed OS Giga Boards", + "architecture": "mbed_giga", + "version": "%%VERSION%%", + "category": "Arduino", + "url": "http://downloads.arduino.cc/cores/staging/%%GIGA_FILENAME%%", + "archiveFileName": "%%GIGA_FILENAME%%", + "checksum": "SHA-256:%%GIGA_CHECKSUM%%", + "size": "%%GIGA_SIZE%%", + "help": { + "online": "https://github.com/arduino/ArduinoCore-mbed/issues" + }, + "boards": [ + { + "name": "Arduino Giga" + } + ], + "toolsDependencies": [ + { + "packager": "arduino", + "name": "arm-none-eabi-gcc", + "version": "7-2017q4" + }, + { + "packager": "arduino", + "name": "dfu-util", + "version": "0.10.0-arduino1" + }, + { + "packager": "arduino", + "name": "imgtool", + "version": "1.8.0-arduino.2" + }, + { + "packager": "arduino", + "name": "openocd", + "version": "0.11.0-arduino2" + } + ] + } + ] + } + ] +} diff --git a/extras/mbed_nano-tag.template.json b/extras/mbed_nano-tag.template.json new file mode 100644 index 000000000..944622f48 --- /dev/null +++ b/extras/mbed_nano-tag.template.json @@ -0,0 +1,59 @@ +{ + "packages": [ + { + "platforms": [ + { + "name": "Arduino Mbed OS Nano Boards", + "architecture": "mbed_nano", + "version": "%%VERSION%%", + "category": "Arduino", + "url": "http://downloads.arduino.cc/cores/staging/%%NANO_FILENAME%%", + "archiveFileName": "%%NANO_FILENAME%%", + "checksum": "SHA-256:%%NANO_CHECKSUM%%", + "size": "%%NANO_SIZE%%", + "help": { + "online": "https://github.com/arduino/ArduinoCore-mbed/issues" + }, + "boards": [ + { + "name": "Arduino Nano 33 BLE" + }, + { + "name": "Arduino Nano 33 BLE Sense" + }, + { + "name": "Arduino Nano RP2040 Connect" + } + ], + "toolsDependencies": [ + { + "packager": "arduino", + "name": "arm-none-eabi-gcc", + "version": "7-2017q4" + }, + { + "packager": "arduino", + "name": "bossac", + "version": "1.9.1-arduino2" + }, + { + "packager": "arduino", + "name": "dfu-util", + "version": "0.10.0-arduino1" + }, + { + "packager": "arduino", + "name": "openocd", + "version": "0.11.0-arduino2" + }, + { + "packager": "arduino", + "name": "rp2040tools", + "version": "1.0.6" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/extras/mbed_nicla-tag.template.json b/extras/mbed_nicla-tag.template.json new file mode 100644 index 000000000..4cffeb9c5 --- /dev/null +++ b/extras/mbed_nicla-tag.template.json @@ -0,0 +1,59 @@ +{ + "packages": [ + { + "platforms": [ + { + "name": "Arduino Mbed OS Nicla Boards", + "architecture": "mbed_nicla", + "version": "%%VERSION%%", + "category": "Arduino", + "url": "http://downloads.arduino.cc/cores/staging/%%NICLA_FILENAME%%", + "archiveFileName": "%%NICLA_FILENAME%%", + "checksum": "SHA-256:%%NICLA_CHECKSUM%%", + "size": "%%NICLA_SIZE%%", + "help": { + "online": "https://github.com/arduino/ArduinoCore-mbed/issues" + }, + "boards": [ + { + "name": "Nicla Sense ME" + }, + { + "name": "Nicla Voice" + }, + { + "name": "Nicla Vision" + } + ], + "toolsDependencies": [ + { + "packager": "arduino", + "name": "arm-none-eabi-gcc", + "version": "7-2017q4" + }, + { + "packager": "arduino", + "name": "bossac", + "version": "1.9.1-arduino2" + }, + { + "packager": "arduino", + "name": "dfu-util", + "version": "0.10.0-arduino1" + }, + { + "packager": "arduino", + "name": "openocd", + "version": "0.11.0-arduino2" + }, + { + "packager": "arduino", + "name": "rp2040tools", + "version": "1.0.6" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/extras/mbed_opta-tag.template.json b/extras/mbed_opta-tag.template.json new file mode 100644 index 000000000..d76b89e49 --- /dev/null +++ b/extras/mbed_opta-tag.template.json @@ -0,0 +1,48 @@ +{ + "packages": [ + { + "platforms": [ + { + "name": "Arduino Mbed OS Opta Boards", + "architecture": "mbed_opta", + "version": "%%VERSION%%", + "category": "Arduino", + "url": "http://downloads.arduino.cc/cores/staging/%%OPTA_FILENAME%%", + "archiveFileName": "%%OPTA_FILENAME%%", + "checksum": "SHA-256:%%OPTA_CHECKSUM%%", + "size": "%%OPTA_SIZE%%", + "help": { + "online": "https://github.com/arduino/ArduinoCore-mbed/issues" + }, + "boards": [ + { + "name": "Arduino Finder Opta" + } + ], + "toolsDependencies": [ + { + "packager": "arduino", + "name": "arm-none-eabi-gcc", + "version": "7-2017q4" + }, + { + "packager": "arduino", + "name": "dfu-util", + "version": "0.10.0-arduino1" + }, + { + "packager": "arduino", + "name": "imgtool", + "version": "1.8.0-arduino.2" + }, + { + "packager": "arduino", + "name": "openocd", + "version": "0.11.0-arduino2" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/extras/mbed_portenta-tag.template.json b/extras/mbed_portenta-tag.template.json new file mode 100644 index 000000000..e73501f94 --- /dev/null +++ b/extras/mbed_portenta-tag.template.json @@ -0,0 +1,56 @@ +{ + "packages": [ + { + "platforms": [ + { + "name": "Arduino Mbed OS Portenta Boards", + "architecture": "mbed_portenta", + "version": "%%VERSION%%", + "category": "Arduino", + "url": "http://downloads.arduino.cc/cores/staging/%%PORTENTA_FILENAME%%", + "archiveFileName": "%%PORTENTA_FILENAME%%", + "checksum": "SHA-256:%%PORTENTA_CHECKSUM%%", + "size": "%%PORTENTA_SIZE%%", + "help": { + "online": "https://github.com/arduino/ArduinoCore-mbed/issues" + }, + "boards": [ + { + "name": "Arduino Portenta H7" + }, + { + "name": "Arduino Portenta X8" + } + ], + "toolsDependencies": [ + { + "packager": "arduino", + "name": "adb", + "version": "32.0.0" + }, + { + "packager": "arduino", + "name": "arm-none-eabi-gcc", + "version": "7-2017q4" + }, + { + "packager": "arduino", + "name": "dfu-util", + "version": "0.10.0-arduino1" + }, + { + "packager": "arduino", + "name": "imgtool", + "version": "1.8.0-arduino.2" + }, + { + "packager": "arduino", + "name": "openocd", + "version": "0.11.0-arduino2" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/extras/mbed_rp2040-tag.template.json b/extras/mbed_rp2040-tag.template.json new file mode 100644 index 000000000..424ffe18c --- /dev/null +++ b/extras/mbed_rp2040-tag.template.json @@ -0,0 +1,53 @@ +{ + "packages": [ + { + "platforms": [ + { + "name": "Arduino Mbed OS RP2040 Boards", + "architecture": "mbed_rp2040", + "version": "%%VERSION%%", + "category": "Arduino", + "url": "http://downloads.arduino.cc/cores/staging/%%RP2040_FILENAME%%", + "archiveFileName": "%%RP2040_FILENAME%%", + "checksum": "SHA-256:%%RP2040_CHECKSUM%%", + "size": "%%RP2040_SIZE%%", + "help": { + "online": "https://github.com/arduino/ArduinoCore-mbed/issues" + }, + "boards": [ + { + "name": "Raspberry Pi Pico" + } + ], + "toolsDependencies": [ + { + "packager": "arduino", + "name": "arm-none-eabi-gcc", + "version": "7-2017q4" + }, + { + "packager": "arduino", + "name": "bossac", + "version": "1.9.1-arduino2" + }, + { + "packager": "arduino", + "name": "dfu-util", + "version": "0.10.0-arduino1" + }, + { + "packager": "arduino", + "name": "openocd", + "version": "0.11.0-arduino2" + }, + { + "packager": "arduino", + "name": "rp2040tools", + "version": "1.0.6" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/extras/mbed_stella-tag.template.json b/extras/mbed_stella-tag.template.json new file mode 100644 index 000000000..d54eef818 --- /dev/null +++ b/extras/mbed_stella-tag.template.json @@ -0,0 +1,53 @@ +{ + "packages": [ + { + "platforms": [ + { + "name": "Arduino Mbed OS Stella Boards", + "architecture": "mbed_stella", + "version": "%%VERSION%%", + "category": "Arduino", + "url": "http://downloads.arduino.cc/cores/staging/%%STELLA_FILENAME%%", + "archiveFileName": "%%STELLA_FILENAME%%", + "checksum": "SHA-256:%%STELLA_CHECKSUM%%", + "size": "%%STELLA_SIZE%%", + "help": { + "online": "https://github.com/arduino/ArduinoCore-mbed/issues" + }, + "boards": [ + { + "name": "Arduino Stella" + } + ], + "toolsDependencies": [ + { + "packager": "arduino", + "name": "arm-none-eabi-gcc", + "version": "7-2017q4" + }, + { + "packager": "arduino", + "name": "bossac", + "version": "1.9.1-arduino2" + }, + { + "packager": "arduino", + "name": "dfu-util", + "version": "0.10.0-arduino1" + }, + { + "packager": "arduino", + "name": "openocd", + "version": "0.11.0-arduino2" + }, + { + "packager": "arduino", + "name": "rp2040tools", + "version": "1.0.6" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/extras/package_index.json.NewTag.template b/extras/package_index.json.NewTag.template deleted file mode 100644 index df360e171..000000000 --- a/extras/package_index.json.NewTag.template +++ /dev/null @@ -1,408 +0,0 @@ -{ - "packages": [ - { - "name": "arduino", - "maintainer": "Arduino", - "websiteURL": "http://www.arduino.cc/", - "email": "packages@arduino.cc", - "help": { - "online": "http://www.arduino.cc/en/Reference/HomePage" - }, - "platforms": [ - { - "name": "[DEPRECATED - Please install standalone packages] Arduino Mbed OS Boards", - "architecture": "mbed", - "version": "%%VERSION%%", - "deprecated": true, - "category": "Arduino", - "url": "http://downloads.arduino.cc/cores/staging/%%FILENAME%%", - "archiveFileName": "%%FILENAME%%", - "checksum": "SHA-256:%%CHECKSUM%%", - "size": "%%SIZE%%", - "help": { - "online": "https://github.com/arduino/ArduinoCore-mbed/issues" - }, - "boards": [ - { - "name": "Arduino Nano 33 BLE" - }, - { - "name": "Arduino Nano 33 BLE Sense" - }, - { - "name": "Arduino Nano RP2040 Connect" - }, - { - "name": "Arduino Portenta H7" - }, - { - "name": "Arduino Edge Control" - }, - { - "name": "Raspberry Pi Pico" - }, - { - "name": "Nicla Sense ME" - }, - { - "name": "Arduino Nicla Vision" - } - ], - "toolsDependencies": [ - { - "packager": "arduino", - "name": "openocd", - "version": "0.11.0-arduino2" - }, - { - "packager": "arduino", - "name": "arm-none-eabi-gcc", - "version": "7-2017q4" - }, - { - "packager": "arduino", - "name": "bossac", - "version": "1.9.1-arduino2" - }, - { - "packager": "arduino", - "version": "0.10.0-arduino1", - "name": "dfu-util" - }, - { - "packager": "arduino", - "version": "1.0.6", - "name": "rp2040tools" - }, - { - "packager": "arduino", - "version": "1.8.0-arduino.2", - "name": "imgtool" - } - ] - }, - { - "name": "Arduino Mbed OS Edge Boards", - "architecture": "mbed_edge", - "version": "%%VERSION%%", - "category": "Arduino", - "url": "http://downloads.arduino.cc/cores/staging/%%EDGE_FILENAME%%", - "archiveFileName": "%%EDGE_FILENAME%%", - "checksum": "SHA-256:%%EDGE_CHECKSUM%%", - "size": "%%EDGE_SIZE%%", - "help": { - "online": "https://github.com/arduino/ArduinoCore-mbed/issues" - }, - "boards": [ - { - "name": "Arduino Edge Control" - } - ], - "toolsDependencies": [ - { - "packager": "arduino", - "name": "openocd", - "version": "0.11.0-arduino2" - }, - { - "packager": "arduino", - "name": "arm-none-eabi-gcc", - "version": "7-2017q4" - }, - { - "packager": "arduino", - "name": "bossac", - "version": "1.9.1-arduino2" - }, - { - "packager": "arduino", - "version": "0.10.0-arduino1", - "name": "dfu-util" - }, - { - "packager": "arduino", - "version": "1.0.6", - "name": "rp2040tools" - } - ] - }, - { - "name": "Arduino Mbed OS Nano Boards", - "architecture": "mbed_nano", - "version": "%%VERSION%%", - "category": "Arduino", - "url": "http://downloads.arduino.cc/cores/staging/%%NANO_FILENAME%%", - "archiveFileName": "%%NANO_FILENAME%%", - "checksum": "SHA-256:%%NANO_CHECKSUM%%", - "size": "%%NANO_SIZE%%", - "help": { - "online": "https://github.com/arduino/ArduinoCore-mbed/issues" - }, - "boards": [ - { - "name": "Arduino Nano 33 BLE" - }, - { - "name": "Arduino Nano 33 BLE Sense" - }, - { - "name": "Arduino Nano RP2040 Connect" - } - ], - "toolsDependencies": [ - { - "packager": "arduino", - "name": "openocd", - "version": "0.11.0-arduino2" - }, - { - "packager": "arduino", - "name": "arm-none-eabi-gcc", - "version": "7-2017q4" - }, - { - "packager": "arduino", - "name": "bossac", - "version": "1.9.1-arduino2" - }, - { - "packager": "arduino", - "version": "0.10.0-arduino1", - "name": "dfu-util" - }, - { - "packager": "arduino", - "version": "1.0.6", - "name": "rp2040tools" - } - ] - }, - { - "name": "Arduino Mbed OS Portenta Boards", - "architecture": "mbed_portenta", - "version": "%%VERSION%%", - "category": "Arduino", - "url": "http://downloads.arduino.cc/cores/staging/%%PORTENTA_FILENAME%%", - "archiveFileName": "%%PORTENTA_FILENAME%%", - "checksum": "SHA-256:%%PORTENTA_CHECKSUM%%", - "size": "%%PORTENTA_SIZE%%", - "help": { - "online": "https://github.com/arduino/ArduinoCore-mbed/issues" - }, - "boards": [ - { - "name": "Arduino Portenta H7" - }, - { - "name": "Arduino Portenta X8" - } - ], - "toolsDependencies": [ - { - "packager": "arduino", - "name": "openocd", - "version": "0.11.0-arduino2" - }, - { - "packager": "arduino", - "name": "arm-none-eabi-gcc", - "version": "7-2017q4" - }, - { - "packager": "arduino", - "version": "0.10.0-arduino1", - "name": "dfu-util" - }, - { - "packager": "arduino", - "version": "1.8.0-arduino.2", - "name": "imgtool" - }, - { - "packager": "arduino", - "version": "32.0.0", - "name": "adb" - } - ] - }, - { - "name": "Arduino Mbed OS RP2040 Boards", - "architecture": "mbed_rp2040", - "version": "%%VERSION%%", - "category": "Arduino", - "url": "http://downloads.arduino.cc/cores/staging/%%RP2040_FILENAME%%", - "archiveFileName": "%%RP2040_FILENAME%%", - "checksum": "SHA-256:%%RP2040_CHECKSUM%%", - "size": "%%RP2040_SIZE%%", - "help": { - "online": "https://github.com/arduino/ArduinoCore-mbed/issues" - }, - "boards": [ - { - "name": "Raspberry Pi Pico" - } - ], - "toolsDependencies": [ - { - "packager": "arduino", - "name": "openocd", - "version": "0.11.0-arduino2" - }, - { - "packager": "arduino", - "name": "arm-none-eabi-gcc", - "version": "7-2017q4" - }, - { - "packager": "arduino", - "name": "bossac", - "version": "1.9.1-arduino2" - }, - { - "packager": "arduino", - "version": "0.10.0-arduino1", - "name": "dfu-util" - }, - { - "packager": "arduino", - "version": "1.0.6", - "name": "rp2040tools" - } - ] - }, - { - "name": "Arduino Mbed OS Nicla Boards", - "architecture": "mbed_nicla", - "version": "%%VERSION%%", - "category": "Arduino", - "url": "http://downloads.arduino.cc/cores/staging/%%NICLA_FILENAME%%", - "archiveFileName": "%%NICLA_FILENAME%%", - "checksum": "SHA-256:%%NICLA_CHECKSUM%%", - "size": "%%NICLA_SIZE%%", - "help": { - "online": "https://github.com/arduino/ArduinoCore-mbed/issues" - }, - "boards": [ - { - "name": "Nicla Sense ME" - }, - { - "name": "Nicla Voice" - }, - { - "name": "Nicla Vision" - } - ], - "toolsDependencies": [ - { - "packager": "arduino", - "name": "openocd", - "version": "0.11.0-arduino2" - }, - { - "packager": "arduino", - "name": "arm-none-eabi-gcc", - "version": "7-2017q4" - }, - { - "packager": "arduino", - "name": "bossac", - "version": "1.9.1-arduino2" - }, - { - "packager": "arduino", - "version": "0.10.0-arduino1", - "name": "dfu-util" - }, - { - "packager": "arduino", - "version": "1.0.6", - "name": "rp2040tools" - } - ] - }, - { - "name": "Arduino Mbed OS Opta Boards", - "architecture": "mbed_opta", - "version": "%%VERSION%%", - "category": "Arduino", - "url": "http://downloads.arduino.cc/cores/staging/%%OPTA_FILENAME%%", - "archiveFileName": "%%OPTA_FILENAME%%", - "checksum": "SHA-256:%%OPTA_CHECKSUM%%", - "size": "%%OPTA_SIZE%%", - "help": { - "online": "https://github.com/arduino/ArduinoCore-mbed/issues" - }, - "boards": [ - { - "name": "Arduino Finder Opta" - } - ], - "toolsDependencies": [ - { - "packager": "arduino", - "name": "openocd", - "version": "0.11.0-arduino2" - }, - { - "packager": "arduino", - "name": "arm-none-eabi-gcc", - "version": "7-2017q4" - }, - { - "packager": "arduino", - "version": "0.10.0-arduino1", - "name": "dfu-util" - }, - { - "packager": "arduino", - "version": "1.8.0-arduino.2", - "name": "imgtool" - } - ] - }, - { - "name": "Arduino Mbed OS Giga Boards", - "architecture": "mbed_giga", - "version": "%%VERSION%%", - "category": "Arduino", - "url": "http://downloads.arduino.cc/cores/staging/%%GIGA_FILENAME%%", - "archiveFileName": "%%GIGA_FILENAME%%", - "checksum": "SHA-256:%%GIGA_CHECKSUM%%", - "size": "%%GIGA_SIZE%%", - "help": { - "online": "https://github.com/arduino/ArduinoCore-mbed/issues" - }, - "boards": [ - { - "name": "Arduino Giga" - } - ], - "toolsDependencies": [ - { - "packager": "arduino", - "name": "openocd", - "version": "0.11.0-arduino2" - }, - { - "packager": "arduino", - "name": "arm-none-eabi-gcc", - "version": "7-2017q4" - }, - { - "packager": "arduino", - "version": "0.10.0-arduino1", - "name": "dfu-util" - }, - { - "packager": "arduino", - "version": "1.8.0-arduino.2", - "name": "imgtool" - } - ] - } - ], - "tools": [] - } - ] -} diff --git a/libraries/Arduino_CAN/src/Arduino_CAN.cpp b/libraries/Arduino_CAN/src/Arduino_CAN.cpp index de74c22c5..30690e83f 100644 --- a/libraries/Arduino_CAN/src/Arduino_CAN.cpp +++ b/libraries/Arduino_CAN/src/Arduino_CAN.cpp @@ -57,7 +57,10 @@ int Arduino_CAN::write(CanMsg const & msg) CANData, is_standard_id ? CANStandard : CANExtended); - return _can.write(can_msg); + int const rc = _can.write(can_msg); + if (rc == 0) /* mbed returns 0 in case of failed CAN::write(). */ + return -1; /* Note: provide named constant in ArduinoCore-API/HardwareCAN.h, i.e. CAN_WRITE_GENERIC_ERROR */ + return 1; } size_t Arduino_CAN::available() 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/examples/ArduinoLogo/ArduinoLogo.ino b/libraries/Arduino_H7_Video/examples/ArduinoLogo/ArduinoLogo.ino index 1c0d0fd0f..9f40fbfb2 100644 --- a/libraries/Arduino_H7_Video/examples/ArduinoLogo/ArduinoLogo.ino +++ b/libraries/Arduino_H7_Video/examples/ArduinoLogo/ArduinoLogo.ino @@ -22,12 +22,23 @@ Arduino_H7_Video Display(800, 480, GigaDisplayShield); Image img_arduinologo(ENCODING_RGB16, (uint8_t *) texture_raw, 300, 300); +void error() { + while (true) { + digitalWrite(LEDR, LOW); + delay(500); + digitalWrite(LEDR, HIGH); + delay(500); + } +} + void setup() { - Display.begin(); + if (Display.begin()) { + error(); + } Display.beginDraw(); Display.image(img_arduinologo, (Display.width() - img_arduinologo.width())/2, (Display.height() - img_arduinologo.height())/2); Display.endDraw(); } -void loop() { } \ No newline at end of file +void loop() { } diff --git a/libraries/Arduino_H7_Video/examples/ArduinoLogoDrawing/ArduinoLogoDrawing.ino b/libraries/Arduino_H7_Video/examples/ArduinoLogoDrawing/ArduinoLogoDrawing.ino index 46ddf35c8..6f4e94be3 100644 --- a/libraries/Arduino_H7_Video/examples/ArduinoLogoDrawing/ArduinoLogoDrawing.ino +++ b/libraries/Arduino_H7_Video/examples/ArduinoLogoDrawing/ArduinoLogoDrawing.ino @@ -11,9 +11,20 @@ Arduino_H7_Video Display(800, 480, GigaDisplayShield); //Arduino_H7_Video Display(1024, 768, USBCVideo); +void error() { + while (true) { + digitalWrite(LEDR, LOW); + delay(500); + digitalWrite(LEDR, HIGH); + delay(500); + } +} + void setup() { - Display.begin(); - + if (Display.begin()) { + error(); + } + Display.beginDraw(); Display.background(255, 255, 255); Display.clear(); @@ -34,4 +45,4 @@ void setup() { Display.endDraw(); } -void loop() { } \ No newline at end of file +void loop() { } diff --git a/libraries/Arduino_H7_Video/examples/LVGLDemo/LVGLDemo.ino b/libraries/Arduino_H7_Video/examples/LVGLDemo/LVGLDemo.ino index 385ead77c..8ef11970b 100644 --- a/libraries/Arduino_H7_Video/examples/LVGLDemo/LVGLDemo.ino +++ b/libraries/Arduino_H7_Video/examples/LVGLDemo/LVGLDemo.ino @@ -28,10 +28,22 @@ static void set_slider_val(void * bar, int32_t val) { lv_bar_set_value((lv_obj_t *)bar, val, LV_ANIM_ON); } +void error() { + while (true) { + digitalWrite(LEDR, LOW); + delay(500); + digitalWrite(LEDR, HIGH); + delay(500); + } +} + void setup() { Serial.begin(115200); - Display.begin(); + if (Display.begin()) { + error(); + } + TouchDetector.begin(); /* Create a container with grid 2x2 */ @@ -140,4 +152,4 @@ void setup() { void loop() { /* Feed LVGL engine */ lv_timer_handler(); -} \ No newline at end of file +} diff --git a/libraries/Arduino_H7_Video/src/Arduino_H7_Video.cpp b/libraries/Arduino_H7_Video/src/Arduino_H7_Video.cpp index 90e075afa..68ee9b01f 100644 --- a/libraries/Arduino_H7_Video/src/Arduino_H7_Video.cpp +++ b/libraries/Arduino_H7_Video/src/Arduino_H7_Video.cpp @@ -89,8 +89,16 @@ int Arduino_H7_Video::begin() { textFont(Font_5x7); #endif +#if defined(ARDUINO_GIGA) + /* Configure SDRAM */ + SDRAM.begin(dsi_getFramebufferEnd()); +#endif + /* Video controller/bridge init */ - _shield->init(_edidMode); + int err_code = _shield->init(_edidMode); + if (err_code < 0) { + return 3; /* Video controller fail init */ + } #if __has_include("lvgl.h") /* Initiliaze LVGL library */ @@ -103,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) { @@ -148,12 +152,13 @@ int Arduino_H7_Video::begin() { } disp_drv.sw_rotate = 1; lv_disp_drv_register(&disp_drv); /* Finally register the driver */ - #endif #endif +#if !defined(ARDUINO_GIGA) /* Configure SDRAM */ SDRAM.begin(dsi_getFramebufferEnd()); //FIXME: SDRAM init after video controller init can cause display glitch at start-up +#endif return 0; } @@ -170,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(); @@ -243,10 +253,14 @@ void lvgl_displayFlushing(lv_display_t * disp, const lv_area_t * area, unsigned if (rotation != LV_DISPLAY_ROTATION_0) { rotated_buf = (uint8_t*)realloc(rotated_buf, w * h * 4); lv_color_format_t cf = lv_display_get_color_format(disp); + #if (LVGL_VERSION_MINOR < 2) + rotation = LV_DISPLAY_ROTATION_90; // bugfix: force 90 degree rotation for lvgl 9.1 end earlier + #endif lv_draw_sw_rotate(px_map, rotated_buf, w, h, lv_draw_buf_width_to_stride(w, cf), lv_draw_buf_width_to_stride(h, cf), - LV_DISPLAY_ROTATION_90, cf); + rotation, cf); + rotated_area.x1 = lv_display_get_vertical_resolution(disp) - area->y2 - 1; rotated_area.y1 = area->x1; //rotated_area.y2 = dsi_getDisplayYSize() - area->x1 - 1; @@ -277,4 +291,4 @@ void lvgl_displayFlushing(lv_disp_drv_t * disp, const lv_area_t * area, lv_color #endif #endif -/**** END OF FILE ****/ \ No newline at end of file +/**** END OF FILE ****/ 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 82356a638..3e9a815fe 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; @@ -31,13 +35,19 @@ int USBCVideoClass::init(int edidmode) { } //Checking HDMI plug event - anx7625_wait_hpd_event(0); + err_code = anx7625_wait_hpd_event(0); + if(err_code < 0) { + return err_code; + } //Read EDID anx7625_dp_get_edid(0, &recognized_edid); //DSI Configuration - anx7625_dp_start(0, &recognized_edid, (enum edid_modes) edidmode); + err_code = anx7625_dp_start(0, &recognized_edid, (enum edid_modes) edidmode); + if(err_code < 0) { + return err_code; + } return 0; } @@ -48,5 +58,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 +USBCVideoClass USBCVideo; 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 552da163f..3cfefce47 100644 --- a/libraries/Arduino_H7_Video/src/anx7625.cpp +++ b/libraries/Arduino_H7_Video/src/anx7625.cpp @@ -520,15 +520,21 @@ int anx7625_init(uint8_t bus) { return 0; } -void anx7625_wait_hpd_event(uint8_t bus) { +int anx7625_wait_hpd_event(uint8_t bus) { ANXINFO("Waiting for HDMI hot plug event...\n"); - - while (1) { + + int retry_hpd_change = 10000; + while (--retry_hpd_change) { mdelay(10); int detected = anx7625_hpd_change_detect(bus); - if (detected == 1) - break; + if (detected < 0) + return -1; + if (detected > 0) + return 0; } + + ANXERROR("Timed out to detect HPD change on bus %d.\n", bus); + return -1; } int anx7625_get_cc_status(uint8_t bus, uint8_t *cc_status) { @@ -624,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 a1ae467a9..146d09ec1 100644 --- a/libraries/Arduino_H7_Video/src/anx7625.h +++ b/libraries/Arduino_H7_Video/src/anx7625.h @@ -20,9 +20,10 @@ extern "C" { int anx7625_dp_start(uint8_t bus, const struct edid *edid, enum edid_modes mode = EDID_MODE_AUTO); int anx7625_dp_get_edid(uint8_t bus, struct edid *out); int anx7625_init(uint8_t bus); -void anx7625_wait_hpd_event(uint8_t bus); +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/Ethernet/examples/AdvancedChatServer/AdvancedChatServer.ino b/libraries/Ethernet/examples/AdvancedChatServer/AdvancedChatServer.ino index 630f27240..890787130 100644 --- a/libraries/Ethernet/examples/AdvancedChatServer/AdvancedChatServer.ino +++ b/libraries/Ethernet/examples/AdvancedChatServer/AdvancedChatServer.ino @@ -4,11 +4,6 @@ A more advanced server that distributes any incoming messages to all connected clients but the client the message comes from. To use, telnet to your device's IP address and type. - You can see the client's input in the serial monitor as well. - Using an Arduino Wiznet Ethernet shield. - - Circuit: - * Ethernet shield attached to pins 10, 11, 12, 13 created 18 Dec 2009 by David A. Mellis @@ -67,7 +62,7 @@ void setup() { void loop() { // check for any new client connecting, and say hello (before any incoming data) - EthernetClient newClient = server.available(); + EthernetClient newClient = server.accept(); if (newClient) { for (byte i=0; i < 8; i++) { if (!clients[i]) { diff --git a/libraries/Ethernet/examples/BarometricPressureWebServer/BarometricPressureWebServer.ino b/libraries/Ethernet/examples/BarometricPressureWebServer/BarometricPressureWebServer.ino index 6f26ef888..37ba334c4 100644 --- a/libraries/Ethernet/examples/BarometricPressureWebServer/BarometricPressureWebServer.ino +++ b/libraries/Ethernet/examples/BarometricPressureWebServer/BarometricPressureWebServer.ino @@ -141,7 +141,7 @@ void getData() { void listenForEthernetClients() { // listen for incoming clients - EthernetClient client = server.available(); + EthernetClient client = server.accept(); if (client) { Serial.println("Got a client"); // an http request ends with a blank line diff --git a/libraries/Ethernet/examples/ChatServer/ChatServer.ino b/libraries/Ethernet/examples/ChatServer/ChatServer.ino deleted file mode 100644 index bfc310b9c..000000000 --- a/libraries/Ethernet/examples/ChatServer/ChatServer.ino +++ /dev/null @@ -1,97 +0,0 @@ -/* - Chat Server - - A simple server that distributes any incoming messages to all - connected clients. To use, telnet to your device's IP address and type. - You can see the client's input in the serial monitor as well. - Using an Arduino Wiznet Ethernet shield. - - Circuit: - * Ethernet shield attached to pins 10, 11, 12, 13 - - created 18 Dec 2009 - by David A. Mellis - modified 9 Apr 2012 - by Tom Igoe - - */ - -#include -#include -#include - -// The IP address will be dependent on your local network. -// gateway and subnet are optional: -IPAddress ip(192, 168, 1, 177); -IPAddress myDns(192, 168, 1, 1); -IPAddress gateway(192, 168, 1, 1); -IPAddress subnet(255, 255, 0, 0); - - -// telnet defaults to port 23 -EthernetServer server(23); -boolean alreadyConnected = false; // whether or not the client was connected previously - -void setup() { - // You can use Ethernet.init(pin) to configure the CS pin - //Ethernet.init(10); // Most Arduino shields - //Ethernet.init(5); // MKR ETH shield - //Ethernet.init(0); // Teensy 2.0 - //Ethernet.init(20); // Teensy++ 2.0 - //Ethernet.init(15); // ESP8266 with Adafruit Featherwing Ethernet - //Ethernet.init(33); // ESP32 with Adafruit Featherwing Ethernet - - // initialize the ethernet device - Ethernet.begin(ip, myDns, gateway, subnet); - - // Open serial communications and wait for port to open: - Serial.begin(9600); - while (!Serial) { - ; // wait for serial port to connect. Needed for native USB port only - } - - // Check for Ethernet hardware present - if (Ethernet.hardwareStatus() == EthernetNoHardware) { - Serial.println("Ethernet shield was not found. Sorry, can't run without hardware. :("); - while (true) { - delay(1); // do nothing, no point running without Ethernet hardware - } - } - if (Ethernet.linkStatus() == LinkOFF) { - Serial.println("Ethernet cable is not connected."); - } - - // start listening for clients - server.begin(); - - Serial.print("Chat server address:"); - Serial.println(Ethernet.localIP()); -} - -void loop() { - // wait for a new client: - EthernetClient client = server.available(); - - // when the client sends the first byte, say hello: - if (client) { - if (!alreadyConnected) { - // clear out the input buffer: - client.flush(); - Serial.println("We have a new client"); - client.println("Hello, client!"); - alreadyConnected = true; - } - - if (client.available() > 0) { - // read the bytes incoming from the client: - char thisChar = client.read(); - // echo the bytes back to the client: - server.write(thisChar); - // echo the bytes to the server as well: - Serial.write(thisChar); - } - } -} - - - diff --git a/libraries/Ethernet/examples/DhcpChatServer/DhcpChatServer.ino b/libraries/Ethernet/examples/DhcpChatServer/DhcpChatServer.ino deleted file mode 100644 index cbf2deadd..000000000 --- a/libraries/Ethernet/examples/DhcpChatServer/DhcpChatServer.ino +++ /dev/null @@ -1,91 +0,0 @@ -/* - DHCP Chat Server - - A simple server that distributes any incoming messages to all - connected clients. To use, telnet to your device's IP address and type. - You can see the client's input in the serial monitor as well. - Using an Arduino Wiznet Ethernet shield. - - THis version attempts to get an IP address using DHCP - - Circuit: - * Ethernet shield attached to pins 10, 11, 12, 13 - - created 21 May 2011 - modified 9 Apr 2012 - by Tom Igoe - modified 02 Sept 2015 - by Arturo Guadalupi - Based on ChatServer example by David A. Mellis - - */ - -#include -#include -#include - -// The IP address will be dependent on your local network. -// gateway and subnet are optional: -IPAddress ip(192, 168, 1, 177); -IPAddress myDns(192, 168, 1, 1); -IPAddress gateway(192, 168, 1, 1); -IPAddress subnet(255, 255, 0, 0); - -// telnet defaults to port 23 -EthernetServer server(23); -boolean gotAMessage = false; // whether or not you got a message from the client yet - -void setup() { - - // Open serial communications and wait for port to open: - Serial.begin(9600); - while (!Serial) { - ; // wait for serial port to connect. Needed for native USB port only - } - - // start the Ethernet connection: - Serial.println("Trying to get an IP address using DHCP"); - if (Ethernet.begin() == 0) { - Serial.println("Failed to configure Ethernet using DHCP"); - // Check for Ethernet hardware present - if (Ethernet.hardwareStatus() == EthernetNoHardware) { - Serial.println("Ethernet shield was not found. Sorry, can't run without hardware. :("); - while (true) { - delay(1); // do nothing, no point running without Ethernet hardware - } - } - if (Ethernet.linkStatus() == LinkOFF) { - Serial.println("Ethernet cable is not connected."); - } - // initialize the Ethernet device not using DHCP: - Ethernet.begin(ip, myDns, gateway, subnet); - } - // print your local IP address: - Serial.print("My IP address: "); - Serial.println(Ethernet.localIP()); - - // start listening for clients - server.begin(); -} - -void loop() { - // wait for a new client: - EthernetClient client = server.available(); - - // when the client sends the first byte, say hello: - if (client) { - if (!gotAMessage) { - Serial.println("We have a new client"); - client.println("Hello, client!"); - gotAMessage = true; - } - - // read the bytes incoming from the client: - char thisChar = client.read(); - // echo the bytes back to the client: - server.write(thisChar); - // echo the bytes to the server as well: - Serial.print(thisChar); - } -} - diff --git a/libraries/Ethernet/examples/WebServer/WebServer.ino b/libraries/Ethernet/examples/WebServer/WebServer.ino index 6201495f7..8c712fd02 100644 --- a/libraries/Ethernet/examples/WebServer/WebServer.ino +++ b/libraries/Ethernet/examples/WebServer/WebServer.ino @@ -61,7 +61,7 @@ void setup() { void loop() { // listen for incoming clients - EthernetClient client = server.available(); + EthernetClient client = server.accept(); if (client) { Serial.println("new client"); // an http request ends with a blank line diff --git a/libraries/Ethernet/src/Ethernet.cpp b/libraries/Ethernet/src/Ethernet.cpp index 0f6450a7a..ab720fcaf 100644 --- a/libraries/Ethernet/src/Ethernet.cpp +++ b/libraries/Ethernet/src/Ethernet.cpp @@ -55,11 +55,13 @@ int arduino::EthernetClass::begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPA eth_if->set_dhcp(false); eth_if->set_network(_ip, _netmask, _gateway); + + auto ret = _begin(mac, timeout, responseTimeout); + char if_name[5]; eth_if->get_interface_name(if_name); eth_if->add_dns_server(_dnsServer1, if_name); - auto ret = _begin(mac, timeout, responseTimeout); return ret; } diff --git a/libraries/Ethernet/src/EthernetServer.cpp b/libraries/Ethernet/src/EthernetServer.cpp index 94f5854b6..7a383198a 100644 --- a/libraries/Ethernet/src/EthernetServer.cpp +++ b/libraries/Ethernet/src/EthernetServer.cpp @@ -1,6 +1,10 @@ #include "EthernetServer.h" arduino::EthernetClient arduino::EthernetServer::available(uint8_t* status) { + return accept(status); +} + +arduino::EthernetClient arduino::EthernetServer::accept(uint8_t* status) { EthernetClient client; nsapi_error_t error; diff --git a/libraries/Ethernet/src/EthernetServer.h b/libraries/Ethernet/src/EthernetServer.h index 3ddec326f..9374c3023 100644 --- a/libraries/Ethernet/src/EthernetServer.h +++ b/libraries/Ethernet/src/EthernetServer.h @@ -31,9 +31,11 @@ class EthernetServer : public MbedServer { } public: + EthernetServer() {} EthernetServer(uint16_t port) : MbedServer(port) {} - EthernetClient available(uint8_t* status = nullptr); + EthernetClient accept(uint8_t* status = nullptr); + EthernetClient available(uint8_t* status = nullptr) __attribute__((deprecated("Use accept()."))); }; } 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 cf3652c26..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,9 +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, uint8_t ttl = 128); - int ping(const String& hostname, uint8_t ttl = 128); - int ping(IPAddress host, uint8_t ttl = 128); + 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; @@ -130,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[]; @@ -149,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/PDM/src/STM32H747_dfsdm/audio.c b/libraries/PDM/src/STM32H747_dfsdm/audio.c index ab8d6e902..23c4cacb1 100644 --- a/libraries/PDM/src/STM32H747_dfsdm/audio.c +++ b/libraries/PDM/src/STM32H747_dfsdm/audio.c @@ -391,7 +391,10 @@ int py_audio_init(size_t channels, uint32_t frequency) void py_audio_gain_set(int gain_db) { - attenuation = 8 - gain_db; + attenuation = 8 - (gain_db / 3); + if (attenuation < 0) { + attenuation = 0; + } } void py_audio_deinit() diff --git a/libraries/RPC/LICENSE b/libraries/RPC/LICENSE new file mode 100644 index 000000000..a612ad981 --- /dev/null +++ b/libraries/RPC/LICENSE @@ -0,0 +1,373 @@ +Mozilla Public License Version 2.0 +================================== + +1. Definitions +-------------- + +1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. + +1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + +1.6. "Executable Form" + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + +1.8. "License" + means this document. + +1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + +1.10. "Modifications" + means any of the following: + + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + + (b) any new file in Source Code Form that contains any Covered + Software. + +1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + +1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + +1.13. "Source Code Form" + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + +2. License Grants and Conditions +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; + or + +(b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ + +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. diff --git a/libraries/RPC/src/RPC.cpp b/libraries/RPC/src/RPC.cpp index 1fde36501..65d0c2b5a 100644 --- a/libraries/RPC/src/RPC.cpp +++ b/libraries/RPC/src/RPC.cpp @@ -1,3 +1,5 @@ +// Copyright (c) 2024 Arduino SA +// SPDX-License-Identifier: MPL-2.0 #include "RPC.h" #define ENDPOINT_ID_RAW 0 @@ -161,6 +163,35 @@ int RPCClass::begin() { #endif #ifdef CORE_CM4 +#if (CM4_BINARY_START >= 0x60000000) && (CM4_BINARY_START < 0xe0000000) +class M4Init { +public: + M4Init() { + // If the Cortex-M4 core is booting from SDRAM, the memory region must be + // configured as Strongly Ordered. Note that the Cortex-M4 core does not + // seem to implement speculative prefetching, so there is no need to protect + // the whole region from speculative prefetching with a second MPU region. + HAL_MPU_Disable(); + MPU_Region_InitTypeDef MPU_InitStruct; + MPU_InitStruct.Number = MPU_REGION_NUMBER1; + MPU_InitStruct.Enable = MPU_REGION_ENABLE; + MPU_InitStruct.BaseAddress = CM4_BINARY_START; + MPU_InitStruct.Size = MPU_REGION_SIZE_1MB; + MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0; + MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS; + MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE; + MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE; + MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE; + MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE; + MPU_InitStruct.SubRegionDisable = 0x00; + HAL_MPU_ConfigRegion(&MPU_InitStruct); + HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT); + } +}; + +M4Init __m4init __attribute__ ((init_priority (101))); +#endif + int RPCClass::begin() { eventThread = new rtos::Thread(osPriorityHigh, 16*1024, nullptr, "rpc_evt"); eventThread->start(&eventHandler); diff --git a/libraries/RPC/src/RPC.h b/libraries/RPC/src/RPC.h index d4a8729b8..92255f4c8 100644 --- a/libraries/RPC/src/RPC.h +++ b/libraries/RPC/src/RPC.h @@ -1,3 +1,5 @@ +// Copyright (c) 2024 Arduino SA +// SPDX-License-Identifier: MPL-2.0 #ifdef __cplusplus #ifndef __ARDUINO_RPC_IMPLEMENTATION__ diff --git a/libraries/RPC/src/RPC_client.h b/libraries/RPC/src/RPC_client.h index 860c0be32..64bbf55b1 100644 --- a/libraries/RPC/src/RPC_client.h +++ b/libraries/RPC/src/RPC_client.h @@ -1,3 +1,5 @@ +// Copyright (c) 2024 Arduino SA +// SPDX-License-Identifier: MPL-2.0 #include "Arduino.h" #include "mbed.h" #include "rpc/dispatcher.h" diff --git a/libraries/RPC/src/SerialRPC.cpp b/libraries/RPC/src/SerialRPC.cpp index 1965e0cba..0b2d57348 100644 --- a/libraries/RPC/src/SerialRPC.cpp +++ b/libraries/RPC/src/SerialRPC.cpp @@ -1,3 +1,5 @@ +// Copyright (c) 2024 Arduino SA +// SPDX-License-Identifier: MPL-2.0 #include "SerialRPC.h" #include "RPC.h" @@ -22,4 +24,4 @@ arduino::SerialRPCClass::operator bool() { return RPC; } -arduino::SerialRPCClass SerialRPC; \ No newline at end of file +arduino::SerialRPCClass SerialRPC; diff --git a/libraries/RPC/src/SerialRPC.h b/libraries/RPC/src/SerialRPC.h index e732f19db..7c7a4768c 100644 --- a/libraries/RPC/src/SerialRPC.h +++ b/libraries/RPC/src/SerialRPC.h @@ -1,3 +1,5 @@ +// Copyright (c) 2024 Arduino SA +// SPDX-License-Identifier: MPL-2.0 #ifndef __SERIAL_RPC__ #define __SERIAL_RPC__ @@ -69,4 +71,4 @@ class SerialRPCClass : public Stream { extern arduino::SerialRPCClass SerialRPC; -#endif \ No newline at end of file +#endif diff --git a/libraries/SE05X/src/SE05X.cpp b/libraries/SE05X/src/SE05X.cpp index c9a322bc4..1fb3dfe22 100644 --- a/libraries/SE05X/src/SE05X.cpp +++ b/libraries/SE05X/src/SE05X.cpp @@ -26,7 +26,6 @@ #define SE05X_EC_SIGNATURE_HEADER_LENGTH 6 #define SE05X_EC_SIGNATURE_DER_LENGTH SE05X_EC_SIGNATURE_HEADER_LENGTH + SE05X_EC_SIGNATURE_RAW_LENGTH #define SE05X_SHA256_LENGTH 32 -#define SE05X_SN_LENGTH 18 #define SE05X_DER_BUFFER_SIZE 256 #define SE05X_TEMP_OBJECT 9999 @@ -111,8 +110,6 @@ static void setECSignatureRsValuesInDER(const byte* rawSignature, byte* signatur int SE05XClass::begin() { - sss_status_t status; - memset(&_boot_ctx, 0, sizeof(ex_sss_boot_ctx_t)); se05x_ic_power_on(); @@ -158,17 +155,39 @@ int SE05XClass::readConfiguration(byte data[]) return 1; } +int SE05XClass::serialNumber(byte sn[]) +{ + return serialNumber(sn, SE05X_SN_LENGTH); +} + +int SE05XClass::serialNumber(byte sn[], size_t length) +{ + size_t uidLen = SE05X_SN_LENGTH; + byte UID[SE05X_SN_LENGTH]; + + if(!sn) { + return 0; + } + + sss_status_t status = sss_session_prop_get_au8(&_boot_ctx.session, kSSS_SessionProp_UID, UID, &uidLen); + if ((status != kStatus_SSS_Success)) { + SE05X_PRINT_ERROR("Error in Se05x_API_ReadObject \n"); + return 0; + } + memcpy(sn, UID, length < SE05X_SN_LENGTH ? length : SE05X_SN_LENGTH); + return 1; +} + String SE05XClass::serialNumber() { String result = (char*)NULL; byte UID[SE05X_SN_LENGTH]; - size_t uidLen = 18; - sss_session_prop_get_au8(&_boot_ctx.session, kSSS_SessionProp_UID, UID, &uidLen); + serialNumber(UID, sizeof(UID)); - result.reserve(uidLen*2); + result.reserve(SE05X_SN_LENGTH * 2); - for (int i = 0; i < uidLen; i++) { + for (size_t i = 0; i < SE05X_SN_LENGTH; i++) { byte b = UID[i]; if (b < 16) { @@ -591,8 +610,6 @@ int SE05XClass::deleteAllObjects(void) int SE05XClass::getObjectHandle(int objectId, sss_object_t * object) { - sss_status_t status; - if(kStatus_SSS_Success != sss_key_object_init(object, &_boot_ctx.ks)) { SE05X_PRINT_ERROR("sss_key_object_init Failed"); return 0; diff --git a/libraries/SE05X/src/SE05X.h b/libraries/SE05X/src/SE05X.h index a01eb8b01..e955491ba 100644 --- a/libraries/SE05X/src/SE05X.h +++ b/libraries/SE05X/src/SE05X.h @@ -27,11 +27,13 @@ #include "se05x_APDU.h" #if defined SE05X_PRINT_ERROR_ENABLE -#define SE05X_PRINT_ERROR Serial.println +#define SE05X_PRINT_ERROR(x) Serial.println(x) #else -#define SE05X_PRINT_ERROR +#define SE05X_PRINT_ERROR(x) #endif +#define SE05X_SN_LENGTH 18 + class SE05XClass { public: @@ -41,6 +43,8 @@ class SE05XClass int begin(); void end(); + int serialNumber(byte sn[]); + int serialNumber(byte sn[], size_t length); String serialNumber(); long random(long max); @@ -76,8 +80,8 @@ class SE05XClass int readSlot(int slot, byte data[], int length); int writeSlot(int slot, const byte data[], int length); inline int locked() { return 1; } - inline int writeConfiguration(const byte data[]); - inline int readConfiguration(byte data[]); + int writeConfiguration(const byte data[]); + int readConfiguration(byte data[]); inline int lock() { return 1; } private: diff --git a/libraries/SE05X/src/WiFiSSLSE050Client.h b/libraries/SE05X/src/WiFiSSLSE050Client.h index 255ff2f47..6d3409652 100644 --- a/libraries/SE05X/src/WiFiSSLSE050Client.h +++ b/libraries/SE05X/src/WiFiSSLSE050Client.h @@ -48,6 +48,10 @@ class MbedSSLSE050Client : public arduino::MbedSSLClient { return 0; } + if(_hostname && !_disableSNI) { + ((TLSSocket*)sock)->set_hostname(_hostname); + } + if( NSAPI_ERROR_OK != ((TLSSocket*)sock)->append_root_ca_cert(_ca_cert_custom)) { return 0; } diff --git a/libraries/STM32H747_System/examples/QSPIFormat/QSPIFormat.ino b/libraries/STM32H747_System/examples/QSPIFormat/QSPIFormat.ino index 8d2b537dc..7aba71d8c 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,171 @@ 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]"); + Serial.println("Note: Full flash erase can take up to one minute."); + bool fullErase = waitResponse(); + if (fullErase == true) { + Serial.println("Full erase started, please wait..."); + root->erase(0x0, root->size()); + Serial.println("Full erase completed."); } 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()); } - int err = wifi_data_fs.reformat(&wifi_data); - if (err) { + 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(); + } + + 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 || fullErase) { + Serial.println("\nDo you want to restore the WiFi firmware and certificates? Y/[n]"); + restore = waitResponse(); + } + + if (reformat && restore) { + flashWiFiFirmwareAndCertificates(); + } + + if (fullErase && restore) { + flashWiFiFirmwareMapped(); + } + + 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."); } +const uint32_t file_size = 421098; +extern const unsigned char wifi_firmware_image_data[]; + +void flashWiFiFirmwareAndCertificates() { + FILE* fp = fopen("/wlan/4343WA1.BIN", "wb"); + uint32_t chunk_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 + chunk_size > file_size) + chunk_size = file_size - byte_count; + int ret = fwrite(&wifi_firmware_image_data[byte_count], chunk_size, 1, fp); + if (ret != 1) { + Serial.println("Error writing firmware data"); + break; + } + byte_count += chunk_size; + printProgress(byte_count, file_size, 10, false); + } + fclose(fp); + + fp = fopen("/wlan/cacert.pem", "wb"); + + Serial.println("Flashing certificates"); + chunk_size = 128; + byte_count = 0; + printProgress(byte_count, cacert_pem_len, 10, true); + while (byte_count < cacert_pem_len) { + if(byte_count + chunk_size > cacert_pem_len) + chunk_size = cacert_pem_len - byte_count; + int ret = fwrite(&cacert_pem[byte_count], chunk_size, 1 ,fp); + if (ret != 1) { + Serial.println("Error writing certificates"); + break; + } + byte_count += chunk_size; + printProgress(byte_count, cacert_pem_len, 10, false); + } + fclose(fp); +} + +void flashWiFiFirmwareMapped() { + uint32_t chunk_size = 1024; + uint32_t byte_count = 0; + const uint32_t offset = 15 * 1024 * 1024 + 1024 * 512; + + Serial.println("Flashing memory mapped WiFi firmware"); + printProgress(byte_count, file_size, 10, true); + 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); + if (ret != 0) { + Serial.println("Error writing memory mapped firmware"); + break; + } + byte_count += chunk_size; + printProgress(byte_count, file_size, 10, false); + } +} + 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/AClient.cpp b/libraries/SocketWrapper/src/AClient.cpp index 272b18946..9ffa9137a 100644 --- a/libraries/SocketWrapper/src/AClient.cpp +++ b/libraries/SocketWrapper/src/AClient.cpp @@ -46,11 +46,11 @@ int arduino::AClient::connectSSL(IPAddress ip, uint16_t port) { return client->connectSSL(ip, port); } -int arduino::AClient::connectSSL(const char *host, uint16_t port, bool disableSNI) { +int arduino::AClient::connectSSL(const char *host, uint16_t port) { if (!client) { newMbedClient(); } - return client->connectSSL(host, port, disableSNI); + return client->connectSSL(host, port); } void arduino::AClient::stop() { diff --git a/libraries/SocketWrapper/src/AClient.h b/libraries/SocketWrapper/src/AClient.h index 195f7a1f2..4f72020ee 100644 --- a/libraries/SocketWrapper/src/AClient.h +++ b/libraries/SocketWrapper/src/AClient.h @@ -32,7 +32,7 @@ class AClient : public Client { virtual int connect(IPAddress ip, uint16_t port); virtual int connect(const char *host, uint16_t port); int connectSSL(IPAddress ip, uint16_t port); - int connectSSL(const char* host, uint16_t port, bool disableSNI = false); + int connectSSL(const char* host, uint16_t port); virtual void stop(); virtual explicit operator bool(); diff --git a/libraries/SocketWrapper/src/MbedClient.cpp b/libraries/SocketWrapper/src/MbedClient.cpp index ad74db1ca..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(); @@ -80,14 +80,8 @@ void arduino::MbedClient::configureSocket(Socket *_s) { } int arduino::MbedClient::connect(SocketAddress socketAddress) { - - if (sock && reader_th) { - // trying to reuse a connection, let's call stop() to cleanup the state - char c; - if (sock->recv(&c, 1) < 0) { - stop(); - } - } + // if a connection is aready ongoing, a disconnection must be enforced before starting another one + stop(); if (sock == nullptr) { sock = new TCPSocket(); @@ -135,6 +129,9 @@ int arduino::MbedClient::connect(const char *host, uint16_t port) { } int arduino::MbedClient::connectSSL(SocketAddress socketAddress) { + // if a connection is aready ongoing, a disconnection must be enforced before starting another one + stop(); + if (sock == nullptr) { sock = new TLSSocket(); _own_socket = true; @@ -189,15 +186,7 @@ int arduino::MbedClient::connectSSL(IPAddress ip, uint16_t port) { return connectSSL(SocketHelpers::socketAddressFromIpAddress(ip, port)); } -int arduino::MbedClient::connectSSL(const char *host, uint16_t port, bool disableSNI) { - if (!disableSNI) { - if (sock == nullptr) { - sock = new TLSSocket(); - _own_socket = true; - } - static_cast(sock)->set_hostname(host); - } - +int arduino::MbedClient::connectSSL(const char *host, uint16_t port) { SocketAddress socketAddress = SocketAddress(); socketAddress.set_port(port); SocketHelpers::gethostbyname(getNetwork(), host, &socketAddress); diff --git a/libraries/SocketWrapper/src/MbedClient.h b/libraries/SocketWrapper/src/MbedClient.h index 2a6777af4..573c4d5b1 100644 --- a/libraries/SocketWrapper/src/MbedClient.h +++ b/libraries/SocketWrapper/src/MbedClient.h @@ -56,7 +56,7 @@ class MbedClient { virtual int connect(const char* host, uint16_t port); int connectSSL(SocketAddress socketAddress); int connectSSL(IPAddress ip, uint16_t port); - int connectSSL(const char* host, uint16_t port, bool disableSNI = false); + int connectSSL(const char* host, uint16_t port); size_t write(uint8_t); size_t write(const uint8_t* buf, size_t size); int available(); diff --git a/libraries/SocketWrapper/src/MbedSSLClient.cpp b/libraries/SocketWrapper/src/MbedSSLClient.cpp index e0aa1d2dd..ce4cc9fca 100644 --- a/libraries/SocketWrapper/src/MbedSSLClient.cpp +++ b/libraries/SocketWrapper/src/MbedSSLClient.cpp @@ -1,5 +1,9 @@ #include "MbedSSLClient.h" -arduino::MbedSSLClient::MbedSSLClient(): _disableSNI{false} { +arduino::MbedSSLClient::MbedSSLClient() + : _ca_cert_custom(nullptr), + _hostname(nullptr), + _disableSNI(false) { + onBeforeConnect(mbed::callback(this, &MbedSSLClient::setRootCA)); }; diff --git a/libraries/SocketWrapper/src/MbedSSLClient.h b/libraries/SocketWrapper/src/MbedSSLClient.h index 34f4d583d..d4c48fc82 100644 --- a/libraries/SocketWrapper/src/MbedSSLClient.h +++ b/libraries/SocketWrapper/src/MbedSSLClient.h @@ -41,7 +41,8 @@ class MbedSSLClient : public arduino::MbedClient { return connectSSL(ip, port); } int connect(const char* host, uint16_t port) { - return connectSSL(host, port, _disableSNI); + _hostname = host; + return connectSSL(host, port); } void disableSNI(bool statusSNI) { _disableSNI = statusSNI; @@ -52,7 +53,9 @@ class MbedSSLClient : public arduino::MbedClient { } protected: - const char* _ca_cert_custom = NULL; + const char* _ca_cert_custom; + const char* _hostname; + bool _disableSNI; private: int setRootCA() { @@ -79,13 +82,15 @@ 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); } return err; } - - bool _disableSNI; }; } diff --git a/libraries/SocketWrapper/src/MbedServer.cpp b/libraries/SocketWrapper/src/MbedServer.cpp index 758c0208c..5f0881d3f 100644 --- a/libraries/SocketWrapper/src/MbedServer.cpp +++ b/libraries/SocketWrapper/src/MbedServer.cpp @@ -5,39 +5,29 @@ uint8_t arduino::MbedServer::status() { return 0; } +void arduino::MbedServer::begin(uint16_t port) { + _port = port; + begin(); +} + void arduino::MbedServer::begin() { if (sock == nullptr) { sock = new TCPSocket(); ((TCPSocket *)sock)->open(getNetwork()); } if (sock) { + int enable = 1; + sock->setsockopt(NSAPI_SOCKET, NSAPI_REUSEADDR, &enable, sizeof(int)); sock->bind(_port); sock->listen(5); sock->set_blocking(false); } } -size_t arduino::MbedServer::write(uint8_t c) { - if (sock) { - sock->send(&c, 1); - return 1; - } - return 0; -} - -size_t arduino::MbedServer::write(const uint8_t *buf, size_t size) { - if (sock) { - sock->send(buf, size); - return size; - } - return 0; -} - - // MUST be reimplemented (just copy/paste and replace MbedClient to *Client) since MbedClient is abstract /* -arduino::MbedClient arduino::MbedServer::available(uint8_t* status) { +arduino::MbedClient arduino::MbedServer::accept(uint8_t* status) { MbedClient client; nsapi_error_t error; if (sock == nullptr) { diff --git a/libraries/SocketWrapper/src/MbedServer.h b/libraries/SocketWrapper/src/MbedServer.h index 23017e296..c6a844e15 100644 --- a/libraries/SocketWrapper/src/MbedServer.h +++ b/libraries/SocketWrapper/src/MbedServer.h @@ -30,7 +30,7 @@ namespace arduino { class MbedClient; -class MbedServer : public arduino::Server { +class MbedServer { protected: virtual NetworkInterface *getNetwork() = 0; @@ -38,23 +38,26 @@ class MbedServer : public arduino::Server { uint16_t _port; public: + MbedServer() + : _port(80){}; MbedServer(uint16_t port) : _port(port){}; virtual ~MbedServer() { + end(); + } + void end() { if (sock) { delete sock; sock = nullptr; } } + void begin(uint16_t port); void begin(); - virtual size_t write(uint8_t); - virtual size_t write(const uint8_t *buf, size_t size); uint8_t status(); - - //virtual MbedClient available(uint8_t* status) = 0; - - using Print::write; + explicit operator bool() { + return sock != nullptr; + } friend class MbedSocketClass; friend class MbedClient; diff --git a/libraries/SocketWrapper/src/SocketHelpers.cpp b/libraries/SocketWrapper/src/SocketHelpers.cpp index ada31434f..591cd2f17 100644 --- a/libraries/SocketWrapper/src/SocketHelpers.cpp +++ b/libraries/SocketWrapper/src/SocketHelpers.cpp @@ -1,18 +1,28 @@ #include "SocketHelpers.h" +#include uint8_t* arduino::MbedSocketClass::macAddress(uint8_t* mac) { const char* mac_str = getNetwork()->get_mac_address(); for (int b = 0; b < 6; b++) { uint32_t tmp; sscanf(&mac_str[b * 2 + (b)], "%02x", (unsigned int*)&tmp); - mac[5 - b] = (uint8_t)tmp; + mac[b] = (uint8_t)tmp; } - //sscanf(mac_str, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx", &mac[5], &mac[4], &mac[3], &mac[2], &mac[1], &mac[0]); return mac; } String arduino::MbedSocketClass::macAddress() { - return String(getNetwork()->get_mac_address()); + const char* mac_str = getNetwork()->get_mac_address(); + if (!mac_str) { + return String("ff:ff:ff:ff:ff:ff"); + } + return String(mac_str); +} + +int arduino::MbedSocketClass::setHostname(const char* hostname) { + NetworkInterface* interface = getNetwork(); + interface->set_hostname(hostname); + return 1; } int arduino::MbedSocketClass::hostByName(const char* aHostname, IPAddress& aResult) { @@ -65,6 +75,24 @@ arduino::IPAddress arduino::MbedSocketClass::dnsIP(int n) { return ipAddressFromSocketAddress(ip); } +int arduino::MbedSocketClass::ping(const char *hostname, uint8_t ttl, uint32_t timeout) +{ + SocketAddress socketAddress; + gethostbyname(getNetwork(),hostname, &socketAddress); + return ping(socketAddress, ttl, timeout); +} + +int arduino::MbedSocketClass::ping(const String &hostname, uint8_t ttl, uint32_t timeout) +{ + return ping(hostname.c_str(), ttl, timeout); +} + +int arduino::MbedSocketClass::ping(IPAddress host, uint8_t ttl, uint32_t timeout) +{ + SocketAddress socketAddress = socketAddressFromIpAddress(host, 0); + return ping(socketAddress, ttl, timeout); +} + void arduino::MbedSocketClass::config(arduino::IPAddress local_ip) { IPAddress dns = local_ip; dns[3] = 1; @@ -110,6 +138,22 @@ void arduino::MbedSocketClass::setDNS(IPAddress dns_server1, IPAddress dns_serve _dnsServer2 = SocketAddress(convertedDNSServer2); } +int arduino::MbedSocketClass::ping(SocketAddress &socketAddress, uint8_t ttl, uint32_t timeout) +{ + /* 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()); + response = s.ping(socketAddress, timeout); + s.close(); +#endif + + return response; +} + arduino::IPAddress arduino::MbedSocketClass::ipAddressFromSocketAddress(SocketAddress socketAddress) { nsapi_addr_t address = socketAddress.get_addr(); return IPAddress(address.bytes[0], address.bytes[1], address.bytes[2], address.bytes[3]); @@ -123,7 +167,11 @@ SocketAddress arduino::MbedSocketClass::socketAddressFromIpAddress(arduino::IPAd nsapi_error_t arduino::MbedSocketClass::gethostbyname(NetworkInterface* interface, const char* aHostname, SocketAddress* socketAddress) { char ifname[5] {}; interface->get_interface_name(ifname); - return interface->gethostbyname(aHostname, socketAddress, NSAPI_UNSPEC, ifname); + nsapi_version_t version = NSAPI_IPv4; +#if MBED_CONF_LWIP_IPV6_ENABLED + version = NSAPI_UNSPEC; +#endif + return interface->gethostbyname(aHostname, socketAddress, version, ifname); } // Download helper diff --git a/libraries/SocketWrapper/src/SocketHelpers.h b/libraries/SocketWrapper/src/SocketHelpers.h index c31988fde..428ab4a63 100644 --- a/libraries/SocketWrapper/src/SocketHelpers.h +++ b/libraries/SocketWrapper/src/SocketHelpers.h @@ -28,107 +28,140 @@ class MbedSocketClass { void config(IPAddress local_ip); /* Change Ip configuration settings disabling the dhcp client - * - * param local_ip: Static ip configuration as string - */ + * + * param local_ip: Static ip configuration as string + */ void config(const char* local_ip); /* Change Ip configuration settings disabling the dhcp client - * - * param local_ip: Static ip configuration - * param dns_server: IP configuration for DNS server 1 - */ + * + * param local_ip: Static ip configuration + * param dns_server: IP configuration for DNS server 1 + */ void config(IPAddress local_ip, IPAddress dns_server); /* Change Ip configuration settings disabling the dhcp client - * - * param local_ip: Static ip configuration - * param dns_server: IP configuration for DNS server 1 - * param gateway : Static gateway configuration - */ + * + * param local_ip: Static ip configuration + * param dns_server: IP configuration for DNS server 1 + * param gateway : Static gateway configuration + */ void config(IPAddress local_ip, IPAddress dns_server, IPAddress gateway); /* Change Ip configuration settings disabling the dhcp client - * - * param local_ip: Static ip configuration - * param dns_server: IP configuration for DNS server 1 - * param gateway: Static gateway configuration - * param subnet: Static Subnet mask - */ + * + * param local_ip: Static ip configuration + * param dns_server: IP configuration for DNS server 1 + * param gateway: Static gateway configuration + * param subnet: Static Subnet mask + */ void config(IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet); + // When using DHCP the hostname provided will be used. + int setHostname(const char* hostname); + /* Change DNS Ip configuration - * - * param dns_server1: ip configuration for DNS server 1 - */ + * + * param dns_server1: ip configuration for DNS server 1 + */ void setDNS(IPAddress dns_server1); /* Change DNS Ip configuration - * - * param dns_server1: ip configuration for DNS server 1 - * param dns_server2: ip configuration for DNS server 2 - * - */ + * + * param dns_server1: ip configuration for DNS server 1 + * param dns_server2: ip configuration for DNS server 2 + * + */ void setDNS(IPAddress dns_server1, IPAddress dns_server2); /* - * Get the interface IP address. - * - * return: Ip address value - */ + * Get the interface IP address. + * + * return: Ip address value + */ IPAddress localIP(); /* - * Get the interface subnet mask address. - * - * return: subnet mask address value - */ + * Get the interface subnet mask address. + * + * return: subnet mask address value + */ IPAddress subnetMask(); /* - * Get the gateway ip address. - * - * return: gateway ip address value - */ + * Get the gateway ip address. + * + * return: gateway ip address value + */ IPAddress gatewayIP(); /* - * Get the DNS Server ip address. - * - * return: DNS Server ip address value - */ + * Get the DNS Server ip address. + * + * return: DNS Server ip address value + */ IPAddress dnsServerIP(); /* - * Get the DNS Server ip address. - * - * return: DNS Server ip address value - */ + * Get the DNS Server ip address. + * + * return: DNS Server ip address value + */ IPAddress dnsIP(int n = 0); virtual NetworkInterface* getNetwork() = 0; - + + /* + * Ping the specified target. + * + * ttl value is unused, but kept for API compatibility + * + * return: RTT in milliseconds or -1 on error + */ + 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 - * The parameter cbk can be used to perform actions on the buffer before saving on the fs - * - * return: on success the size of the downloaded file, on error -status code - */ + * Download a file from an HTTP endpoint and save it in the provided `target` location on the fs + * The parameter cbk can be used to perform actions on the buffer before saving on the fs + * + * return: on success the size of the downloaded file, on error -status code + */ int download( const char* url, const char* target, bool const is_https = false); /* - * Download a file from an HTTP endpoint and handle the body of the request on a callback - * passed as an argument - * - * return: on success the size of the downloaded file, on error -status code - */ + * Download a file from an HTTP endpoint and handle the body of the request on a callback + * passed as an argument + * + * return: on success the size of the downloaded file, on error -status code + */ int download( const char* url, bool const is_https = false, mbed::Callback cbk = nullptr); int hostByName(const char* aHostname, IPAddress& aResult); + /* + * Get the interface MAC address. + * + * Network interface should be ready to get a valid mac address. + * Call WiFi.begin("",""); or Ethernet.begin(); before issuing a mac address + * request, otherwhise returned value will be ff:ff:ff:ff:ff:ff + * + * return: pointer to uint8_t array with length WL_MAC_ADDR_LENGTH + */ uint8_t* macAddress(uint8_t* mac); + + /* + * Get the interface MAC address String. + * + * Network interface should be ready to get a valid MAC address. + * Call WiFi.begin("",""); or Ethernet.begin(); before issuing a mac address + * request, otherwhise returned value will be ff:ff:ff:ff:ff:ff + * + * return: MAC Address String + */ String macAddress(); void setFeedWatchdogFunc(voidFuncPtr func); @@ -152,6 +185,7 @@ class MbedSocketClass { void body_callback(const char* data, uint32_t data_len); + 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/WiFi/examples/AP_SimpleWebServer/AP_SimpleWebServer.ino b/libraries/WiFi/examples/AP_SimpleWebServer/AP_SimpleWebServer.ino new file mode 100644 index 000000000..8dc0678b8 --- /dev/null +++ b/libraries/WiFi/examples/AP_SimpleWebServer/AP_SimpleWebServer.ino @@ -0,0 +1,152 @@ +/* + WiFi Web Server LED Blink + + A simple web server that lets you blink an LED via the web. + This sketch will create a new access point (with no password). + It will then launch a new server and print out the IP address + to the Serial Monitor. From there, you can open that address in a web browser + to turn on and off the LED on pin 13. + + If the IP address of your board is yourAddress: + http://yourAddress/H turns the LED on + http://yourAddress/L turns it off + + created 25 Nov 2012 + by Tom Igoe + adapted to WiFi AP by Adafruit + */ + +#include +#include "arduino_secrets.h" +///////please enter your sensitive data in the Secret tab/arduino_secrets.h +char ssid[] = SECRET_SSID; // your network SSID (name) +char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP) +int keyIndex = 0; // your network key index number (needed only for WEP) + +int led = LED_BUILTIN; +int status = WL_IDLE_STATUS; +WiFiServer server(80); + +void setup() { + //Initialize serial and wait for port to open: + Serial.begin(9600); + while (!Serial) { + ; // wait for serial port to connect. Needed for native USB port only + } + + Serial.println("Access Point Web Server"); + + pinMode(led, OUTPUT); // set the LED pin mode + + // check for the WiFi module: + if (WiFi.status() == WL_NO_MODULE) { + Serial.println("Communication with WiFi module failed!"); + // don't continue + while (true); + } + + WiFi.config(IPAddress(10, 0, 0, 1)); + + // print the network name (SSID); + Serial.print("Creating access point named: "); + Serial.println(ssid); + + // Create open network. Change this line if you want to create an open network: + status = WiFi.beginAP(ssid, pass); + if (status != WL_AP_LISTENING) { + Serial.println("Creating access point failed"); + // don't continue + while (true); + } + + // start the web server on port 80 + server.begin(); + + // you're connected now, so print out the status + printWiFiStatus(); +} + + +void loop() { + // compare the previous status to the current status + if (status != WiFi.status()) { + // it has changed update the variable + status = WiFi.status(); + + if (status == WL_AP_CONNECTED) { + // a device has connected to the AP + Serial.println("Device connected to AP"); + } else { + // a device has disconnected from the AP, and we are back in listening mode + Serial.println("Device disconnected from AP"); + } + } + + WiFiClient client = server.accept(); // listen for incoming clients + + if (client) { // if you get a client, + Serial.println("new client"); // print a message out the serial port + String currentLine = ""; // make a String to hold incoming data from the client + while (client.connected()) { // loop while the client's connected + delayMicroseconds(10); // This is required for the Arduino Nano RP2040 Connect - otherwise it will loop so fast that SPI will never be served. + if (client.available()) { // if there's bytes to read from the client, + char c = client.read(); // read a byte, then + Serial.write(c); // print it out to the serial monitor + if (c == '\n') { // if the byte is a newline character + + // if the current line is blank, you got two newline characters in a row. + // that's the end of the client HTTP request, so send a response: + if (currentLine.length() == 0) { + // HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK) + // and a content-type so the client knows what's coming, then a blank line: + client.println("HTTP/1.1 200 OK"); + client.println("Content-type:text/html"); + client.println(); + + // the content of the HTTP response follows the header: + client.print("Click here turn the LED on
"); + client.print("Click here turn the LED off
"); + + // The HTTP response ends with another blank line: + client.println(); + // break out of the while loop: + break; + } + else { // if you got a newline, then clear currentLine: + currentLine = ""; + } + } + else if (c != '\r') { // if you got anything else but a carriage return character, + currentLine += c; // add it to the end of the currentLine + } + + // Check to see if the client request was "GET /H" or "GET /L": + if (currentLine.endsWith("GET /H")) { + digitalWrite(led, HIGH); // GET /H turns the LED on + } + if (currentLine.endsWith("GET /L")) { + digitalWrite(led, LOW); // GET /L turns the LED off + } + } + } + // close the connection: + client.stop(); + Serial.println("client disconnected"); + } +} + +void printWiFiStatus() { + // print the SSID of the network you're attached to: + Serial.print("SSID: "); + Serial.println(WiFi.SSID()); + + // print your WiFi shield's IP address: + IPAddress ip = WiFi.localIP(); + Serial.print("IP Address: "); + Serial.println(ip); + + // print where to go in a browser: + Serial.print("To see this page in action, open a browser to http://"); + Serial.println(ip); + +} diff --git a/libraries/WiFi/examples/AP_SimpleWebServer/arduino_secrets.h b/libraries/WiFi/examples/AP_SimpleWebServer/arduino_secrets.h new file mode 100644 index 000000000..493b719ca --- /dev/null +++ b/libraries/WiFi/examples/AP_SimpleWebServer/arduino_secrets.h @@ -0,0 +1,3 @@ +// Both SSID and password must be 8 characters or longer +#define SECRET_SSID "" +#define SECRET_PASS "" diff --git a/libraries/WiFi/examples/SimpleWebServerWiFi/SimpleWebServerWiFi.ino b/libraries/WiFi/examples/SimpleWebServerWiFi/SimpleWebServerWiFi.ino new file mode 100644 index 000000000..5fe110116 --- /dev/null +++ b/libraries/WiFi/examples/SimpleWebServerWiFi/SimpleWebServerWiFi.ino @@ -0,0 +1,130 @@ +/* + WiFi Web Server LED Blink + + A simple web server that lets you blink an LED via the web. + This sketch will print the IP address of your WiFi module (once connected) + to the Serial Monitor. From there, you can open that address in a web browser + to turn on and off the LED on pin 9. + + If the IP address of your board is yourAddress: + http://yourAddress/H turns the LED on + http://yourAddress/L turns it off + + This example is written for a network using WPA encryption. For + WEP or WPA, change the WiFi.begin() call accordingly. + + Circuit: + * Board with WiFi + * LED attached to pin 9 + + created 25 Nov 2012 + by Tom Igoe + */ + +#include + +#include "arduino_secrets.h" +///////please enter your sensitive data in the Secret tab/arduino_secrets.h +char ssid[] = SECRET_SSID; // your network SSID (name) +char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP) +int keyIndex = 0; // your network key index number (needed only for WEP) + +int status = WL_IDLE_STATUS; +WiFiServer server(80); + +void setup() { + Serial.begin(9600); // initialize serial communication + pinMode(LED_BUILTIN, OUTPUT); // set the LED pin mode + + // check for the WiFi module: + if (WiFi.status() == WL_NO_MODULE) { + Serial.println("Communication with WiFi module failed!"); + // don't continue + while (true); + } + + // attempt to connect to WiFi network: + while (status != WL_CONNECTED) { + Serial.print("Attempting to connect to Network named: "); + Serial.println(ssid); // print the network name (SSID); + + // Connect to WPA/WPA2 network. Change this line if using open or WEP network: + status = WiFi.begin(ssid, pass); + // wait 3 seconds for connection: + delay(3000); + } + server.begin(); // start the web server on port 80 + printWifiStatus(); // you're connected now, so print out the status +} + + +void loop() { + WiFiClient client = server.accept(); // listen for incoming clients + + if (client) { // if you get a client, + Serial.println("new client"); // print a message out the serial port + String currentLine = ""; // make a String to hold incoming data from the client + while (client.connected()) { // loop while the client's connected + if (client.available()) { // if there's bytes to read from the client, + char c = client.read(); // read a byte, then + Serial.write(c); // print it out to the serial monitor + if (c == '\n') { // if the byte is a newline character + + // if the current line is blank, you got two newline characters in a row. + // that's the end of the client HTTP request, so send a response: + if (currentLine.length() == 0) { + // HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK) + // and a content-type so the client knows what's coming, then a blank line: + client.println("HTTP/1.1 200 OK"); + client.println("Content-type:text/html"); + client.println(); + + // the content of the HTTP response follows the header: + client.print("Click here turn the LED on
"); + client.print("Click here turn the LED off
"); + + // The HTTP response ends with another blank line: + client.println(); + // break out of the while loop: + break; + } else { // if you got a newline, then clear currentLine: + currentLine = ""; + } + } else if (c != '\r') { // if you got anything else but a carriage return character, + currentLine += c; // add it to the end of the currentLine + } + + // Check to see if the client request was "GET /H" or "GET /L": + if (currentLine.endsWith("GET /H")) { + digitalWrite(LED_BUILTIN, HIGH); // GET /H turns the LED on + } + if (currentLine.endsWith("GET /L")) { + digitalWrite(LED_BUILTIN, LOW); // GET /L turns the LED off + } + } + } + // close the connection: + client.stop(); + Serial.println("client disconnected"); + } +} + +void printWifiStatus() { + // print the SSID of the network you're attached to: + Serial.print("SSID: "); + Serial.println(WiFi.SSID()); + + // print your board's IP address: + IPAddress ip = WiFi.localIP(); + Serial.print("IP Address: "); + Serial.println(ip); + + // print the received signal strength: + long rssi = WiFi.RSSI(); + Serial.print("signal strength (RSSI):"); + Serial.print(rssi); + Serial.println(" dBm"); + // print where to go in a browser: + Serial.print("To see this page in action, open a browser to http://"); + Serial.println(ip); +} diff --git a/libraries/WiFi/examples/SimpleWebServerWiFi/arduino_secrets.h b/libraries/WiFi/examples/SimpleWebServerWiFi/arduino_secrets.h new file mode 100644 index 000000000..0c9fdd556 --- /dev/null +++ b/libraries/WiFi/examples/SimpleWebServerWiFi/arduino_secrets.h @@ -0,0 +1,2 @@ +#define SECRET_SSID "" +#define SECRET_PASS "" diff --git a/libraries/WiFi/examples/WiFiAdvancedChatServer/WiFiAdvancedChatServer.ino b/libraries/WiFi/examples/WiFiAdvancedChatServer/WiFiAdvancedChatServer.ino new file mode 100644 index 000000000..4d09fdab2 --- /dev/null +++ b/libraries/WiFi/examples/WiFiAdvancedChatServer/WiFiAdvancedChatServer.ino @@ -0,0 +1,101 @@ +/* + Advanced WiFi Chat Server + + A more advanced server that distributes any incoming messages + to all connected clients but the client the message comes from. + To use, telnet to your device's IP address and type. + + Circuit: + * Board with WiFi + + */ + +#include + +#include "arduino_secrets.h" +///////please enter your sensitive data in the Secret tab/arduino_secrets.h +char ssid[] = SECRET_SSID; // your network SSID (name) +char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP) + +int status = WL_IDLE_STATUS; + +// telnet defaults to port 23 +WiFiServer server(23); + +WiFiClient clients[8]; + +void setup() { + //Initialize serial and wait for port to open: + Serial.begin(9600); + while (!Serial) { + ; // wait for serial port to connect. Needed for native USB port only + } + + // check for the WiFi module: + if (WiFi.status() == WL_NO_MODULE) { + Serial.println("Communication with WiFi module failed!"); + // don't continue + while (true); + } + + // attempt to connect to WiFi network: + while (status != WL_CONNECTED) { + Serial.print("Attempting to connect to SSID: "); + Serial.println(ssid); + // Connect to WPA/WPA2 network. Change this line if using open network: + status = WiFi.begin(ssid, pass); + + // wait 3 seconds for connection: + delay(3000); + } + + // start the server: + server.begin(); + + Serial.print("Chat server address:"); + Serial.println(WiFi.localIP()); +} + +void loop() { + // check for any new client connecting, and say hello (before any incoming data) + WiFiClient newClient = server.accept(); + if (newClient) { + for (byte i=0; i < 8; i++) { + if (!clients[i]) { + Serial.print("We have a new client #"); + Serial.println(i); + newClient.print("Hello, client number: "); + newClient.println(i); + // Once we "accept", the client is no longer tracked by WiFiServer + // so we must store it into our list of clients + clients[i] = newClient; + break; + } + } + } + + // check for incoming data from all clients + for (byte i=0; i < 8; i++) { + if (clients[i] && clients[i].available() > 0) { + // read bytes from a client + byte buffer[80]; + int count = clients[i].read(buffer, 80); + // write the bytes to all other connected clients + for (byte j=0; j < 8; j++) { + if (j != i && clients[j].connected()) { + clients[j].write(buffer, count); + } + } + } + } + + // stop any clients which disconnect + for (byte i=0; i < 8; i++) { + if (clients[i] && !clients[i].connected()) { + Serial.print("disconnect client #"); + Serial.println(i); + clients[i].stop(); + } + } + +} diff --git a/libraries/WiFi/examples/WiFiAdvancedChatServer/arduino_secrets.h b/libraries/WiFi/examples/WiFiAdvancedChatServer/arduino_secrets.h new file mode 100644 index 000000000..0c9fdd556 --- /dev/null +++ b/libraries/WiFi/examples/WiFiAdvancedChatServer/arduino_secrets.h @@ -0,0 +1,2 @@ +#define SECRET_SSID "" +#define SECRET_PASS "" diff --git a/libraries/WiFi/examples/WiFiPing/WiFiPing.ino b/libraries/WiFi/examples/WiFiPing/WiFiPing.ino new file mode 100644 index 000000000..db81e1ce7 --- /dev/null +++ b/libraries/WiFi/examples/WiFiPing/WiFiPing.ino @@ -0,0 +1,114 @@ +/* + Web ICMP Ping + + This sketch pings a device based on the IP address or the hostname + using the WiFi module. + + This example is written for a network using WPA encryption. For + WEP or WPA, change the WiFi.begin() call accordingly. + + created 14 February 2024 + by paulvha + modified 8 Jenuary 2025 + by fabik111 + + */ + +#include +#include "arduino_secrets.h" + +///////please enter your sensitive data in the Secret tab/arduino_secrets.h +char ssid[] = SECRET_SSID; // your network SSID (name) +char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP) + +int status = WL_IDLE_STATUS; + +/* -------------------------------------------------------------------------- */ +void setup() { +/* -------------------------------------------------------------------------- */ + //Initialize serial and wait for port to open: + Serial.begin(9600); + while (!Serial) { + ; // wait for serial port to connect. Needed for native USB port only + } + + // check for the WiFi module: + if (WiFi.status() == WL_NO_MODULE) { + Serial.println("Communication with WiFi module failed."); + // don't continue + while (true); + } + + // attempt to connect to WiFi network: + while (status != WL_CONNECTED) { + Serial.print("Attempting to connect to SSID: "); + Serial.println(ssid); + // Connect to WPA/WPA2 network. Change this line if using open or WEP network: + status = WiFi.begin(ssid, pass); + + // wait 3 seconds for connection: + delay(3000); + } + + printWifiStatus(); +} + +/* -------------------------------------------------------------------------- */ +void loop() { +/* -------------------------------------------------------------------------- */ + + // Ping IP + const IPAddress remote_ip(140,82,121,4); + Serial.print("Trying to ping github.com on IP: "); + Serial.println(remote_ip); + + // using default ping count of 1 + int res = WiFi.ping(remote_ip); + + if (res > 0) { + Serial.print("Ping response time: "); + Serial.print(res); + Serial.println(" ms"); + } + else { + Serial.println("Timeout on IP!"); + } + + // Ping Host + const char* remote_host = "www.google.com"; + Serial.print("Trying to ping host: "); + Serial.println(remote_host); + + int res1 = WiFi.ping(remote_host); + + if (res1 > 0) { + Serial.print("Ping response time: "); + Serial.print(res1); + Serial.println(" ms"); + } + else { + Serial.println("Timeout on host!"); + } + + Serial.println(); + delay(5000); +} + +/* -------------------------------------------------------------------------- */ +void printWifiStatus() { +/* -------------------------------------------------------------------------- */ + // print the SSID of the network you're attached to: + Serial.print("SSID: "); + Serial.println(WiFi.SSID()); + + // print your board's IP address: + IPAddress ip = WiFi.localIP(); + Serial.print("IP Address: "); + Serial.println(ip); + + // print the received signal strength: + long rssi = WiFi.RSSI(); + Serial.print("signal strength (RSSI):"); + Serial.print(rssi); + Serial.println(" dBm"); +} diff --git a/libraries/WiFi/examples/WiFiPing/arduino_secrets.h b/libraries/WiFi/examples/WiFiPing/arduino_secrets.h new file mode 100644 index 000000000..0c9fdd556 --- /dev/null +++ b/libraries/WiFi/examples/WiFiPing/arduino_secrets.h @@ -0,0 +1,2 @@ +#define SECRET_SSID "" +#define SECRET_PASS "" diff --git a/libraries/WiFi/examples/WiFiSSLClient/WiFiSSLClient.ino b/libraries/WiFi/examples/WiFiSSLClient/WiFiSSLClient.ino new file mode 100644 index 000000000..be1875f84 --- /dev/null +++ b/libraries/WiFi/examples/WiFiSSLClient/WiFiSSLClient.ino @@ -0,0 +1,106 @@ +/* +This example creates a client object that connects and transfers +data using always SSL. + +It is compatible with the methods normally related to plain +connections, like client.connect(host, port). + +Written by Arturo Guadalupi +last revision November 2015 + +*/ + +#include + +#include "arduino_secrets.h" +///////please enter your sensitive data in the Secret tab/arduino_secrets.h +char ssid[] = SECRET_SSID; // your network SSID (name) +char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP) +int keyIndex = 0; // your network key index number (needed only for WEP) + +int status = WL_IDLE_STATUS; +// if you don't want to use DNS (and reduce your sketch size) +// use the numeric IP instead of the name for the server: +//IPAddress server(74,125,232,128); // numeric IP for Google (no DNS) +char server[] = "www.google.com"; // name address for Google (using DNS) + +// Initialize the Ethernet client library +// with the IP address and port of the server +// that you want to connect to (port 80 is default for HTTP): +WiFiSSLClient client; + +void setup() { + //Initialize serial and wait for port to open: + Serial.begin(9600); + while (!Serial) { + ; // wait for serial port to connect. Needed for native USB port only + } + + // check for the WiFi module: + if (WiFi.status() == WL_NO_MODULE) { + Serial.println("Communication with WiFi module failed!"); + // don't continue + while (true); + } + + // attempt to connect to WiFi network: + while (status != WL_CONNECTED) { + Serial.print("Attempting to connect to SSID: "); + Serial.println(ssid); + // Connect to WPA/WPA2 network. Change this line if using open network: + status = WiFi.begin(ssid, pass); + + // wait 3 seconds for connection: + delay(3000); + } + Serial.println("Connected to WiFi"); + printWiFiStatus(); + + Serial.println("\nStarting connection to server..."); + // if you get a connection, report back via serial: + if (client.connect(server, 443)) { + Serial.println("connected to server"); + // Make a HTTP request: + client.println("GET /search?q=arduino HTTP/1.1"); + client.println("Host: www.google.com"); + client.println("Connection: close"); + client.println(); + } +} + +void loop() { + // if there are incoming bytes available + // from the server, read them and print them: + while (client.available()) { + char c = client.read(); + Serial.write(c); + } + + // if the server's disconnected, stop the client: + if (!client.connected()) { + Serial.println(); + Serial.println("disconnecting from server."); + client.stop(); + + // do nothing forevermore: + while (true); + } +} + + +void printWiFiStatus() { + // print the SSID of the network you're attached to: + Serial.print("SSID: "); + Serial.println(WiFi.SSID()); + + // print your board's IP address: + IPAddress ip = WiFi.localIP(); + Serial.print("IP Address: "); + Serial.println(ip); + + // print the received signal strength: + long rssi = WiFi.RSSI(); + Serial.print("signal strength (RSSI):"); + Serial.print(rssi); + Serial.println(" dBm"); +} diff --git a/libraries/WiFi/examples/WiFiSSLClient/arduino_secrets.h b/libraries/WiFi/examples/WiFiSSLClient/arduino_secrets.h new file mode 100644 index 000000000..0c9fdd556 --- /dev/null +++ b/libraries/WiFi/examples/WiFiSSLClient/arduino_secrets.h @@ -0,0 +1,2 @@ +#define SECRET_SSID "" +#define SECRET_PASS "" diff --git a/libraries/WiFi/examples/WiFiUdpNtpClient/WiFiUdpNtpClient.ino b/libraries/WiFi/examples/WiFiUdpNtpClient/WiFiUdpNtpClient.ino new file mode 100644 index 000000000..2c799a442 --- /dev/null +++ b/libraries/WiFi/examples/WiFiUdpNtpClient/WiFiUdpNtpClient.ino @@ -0,0 +1,166 @@ +/* + Udp NTP Client + + Get the time from a Network Time Protocol (NTP) time server + Demonstrates use of UDP sendPacket and ReceivePacket + For more on NTP time servers and the messages needed to communicate with them, + see http://en.wikipedia.org/wiki/Network_Time_Protocol + + created 4 Sep 2010 + by Michael Margolis + modified 9 Apr 2012 + by Tom Igoe + + This code is in the public domain. + + */ + +#include + +int status = WL_IDLE_STATUS; +#include "arduino_secrets.h" +///////please enter your sensitive data in the Secret tab/arduino_secrets.h +char ssid[] = SECRET_SSID; // your network SSID (name) +char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP) +int keyIndex = 0; // your network key index number (needed only for WEP) + +unsigned int localPort = 2390; // local port to listen for UDP packets + +IPAddress timeServer(162, 159, 200, 123); // pool.ntp.org NTP server + +const int NTP_PACKET_SIZE = 48; // NTP timestamp is in the first 48 bytes of the message + +byte packetBuffer[NTP_PACKET_SIZE]; //buffer to hold incoming and outgoing packets + +// A UDP instance to let us send and receive packets over UDP +WiFiUDP Udp; + +void setup() { + // Open serial communications and wait for port to open: + Serial.begin(9600); + while (!Serial) { + ; // wait for serial port to connect. Needed for native USB port only + } + + // check for the WiFi module: + if (WiFi.status() == WL_NO_MODULE) { + Serial.println("Communication with WiFi module failed!"); + // don't continue + while (true); + } + + // attempt to connect to WiFi network: + while (status != WL_CONNECTED) { + Serial.print("Attempting to connect to SSID: "); + Serial.println(ssid); + // Connect to WPA/WPA2 network. Change this line if using open network: + status = WiFi.begin(ssid, pass); + + // wait 3 seconds for connection: + delay(3000); + } + + Serial.println("Connected to WiFi"); + printWifiStatus(); + + Serial.println("\nStarting connection to server..."); + Udp.begin(localPort); +} + +void loop() { + sendNTPpacket(timeServer); // send an NTP packet to a time server + // wait to see if a reply is available + delay(1000); + if (Udp.parsePacket()) { + Serial.println("packet received"); + // We've received a packet, read the data from it + Udp.read(packetBuffer, NTP_PACKET_SIZE); // read the packet into the buffer + + //the timestamp starts at byte 40 of the received packet and is four bytes, + // or two words, long. First, extract the two words: + + unsigned long highWord = word(packetBuffer[40], packetBuffer[41]); + unsigned long lowWord = word(packetBuffer[42], packetBuffer[43]); + // combine the four bytes (two words) into a long integer + // this is NTP time (seconds since Jan 1 1900): + unsigned long secsSince1900 = highWord << 16 | lowWord; + Serial.print("Seconds since Jan 1 1900 = "); + Serial.println(secsSince1900); + + // now convert NTP time into everyday time: + Serial.print("Unix time = "); + // Unix time starts on Jan 1 1970. In seconds, that's 2208988800: + const unsigned long seventyYears = 2208988800UL; + // subtract seventy years: + unsigned long epoch = secsSince1900 - seventyYears; + // print Unix time: + Serial.println(epoch); + + + // print the hour, minute and second: + Serial.print("The UTC time is "); // UTC is the time at Greenwich Meridian (GMT) + Serial.print((epoch % 86400L) / 3600); // print the hour (86400 equals secs per day) + Serial.print(':'); + if (((epoch % 3600) / 60) < 10) { + // In the first 10 minutes of each hour, we'll want a leading '0' + Serial.print('0'); + } + Serial.print((epoch % 3600) / 60); // print the minute (3600 equals secs per minute) + Serial.print(':'); + if ((epoch % 60) < 10) { + // In the first 10 seconds of each minute, we'll want a leading '0' + Serial.print('0'); + } + Serial.println(epoch % 60); // print the second + } + // wait ten seconds before asking for the time again + delay(10000); +} + +// send an NTP request to the time server at the given address +unsigned long sendNTPpacket(IPAddress& address) { + //Serial.println("1"); + // set all bytes in the buffer to 0 + memset(packetBuffer, 0, NTP_PACKET_SIZE); + // Initialize values needed to form NTP request + // (see URL above for details on the packets) + //Serial.println("2"); + packetBuffer[0] = 0b11100011; // LI, Version, Mode + packetBuffer[1] = 0; // Stratum, or type of clock + packetBuffer[2] = 6; // Polling Interval + packetBuffer[3] = 0xEC; // Peer Clock Precision + // 8 bytes of zero for Root Delay & Root Dispersion + packetBuffer[12] = 49; + packetBuffer[13] = 0x4E; + packetBuffer[14] = 49; + packetBuffer[15] = 52; + + //Serial.println("3"); + + // all NTP fields have been given values, now + // you can send a packet requesting a timestamp: + Udp.beginPacket(address, 123); //NTP requests are to port 123 + //Serial.println("4"); + Udp.write(packetBuffer, NTP_PACKET_SIZE); + //Serial.println("5"); + Udp.endPacket(); + //Serial.println("6"); +} + + +void printWifiStatus() { + // print the SSID of the network you're attached to: + Serial.print("SSID: "); + Serial.println(WiFi.SSID()); + + // print your board's IP address: + IPAddress ip = WiFi.localIP(); + Serial.print("IP Address: "); + Serial.println(ip); + + // print the received signal strength: + long rssi = WiFi.RSSI(); + Serial.print("signal strength (RSSI):"); + Serial.print(rssi); + Serial.println(" dBm"); +} diff --git a/libraries/WiFi/examples/WiFiUdpNtpClient/arduino_secrets.h b/libraries/WiFi/examples/WiFiUdpNtpClient/arduino_secrets.h new file mode 100644 index 000000000..0c9fdd556 --- /dev/null +++ b/libraries/WiFi/examples/WiFiUdpNtpClient/arduino_secrets.h @@ -0,0 +1,2 @@ +#define SECRET_SSID "" +#define SECRET_PASS "" diff --git a/libraries/WiFi/examples/WiFiUdpSendReceiveString/WiFiUdpSendReceiveString.ino b/libraries/WiFi/examples/WiFiUdpSendReceiveString/WiFiUdpSendReceiveString.ino new file mode 100644 index 000000000..9a42aad4c --- /dev/null +++ b/libraries/WiFi/examples/WiFiUdpSendReceiveString/WiFiUdpSendReceiveString.ino @@ -0,0 +1,105 @@ +/* + WiFi UDP Send and Receive String + + This sketch waits for a UDP packet on localPort using the WiFi module. + When a packet is received an Acknowledge packet is sent to the client on port remotePort + + created 30 December 2012 + by dlf (Metodo2 srl) + + */ + + +#include + +int status = WL_IDLE_STATUS; +#include "arduino_secrets.h" +///////please enter your sensitive data in the Secret tab/arduino_secrets.h +char ssid[] = SECRET_SSID; // your network SSID (name) +char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP) +int keyIndex = 0; // your network key index number (needed only for WEP) + +unsigned int localPort = 2390; // local port to listen on + +char packetBuffer[256]; //buffer to hold incoming packet +char ReplyBuffer[] = "acknowledged"; // a string to send back + +WiFiUDP Udp; + +void setup() { + //Initialize serial and wait for port to open: + Serial.begin(9600); + while (!Serial) { + ; // wait for serial port to connect. Needed for native USB port only + } + + // check for the WiFi module: + if (WiFi.status() == WL_NO_MODULE) { + Serial.println("Communication with WiFi module failed!"); + // don't continue + while (true); + } + + // attempt to connect to WiFi network: + while (status != WL_CONNECTED) { + Serial.print("Attempting to connect to SSID: "); + Serial.println(ssid); + // Connect to WPA/WPA2 network. Change this line if using open network: + status = WiFi.begin(ssid, pass); + + // wait 3 seconds for connection: + delay(3000); + } + Serial.println("Connected to WiFi"); + printWifiStatus(); + + Serial.println("\nStarting connection to server..."); + // if you get a connection, report back via serial: + Udp.begin(localPort); +} + +void loop() { + + // if there's data available, read a packet + int packetSize = Udp.parsePacket(); + if (packetSize) { + Serial.print("Received packet of size "); + Serial.println(packetSize); + Serial.print("From "); + IPAddress remoteIp = Udp.remoteIP(); + Serial.print(remoteIp); + Serial.print(", port "); + Serial.println(Udp.remotePort()); + + // read the packet into packetBuffer + int len = Udp.read(packetBuffer, 255); + if (len > 0) { + packetBuffer[len] = 0; + } + Serial.println("Contents:"); + Serial.println(packetBuffer); + + // send a reply, to the IP address and port that sent us the packet we received + Udp.beginPacket(Udp.remoteIP(), Udp.remotePort()); + Udp.write(ReplyBuffer); + Udp.endPacket(); + } +} + + +void printWifiStatus() { + // print the SSID of the network you're attached to: + Serial.print("SSID: "); + Serial.println(WiFi.SSID()); + + // print your board's IP address: + IPAddress ip = WiFi.localIP(); + Serial.print("IP Address: "); + Serial.println(ip); + + // print the received signal strength: + long rssi = WiFi.RSSI(); + Serial.print("signal strength (RSSI):"); + Serial.print(rssi); + Serial.println(" dBm"); +} diff --git a/libraries/WiFi/examples/WiFiUdpSendReceiveString/arduino_secrets.h b/libraries/WiFi/examples/WiFiUdpSendReceiveString/arduino_secrets.h new file mode 100644 index 000000000..0c9fdd556 --- /dev/null +++ b/libraries/WiFi/examples/WiFiUdpSendReceiveString/arduino_secrets.h @@ -0,0 +1,2 @@ +#define SECRET_SSID "" +#define SECRET_PASS "" diff --git a/libraries/WiFi/src/WiFi.cpp b/libraries/WiFi/src/WiFi.cpp index 09e8c6e56..6ad89d619 100644 --- a/libraries/WiFi/src/WiFi.cpp +++ b/libraries/WiFi/src/WiFi.cpp @@ -53,29 +53,39 @@ int arduino::WiFiClass::begin(const char* ssid, const char* passphrase, wl_enc_t wifi_if->attach(&arduino::WiFiClass::statusCallback); - scanNetworks(); - - if (isVisible(ssid)) { - // Set the network security mode from the scan result. - _security = ap_list[connected_ap].get_security(); + if(security == ENC_TYPE_UNKNOWN) { + scanNetworks(); + if (isVisible(ssid)) { + // Set the network security mode from the scan result. + _security = ap_list[connected_ap].get_security(); + } else { + // For hidden networks, the security mode must be set explicitly. + // if ENC_TYPE_UNKNOWN this means that is the default value and so the user + // has not set it... no worth trying, it is probably an unknown (not hidden) + // interface + _currentNetworkStatus = WL_CONNECT_FAILED; + return _currentNetworkStatus; + } } else { - // For hidden networks, the security mode must be set explicitly. _security = enum2sec(security); } wifi_if->set_dhcp(!_useStaticIP); if (_useStaticIP) { wifi_if->set_network(_ip, _netmask, _gateway); - char if_name[5]; - wifi_if->get_interface_name(if_name); - wifi_if->add_dns_server(_dnsServer2, if_name); - wifi_if->add_dns_server(_dnsServer1, if_name); // pushes dnsServer2 at index 1 } + wifi_if->set_timeout(_timeout); nsapi_error_t result = wifi_if->connect(ssid, passphrase, _security); if(result == NSAPI_ERROR_IS_CONNECTED) { wifi_if->disconnect(); + } else + if (_useStaticIP) { + char if_name[5]; + wifi_if->get_interface_name(if_name); + wifi_if->add_dns_server(_dnsServer2, if_name); + wifi_if->add_dns_server(_dnsServer1, if_name); // pushes dnsServer2 at index 1 } _currentNetworkStatus = (result == NSAPI_ERROR_OK && setSSID(ssid)) ? WL_CONNECTED : WL_CONNECT_FAILED; @@ -288,6 +298,10 @@ unsigned long arduino::WiFiClass::getTime() { return 0; } +void arduino::WiFiClass::setTimeout(unsigned long timeout) { + _timeout = timeout; +} + void arduino::WiFiClass::statusCallback(nsapi_event_t status, intptr_t param) { if (((param == NSAPI_STATUS_DISCONNECTED) || @@ -364,12 +378,17 @@ wiced_result_t whd_firmware_check_hook(const char* mounted_name, int mount_err) #include "whd_version.h" const char* arduino::WiFiClass::firmwareVersion() { - if ((wiced_filesystem_init() != WICED_ERROR) && (wiced_filesystem_mount_default() != WICED_ERROR)) { - if (firmware_available) { - return WHD_VERSION; - } + if (!firmware_available) { + /* Try to mount WiFi firmware filesystem */ + wiced_filesystem_init(); + wiced_filesystem_mount_default(); + } + + if (firmware_available) { + return WHD_VERSION; + } else { + return "v0.0.0"; } - return "v0.0.0"; } arduino::WiFiClass WiFi(WiFiInterface::get_default_instance()); diff --git a/libraries/WiFi/src/WiFi.h b/libraries/WiFi/src/WiFi.h index ad650fb14..a3a8a6ea9 100644 --- a/libraries/WiFi/src/WiFi.h +++ b/libraries/WiFi/src/WiFi.h @@ -55,27 +55,27 @@ class WiFiClass : public MbedSocketClass { : wifi_if(_if){}; /* - * Get firmware version - */ + * Get firmware version + */ static const char* firmwareVersion(); /* Start Wifi connection for OPEN networks - * - * param ssid: Pointer to the SSID string. - */ + * + * param ssid: Pointer to the SSID string. + */ int begin(const char* ssid); - void MACAddress(uint8_t *mac_address); + void MACAddress(uint8_t *mac_address) __attribute__((deprecated("Use macAddress(uint8_t *mac_address)"))); /* Start Wifi connection with passphrase - * the most secure supported mode will be automatically selected - * - * param ssid: Pointer to the SSID string. - * param passphrase: Passphrase. Valid characters in a passphrase - * must be between ASCII 32-126 (decimal). - */ - int begin(const char* ssid, const char* passphrase, wl_enc_type security = ENC_TYPE_CCMP); - + * the most secure supported mode will be automatically selected + * + * param ssid: Pointer to the SSID string. + * param passphrase: Passphrase. Valid characters in a passphrase + * must be between ASCII 32-126 (decimal). + */ + int begin(const char* ssid, const char* passphrase, wl_enc_type security = ENC_TYPE_UNKNOWN); + // Inherit config methods from the parent class using MbedSocketClass::config; @@ -84,90 +84,95 @@ class WiFiClass : public MbedSocketClass { int beginAP(const char* ssid, const char* passphrase, uint8_t channel = DEFAULT_AP_CHANNEL); /* - * 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); void end(void); /* - * Return the current SSID associated with the network - * - * return: ssid string - */ + * Return the current SSID associated with the network + * + * return: ssid string + */ char* SSID(); /* - * Return the current BSSID associated with the network. - * It is the MAC address of the Access Point - * - * return: pointer to uint8_t array with length WL_MAC_ADDR_LENGTH - */ + * Return the current BSSID associated with the network. + * It is the MAC address of the Access Point + * + * return: pointer to uint8_t array with length WL_MAC_ADDR_LENGTH + */ uint8_t* BSSID(uint8_t* bssid); /* - * Return the current RSSI /Received Signal Strength in dBm) - * associated with the network - * - * return: signed value - */ + * Return the current RSSI /Received Signal Strength in dBm) + * associated with the network + * + * return: signed value + */ int32_t RSSI(); /* - * Return the Encryption Type associated with the network - * - * return: one value of wl_enc_type enum - */ + * Return the Encryption Type associated with the network + * + * return: one value of wl_enc_type enum + */ uint8_t encryptionType(); /* - * Start scan WiFi networks available - * - * return: Number of discovered networks - */ + * Start scan WiFi networks available + * + * return: Number of discovered networks + */ int8_t scanNetworks(); /* - * Return the SSID discovered during the network scan. - * - * param networkItem: specify from which network item want to get the information - * - * return: ssid string of the specified item on the networks scanned list - */ + * Return the SSID discovered during the network scan. + * + * param networkItem: specify from which network item want to get the information + * + * return: ssid string of the specified item on the networks scanned list + */ char* SSID(uint8_t networkItem); /* - * Return the encryption type of the networks discovered during the scanNetworks - * - * param networkItem: specify from which network item want to get the information - * - * return: encryption type (enum wl_enc_type) of the specified item on the networks scanned list - */ + * Return the encryption type of the networks discovered during the scanNetworks + * + * param networkItem: specify from which network item want to get the information + * + * return: encryption type (enum wl_enc_type) of the specified item on the networks scanned list + */ uint8_t encryptionType(uint8_t networkItem); uint8_t* BSSID(uint8_t networkItem, uint8_t* bssid); uint8_t channel(uint8_t networkItem); /* - * Return the RSSI of the networks discovered during the scanNetworks - * - * param networkItem: specify from which network item want to get the information - * - * return: signed value of RSSI of the specified item on the networks scanned list - */ + * Return the RSSI of the networks discovered during the scanNetworks + * + * param networkItem: specify from which network item want to get the information + * + * return: signed value of RSSI of the specified item on the networks scanned list + */ int32_t RSSI(uint8_t networkItem); /* - * Return Connection status. - * - * return: one of the value defined in wl_status_t - */ + * Return Connection status. + * + * return: one of the value defined in wl_status_t + */ uint8_t status(); unsigned long getTime(); + /* + * Configure WiFi join timeout in milliseconds. Default value is 7s. + */ + void setTimeout(unsigned long timeout); + friend class WiFiClient; friend class WiFiServer; friend class WiFiUDP; @@ -183,6 +188,7 @@ class WiFiClass : public MbedSocketClass { WiFiAccessPoint* ap_list = nullptr; uint8_t connected_ap; nsapi_security_t _security; + unsigned long _timeout = 7000; int setSSID(const char* ssid); void ensureDefaultAPNetworkConfiguration(); static void* handleAPEvents(whd_interface_t ifp, const whd_event_header_t* event_header, const uint8_t* event_data, void* handler_user_data); diff --git a/libraries/WiFi/src/WiFiServer.cpp b/libraries/WiFi/src/WiFiServer.cpp index cefbd0214..fb919eff9 100644 --- a/libraries/WiFi/src/WiFiServer.cpp +++ b/libraries/WiFi/src/WiFiServer.cpp @@ -1,6 +1,10 @@ #include "WiFiServer.h" arduino::WiFiClient arduino::WiFiServer::available(uint8_t* status) { + return accept(status); +} + +arduino::WiFiClient arduino::WiFiServer::accept(uint8_t* status) { WiFiClient client; nsapi_error_t error; if (sock == nullptr) { diff --git a/libraries/WiFi/src/WiFiServer.h b/libraries/WiFi/src/WiFiServer.h index ae293b374..3e20d7959 100644 --- a/libraries/WiFi/src/WiFiServer.h +++ b/libraries/WiFi/src/WiFiServer.h @@ -31,9 +31,11 @@ class WiFiServer : public MbedServer { } public: + WiFiServer() {} WiFiServer(uint16_t port) : MbedServer(port) {} - WiFiClient available(uint8_t* status = nullptr); + WiFiClient accept(uint8_t* status = nullptr); + WiFiClient available(uint8_t* status = nullptr) __attribute__((deprecated("Use accept()."))); }; } diff --git a/libraries/Wire/Wire.cpp b/libraries/Wire/Wire.cpp index ddd3a3ce4..954f8c3af 100644 --- a/libraries/Wire/Wire.cpp +++ b/libraries/Wire/Wire.cpp @@ -122,14 +122,21 @@ 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()) { - return rxBuffer.read_char(); + + rv = rxBuffer.read_char(); } - return -1; + core_util_critical_section_exit(); + return rv; } int arduino::MbedI2C::available() { - return rxBuffer.available(); + core_util_critical_section_enter(); + int rv = rxBuffer.available(); + core_util_critical_section_exit(); + return rv; } int arduino::MbedI2C::peek() { @@ -151,16 +158,22 @@ void arduino::MbedI2C::receiveThd() { onRequestCb(); } if (usedTxBuffer != 0) { - slave->write((const char *) txBuffer, usedTxBuffer); + core_util_critical_section_enter(); + 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; case mbed::I2CSlave::WriteGeneral: case mbed::I2CSlave::WriteAddressed: - rxBuffer.clear(); char buf[240]; c = slave->read(buf, sizeof(buf)); + core_util_critical_section_enter(); + rxBuffer.clear(); for (buf_idx = 0; buf_idx < c; buf_idx++) { if (rxBuffer.availableForStore()) { rxBuffer.store_char(uint8_t(buf[buf_idx])); @@ -168,8 +181,9 @@ void arduino::MbedI2C::receiveThd() { break; } } - if (rxBuffer.available() > 0 && onReceiveCb != NULL) { - onReceiveCb(rxBuffer.available()); + core_util_critical_section_exit(); + if (available() > 0 && onReceiveCb != NULL) { + onReceiveCb(available()); } //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/libraries/openamp_arduino/src/openamp_conf.h b/libraries/openamp_arduino/src/openamp_conf.h index 922b45239..1eeacd81a 100644 --- a/libraries/openamp_arduino/src/openamp_conf.h +++ b/libraries/openamp_arduino/src/openamp_conf.h @@ -151,6 +151,9 @@ extern int __OPENAMP_region_end__[]; #define SHM_START_ADDRESS ((metal_phys_addr_t)__OPENAMP_region_start__) #define SHM_SIZE (size_t)((void *)__OPENAMP_region_end__ - (void *) __OPENAMP_region_start__) +#define SHM_RSC_SIZE (1024) +#define SHM_RSC_ADDR ((void *)__OPENAMP_region_start__ - SHM_RSC_SIZE) + #endif #define VRING_RX_ADDRESS SHM_START_ADDRESS diff --git a/libraries/openamp_arduino/src/rsc_table.c b/libraries/openamp_arduino/src/rsc_table.c index 3fde24727..f2335dd8f 100644 --- a/libraries/openamp_arduino/src/rsc_table.c +++ b/libraries/openamp_arduino/src/rsc_table.c @@ -21,137 +21,58 @@ ****************************************************************************** */ -/** @addtogroup RSC_TABLE - * @{ - */ - -/** @addtogroup resource_table - * @{ - */ - -/** @addtogroup resource_table_Private_Includes - * @{ - */ - - #if defined(__ICCARM__) || defined (__CC_ARM) #include /* needed for offsetof definition*/ #endif #include "rsc_table.h" #include "openamp/open_amp.h" -/** - * @} - */ - -/** @addtogroup resource_table_Private_TypesDefinitions - * @{ - */ - -/** - * @} - */ - -/** @addtogroup resource_table_Private_Defines - * @{ - */ - -/* Place resource table in special ELF section */ -#if defined(__GNUC__) -#define __section_t(S) __attribute__((__section__(#S))) -#define __resource __section_t(.resource_table) -#endif - -#define RPMSG_IPU_C0_FEATURES 1 -#define VRING_COUNT 2 - -/* VirtIO rpmsg device id */ -#define VIRTIO_ID_RPMSG_ 7 - #if defined (__LOG_TRACE_IO_) extern char system_log_buf[]; #endif -#if defined(__GNUC__) -#if !defined (__CC_ARM) -/* Since GCC is not initializing the resource_table at startup, it is declared as volatile to avoid compiler optimization - * for the CM4 (see resource_table_init() below) - */ -volatile struct shared_resource_table __resource __attribute__((used)) resource_table; -#else -struct shared_resource_table __resource __attribute__((used)) resource_table = { -#endif -#elif defined(__ICCARM__) -__root struct shared_resource_table resource_table @ ".resource_table" = { -#endif - -#if defined(__ICCARM__) || defined (__CC_ARM) - .version = 1, - .num = 2, - .reserved = {0, 0}, - .offset = { - offsetof(struct shared_resource_table, vdev), - offsetof(struct shared_resource_table, cm_trace), - }, - - /* Virtio device entry */ - .vdev= { - RSC_VDEV, VIRTIO_ID_RPMSG_, 0, RPMSG_IPU_C0_FEATURES, 0, 0, 0, - VRING_COUNT, {0, 0}, - }, - - /* Vring rsc entry - part of vdev rsc entry */ - .vring0 = {VRING_TX_ADDRESS, VRING_ALIGNMENT, VRING_NUM_BUFFS, VRING0_ID, 0}, - .vring1 = {VRING_RX_ADDRESS, VRING_ALIGNMENT, VRING_NUM_BUFFS, VRING1_ID, 0}, - -#if defined (__LOG_TRACE_IO_) - .cm_trace = { - RSC_TRACE, - (uint32_t)system_log_buf, SYSTEM_TRACE_BUF_SZ, 0, "cm4_log", - }, -#endif -} ; -#endif - -void resource_table_init(int RPMsgRole, void **table_ptr, int *length) -{ - -#if defined (__GNUC__) && ! defined (__CC_ARM) -#ifdef CORE_CM7 - /* - * Currently the GCC linker doesn't initialize the resource_table global variable at startup - * it is done here by the CM7 application. - */ - memset(&resource_table, '\0', sizeof(struct shared_resource_table)); - resource_table.num = 1; - resource_table.version = 1; - resource_table.offset[0] = offsetof(struct shared_resource_table, vdev); - - resource_table.vring0.da = VRING_TX_ADDRESS; - resource_table.vring0.align = VRING_ALIGNMENT; - resource_table.vring0.num = VRING_NUM_BUFFS; - resource_table.vring0.notifyid = VRING0_ID; - - resource_table.vring1.da = VRING_RX_ADDRESS; - resource_table.vring1.align = VRING_ALIGNMENT; - resource_table.vring1.num = VRING_NUM_BUFFS; - resource_table.vring1.notifyid = VRING1_ID; - - - resource_table.vdev.type = RSC_VDEV; - resource_table.vdev.id = VIRTIO_ID_RPMSG_; - resource_table.vdev.num_of_vrings=VRING_COUNT; - resource_table.vdev.dfeatures = RPMSG_IPU_C0_FEATURES; -#else - /* For CM4 let's wait until the resource_table is correctly initialized */ - while(resource_table.vring1.da != VRING_RX_ADDRESS) - { - - } -#endif -#endif - - (void)RPMsgRole; - *length = sizeof(resource_table); - *table_ptr = &resource_table; +void resource_table_init(int RPMsgRole, void **table_ptr, int *length) { + (void)RPMsgRole; + volatile struct shared_resource_table *resource_table = SHM_RSC_ADDR; + + #ifdef CORE_CM7 + memset(resource_table, 0, SHM_RSC_SIZE); + resource_table->num = 1; + resource_table->version = 1; + resource_table->offset[0] = offsetof(struct shared_resource_table, vdev); + #if defined (__LOG_TRACE_IO_) + resource_table->offset[1] = offsetof(struct shared_resource_table, cm_trace); + #endif + + resource_table->vring0.da = VRING_TX_ADDRESS; + resource_table->vring0.align = VRING_ALIGNMENT; + resource_table->vring0.num = VRING_NUM_BUFFS; + resource_table->vring0.notifyid = VRING0_ID; + + resource_table->vring1.da = VRING_RX_ADDRESS; + resource_table->vring1.align = VRING_ALIGNMENT; + resource_table->vring1.num = VRING_NUM_BUFFS; + resource_table->vring1.notifyid = VRING1_ID; + + #if defined (__LOG_TRACE_IO_) + resource_table->cm_trace.type; + resource_table->cm_trace.da; + resource_table->cm_trace.len; + resource_table->cm_trace.reserved = 0; + resource_table->cm_trace.name = (uint8_t[]){"cm_trace"}; + #endif + + resource_table->vdev.type = RSC_VDEV; + resource_table->vdev.id = VIRTIO_ID_RPMSG; + resource_table->vdev.num_of_vrings=VRING_COUNT; + resource_table->vdev.dfeatures = (1 << VIRTIO_RPMSG_F_NS); + #else + // For CM4, wait until the resource_table is initialized by the host + while(resource_table->vring1.da != VRING_RX_ADDRESS) { + + } + #endif + + *length = SHM_RSC_SIZE; + *table_ptr = resource_table; } diff --git a/mbed-os-to-arduino b/mbed-os-to-arduino index ef911b5e4..d919715ee 100755 --- a/mbed-os-to-arduino +++ b/mbed-os-to-arduino @@ -187,31 +187,16 @@ generate_flags () { echo "Patching '-fno-exceptions' flag for $ARDUINOVARIANT/${fl}flags.txt" sed -i '/-fno-exceptions/d' "$ARDUINOVARIANT"/${fl}flags.txt set +e - HAS_OPENAMP_SECTION=`grep openamp_section "$ARDUINOVARIANT"/linker_script.ld` + HAS_PDM_SECTION=`grep pdm_section "$ARDUINOVARIANT"/linker_script.ld` set -e - if [ x"$HAS_OPENAMP_SECTION" == x ]; then - echo "Adding OpenAMP section to $ARDUINOVARIANT/linker_script.ld" - OPENAMP_SECTION=".openamp_section (NOLOAD) : {\n \ - . = ABSOLUTE(0x38000000);\n \ - *(.resource_table)\n \ - } >RAM_D3 AT > FLASH\n \ - .pdm_section (NOLOAD) : {\n \ - . = ABSOLUTE(0x3800FC00);\n \ + if [ x"$HAS_PDM_SECTION" == x ]; then + echo "Adding PDM section to $ARDUINOVARIANT/linker_script.ld" + PDM_SECTION=".pdm_section 0x3800FC00 (NOLOAD): {\n \ *(.pdm_buffer)\n \ } > RAM_D3\n" - if [[ $ARDUINOVARIANT == *GENERIC*M4 ]]; then - echo "Fixing VTOR base in $ARDUINOVARIANT/linker_script.ld" - VTOR_SECTION="#if (CM4_BINARY_START == 0x60000000)\n \ - REGION_ALIAS(\"RAM\", FLASH);\n \ - #else\n \ - REGION_ALIAS(\"RAM\", RAM_D2);\n \ - #endif\n" - sed -i "s?REGION_ALIAS.*?${VTOR_SECTION}?g" $ARDUINOVARIANT/linker_script.ld - fi - if [[ $ARDUINOVARIANT == *PORTENTA*M7* || $ARDUINOVARIANT == *GIGA* || $ARDUINOVARIANT == *OPTA* ]]; then - OPENAMP_SECTION="${OPENAMP_SECTION} \ + PDM_SECTION="${PDM_SECTION} \ _dtcm_lma = __etext + SIZEOF(.data);\n \ .dtcm : AT(_dtcm_lma) {\n \ _sdtcm = .;\n \ @@ -220,27 +205,28 @@ generate_flags () { } > DTCMRAM" fi - sed -i "s?.heap (COPY):?${OPENAMP_SECTION}\n .heap (COPY):?g" $ARDUINOVARIANT/linker_script.ld + sed -i "s?.heap (COPY):?${PDM_SECTION}\n .heap (COPY):?g" $ARDUINOVARIANT/linker_script.ld OPENAMP_REGIONS="__OPENAMP_region_start__ = 0x38000400;\n__OPENAMP_region_end__ = 0x38000400 + LENGTH(RAM_D3) - 1K;" sed -i "s?ENTRY(Reset_Handler)?${OPENAMP_REGIONS}\nENTRY(Reset_Handler)?g" $ARDUINOVARIANT/linker_script.ld + + if [[ $ARDUINOVARIANT == *GENERIC*M4 ]]; then + echo "Fixing VTOR base in $ARDUINOVARIANT/linker_script.ld" + VTOR_SECTION="#if (CM4_BINARY_START == 0x60000000)\n \ + REGION_ALIAS(\"RAM\", FLASH);\n \ + #else\n \ + REGION_ALIAS(\"RAM\", RAM_D2);\n \ + #endif\n" + sed -i "s?REGION_ALIAS.*?${VTOR_SECTION}?g" $ARDUINOVARIANT/linker_script.ld + echo "Fixing shared memory attributes in $ARDUINOVARIANT/linker_script.ld" + 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 fi echo "Patching linker scripts" sed -i 's/0x8100000/CM4_BINARY_START/g' "$ARDUINOVARIANT"/linker_script.ld sed -i 's/LENGTH = 0x200000/LENGTH = CM4_BINARY_END - CM4_BINARY_START/g' "$ARDUINOVARIANT"/linker_script.ld sed -i 's/LENGTH = 0x1c0000/LENGTH = CM4_BINARY_START - 0x8040000/g' "$ARDUINOVARIANT"/linker_script.ld fi - if [[ $ARDUINOVARIANT == *NANO_RP2040* ]]; then - set +e - HAS_2NDSTAGE_SECTION=`grep second_stage_ota "$ARDUINOVARIANT"/linker_script.ld` - set -e - if [ x"$HAS_2NDSTAGE_SECTION" == x ]; then - echo "Adding second stage bootloader section to Nano RP2040 Connect" - SECOND_STAGE_SECTION=".second_stage_ota : {\n \ - KEEP (*(.second_stage_ota))\n \ - } > FLASH" - sed -i "s?.flash_begin?${SECOND_STAGE_SECTION}\n .flash_begin?g" $ARDUINOVARIANT/linker_script.ld - fi - fi done echo " done." } diff --git a/mbed-os-to-arduino-macos b/mbed-os-to-arduino-macos index 077a4d7d0..bd745a976 100755 --- a/mbed-os-to-arduino-macos +++ b/mbed-os-to-arduino-macos @@ -253,18 +253,6 @@ generate_flags () { gsed -i 's/LENGTH = 0x200000/LENGTH = CM4_BINARY_END - CM4_BINARY_START/g' "$ARDUINOVARIANT"/linker_script.ld gsed -i 's/LENGTH = 0x1c0000/LENGTH = CM4_BINARY_START - 0x8040000/g' "$ARDUINOVARIANT"/linker_script.ld fi - if [[ $ARDUINOVARIANT == *NANO_RP2040* ]]; then - set +e - HAS_2NDSTAGE_SECTION=`grep second_stage_ota "$ARDUINOVARIANT"/linker_script.ld` - set -e - if [ x"$HAS_2NDSTAGE_SECTION" == x ]; then - echo "Adding second stage bootloader section to Nano RP2040 Connect" - SECOND_STAGE_SECTION=".second_stage_ota : {\n \ - KEEP (*(.second_stage_ota))\n \ - } > FLASH" - gsed -i "s?.flash_begin?${SECOND_STAGE_SECTION}\n .flash_begin?g" $ARDUINOVARIANT/linker_script.ld - fi - fi done echo " done." } 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.sh b/package.sh index 3d89d8155..ded181efc 100755 --- a/package.sh +++ b/package.sh @@ -73,10 +73,19 @@ BASE_FOLDER=`basename $PWD` #Package! (remove .git, patches folders) cd .. tar --exclude='*.git*' --exclude='*patches*' -cjhf ArduinoCore-mbed-$FLAVOUR-$VERSION.tar.bz2 $BASE_FOLDER -if [ x$FLAVOUR == x ]; then -mv ArduinoCore-mbed-$FLAVOUR-$VERSION.tar.bz2 ArduinoCore-mbed-$VERSION.tar.bz2 -echo FILENAME=ArduinoCore-mbed-$VERSION.tar.bz2 > /tmp/env -else -echo FILENAME=ArduinoCore-mbed-$FLAVOUR-$VERSION.tar.bz2 > /tmp/env -fi + +# Create JSON file for the package +FILENAME=ArduinoCore-mbed-$FLAVOUR-$VERSION.tar.bz2 +CHKSUM=`sha256sum $FILENAME | awk '{ print $1 }'` +SIZE=`wc -c $FILENAME | awk '{ print $1 }'` +FLAVOUR_TAG=${FLAVOUR^^}_ +FLAVOUR_NAME=${FLAVOUR,,} +VERSION_NAME=${VERSION//./-} + +cat ArduinoCore-mbed/extras/mbed_$FLAVOUR_NAME-tag.template.json | +sed "s/%%VERSION%%/${VERSION}/" | +sed "s/%%${FLAVOUR_TAG}FILENAME%%/${FILENAME}/" | +sed "s/%%${FLAVOUR_TAG}CHECKSUM%%/${CHKSUM}/" | +sed "s/%%${FLAVOUR_TAG}SIZE%%/${SIZE}/" > mbed_$FLAVOUR_NAME-$VERSION_NAME.json + cd - diff --git a/package_full.sh b/package_full.sh index 4c3f590b0..ac971df4b 100755 --- a/package_full.sh +++ b/package_full.sh @@ -1,10 +1,8 @@ #Get version from git(hub) tag -export VERSION="4.1.5" +export VERSION="4.4.1" FLAVOURS=`ls *.variables` -cp extras/package_index.json.NewTag.template /tmp/json - for flavour in $FLAVOURS; do # Hack, clean everything from known positions and restart @@ -17,32 +15,4 @@ git clone git@github.com:arduino/ArduinoCore-API.git ../api/ ln -s ../../../api/api cores/arduino/api ./package.sh $flavour -echo "Creating json" - -source /tmp/env -CHKSUM=`sha256sum ../$FILENAME | awk '{ print $1 }'` -SIZE=`wc -c ../$FILENAME | awk '{ print $1 }'` -source ${flavour} - -FLAVOUR=${FLAVOUR^^} - -if [ x$FLAVOUR != x ]; then -FLAVOUR=${FLAVOUR}_ -fi - -echo FILENAME=$FILENAME -echo CHKSUM=$CHKSUM -echo SIZE=$SIZE -echo VERSION=$VERSION -echo FLAVOUR=$FLAVOUR - -cat /tmp/json | -sed "s/%%VERSION%%/${VERSION}/" | -sed "s/%%${FLAVOUR}FILENAME%%/${FILENAME}/" | -sed "s/%%${FLAVOUR}CHECKSUM%%/${CHKSUM}/" | -sed "s/%%${FLAVOUR}SIZE%%/${SIZE}/" > /tmp/json2 -mv /tmp/json2 /tmp/json - done - -cp /tmp/json package_${CORE_NAME}_${VERSION}_index.json diff --git a/patches/0235-RP2040-add-second_stage_ota-section-to-linker-script.patch b/patches/0235-RP2040-add-second_stage_ota-section-to-linker-script.patch new file mode 100644 index 000000000..875ba721b --- /dev/null +++ b/patches/0235-RP2040-add-second_stage_ota-section-to-linker-script.patch @@ -0,0 +1,28 @@ +From 9819fef4bdb417e3ff9aee08266264b6ec23e075 Mon Sep 17 00:00:00 2001 +From: pennam +Date: Wed, 11 Sep 2024 12:24:01 +0200 +Subject: [PATCH 235/236] RP2040: add second_stage_ota section to linker script + + - This was previously done inside mbed-os-to-arduino script +--- + .../TARGET_RP2040/TOOLCHAIN_GCC_ARM/memmap_default.ld | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/targets/TARGET_RASPBERRYPI/TARGET_RP2040/TOOLCHAIN_GCC_ARM/memmap_default.ld b/targets/TARGET_RASPBERRYPI/TARGET_RP2040/TOOLCHAIN_GCC_ARM/memmap_default.ld +index ec8bac7e40..8295f3269d 100644 +--- a/targets/TARGET_RASPBERRYPI/TARGET_RP2040/TOOLCHAIN_GCC_ARM/memmap_default.ld ++++ b/targets/TARGET_RASPBERRYPI/TARGET_RP2040/TOOLCHAIN_GCC_ARM/memmap_default.ld +@@ -54,6 +54,10 @@ SECTIONS + __flash_binary_start = .; + } > FLASH + ++ .second_stage_ota : { ++ KEEP (*(.second_stage_ota)) ++ } > FLASH ++ + .boot2 : { + __boot2_start__ = .; + KEEP (*(.boot2)) +-- +2.45.2 + diff --git a/patches/0236-RP2040-add-simbols-to-linker-script-to-compute-.unin.patch b/patches/0236-RP2040-add-simbols-to-linker-script-to-compute-.unin.patch new file mode 100644 index 000000000..df9c8a642 --- /dev/null +++ b/patches/0236-RP2040-add-simbols-to-linker-script-to-compute-.unin.patch @@ -0,0 +1,27 @@ +From 35b0d95199cb5b9cda593ce4b4029c4306906ccd Mon Sep 17 00:00:00 2001 +From: pennam +Date: Wed, 11 Sep 2024 12:27:03 +0200 +Subject: [PATCH 236/236] RP2040: add simbols to linker script to compute + .uninitialized_data section size + +--- + .../TARGET_RP2040/TOOLCHAIN_GCC_ARM/memmap_default.ld | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/targets/TARGET_RASPBERRYPI/TARGET_RP2040/TOOLCHAIN_GCC_ARM/memmap_default.ld b/targets/TARGET_RASPBERRYPI/TARGET_RP2040/TOOLCHAIN_GCC_ARM/memmap_default.ld +index 8295f3269d..b748bab5fa 100644 +--- a/targets/TARGET_RASPBERRYPI/TARGET_RP2040/TOOLCHAIN_GCC_ARM/memmap_default.ld ++++ b/targets/TARGET_RASPBERRYPI/TARGET_RP2040/TOOLCHAIN_GCC_ARM/memmap_default.ld +@@ -183,7 +183,9 @@ SECTIONS + + .uninitialized_data (COPY): { + . = ALIGN(4); ++ __uninitialized_data_start__ = .; + *(.uninitialized_data*) ++ __uninitialized_data_end__ = .; + } > RAM + + /* Start and end symbols must be word-aligned */ +-- +2.45.2 + diff --git a/patches/0237-Watchdog-kick-only-if-watchdog-is-running.patch b/patches/0237-Watchdog-kick-only-if-watchdog-is-running.patch new file mode 100644 index 000000000..32071746a --- /dev/null +++ b/patches/0237-Watchdog-kick-only-if-watchdog-is-running.patch @@ -0,0 +1,31 @@ +From 81a7d47a15e76701b206bce907526b9d9d5888cc Mon Sep 17 00:00:00 2001 +From: pennam +Date: Wed, 2 Oct 2024 11:31:36 +0200 +Subject: [PATCH] Watchdog: kick only if watchdog is running + +--- + drivers/source/Watchdog.cpp | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +diff --git a/drivers/source/Watchdog.cpp b/drivers/source/Watchdog.cpp +index 3f21b94dfb..daca018148 100644 +--- a/drivers/source/Watchdog.cpp ++++ b/drivers/source/Watchdog.cpp +@@ -72,9 +72,11 @@ bool Watchdog::stop() + + void Watchdog::kick() + { +- core_util_critical_section_enter(); +- hal_watchdog_kick(); +- core_util_critical_section_exit(); ++ if (_running) { ++ core_util_critical_section_enter(); ++ hal_watchdog_kick(); ++ core_util_critical_section_exit(); ++ } + } + + bool Watchdog::is_running() const +-- +2.45.2 + diff --git a/patches/0238-WHD-reduce-the-number-of-join-retry.patch b/patches/0238-WHD-reduce-the-number-of-join-retry.patch new file mode 100644 index 000000000..ac90a76e7 --- /dev/null +++ b/patches/0238-WHD-reduce-the-number-of-join-retry.patch @@ -0,0 +1,25 @@ +From 42b018c12eb413383c6ae4f2432be9f0c2d9dbe9 Mon Sep 17 00:00:00 2001 +From: pennam +Date: Mon, 17 Jun 2024 17:11:58 +0200 +Subject: [PATCH] WHD: reduce the number of join retry + +--- + .../drivers/emac/COMPONENT_WHD/interface/WhdSTAInterface.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/connectivity/drivers/emac/COMPONENT_WHD/interface/WhdSTAInterface.cpp b/connectivity/drivers/emac/COMPONENT_WHD/interface/WhdSTAInterface.cpp +index 509a2c0981..c933203d36 100644 +--- a/connectivity/drivers/emac/COMPONENT_WHD/interface/WhdSTAInterface.cpp ++++ b/connectivity/drivers/emac/COMPONENT_WHD/interface/WhdSTAInterface.cpp +@@ -260,7 +260,7 @@ nsapi_error_t WhdSTAInterface::connect() + { + ScopedMutexLock lock(_iface_shared.mutex); + +-#define MAX_RETRY_COUNT ( 5 ) ++#define MAX_RETRY_COUNT ( 1 ) + int i; + whd_result_t res; + +-- +2.43.0 + diff --git a/patches/0239-WHD-add-join-timeout-parameter-to-WiFiSTAInterface-a.patch b/patches/0239-WHD-add-join-timeout-parameter-to-WiFiSTAInterface-a.patch new file mode 100644 index 000000000..9c5b688a2 --- /dev/null +++ b/patches/0239-WHD-add-join-timeout-parameter-to-WiFiSTAInterface-a.patch @@ -0,0 +1,152 @@ +From efd54c8990ba5b437eb4eb8b786b7e48941b03f1 Mon Sep 17 00:00:00 2001 +From: pennam +Date: Mon, 21 Oct 2024 11:27:36 +0200 +Subject: [PATCH] WHD: add join timeout parameter to WiFiSTAInterface and + drivers + +--- + .../emac/COMPONENT_WHD/interface/WhdSTAInterface.cpp | 7 ++++--- + .../emac/COMPONENT_WHD/interface/WhdSTAInterface.h | 6 ++++++ + .../COMPONENT_WHD/wifi-host-driver/inc/whd_wifi_api.h | 2 +- + .../COMPONENT_WHD/wifi-host-driver/src/whd_wifi_api.c | 9 ++++++--- + connectivity/netsocket/include/netsocket/WiFiInterface.h | 7 +++++++ + 5 files changed, 24 insertions(+), 7 deletions(-) + +diff --git a/connectivity/drivers/emac/COMPONENT_WHD/interface/WhdSTAInterface.cpp b/connectivity/drivers/emac/COMPONENT_WHD/interface/WhdSTAInterface.cpp +index c933203d36..f7631a0583 100644 +--- a/connectivity/drivers/emac/COMPONENT_WHD/interface/WhdSTAInterface.cpp ++++ b/connectivity/drivers/emac/COMPONENT_WHD/interface/WhdSTAInterface.cpp +@@ -211,7 +211,8 @@ WhdSTAInterface::WhdSTAInterface(WHD_EMAC &emac, OnboardNetworkStack &stack, Olm + _security(NSAPI_SECURITY_NONE), + _whd_emac(emac), + _olm(&olm), +- _iface_shared(shared) ++ _iface_shared(shared), ++ _timeout(7000) + { + } + +@@ -334,7 +335,7 @@ nsapi_error_t WhdSTAInterface::connect() + res = (whd_result_t)whd_wifi_join(_whd_emac.ifp, + &ssid, + security, +- (const uint8_t *)_pass, strlen(_pass)); ++ (const uint8_t *)_pass, strlen(_pass), _timeout); + } + else + { +@@ -345,7 +346,7 @@ nsapi_error_t WhdSTAInterface::connect() + res = (whd_result_t)whd_wifi_join(_whd_emac.ifp, + &ssid, + security, +- (const uint8_t *)_pass, key_length); ++ (const uint8_t *)_pass, key_length, _timeout); + } + if (res == WHD_SUCCESS) { + break; +diff --git a/connectivity/drivers/emac/COMPONENT_WHD/interface/WhdSTAInterface.h b/connectivity/drivers/emac/COMPONENT_WHD/interface/WhdSTAInterface.h +index 4dd1098947..bfe933bac7 100644 +--- a/connectivity/drivers/emac/COMPONENT_WHD/interface/WhdSTAInterface.h ++++ b/connectivity/drivers/emac/COMPONENT_WHD/interface/WhdSTAInterface.h +@@ -119,6 +119,11 @@ public: + return 0; + } + ++ nsapi_error_t set_timeout(uint32_t timeout) ++ { ++ _timeout = timeout; ++ } ++ + /** Set blocking status of interface. + * Nonblocking mode unsupported. + * +@@ -257,6 +262,7 @@ private: + nsapi_security_t _security; + WHD_EMAC &_whd_emac; + OlmInterface *_olm; ++ uint32_t _timeout; + whd_interface_shared_info_t &_iface_shared; + }; + +diff --git a/connectivity/drivers/wifi/COMPONENT_WHD/wifi-host-driver/inc/whd_wifi_api.h b/connectivity/drivers/wifi/COMPONENT_WHD/wifi-host-driver/inc/whd_wifi_api.h +index f3b73214cb..291bd23de8 100755 +--- a/connectivity/drivers/wifi/COMPONENT_WHD/wifi-host-driver/inc/whd_wifi_api.h ++++ b/connectivity/drivers/wifi/COMPONENT_WHD/wifi-host-driver/inc/whd_wifi_api.h +@@ -281,7 +281,7 @@ extern uint32_t whd_wifi_stop_scan(whd_interface_t ifp); + * Error code if an error occurred + */ + extern uint32_t whd_wifi_join(whd_interface_t ifp, const whd_ssid_t *ssid, whd_security_t auth_type, +- const uint8_t *security_key, uint8_t key_length); ++ const uint8_t *security_key, uint8_t key_length, uint32_t timeout); + + /** Joins a specific Wi-Fi network + * +diff --git a/connectivity/drivers/wifi/COMPONENT_WHD/wifi-host-driver/src/whd_wifi_api.c b/connectivity/drivers/wifi/COMPONENT_WHD/wifi-host-driver/src/whd_wifi_api.c +index 5294104ab4..8a8f411ef9 100755 +--- a/connectivity/drivers/wifi/COMPONENT_WHD/wifi-host-driver/src/whd_wifi_api.c ++++ b/connectivity/drivers/wifi/COMPONENT_WHD/wifi-host-driver/src/whd_wifi_api.c +@@ -294,6 +294,8 @@ static const uint16_t mcs_data_rate_lookup_table[32][2][2] = + }, + }; + ++static whd_wifi_join_timeout = DEFAULT_JOIN_ATTEMPT_TIMEOUT; ++ + + /****************************************************** + * Static Function prototypes +@@ -1334,7 +1336,7 @@ static uint32_t whd_wifi_join_wait_for_complete(whd_interface_t ifp, cy_semaphor + + while (!done) + { +- result = cy_rtos_get_semaphore(semaphore, DEFAULT_JOIN_ATTEMPT_TIMEOUT / 10, WHD_FALSE); ++ result = cy_rtos_get_semaphore(semaphore, whd_wifi_join_timeout / 10, WHD_FALSE); + whd_assert("Get semaphore failed", (result == CY_RSLT_SUCCESS) || (result == CY_RTOS_TIMEOUT) ); + REFERENCE_DEBUG_ONLY_VARIABLE(result); + +@@ -1345,7 +1347,7 @@ static uint32_t whd_wifi_join_wait_for_complete(whd_interface_t ifp, cy_semaphor + } + + cy_rtos_get_time(¤t_time); +- done = (whd_bool_t)( (current_time - start_time) >= DEFAULT_JOIN_ATTEMPT_TIMEOUT ); ++ done = (whd_bool_t)( (current_time - start_time) >= whd_wifi_join_timeout ); + } + + if (result != WHD_SUCCESS) +@@ -1574,7 +1576,7 @@ uint32_t whd_wifi_join_specific(whd_interface_t ifp, const whd_scan_result_t *ap + } + + uint32_t whd_wifi_join(whd_interface_t ifp, const whd_ssid_t *ssid, whd_security_t auth_type, +- const uint8_t *security_key, uint8_t key_length) ++ const uint8_t *security_key, uint8_t key_length, uint32_t timeout) + { + cy_semaphore_t join_sema; + whd_result_t result; +@@ -1616,6 +1618,7 @@ uint32_t whd_wifi_join(whd_interface_t ifp, const whd_ssid_t *ssid, whd_security + ssid_params->SSID_len = htod32(ssid->length); + memcpy(ssid_params->SSID, ssid->value, ssid_params->SSID_len); + result = whd_cdc_send_ioctl(ifp, CDC_SET, WLC_SET_SSID, buffer, 0); ++ whd_wifi_join_timeout = timeout; + + if (result == WHD_SUCCESS) + { +diff --git a/connectivity/netsocket/include/netsocket/WiFiInterface.h b/connectivity/netsocket/include/netsocket/WiFiInterface.h +index 4fd7fc6fb8..c13cab4312 100644 +--- a/connectivity/netsocket/include/netsocket/WiFiInterface.h ++++ b/connectivity/netsocket/include/netsocket/WiFiInterface.h +@@ -59,6 +59,13 @@ public: + */ + virtual nsapi_error_t set_channel(uint8_t channel) = 0; + ++ /** Set the Wi-Fi network join timeout. ++ * ++ * @param timeout joint timeout in milliseconds (Default: 7000). ++ * @return NSAPI_ERROR_OK on success, or error code on failure. ++ */ ++ virtual nsapi_error_t set_timeout(uint32_t timeout) = 0; ++ + /** Get the current radio signal strength for active connection. + * + * @return Connection strength in dBm (negative value), +-- +2.45.2 + diff --git a/patches/0240-TLSSocketWrapper-add-read-write-event-flags.patch b/patches/0240-TLSSocketWrapper-add-read-write-event-flags.patch new file mode 100644 index 000000000..bcdc702ce --- /dev/null +++ b/patches/0240-TLSSocketWrapper-add-read-write-event-flags.patch @@ -0,0 +1,69 @@ +From 4369443525c662ddb2ecb15dd9cdba0098e1f01d Mon Sep 17 00:00:00 2001 +From: pennam +Date: Mon, 28 Oct 2024 09:56:31 +0100 +Subject: [PATCH] TLSSocketWrapper: add read/write event flags + + This allows to properly handle timeouts during read write operations +--- + .../netsocket/include/netsocket/TLSSocketWrapper.h | 4 ++++ + connectivity/netsocket/source/TLSSocketWrapper.cpp | 8 ++++---- + 2 files changed, 8 insertions(+), 4 deletions(-) + +diff --git a/connectivity/netsocket/include/netsocket/TLSSocketWrapper.h b/connectivity/netsocket/include/netsocket/TLSSocketWrapper.h +index 2dc3b4b000..79fe5c564d 100644 +--- a/connectivity/netsocket/include/netsocket/TLSSocketWrapper.h ++++ b/connectivity/netsocket/include/netsocket/TLSSocketWrapper.h +@@ -379,6 +379,10 @@ private: + Socket *_transport; + int _timeout = -1; + ++ // Event flags ++ static const int READ_FLAG = 0x1u; ++ static const int WRITE_FLAG = 0x2u; ++ + #ifdef MBEDTLS_X509_CRT_PARSE_C + mbedtls_x509_crt *_cacert = nullptr; + mbedtls_x509_crt *_clicert = nullptr; +diff --git a/connectivity/netsocket/source/TLSSocketWrapper.cpp b/connectivity/netsocket/source/TLSSocketWrapper.cpp +index c020cd9f59..3a66be2e5e 100644 +--- a/connectivity/netsocket/source/TLSSocketWrapper.cpp ++++ b/connectivity/netsocket/source/TLSSocketWrapper.cpp +@@ -381,7 +381,7 @@ nsapi_error_t TLSSocketWrapper::continue_handshake() + ret = mbedtls_ssl_handshake(&_ssl); + if (_timeout && (ret == MBEDTLS_ERR_SSL_WANT_READ || ret == MBEDTLS_ERR_SSL_WANT_WRITE)) { + uint32_t flag; +- flag = _event_flag.wait_any(1, _timeout); ++ flag = _event_flag.wait_any(WRITE_FLAG | READ_FLAG, _timeout); + if (flag & osFlagsError) { + break; + } +@@ -461,7 +461,7 @@ nsapi_error_t TLSSocketWrapper::send(const void *data, nsapi_size_t size) + break; + } else if (ret == MBEDTLS_ERR_SSL_WANT_WRITE || ret == MBEDTLS_ERR_SSL_WANT_READ) { + uint32_t flag; +- flag = _event_flag.wait_any(1, _timeout); ++ flag = _event_flag.wait_any(WRITE_FLAG, _timeout); + if (flag & osFlagsError) { + // Timeout break + break; +@@ -522,7 +522,7 @@ nsapi_size_or_error_t TLSSocketWrapper::recv(void *data, nsapi_size_t size) + break; + } else if (ret == MBEDTLS_ERR_SSL_WANT_WRITE || ret == MBEDTLS_ERR_SSL_WANT_READ) { + uint32_t flag; +- flag = _event_flag.wait_any(1, _timeout); ++ flag = _event_flag.wait_any(READ_FLAG, _timeout); + if (flag & osFlagsError) { + // Timeout break + break; +@@ -855,7 +855,7 @@ nsapi_error_t TLSSocketWrapper::listen(int) + + void TLSSocketWrapper::event() + { +- _event_flag.set(1); ++ _event_flag.set(READ_FLAG | WRITE_FLAG); + if (_sigio) { + _sigio(); + } +-- +2.45.2 + diff --git a/patches/0241-Add-methods-for-setting-hostname.patch b/patches/0241-Add-methods-for-setting-hostname.patch new file mode 100644 index 000000000..21c301771 --- /dev/null +++ b/patches/0241-Add-methods-for-setting-hostname.patch @@ -0,0 +1,196 @@ +From 75b34cc20a33c05cbc01b3fbdabbfc40ae034bef Mon Sep 17 00:00:00 2001 +From: Guilherme Ricioli +Date: Mon, 15 Apr 2024 17:40:59 -0300 +Subject: [PATCH] Add methods for setting hostname + +In the same way it is done for setting MAC address, add methods for +setting hostname. The underlying network stack can then request this +to the local DNS through DHCP. +--- + .../include/netsocket/EMACInterface.h | 8 ++++++ + .../include/netsocket/NetworkInterface.h | 16 ++++++++++++ + .../netsocket/include/netsocket/nsapi_types.h | 10 +++++++ + .../netsocket/source/EMACInterface.cpp | 26 +++++++++++++++++++ + .../netsocket/source/NetworkInterface.cpp | 10 +++++++ + .../doubles/NetworkInterface_stub.cpp | 10 +++++++ + .../test_NetworkInterface.cpp | 11 ++++++++ + 7 files changed, 91 insertions(+) + +diff --git a/connectivity/netsocket/include/netsocket/EMACInterface.h b/connectivity/netsocket/include/netsocket/EMACInterface.h +index 8cf47cb703..c06aeb850e 100644 +--- a/connectivity/netsocket/include/netsocket/EMACInterface.h ++++ b/connectivity/netsocket/include/netsocket/EMACInterface.h +@@ -83,6 +83,12 @@ public: + /** @copydoc NetworkInterface::disconnect */ + nsapi_error_t disconnect() override; + ++ /** @copydoc NetworkInterface::get_hostname */ ++ const char *get_hostname() override; ++ ++ /** @copydoc NetworkInterface::set_hostname */ ++ nsapi_error_t set_hostname(const char *hostname) override; ++ + /** @copydoc NetworkInterface::get_mac_address */ + const char *get_mac_address() override; + +@@ -146,6 +152,8 @@ protected: + OnboardNetworkStack::Interface *_interface = nullptr; + bool _dhcp = true; + bool _blocking = true; ++ bool _hostname_set = false; ++ char _hostname[NSAPI_HOSTNAME_SIZE]; + bool _hw_mac_addr_set = false; + char _mac_address[NSAPI_MAC_SIZE]; + char _ip_address[NSAPI_IPv6_SIZE] {}; +diff --git a/connectivity/netsocket/include/netsocket/NetworkInterface.h b/connectivity/netsocket/include/netsocket/NetworkInterface.h +index 9071a1e40b..81f6011950 100644 +--- a/connectivity/netsocket/include/netsocket/NetworkInterface.h ++++ b/connectivity/netsocket/include/netsocket/NetworkInterface.h +@@ -90,6 +90,22 @@ public: + */ + virtual void set_as_default(); + ++ /** Get hostname. ++ * ++ * @return Hostname if configured, null otherwise ++ */ ++ virtual const char *get_hostname(); ++ ++ /** Set hostname. ++ * ++ * @param hostname Hostname string ++ * @retval NSAPI_ERROR_OK on success ++ * @retval NSAPI_ERROR_UNSUPPORTED if this feature is not supported ++ * @retval NSAPI_ERROR_PARAMETER if hostname is not valid ++ * @retval NSAPI_ERROR_BUSY if hostname couldn't be set ++ */ ++ virtual nsapi_error_t set_hostname(const char *hostname); ++ + /** Get the local MAC address. + * + * Provided MAC address is intended for info or debug purposes and +diff --git a/connectivity/netsocket/include/netsocket/nsapi_types.h b/connectivity/netsocket/include/netsocket/nsapi_types.h +index 3b496d5087..28dbcc9a38 100644 +--- a/connectivity/netsocket/include/netsocket/nsapi_types.h ++++ b/connectivity/netsocket/include/netsocket/nsapi_types.h +@@ -196,6 +196,16 @@ typedef enum nsapi_security { + */ + #define NSAPI_IP_BYTES NSAPI_IPv6_BYTES + ++/** Maximum size of hostname ++ * ++ * According to RFC 1034 [1], Section 3.1 "Name space specifications and ++ * terminology", 63 is the maximum size of a hostname. +1 for the string ++ * terminator. ++ * ++ * [1] https://www.rfc-editor.org/rfc/rfc1034 ++ */ ++#define NSAPI_HOSTNAME_SIZE 64 ++ + /** Maximum size of MAC address representation + */ + #define NSAPI_MAC_SIZE 18 +diff --git a/connectivity/netsocket/source/EMACInterface.cpp b/connectivity/netsocket/source/EMACInterface.cpp +index f48bc0a185..de8d9753d7 100644 +--- a/connectivity/netsocket/source/EMACInterface.cpp ++++ b/connectivity/netsocket/source/EMACInterface.cpp +@@ -88,6 +88,32 @@ nsapi_error_t EMACInterface::disconnect() + return NSAPI_ERROR_NO_CONNECTION; + } + ++const char *EMACInterface::get_hostname() ++{ ++ if (_hostname_set) { ++ return _hostname; ++ } ++ return nullptr; ++} ++ ++nsapi_error_t EMACInterface::set_hostname(const char *hostname) ++{ ++ if (!hostname || strlen(hostname) > NSAPI_HOSTNAME_SIZE - 1) { ++ return NSAPI_ERROR_PARAMETER; ++ } ++ ++ if (_interface) { ++ // can't set hostname once initialized ++ return NSAPI_ERROR_BUSY; ++ } ++ ++ memset(_hostname, 0, NSAPI_HOSTNAME_SIZE); ++ strncpy(_hostname, hostname, NSAPI_HOSTNAME_SIZE - 1); ++ _hostname_set = true; ++ ++ return NSAPI_ERROR_OK; ++} ++ + const char *EMACInterface::get_mac_address() + { + if (_interface && _interface->get_mac_address(_mac_address, sizeof(_mac_address))) { +diff --git a/connectivity/netsocket/source/NetworkInterface.cpp b/connectivity/netsocket/source/NetworkInterface.cpp +index 0f237f0e19..649df0f9b3 100644 +--- a/connectivity/netsocket/source/NetworkInterface.cpp ++++ b/connectivity/netsocket/source/NetworkInterface.cpp +@@ -29,6 +29,16 @@ void NetworkInterface::set_as_default() + + } + ++const char *NetworkInterface::get_hostname() ++{ ++ return 0; ++} ++ ++nsapi_error_t NetworkInterface::set_hostname(const char *hostname) ++{ ++ return NSAPI_ERROR_UNSUPPORTED; ++} ++ + const char *NetworkInterface::get_mac_address() + { + return 0; +diff --git a/connectivity/netsocket/tests/UNITTESTS/doubles/NetworkInterface_stub.cpp b/connectivity/netsocket/tests/UNITTESTS/doubles/NetworkInterface_stub.cpp +index 020a551ba9..c849704a35 100644 +--- a/connectivity/netsocket/tests/UNITTESTS/doubles/NetworkInterface_stub.cpp ++++ b/connectivity/netsocket/tests/UNITTESTS/doubles/NetworkInterface_stub.cpp +@@ -21,6 +21,16 @@ + + + // Default network-interface state ++const char *NetworkInterface::get_hostname() ++{ ++ return 0; ++} ++ ++nsapi_error_t NetworkInterface::set_hostname(const char *hostname) ++{ ++ return NSAPI_ERROR_UNSUPPORTED; ++} ++ + const char *NetworkInterface::get_mac_address() + { + return 0; +diff --git a/connectivity/netsocket/tests/UNITTESTS/netsocket/NetworkInterface/test_NetworkInterface.cpp b/connectivity/netsocket/tests/UNITTESTS/netsocket/NetworkInterface/test_NetworkInterface.cpp +index 1a928c36ee..27433ffaa1 100644 +--- a/connectivity/netsocket/tests/UNITTESTS/netsocket/NetworkInterface/test_NetworkInterface.cpp ++++ b/connectivity/netsocket/tests/UNITTESTS/netsocket/NetworkInterface/test_NetworkInterface.cpp +@@ -68,6 +68,17 @@ TEST_F(TestNetworkInterface, constructor) + } + + // get_default_instance is tested along with the implementations of NetworkInterface. ++TEST_F(TestNetworkInterface, get_hostname) ++{ ++ char *n = 0; ++ EXPECT_EQ(iface->get_hostname(), n); ++} ++ ++TEST_F(TestNetworkInterface, set_hostname) ++{ ++ char *hostname; ++ EXPECT_EQ(iface->set_hostname(hostname), NSAPI_ERROR_UNSUPPORTED); ++} + + TEST_F(TestNetworkInterface, get_mac_address) + { +-- +2.45.2 + diff --git a/patches/0242-Request-hostname-through-DHCP.patch b/patches/0242-Request-hostname-through-DHCP.patch new file mode 100644 index 000000000..e2a383900 --- /dev/null +++ b/patches/0242-Request-hostname-through-DHCP.patch @@ -0,0 +1,53 @@ +From 091ea74d6956d6684bcd88ed842a73218a7b8bd3 Mon Sep 17 00:00:00 2001 +From: Guilherme Ricioli +Date: Tue, 16 Apr 2024 10:50:48 -0300 +Subject: [PATCH] Request hostname through DHCP + +If hostname is provided, request it to local DNS through DHCP. +--- + connectivity/lwipstack/source/LWIPInterface.cpp | 6 ++++++ + connectivity/netsocket/include/netsocket/NetworkInterface.h | 4 +++- + 2 files changed, 9 insertions(+), 1 deletion(-) + +diff --git a/connectivity/lwipstack/source/LWIPInterface.cpp b/connectivity/lwipstack/source/LWIPInterface.cpp +index dfefebcb8b..64869a3538 100644 +--- a/connectivity/lwipstack/source/LWIPInterface.cpp ++++ b/connectivity/lwipstack/source/LWIPInterface.cpp +@@ -437,6 +437,7 @@ LWIP::Interface::Interface() : + nsapi_error_t LWIP::add_ethernet_interface(EMAC &emac, bool default_if, OnboardNetworkStack::Interface **interface_out, NetworkInterface *user_network_interface) + { + #if LWIP_ETHERNET ++ const char *hostname; + Interface *interface = new (std::nothrow) Interface(); + if (!interface) { + return NSAPI_ERROR_NO_MEMORY; +@@ -445,6 +446,11 @@ nsapi_error_t LWIP::add_ethernet_interface(EMAC &emac, bool default_if, OnboardN + interface->memory_manager = &memory_manager; + interface->ppp_enabled = false; + ++ hostname = user_network_interface->get_hostname(); ++ if (hostname) { ++ netif_set_hostname(&interface->netif, hostname); ++ } ++ + #if (MBED_MAC_ADDRESS_SUM != MBED_MAC_ADDR_INTERFACE) + netif->interface.hwaddr[0] = MBED_MAC_ADDR_0; + netif->interface.hwaddr[1] = MBED_MAC_ADDR_1; +diff --git a/connectivity/netsocket/include/netsocket/NetworkInterface.h b/connectivity/netsocket/include/netsocket/NetworkInterface.h +index 81f6011950..22355767ce 100644 +--- a/connectivity/netsocket/include/netsocket/NetworkInterface.h ++++ b/connectivity/netsocket/include/netsocket/NetworkInterface.h +@@ -102,7 +102,9 @@ public: + * @retval NSAPI_ERROR_OK on success + * @retval NSAPI_ERROR_UNSUPPORTED if this feature is not supported + * @retval NSAPI_ERROR_PARAMETER if hostname is not valid +- * @retval NSAPI_ERROR_BUSY if hostname couldn't be set ++ * @retval NSAPI_ERROR_BUSY if hostname couldn't be set (e.g. for ++ * LwIP stack, hostname can only be set before calling ++ * \c EthernetInterface::connect method) + */ + virtual nsapi_error_t set_hostname(const char *hostname); + +-- +2.45.2 + diff --git a/patches/0243-WhdSTA-allow-hostname-configuration.patch b/patches/0243-WhdSTA-allow-hostname-configuration.patch new file mode 100644 index 000000000..9fea05c90 --- /dev/null +++ b/patches/0243-WhdSTA-allow-hostname-configuration.patch @@ -0,0 +1,25 @@ +From b6c62d169e750de6e5af3a47bc6c0c2a1fc81c88 Mon Sep 17 00:00:00 2001 +From: pennam +Date: Thu, 3 Oct 2024 18:05:26 +0200 +Subject: [PATCH] WhdSTA allow hostname configuration + +--- + .../drivers/emac/COMPONENT_WHD/interface/WhdSTAInterface.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/connectivity/drivers/emac/COMPONENT_WHD/interface/WhdSTAInterface.cpp b/connectivity/drivers/emac/COMPONENT_WHD/interface/WhdSTAInterface.cpp +index 509a2c0981..ba1fa7900a 100644 +--- a/connectivity/drivers/emac/COMPONENT_WHD/interface/WhdSTAInterface.cpp ++++ b/connectivity/drivers/emac/COMPONENT_WHD/interface/WhdSTAInterface.cpp +@@ -280,7 +280,7 @@ nsapi_error_t WhdSTAInterface::connect() + _iface_shared.if_status_flags |= IF_STATUS_STA_UP; + _iface_shared.default_if_cfg = DEFAULT_IF_STA; + if (!_interface) { +- nsapi_error_t err = _stack.add_ethernet_interface(_emac, true, &_interface); ++ nsapi_error_t err = _stack.add_ethernet_interface(_emac, true, &_interface, this); + if (err != NSAPI_ERROR_OK) { + _interface = NULL; + return err; +-- +2.45.2 + diff --git a/patches/0244-Add-user-network-interface-check-before-reading-host.patch b/patches/0244-Add-user-network-interface-check-before-reading-host.patch new file mode 100644 index 000000000..52d3e79b9 --- /dev/null +++ b/patches/0244-Add-user-network-interface-check-before-reading-host.patch @@ -0,0 +1,31 @@ +From 4292f8b7c4aa38b68d22c413f91bdc95192cfad6 Mon Sep 17 00:00:00 2001 +From: pennam +Date: Tue, 29 Oct 2024 11:30:00 +0100 +Subject: [PATCH] Add user network interface check before reading hostname + +--- + connectivity/lwipstack/source/LWIPInterface.cpp | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +diff --git a/connectivity/lwipstack/source/LWIPInterface.cpp b/connectivity/lwipstack/source/LWIPInterface.cpp +index 64869a3538..da964543c7 100644 +--- a/connectivity/lwipstack/source/LWIPInterface.cpp ++++ b/connectivity/lwipstack/source/LWIPInterface.cpp +@@ -446,9 +446,11 @@ nsapi_error_t LWIP::add_ethernet_interface(EMAC &emac, bool default_if, OnboardN + interface->memory_manager = &memory_manager; + interface->ppp_enabled = false; + +- hostname = user_network_interface->get_hostname(); +- if (hostname) { +- netif_set_hostname(&interface->netif, hostname); ++ if (user_network_interface) { ++ hostname = user_network_interface->get_hostname(); ++ if (hostname) { ++ netif_set_hostname(&interface->netif, hostname); ++ } + } + + #if (MBED_MAC_ADDRESS_SUM != MBED_MAC_ADDR_INTERFACE) +-- +2.45.2 + diff --git a/patches/0245-WHD-fix-WhdSTAInterface-add-return-value-to-set_time.patch b/patches/0245-WHD-fix-WhdSTAInterface-add-return-value-to-set_time.patch new file mode 100644 index 000000000..b96a94888 --- /dev/null +++ b/patches/0245-WHD-fix-WhdSTAInterface-add-return-value-to-set_time.patch @@ -0,0 +1,24 @@ +From 310f0dd40c5b070ea2077c8a580f777a5cf17951 Mon Sep 17 00:00:00 2001 +From: pennam +Date: Tue, 7 Jan 2025 09:47:09 +0100 +Subject: [PATCH] WHD: fix WhdSTAInterface, add return value to set_timeout + +--- + .../drivers/emac/COMPONENT_WHD/interface/WhdSTAInterface.h | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/connectivity/drivers/emac/COMPONENT_WHD/interface/WhdSTAInterface.h b/connectivity/drivers/emac/COMPONENT_WHD/interface/WhdSTAInterface.h +index bfe933bac7..8d8f540759 100644 +--- a/connectivity/drivers/emac/COMPONENT_WHD/interface/WhdSTAInterface.h ++++ b/connectivity/drivers/emac/COMPONENT_WHD/interface/WhdSTAInterface.h +@@ -122,6 +122,7 @@ public: + nsapi_error_t set_timeout(uint32_t timeout) + { + _timeout = timeout; ++ return NSAPI_ERROR_OK; + } + + /** Set blocking status of interface. +-- +2.45.2 + diff --git a/patches/0246-WHD-remove-v-from-WHD_VERSION-define.patch b/patches/0246-WHD-remove-v-from-WHD_VERSION-define.patch new file mode 100644 index 000000000..8d0289263 --- /dev/null +++ b/patches/0246-WHD-remove-v-from-WHD_VERSION-define.patch @@ -0,0 +1,25 @@ +From fa1e9697ca3b74489bd2eb08ab9ab1ffeee2a298 Mon Sep 17 00:00:00 2001 +From: pennam +Date: Fri, 31 Jan 2025 16:34:05 +0100 +Subject: [PATCH 246/247] WHD: remove v from WHD_VERSION define + +--- + .../wifi/COMPONENT_WHD/wifi-host-driver/inc/whd_version.h | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/connectivity/drivers/wifi/COMPONENT_WHD/wifi-host-driver/inc/whd_version.h b/connectivity/drivers/wifi/COMPONENT_WHD/wifi-host-driver/inc/whd_version.h +index 1caef23b67..5f69d8c3e0 100755 +--- a/connectivity/drivers/wifi/COMPONENT_WHD/wifi-host-driver/inc/whd_version.h ++++ b/connectivity/drivers/wifi/COMPONENT_WHD/wifi-host-driver/inc/whd_version.h +@@ -15,6 +15,7 @@ + * limitations under the License. + */ + +-#define WHD_VERSION "v1.94.0" ++/* This define is used by arduino::WiFiClass::firmwareVersion() do not prepend v */ ++#define WHD_VERSION "1.94.0" + #define WHD_BRANCH "v1.94.0" + #define WHD_DATE "2021-04-27 16:54:34 +0800" +-- +2.47.2 + diff --git a/patches/0247-ICMPSocket-add-ping.patch b/patches/0247-ICMPSocket-add-ping.patch new file mode 100644 index 000000000..2019bcb0c --- /dev/null +++ b/patches/0247-ICMPSocket-add-ping.patch @@ -0,0 +1,106 @@ +From 933694e0f35451d21eed77a93fa346570de20878 Mon Sep 17 00:00:00 2001 +From: pennam +Date: Tue, 4 Feb 2025 14:31:59 +0100 +Subject: [PATCH] ICMPSocket: add ping + +--- + .../netsocket/include/netsocket/ICMPSocket.h | 4 ++ + connectivity/netsocket/source/ICMPSocket.cpp | 61 +++++++++++++++++++ + 2 files changed, 65 insertions(+) + +diff --git a/connectivity/netsocket/include/netsocket/ICMPSocket.h b/connectivity/netsocket/include/netsocket/ICMPSocket.h +index 1837bc8e09..5e1ee8fb03 100644 +--- a/connectivity/netsocket/include/netsocket/ICMPSocket.h ++++ b/connectivity/netsocket/include/netsocket/ICMPSocket.h +@@ -37,6 +37,10 @@ public: + */ + ICMPSocket(); + ++#if MBED_CONF_LWIP_RAW_SOCKET_ENABLED ++ int ping(SocketAddress &socketAddress, uint32_t timeout); ++#endif ++ + #if !defined(DOXYGEN_ONLY) + + protected: +diff --git a/connectivity/netsocket/source/ICMPSocket.cpp b/connectivity/netsocket/source/ICMPSocket.cpp +index f6c9b98de1..d8ea954835 100644 +--- a/connectivity/netsocket/source/ICMPSocket.cpp ++++ b/connectivity/netsocket/source/ICMPSocket.cpp +@@ -16,12 +16,73 @@ + */ + + #include "ICMPSocket.h" ++#if MBED_CONF_LWIP_RAW_SOCKET_ENABLED ++#include "drivers/Timer.h" ++#include "lwip/prot/icmp.h" ++#include "lwip/inet_chksum.h" ++#include "lwip/prot/ip4.h" ++#endif + + ICMPSocket::ICMPSocket() + { + _socket_stats.stats_update_proto(this, NSAPI_ICMP); + } + ++#if MBED_CONF_LWIP_RAW_SOCKET_ENABLED ++int ICMPSocket::ping(SocketAddress &socketAddress, uint32_t timeout) ++{ ++ struct __attribute__((__packed__)) { ++ struct icmp_echo_hdr header; ++ uint8_t data[32]; ++ } request; ++ ++ ICMPH_TYPE_SET(&request.header, ICMP_ECHO); ++ ICMPH_CODE_SET(&request.header, 0); ++ request.header.chksum = 0; ++ request.header.id = 0xAFAF; ++ request.header.seqno = random(); ++ ++ for (size_t i = 0; i < sizeof(request.data); i++) { ++ request.data[i] = i; ++ } ++ ++ request.header.chksum = inet_chksum(&request, sizeof(request)); ++ ++ int res = sendto(socketAddress, &request, sizeof(request)); ++ if (res <= 0){ ++ return -1; ++ } ++ ++ mbed::Timer timer; ++ timer.start(); ++ int elapsed = -1; ++ do { ++ struct __attribute__((__packed__)) { ++ struct ip_hdr ipHeader; ++ struct icmp_echo_hdr header; ++ } response; ++ ++ int rxSize = recvfrom(&socketAddress, &response, sizeof(response)); ++ if (rxSize < 0) { ++ // time out ++ break; ++ } ++ ++ if (rxSize < sizeof(response)) { ++ // too short ++ continue; ++ } ++ ++ if ((response.header.id == request.header.id) && (response.header.seqno == request.header.seqno)) { ++ elapsed = std::chrono::duration_cast(timer.elapsed_time()).count(); ++ timer.stop(); ++ } ++ } while (elapsed == -1 && std::chrono::duration_cast(timer.elapsed_time()).count() < timeout); ++ ++ return elapsed; ++} ++#endif ++ + nsapi_protocol_t ICMPSocket::get_proto() + { + return NSAPI_ICMP; +-- +2.47.2 + 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/patches/0262-Add-Stella-target.patch b/patches/0262-Add-Stella-target.patch new file mode 100644 index 000000000..ae9d94f89 --- /dev/null +++ b/patches/0262-Add-Stella-target.patch @@ -0,0 +1,343 @@ +From 2e630587c4174fc192a1945f09300e73fc2d5b87 Mon Sep 17 00:00:00 2001 +From: pennam +Date: Mon, 30 Jun 2025 14:15:01 +0200 +Subject: [PATCH] Add Stella target + +--- + .../TARGET_STELLA/PinNames.h | 246 ++++++++++++++++++ + .../TARGET_STELLA/device.h | 39 +++ + targets/targets.json | 19 ++ + 3 files changed, 304 insertions(+) + create mode 100644 targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/TARGET_STELLA/PinNames.h + create mode 100644 targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/TARGET_STELLA/device.h + +diff --git a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/TARGET_STELLA/PinNames.h b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/TARGET_STELLA/PinNames.h +new file mode 100644 +index 0000000000..b4ef8a160b +--- /dev/null ++++ b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/TARGET_STELLA/PinNames.h +@@ -0,0 +1,246 @@ ++/* ++ * Copyright (c) 2019 Arduino SA ++ * ++ * Licensed under the Apache License, Version 2.0 (the "License"); ++ * you may not use this file except in compliance with the License. ++ * You may obtain a copy of the License at ++ * ++ * http://www.apache.org/licenses/LICENSE-2.0 ++ * ++ * Unless required by applicable law or agreed to in writing, software ++ * distributed under the License is distributed on an "AS IS" BASIS, ++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++ * See the License for the specific language governing permissions and ++ * limitations under the License. ++ */ ++ ++/* MBED TARGET LIST: ARDUINO_NANO33BLE */ ++ ++#ifndef MBED_PINNAMES_H ++#define MBED_PINNAMES_H ++ ++#include "cmsis.h" ++#include "nrf_gpio.h" ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++typedef enum { ++ PIN_INPUT, ++ PIN_OUTPUT ++} PinDirection; ++ ++///> define macro producing for example Px_y = NRF_GPIO_PIN_MAP(x, y) ++#define PinDef(port_num, pin_num) P##port_num##_##pin_num = NRF_GPIO_PIN_MAP(port_num, pin_num) ++ ++ ++typedef enum { ++ PinDef(0 , 0), // P0_0 = 0... ++ PinDef(0 , 1), ++ PinDef(0 , 2), ++ PinDef(0 , 3), ++ PinDef(0 , 4), ++ PinDef(0 , 5), ++ PinDef(0 , 6), ++ PinDef(0 , 7), ++ PinDef(0 , 8), ++ PinDef(0 , 9), ++ PinDef(0 , 10), ++ PinDef(0 , 11), ++ PinDef(0 , 12), ++ PinDef(0 , 13), ++ PinDef(0 , 14), ++ PinDef(0 , 15), ++ PinDef(0 , 16), ++ PinDef(0 , 17), ++ PinDef(0 , 18), ++ PinDef(0 , 19), ++ PinDef(0 , 20), ++ PinDef(0 , 21), ++ PinDef(0 , 22), ++ PinDef(0 , 23), ++ PinDef(0 , 24), ++ PinDef(0 , 25), ++ PinDef(0 , 26), ++ PinDef(0 , 27), ++ PinDef(0 , 28), ++ PinDef(0 , 29), ++ PinDef(0 , 30), ++ PinDef(0 , 31), ++ ++ PinDef(1 , 0), //P1_1 = 32... ++ PinDef(1 , 1), ++ PinDef(1 , 2), ++ PinDef(1 , 3), ++ PinDef(1 , 4), ++ PinDef(1 , 5), ++ PinDef(1 , 6), ++ PinDef(1 , 7), ++ PinDef(1 , 8), ++ PinDef(1 , 9), ++ PinDef(1 , 10), ++ PinDef(1 , 11), ++ PinDef(1 , 12), ++ PinDef(1 , 13), ++ PinDef(1 , 14), ++ PinDef(1 , 15), ++ ++ // Port0 ++ p0 = P0_0, ++ p1 = P0_1, ++ p2 = P0_2, ++ p3 = P0_3, ++ p4 = P0_4, ++ p5 = P0_5, ++ p6 = P0_6, ++ p7 = P0_7, ++ p8 = P0_8, ++ p9 = P0_9, ++ p10 = P0_10, ++ p11 = P0_11, ++ p12 = P0_12, ++ p13 = P0_13, ++ p14 = P0_14, ++ p15 = P0_15, ++ p16 = P0_16, ++ p17 = P0_17, ++ p18 = P0_18, ++ p19 = P0_19, ++ p20 = P0_20, ++ p21 = P0_21, ++ p22 = P0_22, ++ p23 = P0_23, ++ p24 = P0_24, ++ p25 = P0_25, ++ p26 = P0_26, ++ p27 = P0_27, ++ p28 = P0_28, ++ p29 = P0_29, ++ p30 = P0_30, ++ p31 = P0_31, ++ ++ // Port1 ++ p32 = P1_0, ++ p33 = P1_1, ++ p34 = P1_2, ++ p35 = P1_3, ++ p36 = P1_4, ++ p37 = P1_5, ++ p38 = P1_6, ++ p39 = P1_7, ++ p40 = P1_8, ++ p41 = P1_9, ++ p42 = P1_10, ++ p43 = P1_11, ++ p44 = P1_12, ++ p45 = P1_13, ++ p46 = P1_14, ++ p47 = P1_15, ++ ++ RX_PIN_NUMBER = P1_10, ++ TX_PIN_NUMBER = P1_3, ++ ++ LED_BUILTIN = P0_13, ++ LED_POWER = P1_9, ++ ++ LED_RED = p24, ++ LED_GREEN = p16, ++ LED_BLUE = p6, ++ ++ LED1 = LED_BUILTIN, ++ LED2 = LED_RED, ++ LED3 = LED_GREEN, ++ LED4 = LED_BLUE, ++ ++ // mBed interface Pins ++ CONSOLE_TX = TX_PIN_NUMBER, ++ CONSOLE_RX = RX_PIN_NUMBER, ++#if defined(MBED_CONF_TARGET_STDIO_UART_TX) ++ STDIO_UART_TX = MBED_CONF_TARGET_STDIO_UART_TX, ++#else ++ STDIO_UART_TX = CONSOLE_TX, ++#endif ++#if defined(MBED_CONF_TARGET_STDIO_UART_RX) ++ STDIO_UART_RX = MBED_CONF_TARGET_STDIO_UART_RX, ++#else ++ STDIO_UART_RX = CONSOLE_RX, ++#endif ++ ++ SPI_PSELMOSI0 = P1_1, ++ SPI_PSELMISO0 = P1_8, ++ SPI_PSELSS0 = P1_2, ++ SPI_PSELSCK0 = P0_13, ++ ++ SPIS_PSELMOSI = P1_1, ++ SPIS_PSELMISO = P1_8, ++ SPIS_PSELSS = P1_2, ++ SPIS_PSELSCK = P0_13, ++ ++ I2C_SDA0 = p31, ++ I2C_SCL0 = p2, ++ ++#ifndef ARDUINO_ARCH_MBED ++ // Digital Pins ++ D2 = P1_11, ++ D3 = P1_12, ++ D4 = P1_15, ++ D5 = P1_13, ++ D6 = P1_14, ++ D7 = P0_23, ++ D8 = P0_21, ++ D9 = P0_27, ++ D10 = P1_2, ++ D11 = P1_1, ++ D12 = P1_8, ++ D13 = P0_13, ++ ++ // Analog Pins ++ A0 = p4, ++ A1 = p5, ++ A2 = p30, ++ A3 = p29, ++ A4 = p31, ++ A5 = p2, ++ A6 = p28, ++ A7 = p3, ++#endif ++ ++ AIN0 = p4, ++ AIN1 = p5, ++ AIN2 = p30, ++ AIN3 = p29, ++ AIN6 = p28, ++ AIN7 = p3, ++ ++ // Arduino Nano 33 BLE Sense Pins ++ VDD_ENV = p22, ++ INT_APDS = p19, ++ ++ I2C_SDA1 = p14, ++ I2C_SCL1 = p15, ++ ++ MIC_PWR = p17, ++ PDM_CLK = p26, ++ PDM_DIN = p25, ++ ++ // Not connected ++ NC = (int)0xFFFFFFFF, ++ ++ STDIO_UART_RTS = NC, ++ STDIO_UART_CTS = NC, ++ ++} PinName; ++ ++typedef enum { ++ PullNone = 0, ++ PullDown = 1, ++ PullUp = 3, ++ PullDefault = PullUp ++} PinMode; ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif +diff --git a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/TARGET_STELLA/device.h b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/TARGET_STELLA/device.h +new file mode 100644 +index 0000000000..a086e5b7f0 +--- /dev/null ++++ b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/TARGET_STELLA/device.h +@@ -0,0 +1,39 @@ ++// The 'features' section in 'target.json' is now used to create the device's hardware preprocessor switches. ++// Check the 'features' section of the target description in 'targets.json' for more details. ++/* mbed Microcontroller Library ++ * Copyright (c) 2006-2013 ARM Limited ++ * SPDX-License-Identifier: Apache-2.0 ++ * ++ * Licensed under the Apache License, Version 2.0 (the "License"); ++ * you may not use this file except in compliance with the License. ++ * You may obtain a copy of the License at ++ * ++ * http://www.apache.org/licenses/LICENSE-2.0 ++ * ++ * Unless required by applicable law or agreed to in writing, software ++ * distributed under the License is distributed on an "AS IS" BASIS, ++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++ * See the License for the specific language governing permissions and ++ * limitations under the License. ++ */ ++#ifndef MBED_DEVICE_H ++#define MBED_DEVICE_H ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++#include "objects.h" ++ ++#endif +diff --git a/targets/targets.json b/targets/targets.json +index 83fa8c930a..f69cbeef40 100644 +--- a/targets/targets.json ++++ b/targets/targets.json +@@ -7332,6 +7332,25 @@ + "CONFIG_GPIO_AS_PINRESET" + ] + }, ++ "STELLA": { ++ "inherits": [ ++ "MCU_NRF52840" ++ ], ++ "features_add": [ ++ "STORAGE" ++ ], ++ "components_remove": [ ++ "QSPIF" ++ ], ++ "device_has_add": ["WATCHDOG"], ++ "device_has_remove": [ ++ "QSPI", ++ "ITM" ++ ], ++ "macros_add": [ ++ "CONFIG_GPIO_AS_PINRESET" ++ ] ++ }, + "EDGE_CONTROL": { + "inherits": ["MCU_NRF52840"], + "features_add": ["STORAGE"], +-- +2.47.2 + diff --git a/platform.txt b/platform.txt index 0e7193624..3ace82eab 100644 --- a/platform.txt +++ b/platform.txt @@ -125,11 +125,11 @@ tools.openocd.cmd.windows=bin/openocd.exe tools.openocd.upload.params.verbose=-d2 tools.openocd.upload.params.quiet=-d0 -tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" {bootloader.programmer} {upload.transport} {bootloader.config} -c "telnet_port disabled; init; reset init; halt; adapter speed 10000; program {{build.path}/{build.project_name}.elf}; reset run; shutdown" +tools.openocd.upload.pattern="{path}/{cmd}" {upload.verbose} -s "{path}/share/openocd/scripts/" -f interface/{programmer.protocol}.cfg -f {programmer.transport_script} {bootloader.config} -c "telnet_port disabled; init; reset init; halt; adapter speed 10000; program {{build.path}/{build.project_name}.elf}; reset run; shutdown" tools.openocd.program.params.verbose=-d2 tools.openocd.program.params.quiet=-d0 -tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" {bootloader.programmer} {upload.transport} {bootloader.config} -c "telnet_port disabled; init; reset init; halt; adapter speed 10000; program {{build.path}/{build.project_name}.elf}; reset run; shutdown" +tools.openocd.program.pattern="{path}/{cmd}" {program.verbose} -s "{path}/share/openocd/scripts/" -f interface/{programmer.protocol}.cfg -f {programmer.transport_script} {bootloader.config} -c "telnet_port disabled; init; reset init; halt; adapter speed 10000; program {{build.path}/{build.project_name}.elf}; reset run; shutdown" tools.openocd.erase.params.verbose=-d2 tools.openocd.erase.params.quiet=-d0 @@ -137,7 +137,7 @@ tools.openocd.erase.pattern= tools.openocd.bootloader.params.verbose=-d2 tools.openocd.bootloader.params.quiet=-d0 -tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" {bootloader.programmer} {upload.transport} {bootloader.config} -c "telnet_port disabled; init; reset init; halt; adapter speed 10000; {bootloader.extra_action.preflash}; program {{runtime.platform.path}/bootloaders/{bootloader.file}}; reset run; shutdown" +tools.openocd.bootloader.pattern="{path}/{cmd}" {bootloader.verbose} -s "{path}/share/openocd/scripts/" -f interface/{programmer.protocol}.cfg -f {programmer.transport_script} {bootloader.config} -c "telnet_port disabled; init; reset init; halt; adapter speed 10000; {bootloader.extra_action.preflash}; program {{runtime.platform.path}/bootloaders/{bootloader.file}}; reset run; shutdown" # # BOSSA diff --git a/post_install.sh b/post_install.sh index d7ea9c313..66b668b1a 100755 --- a/post_install.sh +++ b/post_install.sh @@ -12,25 +12,31 @@ SUBSYSTEMS=="usb", ATTRS{idVendor}=="0525", MODE:="0666" EOF } -if [ "$EUID" -ne 0 ]; then - if [ -e "${PWD}/post_install.sh" ]; then - echo - echo "You might need to configure permissions for uploading." - echo "To do so, run the following command from the terminal:" - echo "sudo \"${PWD}/post_install.sh\"" - echo - else - # Script was executed from another path. It is assumed this will only occur when user is executing script directly. - # So it is not necessary to provide the command line. - echo "Please run as root" +OS="$(uname -s)" +case "$OS" in +Linux*) + if [ "$EUID" -ne 0 ]; then + if [ -e "${PWD}/post_install.sh" ]; then + echo + echo "You might need to configure permissions for uploading." + echo "To do so, run the following command from the terminal:" + echo "sudo \"${PWD}/post_install.sh\"" + echo + else + # Script was executed from another path. It is assumed this will only occur when user is executing script directly. + # So it is not necessary to provide the command line. + echo "Please run as root" + fi + + exit fi - exit -fi + arduino_mbed_rules > /etc/udev/rules.d/60-arduino-mbed.rules -arduino_mbed_rules > /etc/udev/rules.d/60-arduino-mbed.rules + # reload udev rules + echo "Reload rules..." + udevadm trigger + udevadm control --reload-rules -# reload udev rules -echo "Reload rules..." -udevadm trigger -udevadm control --reload-rules + ;; +esac diff --git a/stella.variables b/stella.variables new file mode 100644 index 000000000..50c10fea6 --- /dev/null +++ b/stella.variables @@ -0,0 +1,5 @@ +export FLAVOUR="stella" +export VARIANTS=("STELLA") +export FQBNS=("stella") +export LIBRARIES=("PDM SPI Wire MRI USBHID USBMIDI USBMSD ThreadDebug Scheduler SFU Nano33BLE_System SocketWrapper MLC") +export BOOTLOADERS=("nano33ble") diff --git a/variants/ARDUINO_NANO33BLE/defines.txt b/variants/ARDUINO_NANO33BLE/defines.txt index 1d4374713..cd703265d 100644 --- a/variants/ARDUINO_NANO33BLE/defines.txt +++ b/variants/ARDUINO_NANO33BLE/defines.txt @@ -34,7 +34,7 @@ -DFEATURE_STORAGE=1 -D__FPU_PRESENT=1 -D__MBED__=1 --DMBED_BUILD_TIMESTAMP=1719580467.0657709 +-DMBED_BUILD_TIMESTAMP=1751295810.7982233 -D__MBED_CMSIS_RTOS_CM -DMBED_MPU_CUSTOM -DMBED_TICKLESS diff --git a/variants/ARDUINO_NANO33BLE/libs/libmbed.a b/variants/ARDUINO_NANO33BLE/libs/libmbed.a index 4327290f8..709f5c1bd 100644 Binary files a/variants/ARDUINO_NANO33BLE/libs/libmbed.a and b/variants/ARDUINO_NANO33BLE/libs/libmbed.a differ diff --git a/variants/EDGE_CONTROL/conf/mbed_app.json b/variants/EDGE_CONTROL/conf/mbed_app.json index 572df7428..93d202c0d 100644 --- a/variants/EDGE_CONTROL/conf/mbed_app.json +++ b/variants/EDGE_CONTROL/conf/mbed_app.json @@ -19,7 +19,8 @@ "cellular.offload-dns-queries": true, "cellular.at-handler-buffer-size": 1024, "mbed-trace.enable": true, - "target.mbed_app_start": "0x10000" + "target.mbed_app_start": "0x10000", + "lwip.raw-socket-enabled": true }, "EDGE_CONTROL": { "sd.SPI_MOSI": "P0_20", diff --git a/variants/EDGE_CONTROL/defines.txt b/variants/EDGE_CONTROL/defines.txt index f9d7a0132..c8f7009b8 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=1719580640.5462966 +-DMBED_BUILD_TIMESTAMP=1751295976.2142034 -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 40c43b735..0b39e325b 100644 Binary files a/variants/EDGE_CONTROL/libs/libmbed.a and b/variants/EDGE_CONTROL/libs/libmbed.a differ diff --git a/variants/EDGE_CONTROL/mbed_config.h b/variants/EDGE_CONTROL/mbed_config.h index c61166166..31fa1228d 100644 --- a/variants/EDGE_CONTROL/mbed_config.h +++ b/variants/EDGE_CONTROL/mbed_config.h @@ -239,7 +239,7 @@ #define MBED_CONF_LWIP_PPP_IPV6_ENABLED 0 // set by library:lwip #define MBED_CONF_LWIP_PPP_THREAD_STACKSIZE 768 // set by library:lwip #define MBED_CONF_LWIP_PRESENT 1 // set by library:lwip -#define MBED_CONF_LWIP_RAW_SOCKET_ENABLED 0 // set by library:lwip +#define MBED_CONF_LWIP_RAW_SOCKET_ENABLED 1 // set by application[*] #define MBED_CONF_LWIP_SOCKET_MAX 4 // set by library:lwip #define MBED_CONF_LWIP_TCPIP_THREAD_PRIORITY osPriorityNormal // set by library:lwip #define MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE 1200 // set by library:lwip diff --git a/variants/GENERIC_STM32H747_M4/defines.txt b/variants/GENERIC_STM32H747_M4/defines.txt index cf07bc268..d5b9717bf 100644 --- a/variants/GENERIC_STM32H747_M4/defines.txt +++ b/variants/GENERIC_STM32H747_M4/defines.txt @@ -42,7 +42,7 @@ -DFEATURE_BLE=1 -D__FPU_PRESENT=1 -D__MBED__=1 --DMBED_BUILD_TIMESTAMP=1719580585.9789317 +-DMBED_BUILD_TIMESTAMP=1751295923.2991855 -D__MBED_CMSIS_RTOS_CM -DMBED_MPU_CUSTOM -DMBED_TICKLESS diff --git a/variants/GENERIC_STM32H747_M4/libs/libmbed.a b/variants/GENERIC_STM32H747_M4/libs/libmbed.a index 33ac8b026..3d42847c7 100644 Binary files a/variants/GENERIC_STM32H747_M4/libs/libmbed.a and b/variants/GENERIC_STM32H747_M4/libs/libmbed.a differ diff --git a/variants/GENERIC_STM32H747_M4/linker_script.ld b/variants/GENERIC_STM32H747_M4/linker_script.ld index f93b6e2e6..207a6f162 100644 --- a/variants/GENERIC_STM32H747_M4/linker_script.ld +++ b/variants/GENERIC_STM32H747_M4/linker_script.ld @@ -91,16 +91,11 @@ SECTIONS __bss_end__ = .; _ebss = .; } > RAM - .openamp_section (NOLOAD) : { - . = ABSOLUTE(0x38000000); - *(.resource_table) - } >RAM_D3 AT > FLASH - .pdm_section (NOLOAD) : { - . = ABSOLUTE(0x3800FC00); + .pdm_section 0x3800FC00 (NOLOAD): { *(.pdm_buffer) } > RAM_D3 - .heap (COPY): + .heap (NOLOAD): { __end__ = .; PROVIDE(end = .); @@ -108,7 +103,7 @@ SECTIONS . = ORIGIN(RAM) + LENGTH(RAM) - 0x400; __HeapLimit = .; } > RAM - .stack_dummy (COPY): + .stack_dummy (NOLOAD): { *(.stack*) } > RAM diff --git a/variants/GIGA/conf/mbed_app.json b/variants/GIGA/conf/mbed_app.json index 0fb7e9221..361a0ab94 100644 --- a/variants/GIGA/conf/mbed_app.json +++ b/variants/GIGA/conf/mbed_app.json @@ -11,6 +11,9 @@ "rtos.main-thread-stack-size": 32768, "cordio.max-connections": 5, "target.mbed_app_start": "0x8040000", + "nsapi.dns-response-wait-time": 5000, + "nsapi.dns-total-attempts": 3, + "lwip.raw-socket-enabled": true, "target.macros_add": [ "METAL_INTERNAL", "VIRTIO_DRIVER_ONLY", diff --git a/variants/GIGA/defines.txt b/variants/GIGA/defines.txt index c45884ea6..136fb76db 100644 --- a/variants/GIGA/defines.txt +++ b/variants/GIGA/defines.txt @@ -44,7 +44,7 @@ -DFEATURE_BLE=1 -D__FPU_PRESENT=1 -D__MBED__=1 --DMBED_BUILD_TIMESTAMP=1719930214.211079 +-DMBED_BUILD_TIMESTAMP=1751296168.0928738 -D__MBED_CMSIS_RTOS_CM -DMBED_TICKLESS -DMBEDTLS_FS_IO diff --git a/variants/GIGA/libs/libmbed.a b/variants/GIGA/libs/libmbed.a index ed0ef5bfa..79c8f413a 100644 Binary files a/variants/GIGA/libs/libmbed.a and b/variants/GIGA/libs/libmbed.a differ diff --git a/variants/GIGA/linker_script.ld b/variants/GIGA/linker_script.ld index 8941b72a6..a0fdb9fcd 100644 --- a/variants/GIGA/linker_script.ld +++ b/variants/GIGA/linker_script.ld @@ -94,12 +94,7 @@ SECTIONS __bss_end__ = .; _ebss = .; } > RAM - .openamp_section (NOLOAD) : { - . = ABSOLUTE(0x38000000); - *(.resource_table) - } >RAM_D3 AT > FLASH - .pdm_section (NOLOAD) : { - . = ABSOLUTE(0x3800FC00); + .pdm_section 0x3800FC00 (NOLOAD): { *(.pdm_buffer) } > RAM_D3 _dtcm_lma = __etext + SIZEOF(.data); diff --git a/variants/GIGA/mbed_config.h b/variants/GIGA/mbed_config.h index 460ac941c..3133aa110 100644 --- a/variants/GIGA/mbed_config.h +++ b/variants/GIGA/mbed_config.h @@ -226,7 +226,7 @@ #define MBED_CONF_LWIP_PPP_IPV6_ENABLED 0 // set by library:lwip #define MBED_CONF_LWIP_PPP_THREAD_STACKSIZE 768 // set by library:lwip #define MBED_CONF_LWIP_PRESENT 1 // set by library:lwip -#define MBED_CONF_LWIP_RAW_SOCKET_ENABLED 0 // set by library:lwip +#define MBED_CONF_LWIP_RAW_SOCKET_ENABLED 1 // set by application[*] #define MBED_CONF_LWIP_SOCKET_MAX 4 // set by library:lwip #define MBED_CONF_LWIP_TCPIP_THREAD_PRIORITY osPriorityNormal // set by library:lwip #define MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE 1200 // set by library:lwip @@ -250,9 +250,9 @@ #define MBED_CONF_NSAPI_DEFAULT_WIFI_SECURITY NONE // set by library:nsapi #define MBED_CONF_NSAPI_DNS_ADDRESSES_LIMIT 10 // set by library:nsapi #define MBED_CONF_NSAPI_DNS_CACHE_SIZE 3 // set by library:nsapi -#define MBED_CONF_NSAPI_DNS_RESPONSE_WAIT_TIME 10000 // set by library:nsapi +#define MBED_CONF_NSAPI_DNS_RESPONSE_WAIT_TIME 5000 // set by application[*] #define MBED_CONF_NSAPI_DNS_RETRIES 1 // set by library:nsapi -#define MBED_CONF_NSAPI_DNS_TOTAL_ATTEMPTS 10 // set by library:nsapi +#define MBED_CONF_NSAPI_DNS_TOTAL_ATTEMPTS 3 // set by application[*] #define MBED_CONF_NSAPI_PRESENT 1 // set by library:nsapi #define MBED_CONF_NSAPI_SOCKET_STATS_ENABLED 0 // set by library:nsapi #define MBED_CONF_NSAPI_SOCKET_STATS_MAX_COUNT 10 // set by library:nsapi diff --git a/variants/NANO_RP2040_CONNECT/conf/mbed_app.json b/variants/NANO_RP2040_CONNECT/conf/mbed_app.json index 839285b81..8cd4676b8 100644 --- a/variants/NANO_RP2040_CONNECT/conf/mbed_app.json +++ b/variants/NANO_RP2040_CONNECT/conf/mbed_app.json @@ -2,7 +2,7 @@ "target_overrides": { "*": { "target.printf_lib": "std", - "target.macros_add": [ "MBEDTLS_ENTROPY_NV_SEED" ], + "target.macros_add": [ "MBEDTLS_ENTROPY_NV_SEED", "UNINITIALIZED_DATA_SECTION=1" ], "platform.stdio-buffered-serial": false, "platform.stdio-baud-rate": 115200, "platform.default-serial-baud-rate": 115200, diff --git a/variants/NANO_RP2040_CONNECT/defines.txt b/variants/NANO_RP2040_CONNECT/defines.txt index 31cca3e7d..a6602e69a 100644 --- a/variants/NANO_RP2040_CONNECT/defines.txt +++ b/variants/NANO_RP2040_CONNECT/defines.txt @@ -21,7 +21,7 @@ -DDEVICE_USTICKER=1 -DDEVICE_WATCHDOG=1 -D__MBED__=1 --DMBED_BUILD_TIMESTAMP=1719580442.2641459 +-DMBED_BUILD_TIMESTAMP=1751295788.6373296 -D__MBED_CMSIS_RTOS_CM -DMBED_MPU_CUSTOM -DMBEDTLS_ENTROPY_NV_SEED @@ -44,6 +44,7 @@ -DTARGET_RP2040 -DTOOLCHAIN_GCC -DTOOLCHAIN_GCC_ARM +-DUNINITIALIZED_DATA_SECTION=1 -DMBED_NO_GLOBAL_USING_DIRECTIVE=1 -DCORE_MAJOR= -DCORE_MINOR= diff --git a/variants/NANO_RP2040_CONNECT/libs/libmbed.a b/variants/NANO_RP2040_CONNECT/libs/libmbed.a index 5c7a8064d..0ededd88e 100644 Binary files a/variants/NANO_RP2040_CONNECT/libs/libmbed.a and b/variants/NANO_RP2040_CONNECT/libs/libmbed.a differ diff --git a/variants/NANO_RP2040_CONNECT/linker_script.ld b/variants/NANO_RP2040_CONNECT/linker_script.ld index 02fc23730..a96cf5167 100644 --- a/variants/NANO_RP2040_CONNECT/linker_script.ld +++ b/variants/NANO_RP2040_CONNECT/linker_script.ld @@ -8,12 +8,12 @@ MEMORY ENTRY(_entry_point) SECTIONS { - .second_stage_ota : { - KEEP (*(.second_stage_ota)) - } > FLASH .flash_begin : { __flash_binary_start = .; } > FLASH + .second_stage_ota : { + KEEP (*(.second_stage_ota)) + } > FLASH .boot2 : { __boot2_start__ = .; KEEP (*(.boot2)) @@ -104,7 +104,9 @@ SECTIONS } > RAM AT> FLASH .uninitialized_data (COPY): { . = ALIGN(4); + __uninitialized_data_start__ = .; *(.uninitialized_data*) + __uninitialized_data_end__ = .; } > RAM .scratch_x : { __scratch_x_start__ = .; diff --git a/variants/NICLA/defines.txt b/variants/NICLA/defines.txt index 011c86fc7..070856ff6 100644 --- a/variants/NICLA/defines.txt +++ b/variants/NICLA/defines.txt @@ -33,7 +33,7 @@ -DFEATURE_BLE=1 -D__FPU_PRESENT=1 -D__MBED__=1 --DMBED_BUILD_TIMESTAMP=1719580684.6774077 +-DMBED_BUILD_TIMESTAMP=1751296019.4294596 -D__MBED_CMSIS_RTOS_CM -DMBED_MPU_CUSTOM -DMBED_TICKLESS diff --git a/variants/NICLA/libs/libmbed.a b/variants/NICLA/libs/libmbed.a index 74e8feae6..0f5cfdad2 100644 Binary files a/variants/NICLA/libs/libmbed.a and b/variants/NICLA/libs/libmbed.a differ diff --git a/variants/NICLA_VISION/conf/mbed_app.json b/variants/NICLA_VISION/conf/mbed_app.json index 6d743d296..f3227a71f 100644 --- a/variants/NICLA_VISION/conf/mbed_app.json +++ b/variants/NICLA_VISION/conf/mbed_app.json @@ -12,6 +12,9 @@ "rtos.main-thread-stack-size": 32768, "cordio.max-connections": 5, "target.mbed_app_start": "0x8040000", + "nsapi.dns-response-wait-time": 5000, + "nsapi.dns-total-attempts": 3, + "lwip.raw-socket-enabled": true, "target.macros_add": [ "METAL_INTERNAL", "VIRTIO_DRIVER_ONLY", diff --git a/variants/NICLA_VISION/defines.txt b/variants/NICLA_VISION/defines.txt index 031e34fbb..79ccdbfd8 100644 --- a/variants/NICLA_VISION/defines.txt +++ b/variants/NICLA_VISION/defines.txt @@ -45,7 +45,7 @@ -DFLOW_SILENT -D__FPU_PRESENT=1 -D__MBED__=1 --DMBED_BUILD_TIMESTAMP=1719580720.2247646 +-DMBED_BUILD_TIMESTAMP=1751296054.2534025 -D__MBED_CMSIS_RTOS_CM -DMBED_TICKLESS -DMBEDTLS_FS_IO diff --git a/variants/NICLA_VISION/libs/libmbed.a b/variants/NICLA_VISION/libs/libmbed.a index 8c7e3f253..78b2cae39 100644 Binary files a/variants/NICLA_VISION/libs/libmbed.a and b/variants/NICLA_VISION/libs/libmbed.a differ diff --git a/variants/NICLA_VISION/linker_script.ld b/variants/NICLA_VISION/linker_script.ld index 0b00d41d9..c681810c5 100644 --- a/variants/NICLA_VISION/linker_script.ld +++ b/variants/NICLA_VISION/linker_script.ld @@ -94,12 +94,7 @@ SECTIONS __bss_end__ = .; _ebss = .; } > RAM - .openamp_section (NOLOAD) : { - . = ABSOLUTE(0x38000000); - *(.resource_table) - } >RAM_D3 AT > FLASH - .pdm_section (NOLOAD) : { - . = ABSOLUTE(0x3800FC00); + .pdm_section 0x3800FC00 (NOLOAD): { *(.pdm_buffer) } > RAM_D3 diff --git a/variants/NICLA_VISION/mbed_config.h b/variants/NICLA_VISION/mbed_config.h index ed8376f00..d4ec859a3 100644 --- a/variants/NICLA_VISION/mbed_config.h +++ b/variants/NICLA_VISION/mbed_config.h @@ -226,7 +226,7 @@ #define MBED_CONF_LWIP_PPP_IPV6_ENABLED 0 // set by library:lwip #define MBED_CONF_LWIP_PPP_THREAD_STACKSIZE 768 // set by library:lwip #define MBED_CONF_LWIP_PRESENT 1 // set by library:lwip -#define MBED_CONF_LWIP_RAW_SOCKET_ENABLED 0 // set by library:lwip +#define MBED_CONF_LWIP_RAW_SOCKET_ENABLED 1 // set by application[*] #define MBED_CONF_LWIP_SOCKET_MAX 4 // set by library:lwip #define MBED_CONF_LWIP_TCPIP_THREAD_PRIORITY osPriorityNormal // set by library:lwip #define MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE 1200 // set by library:lwip @@ -250,9 +250,9 @@ #define MBED_CONF_NSAPI_DEFAULT_WIFI_SECURITY NONE // set by library:nsapi #define MBED_CONF_NSAPI_DNS_ADDRESSES_LIMIT 10 // set by library:nsapi #define MBED_CONF_NSAPI_DNS_CACHE_SIZE 3 // set by library:nsapi -#define MBED_CONF_NSAPI_DNS_RESPONSE_WAIT_TIME 10000 // set by library:nsapi +#define MBED_CONF_NSAPI_DNS_RESPONSE_WAIT_TIME 5000 // set by application[*] #define MBED_CONF_NSAPI_DNS_RETRIES 1 // set by library:nsapi -#define MBED_CONF_NSAPI_DNS_TOTAL_ATTEMPTS 10 // set by library:nsapi +#define MBED_CONF_NSAPI_DNS_TOTAL_ATTEMPTS 3 // set by application[*] #define MBED_CONF_NSAPI_PRESENT 1 // set by library:nsapi #define MBED_CONF_NSAPI_SOCKET_STATS_ENABLED 0 // set by library:nsapi #define MBED_CONF_NSAPI_SOCKET_STATS_MAX_COUNT 10 // set by library:nsapi diff --git a/variants/OPTA/conf/mbed_app.json b/variants/OPTA/conf/mbed_app.json index 0fb7e9221..361a0ab94 100644 --- a/variants/OPTA/conf/mbed_app.json +++ b/variants/OPTA/conf/mbed_app.json @@ -11,6 +11,9 @@ "rtos.main-thread-stack-size": 32768, "cordio.max-connections": 5, "target.mbed_app_start": "0x8040000", + "nsapi.dns-response-wait-time": 5000, + "nsapi.dns-total-attempts": 3, + "lwip.raw-socket-enabled": true, "target.macros_add": [ "METAL_INTERNAL", "VIRTIO_DRIVER_ONLY", diff --git a/variants/OPTA/defines.txt b/variants/OPTA/defines.txt index d2bdfafe1..e2efa0d9a 100644 --- a/variants/OPTA/defines.txt +++ b/variants/OPTA/defines.txt @@ -44,7 +44,7 @@ -DFEATURE_BLE=1 -D__FPU_PRESENT=1 -D__MBED__=1 --DMBED_BUILD_TIMESTAMP=1719929630.0019104 +-DMBED_BUILD_TIMESTAMP=1751296112.1474662 -D__MBED_CMSIS_RTOS_CM -DMBED_TICKLESS -DMBEDTLS_FS_IO diff --git a/variants/OPTA/libs/libmbed.a b/variants/OPTA/libs/libmbed.a index c65f0bde3..bf4629098 100644 Binary files a/variants/OPTA/libs/libmbed.a and b/variants/OPTA/libs/libmbed.a differ diff --git a/variants/OPTA/linker_script.ld b/variants/OPTA/linker_script.ld index 8941b72a6..a0fdb9fcd 100644 --- a/variants/OPTA/linker_script.ld +++ b/variants/OPTA/linker_script.ld @@ -94,12 +94,7 @@ SECTIONS __bss_end__ = .; _ebss = .; } > RAM - .openamp_section (NOLOAD) : { - . = ABSOLUTE(0x38000000); - *(.resource_table) - } >RAM_D3 AT > FLASH - .pdm_section (NOLOAD) : { - . = ABSOLUTE(0x3800FC00); + .pdm_section 0x3800FC00 (NOLOAD): { *(.pdm_buffer) } > RAM_D3 _dtcm_lma = __etext + SIZEOF(.data); diff --git a/variants/OPTA/mbed_config.h b/variants/OPTA/mbed_config.h index c0485cbf8..4b6d57eaa 100644 --- a/variants/OPTA/mbed_config.h +++ b/variants/OPTA/mbed_config.h @@ -226,7 +226,7 @@ #define MBED_CONF_LWIP_PPP_IPV6_ENABLED 0 // set by library:lwip #define MBED_CONF_LWIP_PPP_THREAD_STACKSIZE 768 // set by library:lwip #define MBED_CONF_LWIP_PRESENT 1 // set by library:lwip -#define MBED_CONF_LWIP_RAW_SOCKET_ENABLED 0 // set by library:lwip +#define MBED_CONF_LWIP_RAW_SOCKET_ENABLED 1 // set by application[*] #define MBED_CONF_LWIP_SOCKET_MAX 4 // set by library:lwip #define MBED_CONF_LWIP_TCPIP_THREAD_PRIORITY osPriorityNormal // set by library:lwip #define MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE 1200 // set by library:lwip @@ -250,9 +250,9 @@ #define MBED_CONF_NSAPI_DEFAULT_WIFI_SECURITY NONE // set by library:nsapi #define MBED_CONF_NSAPI_DNS_ADDRESSES_LIMIT 10 // set by library:nsapi #define MBED_CONF_NSAPI_DNS_CACHE_SIZE 3 // set by library:nsapi -#define MBED_CONF_NSAPI_DNS_RESPONSE_WAIT_TIME 10000 // set by library:nsapi +#define MBED_CONF_NSAPI_DNS_RESPONSE_WAIT_TIME 5000 // set by application[*] #define MBED_CONF_NSAPI_DNS_RETRIES 1 // set by library:nsapi -#define MBED_CONF_NSAPI_DNS_TOTAL_ATTEMPTS 10 // set by library:nsapi +#define MBED_CONF_NSAPI_DNS_TOTAL_ATTEMPTS 3 // set by application[*] #define MBED_CONF_NSAPI_PRESENT 1 // set by library:nsapi #define MBED_CONF_NSAPI_SOCKET_STATS_ENABLED 0 // set by library:nsapi #define MBED_CONF_NSAPI_SOCKET_STATS_MAX_COUNT 10 // set by library:nsapi diff --git a/variants/OPTA/pins_arduino.h b/variants/OPTA/pins_arduino.h index 25d6e8c06..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) @@ -148,6 +158,7 @@ static const uint8_t SCK = PIN_SPI_SCK; // Use these only if bootloader data is not available / valid #define _BOARD_VENDORID 0x2341 #define _BOARD_PRODUCTID 0x0264 + uint16_t _getVid_(); uint16_t _getPid_(); diff --git a/variants/OPTA/variant.cpp b/variants/OPTA/variant.cpp index 342a7a3c8..93b796e88 100644 --- a/variants/OPTA/variant.cpp +++ b/variants/OPTA/variant.cpp @@ -296,6 +296,15 @@ bool getSecureFlashData() { return ret == QSPI_STATUS_OK; } +class SecureQSPIReader { +public: + SecureQSPIReader() { + getSecureFlashData(); + } +}; + +SecureQSPIReader __reader __attribute__ ((init_priority (101))); + uint8_t* boardInfo() { return _boardInfo; } @@ -304,26 +313,19 @@ uint16_t boardRevision() { return (((OptaBoardInfo*)_boardInfo)->revision); } +#ifndef FIRST_PROGRAMMING uint16_t _getVid_() { -#ifdef FIRST_PROGRAMMING - return _BOARD_VENDORID; -#else if (!has_otp_info) { getSecureFlashData(); } return ((OptaBoardInfo*)_boardInfo)->vid; -#endif } uint16_t _getPid_() { -#ifdef FIRST_PROGRAMMING - return _BOARD_PRODUCTID; -#else if (!has_otp_info) { getSecureFlashData(); } return ((OptaBoardInfo*)_boardInfo)->pid; -#endif } uint8_t _getSecureEthMac_(uint8_t *mac_address) { @@ -340,6 +342,7 @@ uint8_t mbed_otp_mac_address(char *mac) auto ret = _getSecureEthMac_(reinterpret_cast(mac)); return ret; } +#endif #define BOARD_REVISION(x,y) (x << 8 | y) diff --git a/variants/PORTENTA_H7_M7/conf/mbed_app.json b/variants/PORTENTA_H7_M7/conf/mbed_app.json index 2ab0fddc5..fbf702dd2 100644 --- a/variants/PORTENTA_H7_M7/conf/mbed_app.json +++ b/variants/PORTENTA_H7_M7/conf/mbed_app.json @@ -15,6 +15,9 @@ "cellular.at-handler-buffer-size": 512, "mbed-trace.enable": true, "target.mbed_app_start": "0x8040000", + "nsapi.dns-response-wait-time": 5000, + "nsapi.dns-total-attempts": 3, + "lwip.raw-socket-enabled": true, "target.macros_add": [ "BT_UART_NO_3M_SUPPORT", "USB_DYNAMIC_CONFIGURATION", diff --git a/variants/PORTENTA_H7_M7/defines.txt b/variants/PORTENTA_H7_M7/defines.txt index 88cd37d58..6296cba65 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=1719580529.7864532 +-DMBED_BUILD_TIMESTAMP=1751295869.6783228 -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 0c6498244..29612e1b2 100644 Binary files a/variants/PORTENTA_H7_M7/libs/libmbed.a and b/variants/PORTENTA_H7_M7/libs/libmbed.a differ diff --git a/variants/PORTENTA_H7_M7/linker_script.ld b/variants/PORTENTA_H7_M7/linker_script.ld index 8941b72a6..a0fdb9fcd 100644 --- a/variants/PORTENTA_H7_M7/linker_script.ld +++ b/variants/PORTENTA_H7_M7/linker_script.ld @@ -94,12 +94,7 @@ SECTIONS __bss_end__ = .; _ebss = .; } > RAM - .openamp_section (NOLOAD) : { - . = ABSOLUTE(0x38000000); - *(.resource_table) - } >RAM_D3 AT > FLASH - .pdm_section (NOLOAD) : { - . = ABSOLUTE(0x3800FC00); + .pdm_section 0x3800FC00 (NOLOAD): { *(.pdm_buffer) } > RAM_D3 _dtcm_lma = __etext + SIZEOF(.data); diff --git a/variants/PORTENTA_H7_M7/mbed_config.h b/variants/PORTENTA_H7_M7/mbed_config.h index a6f5ffd53..0bdce3566 100644 --- a/variants/PORTENTA_H7_M7/mbed_config.h +++ b/variants/PORTENTA_H7_M7/mbed_config.h @@ -227,7 +227,7 @@ #define MBED_CONF_LWIP_PPP_IPV6_ENABLED 0 // set by library:lwip #define MBED_CONF_LWIP_PPP_THREAD_STACKSIZE 768 // set by library:lwip #define MBED_CONF_LWIP_PRESENT 1 // set by library:lwip -#define MBED_CONF_LWIP_RAW_SOCKET_ENABLED 0 // set by library:lwip +#define MBED_CONF_LWIP_RAW_SOCKET_ENABLED 1 // set by application[*] #define MBED_CONF_LWIP_SOCKET_MAX 4 // set by library:lwip #define MBED_CONF_LWIP_TCPIP_THREAD_PRIORITY osPriorityNormal // set by library:lwip #define MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE 1200 // set by library:lwip @@ -252,9 +252,9 @@ #define MBED_CONF_NSAPI_DEFAULT_WIFI_SECURITY NONE // set by library:nsapi #define MBED_CONF_NSAPI_DNS_ADDRESSES_LIMIT 10 // set by library:nsapi #define MBED_CONF_NSAPI_DNS_CACHE_SIZE 3 // set by library:nsapi -#define MBED_CONF_NSAPI_DNS_RESPONSE_WAIT_TIME 10000 // set by library:nsapi +#define MBED_CONF_NSAPI_DNS_RESPONSE_WAIT_TIME 5000 // set by application[*] #define MBED_CONF_NSAPI_DNS_RETRIES 1 // set by library:nsapi -#define MBED_CONF_NSAPI_DNS_TOTAL_ATTEMPTS 10 // set by library:nsapi +#define MBED_CONF_NSAPI_DNS_TOTAL_ATTEMPTS 3 // set by application[*] #define MBED_CONF_NSAPI_PRESENT 1 // set by library:nsapi #define MBED_CONF_NSAPI_SOCKET_STATS_ENABLED 0 // set by library:nsapi #define MBED_CONF_NSAPI_SOCKET_STATS_MAX_COUNT 10 // set by library:nsapi diff --git a/variants/PORTENTA_X8/defines.txt b/variants/PORTENTA_X8/defines.txt index 438b2dd31..c8bf9be16 100644 --- a/variants/PORTENTA_X8/defines.txt +++ b/variants/PORTENTA_X8/defines.txt @@ -34,7 +34,7 @@ -DEXTRA_IDLE_STACK_REQUIRED -D__FPU_PRESENT=1 -D__MBED__=1 --DMBED_BUILD_TIMESTAMP=1719580895.1557932 +-DMBED_BUILD_TIMESTAMP=1751296223.5654757 -D__MBED_CMSIS_RTOS_CM -DMBED_MPU_CUSTOM -DMBED_TICKLESS diff --git a/variants/PORTENTA_X8/libs/libmbed.a b/variants/PORTENTA_X8/libs/libmbed.a index 447f1fc0d..6dc74d033 100644 Binary files a/variants/PORTENTA_X8/libs/libmbed.a and b/variants/PORTENTA_X8/libs/libmbed.a differ diff --git a/variants/PORTENTA_X8/linker_script.ld b/variants/PORTENTA_X8/linker_script.ld index f7e5c0fb5..e38e2df60 100644 --- a/variants/PORTENTA_X8/linker_script.ld +++ b/variants/PORTENTA_X8/linker_script.ld @@ -86,12 +86,7 @@ SECTIONS __bss_end__ = .; _ebss = .; } > RAM - .openamp_section (NOLOAD) : { - . = ABSOLUTE(0x38000000); - *(.resource_table) - } >RAM_D3 AT > FLASH - .pdm_section (NOLOAD) : { - . = ABSOLUTE(0x3800FC00); + .pdm_section 0x3800FC00 (NOLOAD): { *(.pdm_buffer) } > RAM_D3 diff --git a/variants/RASPBERRY_PI_PICO/defines.txt b/variants/RASPBERRY_PI_PICO/defines.txt index 49d1bf817..43f6f22d4 100644 --- a/variants/RASPBERRY_PI_PICO/defines.txt +++ b/variants/RASPBERRY_PI_PICO/defines.txt @@ -21,7 +21,7 @@ -DDEVICE_USTICKER=1 -DDEVICE_WATCHDOG=1 -D__MBED__=1 --DMBED_BUILD_TIMESTAMP=1719580504.0819786 +-DMBED_BUILD_TIMESTAMP=1751295845.4641042 -D__MBED_CMSIS_RTOS_CM -DMBED_MPU_CUSTOM -DMBEDTLS_ENTROPY_NV_SEED diff --git a/variants/RASPBERRY_PI_PICO/libs/libmbed.a b/variants/RASPBERRY_PI_PICO/libs/libmbed.a index 74546c2af..2e2d98df1 100644 Binary files a/variants/RASPBERRY_PI_PICO/libs/libmbed.a and b/variants/RASPBERRY_PI_PICO/libs/libmbed.a differ diff --git a/variants/RASPBERRY_PI_PICO/linker_script.ld b/variants/RASPBERRY_PI_PICO/linker_script.ld index 6aad4a2ab..38608120e 100644 --- a/variants/RASPBERRY_PI_PICO/linker_script.ld +++ b/variants/RASPBERRY_PI_PICO/linker_script.ld @@ -11,6 +11,9 @@ SECTIONS .flash_begin : { __flash_binary_start = .; } > FLASH + .second_stage_ota : { + KEEP (*(.second_stage_ota)) + } > FLASH .boot2 : { __boot2_start__ = .; KEEP (*(.boot2)) @@ -101,7 +104,9 @@ SECTIONS } > RAM AT> FLASH .uninitialized_data (COPY): { . = ALIGN(4); + __uninitialized_data_start__ = .; *(.uninitialized_data*) + __uninitialized_data_end__ = .; } > RAM .scratch_x : { __scratch_x_start__ = .; diff --git a/variants/STELLA/cflags.txt b/variants/STELLA/cflags.txt new file mode 100644 index 000000000..557950364 --- /dev/null +++ b/variants/STELLA/cflags.txt @@ -0,0 +1,24 @@ +-c +-std=gnu11 +-DAPPLICATION_ADDR=0x10000 +-DAPPLICATION_SIZE=0xf0000 +-DMBED_RAM_SIZE=0x40000 +-DMBED_RAM_START=0x20000000 +-DMBED_ROM_SIZE=0x100000 +-DMBED_ROM_START=0x0 +-DMBED_TRAP_ERRORS_ENABLED=1 +-Os +-Wall +-Wextra +-Wno-missing-field-initializers +-Wno-unused-parameter +-fdata-sections +-ffunction-sections +-fmessage-length=0 +-fno-exceptions +-fomit-frame-pointer +-funsigned-char +-mcpu=cortex-m4 +-mfloat-abi=softfp +-mfpu=fpv4-sp-d16 +-mthumb diff --git a/variants/STELLA/conf/.mbedignore b/variants/STELLA/conf/.mbedignore new file mode 100644 index 000000000..3562a46dc --- /dev/null +++ b/variants/STELLA/conf/.mbedignore @@ -0,0 +1,2 @@ +mbed-os/connectivity/drivers/cellular/* +mbed-os/connectivity/nanostack/* \ No newline at end of file diff --git a/variants/STELLA/conf/mbed_app.json b/variants/STELLA/conf/mbed_app.json new file mode 100644 index 000000000..279ca8808 --- /dev/null +++ b/variants/STELLA/conf/mbed_app.json @@ -0,0 +1,19 @@ +{ + "macros": [ + "NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS=8", + "NRFX_WDT_ENABLED=1" + ], + "target_overrides": { + "*": { + "target.printf_lib": "std", + "platform.stdio-buffered-serial": false, + "platform.stdio-baud-rate": 115200, + "platform.default-serial-baud-rate": 115200, + "platform.callback-nontrivial": true, + "rtos.main-thread-stack-size": 32768, + "cordio.max-connections": 5, + "platform.all-stats-enabled": true, + "target.mbed_app_start": "0x10000" + } + } +} diff --git a/variants/STELLA/cxxflags.txt b/variants/STELLA/cxxflags.txt new file mode 100644 index 000000000..ca7f1f869 --- /dev/null +++ b/variants/STELLA/cxxflags.txt @@ -0,0 +1,26 @@ +-Wvla +-c +-fno-rtti +-std=gnu++14 +-DAPPLICATION_ADDR=0x10000 +-DAPPLICATION_SIZE=0xf0000 +-DMBED_RAM_SIZE=0x40000 +-DMBED_RAM_START=0x20000000 +-DMBED_ROM_SIZE=0x100000 +-DMBED_ROM_START=0x0 +-DMBED_TRAP_ERRORS_ENABLED=1 +-Os +-Wall +-Wextra +-Wno-missing-field-initializers +-Wno-unused-parameter +-fdata-sections +-ffunction-sections +-fmessage-length=0 +-fno-exceptions +-fomit-frame-pointer +-funsigned-char +-mcpu=cortex-m4 +-mfloat-abi=softfp +-mfpu=fpv4-sp-d16 +-mthumb diff --git a/variants/STELLA/defines.txt b/variants/STELLA/defines.txt new file mode 100644 index 000000000..8199cf727 --- /dev/null +++ b/variants/STELLA/defines.txt @@ -0,0 +1,71 @@ + +-DARM_MATH_CM4 +-DBOARD_PCA10056 +-D__CMSIS_RTOS +-DCMSIS_VECTAB_VIRTUAL +-DCMSIS_VECTAB_VIRTUAL_HEADER_FILE=\"cmsis_nvic.h\" +-DCOMPONENT_FLASHIAP=1 +-DCONFIG_GPIO_AS_PINRESET +-D__CORTEX_M4 +-DDEVICE_ANALOGIN=1 +-DDEVICE_FLASH=1 +-DDEVICE_I2C=1 +-DDEVICE_I2C_ASYNCH=1 +-DDEVICE_I2CSLAVE=1 +-DDEVICE_INTERRUPTIN=1 +-DDEVICE_LPTICKER=1 +-DDEVICE_PORTIN=1 +-DDEVICE_PORTINOUT=1 +-DDEVICE_PORTOUT=1 +-DDEVICE_PWMOUT=1 +-DDEVICE_SERIAL=1 +-DDEVICE_SERIAL_ASYNCH=1 +-DDEVICE_SERIAL_FC=1 +-DDEVICE_SLEEP=1 +-DDEVICE_SPI=1 +-DDEVICE_SPI_ASYNCH=1 +-DDEVICE_SYSTICK_CLK_OFF_DURING_SLEEP=1 +-DDEVICE_TRNG=1 +-DDEVICE_USBDEVICE=1 +-DDEVICE_USTICKER=1 +-DDEVICE_WATCHDOG=1 +-DFEATURE_BLE=1 +-DFEATURE_CRYPTOCELL310=1 +-DFEATURE_STORAGE=1 +-D__FPU_PRESENT=1 +-D__MBED__=1 +-DMBED_BUILD_TIMESTAMP=1751296267.721782 +-D__MBED_CMSIS_RTOS_CM +-DMBED_MPU_CUSTOM +-DMBED_TICKLESS +-DMBEDTLS_CONFIG_HW_SUPPORT +-DNRF52840_XXAA +-DNRF52_PAN_20 +-DSWI_DISABLE0 +-DTARGET_CORDIO +-DTARGET_CORDIO_LL +-DTARGET_CORTEX +-DTARGET_CORTEX_M +-DTARGET_LIKE_CORTEX_M4 +-DTARGET_LIKE_MBED +-DTARGET_M4 +-DTARGET_MCU_NRF52840 +-DTARGET_NAME=STELLA +-DTARGET_NORDIC +-DTARGET_NORDIC_CORDIO +-DTARGET_NRF52 +-DTARGET_NRF52840 +-DTARGET_NRF5x +-DTARGET_RELEASE +-DTARGET_RTOS_M4_M7 +-DTARGET_SDK_15_0 +-DTARGET_SOFTDEVICE_NONE +-DTARGET_STELLA +-DTOOLCHAIN_GCC +-DTOOLCHAIN_GCC_ARM +-DWSF_MAX_HANDLERS=10 +-DMBED_NO_GLOBAL_USING_DIRECTIVE=1 +-DCORE_MAJOR= +-DCORE_MINOR= +-DCORE_PATCH= +-DUSE_ARDUINO_PINOUT diff --git a/variants/STELLA/includes.txt b/variants/STELLA/includes.txt new file mode 100644 index 000000000..f04ec2f39 --- /dev/null +++ b/variants/STELLA/includes.txt @@ -0,0 +1,293 @@ +-iwithprefixbefore/mbed +-iwithprefixbefore/mbed/cmsis +-iwithprefixbefore/mbed/cmsis/CMSIS_5 +-iwithprefixbefore/mbed/cmsis/CMSIS_5/CMSIS +-iwithprefixbefore/mbed/cmsis/CMSIS_5/CMSIS/RTOS2 +-iwithprefixbefore/mbed/cmsis/CMSIS_5/CMSIS/RTOS2/Include +-iwithprefixbefore/mbed/cmsis/CMSIS_5/CMSIS/RTOS2/RTX +-iwithprefixbefore/mbed/cmsis/CMSIS_5/CMSIS/RTOS2/RTX/Config +-iwithprefixbefore/mbed/cmsis/CMSIS_5/CMSIS/RTOS2/RTX/Include +-iwithprefixbefore/mbed/cmsis/CMSIS_5/CMSIS/RTOS2/RTX/Include1 +-iwithprefixbefore/mbed/cmsis/CMSIS_5/CMSIS/RTOS2/RTX/Source +-iwithprefixbefore/mbed/cmsis/CMSIS_5/CMSIS/TARGET_CORTEX_M +-iwithprefixbefore/mbed/cmsis/CMSIS_5/CMSIS/TARGET_CORTEX_M/Include +-iwithprefixbefore/mbed/cmsis/device +-iwithprefixbefore/mbed/cmsis/device/RTE +-iwithprefixbefore/mbed/cmsis/device/RTE/include +-iwithprefixbefore/mbed/cmsis/device/rtos +-iwithprefixbefore/mbed/cmsis/device/rtos/include +-iwithprefixbefore/mbed/connectivity +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/include +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/include/ble +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/include/ble/common +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/include/ble/compatibility +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/include/ble/compatibility/ble +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/include/ble/driver +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/include/ble/gap +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/include/ble/gatt +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/include/ble/services +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO_LL +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO_LL/stack +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO_LL/stack/controller +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO_LL/stack/controller/include +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO_LL/stack/controller/include/ble +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO_LL/stack/controller/include/common +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO_LL/stack/controller/sources +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO_LL/stack/controller/sources/ble +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO_LL/stack/controller/sources/ble/bb +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO_LL/stack/controller/sources/ble/include +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO_LL/stack/controller/sources/ble/lctr +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO_LL/stack/controller/sources/ble/lhci +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO_LL/stack/controller/sources/ble/sch +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO_LL/stack/controller/sources/common +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO_LL/stack/controller/sources/common/bb +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO_LL/stack/controller/sources/common/sch +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO_LL/stack/thirdparty +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO_LL/stack/thirdparty/uecc +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries/TARGET_CORDIO_LL/stack_adaptation +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries/cordio_stack +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/include +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/hci +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/hci/dual_chip +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/sec +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/sec/common +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/att +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/cfg +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/hci +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/l2c +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/smp +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries/cordio_stack/platform +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries/cordio_stack/platform/include +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/libraries/cordio_stack/wsf/include/util +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/source +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/source/common +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/source/cordio +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/source/cordio/source +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/source/cordio/stack_adaptation +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/source/generic +-iwithprefixbefore/mbed/connectivity/FEATURE_BLE/source/pal +-iwithprefixbefore/mbed/connectivity/cellular +-iwithprefixbefore/mbed/connectivity/cellular/include +-iwithprefixbefore/mbed/connectivity/cellular/include/cellular +-iwithprefixbefore/mbed/connectivity/cellular/include/cellular/framework +-iwithprefixbefore/mbed/connectivity/cellular/include/cellular/framework/API +-iwithprefixbefore/mbed/connectivity/cellular/include/cellular/framework/AT +-iwithprefixbefore/mbed/connectivity/cellular/include/cellular/framework/common +-iwithprefixbefore/mbed/connectivity/cellular/include/cellular/framework/device +-iwithprefixbefore/mbed/connectivity/drivers +-iwithprefixbefore/mbed/connectivity/drivers/802.15.4_RF +-iwithprefixbefore/mbed/connectivity/drivers/802.15.4_RF/atmel-rf-driver +-iwithprefixbefore/mbed/connectivity/drivers/802.15.4_RF/atmel-rf-driver/atmel-rf-driver +-iwithprefixbefore/mbed/connectivity/drivers/802.15.4_RF/atmel-rf-driver/source +-iwithprefixbefore/mbed/connectivity/drivers/802.15.4_RF/mcr20a-rf-driver +-iwithprefixbefore/mbed/connectivity/drivers/802.15.4_RF/mcr20a-rf-driver/mcr20a-rf-driver +-iwithprefixbefore/mbed/connectivity/drivers/802.15.4_RF/mcr20a-rf-driver/source +-iwithprefixbefore/mbed/connectivity/drivers/802.15.4_RF/stm-s2lp-rf-driver +-iwithprefixbefore/mbed/connectivity/drivers/802.15.4_RF/stm-s2lp-rf-driver/source +-iwithprefixbefore/mbed/connectivity/drivers/802.15.4_RF/stm-s2lp-rf-driver/stm-s2lp-rf-driver +-iwithprefixbefore/mbed/connectivity/drivers/ble/FEATURE_BLE/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_NRF5x +-iwithprefixbefore/mbed/connectivity/drivers/mbedtls/FEATURE_CRYPTOCELL310 +-iwithprefixbefore/mbed/connectivity/drivers/mbedtls/FEATURE_CRYPTOCELL310/TARGET_MCU_NRF52840 +-iwithprefixbefore/mbed/connectivity/drivers/mbedtls/FEATURE_CRYPTOCELL310/include +-iwithprefixbefore/mbed/connectivity/drivers/mbedtls/FEATURE_CRYPTOCELL310/include/cryptocell310 +-iwithprefixbefore/mbed/connectivity/drivers/mbedtls/FEATURE_CRYPTOCELL310/include/cryptocell310/internal +-iwithprefixbefore/mbed/connectivity/drivers/nfc +-iwithprefixbefore/mbed/connectivity/drivers/nfc/PN512 +-iwithprefixbefore/mbed/connectivity/drivers/nfc/PN512/include +-iwithprefixbefore/mbed/connectivity/drivers/nfc/PN512/include/nfc +-iwithprefixbefore/mbed/connectivity/drivers/nfc/PN512/include/nfc/controllers +-iwithprefixbefore/mbed/connectivity/drivers/nfc/PN512/source +-iwithprefixbefore/mbed/connectivity/drivers/nfc/PN512/source/transceiver +-iwithprefixbefore/mbed/connectivity/drivers/wifi +-iwithprefixbefore/mbed/connectivity/drivers/wifi/esp8266-driver +-iwithprefixbefore/mbed/connectivity/drivers/wifi/esp8266-driver/ESP8266 +-iwithprefixbefore/mbed/connectivity/libraries +-iwithprefixbefore/mbed/connectivity/libraries/mbed-coap +-iwithprefixbefore/mbed/connectivity/libraries/mbed-coap/mbed-coap +-iwithprefixbefore/mbed/connectivity/libraries/mbed-coap/source +-iwithprefixbefore/mbed/connectivity/libraries/mbed-coap/source/include +-iwithprefixbefore/mbed/connectivity/libraries/nanostack-libservice +-iwithprefixbefore/mbed/connectivity/libraries/nanostack-libservice/mbed-client-libservice +-iwithprefixbefore/mbed/connectivity/libraries/nanostack-libservice/mbed-client-libservice/platform +-iwithprefixbefore/mbed/connectivity/libraries/ppp +-iwithprefixbefore/mbed/connectivity/libraries/ppp/include +-iwithprefixbefore/mbed/connectivity/libraries/ppp/include/polarssl +-iwithprefixbefore/mbed/connectivity/libraries/ppp/include/ppp +-iwithprefixbefore/mbed/connectivity/lorawan +-iwithprefixbefore/mbed/connectivity/lorawan/include +-iwithprefixbefore/mbed/connectivity/lorawan/include/lorawan +-iwithprefixbefore/mbed/connectivity/lorawan/lorastack +-iwithprefixbefore/mbed/connectivity/lorawan/lorastack/mac +-iwithprefixbefore/mbed/connectivity/lorawan/lorastack/phy +-iwithprefixbefore/mbed/connectivity/lorawan/system +-iwithprefixbefore/mbed/connectivity/mbedtls +-iwithprefixbefore/mbed/connectivity/mbedtls/include +-iwithprefixbefore/mbed/connectivity/mbedtls/include/mbedtls +-iwithprefixbefore/mbed/connectivity/mbedtls/platform +-iwithprefixbefore/mbed/connectivity/mbedtls/platform/inc +-iwithprefixbefore/mbed/connectivity/mbedtls/source +-iwithprefixbefore/mbed/connectivity/netsocket +-iwithprefixbefore/mbed/connectivity/netsocket/include +-iwithprefixbefore/mbed/connectivity/netsocket/include/netsocket +-iwithprefixbefore/mbed/connectivity/nfc +-iwithprefixbefore/mbed/connectivity/nfc/include +-iwithprefixbefore/mbed/connectivity/nfc/include/nfc +-iwithprefixbefore/mbed/connectivity/nfc/include/nfc/ndef +-iwithprefixbefore/mbed/connectivity/nfc/include/nfc/ndef/common +-iwithprefixbefore/mbed/connectivity/nfc/libraries +-iwithprefixbefore/mbed/connectivity/nfc/libraries/acore +-iwithprefixbefore/mbed/connectivity/nfc/libraries/acore/acore +-iwithprefixbefore/mbed/connectivity/nfc/libraries/stack +-iwithprefixbefore/mbed/connectivity/nfc/libraries/stack/ndef +-iwithprefixbefore/mbed/connectivity/nfc/libraries/stack/platform +-iwithprefixbefore/mbed/connectivity/nfc/libraries/stack/tech +-iwithprefixbefore/mbed/connectivity/nfc/libraries/stack/tech/iso7816 +-iwithprefixbefore/mbed/connectivity/nfc/libraries/stack/tech/isodep +-iwithprefixbefore/mbed/connectivity/nfc/libraries/stack/tech/type4 +-iwithprefixbefore/mbed/connectivity/nfc/libraries/stack/transceiver +-iwithprefixbefore/mbed/drivers +-iwithprefixbefore/mbed/drivers/device_key +-iwithprefixbefore/mbed/drivers/device_key/include +-iwithprefixbefore/mbed/drivers/device_key/include/device_key +-iwithprefixbefore/mbed/drivers/include +-iwithprefixbefore/mbed/drivers/include/drivers +-iwithprefixbefore/mbed/drivers/include/drivers/interfaces +-iwithprefixbefore/mbed/drivers/usb +-iwithprefixbefore/mbed/drivers/usb/include +-iwithprefixbefore/mbed/drivers/usb/include/usb +-iwithprefixbefore/mbed/drivers/usb/include/usb/internal +-iwithprefixbefore/mbed/events +-iwithprefixbefore/mbed/events/include +-iwithprefixbefore/mbed/events/include/events +-iwithprefixbefore/mbed/events/include/events/internal +-iwithprefixbefore/mbed/features +-iwithprefixbefore/mbed/features/frameworks +-iwithprefixbefore/mbed/features/frameworks/greentea-client +-iwithprefixbefore/mbed/features/frameworks/greentea-client/greentea-client +-iwithprefixbefore/mbed/features/frameworks/mbed-client-cli +-iwithprefixbefore/mbed/features/frameworks/mbed-client-cli/mbed-client-cli +-iwithprefixbefore/mbed/features/frameworks/unity +-iwithprefixbefore/mbed/features/frameworks/unity/unity +-iwithprefixbefore/mbed/features/frameworks/utest +-iwithprefixbefore/mbed/features/frameworks/utest/utest +-iwithprefixbefore/mbed/hal +-iwithprefixbefore/mbed/hal/include +-iwithprefixbefore/mbed/hal/include/hal +-iwithprefixbefore/mbed/hal/usb +-iwithprefixbefore/mbed/hal/usb/include +-iwithprefixbefore/mbed/hal/usb/include/usb +-iwithprefixbefore/mbed/platform +-iwithprefixbefore/mbed/platform/cxxsupport +-iwithprefixbefore/mbed/platform/include +-iwithprefixbefore/mbed/platform/include/platform +-iwithprefixbefore/mbed/platform/include/platform/internal +-iwithprefixbefore/mbed/platform/mbed-trace +-iwithprefixbefore/mbed/platform/mbed-trace/include +-iwithprefixbefore/mbed/platform/mbed-trace/include/mbed-trace +-iwithprefixbefore/mbed/platform/randlib +-iwithprefixbefore/mbed/platform/randlib/include +-iwithprefixbefore/mbed/platform/randlib/include/mbed-client-randlib +-iwithprefixbefore/mbed/platform/randlib/include/mbed-client-randlib/platform +-iwithprefixbefore/mbed/platform/source +-iwithprefixbefore/mbed/platform/source/minimal-printf +-iwithprefixbefore/mbed/rtos +-iwithprefixbefore/mbed/rtos/include +-iwithprefixbefore/mbed/rtos/include/rtos +-iwithprefixbefore/mbed/rtos/include/rtos/internal +-iwithprefixbefore/mbed/rtos/source +-iwithprefixbefore/mbed/storage +-iwithprefixbefore/mbed/storage/blockdevice +-iwithprefixbefore/mbed/storage/blockdevice/COMPONENT_FLASHIAP +-iwithprefixbefore/mbed/storage/blockdevice/COMPONENT_FLASHIAP/include +-iwithprefixbefore/mbed/storage/blockdevice/COMPONENT_FLASHIAP/include/FlashIAP +-iwithprefixbefore/mbed/storage/blockdevice/include +-iwithprefixbefore/mbed/storage/blockdevice/include/blockdevice +-iwithprefixbefore/mbed/storage/blockdevice/include/blockdevice/internal +-iwithprefixbefore/mbed/storage/filesystem +-iwithprefixbefore/mbed/storage/filesystem/fat +-iwithprefixbefore/mbed/storage/filesystem/fat/ChaN +-iwithprefixbefore/mbed/storage/filesystem/fat/include +-iwithprefixbefore/mbed/storage/filesystem/fat/include/fat +-iwithprefixbefore/mbed/storage/filesystem/include +-iwithprefixbefore/mbed/storage/filesystem/include/filesystem +-iwithprefixbefore/mbed/storage/filesystem/littlefs +-iwithprefixbefore/mbed/storage/filesystem/littlefs/include +-iwithprefixbefore/mbed/storage/filesystem/littlefs/include/littlefs +-iwithprefixbefore/mbed/storage/filesystem/littlefs/littlefs +-iwithprefixbefore/mbed/storage/filesystem/littlefsv2 +-iwithprefixbefore/mbed/storage/filesystem/littlefsv2/include +-iwithprefixbefore/mbed/storage/filesystem/littlefsv2/include/littlefsv2 +-iwithprefixbefore/mbed/storage/filesystem/littlefsv2/littlefs +-iwithprefixbefore/mbed/storage/kvstore +-iwithprefixbefore/mbed/storage/kvstore/direct_access_devicekey +-iwithprefixbefore/mbed/storage/kvstore/direct_access_devicekey/include +-iwithprefixbefore/mbed/storage/kvstore/direct_access_devicekey/include/direct_access_devicekey +-iwithprefixbefore/mbed/storage/kvstore/filesystemstore +-iwithprefixbefore/mbed/storage/kvstore/filesystemstore/include +-iwithprefixbefore/mbed/storage/kvstore/filesystemstore/include/filesystemstore +-iwithprefixbefore/mbed/storage/kvstore/include +-iwithprefixbefore/mbed/storage/kvstore/include/kvstore +-iwithprefixbefore/mbed/storage/kvstore/kv_config +-iwithprefixbefore/mbed/storage/kvstore/kv_config/include +-iwithprefixbefore/mbed/storage/kvstore/kv_config/include/kv_config +-iwithprefixbefore/mbed/storage/kvstore/kvstore_global_api +-iwithprefixbefore/mbed/storage/kvstore/kvstore_global_api/include +-iwithprefixbefore/mbed/storage/kvstore/kvstore_global_api/include/kvstore_global_api +-iwithprefixbefore/mbed/storage/kvstore/securestore +-iwithprefixbefore/mbed/storage/kvstore/securestore/include +-iwithprefixbefore/mbed/storage/kvstore/securestore/include/securestore +-iwithprefixbefore/mbed/storage/kvstore/tdbstore +-iwithprefixbefore/mbed/storage/kvstore/tdbstore/include +-iwithprefixbefore/mbed/storage/kvstore/tdbstore/include/tdbstore +-iwithprefixbefore/mbed/targets/TARGET_NORDIC +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52 +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840 +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/TARGET_STELLA +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/config +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/device +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0 +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/TARGET_SOFTDEVICE_NONE +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/TARGET_SOFTDEVICE_NONE/libraries +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/TARGET_SOFTDEVICE_NONE/libraries/fstorage +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/TARGET_SOFTDEVICE_NONE/nrf_soc_nosd +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/components +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/components/libraries +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/components/libraries/atomic +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/components/libraries/atomic_fifo +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/components/libraries/balloc +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/components/libraries/delay +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/components/libraries/experimental_log +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/components/libraries/experimental_log/src +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/components/libraries/experimental_memobj +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/components/libraries/experimental_section_vars +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/components/libraries/fds +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/components/libraries/fstorage +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/components/libraries/queue +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/components/libraries/spi_mngr +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/components/libraries/strerror +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/components/libraries/twi_mngr +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/components/libraries/util +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/integration +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/integration/nrfx +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/integration/nrfx/legacy +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/integration/nrfx/legacy/ble_flash +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/modules +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/modules/nrfx +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/modules/nrfx/drivers +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/modules/nrfx/drivers/include +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/modules/nrfx/drivers/src +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/modules/nrfx/drivers/src/prs +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/modules/nrfx/hal +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/modules/nrfx/mdk +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/modules/nrfx/soc +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/modules/softdevice +-iwithprefixbefore/mbed/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/modules/softdevice/common diff --git a/variants/STELLA/ldflags.txt b/variants/STELLA/ldflags.txt new file mode 100644 index 000000000..510613aa2 --- /dev/null +++ b/variants/STELLA/ldflags.txt @@ -0,0 +1,22 @@ +-DMBED_APP_SIZE=0xf0000 +-DMBED_APP_START=0x10000 +-DMBED_BOOT_STACK_SIZE=1024 +-DMBED_RAM_SIZE=0x40000 +-DMBED_RAM_START=0x20000000 +-DMBED_ROM_SIZE=0x100000 +-DMBED_ROM_START=0x0 +-DXIP_ENABLE=0 +-Wl,--gc-sections +-Wl,--wrap,_calloc_r +-Wl,--wrap,_free_r +-Wl,--wrap,_malloc_r +-Wl,--wrap,_memalign_r +-Wl,--wrap,_realloc_r +-Wl,--wrap,atexit +-Wl,--wrap,exit +-Wl,--wrap,main +-Wl,-n +-mcpu=cortex-m4 +-mfloat-abi=softfp +-mfpu=fpv4-sp-d16 +-mthumb diff --git a/variants/STELLA/libs/libcc_310_core.a b/variants/STELLA/libs/libcc_310_core.a new file mode 100644 index 000000000..bace518f9 Binary files /dev/null and b/variants/STELLA/libs/libcc_310_core.a differ diff --git a/variants/STELLA/libs/libcc_310_ext.a b/variants/STELLA/libs/libcc_310_ext.a new file mode 100644 index 000000000..64c57cceb Binary files /dev/null and b/variants/STELLA/libs/libcc_310_ext.a differ diff --git a/variants/STELLA/libs/libcc_310_trng.a b/variants/STELLA/libs/libcc_310_trng.a new file mode 100644 index 000000000..df24c2c2c Binary files /dev/null and b/variants/STELLA/libs/libcc_310_trng.a differ diff --git a/variants/STELLA/libs/libmbed.a b/variants/STELLA/libs/libmbed.a new file mode 100644 index 000000000..de69bdf91 Binary files /dev/null and b/variants/STELLA/libs/libmbed.a differ diff --git a/variants/STELLA/linker_script.ld b/variants/STELLA/linker_script.ld new file mode 100644 index 000000000..270da6c43 --- /dev/null +++ b/variants/STELLA/linker_script.ld @@ -0,0 +1,154 @@ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x10000, LENGTH = 0xf0000 + RAM_NVIC (rwx) : ORIGIN = 0x20000000, LENGTH = 0x100 + RAM_CRASH_DATA (rwx) : ORIGIN = (0x20000000 + 0x100), LENGTH = 0x100 + RAM (rwx) : ORIGIN = ((0x20000000 + 0x100) + 0x100), LENGTH = (0x40000 - (0x100 + 0x100)) +} +OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") +ENTRY(Reset_Handler) +SECTIONS +{ + .text : + { + KEEP(*(.Vectors)) + *(.text*) + KEEP(*(.init)) + KEEP(*(.fini)) + *crtbegin.o(.ctors) + *crtbegin?.o(.ctors) + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) + *(SORT(.ctors.*)) + *(.ctors) + *crtbegin.o(.dtors) + *crtbegin?.o(.dtors) + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) + *(SORT(.dtors.*)) + *(.dtors) + *(.rodata*) + KEEP(*(.eh_frame*)) + } > FLASH + .sdh_soc_observers : + { + PROVIDE(__start_sdh_soc_observers = .); + KEEP(*(SORT(.sdh_soc_observers*))) + PROVIDE(__stop_sdh_soc_observers = .); + } > FLASH + .sdh_stack_observers : + { + PROVIDE(__start_sdh_stack_observers = .); + KEEP(*(SORT(.sdh_stack_observers*))) + PROVIDE(__stop_sdh_stack_observers = .); + } > FLASH + .sdh_req_observers : + { + PROVIDE(__start_sdh_req_observers = .); + KEEP(*(SORT(.sdh_req_observers*))) + PROVIDE(__stop_sdh_req_observers = .); + } > FLASH + .sdh_state_observers : + { + PROVIDE(__start_sdh_state_observers = .); + KEEP(*(SORT(.sdh_state_observers*))) + PROVIDE(__stop_sdh_state_observers = .); + } > FLASH + .sdh_ble_observers : + { + PROVIDE(__start_sdh_ble_observers = .); + KEEP(*(SORT(.sdh_ble_observers*))) + PROVIDE(__stop_sdh_ble_observers = .); + } > FLASH + .ARM.extab : + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > FLASH + __exidx_start = .; + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > FLASH + __exidx_end = .; + __etext = .; + .data : AT (__etext) + { + __data_start__ = .; + *(vtable) + *(.data*) + . = ALIGN(8); + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP(*(.preinit_array)) + PROVIDE_HIDDEN (__preinit_array_end = .); + . = ALIGN(8); + PROVIDE_HIDDEN (__init_array_start = .); + KEEP(*(SORT(.init_array.*))) + KEEP(*(.init_array)) + PROVIDE_HIDDEN (__init_array_end = .); + . = ALIGN(8); + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP(*(SORT(.fini_array.*))) + KEEP(*(.fini_array)) + PROVIDE_HIDDEN (__fini_array_end = .); + . = ALIGN(8); + PROVIDE(__start_fs_data = .); + KEEP(*(.fs_data)) + PROVIDE(__stop_fs_data = .); + *(.jcr) + . = ALIGN(8); + __data_end__ = .; + } > RAM + __edata = .; + .nvictable (NOLOAD) : + { + PROVIDE(__start_nvictable = .); + KEEP(*(.nvictable)) + PROVIDE(__stop_nvictable = .); + } > RAM_NVIC + .crash_data_ram : + { + . = ALIGN(8); + __CRASH_DATA_RAM__ = .; + __CRASH_DATA_RAM_START__ = .; + KEEP(*(.keep.crash_data_ram)) + *(.m_crash_data_ram) + . += 0x100; + . = ALIGN(8); + __CRASH_DATA_RAM_END__ = .; + } > RAM_CRASH_DATA + .noinit (NOLOAD) : + { + PROVIDE(__start_noinit = .); + KEEP(*(.noinit)) + PROVIDE(__stop_noinit = .); + } > RAM + .bss : + { + . = ALIGN(8); + __bss_start__ = .; + *(.bss*) + *(COMMON) + . = ALIGN(8); + __bss_end__ = .; + } > RAM + .heap (NOLOAD): + { + __end__ = .; + end = __end__; + *(.heap*); + ASSERT(. <= (ORIGIN(RAM) + LENGTH(RAM) - 0x400), "heap region overflowed into stack"); + . = ORIGIN(RAM) + LENGTH(RAM) - 0x400; + __HeapLimit = .; + } > RAM + PROVIDE(__heap_start = ADDR(.heap)); + PROVIDE(__heap_size = SIZEOF(.heap)); + PROVIDE(__mbed_sbrk_start = ADDR(.heap)); + PROVIDE(__mbed_krbs_start = ADDR(.heap) + SIZEOF(.heap)); + .stack (NOLOAD): + { + __StackLimit = .; + *(.stack*) + . = ORIGIN(RAM) + LENGTH(RAM); + } > RAM + __StackTop = ORIGIN(RAM) + LENGTH(RAM); + __StackLimit = __StackTop - 0x400; + PROVIDE(__stack = __StackTop); +} diff --git a/variants/STELLA/mbed_config.h b/variants/STELLA/mbed_config.h new file mode 100644 index 000000000..7af2c4570 --- /dev/null +++ b/variants/STELLA/mbed_config.h @@ -0,0 +1,395 @@ +/* + * mbed SDK + * Copyright (c) 2017 ARM Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Automatically generated configuration file. +// DO NOT EDIT, content will be overwritten. + +#ifndef __MBED_CONFIG_DATA__ +#define __MBED_CONFIG_DATA__ + +// Configuration parameters +#define ATT_NUM_SIMUL_NTF 1 // set by library:cordio +#define ATT_NUM_SIMUL_WRITE_CMD 1 // set by library:cordio +#define BLE_FEATURE_EXTENDED_ADVERTISING 1 // set by library:ble +#define BLE_FEATURE_GATT_CLIENT 1 // set by library:ble +#define BLE_FEATURE_GATT_SERVER 1 // set by library:ble +#define BLE_FEATURE_PERIODIC_ADVERTISING 1 // set by library:ble +#define BLE_FEATURE_PHY_MANAGEMENT 1 // set by library:ble +#define BLE_FEATURE_PRIVACY 1 // set by library:ble +#define BLE_FEATURE_SECURE_CONNECTIONS 1 // set by library:ble +#define BLE_FEATURE_SECURITY 1 // set by library:ble +#define BLE_FEATURE_SIGNING 1 // set by library:ble +#define BLE_FEATURE_WHITELIST 1 // set by library:ble +#define BLE_GAP_HOST_BASED_PRIVATE_ADDRESS_RESOLUTION 0 // set by library:ble[MCU_NRF52840] +#define BLE_GAP_HOST_MAX_OUTSTANDING_ADVERTISING_START_COMMANDS 4 // set by library:ble +#define BLE_GAP_HOST_PRIVACY_RESOLVED_CACHE_SIZE 16 // set by library:ble +#define BLE_GAP_MAX_ADVERTISING_REPORTS_PENDING_ADDRESS_RESOLUTION 16 // set by library:ble +#define BLE_GAP_MAX_ADVERTISING_SETS 15 // set by library:ble +#define BLE_PASSKEY_DISPLAY_REVERSED_DIGITS_DEPRECATION 1 // set by library:ble +#define BLE_ROLE_BROADCASTER 1 // set by library:ble +#define BLE_ROLE_CENTRAL 1 // set by library:ble +#define BLE_ROLE_OBSERVER 1 // set by library:ble +#define BLE_ROLE_PERIPHERAL 1 // set by library:ble +#define BLE_SECURITY_DATABASE_FILESYSTEM 1 // set by library:ble +#define BLE_SECURITY_DATABASE_KVSTORE 0 // set by library:ble +#define BLE_SECURITY_DATABASE_MAX_ENTRIES 5 // set by library:ble +#define CHCI_TR_CUSTOM 1 // set by library:cordio-ll +#define CHCI_TR_UART 0 // set by library:cordio-ll +#define CORDIO_ZERO_COPY_HCI 1 // set by library:cordio-nordic-ll +#define DM_CONN_MAX 5 // set by application[*] +#define DM_NUM_ADV_SETS 3 // set by library:cordio +#define DM_NUM_PHYS 3 // set by library:cordio +#define DM_SYNC_MAX 1 // set by library:cordio +#define EATT_CONN_CHAN_MAX 1 // set by library:cordio +#define L2C_COC_CHAN_MAX 1 // set by library:cordio +#define L2C_COC_REG_MAX 1 // set by library:cordio +#define LHCI_ENABLE_VS 0 // set by library:cordio-ll +#define MBED_ALL_STATS_ENABLED 1 // set by application[*] +#define MBED_CONF_ATMEL_RF_ASSUME_SPACED_SPI 0 // set by library:atmel-rf +#define MBED_CONF_ATMEL_RF_FULL_SPI_SPEED 7500000 // set by library:atmel-rf +#define MBED_CONF_ATMEL_RF_FULL_SPI_SPEED_BYTE_SPACING 250 // set by library:atmel-rf +#define MBED_CONF_ATMEL_RF_IRQ_THREAD_STACK_SIZE 1024 // set by library:atmel-rf +#define MBED_CONF_ATMEL_RF_LOW_SPI_SPEED 3750000 // set by library:atmel-rf +#define MBED_CONF_ATMEL_RF_PROVIDE_DEFAULT 0 // set by library:atmel-rf +#define MBED_CONF_ATMEL_RF_USE_SPI_SPACING_API 0 // set by library:atmel-rf +#define MBED_CONF_BLE_API_IMPLEMENTATION_MAX_CCCD_COUNT 20 // set by library:ble-api-implementation +#define MBED_CONF_BLE_API_IMPLEMENTATION_MAX_CHARACTERISTIC_AUTHORISATION_COUNT 20 // set by library:ble-api-implementation +#define MBED_CONF_BLE_PRESENT 1 // set by library:ble +#define MBED_CONF_BLE_TRACE_HUMAN_READABLE_ENUMS 0 // set by library:ble +#define MBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE 32 // set by library:cellular +#define MBED_CONF_CELLULAR_CONTROL_PLANE_OPT 0 // set by library:cellular +#define MBED_CONF_CELLULAR_DEBUG_AT 0 // set by library:cellular +#define MBED_CONF_CELLULAR_MAX_CP_DATA_RECV_LEN 1358 // set by library:cellular +#define MBED_CONF_CELLULAR_PRESENT 1 // set by library:cellular +#define MBED_CONF_CELLULAR_RANDOM_MAX_START_DELAY 0 // set by library:cellular +#define MBED_CONF_CELLULAR_USE_APN_LOOKUP 0 // set by library:cellular +#define MBED_CONF_CELLULAR_USE_SMS 0 // set by library:cellular +#define MBED_CONF_CORDIO_DESIRED_ATT_MTU 23 // set by library:cordio +#define MBED_CONF_CORDIO_LL_DEFAULT_EXTENDED_ADVERTISING_FRAGMENTATION_SIZE 64 // set by library:cordio-ll +#define MBED_CONF_CORDIO_LL_EXTENDED_ADVERTISING_SIZE 512 // set by library:cordio-ll[MCU_NRF52840] +#define MBED_CONF_CORDIO_LL_MAX_ACL_SIZE 256 // set by library:cordio-ll +#define MBED_CONF_CORDIO_LL_MAX_ADVERTISING_REPORTS 4 // set by library:cordio-ll +#define MBED_CONF_CORDIO_LL_MAX_ADVERTISING_SETS 3 // set by library:cordio-ll +#define MBED_CONF_CORDIO_LL_MAX_SCAN_REQUEST_EVENTS 4 // set by library:cordio-ll +#define MBED_CONF_CORDIO_LL_NRF52840_CRYPTOCELL310_ACCELERATION 1 // set by library:cordio-ll-nrf52840 +#define MBED_CONF_CORDIO_LL_PHY_2M_SUPPORT 1 // set by library:cordio-ll +#define MBED_CONF_CORDIO_LL_PHY_CODED_SUPPORT 1 // set by library:cordio-ll[MCU_NRF52840] +#define MBED_CONF_CORDIO_LL_RX_BUFFERS 4 // set by library:cordio-ll +#define MBED_CONF_CORDIO_LL_TX_BUFFERS 4 // set by library:cordio-ll +#define MBED_CONF_CORDIO_MAX_PREPARED_WRITES 4 // set by library:cordio +#define MBED_CONF_CORDIO_NORDIC_LL_HCI_DRIVER_BUFFER_SIZE 16056 // set by library:cordio-nordic-ll[MCU_NRF52840] +#define MBED_CONF_CORDIO_NORDIC_LL_WSF_POOL_BUFFER_SIZE 4900 // set by library:cordio-nordic-ll +#define MBED_CONF_CORDIO_PREFERRED_TX_POWER 0 // set by library:cordio +#define MBED_CONF_CORDIO_ROUTE_UNHANDLED_COMMAND_COMPLETE_EVENTS 1 // set by library:cordio +#define MBED_CONF_CORDIO_RX_ACL_BUFFER_SIZE 70 // set by library:cordio +#define MBED_CONF_CORDIO_TRACE_HCI_PACKETS 0 // set by library:cordio +#define MBED_CONF_CORDIO_TRACE_PAL_ECHOES 0 // set by library:cordio +#define MBED_CONF_CRYPTOCELL310_PRESENT 1 // set by library:cryptocell310 +#define MBED_CONF_DRIVERS_OSPI_CSN OSPI_FLASH1_CSN // set by library:drivers +#define MBED_CONF_DRIVERS_OSPI_DQS OSPI_FLASH1_DQS // set by library:drivers +#define MBED_CONF_DRIVERS_OSPI_IO0 OSPI_FLASH1_IO0 // set by library:drivers +#define MBED_CONF_DRIVERS_OSPI_IO1 OSPI_FLASH1_IO1 // set by library:drivers +#define MBED_CONF_DRIVERS_OSPI_IO2 OSPI_FLASH1_IO2 // set by library:drivers +#define MBED_CONF_DRIVERS_OSPI_IO3 OSPI_FLASH1_IO3 // set by library:drivers +#define MBED_CONF_DRIVERS_OSPI_IO4 OSPI_FLASH1_IO4 // set by library:drivers +#define MBED_CONF_DRIVERS_OSPI_IO5 OSPI_FLASH1_IO5 // set by library:drivers +#define MBED_CONF_DRIVERS_OSPI_IO6 OSPI_FLASH1_IO6 // set by library:drivers +#define MBED_CONF_DRIVERS_OSPI_IO7 OSPI_FLASH1_IO7 // set by library:drivers +#define MBED_CONF_DRIVERS_OSPI_SCK OSPI_FLASH1_SCK // set by library:drivers +#define MBED_CONF_DRIVERS_QSPI_CSN QSPI_FLASH1_CSN // set by library:drivers +#define MBED_CONF_DRIVERS_QSPI_IO0 QSPI_FLASH1_IO0 // set by library:drivers +#define MBED_CONF_DRIVERS_QSPI_IO1 QSPI_FLASH1_IO1 // set by library:drivers +#define MBED_CONF_DRIVERS_QSPI_IO2 QSPI_FLASH1_IO2 // set by library:drivers +#define MBED_CONF_DRIVERS_QSPI_IO3 QSPI_FLASH1_IO3 // set by library:drivers +#define MBED_CONF_DRIVERS_QSPI_SCK QSPI_FLASH1_SCK // set by library:drivers +#define MBED_CONF_DRIVERS_UART_SERIAL_RXBUF_SIZE 256 // set by library:drivers +#define MBED_CONF_DRIVERS_UART_SERIAL_TXBUF_SIZE 256 // set by library:drivers +#define MBED_CONF_ESP8266_BUILT_IN_DNS 0 // set by library:esp8266 +#define MBED_CONF_ESP8266_DEBUG 0 // set by library:esp8266 +#define MBED_CONF_ESP8266_POWER_OFF_TIME_MS 3 // set by library:esp8266 +#define MBED_CONF_ESP8266_POWER_ON_POLARITY 0 // set by library:esp8266 +#define MBED_CONF_ESP8266_POWER_ON_TIME_MS 3 // set by library:esp8266 +#define MBED_CONF_ESP8266_PROVIDE_DEFAULT 0 // set by library:esp8266 +#define MBED_CONF_ESP8266_SERIAL_BAUDRATE 115200 // set by library:esp8266 +#define MBED_CONF_ESP8266_SNTP_ENABLE 0 // set by library:esp8266 +#define MBED_CONF_ESP8266_SNTP_SERVER0 "" // set by library:esp8266 +#define MBED_CONF_ESP8266_SNTP_SERVER1 "" // set by library:esp8266 +#define MBED_CONF_ESP8266_SNTP_SERVER2 "" // set by library:esp8266 +#define MBED_CONF_ESP8266_SNTP_TIMEZONE 0 // set by library:esp8266 +#define MBED_CONF_ESP8266_SOCKET_BUFSIZE 8192 // set by library:esp8266 +#define MBED_CONF_EVENTS_PRESENT 1 // set by library:events +#define MBED_CONF_EVENTS_SHARED_DISPATCH_FROM_APPLICATION 0 // set by library:events +#define MBED_CONF_EVENTS_SHARED_EVENTSIZE 768 // set by library:events +#define MBED_CONF_EVENTS_SHARED_HIGHPRIO_EVENTSIZE 256 // set by library:events +#define MBED_CONF_EVENTS_SHARED_HIGHPRIO_STACKSIZE 1024 // set by library:events +#define MBED_CONF_EVENTS_SHARED_STACKSIZE 2048 // set by library:events +#define MBED_CONF_EVENTS_USE_LOWPOWER_TIMER_TICKER 0 // set by library:events +#define MBED_CONF_FAT_CHAN_FFS_DBG 0 // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FF_CODE_PAGE 437 // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FF_FS_EXFAT 0 // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FF_FS_HEAPBUF 1 // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FF_FS_LOCK 0 // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FF_FS_MINIMIZE 0 // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FF_FS_NOFSINFO 0 // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FF_FS_NORTC 0 // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FF_FS_READONLY 0 // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FF_FS_REENTRANT 0 // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FF_FS_RPATH 1 // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FF_FS_TIMEOUT 1000 // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FF_FS_TINY 1 // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FF_LFN_BUF 255 // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FF_LFN_UNICODE 0 // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FF_MAX_LFN 255 // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FF_MAX_SS 4096 // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FF_MIN_SS 512 // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FF_MULTI_PARTITION 0 // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FF_NORTC_MDAY 1 // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FF_NORTC_MON 1 // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FF_NORTC_YEAR 2017 // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FF_PRINT_FLOAT 0 // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FF_PRINT_LLI 0 // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FF_SFN_BUF 12 // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FF_STRF_ENCODE 3 // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FF_STR_VOLUME_ID 0 // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FF_SYNC_T HANDLE // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FF_USE_CHMOD 0 // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FF_USE_EXPAND 0 // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FF_USE_FASTSEEK 0 // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FF_USE_FIND 0 // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FF_USE_FORWARD 0 // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FF_USE_LABEL 0 // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FF_USE_LFN 3 // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FF_USE_MKFS 1 // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FF_USE_STRFUNC 0 // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FF_USE_TRIM 1 // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FF_VOLUMES 4 // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FF_VOLUME_STRS "RAM","NAND","CF","SD","SD2","USB","USB2","USB3" // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FLUSH_ON_NEW_CLUSTER 0 // set by library:fat_chan +#define MBED_CONF_FAT_CHAN_FLUSH_ON_NEW_SECTOR 1 // set by library:fat_chan +#define MBED_CONF_FILESYSTEM_PRESENT 1 // set by library:filesystem +#define MBED_CONF_FLASHIAP_BLOCK_DEVICE_BASE_ADDRESS 0xFFFFFFFF // set by library:flashiap-block-device +#define MBED_CONF_FLASHIAP_BLOCK_DEVICE_SIZE 0 // set by library:flashiap-block-device +#define MBED_CONF_LORA_ADR_ON 1 // set by library:lora +#define MBED_CONF_LORA_APPLICATION_EUI {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // set by library:lora +#define MBED_CONF_LORA_APPLICATION_KEY {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // set by library:lora +#define MBED_CONF_LORA_APPSKEY {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // set by library:lora +#define MBED_CONF_LORA_APP_PORT 15 // set by library:lora +#define MBED_CONF_LORA_AUTOMATIC_UPLINK_MESSAGE 1 // set by library:lora +#define MBED_CONF_LORA_DEVICE_ADDRESS 0x00000000 // set by library:lora +#define MBED_CONF_LORA_DEVICE_EUI {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // set by library:lora +#define MBED_CONF_LORA_DOWNLINK_PREAMBLE_LENGTH 5 // set by library:lora +#define MBED_CONF_LORA_DUTY_CYCLE_ON 1 // set by library:lora +#define MBED_CONF_LORA_DUTY_CYCLE_ON_JOIN 1 // set by library:lora +#define MBED_CONF_LORA_FSB_MASK {0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x00FF} // set by library:lora +#define MBED_CONF_LORA_FSB_MASK_CHINA {0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF} // set by library:lora +#define MBED_CONF_LORA_LBT_ON 0 // set by library:lora +#define MBED_CONF_LORA_MAX_SYS_RX_ERROR 5 // set by library:lora +#define MBED_CONF_LORA_NB_TRIALS 12 // set by library:lora +#define MBED_CONF_LORA_NWKSKEY {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // set by library:lora +#define MBED_CONF_LORA_OVER_THE_AIR_ACTIVATION 1 // set by library:lora +#define MBED_CONF_LORA_PHY EU868 // set by library:lora +#define MBED_CONF_LORA_PHY_AS923_SUB_REGION AS1 // set by library:lora +#define MBED_CONF_LORA_PUBLIC_NETWORK 1 // set by library:lora +#define MBED_CONF_LORA_TX_MAX_SIZE 64 // set by library:lora +#define MBED_CONF_LORA_UPLINK_PREAMBLE_LENGTH 8 // set by library:lora +#define MBED_CONF_LORA_WAKEUP_TIME 5 // set by library:lora +#define MBED_CONF_LWIP_ADDR_TIMEOUT 5 // set by library:lwip +#define MBED_CONF_LWIP_ADDR_TIMEOUT_MODE 1 // set by library:lwip +#define MBED_CONF_LWIP_DEBUG_ENABLED 0 // set by library:lwip +#define MBED_CONF_LWIP_DEFAULT_THREAD_STACKSIZE 512 // set by library:lwip +#define MBED_CONF_LWIP_DHCP_TIMEOUT 60 // set by library:lwip +#define MBED_CONF_LWIP_ENABLE_PPP_TRACE 0 // set by library:lwip +#define MBED_CONF_LWIP_ETHERNET_ENABLED 1 // set by library:lwip +#define MBED_CONF_LWIP_IPV4_ENABLED 1 // set by library:lwip +#define MBED_CONF_LWIP_IPV6_ENABLED 0 // set by library:lwip +#define MBED_CONF_LWIP_IP_VER_PREF 4 // set by library:lwip +#define MBED_CONF_LWIP_L3IP_ENABLED 0 // set by library:lwip +#define MBED_CONF_LWIP_MBOX_SIZE 8 // set by library:lwip +#define MBED_CONF_LWIP_MEMP_NUM_TCPIP_MSG_INPKT 8 // set by library:lwip +#define MBED_CONF_LWIP_MEMP_NUM_TCP_SEG 16 // set by library:lwip +#define MBED_CONF_LWIP_MEM_SIZE 1600 // set by library:lwip +#define MBED_CONF_LWIP_ND6_QUEUEING 0 // set by library:lwip +#define MBED_CONF_LWIP_ND6_RDNSS_MAX_DNS_SERVERS 0 // set by library:lwip +#define MBED_CONF_LWIP_NETBUF_RECVINFO_ENABLED 0 // set by library:lwip +#define MBED_CONF_LWIP_NUM_NETBUF 8 // set by library:lwip +#define MBED_CONF_LWIP_NUM_PBUF 8 // set by library:lwip +#define MBED_CONF_LWIP_PBUF_POOL_SIZE 5 // set by library:lwip +#define MBED_CONF_LWIP_PPP_ENABLED 0 // set by library:lwip +#define MBED_CONF_LWIP_PPP_IPV4_ENABLED 0 // set by library:lwip +#define MBED_CONF_LWIP_PPP_IPV6_ENABLED 0 // set by library:lwip +#define MBED_CONF_LWIP_PPP_THREAD_STACKSIZE 768 // set by library:lwip +#define MBED_CONF_LWIP_PRESENT 1 // set by library:lwip +#define MBED_CONF_LWIP_RAW_SOCKET_ENABLED 0 // set by library:lwip +#define MBED_CONF_LWIP_SOCKET_MAX 4 // set by library:lwip +#define MBED_CONF_LWIP_TCPIP_THREAD_PRIORITY osPriorityNormal // set by library:lwip +#define MBED_CONF_LWIP_TCPIP_THREAD_STACKSIZE 1200 // set by library:lwip +#define MBED_CONF_LWIP_TCP_CLOSE_TIMEOUT 1000 // set by library:lwip +#define MBED_CONF_LWIP_TCP_ENABLED 1 // set by library:lwip +#define MBED_CONF_LWIP_TCP_MAXRTX 6 // set by library:lwip +#define MBED_CONF_LWIP_TCP_MSS 536 // set by library:lwip +#define MBED_CONF_LWIP_TCP_SERVER_MAX 4 // set by library:lwip +#define MBED_CONF_LWIP_TCP_SND_BUF (2 * TCP_MSS) // set by library:lwip +#define MBED_CONF_LWIP_TCP_SOCKET_MAX 4 // set by library:lwip +#define MBED_CONF_LWIP_TCP_SYNMAXRTX 6 // set by library:lwip +#define MBED_CONF_LWIP_TCP_WND (4 * TCP_MSS) // set by library:lwip +#define MBED_CONF_LWIP_UDP_SOCKET_MAX 4 // set by library:lwip +#define MBED_CONF_LWIP_USE_MBED_TRACE 0 // set by library:lwip +#define MBED_CONF_MCR20A_PROVIDE_DEFAULT 0 // set by library:mcr20a +#define MBED_CONF_NANOSTACK_LIBSERVICE_NSDYNMEM_TRACKER_ENABLED 0 // set by library:nanostack-libservice +#define MBED_CONF_NANOSTACK_LIBSERVICE_PRESENT 1 // set by library:nanostack-libservice +#define MBED_CONF_NORDIC_NRF_LF_CLOCK_CALIB_MODE_CONFIG 0 // set by target:MCU_NRF52840 +#define MBED_CONF_NORDIC_NRF_LF_CLOCK_CALIB_TIMER_INTERVAL 16 // set by target:MCU_NRF52840 +#define MBED_CONF_NORDIC_NRF_LF_CLOCK_SRC NRF_LF_SRC_XTAL // set by target:MCU_NRF52840 +#define MBED_CONF_NSAPI_ADD_EVENT_LISTENER_RETURN_CHANGE 0 // set by library:nsapi +#define MBED_CONF_NSAPI_DEFAULT_MESH_TYPE THREAD // set by library:nsapi +#define MBED_CONF_NSAPI_DEFAULT_STACK LWIP // set by library:nsapi +#define MBED_CONF_NSAPI_DEFAULT_WIFI_SECURITY NONE // set by library:nsapi +#define MBED_CONF_NSAPI_DNS_ADDRESSES_LIMIT 10 // set by library:nsapi +#define MBED_CONF_NSAPI_DNS_CACHE_SIZE 3 // set by library:nsapi +#define MBED_CONF_NSAPI_DNS_RESPONSE_WAIT_TIME 10000 // set by library:nsapi +#define MBED_CONF_NSAPI_DNS_RETRIES 1 // set by library:nsapi +#define MBED_CONF_NSAPI_DNS_TOTAL_ATTEMPTS 10 // set by library:nsapi +#define MBED_CONF_NSAPI_PRESENT 1 // set by library:nsapi +#define MBED_CONF_NSAPI_SOCKET_STATS_ENABLED 0 // set by library:nsapi +#define MBED_CONF_NSAPI_SOCKET_STATS_MAX_COUNT 10 // set by library:nsapi +#define MBED_CONF_PLATFORM_CALLBACK_COMPARABLE 1 // set by library:platform +#define MBED_CONF_PLATFORM_CALLBACK_NONTRIVIAL 1 // set by application[*] +#define MBED_CONF_PLATFORM_CRASH_CAPTURE_ENABLED 0 // set by library:platform +#define MBED_CONF_PLATFORM_CTHUNK_COUNT_MAX 8 // set by library:platform +#define MBED_CONF_PLATFORM_DEEPSLEEP_STATS_VERBOSE 1 // set by library:platform +#define MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE 115200 // set by application[*] +#define MBED_CONF_PLATFORM_ERROR_ALL_THREADS_INFO 0 // set by library:platform +#define MBED_CONF_PLATFORM_ERROR_FILENAME_CAPTURE_ENABLED 0 // set by library:platform +#define MBED_CONF_PLATFORM_ERROR_HIST_ENABLED 0 // set by library:platform +#define MBED_CONF_PLATFORM_ERROR_HIST_SIZE 4 // set by library:platform +#define MBED_CONF_PLATFORM_ERROR_REBOOT_MAX 1 // set by library:platform +#define MBED_CONF_PLATFORM_FATAL_ERROR_AUTO_REBOOT_ENABLED 0 // set by library:platform +#define MBED_CONF_PLATFORM_MAX_ERROR_FILENAME_LEN 16 // set by library:platform +#define MBED_CONF_PLATFORM_MINIMAL_PRINTF_ENABLE_64_BIT 1 // set by library:platform +#define MBED_CONF_PLATFORM_MINIMAL_PRINTF_ENABLE_FLOATING_POINT 0 // set by library:platform +#define MBED_CONF_PLATFORM_MINIMAL_PRINTF_SET_FLOATING_POINT_MAX_DECIMALS 6 // set by library:platform +#define MBED_CONF_PLATFORM_POLL_USE_LOWPOWER_TIMER 0 // set by library:platform +#define MBED_CONF_PLATFORM_STDIO_BAUD_RATE 115200 // set by application[*] +#define MBED_CONF_PLATFORM_STDIO_BUFFERED_SERIAL 0 // set by application[*] +#define MBED_CONF_PLATFORM_STDIO_CONVERT_NEWLINES 1 // set by library:platform +#define MBED_CONF_PLATFORM_STDIO_CONVERT_TTY_NEWLINES 1 // set by library:platform +#define MBED_CONF_PLATFORM_STDIO_FLUSH_AT_EXIT 1 // set by library:platform +#define MBED_CONF_PLATFORM_STDIO_MINIMAL_CONSOLE_ONLY 0 // set by library:platform +#define MBED_CONF_PLATFORM_USE_MPU 1 // set by library:platform +#define MBED_CONF_PPP_ENABLED 0 // set by library:ppp +#define MBED_CONF_PPP_ENABLE_TRACE 0 // set by library:ppp +#define MBED_CONF_PPP_IPV4_ENABLED 1 // set by library:ppp +#define MBED_CONF_PPP_IPV6_ENABLED 0 // set by library:ppp +#define MBED_CONF_PPP_MBED_EVENT_QUEUE 0 // set by library:ppp +#define MBED_CONF_PPP_THREAD_STACKSIZE 816 // set by library:ppp +#define MBED_CONF_RTOS_API_PRESENT 1 // set by library:rtos-api +#define MBED_CONF_RTOS_ENABLE_ALL_RTX_EVENTS 0 // set by library:rtos +#define MBED_CONF_RTOS_EVFLAGS_NUM 0 // set by library:rtos +#define MBED_CONF_RTOS_IDLE_THREAD_STACK_SIZE 512 // set by library:rtos +#define MBED_CONF_RTOS_IDLE_THREAD_STACK_SIZE_DEBUG_EXTRA 0 // set by library:rtos +#define MBED_CONF_RTOS_IDLE_THREAD_STACK_SIZE_TICKLESS_EXTRA 256 // set by library:rtos +#define MBED_CONF_RTOS_MAIN_THREAD_STACK_SIZE 32768 // set by application[*] +#define MBED_CONF_RTOS_MSGQUEUE_DATA_SIZE 0 // set by library:rtos +#define MBED_CONF_RTOS_MSGQUEUE_NUM 0 // set by library:rtos +#define MBED_CONF_RTOS_MUTEX_NUM 0 // set by library:rtos +#define MBED_CONF_RTOS_PRESENT 1 // set by library:rtos +#define MBED_CONF_RTOS_SEMAPHORE_NUM 0 // set by library:rtos +#define MBED_CONF_RTOS_THREAD_NUM 0 // set by library:rtos +#define MBED_CONF_RTOS_THREAD_STACK_SIZE 4096 // set by library:rtos +#define MBED_CONF_RTOS_THREAD_USER_STACK_SIZE 0 // set by library:rtos +#define MBED_CONF_RTOS_TIMER_NUM 0 // set by library:rtos +#define MBED_CONF_RTOS_TIMER_THREAD_STACK_SIZE 768 // set by library:rtos +#define MBED_CONF_S2LP_PROVIDE_DEFAULT 0 // set by library:s2lp +#define MBED_CONF_STORAGE_DEFAULT_KV kv // set by library:storage +#define MBED_CONF_STORAGE_FILESYSTEM_BLOCKDEVICE default // set by library:storage_filesystem +#define MBED_CONF_STORAGE_FILESYSTEM_EXTERNAL_BASE_ADDRESS 0 // set by library:storage_filesystem +#define MBED_CONF_STORAGE_FILESYSTEM_EXTERNAL_SIZE 0 // set by library:storage_filesystem +#define MBED_CONF_STORAGE_FILESYSTEM_FILESYSTEM default // set by library:storage_filesystem +#define MBED_CONF_STORAGE_FILESYSTEM_FOLDER_PATH kvstore // set by library:storage_filesystem +#define MBED_CONF_STORAGE_FILESYSTEM_INTERNAL_BASE_ADDRESS 0 // set by library:storage_filesystem +#define MBED_CONF_STORAGE_FILESYSTEM_MOUNT_POINT kv // set by library:storage_filesystem +#define MBED_CONF_STORAGE_FILESYSTEM_NO_RBP_BLOCKDEVICE default // set by library:storage_filesystem_no_rbp +#define MBED_CONF_STORAGE_FILESYSTEM_NO_RBP_EXTERNAL_BASE_ADDRESS 0 // set by library:storage_filesystem_no_rbp +#define MBED_CONF_STORAGE_FILESYSTEM_NO_RBP_EXTERNAL_SIZE 0 // set by library:storage_filesystem_no_rbp +#define MBED_CONF_STORAGE_FILESYSTEM_NO_RBP_FILESYSTEM default // set by library:storage_filesystem_no_rbp +#define MBED_CONF_STORAGE_FILESYSTEM_NO_RBP_FOLDER_PATH kvstore // set by library:storage_filesystem_no_rbp +#define MBED_CONF_STORAGE_FILESYSTEM_NO_RBP_MOUNT_POINT kv // set by library:storage_filesystem_no_rbp +#define MBED_CONF_STORAGE_FILESYSTEM_RBP_INTERNAL_SIZE 0 // set by library:storage_filesystem +#define MBED_CONF_STORAGE_STORAGE_TYPE default // set by library:storage +#define MBED_CONF_STORAGE_TDB_EXTERNAL_BLOCKDEVICE default // set by library:storage_tdb_external +#define MBED_CONF_STORAGE_TDB_EXTERNAL_EXTERNAL_BASE_ADDRESS 0 // set by library:storage_tdb_external +#define MBED_CONF_STORAGE_TDB_EXTERNAL_EXTERNAL_SIZE 0 // set by library:storage_tdb_external +#define MBED_CONF_STORAGE_TDB_EXTERNAL_INTERNAL_BASE_ADDRESS 0 // set by library:storage_tdb_external +#define MBED_CONF_STORAGE_TDB_EXTERNAL_NO_RBP_BLOCKDEVICE default // set by library:storage_tdb_external_no_rbp +#define MBED_CONF_STORAGE_TDB_EXTERNAL_NO_RBP_EXTERNAL_BASE_ADDRESS 0 // set by library:storage_tdb_external_no_rbp +#define MBED_CONF_STORAGE_TDB_EXTERNAL_NO_RBP_EXTERNAL_SIZE 0 // set by library:storage_tdb_external_no_rbp +#define MBED_CONF_STORAGE_TDB_EXTERNAL_RBP_INTERNAL_SIZE 0 // set by library:storage_tdb_external +#define MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_BASE_ADDRESS 0 // set by library:storage_tdb_internal +#define MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_SIZE 0 // set by library:storage_tdb_internal +#define MBED_CONF_TARGET_BOOT_STACK_SIZE 0x400 // set by library:rtos[*] +#define MBED_CONF_TARGET_CONSOLE_UART 1 // set by target:Target +#define MBED_CONF_TARGET_CUSTOM_TICKERS 1 // set by target:Target +#define MBED_CONF_TARGET_DEEP_SLEEP_LATENCY 0 // set by target:Target +#define MBED_CONF_TARGET_DEFAULT_ADC_VREF NAN // set by target:Target +#define MBED_CONF_TARGET_INIT_US_TICKER_AT_BOOT 0 // set by target:Target +#define MBED_CONF_TARGET_INTERNAL_FLASH_UNIFORM_SECTORS 1 // set by target:Target +#define MBED_CONF_TARGET_MPU_ROM_END 0x1fffffff // set by target:MCU_NRF52840 +#define MBED_CONF_TARGET_TICKLESS_FROM_US_TICKER 0 // set by target:Target +#define MBED_CONF_TARGET_UART_0_FIFO_SIZE 32 // set by target:MCU_NRF52840 +#define MBED_CONF_TARGET_UART_1_FIFO_SIZE 32 // set by target:MCU_NRF52840 +#define MBED_CONF_TARGET_XIP_ENABLE 0 // set by target:Target +#define MBED_CRC_TABLE_SIZE 16 // set by library:drivers +#define MBED_LFS2_BLOCK_CYCLES 1024 // set by library:littlefs2 +#define MBED_LFS2_BLOCK_SIZE 512 // set by library:littlefs2 +#define MBED_LFS2_CACHE_SIZE 64 // set by library:littlefs2 +#define MBED_LFS2_ENABLE_INFO 0 // set by library:littlefs2 +#define MBED_LFS2_INTRINSICS 1 // set by library:littlefs2 +#define MBED_LFS2_LOOKAHEAD_SIZE 64 // set by library:littlefs2 +#define MBED_LFS_BLOCK_SIZE 512 // set by library:littlefs +#define MBED_LFS_ENABLE_INFO 0 // set by library:littlefs +#define MBED_LFS_INTRINSICS 1 // set by library:littlefs +#define MBED_LFS_LOOKAHEAD 512 // set by library:littlefs +#define MBED_LFS_PROG_SIZE 64 // set by library:littlefs +#define MBED_LFS_READ_SIZE 64 // set by library:littlefs +#define MBED_STACK_DUMP_ENABLED 0 // set by library:platform +#define MBED_TRACE_COLOR_THEME 0 // set by library:mbed-trace +#define MEM_ALLOC malloc // set by library:mbed-trace +#define MEM_FREE free // set by library:mbed-trace +#define PPP_DEBUG 0 // set by library:ppp +#define QSPIF_SFDP_DATA_LEN 128 // set by target:MCU_NRF52840 +#define SEC_CCM_CFG 1 // set by library:cordio +#define SMP_DB_MAX_DEVICES 3 // set by library:cordio +#define WSF_TRACE_ENABLED 0 // set by library:cordio +// Macros +#define BB_CLK_RATE_HZ 1000000 // defined by library:cordio-nordic-ll +#define INIT_BROADCASTER // defined by library:cordio-nordic-ll +#define INIT_CENTRAL // defined by library:cordio-nordic-ll +#define INIT_ENCRYPTED // defined by library:cordio-nordic-ll +#define INIT_OBSERVER // defined by library:cordio-nordic-ll +#define INIT_PERIPHERAL // defined by library:cordio-nordic-ll +#define LHCI_ENABLE_VS 0 // defined by library:cordio-nordic-ll +#define LL_MAX_PER_SCAN 3 // defined by library:cordio-nordic-ll +#define MBEDTLS_CIPHER_MODE_CTR // defined by library:SecureStore +#define NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 8 // defined by application +#define NRFX_WDT_ENABLED 1 // defined by application +#define NSAPI_PPP_AVAILABLE (MBED_CONF_PPP_ENABLED || MBED_CONF_LWIP_PPP_ENABLED) // defined by library:ppp +#define NSDYNMEM_TRACKER_ENABLED MBED_CONF_NANOSTACK_LIBSERVICE_NSDYNMEM_TRACKER_ENABLED // defined by library:nanostack-libservice +#define UNITY_INCLUDE_CONFIG_H // defined by library:utest +#define WSF_MS_PER_TICK 1 // defined by library:cordio +#define _RTE_ // defined by library:rtos + +#endif diff --git a/variants/STELLA/pinmode_arduino.h b/variants/STELLA/pinmode_arduino.h new file mode 100644 index 000000000..9f3c481a6 --- /dev/null +++ b/variants/STELLA/pinmode_arduino.h @@ -0,0 +1,52 @@ + +/* Define mock symbols to nullify PinMode definitions */ +#define PullNone TempPullNone +#define PullDown TempPullDown +#define PullUp TempPullUp +#define PullDefault TempPullDefault + +#define INPUT TempINPUT +#define OUTPUT TempOUTPUT +#define INPUT_PULLUP TempINPUT_PULLUP +#define INPUT_PULLDOWN TempINPUT_PULLDOWN + +/* Rename symbol PinMode into MbedPinMode for all the file PinNames.h + * Functions using PinMode should be redeclared with the correct PinMode symbol */ +#define PinMode MbedPinMode +#include "mbed_config.h" +#include "PinNames.h" +#undef PinMode + +/* Rename symbol PinMode into ArduinoPinMode for all the file Common.h + * Functions using PinMode should be redeclared with the correct PinMode symbol */ +#define PinMode ArduinoPinMode +#include "api/Common.h" +#undef PinMode + +#undef PullNone +#undef PullDown +#undef PullUp +#undef PullDefault + +#undef INPUT +#undef OUTPUT +#undef INPUT_PULLUP +#undef INPUT_PULLDOWN + +typedef enum { + PullNone = TempPullNone, + PullDown = TempPullDown, + PullUp = TempPullUp, + PullDefault = TempPullDefault, + INPUT = TempINPUT, + OUTPUT = TempOUTPUT, + INPUT_PULLUP = TempINPUT_PULLUP, + INPUT_PULLDOWN = TempINPUT_PULLDOWN +} PinMode; + +#if defined(__cplusplus) + +/* Redeclare Common.h functions with the updated PinMode */ +void pinMode(pin_size_t pinNumber, PinMode pinMode); + +#endif \ No newline at end of file diff --git a/variants/STELLA/pins_arduino.h b/variants/STELLA/pins_arduino.h new file mode 100644 index 000000000..e22d186ac --- /dev/null +++ b/variants/STELLA/pins_arduino.h @@ -0,0 +1,186 @@ +#pragma once +#include +#include + +#ifndef __PINS_ARDUINO__ +#define __PINS_ARDUINO__ + +#define ANALOG_CONFIG + +/* Analog reference options + * Different possibilities available combining Reference and Gain + */ +enum _AnalogReferenceMode +{ + AR_VDD, // 3.3 V + AR_INTERNAL, // 0.6 V + AR_INTERNAL1V2, // 1.2 V + AR_INTERNAL2V4 // 2.4 V +}; + +/* Analog acquisition time options */ +enum _AnalogAcquisitionTime +{ + AT_3_US, + AT_5_US, + AT_10_US, // Default value + AT_15_US, + AT_20_US, + AT_40_US +}; + +// Frequency of the board main oscillator +#define VARIANT_MAINOSC (32768ul) + +// Master clock frequency +#define VARIANT_MCK (64000000ul) + +// Pins +// ---- + +// Number of pins defined in PinDescription array +#ifdef __cplusplus +extern "C" unsigned int PINCOUNT_fn(); +#endif +#define PINS_COUNT (PINCOUNT_fn()) +#define NUM_DIGITAL_PINS (21u) +#define NUM_ANALOG_INPUTS (8u) +#define NUM_ANALOG_OUTPUTS (0u) + +extern PinName digitalPinToPinName(pin_size_t P); + +// LEDs +// ---- +#define PIN_LED (13u) +#define LED_BUILTIN PIN_LED +#define LEDR (22u) +#define LEDG (23u) +#define LEDB (24u) +#define LED_PWR (25u) + +// Analog pins +// ----------- +#define PIN_A0 (14u) +#define PIN_A1 (15u) +#define PIN_A2 (16u) +#define PIN_A3 (17u) +#define PIN_A4 (18u) +#define PIN_A5 (19u) +#define PIN_A6 (20u) +#define PIN_A7 (21u) +static const uint8_t A0 = PIN_A0; +static const uint8_t A1 = PIN_A1; +static const uint8_t A2 = PIN_A2; +static const uint8_t A3 = PIN_A3; +static const uint8_t A4 = PIN_A4; +static const uint8_t A5 = PIN_A5; +static const uint8_t A6 = PIN_A6; +static const uint8_t A7 = PIN_A7; +#define ADC_RESOLUTION 12 + +// Digital pins +// ----------- +#define D0 (0u) +#define D1 (1u) +#define D2 (2u) +#define D3 (3u) +#define D4 (4u) +#define D5 (5u) +#define D6 (6u) +#define D7 (7u) +#define D8 (8u) +#define D9 (9u) +#define D10 (10u) +#define D11 (11u) +#define D12 (12u) +#define D13 (13u) + +/* + * Serial interfaces + */ +// Serial (EDBG) +#define PIN_SERIAL_RX (1ul) +#define PIN_SERIAL_TX (0ul) + +// SPI +#define PIN_SPI_MISO (12u) +#define PIN_SPI_MOSI (11u) +#define PIN_SPI_SCK (13u) +#define PIN_SPI_SS (10u) + +static const uint8_t SS = PIN_SPI_SS; // SPI Slave SS not used. Set here only for reference. +static const uint8_t MOSI = PIN_SPI_MOSI; +static const uint8_t MISO = PIN_SPI_MISO; +static const uint8_t SCK = PIN_SPI_SCK; + +// Wire +#define PIN_WIRE_SDA (18u) +#define PIN_WIRE_SCL (19u) + +#define PIN_WIRE_SDA1 (30u) +#define PIN_WIRE_SCL1 (31u) + +#define PIN_ENABLE_I2C_PULLUP (32u) +#define PIN_ENABLE_SENSORS_3V3 (33u) + +#define PIN_INT_APDS (26u) + +// PDM Interfaces +// --------------- +#define PIN_PDM_PWR (27) +#define PIN_PDM_CLK (28) +#define PIN_PDM_DIN (29) + +// These serial port names are intended to allow libraries and architecture-neutral +// sketches to automatically default to the correct port name for a particular type +// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, +// the first hardware serial port whose RX/TX pins are not dedicated to another use. +// +// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor +// +// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial +// +// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library +// +// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. +// +// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX +// pins are NOT connected to anything by default. +#define SERIAL_PORT_USBVIRTUAL SerialUSB +#define SERIAL_PORT_MONITOR SerialUSB +#define SERIAL_PORT_HARDWARE Serial1 +#define SERIAL_PORT_HARDWARE_OPEN Serial1 + + +// Mbed specific defines +#define SERIAL_HOWMANY 1 +#define SERIAL1_TX (digitalPinToPinName(PIN_SERIAL_TX)) +#define SERIAL1_RX (digitalPinToPinName(PIN_SERIAL_RX)) + +#define SERIAL_CDC 1 +#define HAS_UNIQUE_ISERIAL_DESCRIPTOR +#define BOARD_VENDORID 0x2341 +#define BOARD_PRODUCTID 0x0076 +#define BOARD_NAME "Stella" + +#define DFU_MAGIC_SERIAL_ONLY_RESET 0xb0 + +#define WIRE_HOWMANY 2 + +#define I2C_SDA (digitalPinToPinName(PIN_WIRE_SDA)) +#define I2C_SCL (digitalPinToPinName(PIN_WIRE_SCL)) +#define I2C_SDA1 (digitalPinToPinName(PIN_WIRE_SDA1)) +#define I2C_SCL1 (digitalPinToPinName(PIN_WIRE_SCL1)) + +#define SPI_HOWMANY 1 + +#define SPI_MISO (digitalPinToPinName(PIN_SPI_MISO)) +#define SPI_MOSI (digitalPinToPinName(PIN_SPI_MOSI)) +#define SPI_SCK (digitalPinToPinName(PIN_SPI_SCK)) + +#define digitalPinToPort(P) (digitalPinToPinName(P)/32) + +uint8_t getUniqueSerialNumber(uint8_t* name); +void _ontouch1200bps_(); + +#endif //__PINS_ARDUINO__ diff --git a/variants/STELLA/variant.cpp b/variants/STELLA/variant.cpp new file mode 100644 index 000000000..cbeb7fc76 --- /dev/null +++ b/variants/STELLA/variant.cpp @@ -0,0 +1,218 @@ +#include "Arduino.h" +#include "pinDefinitions.h" + +/* wiring_analog variables definition */ +/* Flag to indicate whether the ADC config has been changed from the default one */ +bool isAdcConfigChanged = false; + +/* + * Configuration used for all the active ADC channels, it is initialized with the mbed default values + * When it is changed, all the ADC channels are reconfigured accordingly + */ +analogin_config_t adcCurrentConfig = { + .resistor_p = NRF_SAADC_RESISTOR_DISABLED, + .resistor_n = NRF_SAADC_RESISTOR_DISABLED, + .gain = NRF_SAADC_GAIN1_4, + .reference = NRF_SAADC_REFERENCE_VDD4, + .acq_time = NRF_SAADC_ACQTIME_10US, + .mode = NRF_SAADC_MODE_SINGLE_ENDED, + .burst = NRF_SAADC_BURST_DISABLED, + .pin_p = NRF_SAADC_INPUT_DISABLED, + .pin_n = NRF_SAADC_INPUT_DISABLED +}; + +void analogReference(uint8_t mode) +{ + nrf_saadc_reference_t reference = NRF_SAADC_REFERENCE_VDD4; + nrf_saadc_gain_t gain = NRF_SAADC_GAIN1_4; + if (mode == AR_VDD) { + reference = NRF_SAADC_REFERENCE_VDD4; + gain = NRF_SAADC_GAIN1_4; + } else if (mode == AR_INTERNAL) { + reference = NRF_SAADC_REFERENCE_INTERNAL; + gain = NRF_SAADC_GAIN1; + } else if (mode == AR_INTERNAL1V2) { + reference = NRF_SAADC_REFERENCE_INTERNAL; + gain = NRF_SAADC_GAIN1_2; + } else if (mode == AR_INTERNAL2V4) { + reference = NRF_SAADC_REFERENCE_INTERNAL; + gain = NRF_SAADC_GAIN1_4; + } + adcCurrentConfig.reference = reference; + adcCurrentConfig.gain = gain; + analogUpdate(); +} + +void analogAcquisitionTime(uint8_t time) +{ + nrf_saadc_acqtime_t acqTime = NRF_SAADC_ACQTIME_10US; + if (time == AT_3_US) { + acqTime = NRF_SAADC_ACQTIME_3US; + } else if (time == AT_5_US) { + acqTime = NRF_SAADC_ACQTIME_5US; + } else if (time == AT_10_US) { + acqTime = NRF_SAADC_ACQTIME_10US; + } else if (time == AT_15_US) { + acqTime = NRF_SAADC_ACQTIME_15US; + } else if (time == AT_20_US) { + acqTime = NRF_SAADC_ACQTIME_20US; + } else if (time == AT_40_US) { + acqTime = NRF_SAADC_ACQTIME_40US; + } + adcCurrentConfig.acq_time = acqTime; + analogUpdate(); +} + +AnalogPinDescription g_AAnalogPinDescription[] = { + // A0 - A7 + { P0_4, NULL }, // A0 + { P0_5, NULL }, // A1 + { P0_30, NULL }, // A2 + { P0_29, NULL }, // A3 + { P0_31, NULL }, // A4/SDA + { P0_2, NULL }, // A5/SCL + { P0_28, NULL }, // A6 + { P0_3, NULL } // A7 +}; + +PinDescription g_APinDescription[] = { + // D0 - D7 + { P1_3, NULL, NULL, NULL }, // D0/TX + { P1_10, NULL, NULL, NULL }, // D1/RX + { P1_11, NULL, NULL, NULL }, // D2 + { P1_12, NULL, NULL, NULL }, // D3 + { P1_15, NULL, NULL, NULL }, // D4 + { P1_13, NULL, NULL, NULL }, // D5 + { P1_14, NULL, NULL, NULL }, // D6 + { P0_23, NULL, NULL, NULL }, // D7 + + // D8 - D13 + { P0_21, NULL, NULL, NULL }, // D8 + { P0_27, NULL, NULL, NULL }, // D9 + { P1_2, NULL, NULL, NULL }, // D10 + { P1_1, NULL, NULL, NULL }, // D11/MOSI + { P1_8, NULL, NULL, NULL }, // D12/MISO + { P0_13, NULL, NULL, NULL }, // D13/SCK/LED + + // A0 - A7 + { P0_4, NULL, NULL, NULL }, // A0 + { P0_5, NULL, NULL, NULL }, // A1 + { P0_30, NULL, NULL, NULL }, // A2 + { P0_29, NULL, NULL, NULL }, // A3 + { P0_31, NULL, NULL, NULL }, // A4/SDA + { P0_2, NULL, NULL, NULL }, // A5/SCL + { P0_28, NULL, NULL, NULL }, // A6 + { 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 + + { P0_19, NULL, NULL, NULL }, // INT APDS + + // PDM + { P0_17, NULL, NULL, NULL }, // PDM PWR + { P0_26, NULL, NULL, NULL }, // PDM CLK + { P0_25, NULL, NULL, NULL }, // PDM DIN + + // Internal I2C + { P0_14, NULL, NULL, NULL }, // SDA2 + { P0_15, NULL, NULL, NULL }, // SCL2 + + // Internal I2C + { P1_0, NULL, NULL, NULL }, // I2C_PULL + { P0_22, NULL, NULL, NULL } // VDD_ENV_ENABLE +}; + +extern "C" { + unsigned int PINCOUNT_fn() { + return (sizeof(g_APinDescription) / sizeof(g_APinDescription[0])); + } +} + +#include "nrf_rtc.h" +#include "nrf_uarte.h" +#include "nrf_uart.h" + +void initVariant() { + // turn power LED on + pinMode(LED_PWR, OUTPUT); + digitalWrite(LED_PWR, HIGH); + + // Errata Nano33BLE - I2C pullup is controlled by the SWO pin. + // Configure the TRACEMUX to disable routing SWO signal to pin. + NRF_CLOCK->TRACECONFIG = 0; + + // FIXME: bootloader enables interrupt on COMPARE[0], which we don't handle + // Disable it here to avoid getting stuck when OVERFLOW irq is triggered + nrf_rtc_event_disable(NRF_RTC1, NRF_RTC_INT_COMPARE0_MASK); + nrf_rtc_int_disable(NRF_RTC1, NRF_RTC_INT_COMPARE0_MASK); + + // FIXME: always enable I2C pullup and power @startup + // Change for maximum powersave + pinMode(PIN_ENABLE_SENSORS_3V3, OUTPUT); + pinMode(PIN_ENABLE_I2C_PULLUP, OUTPUT); + + digitalWrite(PIN_ENABLE_SENSORS_3V3, HIGH); + delay(10); + digitalWrite(PIN_ENABLE_I2C_PULLUP, HIGH); + + // Set high drive pin to properly power the bmi150 + nrf_gpio_cfg( + digitalPinToPinName(PIN_ENABLE_SENSORS_3V3), + NRF_GPIO_PIN_DIR_OUTPUT, + NRF_GPIO_PIN_INPUT_DISCONNECT, + NRF_GPIO_PIN_NOPULL, + NRF_GPIO_PIN_H0H1, + NRF_GPIO_PIN_NOSENSE); + + // Disable UARTE0 which is initially enabled by the bootloader + nrf_uarte_task_trigger(NRF_UARTE0, NRF_UARTE_TASK_STOPRX); + while (!nrf_uarte_event_check(NRF_UARTE0, NRF_UARTE_EVENT_RXTO)) ; + NRF_UARTE0->ENABLE = 0; + NRF_UART0->ENABLE = 0; + + NRF_PWM_Type* PWM[] = { + NRF_PWM0, NRF_PWM1, NRF_PWM2 +#ifdef NRF_PWM3 + ,NRF_PWM3 +#endif + }; + + for (unsigned int i = 0; i < (sizeof(PWM)/sizeof(PWM[0])); i++) { + PWM[i]->ENABLE = 0; + PWM[i]->PSEL.OUT[0] = 0xFFFFFFFFUL; + } +} + +#ifdef SERIAL_CDC + +static void utox8(uint32_t val, uint8_t* s) { + for (int i = 0; i < 16; i=i+2) { + int d = val & 0XF; + val = (val >> 4); + + s[15 - i -1] = d > 9 ? 'A' + d - 10 : '0' + d; + s[15 - i] = '\0'; + } +} + +uint8_t getUniqueSerialNumber(uint8_t* name) { + #define SERIAL_NUMBER_WORD_0 NRF_FICR->DEVICEADDR[1] + #define SERIAL_NUMBER_WORD_1 NRF_FICR->DEVICEADDR[0] + + utox8(SERIAL_NUMBER_WORD_0, &name[0]); + utox8(SERIAL_NUMBER_WORD_1, &name[16]); + + return 32; +} + +void _ontouch1200bps_() { + __disable_irq(); + NRF_POWER->GPREGRET = DFU_MAGIC_SERIAL_ONLY_RESET; + NVIC_SystemReset(); +} + +#endif