Skip to content

Commit 6ea0bba

Browse files
committed
cmake: support custom network interfaces
1 parent 4e95d07 commit 6ea0bba

34 files changed

Lines changed: 54 additions & 276 deletions

File tree

‎CMakeLists.txt‎

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ set(FREERTOS_PLUS_TCP_COMPILER "" CACHE STRING "FreeRTOS Plus TCP Compiler Selec
5555
set(FREERTOS_PLUS_TCP_NETWORK_IF "" CACHE STRING "FreeRTOS Plus TCP Network Interface selection")
5656
set(FREERTOS_PLUS_TCP_NETWORK_IF_LIST
5757
A_CUSTOM_NETWORK_IF
58-
ATSAM43 ATSAME5x # AT
58+
ATSAM4E ATSAME5x # AT
5959
DRIVER_SAM
6060
ESP32
6161
KSZ8851SNL
@@ -71,7 +71,7 @@ set(FREERTOS_PLUS_TCP_NETWORK_IF_LIST
7171
POSIX WIN_PCAP # Native Linux & Windows respectively
7272
RX
7373
SH2A
74-
STM32 # ST Micro
74+
STM32 STM32FXX STM32HXX # ST Micro
7575
MSP432
7676
TM4C
7777
XILINX_ULTRASCALE ZYNQ # AMD/Xilinx
@@ -110,40 +110,28 @@ if(NOT FREERTOS_PLUS_TCP_NETWORK_IF IN_LIST FREERTOS_PLUS_TCP_NETWORK_IF_LIST )
110110
" LPC54018 Target: LPC54018 Tested: TODO\n"
111111
" M487 Target: M487 Tested: TODO\n"
112112
" MPS2_AN385 Target: MPS2_AN385 Tested: TODO\n"
113-
" MPS3_AN552 Target: MPS3_AN552"
113+
" MPS3_AN552 Target: MPS3_AN552 Tested: TODO\n"
114114
" MW300_RD Target: mw300_rd Tested: TODO\n"
115115
" NXP1060 Target: NXP1060 Tested: TODO\n"
116116
" PIC32MZEF_ETH Target: pic32mzef ethernet Tested: TODO\n"
117117
" PIC32MZEF_WIFI Target: pic32mzef Wifi Tested: TODO\n"
118118
" RX Target: RX Tested: TODO\n"
119119
" SH2A Target: SH2A Tested: TODO\n"
120120
" STM32 Target: STM32 Tested: TODO\n"
121+
" STM32FXX Target: STM32Fxx legacy Tested: TODO\n"
122+
" STM32HXX Target: STM32Hxx legacy Tested: TODO\n"
121123
" MSP432 Target: MSP432 Tested: TODO\n"
122124
" TM4C Target: TM4C Tested: TODO\n"
123125
" WIN_PCAP Target: Windows Tested: TODO\n"
124126
" XILINX_ULTRASCALE Target: Xilinx Ultrascale Tested: TODO\n"
125127
" ZYNQ Target: Xilinx Zynq")
126-
elseif((FREERTOS_PORT STREQUAL "A_CUSTOM_PORT") AND (NOT TARGET freertos_kernel_port) )
127-
message(FATAL_ERROR " FREERTOS_PLUS_TCP_NETWORK_IF is set to A_CUSTOM_NETWORK_IF.\n"
128-
" Please specify the custom network interface target with all necessary files.\n"
129-
" For example, assuming a directory of:\n"
130-
" FreeRTOSCustomNetworkInterface/\n"
131-
" CMakeLists.txt\n"
132-
" NetworkInterface.c\n\n"
133-
" Where FreeRTOSCustomNetworkInterface/CMakeLists.txt is a modified version of:\n"
134-
" add_library(freertos_plus_tcp_network_if STATIC)\n\n"
135-
" target_sources(freertos_plus_tcp_network_if\n"
136-
" PRIVATE\n"
137-
" NetworkInterface.c)\n\n"
138-
" target_include_directories(freertos_plus_tcp_network_if\n"
139-
" PUBLIC\n"
140-
" .)\n\n"
141-
" target_link_libraries(freertos_plus_tcp_network_if\n"
142-
" PUBLIC\n"
143-
" freertos_plus_tcp_port\n"
144-
" freertos_plus_tcp_network_if_common\n"
145-
" PRIVATE\n"
146-
" freertos_kernel)")
128+
elseif((FREERTOS_PLUS_TCP_NETWORK_IF STREQUAL "A_CUSTOM_NETWORK_IF") AND
129+
(NOT TARGET freertos_plus_tcp_network_if))
130+
message(FATAL_ERROR
131+
"FREERTOS_PLUS_TCP_NETWORK_IF is set to A_CUSTOM_NETWORK_IF, but the "
132+
"freertos_plus_tcp_network_if target does not exist. Define it before "
133+
"making FreeRTOS-Plus-TCP available, for example:\n"
134+
" add_library(freertos_plus_tcp_network_if STATIC NetworkInterface.c)")
147135
endif()
148136

149137
# There is also the need to add a target - typically an interface library that describes the
@@ -185,4 +173,4 @@ endif()
185173

186174
if(PROJECT_IS_TOP_LEVEL)
187175
FetchContent_MakeAvailable(freertos_kernel cmock)
188-
endif()
176+
endif()

‎README.md‎

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,32 @@ FetchContent_Declare( freertos_plus_tcp
7171
set( FREERTOS_PLUS_TCP_NETWORK_IF "POSIX" CACHE STRING "" FORCE)
7272
# Or: select a cross-compile PORT
7373
if (CMAKE_CROSSCOMPILING)
74-
# Eg. STM32Hxx version of port
75-
set(FREERTOS_PLUS_TCP_NETWORK_IF "STM32HXX" CACHE STRING "" FORCE)
74+
# Eg. STM32H7 version of port
75+
set(FREERTOS_PLUS_TCP_NETWORK_IF "STM32" CACHE STRING "" FORCE)
76+
set(FREERTOS_PLUS_TCP_STM32_IF_DRIVER "H7" CACHE STRING "" FORCE)
7677
endif()
7778
7879
FetchContent_MakeAvailable(freertos_plus_tcp)
7980
```
8081

82+
- To provide a project-specific network interface, create the
83+
`freertos_plus_tcp_network_if` target before making FreeRTOS-Plus-TCP
84+
available. FreeRTOS-Plus-TCP attaches its internal dependencies to this
85+
target; the application only needs to attach platform-specific dependencies.
86+
87+
```cmake
88+
add_library(freertos_plus_tcp_network_if STATIC
89+
path/to/NetworkInterface.c
90+
)
91+
target_link_libraries(freertos_plus_tcp_network_if
92+
PRIVATE
93+
board_support
94+
)
95+
96+
set(FREERTOS_PLUS_TCP_NETWORK_IF "A_CUSTOM_NETWORK_IF" CACHE STRING "" FORCE)
97+
FetchContent_MakeAvailable(freertos_plus_tcp)
98+
```
99+
81100
### Consuming stand-alone
82101

83102
This repository uses [Git Submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules) to bring in dependent components.

‎source/portable/NetworkInterface/ATSAM4E/CMakeLists.txt‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,3 @@ target_sources( freertos_plus_tcp_network_if
1515
gmac.h
1616
NetworkInterface.c
1717
)
18-
19-
target_link_libraries( freertos_plus_tcp_network_if
20-
PUBLIC
21-
freertos_plus_tcp_port
22-
freertos_plus_tcp_network_if_common
23-
PRIVATE
24-
freertos_kernel
25-
freertos_plus_tcp
26-
)

‎source/portable/NetworkInterface/ATSAME5x/CMakeLists.txt‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,3 @@ target_sources( freertos_plus_tcp_network_if
99
PRIVATE
1010
NetworkInterface.c
1111
)
12-
13-
target_link_libraries( freertos_plus_tcp_network_if
14-
PUBLIC
15-
freertos_plus_tcp_port
16-
freertos_plus_tcp_network_if_common
17-
PRIVATE
18-
freertos_kernel
19-
freertos_plus_tcp
20-
)

‎source/portable/NetworkInterface/CMakeLists.txt‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ target_link_libraries( freertos_plus_tcp_network_if_common
2828
)
2929

3030
#------------------------------------------------------------------------------
31+
#add_subdirectory(board_family) - This is only an example.
32+
3133
add_subdirectory(ATSAM4E)
3234
add_subdirectory(ATSAME5x)
33-
#add_subdirectory(board_family) - This is only an example.
3435
add_subdirectory(DriverSAM)
3536
add_subdirectory(esp32)
3637
add_subdirectory(ksz8851snl)
@@ -50,8 +51,17 @@ add_subdirectory(pic32mzef)
5051
add_subdirectory(RX)
5152
add_subdirectory(SH2A)
5253
add_subdirectory(STM32)
53-
add_subdirectory(ThirdParty/MSP432)
54+
add_subdirectory(ThirdParty)
5455
add_subdirectory(TM4C)
5556
add_subdirectory(WinPCap)
5657
add_subdirectory(xilinx_ultrascale)
5758
add_subdirectory(Zynq)
59+
60+
target_link_libraries( freertos_plus_tcp_network_if
61+
PUBLIC
62+
freertos_plus_tcp_port
63+
freertos_plus_tcp_network_if_common
64+
PRIVATE
65+
freertos_kernel
66+
freertos_plus_tcp
67+
)

‎source/portable/NetworkInterface/DriverSAM/CMakeLists.txt‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,3 @@ target_sources( freertos_plus_tcp_network_if
1111
gmac_SAM.h
1212
NetworkInterface.c
1313
)
14-
15-
target_link_libraries( freertos_plus_tcp_network_if
16-
PUBLIC
17-
freertos_plus_tcp_port
18-
freertos_plus_tcp_network_if_common
19-
PRIVATE
20-
freertos_kernel
21-
freertos_plus_tcp
22-
)

‎source/portable/NetworkInterface/LPC17xx/CMakeLists.txt‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,3 @@ target_link_libraries(freertos_plus_tcp_network_if
1717
PRIVATE
1818
lpc17xx_driver
1919
)
20-
21-
target_link_libraries( freertos_plus_tcp_network_if
22-
PUBLIC
23-
freertos_plus_tcp_port
24-
freertos_plus_tcp_network_if_common
25-
PRIVATE
26-
freertos_kernel
27-
freertos_plus_tcp
28-
)

‎source/portable/NetworkInterface/LPC18xx/CMakeLists.txt‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,3 @@ target_link_libraries(freertos_plus_tcp_network_if
1717
PRIVATE
1818
lpc18xx_driver
1919
)
20-
21-
target_link_libraries( freertos_plus_tcp_network_if
22-
PUBLIC
23-
freertos_plus_tcp_port
24-
freertos_plus_tcp_network_if_common
25-
PRIVATE
26-
freertos_kernel
27-
freertos_plus_tcp
28-
)

‎source/portable/NetworkInterface/LPC54018/CMakeLists.txt‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,3 @@ target_link_libraries(freertos_plus_tcp_network_if
1717
PRIVATE
1818
lpc54018_driver
1919
)
20-
21-
target_link_libraries( freertos_plus_tcp_network_if
22-
PUBLIC
23-
freertos_plus_tcp_port
24-
freertos_plus_tcp_network_if_common
25-
PRIVATE
26-
freertos_kernel
27-
freertos_plus_tcp
28-
)

‎source/portable/NetworkInterface/M487/CMakeLists.txt‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,3 @@ target_sources( freertos_plus_tcp_network_if
1111
m480_eth.h
1212
NetworkInterface.c
1313
)
14-
15-
target_link_libraries( freertos_plus_tcp_network_if
16-
PUBLIC
17-
freertos_plus_tcp_port
18-
freertos_plus_tcp_network_if_common
19-
PRIVATE
20-
freertos_kernel
21-
freertos_plus_tcp
22-
)

0 commit comments

Comments
 (0)