Skip to content

Commit 922236c

Browse files
CopilotRbb666
andcommitted
Add comprehensive help descriptions to Kconfig files in libcpu and components
Co-authored-by: Rbb666 <64397326+Rbb666@users.noreply.github.com>
1 parent 1ef262d commit 922236c

File tree

4 files changed

+1616
-7
lines changed

4 files changed

+1616
-7
lines changed

components/Kconfig

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,120 @@ menu "RT-Thread Components"
33
config RT_USING_COMPONENTS_INIT
44
bool
55
default n
6+
help
7+
Enable automatic component initialization framework.
8+
9+
When enabled, components marked with INIT_EXPORT() macros will be
10+
automatically initialized during system startup in proper order.
11+
12+
Initialization levels (in order):
13+
- INIT_BOARD_EXPORT: Board-level initialization (pins, clocks)
14+
- INIT_PREV_EXPORT: Early driver initialization
15+
- INIT_DEVICE_EXPORT: Device driver initialization
16+
- INIT_COMPONENT_EXPORT: Component initialization
17+
- INIT_ENV_EXPORT: Environment initialization
18+
- INIT_APP_EXPORT: Application initialization
19+
20+
Benefits:
21+
- Automatic dependency ordering
22+
- Cleaner code (no manual init function calls)
23+
- Consistent initialization across components
24+
25+
Note: Most RT-Thread components rely on this. Usually enabled automatically
26+
by build system.
627

728
config RT_USING_USER_MAIN
829
bool
930
default n
31+
help
32+
Use user-defined main() function as entry point.
33+
34+
When enabled, RT-Thread creates a main thread that calls your main() function,
35+
allowing traditional C programming style entry point.
36+
37+
Without this option: You must manually create threads from application
38+
With this option: Your main() function runs in a dedicated main thread
39+
40+
The main thread:
41+
- Runs after system initialization
42+
- Has configurable stack size and priority
43+
- Can use RT-Thread APIs like any other thread
44+
- Can create additional threads
45+
46+
Enable this for easier application development and familiar entry point.
1047

1148
if RT_USING_USER_MAIN
1249
config RT_MAIN_THREAD_STACK_SIZE
1350
int "Set main thread stack size"
1451
default 6144 if ARCH_CPU_64BIT
1552
default 2048
53+
help
54+
Stack size in bytes for the main thread.
55+
56+
Default values:
57+
- 64-bit architectures: 6144 bytes (6KB)
58+
- 32-bit architectures: 2048 bytes (2KB)
59+
60+
Increase if:
61+
- Deep recursion in main()
62+
- Large local variables
63+
- Stack overflow in main thread
64+
- Complex initialization requiring more stack
65+
66+
Decrease for memory-constrained systems if main() is simple.
67+
68+
Note: Each thread's stack is separate. This only affects main thread.
1669

1770
config RT_MAIN_THREAD_PRIORITY
1871
int "Set main thread priority"
1972
default 4 if RT_THREAD_PRIORITY_8
2073
default 10 if RT_THREAD_PRIORITY_32
2174
default 85 if RT_THREAD_PRIORITY_256
75+
help
76+
Priority of the main thread (lower number = higher priority).
77+
78+
Default values scale with priority levels:
79+
- 8 levels: Priority 4 (middle-low priority)
80+
- 32 levels: Priority 10 (medium priority)
81+
- 256 levels: Priority 85 (medium-low priority)
82+
83+
Lower values (higher priority) if:
84+
- Main thread needs to preempt other tasks
85+
- Time-critical initialization in main()
86+
87+
Higher values (lower priority) if:
88+
- Main thread is just coordination/monitoring
89+
- Other threads need priority over main
90+
91+
Note: Priority 0 is highest, maximum is configured by RT_THREAD_PRIORITY_MAX.
2292
endif
2393

2494
config RT_USING_LEGACY
2595
bool "Support legacy version for compatibility"
2696
default n
97+
help
98+
Enable compatibility layer for legacy RT-Thread versions.
99+
100+
Provides deprecated APIs and compatibility shims for older code,
101+
allowing gradual migration to newer RT-Thread versions.
102+
103+
Includes:
104+
- Deprecated API wrappers
105+
- Legacy component interfaces
106+
- Backward-compatible behavior
107+
108+
Enable if:
109+
- Porting code from older RT-Thread versions
110+
- Using third-party libraries requiring legacy APIs
111+
- Gradual migration strategy
112+
113+
Disable for:
114+
- New projects (use modern APIs)
115+
- Smaller code size
116+
- Better performance (no compatibility overhead)
117+
118+
Note: Legacy support may be removed in future versions.
119+
Plan to migrate to current APIs.
27120

28121
if RT_USING_CONSOLE
29122
rsource "finsh/Kconfig"

components/mprotect/Kconfig

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,165 @@ config RT_USING_MEM_PROTECTION
44
bool "Enable memory protection"
55
default n
66
select RT_USING_HEAP
7+
help
8+
Enable memory protection framework using MPU (Memory Protection Unit).
9+
10+
Provides hardware-based memory protection to prevent:
11+
- Stack overflow and underflow
12+
- Buffer overruns
13+
- Unauthorized access to memory regions
14+
- Corruption of kernel data structures
15+
16+
Features:
17+
- Per-thread memory protection
18+
- Stack guard regions
19+
- Configurable memory regions with access permissions
20+
- Exclusive regions for sensitive data
21+
22+
Requirements:
23+
- CPU with MPU support (Cortex-M3/M4/M7/M33/R52, etc.)
24+
- ARCH_MM_MPU or ARCH_ARM_MPU enabled
25+
- RT_USING_HEAP (dynamic memory)
26+
27+
Benefits:
28+
- Catch memory bugs early (development)
29+
- Improve system safety (production)
30+
- Isolate thread memory spaces
31+
32+
Costs:
33+
- Context switch overhead (save/restore MPU regions)
34+
- Configuration complexity
35+
- Slight runtime overhead
36+
37+
Ideal for safety-critical applications and debugging memory issues.
738

