diff --git a/ide/STM32CUBE/README.md b/ide/STM32CUBE/README.md new file mode 100644 index 00000000..4284a13d --- /dev/null +++ b/ide/STM32CUBE/README.md @@ -0,0 +1,22 @@ +# wolfSSH for STM32 Cube IDE + +The wolfSSH Cube Pack can be found [here](https://www.wolfssl.com/files/ide/I-CUBE-wolfSSH.pack) + +1. The first step is to setup the wolfCrypt library in your ST project following the guide here [https://github.com/wolfSSL/wolfssl/blob/master/IDE/STM32Cube/README.md](https://github.com/wolfSSL/wolfssl/blob/master/IDE/STM32Cube/README.md). To run the wolfSSH unit tests, name the entry function `wolfSSHTest` instead of `wolfCryptDemo`. + +2. Then install the wolfSSH Cube Pack in the same manner as the wolfSSL pack with CUBEMX. + +3. Open the project `.ioc` file and click the `Softare Packs` drop down menu and then `Select Components`. Expand the `wolfSSH` pack and check all the components. + +4. In the `Softare Packs` configuration category of the `.ioc` file, click on the wolfSSH pack and enable the library by checking the box. + +5. Since LwIP is a dependency for the Cube Pack, enable LwIP in the `Middleware` configuration category of the project. Also enable the `LWIP_DNS` option in the LwIP configuration settings. + +6. Save your changes and select yes to the prompt asking about generating code. + +7. Build the project and run the unit tests. + +## Notes +- Make sure to make [these changes](https://github.com/wolfSSL/wolfssl/tree/master/IDE/STM32Cube#stm32-printf) to redirect the printf's to the UART. + +- If looking to enable filesystem support, the pack assumes the user has defined their own filesystem in `wolfssh/myFilesystem.h`. That file will originally contain a dummy filesystem. If going the FATFS route, make sure to replace `#define WOLFSSH_USER_FILESYSTEM` with `#define WOLFSSH_FATFS` in the `wolfSSL.I-CUBE-wolfSSH_conf.h` header file. The wolfSSL Cube Pack also defaults to disabling filesystem support so make sure to remove `#define NO_FILESYSTEM` from `wolfSSL.I-CUBE-wolfSSL_conf.h`. diff --git a/ide/STM32CUBE/wolfssh_test.c b/ide/STM32CUBE/wolfssh_test.c new file mode 100644 index 00000000..2197480a --- /dev/null +++ b/ide/STM32CUBE/wolfssh_test.c @@ -0,0 +1,60 @@ +/* wolfssh_test.c + * + * Copyright (C) 2006-2023 wolfSSL Inc. + * + * This file is part of wolfSSL. + * + * wolfSSL is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * wolfSSL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA + */ + +#include "wolfssh_test.h" + +#ifndef SINGLE_THREADED + #include + + #ifdef WOLFSSL_DEBUG_MEMORY + /* for memory debugging */ + #include + #endif +#endif + +#include +#include + + +#ifdef CMSIS_OS2_H_ +void wolfSSHTest(void* argument) +#else +void wolfSSHTest(const void* argument) +#endif +{ + int ret = 0; +#if 0 + wolfSSL_Debugging_ON(); + wolfSSH_Debugging_ON(); +#endif + + printf("Running wolfSSH Tests...\n"); + + if (wolfSSH_TestsuiteTest(0, NULL)) + ret = -1; + if (wolfSSH_UnitTest(0, NULL)) + ret = -1; + if (wolfSSH_ApiTest(0, NULL)) + ret = -1; + + printf("wolfSSH Test: Return code %d\n", ret); + +} diff --git a/ide/STM32CUBE/wolfssh_test.h b/ide/STM32CUBE/wolfssh_test.h new file mode 100644 index 00000000..e0d89d70 --- /dev/null +++ b/ide/STM32CUBE/wolfssh_test.h @@ -0,0 +1,43 @@ +/* wolfssh_test.h + * + * Copyright (C) 2006-2023 wolfSSL Inc. + * + * This file is part of wolfSSL. + * + * wolfSSL is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * wolfSSL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA + */ + +#ifndef WOLFSSH_TEST_H_ +#define WOLFSSH_TEST_H_ + +#ifdef HAVE_CONFIG_H + #include +#endif + +#include "../../tests/unit.h" +#include "../../tests/api.h" +#include "../../tests/testsuite.h" + +#ifndef SINGLE_THREADED +#include +#endif + +#ifdef CMSIS_OS2_H_ +void wolfSSHTest(void* argument); +#else +void wolfSSHTest(void const * argument); +#endif + +#endif /* WOLFSSH_TEST_H_ */ diff --git a/wolfssh/port.h b/wolfssh/port.h index b848bb59..f13c1279 100644 --- a/wolfssh/port.h +++ b/wolfssh/port.h @@ -1182,7 +1182,11 @@ extern "C" { #elif defined(WOLFSSH_USER_FILESYSTEM) /* User-defined I/O support */ - #include "myFilesystem.h" + #ifdef WOLFSSH_STM32_CUBEMX + #include + #else + #include "myFilesystem.h" + #endif #else #include /* used for rmdir */ diff --git a/wolfssh/settings.h b/wolfssh/settings.h index 5bc5dd8b..ee00efbf 100644 --- a/wolfssh/settings.h +++ b/wolfssh/settings.h @@ -33,6 +33,9 @@ #ifdef WOLFSSL_USER_SETTINGS #include "user_settings.h" +#elif defined(USE_HAL_DRIVER) && !defined(HAVE_CONFIG_H) + /* STM Configuration File (generated by CubeMX) */ + #include "wolfSSL.I-CUBE-wolfSSH_conf.h" #endif #ifdef __cplusplus diff --git a/wolfssh/test.h b/wolfssh/test.h index cfbf94d1..c336a6fa 100644 --- a/wolfssh/test.h +++ b/wolfssh/test.h @@ -116,14 +116,20 @@ #define NUM_SOCKETS 5 #else /* USE_WINDOWS_API */ #include - #include - #include - #include - #include - #include #include #include - #include + #ifdef WOLFSSH_LWIP + #include + #include + #include + #else + #include + #include + #include + #include + #include + #include + #endif #ifndef SO_NOSIGPIPE #include /* ignore SIGPIPE */ #endif @@ -529,7 +535,8 @@ static INLINE void tcp_socket(WS_SOCKET_T* sockFd) #endif -#if defined(WOLFSSH_TEST_SERVER) && !defined(FREESCALE_MQX) +#if defined(WOLFSSH_TEST_SERVER) && !defined(FREESCALE_MQX)\ + && !defined(WOLFSSH_LWIP) static INLINE void tcp_listen(WS_SOCKET_T* sockfd, word16* port, int useAnyAddr) {