Skip to content

Commit 72b88ec

Browse files
committed
socket connection with FreeRTOS
1 parent e9632df commit 72b88ec

34 files changed

+1800
-788
lines changed

RPi-Pico/CMakeLists.txt

Lines changed: 16 additions & 243 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ cmake_minimum_required(VERSION 3.13)
33
# Pull in Pico and FreeRTOS
44
include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake)
55
#include(pico_extras_import_optional.cmake)
6-
#include($ENV{FREERTOS_KERNEL_PATH}/portable/ThirdParty/GCC/RP2040/FreeRTOS_Kernel_import.cmake)
6+
include($ENV{FREERTOS_KERNEL_PATH}/portable/ThirdParty/GCC/RP2040/FreeRTOS_Kernel_import.cmake)
77

88

99
if(PICO_SDK_VERSION_STRING VERSION_LESS "1.3.0")
10-
message(FATAL_ERROR "Raspberry Pi Pico SDK version 1.3.0 (or later) required. Your version is ${PICO_SDK_VERSION_STRING}")
10+
message(FATAL_ERROR "Raspberry Pi Pico SDK version 1.3.0(or later) required. Your version is ${PICO_SDK_VERSION_STRING}")
1111
endif()
1212

1313
project(wolf_pico_examples C CXX ASM)
@@ -31,254 +31,27 @@ endif()
3131
include_directories(config)
3232
include_directories(include)
3333
include_directories(${PICO_SDK_PATH}/src/rp2_common/pico_lwip/include)
34+
include_directories(${PICO_SDK_PATH}/src/rp2_common/hardware_rtc/include)
3435
include_directories(${PICO_SDK_PATH}/lib/lwip/contrib/ports/freertos/include)
3536
include_directories(${PICO_SDK_PATH}/lib/lwip/src/include)
3637
include_directories(${PICO_SDK_PATH}/src/rp2_common/pico_async_context/include)
38+
#include_directories(${PICO_SDK_PATH}/lib/btstack/test/embedded/)
3739

3840
set(WOLFSSL_ROOT $ENV{WOLFSSL_ROOT})
41+
set(FREERTOS_KERNEL_PATH $ENV{FREERTOS_KERNEL_PATH})
42+
include_directories(${FREERTOS_KERNEL_PATH}/include/)
43+
include_directories(${FREERTOS_KERNEL_PATH}/portable/ThirdParty/GCC/RP2040/include)
3944
include_directories(${WOLFSSL_ROOT})
4045
### End of Global Include Path
4146

47+
include(wolfssl_import.cmake)
4248

