1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
menuconfig RT_USING_SAL
bool "SAL: socket abstraction layer"
select RT_USING_NETDEV
default n
help
SAL (Socket Abstraction Layer) provides unified BSD socket API for multiple network stacks.
Features:
- Standard BSD socket API (socket, bind, connect, send, recv, etc.)
- Support multiple protocol stacks simultaneously
- Network stack independence for applications
- Automatic routing between different network interfaces
Supported protocol stacks:
- LwIP (full TCP/IP stack)
- AT commands (for cellular/WiFi modules)
- TLS/SSL (via MbedTLS)
- Custom protocol stacks
Benefits:
- Write once, run on any supported network stack
- Easy switching between WiFi, Ethernet, cellular
- Multiple network connections concurrently
- Standard POSIX socket compatibility
Use cases:
- Applications requiring network connectivity
- Multi-interface systems (WiFi + Ethernet)
- IoT devices with multiple network options
- Network stack abstraction
Enable for any application using network sockets.
Overhead: ~4-6KB ROM, ~1KB RAM + socket buffers.
if RT_USING_SAL
config SAL_INTERNET_CHECK
bool "Enable the ability that check internet status"
select RT_USING_SYSTEM_WORKQUEUE
default y
help
The ability that check internet status is provided by RT-Thread.
config SOCKET_TABLE_STEP_LEN
int "Configure socket table step length"
default 4
help
Growth step size for dynamic socket table expansion.
Default: 4 sockets
When socket table is full, it grows by this many entries:
- Initial size: SAL_SOCKETS_NUM
- Grows by: SOCKET_TABLE_STEP_LEN when full
Smaller values:
+ Less wasted memory
- More frequent reallocations
Larger values:
+ Fewer reallocations
- More unused memory
Recommended: 4-8 for most applications.
menu "Docking with protocol stacks"
config SAL_USING_LWIP
bool "Docking with lwIP stack"
default n
help
Integrate LwIP (Lightweight IP) TCP/IP stack with SAL.
LwIP provides full-featured TCP/IP protocol stack:
- TCP, UDP, ICMP, IGMP protocols
- IPv4 and IPv6 support
- DHCP client and server
- DNS resolution
- Raw socket support
When enabled, applications can use BSD sockets backed by LwIP.
Required for:
- Ethernet networking
- WiFi with full TCP/IP
- Complex network protocols
Enable if using LwIP as network stack.
config SAL_USING_AT
bool "Docking with AT commands stack"
default n
help
Integrate AT command-based network modules with SAL.
AT commands provide network connectivity through:
- Cellular modules (2G/3G/4G/5G/NB-IoT)
- WiFi modules (ESP8266, ESP32, etc.)
- Bluetooth modules
Features:
- BSD socket API over AT commands
- Transparent to applications
- Supports multiple AT devices
- Hardware offload (module handles TCP/IP)
Advantages:
- Lower MCU resource usage
- Faster time-to-market
- Leverages module's TCP/IP stack
Use cases:
- IoT devices with cellular connectivity
- Low-power WiFi applications
- Systems with network co-processors
Enable for AT command-based network modules.
config SAL_USING_TLS
bool "Docking with MbedTLS protocol"
default n
help
Integrate MbedTLS for SSL/TLS secure communication.
MbedTLS provides:
- SSL/TLS encryption (TLS 1.0-1.3)
- X.509 certificate handling
- Secure sockets (HTTPS, MQTTS, etc.)
- Cryptographic primitives
Features:
- Transparent SSL/TLS layer over SAL
- Certificate verification
- Multiple cipher suites
- Session resumption
Use cases:
- HTTPS web clients/servers
- Secure MQTT (MQTTS)
- Encrypted data transmission
- Cloud service connections (AWS, Azure, etc.)
Requirements:
- MbedTLS package
- Network stack (LwIP or AT)
- Sufficient RAM for TLS buffers (~20-40KB)
Enable for secure network communications.
endmenu
config SAL_USING_POSIX
bool
depends on DFS_USING_POSIX
default y
help
Enable BSD socket operations via file system API.
When enabled, sockets can be used like files:
- open/close for socket creation/destruction
- read/write for send/receive
- select/poll for I/O multiplexing
- File descriptor sharing with regular files
Benefits:
- Unified I/O model (files + sockets)
- Compatible with POSIX I/O functions
- Works with select/poll
- Easier application porting from Linux
Automatically enabled when DFS with POSIX is available.
Required for RT-Smart user-space socket access.
config SAL_SOCKETS_NUM
int "the maximum number of sockets"
depends on !SAL_USING_POSIX
default 16
help
Maximum number of sockets that can be created simultaneously.
Default: 16 sockets
Each socket uses:
- ~100-200 bytes for socket structure
- Send/receive buffers (protocol stack dependent)
Increase for:
- Server applications with many concurrent connections
- Applications opening multiple sockets
Decrease to save memory on constrained systems.
Note: Not used when SAL_USING_POSIX enabled (uses DFS_FD_MAX instead).
endif
|