From 32e27c20fdd40d9462a56ee82efdc4eed1627ef1 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 8 Aug 2022 15:17:47 +0300 Subject: [PATCH 1/4] Fix a path to the ".pio" folder --- examples/mbed-legacy-examples/mbed-events/.gitignore | 3 +-- examples/mbed-legacy-examples/mbed-rtos-tls-client/.gitignore | 4 +--- examples/mbed-rtos-blink-baremetal/.gitignore | 3 +-- examples/mbed-rtos-ethernet-tls/.gitignore | 4 +--- examples/mbed-rtos-kvstore/.gitignore | 4 +--- examples/mbed-rtos-psa/.gitignore | 4 +--- examples/mbed-rtos-usb-msd/.gitignore | 4 +--- 7 files changed, 7 insertions(+), 19 deletions(-) diff --git a/examples/mbed-legacy-examples/mbed-events/.gitignore b/examples/mbed-legacy-examples/mbed-events/.gitignore index 6c69f4c..03f4a3c 100644 --- a/examples/mbed-legacy-examples/mbed-events/.gitignore +++ b/examples/mbed-legacy-examples/mbed-events/.gitignore @@ -1,2 +1 @@ -.pioenvs -.piolibdeps +.pio diff --git a/examples/mbed-legacy-examples/mbed-rtos-tls-client/.gitignore b/examples/mbed-legacy-examples/mbed-rtos-tls-client/.gitignore index 5402c18..03f4a3c 100644 --- a/examples/mbed-legacy-examples/mbed-rtos-tls-client/.gitignore +++ b/examples/mbed-legacy-examples/mbed-rtos-tls-client/.gitignore @@ -1,3 +1 @@ -.pioenvs -.clang_complete -.gcc-flags.json +.pio diff --git a/examples/mbed-rtos-blink-baremetal/.gitignore b/examples/mbed-rtos-blink-baremetal/.gitignore index 6c69f4c..03f4a3c 100644 --- a/examples/mbed-rtos-blink-baremetal/.gitignore +++ b/examples/mbed-rtos-blink-baremetal/.gitignore @@ -1,2 +1 @@ -.pioenvs -.piolibdeps +.pio diff --git a/examples/mbed-rtos-ethernet-tls/.gitignore b/examples/mbed-rtos-ethernet-tls/.gitignore index 5402c18..03f4a3c 100644 --- a/examples/mbed-rtos-ethernet-tls/.gitignore +++ b/examples/mbed-rtos-ethernet-tls/.gitignore @@ -1,3 +1 @@ -.pioenvs -.clang_complete -.gcc-flags.json +.pio diff --git a/examples/mbed-rtos-kvstore/.gitignore b/examples/mbed-rtos-kvstore/.gitignore index 5402c18..03f4a3c 100644 --- a/examples/mbed-rtos-kvstore/.gitignore +++ b/examples/mbed-rtos-kvstore/.gitignore @@ -1,3 +1 @@ -.pioenvs -.clang_complete -.gcc-flags.json +.pio diff --git a/examples/mbed-rtos-psa/.gitignore b/examples/mbed-rtos-psa/.gitignore index 5402c18..03f4a3c 100644 --- a/examples/mbed-rtos-psa/.gitignore +++ b/examples/mbed-rtos-psa/.gitignore @@ -1,3 +1 @@ -.pioenvs -.clang_complete -.gcc-flags.json +.pio diff --git a/examples/mbed-rtos-usb-msd/.gitignore b/examples/mbed-rtos-usb-msd/.gitignore index 5402c18..03f4a3c 100644 --- a/examples/mbed-rtos-usb-msd/.gitignore +++ b/examples/mbed-rtos-usb-msd/.gitignore @@ -1,3 +1 @@ -.pioenvs -.clang_complete -.gcc-flags.json +.pio From 25ad8cda26aa60a3bb9334dee81abab97eb7012e Mon Sep 17 00:00:00 2001 From: Valerii Koval Date: Fri, 9 Jun 2023 17:39:03 +0300 Subject: [PATCH 2/4] Drop support for legacy mbed v5 --- .github/workflows/examples.yml | 2 - boards/frdm_k20d50m.json | 31 -- boards/frdm_kl05z.json | 28 -- boards/frdm_kl27z.json | 29 -- boards/frdm_kl82z.json | 25 -- boards/frdm_kw24d.json | 1 - .../mbed-events/README.md | 27 -- .../mbed-events/include/README | 39 -- .../mbed-events/lib/README | 46 --- .../mbed-events/platformio.ini | 19 - .../mbed-events/src/main.cpp | 15 - .../mbed-events/test/README | 11 - .../mbed-rtos-tls-client/README.md | 21 - .../mbed-rtos-tls-client/include/README | 39 -- .../mbed-rtos-tls-client/lib/readme.txt | 38 -- .../mbed-rtos-tls-client/mbed_app.json | 34 -- .../mbed-rtos-tls-client/platformio.ini | 16 - .../src/HelloHttpsClient.cpp | 382 ------------------ .../src/HelloHttpsClient.h | 236 ----------- .../mbed-rtos-tls-client/src/main.cpp | 119 ------ .../src/mbedtls_entropy_config.h | 49 --- .../mbed-rtos-tls-client/test/README | 11 - misc/mbed_deprecated_boards.json | 7 - platform.json | 5 +- platform.py | 6 - 25 files changed, 1 insertion(+), 1235 deletions(-) delete mode 100644 boards/frdm_k20d50m.json delete mode 100644 boards/frdm_kl05z.json delete mode 100644 boards/frdm_kl27z.json delete mode 100644 boards/frdm_kl82z.json delete mode 100644 examples/mbed-legacy-examples/mbed-events/README.md delete mode 100644 examples/mbed-legacy-examples/mbed-events/include/README delete mode 100644 examples/mbed-legacy-examples/mbed-events/lib/README delete mode 100644 examples/mbed-legacy-examples/mbed-events/platformio.ini delete mode 100644 examples/mbed-legacy-examples/mbed-events/src/main.cpp delete mode 100644 examples/mbed-legacy-examples/mbed-events/test/README delete mode 100644 examples/mbed-legacy-examples/mbed-rtos-tls-client/README.md delete mode 100644 examples/mbed-legacy-examples/mbed-rtos-tls-client/include/README delete mode 100644 examples/mbed-legacy-examples/mbed-rtos-tls-client/lib/readme.txt delete mode 100644 examples/mbed-legacy-examples/mbed-rtos-tls-client/mbed_app.json delete mode 100644 examples/mbed-legacy-examples/mbed-rtos-tls-client/platformio.ini delete mode 100644 examples/mbed-legacy-examples/mbed-rtos-tls-client/src/HelloHttpsClient.cpp delete mode 100644 examples/mbed-legacy-examples/mbed-rtos-tls-client/src/HelloHttpsClient.h delete mode 100644 examples/mbed-legacy-examples/mbed-rtos-tls-client/src/main.cpp delete mode 100644 examples/mbed-legacy-examples/mbed-rtos-tls-client/src/mbedtls_entropy_config.h delete mode 100644 examples/mbed-legacy-examples/mbed-rtos-tls-client/test/README delete mode 100644 misc/mbed_deprecated_boards.json diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index 6ca0e75..5d14b92 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -14,8 +14,6 @@ jobs: - "examples/mbed-rtos-ethernet-tls" - "examples/mbed-rtos-kvstore" - "examples/mbed-rtos-psa" - - "examples/mbed-legacy-examples/mbed-events" - - "examples/mbed-legacy-examples/mbed-rtos-tls-client" - "examples/zephyr-blink" - "examples/zephyr-net-telnet" runs-on: ${{ matrix.os }} diff --git a/boards/frdm_k20d50m.json b/boards/frdm_k20d50m.json deleted file mode 100644 index cfd72d5..0000000 --- a/boards/frdm_k20d50m.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "build": { - "cpu": "cortex-m4", - "f_cpu": "48000000L", - "mcu": "mk20dx128vlh5" - }, - "connectivity": [ - "can" - ], - "debug": { - "jlink_device": "MK20DX128xxx5", - "pyocd_target": "k20d50m", - "svd_path": "MK20D5.svd" - }, - "frameworks": [ - "mbed" - ], - "name": "Freescale Kinetis FRDM-K20D50M", - "upload": { - "maximum_ram_size": 16384, - "maximum_size": 131072, - "protocol": "mbed", - "protocols": [ - "cmsis-dap", - "jlink", - "mbed" - ] - }, - "url": "https://developer.mbed.org/platforms/FRDM-K20D50M/", - "vendor": "Freescale" -} diff --git a/boards/frdm_kl05z.json b/boards/frdm_kl05z.json deleted file mode 100644 index 54e0d5f..0000000 --- a/boards/frdm_kl05z.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "build": { - "cpu": "cortex-m0plus", - "f_cpu": "48000000L", - "mcu": "mkl05z32vfm4" - }, - "debug": { - "jlink_device": "MKL05Z32xxx4", - "pyocd_target": "kl05z", - "svd_path": "MKL05Z4.svd" - }, - "frameworks": [ - "mbed" - ], - "name": "Freescale Kinetis FRDM-KL05Z", - "upload": { - "maximum_ram_size": 4096, - "maximum_size": 32768, - "protocol": "mbed", - "protocols": [ - "cmsis-dap", - "jlink", - "mbed" - ] - }, - "url": "https://developer.mbed.org/platforms/FRDM-KL05Z/", - "vendor": "Freescale" -} diff --git a/boards/frdm_kl27z.json b/boards/frdm_kl27z.json deleted file mode 100644 index 22fa9ba..0000000 --- a/boards/frdm_kl27z.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "build": { - "cpu": "cortex-m0plus", - "f_cpu": "48000000L", - "mcu": "mkl27z64vlh4" - }, - "debug": { - "jlink_device": "MKL27Z64xxx4", - "pyocd_target": "kl27z4", - "svd_path": "MKL27Z644.svd" - }, - "frameworks": [ - "mbed" - ], - "name": "Freescale Kinetis FRDM-KL27Z", - "upload": { - "maximum_ram_size": 16384, - "maximum_size": 65536, - "protocol": "mbed", - "protocols": [ - "blackmagic", - "cmsis-dap", - "jlink", - "mbed" - ] - }, - "url": "https://os.mbed.com/platforms/FRDM-KL27Z/", - "vendor": "Freescale" -} diff --git a/boards/frdm_kl82z.json b/boards/frdm_kl82z.json deleted file mode 100644 index 91e266b..0000000 --- a/boards/frdm_kl82z.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "build": { - "cpu": "cortex-m0plus", - "f_cpu": "96000000L", - "mcu": "mkl82z128vlk7" - }, - "debug": { - "jlink_device": "MKL82Z128xxx7" - }, - "frameworks": [ - "mbed" - ], - "name": "Freescale Kinetis FRDM-KL82Z", - "upload": { - "maximum_ram_size": 98304, - "maximum_size": 131072, - "protocol": "mbed", - "protocols": [ - "jlink", - "mbed" - ] - }, - "url": "https://www.nxp.com/products/processors-and-microcontrollers/arm-based-processors-and-mcus/kinetis-cortex-m-mcus/l-seriesultra-low-powerm0-plus/freedom-development-board-for-kinetis-ultra-low-power-kl82-mcus:FRDM-KL82Z", - "vendor": "Freescale" -} diff --git a/boards/frdm_kw24d.json b/boards/frdm_kw24d.json index 75f4dd7..2c5de78 100644 --- a/boards/frdm_kw24d.json +++ b/boards/frdm_kw24d.json @@ -11,7 +11,6 @@ "jlink_device": "MKW24D512xxx5" }, "frameworks": [ - "mbed", "zephyr" ], "name": "Freescale Kinetis FRDM-KW24D512", diff --git a/examples/mbed-legacy-examples/mbed-events/README.md b/examples/mbed-legacy-examples/mbed-events/README.md deleted file mode 100644 index 6b37c5f..0000000 --- a/examples/mbed-legacy-examples/mbed-events/README.md +++ /dev/null @@ -1,27 +0,0 @@ -How to build PlatformIO based project -===================================== - -1. [Install PlatformIO Core](https://docs.platformio.org/page/core.html) -2. Download [development platform with examples](https://github.com/platformio/platform-freescalekinetis/archive/develop.zip) -3. Extract ZIP archive -4. Run these commands: - -```shell -# Change directory to example -$ cd platform-freescalekinetis/examples/mbed-legacy-examples/mbed-events - -# Build project -$ pio run - -# Upload firmware -$ pio run --target upload - -# Build specific environment -$ pio run -e frdm_kl25z - -# Upload firmware for the specific environment -$ pio run -e frdm_kl25z --target upload - -# Clean build files -$ pio run --target clean -``` diff --git a/examples/mbed-legacy-examples/mbed-events/include/README b/examples/mbed-legacy-examples/mbed-events/include/README deleted file mode 100644 index 194dcd4..0000000 --- a/examples/mbed-legacy-examples/mbed-events/include/README +++ /dev/null @@ -1,39 +0,0 @@ - -This directory is intended for project header files. - -A header file is a file containing C declarations and macro definitions -to be shared between several project source files. You request the use of a -header file in your project source file (C, C++, etc) located in `src` folder -by including it, with the C preprocessing directive `#include'. - -```src/main.c - -#include "header.h" - -int main (void) -{ - ... -} -``` - -Including a header file produces the same results as copying the header file -into each source file that needs it. Such copying would be time-consuming -and error-prone. With a header file, the related declarations appear -in only one place. If they need to be changed, they can be changed in one -place, and programs that include the header file will automatically use the -new version when next recompiled. The header file eliminates the labor of -finding and changing all the copies as well as the risk that a failure to -find one copy will result in inconsistencies within a program. - -In C, the usual convention is to give header files names that end with `.h'. -It is most portable to use only letters, digits, dashes, and underscores in -header file names, and at most one dot. - -Read more about using header files in official GCC documentation: - -* Include Syntax -* Include Operation -* Once-Only Headers -* Computed Includes - -https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/examples/mbed-legacy-examples/mbed-events/lib/README b/examples/mbed-legacy-examples/mbed-events/lib/README deleted file mode 100644 index 6debab1..0000000 --- a/examples/mbed-legacy-examples/mbed-events/lib/README +++ /dev/null @@ -1,46 +0,0 @@ - -This directory is intended for project specific (private) libraries. -PlatformIO will compile them to static libraries and link into executable file. - -The source code of each library should be placed in a an own separate directory -("lib/your_library_name/[here are source files]"). - -For example, see a structure of the following two libraries `Foo` and `Bar`: - -|--lib -| | -| |--Bar -| | |--docs -| | |--examples -| | |--src -| | |- Bar.c -| | |- Bar.h -| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html -| | -| |--Foo -| | |- Foo.c -| | |- Foo.h -| | -| |- README --> THIS FILE -| -|- platformio.ini -|--src - |- main.c - -and a contents of `src/main.c`: -``` -#include -#include - -int main (void) -{ - ... -} - -``` - -PlatformIO Library Dependency Finder will find automatically dependent -libraries scanning project source files. - -More information about PlatformIO Library Dependency Finder -- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/examples/mbed-legacy-examples/mbed-events/platformio.ini b/examples/mbed-legacy-examples/mbed-events/platformio.ini deleted file mode 100644 index 85d93a8..0000000 --- a/examples/mbed-legacy-examples/mbed-events/platformio.ini +++ /dev/null @@ -1,19 +0,0 @@ -; PlatformIO Project Configuration File -; -; Build options: build flags, source filter, extra scripting -; Upload options: custom port, speed and extra flags -; Library options: dependencies, extra library storages -; -; Please visit documentation for the other options and examples -; https://docs.platformio.org/page/projectconf.html - -[env:frdm_k20d50m] -platform = freescalekinetis -framework = mbed -board = frdm_k20d50m - -[env:frdm_kl82z] -platform = freescalekinetis -framework = mbed -board = frdm_kl82z -build_flags = -DPIO_FRAMEWORK_MBED_RTOS_PRESENT diff --git a/examples/mbed-legacy-examples/mbed-events/src/main.cpp b/examples/mbed-legacy-examples/mbed-events/src/main.cpp deleted file mode 100644 index 8762cd4..0000000 --- a/examples/mbed-legacy-examples/mbed-events/src/main.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "mbed_events.h" -#include - -int main() { - // creates a queue with the default size - EventQueue queue; - - // events are simple callbacks - queue.call(printf, "called immediately\n"); - queue.call_in(2000, printf, "called in 2 seconds\n"); - queue.call_every(1000, printf, "called every 1 seconds\n"); - - // events are executed by the dispatch method - queue.dispatch(); -} diff --git a/examples/mbed-legacy-examples/mbed-events/test/README b/examples/mbed-legacy-examples/mbed-events/test/README deleted file mode 100644 index df5066e..0000000 --- a/examples/mbed-legacy-examples/mbed-events/test/README +++ /dev/null @@ -1,11 +0,0 @@ - -This directory is intended for PIO Unit Testing and project tests. - -Unit Testing is a software testing method by which individual units of -source code, sets of one or more MCU program modules together with associated -control data, usage procedures, and operating procedures, are tested to -determine whether they are fit for use. Unit testing finds problems early -in the development cycle. - -More information about PIO Unit Testing: -- https://docs.platformio.org/page/plus/unit-testing.html diff --git a/examples/mbed-legacy-examples/mbed-rtos-tls-client/README.md b/examples/mbed-legacy-examples/mbed-rtos-tls-client/README.md deleted file mode 100644 index e81d71f..0000000 --- a/examples/mbed-legacy-examples/mbed-rtos-tls-client/README.md +++ /dev/null @@ -1,21 +0,0 @@ -How to build PlatformIO based project -==================================== - -1. [Install PlatformIO Core](https://docs.platformio.org/page/core.html) -2. Download [development platform with examples](https://github.com/platformio/platform-freescalekinetis/archive/develop.zip) -3. Extract ZIP archive -4. Run these commands: - -```shell -# Change directory to example -$ cd platform-freescalekinetis/examples/mbed-legacy-examples/mbed-rtos-tls-client - -# Build project -$ pio run - -# Upload firmware -$ pio run --target upload - -# Clean build files -$ pio run --target clean -``` diff --git a/examples/mbed-legacy-examples/mbed-rtos-tls-client/include/README b/examples/mbed-legacy-examples/mbed-rtos-tls-client/include/README deleted file mode 100644 index 194dcd4..0000000 --- a/examples/mbed-legacy-examples/mbed-rtos-tls-client/include/README +++ /dev/null @@ -1,39 +0,0 @@ - -This directory is intended for project header files. - -A header file is a file containing C declarations and macro definitions -to be shared between several project source files. You request the use of a -header file in your project source file (C, C++, etc) located in `src` folder -by including it, with the C preprocessing directive `#include'. - -```src/main.c - -#include "header.h" - -int main (void) -{ - ... -} -``` - -Including a header file produces the same results as copying the header file -into each source file that needs it. Such copying would be time-consuming -and error-prone. With a header file, the related declarations appear -in only one place. If they need to be changed, they can be changed in one -place, and programs that include the header file will automatically use the -new version when next recompiled. The header file eliminates the labor of -finding and changing all the copies as well as the risk that a failure to -find one copy will result in inconsistencies within a program. - -In C, the usual convention is to give header files names that end with `.h'. -It is most portable to use only letters, digits, dashes, and underscores in -header file names, and at most one dot. - -Read more about using header files in official GCC documentation: - -* Include Syntax -* Include Operation -* Once-Only Headers -* Computed Includes - -https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/examples/mbed-legacy-examples/mbed-rtos-tls-client/lib/readme.txt b/examples/mbed-legacy-examples/mbed-rtos-tls-client/lib/readme.txt deleted file mode 100644 index 985c823..0000000 --- a/examples/mbed-legacy-examples/mbed-rtos-tls-client/lib/readme.txt +++ /dev/null @@ -1,38 +0,0 @@ - -This directory is intended for the project specific (private) libraries. -PlatformIO will compile them to static libraries and link to executable file. - -The source code of each library should be placed in separate directory, like -"lib/private_lib/[here are source files]". - -For example, see how can be organized `Foo` and `Bar` libraries: - -|--lib -| |--Bar -| | |--docs -| | |--examples -| | |--src -| | |- Bar.c -| | |- Bar.h -| |--Foo -| | |- Foo.c -| | |- Foo.h -| |- readme.txt --> THIS FILE -|- platformio.ini -|--src - |- main.c - -Then in `src/main.c` you should use: - -#include -#include - -// rest H/C/CPP code - -PlatformIO will find your libraries automatically, configure preprocessor's -include paths and build them. - -See additional options for PlatformIO Library Dependency Finder `lib_*`: - -https://docs.platformio.org/page/projectconf.html#lib-install - diff --git a/examples/mbed-legacy-examples/mbed-rtos-tls-client/mbed_app.json b/examples/mbed-legacy-examples/mbed-rtos-tls-client/mbed_app.json deleted file mode 100644 index 15a5ebf..0000000 --- a/examples/mbed-legacy-examples/mbed-rtos-tls-client/mbed_app.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "macros": [ - "MBED_CONF_APP_MAIN_STACK_SIZE=4096", - "MBEDTLS_USER_CONFIG_FILE=\"mbedtls_entropy_config.h\"" - ], - "config": { - "network-interface":{ - "help": "options are ETHERNET, WIFI_ESP8266, WIFI_ODIN, WIFI_IDW01M1, WIFI_RTW, MESH_LOWPAN_ND, MESH_THREAD", - "value": "ETHERNET" - }, - "esp8266-tx": { - "help": "Pin used as TX (connects to ESP8266 RX)", - "value": "PTD3" - }, - "esp8266-rx": { - "help": "Pin used as RX (connects to ESP8266 TX)", - "value": "PTD2" - }, - "esp8266-debug": { - "value": true - }, - "wifi-ssid": { - "value": "\"SSID\"" - }, - "wifi-password": { - "value": "\"Password\"" - } - }, - "target_overrides": { - "*": { - "platform.stdio-convert-newlines": true - } - } -} diff --git a/examples/mbed-legacy-examples/mbed-rtos-tls-client/platformio.ini b/examples/mbed-legacy-examples/mbed-rtos-tls-client/platformio.ini deleted file mode 100644 index 4328bd5..0000000 --- a/examples/mbed-legacy-examples/mbed-rtos-tls-client/platformio.ini +++ /dev/null @@ -1,16 +0,0 @@ -; PlatformIO Project Configuration File -; -; Build options: build flags, source filter, extra scripting -; Upload options: custom port, speed and extra flags -; Library options: dependencies, extra library storages -; -; Please visit documentation for the other options and examples -; https://docs.platformio.org/page/projectconf.html - -[env:frdm_k64f] -platform = freescalekinetis -framework = mbed -board = frdm_k64f -build_flags = -DPIO_FRAMEWORK_MBED_RTOS_PRESENT -platform_packages = - framework-mbed @ ~6.51506.0 diff --git a/examples/mbed-legacy-examples/mbed-rtos-tls-client/src/HelloHttpsClient.cpp b/examples/mbed-legacy-examples/mbed-rtos-tls-client/src/HelloHttpsClient.cpp deleted file mode 100644 index d1c05fd..0000000 --- a/examples/mbed-legacy-examples/mbed-rtos-tls-client/src/HelloHttpsClient.cpp +++ /dev/null @@ -1,382 +0,0 @@ -/* - * Hello world example of a TLS client: fetch an HTTPS page - * - * Copyright (C) 2006-2018, Arm Limited, All Rights Reserved - * 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. - * - * This file is part of Mbed TLS (https://tls.mbed.org) - */ - -#include "HelloHttpsClient.h" - -#include "mbedtls/platform.h" -#include "mbedtls/config.h" -#include "mbedtls/ssl.h" -#include "mbedtls/entropy.h" -#include "mbedtls/ctr_drbg.h" -#include "mbedtls/error.h" -#include "mbedtls/debug.h" -#include "mbedtls/x509.h" - -#include -#include -#include "mbed.h" - -const char *HelloHttpsClient::DRBG_PERSONALIZED_STR = - "Mbed TLS helloword client"; - -const size_t HelloHttpsClient::ERROR_LOG_BUFFER_LENGTH = 128; - -const char *HelloHttpsClient::TLS_PEM_CA = - "-----BEGIN CERTIFICATE-----\n" - "MIIDQTCCAimgAwIBAgITBmyfz5m/jAo54vB4ikPmljZbyjANBgkqhkiG9w0BAQsF\n" - "ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6\n" - "b24gUm9vdCBDQSAxMB4XDTE1MDUyNjAwMDAwMFoXDTM4MDExNzAwMDAwMFowOTEL\n" - "MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJv\n" - "b3QgQ0EgMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALJ4gHHKeNXj\n" - "ca9HgFB0fW7Y14h29Jlo91ghYPl0hAEvrAIthtOgQ3pOsqTQNroBvo3bSMgHFzZM\n" - "9O6II8c+6zf1tRn4SWiw3te5djgdYZ6k/oI2peVKVuRF4fn9tBb6dNqcmzU5L/qw\n" - "IFAGbHrQgLKm+a/sRxmPUDgH3KKHOVj4utWp+UhnMJbulHheb4mjUcAwhmahRWa6\n" - "VOujw5H5SNz/0egwLX0tdHA114gk957EWW67c4cX8jJGKLhD+rcdqsq08p8kDi1L\n" - "93FcXmn/6pUCyziKrlA4b9v7LWIbxcceVOF34GfID5yHI9Y/QCB/IIDEgEw+OyQm\n" - "jgSubJrIqg0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC\n" - "AYYwHQYDVR0OBBYEFIQYzIU07LwMlJQuCFmcx7IQTgoIMA0GCSqGSIb3DQEBCwUA\n" - "A4IBAQCY8jdaQZChGsV2USggNiMOruYou6r4lK5IpDB/G/wkjUu0yKGX9rbxenDI\n" - "U5PMCCjjmCXPI6T53iHTfIUJrU6adTrCC2qJeHZERxhlbI1Bjjt/msv0tadQ1wUs\n" - "N+gDS63pYaACbvXy8MWy7Vu33PqUXHeeE6V/Uq2V8viTO96LXFvKWlJbYK8U90vv\n" - "o/ufQJVtMVT8QtPHRh8jrdkPSHCa2XV4cdFyQzR1bldZwgJcJmApzyMZFo6IQ6XU\n" - "5MsI+yMRQ+hDKXJioaldXgjUkK642M4UwtBV8ob2xJNDd2ZhwLnoQdeXeGADbkpy\n" - "rqXRfboQnoZsG4q5WTP468SQvvG5\n" - "-----END CERTIFICATE-----\n"; - -const char *HelloHttpsClient::HTTP_REQUEST_FILE_PATH = - "/media/uploads/mbed_official/hello.txt"; - -const char *HelloHttpsClient::HTTP_HELLO_STR = "Hello world!"; - -const char *HelloHttpsClient::HTTP_OK_STR = "200 OK"; - -HelloHttpsClient::HelloHttpsClient(const char *in_server_name, - const char *in_server_addr, - const uint16_t in_server_port) : - socket(), - server_name(in_server_name), - server_addr(in_server_addr), - server_port(in_server_port) -{ - mbedtls_entropy_init(&entropy); - mbedtls_ctr_drbg_init(&ctr_drbg); - mbedtls_x509_crt_init(&cacert); - mbedtls_ssl_init(&ssl); - mbedtls_ssl_config_init(&ssl_conf); -} - -HelloHttpsClient::~HelloHttpsClient() -{ - mbedtls_entropy_free(&entropy); - mbedtls_ctr_drbg_free(&ctr_drbg); - mbedtls_x509_crt_free(&cacert); - mbedtls_ssl_free(&ssl); - mbedtls_ssl_config_free(&ssl_conf); - - socket.close(); -} - -int HelloHttpsClient::run() -{ - int ret; - size_t req_len, req_offset, resp_offset; - uint32_t flags; - bool resp_200, resp_hello; - - /* Configure the TCPSocket */ - if ((ret = configureTCPSocket()) != 0) - return ret; - - /* Configure already initialized Mbed TLS structures */ - if ((ret = configureTlsContexts()) != 0) - return ret; - - /* Start a connection to the server */ - if ((ret = socket.connect(server_addr, server_port)) != NSAPI_ERROR_OK) { - mbedtls_printf("socket.connect() returned %d\n", ret); - return ret; - } - mbedtls_printf("Successfully connected to %s at port %u\n", - server_addr, server_port); - - /* Start the TLS handshake */ - mbedtls_printf("Starting the TLS handshake...\n"); - do { - ret = mbedtls_ssl_handshake(&ssl); - } while(ret != 0 && - (ret == MBEDTLS_ERR_SSL_WANT_READ || - ret == MBEDTLS_ERR_SSL_WANT_WRITE)); - if (ret < 0) { - mbedtls_printf("mbedtls_ssl_handshake() returned -0x%04X\n", -ret); - return ret; - } - mbedtls_printf("Successfully completed the TLS handshake\n"); - - /* Fill the request buffer */ - ret = snprintf(gp_buf, sizeof(gp_buf), - "GET %s HTTP/1.1\r\nHost: %s\r\n\r\n", HTTP_REQUEST_FILE_PATH, - server_name); - req_len = static_cast(ret); - if (ret < 0 || req_len >= sizeof(gp_buf)) { - mbedtls_printf("Failed to compose HTTP request using snprintf: %d\n", - ret); - return ret; - } - - /* Send the HTTP request to the server over TLS */ - req_offset = 0; - do { - ret = mbedtls_ssl_write(&ssl, - reinterpret_cast(gp_buf + req_offset), - req_len - req_offset); - if (ret > 0) - req_offset += static_cast(ret); - } - while(req_offset < req_len && - (ret > 0 || - ret == MBEDTLS_ERR_SSL_WANT_WRITE || - ret == MBEDTLS_ERR_SSL_WANT_READ)); - if (ret < 0) { - mbedtls_printf("mbedtls_ssl_write() returned -0x%04X\n", -ret); - return ret; - } - - /* Print information about the TLS connection */ - ret = mbedtls_x509_crt_info(gp_buf, sizeof(gp_buf), - "\r ", mbedtls_ssl_get_peer_cert(&ssl)); - if (ret < 0) { - mbedtls_printf("mbedtls_x509_crt_info() returned -0x%04X\n", -ret); - return ret; - } - mbedtls_printf("Server certificate:\n%s\n", gp_buf); - - /* Ensure certificate verification was successful */ - flags = mbedtls_ssl_get_verify_result(&ssl); - if (flags != 0) { - ret = mbedtls_x509_crt_verify_info(gp_buf, sizeof(gp_buf), - "\r ! ", flags); - if (ret < 0) { - mbedtls_printf("mbedtls_x509_crt_verify_info() returned " - "-0x%04X\n", -ret); - return ret; - } else { - mbedtls_printf("Certificate verification failed (flags %lu):" - "\n%s\n", flags, gp_buf); - return -1; - } - } else { - mbedtls_printf("Certificate verification passed\n"); - } - - mbedtls_printf("Established TLS connection to %s\n", server_name); - - /* Read response from the server */ - resp_offset = 0; - resp_200 = false; - resp_hello = false; - do { - ret = mbedtls_ssl_read(&ssl, - reinterpret_cast(gp_buf + resp_offset), - sizeof(gp_buf) - resp_offset - 1); - if (ret > 0) - resp_offset += static_cast(ret); - - /* Ensure that the response string is null-terminated */ - gp_buf[resp_offset] = '\0'; - - /* Check if we received expected string */ - resp_200 = resp_200 || strstr(gp_buf, HTTP_OK_STR) != NULL; - resp_hello = resp_hello || strstr(gp_buf, HTTP_HELLO_STR) != NULL; - } while((!resp_200 || !resp_hello) && - (ret > 0 || - ret == MBEDTLS_ERR_SSL_WANT_READ || MBEDTLS_ERR_SSL_WANT_WRITE)); - if (ret < 0) { - mbedtls_printf("mbedtls_ssl_read() returned -0x%04X\n", -ret); - return ret; - } - - /* Display response information */ - mbedtls_printf("HTTP: Received %u chars from server\n", resp_offset); - mbedtls_printf("HTTP: Received '%s' status ... %s\n", HTTP_OK_STR, - resp_200 ? "OK" : "FAIL"); - mbedtls_printf("HTTP: Received message:\n%s\n", gp_buf); - - return 0; -} - -int HelloHttpsClient::configureTCPSocket() -{ - int ret; - - NetworkInterface *network = NetworkInterface::get_default_instance(); - if(network == NULL) { - mbedtls_printf("ERROR: No network interface found!\n"); - return -1; - } - ret = network->connect(); - if (ret != 0) { - mbedtls_printf("Error! network->connect() returned: %d\n", ret); - return ret; - } - - if ((ret = socket.open(network)) != NSAPI_ERROR_OK) { - mbedtls_printf("socket.open() returned %d\n", ret); - return ret; - } - - socket.set_blocking(false); - - return 0; -} - -int HelloHttpsClient::configureTlsContexts() -{ - int ret; - - ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, - reinterpret_cast(DRBG_PERSONALIZED_STR), - strlen(DRBG_PERSONALIZED_STR) + 1); - if (ret != 0) { - mbedtls_printf("mbedtls_ctr_drbg_seed() returned -0x%04X\n", -ret); - return ret; - } - - ret = mbedtls_x509_crt_parse(&cacert, - reinterpret_cast(TLS_PEM_CA), - strlen(TLS_PEM_CA) + 1); - if (ret != 0) { - mbedtls_printf("mbedtls_x509_crt_parse() returned -0x%04X\n", -ret); - return ret; - } - - ret = mbedtls_ssl_config_defaults(&ssl_conf, MBEDTLS_SSL_IS_CLIENT, - MBEDTLS_SSL_TRANSPORT_STREAM, - MBEDTLS_SSL_PRESET_DEFAULT); - if (ret != 0) { - mbedtls_printf("mbedtls_ssl_config_defaults() returned -0x%04X\n", - -ret); - return ret; - } - - mbedtls_ssl_conf_ca_chain(&ssl_conf, &cacert, NULL); - mbedtls_ssl_conf_rng(&ssl_conf, mbedtls_ctr_drbg_random, &ctr_drbg); - - /* - * It is possible to disable authentication by passing - * MBEDTLS_SSL_VERIFY_NONE in the call to mbedtls_ssl_conf_authmode() - */ - mbedtls_ssl_conf_authmode(&ssl_conf, MBEDTLS_SSL_VERIFY_REQUIRED); - - /* Configure certificate verification function to clear time/date flags */ - mbedtls_ssl_conf_verify(&ssl_conf, sslVerify, this); - -#if HELLO_HTTPS_CLIENT_DEBUG_LEVEL > 0 - mbedtls_ssl_conf_dbg(&ssl_conf, sslDebug, NULL); - mbedtls_debug_set_threshold(HELLO_HTTPS_CLIENT_DEBUG_LEVEL); -#endif /* HELLO_HTTPS_CLIENT_DEBUG_LEVEL > 0 */ - - if ((ret = mbedtls_ssl_setup( &ssl, &ssl_conf)) != 0) { - mbedtls_printf("mbedtls_ssl_setup() returned -0x%04X\n", -ret); - return ret; - } - - if ((ret = mbedtls_ssl_set_hostname( &ssl, server_name )) != 0) { - mbedtls_printf("mbedtls_ssl_set_hostname() returned -0x%04X\n", - -ret); - return ret; - } - - mbedtls_ssl_set_bio(&ssl, static_cast(&socket), sslSend, sslRecv, - NULL); - - return 0; -} - -int HelloHttpsClient::sslRecv(void *ctx, unsigned char *buf, size_t len) -{ - TCPSocket *socket = static_cast(ctx); - int ret = socket->recv(buf, len); - - if (ret == NSAPI_ERROR_WOULD_BLOCK) - ret = MBEDTLS_ERR_SSL_WANT_READ; - else if (ret < 0) - mbedtls_printf("socket.recv() returned %d\n", ret); - - return ret; -} - -int HelloHttpsClient::sslSend(void *ctx, const unsigned char *buf, size_t len) -{ - TCPSocket *socket = static_cast(ctx); - int ret = socket->send(buf, len); - - if (ret == NSAPI_ERROR_WOULD_BLOCK) - ret = MBEDTLS_ERR_SSL_WANT_WRITE; - else if (ret < 0) - mbedtls_printf("socket.send() returned %d\n", ret); - - return ret; -} - -void HelloHttpsClient::sslDebug(void *ctx, int level, const char *file, - int line, const char *str) -{ - (void)ctx; - - const char *p, *basename; - - /* Extract basename from file */ - for (p = basename = file; *p != '\0'; p++) { - if (*p == '/' || *p == '\\') - basename = p + 1; - } - - mbedtls_printf("%s:%d: |%d| %s\r", basename, line, level, str); -} - -int HelloHttpsClient::sslVerify(void *ctx, mbedtls_x509_crt *crt, int depth, - uint32_t *flags) -{ - int ret = 0; - - /* - * If MBEDTLS_HAVE_TIME_DATE is defined, then the certificate date and time - * validity checks will probably fail because this application does not set - * up the clock correctly. We filter out date and time related failures - * instead - */ - *flags &= ~MBEDTLS_X509_BADCERT_FUTURE & ~MBEDTLS_X509_BADCERT_EXPIRED; - -#if HELLO_HTTPS_CLIENT_DEBUG_LEVEL > 0 - HelloHttpsClient *client = static_cast(ctx); - - ret = mbedtls_x509_crt_info(client->gp_buf, sizeof(gp_buf), "\r ", crt); - if (ret < 0) { - mbedtls_printf("mbedtls_x509_crt_info() returned -0x%04X\n", -ret); - } else { - ret = 0; - mbedtls_printf("Verifying certificate at depth %d:\n%s\n", - depth, client->gp_buf); - } -#endif /* HELLO_HTTPS_CLIENT_DEBUG_LEVEL > 0 */ - - return ret; -} diff --git a/examples/mbed-legacy-examples/mbed-rtos-tls-client/src/HelloHttpsClient.h b/examples/mbed-legacy-examples/mbed-rtos-tls-client/src/HelloHttpsClient.h deleted file mode 100644 index 0be0f05..0000000 --- a/examples/mbed-legacy-examples/mbed-rtos-tls-client/src/HelloHttpsClient.h +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Hello world example of a TLS client: fetch an HTTPS page - * - * Copyright (C) 2006-2018, Arm Limited, All Rights Reserved - * 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. - * - * This file is part of Mbed TLS (https://tls.mbed.org) - */ - -#ifndef _HELLOHTTPSCLIENT_H_ -#define _HELLOHTTPSCLIENT_H_ - -#include "TCPSocket.h" - -#include "mbedtls/config.h" -#include "mbedtls/ssl.h" -#include "mbedtls/entropy.h" -#include "mbedtls/ctr_drbg.h" -#include "mbedtls/error.h" -#include "mbedtls/debug.h" - -#include - -/** - * Change to a number between 1 and 4 to debug the TLS connection - */ -#define HELLO_HTTPS_CLIENT_DEBUG_LEVEL 0 - -/** - * Length (in bytes) for generic buffers used to hold debug or HTTP - * request/response strings - */ -#define GENERAL_PURPOSE_BUFFER_LENGTH 1024 - -/** - * This class implements the logic for fetching a file from a webserver using - * a TCP socket and parsing the result. - */ -class HelloHttpsClient -{ -public: - /** - * Construct an HelloHttpsClient instance - * - * \param[in] in_server_name - * The server host name - * \param[in] in_server_addr - * The server domain/IP address - * \param[in] in_server_port - * The server port - */ - HelloHttpsClient(const char *in_server_name, - const char *in_server_addr, - const uint16_t in_server_port); - - /** - * Free any allocated resources - */ - ~HelloHttpsClient(); - - /** - * Start the connection to the server and request to read the file at - * HTTP_REQUEST_FILE_PATH - * - * \return 0 if successful - */ - int run(); - -private: - /** - * Create a TCPSocket object that can be used to communicate with the server - */ - int configureTCPSocket(); - - /** - * Configure the Mbed TLS structures required to establish a TLS connection - * with the server - */ - int configureTlsContexts(); - - /** - * Wrapper function around TCPSocket that gets called by Mbed TLS whenever - * we call mbedtls_ssl_read() - * - * \param[in] ctx - * The TCPSocket object - * \param[in] buf - * Buffer where data received will be stored - * \param[in] len - * The length (in bytes) of the buffer - * - * \return If successful, the number of bytes received, a negative value - * otherwise. - */ - static int sslRecv(void *ctx, unsigned char *buf, size_t len); - - /** - * Wrapper function around TCPSocket that gets called by Mbed TLS whenever - * we call mbedtls_ssl_write() - * - * \param[in] ctx - * The TCPSocket object - * \param[in] buf - * Buffer containing the data to be sent - * \param[in] len - * The number of bytes to send - * - * \return If successful, the number of bytes sent, a negative value - * otherwise - */ - static int sslSend(void *ctx, const unsigned char *buf, size_t len); - - /** - * Callback to handle debug prints to serial - * - * \param[in] ctx - * The context (unused in this case) - * \param[in] level - * The current debug level - * \param[in] file - * The C file that is logging this message - * \param[in] line - * The line number in the file - * \param[in] str - * The string to log to serial - */ - static void sslDebug(void *ctx, int level, const char *file, int line, - const char *str); - - /** - * Callback to handle certificate verification - * - * /param[in] data - * (unused) - * /param[in] crt - * The crt in the chain that we are verifying - * /param[in] depth - * The depth of the current certificate in the chain - * /param[in/out] flags - * The flags resulting from the verification - * - * /return 0 if successful - */ - static int sslVerify(void *ctx, mbedtls_x509_crt *crt, int depth, - uint32_t *flags); - -private: - /** - * Personalization string for the drbg - */ - static const char *DRBG_PERSONALIZED_STR; - - /** - * Length of error string buffer for logging failures related to Mbed TLS - */ - static const size_t ERROR_LOG_BUFFER_LENGTH; - - /** - * Chain of trusted CAs in PEM format - */ - static const char *TLS_PEM_CA; - - /** - * Path to the file that will be requested from the server - */ - static const char *HTTP_REQUEST_FILE_PATH; - - /** - * Expected strings in the HTTP response from the server - */ - static const char *HTTP_OK_STR; - - /** - * Expected strings in the HTTP response from the server - */ - static const char *HTTP_HELLO_STR; - - /** - * Instance of TCPSocket used to communicate with the server - */ - TCPSocket socket; - - /** - * The server host name to contact - */ - const char *server_name; - - /** - * The domain/IP address of the server to contact - */ - const char *server_addr; - /** - * The port number to use in the connection - */ - const uint16_t server_port; - - /** - * A generic buffer used to hold debug or HTTP request/response strings - */ - char gp_buf[GENERAL_PURPOSE_BUFFER_LENGTH]; - - /** - * Entropy context used to seed the DRBG to use in the TLS connection - */ - mbedtls_entropy_context entropy; - /** - * The DRBG used throughout the TLS connection - */ - mbedtls_ctr_drbg_context ctr_drbg; - /** - * The parsed chain of trusted CAs - */ - mbedtls_x509_crt cacert; - /** - * THe TLS context - */ - mbedtls_ssl_context ssl; - /** - * The TLS configuration in use - */ - mbedtls_ssl_config ssl_conf; -}; - -#endif /* _HELLOHTTPSCLIENT_H_ */ diff --git a/examples/mbed-legacy-examples/mbed-rtos-tls-client/src/main.cpp b/examples/mbed-legacy-examples/mbed-rtos-tls-client/src/main.cpp deleted file mode 100644 index 77f54fc..0000000 --- a/examples/mbed-legacy-examples/mbed-rtos-tls-client/src/main.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Hello world example of a TLS client: fetch an HTTPS page - * - * Copyright (C) 2006-2018, Arm Limited, All Rights Reserved - * 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. - * - * This file is part of Mbed TLS (https://tls.mbed.org) - */ - -/** - * \file main.cpp - * - * \brief An example TLS Client application - * - * This application sends an HTTPS request to os.mbed.com and searches - * for a string in the result. - * - * This example is implemented as a logic class (HelloHttpsClient) wrapping a - * TCP socket. The logic class handles all events, leaving the main loop to just - * check if the process has finished. - */ - -#include "mbed.h" - -#include "mbedtls/platform.h" -#if defined(MBEDTLS_USE_PSA_CRYPTO) -#include "psa/crypto.h" -#endif /* MBEDTLS_USE_PSA_CRYPTO */ - -#include "HelloHttpsClient.h" - -/* Domain/IP address of the server to contact */ -const char SERVER_NAME[] = "os.mbed.com"; -const char SERVER_ADDR[] = "os.mbed.com"; - -/* Port used to connect to the server */ -const int SERVER_PORT = 443; - -/** - * The main function driving the HTTPS client. - */ -int main() -{ - int exit_code = MBEDTLS_EXIT_FAILURE; - - if((exit_code = mbedtls_platform_setup(NULL)) != 0) { - printf("Platform initialization failed with error %d\r\n", exit_code); - return MBEDTLS_EXIT_FAILURE; - } - -#if defined(MBEDTLS_USE_PSA_CRYPTO) - /* - * Initialize underlying PSA Crypto implementation. - * Even if the HTTPS client doesn't make use of - * PSA-specific API, for example for setting opaque PSKs - * or opaque private keys, Mbed TLS will use PSA - * for public and symmetric key operations as well as - * hashing. - */ - psa_status_t status; - status = psa_crypto_init(); - if( status != PSA_SUCCESS ) - { - printf("psa_crypto_init() failed with %d\r\n", status ); - return MBEDTLS_EXIT_FAILURE; - } -#endif /* MBEDTLS_USE_PSA_CRYPTO */ - - /* - * The default 9600 bps is too slow to print full TLS debug info and could - * cause the other party to time out. - */ - - HelloHttpsClient *client; - - mbedtls_printf("Starting mbed-os-example-tls/tls-client\n"); - -#if defined(MBED_MAJOR_VERSION) - mbedtls_printf("Using Mbed OS %d.%d.%d\n", - MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION); -#else - printf("Using Mbed OS from master.\n"); -#endif /* MBEDTLS_MAJOR_VERSION */ - - /* Allocate a HTTPS client */ - client = new (std::nothrow) HelloHttpsClient(SERVER_NAME, SERVER_ADDR, SERVER_PORT); - - if (client == NULL) { - mbedtls_printf("Failed to allocate HelloHttpsClient object\n" - "\nFAIL\n"); - mbedtls_platform_teardown(NULL); - return exit_code; - } - - /* Run the client */ - if (client->run() != 0) { - mbedtls_printf("\nFAIL\n"); - } else { - exit_code = MBEDTLS_EXIT_SUCCESS; - mbedtls_printf("\nDONE\n"); - } - - delete client; - - mbedtls_platform_teardown(NULL); - return exit_code; -} diff --git a/examples/mbed-legacy-examples/mbed-rtos-tls-client/src/mbedtls_entropy_config.h b/examples/mbed-legacy-examples/mbed-rtos-tls-client/src/mbedtls_entropy_config.h deleted file mode 100644 index d0b032e..0000000 --- a/examples/mbed-legacy-examples/mbed-rtos-tls-client/src/mbedtls_entropy_config.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2006-2018, Arm Limited, All Rights Reserved - * 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. - * - * This file is part of Mbed TLS (https://tls.mbed.org) - */ - -#if !defined(MBEDTLS_ENTROPY_HARDWARE_ALT) && \ - !defined(MBEDTLS_ENTROPY_NV_SEED) && !defined(MBEDTLS_TEST_NULL_ENTROPY) -#error "This hardware does not have an entropy source." -#endif /* !MBEDTLS_ENTROPY_HARDWARE_ALT && !MBEDTLS_ENTROPY_NV_SEED && - * !MBEDTLS_TEST_NULL_ENTROPY */ - -#if !defined(MBEDTLS_SHA1_C) -#define MBEDTLS_SHA1_C -#endif /* !MBEDTLS_SHA1_C */ - -/* - * This value is sufficient for handling 2048 bit RSA keys. - * - * Set this value higher to enable handling larger keys, but be aware that this - * will increase the stack usage. - */ -#undef MBEDTLS_MPI_MAX_SIZE -#define MBEDTLS_MPI_MAX_SIZE 256 - -/* This macro determines whether Mbed TLS uses its own legacy crypto library - * or an implementation of the PSA Crypto API such as Mbed Crypto. - * - * To confirm the use of PSA Crypto, you may enable debugging by setting - * HELLO_HTTPS_CLIENT_DEBUG_LEVEL in HelloHttpsClient.h and look for - * PSA-related debugging output on the serial line. - * - * Uncomment this to use the PSA Crypto API. */ -//#define MBEDTLS_USE_PSA_CRYPTO - -#define MBEDTLS_MPI_WINDOW_SIZE 1 diff --git a/examples/mbed-legacy-examples/mbed-rtos-tls-client/test/README b/examples/mbed-legacy-examples/mbed-rtos-tls-client/test/README deleted file mode 100644 index df5066e..0000000 --- a/examples/mbed-legacy-examples/mbed-rtos-tls-client/test/README +++ /dev/null @@ -1,11 +0,0 @@ - -This directory is intended for PIO Unit Testing and project tests. - -Unit Testing is a software testing method by which individual units of -source code, sets of one or more MCU program modules together with associated -control data, usage procedures, and operating procedures, are tested to -determine whether they are fit for use. Unit testing finds problems early -in the development cycle. - -More information about PIO Unit Testing: -- https://docs.platformio.org/page/plus/unit-testing.html diff --git a/misc/mbed_deprecated_boards.json b/misc/mbed_deprecated_boards.json deleted file mode 100644 index 107984a..0000000 --- a/misc/mbed_deprecated_boards.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - "frdm_kl05z", - "frdm_kl82z", - "frdm_kl27z", - "frdm_k20d50m", - "frdm_kw24d" -] diff --git a/platform.json b/platform.json index 3f0c6fd..6c681b9 100644 --- a/platform.json +++ b/platform.json @@ -42,10 +42,7 @@ "type": "framework", "optional": true, "owner": "platformio", - "version": "~6.60900.0", - "optionalVersions": [ - "~6.51506.0" - ] + "version": "~6.60900.0" }, "framework-zephyr": { "type": "framework", diff --git a/platform.py b/platform.py index cb574f6..17ba2b4 100644 --- a/platform.py +++ b/platform.py @@ -30,12 +30,6 @@ def configure_default_packages(self, variables, targets): board = variables.get("board") frameworks = variables.get("pioframework", []) if "mbed" in frameworks: - deprecated_boards_file = os.path.join( - self.get_dir(), "misc", "mbed_deprecated_boards.json") - if os.path.isfile(deprecated_boards_file): - with open(deprecated_boards_file) as fp: - if board in json.load(fp): - self.packages["framework-mbed"]["version"] = "~6.51506.0" self.packages["toolchain-gccarmnoneeabi"]["version"] = "~1.90201.0" if "zephyr" in frameworks: From 4ab0007c22fcb837b0ac3cb5a6a162c5b0d7b998 Mon Sep 17 00:00:00 2001 From: valeros Date: Wed, 19 Jul 2023 14:13:25 +0300 Subject: [PATCH 3/4] Update mbed framework to v6.17.0 --- examples/mbed-legacy-examples/mbed-events/.gitignore | 1 - .../mbed-rtos-tls-client/.gitignore | 1 - examples/mbed-rtos-blink-baremetal/mbed_app.json | 11 +++++++++++ examples/mbed-rtos-ethernet-tls/.mbedignore | 2 ++ examples/mbed-rtos-kvstore/.mbedignore | 2 ++ examples/mbed-rtos-psa/.mbedignore | 3 +++ examples/mbed-rtos-usb-msd/.mbedignore | 2 ++ platform.json | 2 +- 8 files changed, 21 insertions(+), 3 deletions(-) delete mode 100644 examples/mbed-legacy-examples/mbed-events/.gitignore delete mode 100644 examples/mbed-legacy-examples/mbed-rtos-tls-client/.gitignore create mode 100644 examples/mbed-rtos-blink-baremetal/mbed_app.json create mode 100644 examples/mbed-rtos-ethernet-tls/.mbedignore create mode 100644 examples/mbed-rtos-kvstore/.mbedignore create mode 100644 examples/mbed-rtos-psa/.mbedignore create mode 100644 examples/mbed-rtos-usb-msd/.mbedignore diff --git a/examples/mbed-legacy-examples/mbed-events/.gitignore b/examples/mbed-legacy-examples/mbed-events/.gitignore deleted file mode 100644 index 03f4a3c..0000000 --- a/examples/mbed-legacy-examples/mbed-events/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.pio diff --git a/examples/mbed-legacy-examples/mbed-rtos-tls-client/.gitignore b/examples/mbed-legacy-examples/mbed-rtos-tls-client/.gitignore deleted file mode 100644 index 03f4a3c..0000000 --- a/examples/mbed-legacy-examples/mbed-rtos-tls-client/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.pio diff --git a/examples/mbed-rtos-blink-baremetal/mbed_app.json b/examples/mbed-rtos-blink-baremetal/mbed_app.json new file mode 100644 index 0000000..d04688f --- /dev/null +++ b/examples/mbed-rtos-blink-baremetal/mbed_app.json @@ -0,0 +1,11 @@ +{ + "requires": ["bare-metal"], + "target_overrides": { + "*": { + "target.c_lib": "small", + "target.printf_lib": "minimal-printf", + "platform.minimal-printf-enable-floating-point": false, + "platform.stdio-minimal-console-only": true + } + } +} diff --git a/examples/mbed-rtos-ethernet-tls/.mbedignore b/examples/mbed-rtos-ethernet-tls/.mbedignore new file mode 100644 index 0000000..39e17e7 --- /dev/null +++ b/examples/mbed-rtos-ethernet-tls/.mbedignore @@ -0,0 +1,2 @@ +mbed-os/features/* +mbed-os/storage/* diff --git a/examples/mbed-rtos-kvstore/.mbedignore b/examples/mbed-rtos-kvstore/.mbedignore new file mode 100644 index 0000000..98c51ea --- /dev/null +++ b/examples/mbed-rtos-kvstore/.mbedignore @@ -0,0 +1,2 @@ +mbed-os/connectivity/* +mbed-os/features/* diff --git a/examples/mbed-rtos-psa/.mbedignore b/examples/mbed-rtos-psa/.mbedignore new file mode 100644 index 0000000..0b9808b --- /dev/null +++ b/examples/mbed-rtos-psa/.mbedignore @@ -0,0 +1,3 @@ +mbed-os/connectivity/* +mbed-os/features/* +mbed-os/storage/* diff --git a/examples/mbed-rtos-usb-msd/.mbedignore b/examples/mbed-rtos-usb-msd/.mbedignore new file mode 100644 index 0000000..98c51ea --- /dev/null +++ b/examples/mbed-rtos-usb-msd/.mbedignore @@ -0,0 +1,2 @@ +mbed-os/connectivity/* +mbed-os/features/* diff --git a/platform.json b/platform.json index 6c681b9..a6d195a 100644 --- a/platform.json +++ b/platform.json @@ -42,7 +42,7 @@ "type": "framework", "optional": true, "owner": "platformio", - "version": "~6.60900.0" + "version": "~6.61700.0" }, "framework-zephyr": { "type": "framework", From 966880498f3ef0a2cd1b96479be2752b5afbf1a5 Mon Sep 17 00:00:00 2001 From: valeros Date: Fri, 28 Jul 2023 13:59:00 +0300 Subject: [PATCH 4/4] Bump version to 10.0.0 --- platform.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform.json b/platform.json index a6d195a..cb3bd6a 100644 --- a/platform.json +++ b/platform.json @@ -18,7 +18,7 @@ "type": "git", "url": "https://github.com/platformio/platform-freescalekinetis.git" }, - "version": "9.2.0", + "version": "10.0.0", "frameworks": { "mbed": { "package": "framework-mbed",