Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions IDE/STM32Cube/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# wolfIP for STM32 Cube IDE

The wolfIP Cube Pack can be found [here](https://www.wolfssl.com/files/ide/I-CUBE-wolfIP.pack).

1. If you intend to use TLS with wolfIP, the first step is to set up the wolfSSL 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). If not, skip to the next step.

2. Install the wolfIP Cube Pack with the steps below.
- Run the "STM32CubeMX" tool.
- Under "Manage software installations" pane on the right, click "INSTALL/REMOVE" button.
- From Local and choose "I-CUBE-wolfIP.pack".
- Accept the GPLv3 license. Contact wolfSSL at sales@wolfssl.com for a commercial license and support/maintenance.

3. Create an STM32 project for your board and open the `.ioc` file. Click the `Software Packs` drop down menu and then `Select Components`. Expand the `wolfIP` pack and check the Core component. If you need the embedded HTTP server, check the HTTP component as well. If you intend to use TLS with wolfIP, check the wolfSSL-IO component. This will enforce the dependency to wolfSSL.

4. In the `Software Packs` configuration category of the `.ioc` file, click on the wolfIP pack and enable the library by checking the box.

5. Configure the wolfIP settings in the `.ioc` file as needed (DHCP, DNS, socket pool sizes, MTU, etc.).

6. Save your changes and select yes to the prompt asking about generating code.

7. Build the project.