839
config RT_USING_HW_STACK_GUARD
940
bool "Enable hardware stack guard"
1041
default n
1142
select RT_USING_MEM_PROTECTION
43+
help
44+
Enable hardware-based stack overflow protection using MPU.
45+
46+
Automatically creates guard regions at the end of each thread's stack
47+
to detect stack overflow at the moment it occurs.
48+
49+
How it works:
50+
- Configures MPU region below stack as no-access
51+
- Stack overflow triggers immediate MPU fault
52+
- Exception handler identifies the overflowing thread
53+
54+
Benefits:
55+
- Immediate detection (vs periodic checks)
56+
- Precise identification of overflow location
57+
- No runtime overhead (hardware-based)
58+
- Catches stack corruption before it spreads
59+
60+
Requirements:
61+
- RT_USING_MEM_PROTECTION enabled
62+
- Sufficient MPU regions (at least 1 per thread)
63+
64+
Recommended for:
65+
- Development and debugging
66+
- Safety-critical systems
67+
- Systems with limited stack space
68+
69+
Note: Requires one MPU region per thread. Check NUM_MEM_REGIONS configuration.
1270

1371
if RT_USING_MEM_PROTECTION
1472
config USE_MEM_PROTECTION_EXAMPLES
1573
bool "Use memory protection examples"
1674
default y
75+
help
76+
Build and include memory protection example code.
77+
78+
Provides demonstration code showing how to:
79+
- Configure memory protection regions
80+
- Set up stack guards
81+
- Add exclusive regions
82+
- Handle protection faults
83+
84+
Useful for:
85+
- Learning memory protection concepts
86+
- Testing MPU functionality
87+
- Debugging protection configurations
88+
89+
Disable for production builds to save code space.
1790

1891
config NUM_MEM_REGIONS
1992
int "Total number of memory protection regions supported by hardware"
93+
help
94+
Total number of MPU regions available in hardware.
95+
96+
This depends on your CPU architecture:
97+
- Cortex-M3/M4: Typically 8 regions
98+
- Cortex-M7: 8 or 16 regions
99+
- Cortex-M33/M85: 8 or 16 regions (configurable in silicon)
100+
- Cortex-R52: 16 or 32 regions
101+
102+
Check your MCU datasheet or reference manual for exact count.
103+
104+
Usage breakdown:
105+
- Stack guard per thread: 1 region per thread
106+
- Exclusive regions: NUM_EXCLUSIVE_REGIONS
107+
- Configurable per thread: NUM_CONFIGURABLE_REGIONS
108+
109+
Formula: NUM_MEM_REGIONS = 1 (stack) + NUM_EXCLUSIVE_REGIONS + NUM_CONFIGURABLE_REGIONS
110+
111+
Example for 8-region MPU with 2 threads:
112+
- Thread 1 stack guard: 1 region
113+
- Thread 2 stack guard: 1 region
114+
- Shared exclusive regions: 2 regions
115+
- Per-thread config: 2 regions per thread
116+
Total: 2 + 2 + 4 = 8 regions
20117

21118
config NUM_EXCLUSIVE_REGIONS
22119
int "Total number of exclusive memory regions added using rt_mprotect_add_exclusive_region API"
120+
help
121+
Number of shared exclusive memory protection regions.
122+
123+
Exclusive regions are memory areas with specific access permissions
124+
shared across all threads (e.g., peripheral registers, kernel data).
125+
126+
Use cases:
127+
- Protect peripheral registers from thread access
128+
- Mark flash memory as read-only/execute-only
129+
- Protect kernel data structures
130+
- Define shared memory with specific permissions
131+
132+
Example configurations:
133+
- Peripheral protection: 1-2 regions
134+
- Kernel data protection: 1 region
135+
- Shared buffers: 0-2 regions
136+
137+
Note: These regions are configured once and apply to all threads.
138+
Set based on your system's protection requirements.
23139

24140
config NUM_CONFIGURABLE_REGIONS
25141
int "Maximum number of configurable memory regions for each thread, excluding stack guard and exclusive regions added using rt_mprotect_add_exclusive_region API"
142+
help
143+
Per-thread configurable memory protection regions.
144+
145+
These regions are specific to each thread and can be configured independently
146+
for thread-specific memory protection needs.
147+
148+
Use cases:
149+
- Protect thread's private data buffers
150+
- Restrict access to thread-local peripherals
151+
- Define custom memory permissions per thread
152+
153+
Calculation:
154+
NUM_CONFIGURABLE_REGIONS = NUM_MEM_REGIONS - 1 (stack) - NUM_EXCLUSIVE_REGIONS
155+
156+
Example for 8-region MPU with 2 exclusive regions:
157+
NUM_CONFIGURABLE_REGIONS = 8 - 1 - 2 = 5 regions per thread
158+
159+
More regions = more flexibility but:
160+
- Increased configuration complexity
161+
- Longer context switch time
162+
- More memory for region descriptors
163+
164+
Set based on your application's per-thread protection needs.
165+
Typical values: 1-4 regions per thread.
26166
endif
27167

28168
endmenu

0 commit comments

Comments
 (0)