Skip to content

Commit ea9a8e0

Browse files
committed
Add wolfIP stm32CubeMX IDE support
1 parent ac1a6fc commit ea9a8e0

5 files changed

Lines changed: 211 additions & 1 deletion

File tree

IDE/STM32Cube/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# wolfIP for STM32 Cube IDE
2+
3+
The wolfIP Cube Pack can be found [here](https://www.wolfssl.com/files/ide/I-CUBE-wolfIP.pack).
4+
5+
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.
6+
7+
2. Install the wolfIP Cube Pack with the steps below.
8+
- Run the "STM32CubeMX" tool.
9+
- Under "Manage software installations" pane on the right, click "INSTALL/REMOVE" button.
10+
- From Local and choose "I-CUBE-wolfIP.pack".
11+
- Accept the GPLv3 license. Contact wolfSSL at sales@wolfssl.com for a commercial license and support/maintenance.
12+
13+
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.
14+
15+
4. In the `Software Packs` configuration category of the `.ioc` file, click on the wolfIP pack and enable the library by checking the box.
16+
17+
5. Configure the wolfIP settings in the `.ioc` file as needed (DHCP, DNS, socket pool sizes, MTU, etc.).
18+
19+
6. Save your changes and select yes to the prompt asking about generating code.
20+
21+
7. Build the project.
22+
23+
## Notes
24+
- wolfIP uses zero dynamic memory allocation - all sockets and buffers are pre-allocated at compile time.
25+
- See `src/port/stm32h563/` for a complete bare-metal example targeting the STM32H563 microcontroller.
26+
- For questions please email support@wolfssl.com

IDE/STM32Cube/default_conf.ftl

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
[#ftl]
2+
/**
3+
******************************************************************************
4+
* File Name : ${name}
5+
* Description : This file provides code for the configuration
6+
* of the ${name} instances.
7+
******************************************************************************
8+
[@common.optinclude name=mxTmpFolder+"/license.tmp"/][#--include License text --]
9+
******************************************************************************
10+
*/
11+
[#assign s = name]
12+
[#assign toto = s?replace(".","_")]
13+
[#assign toto = toto?replace("/","")]
14+
[#assign toto = toto?replace("-","_")]
15+
[#assign inclusion_protection = toto?upper_case]
16+
/* Define to prevent recursive inclusion -------------------------------------*/
17+
#ifndef __${inclusion_protection}__
18+
#define __${inclusion_protection}__
19+
20+
#ifdef __cplusplus
21+
extern "C" {
22+
#endif
23+
24+
25+
/* Includes ------------------------------------------------------------------*/
26+
[#if includes??]
27+
[#list includes as include]
28+
#include "${include}"
29+
[/#list]
30+
[/#if]
31+
32+
[#-- SWIPdatas is a list of SWIPconfigModel --]
33+
[#list SWIPdatas as SWIP]
34+
[#-- Global variables --]
35+
[#if SWIP.variables??]
36+
[#list SWIP.variables as variable]
37+
extern ${variable.value} ${variable.name};
38+
[/#list]
39+
[/#if]
40+
41+
[#-- Global variables --]
42+
43+
[#assign instName = SWIP.ipName]
44+
[#assign fileName = SWIP.fileName]
45+
[#assign version = SWIP.version]
46+
47+
/**
48+
MiddleWare name : ${instName}
49+
MiddleWare fileName : ${fileName}
50+
MiddleWare version : ${version}
51+
*/
52+
[#if SWIP.defines??]
53+
[#list SWIP.defines as definition]
54+
/*---------- [#if definition.comments??]${definition.comments}[/#if] -----------*/
55+
#define ${definition.name} #t#t ${definition.value}
56+
[#if definition.description??]${definition.description} [/#if]
57+
[/#list]
58+
[/#if]
59+
60+
61+
62+
[/#list]
63+
64+
/* ------------------------------------------------------------------------- */
65+
/* Platform */
66+
/* ------------------------------------------------------------------------- */
67+
#define WOLFIP_STM32_CUBEMX
68+
#define NO_FILESYSTEM
69+
70+
/* ------------------------------------------------------------------------- */
71+
/* Socket Pool Configuration */
72+
/* ------------------------------------------------------------------------- */
73+
#if defined(WOLFIP_CONF_MAX_TCP) && WOLFIP_CONF_MAX_TCP > 0
74+
#define MAX_TCPSOCKETS WOLFIP_CONF_MAX_TCP
75+
#else
76+
#define MAX_TCPSOCKETS 4
77+
#endif
78+
79+
#if defined(WOLFIP_CONF_MAX_UDP) && WOLFIP_CONF_MAX_UDP > 0
80+
#define MAX_UDPSOCKETS WOLFIP_CONF_MAX_UDP
81+
#else
82+
#define MAX_UDPSOCKETS 2
83+
#endif
84+
85+
#if defined(WOLFIP_CONF_MAX_ICMP) && WOLFIP_CONF_MAX_ICMP > 0
86+
#define MAX_ICMPSOCKETS WOLFIP_CONF_MAX_ICMP
87+
#else
88+
#define MAX_ICMPSOCKETS 2
89+
#endif
90+
91+
/* ------------------------------------------------------------------------- */
92+
/* Buffer Configuration */
93+
/* ------------------------------------------------------------------------- */
94+
#if defined(WOLFIP_CONF_MTU) && WOLFIP_CONF_MTU > 0
95+
#define LINK_MTU WOLFIP_CONF_MTU
96+
#else
97+
#define LINK_MTU 1536
98+
#endif
99+
100+
#define RXBUF_SIZE (LINK_MTU * 16)
101+
#define TXBUF_SIZE (LINK_MTU * 16)
102+
103+
/* ------------------------------------------------------------------------- */
104+
/* Network Configuration */
105+
/* ------------------------------------------------------------------------- */
106+
#define ETHERNET
107+
#define MAX_NEIGHBORS 16
108+
109+
/* ------------------------------------------------------------------------- */
110+
/* Enable/Disable Features */
111+
/* ------------------------------------------------------------------------- */
112+
113+
/* DHCP Client */
114+
#if defined(WOLFIP_CONF_DHCP) && WOLFIP_CONF_DHCP == 1
115+
#define WOLFIP_ENABLE_DHCP
116+
#endif
117+
118+
/* DNS Client */
119+
#if defined(WOLFIP_CONF_DNS) && WOLFIP_CONF_DNS == 1
120+
#define WOLFIP_ENABLE_DNS
121+
#endif
122+
123+
/* Loopback Interface */
124+
#undef WOLFIP_ENABLE_LOOPBACK
125+
#if defined(WOLFIP_CONF_LOOPBACK) && WOLFIP_CONF_LOOPBACK == 1
126+
#define WOLFIP_ENABLE_LOOPBACK 1
127+
#ifndef WOLFIP_MAX_INTERFACES
128+
#define WOLFIP_MAX_INTERFACES 2
129+
#endif
130+
#else
131+
#define WOLFIP_ENABLE_LOOPBACK 0
132+
#endif
133+
134+
/* IP Forwarding */
135+
#undef WOLFIP_ENABLE_FORWARDING
136+
#if defined(WOLFIP_CONF_FORWARDING) && WOLFIP_CONF_FORWARDING == 1
137+
#define WOLFIP_ENABLE_FORWARDING 1
138+
#else
139+
#define WOLFIP_ENABLE_FORWARDING 0
140+
#endif
141+
142+
#ifndef WOLFIP_MAX_INTERFACES
143+
#define WOLFIP_MAX_INTERFACES 1
144+
#endif
145+
146+
/* ------------------------------------------------------------------------- */
147+
/* Debugging */
148+
/* ------------------------------------------------------------------------- */
149+
#if defined(WOLFIP_CONF_DEBUG) && WOLFIP_CONF_DEBUG == 1
150+
#define DEBUG
151+
#else
152+
#undef DEBUG
153+
#endif
154+
155+
/* ------------------------------------------------------------------------- */
156+
/* wolfSSL Integration */
157+
/* ------------------------------------------------------------------------- */
158+
/* Define WOLFSSL_WOLFIP to enable wolfSSL IO callbacks for TLS support.
159+
* Requires wolfSSL Cube Pack to be installed and configured.
160+
*/
161+
/* #define WOLFSSL_WOLFIP */
162+
163+
#ifdef __cplusplus
164+
}
165+
#endif
166+
#endif /* ${inclusion_protection}_H */
167+
168+
/**
169+
* @}
170+
*/
171+
172+
/*****END OF FILE****/

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ build/tcp_netcat_select: $(OBJ) build/port/posix/bsd_socket.o build/test/tcp_net
195195

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

200202
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

src/http/httpd.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
*
4242
*
4343
*/
44+
45+
#ifdef WOLFIP_CONF_HTTP
46+
4447
#include "wolfip.h"
4548
#include "httpd.h"
4649
#include <ctype.h>
@@ -525,3 +528,5 @@ int httpd_init(struct httpd *httpd, struct wolfIP *s, uint16_t port, void *ssl_c
525528
wolfIP_register_callback(s, httpd->listen_sd, http_accept_cb, httpd);
526529
return 0;
527530
}
531+
532+
#endif /* WOLFIP_CONF_HTTP */

src/http/httpd.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#ifndef WOLF_HTTPD_H
22
#define WOLF_HTTPD_H
3+
4+
#ifdef WOLFIP_CONF_HTTP
5+
36
#ifdef WOLFSSL_USER_SETTINGS
47
#include <user_settings.h>
58
#else
@@ -8,6 +11,7 @@
811
#include <wolfssl/wolfcrypt/settings.h>
912
#include <wolfssl/ssl.h>
1013
#include <stdint.h>
14+
#include <stddef.h>
1115

1216
#define HTTP_METHOD_LEN 8
1317
#define HTTP_PATH_LEN 128
@@ -86,5 +90,6 @@ void http_send_418_teapot(struct http_client *hc);
8690
int http_url_decode(char *buf, size_t len);
8791
int http_url_encode(char *buf, size_t len, size_t max_len);
8892

93+
#endif /* WOLFIP_CONF_HTTP */
8994

90-
#endif
95+
#endif /* WOLF_HTTPD_H */

0 commit comments

Comments
 (0)