## Notes
- wolfIP uses zero dynamic memory allocation - all sockets and buffers are pre-allocated at compile time.
- See `src/port/stm32h563/` for a complete bare-metal example targeting the STM32H563 microcontroller.
- For questions please email support@wolfssl.com
172 changes: 172 additions & 0 deletions IDE/STM32Cube/default_conf.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
[#ftl]
/**
******************************************************************************
* File Name : ${name}
* Description : This file provides code for the configuration
* of the ${name} instances.
******************************************************************************
[@common.optinclude name=mxTmpFolder+"/license.tmp"/][#--include License text --]
******************************************************************************
*/
[#assign s = name]
[#assign toto = s?replace(".","_")]
[#assign toto = toto?replace("/","")]
[#assign toto = toto?replace("-","_")]
[#assign inclusion_protection = toto?upper_case]
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __${inclusion_protection}__
#define __${inclusion_protection}__

#ifdef __cplusplus
extern "C" {
#endif


/* Includes ------------------------------------------------------------------*/
[#if includes??]
[#list includes as include]
#include "${include}"
[/#list]
[/#if]

[#-- SWIPdatas is a list of SWIPconfigModel --]
[#list SWIPdatas as SWIP]
[#-- Global variables --]
[#if SWIP.variables??]
[#list SWIP.variables as variable]
extern ${variable.value} ${variable.name};
[/#list]
[/#if]

[#-- Global variables --]

[#assign instName = SWIP.ipName]
[#assign fileName = SWIP.fileName]
[#assign version = SWIP.version]

/**
MiddleWare name : ${instName}
MiddleWare fileName : ${fileName}
MiddleWare version : ${version}
*/
[#if SWIP.defines??]
[#list SWIP.defines as definition]
/*---------- [#if definition.comments??]${definition.comments}[/#if] -----------*/
#define ${definition.name} #t#t ${definition.value}
[#if definition.description??]${definition.description} [/#if]
[/#list]
[/#if]



[/#list]

/* ------------------------------------------------------------------------- */
/* Platform */
/* ------------------------------------------------------------------------- */
#define WOLFIP_STM32_CUBEMX
#define NO_FILESYSTEM

/* ------------------------------------------------------------------------- */
/* Socket Pool Configuration */
/* ------------------------------------------------------------------------- */
#if defined(WOLFIP_CONF_MAX_TCP) && WOLFIP_CONF_MAX_TCP > 0
#define MAX_TCPSOCKETS WOLFIP_CONF_MAX_TCP
#else
#define MAX_TCPSOCKETS 4
#endif

#if defined(WOLFIP_CONF_MAX_UDP) && WOLFIP_CONF_MAX_UDP > 0
#define MAX_UDPSOCKETS WOLFIP_CONF_MAX_UDP
#else
#define MAX_UDPSOCKETS 2
#endif

#if defined(WOLFIP_CONF_MAX_ICMP) && WOLFIP_CONF_MAX_ICMP > 0
#define MAX_ICMPSOCKETS WOLFIP_CONF_MAX_ICMP
#else
#define MAX_ICMPSOCKETS 2
#endif

/* ------------------------------------------------------------------------- */
/* Buffer Configuration */
/* ------------------------------------------------------------------------- */
#if defined(WOLFIP_CONF_MTU) && WOLFIP_CONF_MTU > 0
#define LINK_MTU WOLFIP_CONF_MTU
#else
#define LINK_MTU 1536
#endif

#define RXBUF_SIZE (LINK_MTU * 16)
#define TXBUF_SIZE (LINK_MTU * 16)

/* ------------------------------------------------------------------------- */
/* Network Configuration */
/* ------------------------------------------------------------------------- */
#define ETHERNET
#define MAX_NEIGHBORS 16

/* ------------------------------------------------------------------------- */
/* Enable/Disable Features */
/* ------------------------------------------------------------------------- */

/* DHCP Client */
#if defined(WOLFIP_CONF_DHCP) && WOLFIP_CONF_DHCP == 1
#define WOLFIP_ENABLE_DHCP
#endif

/* DNS Client */
#if defined(WOLFIP_CONF_DNS) && WOLFIP_CONF_DNS == 1
#define WOLFIP_ENABLE_DNS
#endif

/* Loopback Interface */
#undef WOLFIP_ENABLE_LOOPBACK
#if defined(WOLFIP_CONF_LOOPBACK) && WOLFIP_CONF_LOOPBACK == 1
#define WOLFIP_ENABLE_LOOPBACK 1
#ifndef WOLFIP_MAX_INTERFACES
#define WOLFIP_MAX_INTERFACES 2
#endif
#else
#define WOLFIP_ENABLE_LOOPBACK 0
#endif

/* IP Forwarding */
#undef WOLFIP_ENABLE_FORWARDING
#if defined(WOLFIP_CONF_FORWARDING) && WOLFIP_CONF_FORWARDING == 1
#define WOLFIP_ENABLE_FORWARDING 1
#else
#define WOLFIP_ENABLE_FORWARDING 0
#endif

#ifndef WOLFIP_MAX_INTERFACES
#define WOLFIP_MAX_INTERFACES 1
#endif

/* ------------------------------------------------------------------------- */
/* Debugging */
/* ------------------------------------------------------------------------- */
#if defined(WOLFIP_CONF_DEBUG) && WOLFIP_CONF_DEBUG == 1
#define DEBUG
#else
#undef DEBUG
#endif

/* ------------------------------------------------------------------------- */
/* wolfSSL Integration */
/* ------------------------------------------------------------------------- */
/* Define WOLFSSL_WOLFIP to enable wolfSSL IO callbacks for TLS support.
* Requires wolfSSL Cube Pack to be installed and configured.
*/
/* #define WOLFSSL_WOLFIP */

#ifdef __cplusplus
}
#endif
#endif /* ${inclusion_protection}_H */

/**
* @}
*/

/*****END OF FILE****/
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ build/tcp_netcat_select: $(OBJ) build/port/posix/bsd_socket.o build/test/tcp_net

build/test-wolfssl:CFLAGS+=-Wno-cpp -DWOLFSSL_DEBUG -DWOLFSSL_WOLFIP
build/test-httpd:CFLAGS+=-Wno-cpp -DWOLFSSL_DEBUG -DWOLFSSL_WOLFIP -Isrc/http
build/test/test_httpd.o:CFLAGS+=-Wno-cpp -DWOLFSSL_DEBUG -DWOLFSSL_WOLFIP -DWOLFIP_CONF_HTTP -Isrc/http
build/http/httpd.o:CFLAGS+=-Wno-cpp -DWOLFSSL_DEBUG -DWOLFSSL_WOLFIP -DWOLFIP_CONF_HTTP -Isrc/http
build/test-wolfssl-forwarding:CFLAGS+=-Wno-cpp -DWOLFSSL_DEBUG -DWOLFSSL_WOLFIP -DWOLFIP_MAX_INTERFACES=2 -DWOLFIP_ENABLE_FORWARDING=1

build/test-wolfssl: $(OBJ) build/test/test_native_wolfssl.o build/port/wolfssl_io.o build/certs/server_key.o build/certs/ca_cert.o build/certs/server_cert.o
Expand Down
5 changes: 5 additions & 0 deletions src/http/httpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
*
*
*/

#ifdef WOLFIP_CONF_HTTP

#include "wolfip.h"
#include "httpd.h"
#include <ctype.h>
Expand Down Expand Up @@ -525,3 +528,5 @@ int httpd_init(struct httpd *httpd, struct wolfIP *s, uint16_t port, void *ssl_c
wolfIP_register_callback(s, httpd->listen_sd, http_accept_cb, httpd);
return 0;
}

#endif /* WOLFIP_CONF_HTTP */
7 changes: 6 additions & 1 deletion src/http/httpd.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#ifndef WOLF_HTTPD_H
#define WOLF_HTTPD_H

#ifdef WOLFIP_CONF_HTTP

#ifdef WOLFSSL_USER_SETTINGS
#include <user_settings.h>
#else
Expand All @@ -8,6 +11,7 @@
#include <wolfssl/wolfcrypt/settings.h>
#include <wolfssl/ssl.h>
#include <stdint.h>
#include <stddef.h>

#define HTTP_METHOD_LEN 8
#define HTTP_PATH_LEN 128
Expand Down Expand Up @@ -86,5 +90,6 @@ void http_send_418_teapot(struct http_client *hc);
int http_url_decode(char *buf, size_t len);
int http_url_encode(char *buf, size_t len, size_t max_len);

#endif /* WOLFIP_CONF_HTTP */

#endif
#endif /* WOLF_HTTPD_H */