43-
### wolfSSL/wolfCrypt library
44-
file(GLOB WOLFSSL_SRC
45-
"${WOLFSSL_ROOT}/src/*.c"
46-
"${WOLFSSL_ROOT}/wolfcrypt/src/*.c"
47-
"${WOLFSSL_ROOT}/wolfcrypt/src/port/rpi_pico/*"
48-
)
49-
list(REMOVE_ITEM WOLFSSL_SRC EXCLUDE REGEX
50-
"${WOLFSSL_ROOT}/src/bio.c"
51-
"${WOLFSSL_ROOT}/src/conf.c"
52-
"${WOLFSSL_ROOT}/src/pk.c"
53-
"${WOLFSSL_ROOT}/src/ssl_asn1.c"
54-
"${WOLFSSL_ROOT}/src/ssl_bn.c"
55-
"${WOLFSSL_ROOT}/src/ssl_misc.c"
56-
"${WOLFSSL_ROOT}/src/x509.c"
57-
"${WOLFSSL_ROOT}/src/x509_str.c"
58-
"${WOLFSSL_ROOT}/wolfcrypt/src/evp.c"
59-
"${WOLFSSL_ROOT}/wolfcrypt/src/misc.c"
60-
)
61-
62-
add_library(wolfssl STATIC
63-
${WOLFSSL_SRC}
64-
)
65-
66-
target_compile_definitions(wolfssl PUBLIC
67-
WOLFSSL_USER_SETTINGS
68-
)
69-
if (${PICO_PLATFORM} STREQUAL "rp2350-arm-s")
70-
add_compile_definitions(wolfssl WOLFSSL_SP_ARM_CORTEX_M_ASM)
71-
elseif (${PICO_PLATFORM} STREQUAL "rp2350-riscv")
72-
add_compile_definitions(wolfSSL WOLFSSL_SP_RISCV32)
73-
else()
74-
add_compile_definitions(wolfssl WOLFSSL_SP_ARM_THUMB_ASM)
75-
endif()
76-
77-
target_link_libraries(wolfssl
78-
pico_stdlib
79-
pico_rand
80-
)
81-
### End of wolfSSL/wolfCrypt library
82-
83-
84-
### Test wolfCrypt algorithms
85-
add_executable(testwolfcrypt
86-
src/test_main.c
87-
${WOLFSSL_ROOT}/wolfcrypt/test/test.c
88-
)
89-
90-
target_link_libraries(testwolfcrypt
91-
wolfssl
92-
pico_stdlib
93-
pico_rand
94-
)
95-
96-
if (USE_UART)
97-
pico_enable_stdio_usb(testwolfcrypt 0)
98-
pico_enable_stdio_uart(testwolfcrypt 1)
99-
else()
100-
pico_enable_stdio_usb(testwolfcrypt 1)
101-
pico_enable_stdio_uart(testwolfcrypt 0)
102-
endif()
103-
104-
if (${PICO_PLATFORM} STREQUAL "rp2350")
105-
add_compile_definitions(wolfssl WOLFSSL_SP_ARM_CORTEX_M_ASM)
106-
elseif (${PICO_PLATFORM} STREQUAL "rp2350-riscv")
107-
add_compile_definitions(wolfSSL WOLFSSL_SP_RISCV32)
108-
else()
109-
add_compile_definitions(wolfssl WOLFSSL_SP_ARM_THUMB_ASM)
110-
endif()
111-
112-
pico_add_extra_outputs(testwolfcrypt)
113-
### End of Test wolfCrypt algorithms
114-
115-
116-
### Benchmark wolfCrypt algorithms
117-
add_executable(benchmark
118-
src/bench_main.c
119-
${WOLFSSL_ROOT}/wolfcrypt/benchmark/benchmark.c
120-
)
121-
122-
target_link_libraries(benchmark
123-
wolfssl
124-
pico_stdlib
125-
pico_rand
126-
)
127-
128-
if (USE_UART)
129-
pico_enable_stdio_usb(benchmark 0)
130-
pico_enable_stdio_uart(benchmark 1)
131-
else()
132-
pico_enable_stdio_usb(benchmark 1)
133-
pico_enable_stdio_uart(benchmark 0)
134-
endif()
135-
136-
137-
if (${PICO_PLATFORM} STREQUAL "rp2350")
138-
add_compile_definitions(wolfssl WOLFSSL_SP_ARM_CORTEX_M_ASM)
139-
elseif (${PICO_PLATFORM} STREQUAL "rp2350-riscv")
140-
add_compile_definitions(wolfSSL WOLFSSL_SP_RISCV32)
141-
else()
142-
add_compile_definitions(wolfssl WOLFSSL_SP_ARM_THUMB_ASM)
143-
endif()
144-
145-
pico_add_extra_outputs(benchmark)
146-
### End of Benchmark wolfCrypt algorithms
147-
148-
149-
if (USE_WIFI)
150-
### Wifi connection
151-
add_executable(Wifi
152-
src/blink.c
153-
src/wifi.c
154-
src/wifi_main.c
155-
)
156-
157-
target_compile_definitions(Wifi PRIVATE
158-
WIFI_SSID=\"${WIFI_SSID}\"
159-
WIFI_PASSWORD=\"${WIFI_PASSWORD}\"
160-
PICO_CYW43_ARCH_POLL
161-
NO_SYS=1
162-
)
163-
164-
target_link_libraries(Wifi
165-
pico_stdlib
166-
pico_rand
167-
pico_lwip
168-
pico_cyw43_arch
169-
pico_lwip_nosys
170-
pico_async_context_poll
171-
)
172-
173-
if (USE_UART)
174-
pico_enable_stdio_usb(Wifi 0)
175-
pico_enable_stdio_uart(Wifi 1)
176-
else()
177-
pico_enable_stdio_usb(Wifi 1)
178-
pico_enable_stdio_uart(Wifi 0)
179-
endif()
180-
181-
if (${PICO_PLATFORM} STREQUAL "rp2350")
182-
add_compile_definitions(wolfssl WOLFSSL_SP_ARM_CORTEX_M_ASM)
183-
elseif (${PICO_PLATFORM} STREQUAL "rp2350-riscv")
184-
add_compile_definitions(wolfSSL WOLFSSL_SP_RISCV32)
185-
else()
186-
add_compile_definitions(wolfssl WOLFSSL_SP_ARM_THUMB_ASM)
187-
endif()
188-
189-
pico_add_extra_outputs(Wifi)
190-
### End of Wifi connection
191-
endif()
192-
193-
if (USE_WIFI)
194-
### TCP Client
195-
add_executable(tcp_Client
196-
src/blink.c
197-
src/wifi.c
198-
src/tcp.c
199-
src/tcpClient_main.c
200-
)
201-
202-
target_compile_definitions(tcp_Client PRIVATE
203-
WIFI_SSID=\"${WIFI_SSID}\"
204-
WIFI_PASSWORD=\"${WIFI_PASSWORD}\"
205-
TEST_TCP_SERVER_IP=\"${TEST_TCP_SERVER_IP}\"
206-
PICO_CYW43_ARCH_POLL
207-
NO_SYS=1
208-
)
209-
210-
target_link_libraries(tcp_Client
211-
pico_stdlib
212-
pico_rand
213-
pico_lwip
214-
pico_cyw43_arch
215-
pico_lwip_nosys
216-
pico_async_context_poll
217-
)
218-
219-
if (USE_UART)
220-
pico_enable_stdio_usb(tcp_Client 0)
221-
pico_enable_stdio_uart(tcp_Client 1)
222-
else()
223-
pico_enable_stdio_usb(tcp_Client 1)
224-
pico_enable_stdio_uart(tcp_Client 0)
225-
endif()
226-
227-
if (${PICO_PLATFORM} STREQUAL "rp2350")
228-
add_compile_definitions(wolfssl WOLFSSL_SP_ARM_CORTEX_M_ASM)
229-
elseif (${PICO_PLATFORM} STREQUAL "rp2350-riscv")
230-
add_compile_definitions(wolfSSL WOLFSSL_SP_RISCV32)
231-
else()
232-
add_compile_definitions(wolfssl WOLFSSL_SP_ARM_THUMB_ASM)
233-
endif()
234-
235-
pico_add_extra_outputs(tcp_Client)
236-
### End of TCP Client
237-
endif()
238-
239-
if (USE_WIFI)
240-
### TLS Client
241-
add_executable(tls_Client
242-
src/blink.c
243-
src/wifi.c
244-
src/tcp.c
245-
src/tlsClient_main.c
246-
)
247-
248-
target_compile_definitions(tls_Client PRIVATE
249-
WIFI_SSID=\"${WIFI_SSID}\"
250-
WIFI_PASSWORD=\"${WIFI_PASSWORD}\"
251-
TEST_TCP_SERVER_IP=\"${TEST_TCP_SERVER_IP}\"
252-
PICO_CYW43_ARCH_POLL
253-
NO_SYS=1
254-
)
255-
256-
target_link_libraries(tls_Client
257-
pico_stdlib
258-
pico_rand
259-
pico_lwip
260-
pico_cyw43_arch
261-
pico_lwip_nosys
262-
pico_async_context_poll
263-
wolfssl
264-
)
265-
266-
if (USE_UART)
267-
pico_enable_stdio_usb(tls_Client 0)
268-
pico_enable_stdio_uart(tls_Client 1)
269-
else()
270-
pico_enable_stdio_usb(tls_Client 1)
271-
pico_enable_stdio_uart(tls_Client 0)
272-
endif()
273-
274-
if (${PICO_PLATFORM} STREQUAL "rp2350")
275-
add_compile_definitions(wolfssl WOLFSSL_SP_ARM_CORTEX_M_ASM)
276-
elseif (${PICO_PLATFORM} STREQUAL "rp2350-riscv")
277-
add_compile_definitions(wolfSSL WOLFSSL_SP_RISCV32)
278-
else()
279-
add_compile_definitions(wolfssl WOLFSSL_SP_ARM_THUMB_ASM)
49+
add_subdirectory(testwolfcrypt)
50+
add_subdirectory(benchmark)
51+
if (USE_WIFI)
52+
add_subdirectory(wifi)
53+
add_subdirectory(tcp_client)
54+
add_subdirectory(tcp_server)
55+
add_subdirectory(tls_client)
56+
add_subdirectory(tls_server)
28057
endif()
281-
282-
pico_add_extra_outputs(tls_Client)
283-
### End of TLS Client
284-
endif()

RPi-Pico/README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,13 @@ export WOLFSSL_ROOT=/path/to/wolfssl/source
3838
export PICO_SDK_PATH=/path/to/pico-sdk
3939
```
4040

41-
### 3. cmake and make
41+
### 3. Set `FREERTOS_KERNEL_PATH`
42+
If you want to use TCP/TLS server or client, You also need to have the [FreeRTOS-Kernel GitHub repository](https://github.com/FreeRTOS/FreeRTOS-Kernel).
43+
```
44+
export FREERTOS_KERNEL_PATH=/path/to/FreeRTOS-Kernel
45+
```
46+
47+
### 4. cmake and make
4248

4349
The following CMAKE options are available:
4450

@@ -59,7 +65,7 @@ $ cmake -DPICO_BOARD=pico_w ..
5965
$ make
6066
```
6167

62-
### 4. Upload to the Pico
68+
### 5. Upload to the Pico
6369

6470
Hold the boot button and plug the Pico into your computer, you can then
6571
drag/drop a `.uf2` to the Pico. It will stop becoming a USB mass storage device
@@ -71,7 +77,7 @@ sudo picotool load benchmark.uf2
7177
sudo picotool reboot
7278
```
7379

74-
### 5. Serial output
80+
### 6. Serial output
7581

7682
If you have not set `USE_UART`, once rebooted the USB port will turn into an
7783
"Abstract Control Module" serial port. On Linux this will likely be

RPi-Pico/benchmark/CMakeLists.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
add_executable(benchmark
2+
../src/bench_main.c
3+
${WOLFSSL_ROOT}/wolfcrypt/benchmark/benchmark.c
4+
)
5+
6+
target_link_libraries(benchmark
7+
wolfssl
8+
pico_stdlib
9+
pico_rand
10+
)
11+
12+
target_compile_definitions(benchmark PRIVATE
13+
WOLFSSL_RPI_PICO
14+
)
15+
16+
if (USE_UART)
17+
pico_enable_stdio_usb(benchmark 0)
18+
pico_enable_stdio_uart(benchmark 1)
19+
else()
20+
pico_enable_stdio_usb(benchmark 1)
21+
pico_enable_stdio_uart(benchmark 0)
22+
endif()
23+
24+
if (${PICO_PLATFORM} STREQUAL "rp2350")
25+
add_compile_definitions(wolfssl WOLFSSL_SP_ARM_CORTEX_M_ASM)
26+
elseif (${PICO_PLATFORM} STREQUAL "rp2350-riscv")
27+
add_compile_definitions(wolfSSL WOLFSSL_SP_RISCV32)
28+
else()
29+
add_compile_definitions(wolfssl WOLFSSL_SP_ARM_THUMB_ASM)
30+
endif()
31+
32+
pico_add_extra_outputs(benchmark)

0 commit comments

Comments
 (0)