فهرست منبع

Enhance Kconfig help for finsh and dfs components

Co-authored-by: Rbb666 <64397326+Rbb666@users.noreply.github.com>
copilot-swe-agent[bot] 3 ماه پیش
والد
کامیت
0978768bae
2فایلهای تغییر یافته به همراه516 افزوده شده و 4 حذف شده
  1. 285 2
      components/dfs/Kconfig
  2. 231 2
      components/finsh/Kconfig

+ 285 - 2
components/dfs/Kconfig

@@ -5,16 +5,72 @@ config RT_USING_DFS
     select RT_USING_MUTEX
     default y
     help
-        The device file system is a light weight virtual file system.
+        DFS (Device File System) is RT-Thread's lightweight virtual file system.
+        
+        Provides unified file system abstraction layer supporting:
+        - Multiple file system types (FAT, ROM-FS, RAM-FS, NFS, etc.)
+        - POSIX-like file operations (open, read, write, close)
+        - Device file access (/dev/uart1, /dev/spi0, etc.)
+        - Mount points for different file systems
+        - Working directory support
+        
+        Features:
+        - Small footprint (~5-10KB depending on configuration)
+        - POSIX API compatibility for easier porting
+        - Multiple file systems can coexist
+        - Thread-safe operations with mutex protection
+        
+        Typical use cases:
+        - File logging and data storage
+        - Configuration file management
+        - Device access abstraction
+        - Network file systems (NFS)
+        
+        Enable for applications requiring file system support.
+        Disable for simple applications to save ~10-15KB ROM.
 
 if RT_USING_DFS
     config DFS_USING_POSIX
         bool "Using posix-like functions, open/read/write/close"
         default y
+        help
+            Enable POSIX-compliant file I/O API functions.
+            
+            Provides standard POSIX file operations:
+            - open(), close(), read(), write()
+            - lseek(), stat(), fstat()
+            - opendir(), readdir(), closedir()
+            - mkdir(), rmdir(), unlink(), rename()
+            
+            Benefits:
+            - Easier code porting from Linux/POSIX systems
+            - Familiar API for developers
+            - Better compatibility with third-party libraries
+            
+            Required for most applications using file operations.
+            Disable only if using custom file I/O API.
 
     config DFS_USING_WORKDIR
         bool "Using working directory"
         default y
+        help
+            Enable working directory (current directory) support.
+            
+            Features:
+            - Each thread can have its own working directory
+            - chdir() to change current directory
+            - Relative paths resolved from working directory
+            - getcwd() to get current directory path
+            
+            Essential for:
+            - Shell commands (cd, pwd)
+            - Relative path operations
+            - Multi-threaded file access with different contexts
+            
+            Memory cost: ~256 bytes per thread for path storage
+            
+            Recommended to keep enabled for convenience.
+            Disable to save minimal RAM if only using absolute paths.
 
 if RT_USING_DFS_V1
     config RT_USING_DFS_MNTTABLE
@@ -33,36 +89,138 @@ endif
     config DFS_FD_MAX
         int "The maximal number of opened files"
         default 16
+        help
+            Maximum number of file descriptors that can be opened simultaneously
+            across all threads in the system.
+            
+            Default: 16
+            
+            Each open file descriptor uses ~40-60 bytes of RAM.
+            Total memory: DFS_FD_MAX × ~50 bytes
+            
+            Increase if:
+            - Application opens many files concurrently
+            - Multiple threads access files simultaneously
+            - Getting "too many open files" errors
+            
+            Decrease to save RAM on memory-constrained systems (minimum ~4).
+            
+            Note: This is system-wide limit, not per-thread.
 
     choice RT_USING_DFS_VERSION
         prompt "The version of DFS"
         default RT_USING_DFS_V1
         default RT_USING_DFS_V2 if RT_USING_SMART
+        help
+            Select DFS version for your system.
+            
+            DFS v1.0:
+            - Traditional DFS implementation
+            - Stable and well-tested
+            - Suitable for most embedded applications
+            - Lower memory overhead
+            
+            DFS v2.0:
+            - Enhanced for RT-Smart user-space applications
+            - Page cache support for better performance
+            - Memory-mapped file support (mmap)
+            - Required for RT-Smart mode
+            
+            Choose v1.0 for standard RT-Thread applications.
+            Choose v2.0 for RT-Smart with user-space processes.
 
         config RT_USING_DFS_V1
             bool "DFS v1.0"
             depends on !RT_USING_SMART
+            help
+                DFS version 1.0 - traditional implementation.
+                
+                Stable version for standard RT-Thread applications without
+                user-space process support.
 
         config RT_USING_DFS_V2
             bool "DFS v2.0"
             select RT_USING_DEVICE_OPS
+            help
+                DFS version 2.0 - enhanced for RT-Smart.
+                
+                Advanced features:
+                - Page cache for improved performance
+                - Memory-mapped files (mmap)
+                - Better integration with RT-Smart processes
+                - Enhanced POSIX compliance
+                
+                Required for RT-Smart mode.
     endchoice
 
 if RT_USING_DFS_V1
     config DFS_FILESYSTEMS_MAX
         int "The maximal number of mounted file system"
         default 4
+        help
+            Maximum number of file systems that can be mounted simultaneously.
+            
+            Default: 4 mount points
+            
+            Each mount point uses ~40-60 bytes.
+            Examples:
+            - "/" - root file system (FAT/ROM/RAM)
+            - "/sdcard" - SD card FAT
+            - "/dev" - device file system
+            - "/tmp" - temporary file system
+            
+            Increase if you need more mount points.
+            Decrease to save RAM on simple systems (minimum 1).
 
     config DFS_FILESYSTEM_TYPES_MAX
         int "The maximal number of file system type"
         default 4
+        help
+            Maximum number of different file system types registered.
+            
+            Default: 4 types
+            
+            Common file system types:
+            - elm (FAT/exFAT)
+            - romfs (Read-Only Memory FS)
+            - ramfs (RAM FS)
+            - devfs (Device FS)
+            - nfs (Network FS)
+            - tmpfs (Temporary FS)
+            
+            Each type registration uses ~20-30 bytes.
+            Set based on number of file system types you plan to use.
 endif
 
     config RT_USING_DFS_ELMFAT
         bool "Enable elm-chan fatfs"
         default n
         help
-            FatFs is a generic FAT/exFAT file system module for small embedded systems.
+            Enable elm-chan's FAT file system implementation.
+            
+            FatFs is a generic FAT/exFAT file system module designed for
+            embedded systems with limited resources.
+            
+            Supported file systems:
+            - FAT12, FAT16, FAT32
+            - exFAT (with RT_DFS_ELM_USE_EXFAT enabled)
+            
+            Features:
+            - Long File Name (LFN) support
+            - Unicode file names (UTF-8/UTF-16/UTF-32)
+            - Thread-safe operations
+            - Multiple volumes
+            
+            Use cases:
+            - SD card file storage
+            - USB flash drives
+            - Internal flash storage
+            - Data logging
+            
+            ROM overhead: ~15-25KB depending on features enabled.
+            
+            Enable for FAT-formatted storage devices.
+            Disable if not using FAT file systems.
 
     if RT_USING_DFS_ELMFAT
         menu "elm-chan's FatFs, Generic FAT Filesystem Module"
@@ -161,6 +319,29 @@ endif
     config RT_USING_DFS_DEVFS
         bool "Using devfs for device objects"
         default y
+        help
+            Enable device file system (devfs) for accessing devices as files.
+            
+            Devfs provides /dev directory containing device nodes:
+            - /dev/uart1, /dev/uart2 - Serial ports
+            - /dev/spi0, /dev/i2c0 - Bus devices
+            - /dev/sd0, /dev/sd1 - Block devices
+            - /dev/rtc - Real-time clock
+            
+            Benefits:
+            - Unified device access via open/read/write
+            - POSIX-compliant device operations
+            - Better abstraction and portability
+            - Required for many device drivers
+            
+            Essential for:
+            - Device access from user applications
+            - RT-Smart user-space processes
+            - Shell device operations
+            
+            Minimal overhead (~1-2KB ROM, ~100 bytes RAM).
+            
+            Recommended to keep enabled for device access convenience.
 
 if RT_USING_DFS_V1
     config RT_USING_DFS_ISO9660
@@ -172,6 +353,31 @@ endif
     menuconfig RT_USING_DFS_ROMFS
         bool "Enable ReadOnly file system on flash"
         default n
+        help
+            Enable ROM File System for read-only data stored in flash memory.
+            
+            ROMFS stores read-only files directly in program flash, useful for:
+            - Static web pages for web servers
+            - Configuration files
+            - Font files and graphics resources
+            - Help files and documentation
+            - Initial file system bootstrap
+            
+            Features:
+            - Very small footprint (~2-3KB)
+            - No RAM required for file data (executes from flash)
+            - Files embedded in firmware binary
+            - Fast access (no erase/write delays)
+            
+            Files included at compile time using romfs generator tool.
+            
+            Use cases:
+            - Web server static content
+            - Resource files for GUI applications
+            - Read-only configuration defaults
+            
+            Enable if you need embedded read-only files.
+            Disable to save ~2-3KB ROM if not needed.
 
     if RT_USING_DFS_ROMFS
         config RT_USING_DFS_ROMFS_USER_ROOT
@@ -194,6 +400,32 @@ endif
         bool "Enable ReadOnly compressed file system on flash"
         default n
         # select PKG_USING_ZLIB
+        help
+            Enable Compressed ROM File System for compressed read-only data.
+            
+            CROMFS is similar to ROMFS but with compression, providing:
+            - Reduced flash usage (typically 30-70% compression)
+            - Read-only access to compressed files
+            - Automatic decompression on read
+            - Files embedded in firmware binary
+            
+            Trade-offs:
+            + Saves flash space (important for large resource files)
+            - Higher CPU usage for decompression
+            - Slower file access than ROMFS
+            - Requires ZLIB for decompression
+            
+            Best for:
+            - Large resource files (fonts, graphics, web content)
+            - Flash-constrained systems
+            - Files accessed infrequently
+            
+            Not recommended for:
+            - Frequently accessed files
+            - CPU-constrained systems
+            - Files already compressed (JPEG, PNG, MP3)
+            
+            Note: Requires ZLIB package for decompression support.
 
 if RT_USING_DFS_V1
     config RT_USING_DFS_RAMFS
@@ -206,12 +438,63 @@ endif
         bool "Enable TMP file system"
         default y if RT_USING_SMART
         default n
+        help
+            Enable temporary file system (tmpfs) in RAM.
+            
+            Tmpfs provides a RAM-based file system for temporary files:
+            - Files stored entirely in RAM
+            - Very fast read/write performance
+            - Files lost on reboot/power-off
+            - Dynamic size (grows/shrinks with usage)
+            
+            Typical mount point: /tmp
+            
+            Use cases:
+            - Temporary file storage during runtime
+            - Fast cache for processed data
+            - Inter-process communication via temp files
+            - Build/compile temporary files
+            - RT-Smart /tmp directory
+            
+            Memory usage:
+            - Grows with file content
+            - Files consume RAM directly
+            
+            Automatically enabled for RT-Smart (required for POSIX /tmp).
+            
+            Enable if you need fast temporary file storage.
+            Disable to save RAM if temporary files not needed.
 
     config RT_USING_DFS_MQUEUE
         bool "Enable MQUEUE file system"
         select RT_USING_DEV_BUS
         default y if RT_USING_SMART
         default n
+        help
+            Enable POSIX message queue file system.
+            
+            Provides POSIX message queues as files in /dev/mqueue:
+            - mq_open(), mq_send(), mq_receive()
+            - Named message queues
+            - File descriptor based operations
+            - Process-safe IPC mechanism
+            
+            Features:
+            - POSIX-compliant message queue API
+            - Multiple processes can communicate
+            - Priority-based message delivery
+            - Blocking and non-blocking modes
+            
+            Use cases:
+            - Inter-process communication in RT-Smart
+            - POSIX application porting
+            - Priority message passing
+            
+            Required for RT-Smart POSIX message queues.
+            Automatically enabled in RT-Smart mode.
+            
+            Enable for POSIX message queue support.
+            Disable if not using POSIX IPC (~2-3KB ROM savings).
 
 if RT_USING_DFS_V1
     config RT_USING_DFS_NFS

+ 231 - 2
components/finsh/Kconfig

@@ -3,95 +3,324 @@ menuconfig RT_USING_MSH
     default n if RT_USING_NANO
     default y
     select RT_USING_SEMAPHORE
+    help
+        MSH (Module SHell) is RT-Thread's command-line interface (CLI) shell.
+        
+        Provides interactive command execution for:
+        - System debugging and monitoring
+        - Runtime configuration and testing
+        - File system operations
+        - Network diagnostics
+        - Custom application commands
+        
+        Features:
+        - Tab completion for commands and file paths
+        - Command history with arrow keys
+        - Built-in commands (ls, ps, free, etc.)
+        - Custom command registration via MSH_CMD_EXPORT()
+        - Authentication support for secure access
+        
+        Typical use cases:
+        - Development and debugging
+        - Production diagnostics
+        - Interactive testing
+        - System administration
+        
+        Note: Disable for headless embedded systems to save ~8-16KB ROM.
+        Automatically disabled in RT_USING_NANO configuration.
 
 if RT_USING_MSH
 
     config RT_USING_FINSH
         bool
         default y
+        help
+            Internal configuration for finsh shell support.
+            Automatically enabled when RT_USING_MSH is selected.
+            Do not modify directly.
 
     config FINSH_USING_MSH
         bool
         default y
+        help
+            Use MSH (Module SHell) mode instead of traditional C-expression shell.
+            MSH provides a more familiar POSIX-like command interface.
+            Automatically enabled when RT_USING_MSH is selected.
+            Do not modify directly.
 
     config FINSH_THREAD_NAME
         string "The msh thread name"
         default "tshell"
+        help
+            Name of the MSH shell thread visible in thread list.
+            
+            Default: "tshell"
+            
+            Change this to avoid name conflicts or for identification purposes.
+            Thread name length limited by RT_NAME_MAX (default 8 chars).
 
     config FINSH_THREAD_PRIORITY
         int "The priority level value of thread"
         default 20
+        help
+            Priority of MSH shell thread (lower number = higher priority).
+            
+            Default: 20 (low priority)
+            
+            Recommendations:
+            - Keep at low priority (15-25) to avoid blocking real-time tasks
+            - Increase priority if shell responsiveness is critical
+            - Must be less than RT_THREAD_PRIORITY_MAX
+            
+            Note: Shell executes user commands which may have high CPU usage.
 
     config FINSH_THREAD_STACK_SIZE
         int "The stack size for thread"
         default 4096
+        help
+            Stack size in bytes for the MSH shell thread.
+            
+            Default: 4096 bytes (4KB)
+            
+            Increase if:
+            - Shell commands use deep recursion or large local variables
+            - Running complex scripts
+            - Stack overflow errors occur
+            
+            Decrease to save RAM on memory-constrained systems (minimum ~2KB).
+            
+            Note: Each command execution may require additional stack space.
 
     config FINSH_USING_HISTORY
         bool "Enable command history feature"
         default y
+        help
+            Enable command history buffer with up/down arrow key navigation.
+            
+            Features:
+            - Recall previous commands with up arrow
+            - Navigate forward with down arrow
+            - Configurable number of history lines
+            
+            Memory cost: ~80 bytes × FINSH_HISTORY_LINES
+            
+            Enable for improved user experience during interactive sessions.
+            Disable to save minimal RAM (~400 bytes with default 5 lines).
 
     if FINSH_USING_HISTORY
         config FINSH_HISTORY_LINES
             int "The command history line number"
             default 5
+            help
+                Number of command lines stored in history buffer.
+                
+                Default: 5 lines
+                
+                Each line uses ~80 bytes (FINSH_CMD_SIZE).
+                Total memory: FINSH_HISTORY_LINES × FINSH_CMD_SIZE
+                
+                Increase for longer history (up to ~10-20 lines reasonable).
+                Decrease to save RAM on constrained systems.
     endif
 
     config FINSH_USING_WORD_OPERATION
         bool "Enable word-based cursor operations"
         default n
         help
-            Enable Ctrl+Backspace to delete words and Ctrl+Arrow to move cursor by word
+            Enable Ctrl+Backspace to delete words and Ctrl+Arrow to move cursor by word.
+            
+            Provides enhanced editing with word-boundary operations:
+            - Ctrl+Backspace: Delete word before cursor
+            - Ctrl+Left/Right Arrow: Move cursor by word
+            
+            Improves command-line editing efficiency for long commands.
+            Minimal memory overhead (~100 bytes).
         
     config FINSH_USING_FUNC_EXT
         bool "Enable function extension home end ins del"
         default n
         help
-            Enable function extension home end ins del.
+            Enable extended function keys for cursor movement and editing.
+            
+            Supported keys:
+            - Home: Move cursor to start of line
+            - End: Move cursor to end of line
+            - Insert: Toggle insert/overwrite mode
+            - Delete: Delete character at cursor
+            
+            Provides familiar editing experience from standard terminals.
+            Minimal memory overhead (~100 bytes).
 
     config FINSH_USING_SYMTAB
         bool "Using symbol table for commands"
         default y
+        help
+            Use symbol table to store and lookup shell commands.
+            
+            When enabled:
+            - Commands registered via MSH_CMD_EXPORT() are stored in symbol table
+            - Supports command name lookup and auto-completion
+            - Enables help command to list all available commands
+            
+            Required for most shell functionality. Only disable for minimal
+            configurations where commands are hard-coded.
+            
+            Disabling saves ~1-2KB depending on number of commands.
 
     config FINSH_CMD_SIZE
         int "The command line size for shell"
         default 80
+        help
+            Maximum length of a single command line including arguments.
+            
+            Default: 80 characters
+            
+            Increase if you need to:
+            - Enter long file paths
+            - Pass many arguments to commands
+            - Use complex command pipelines
+            
+            Decrease to save RAM (minimum ~40 chars recommended).
+            
+            Memory impact: FINSH_CMD_SIZE bytes per command buffer +
+            FINSH_CMD_SIZE × FINSH_HISTORY_LINES for history
 
     config MSH_USING_BUILT_IN_COMMANDS
         bool "Enable built-in commands, such as list_thread"
         default y
+        help
+            Include standard built-in shell commands.
+            
+            Built-in commands include:
+            - System: help, version, reboot
+            - Threads: list_thread (ps), list_sem, list_mutex, list_timer
+            - Memory: free, memcheck, memtrace
+            - File system: ls, cd, pwd, cat, rm, mkdir, etc.
+            
+            Disabling removes these commands but allows custom implementations.
+            Saves ~4-8KB ROM depending on enabled features.
+            
+            Recommended to keep enabled unless implementing custom command set.
 
     config FINSH_USING_DESCRIPTION
         bool "Keeping description in symbol table"
         default y
+        help
+            Store command descriptions in symbol table for help text.
+            
+            When enabled:
+            - 'help' command shows detailed description for each command
+            - MSH_CMD_EXPORT() macro can include description parameter
+            
+            Cost: ~20-50 bytes per command for description strings
+            
+            Disable to save ROM if help text not needed in production.
+            Keep enabled during development for better usability.
 
     config FINSH_ECHO_DISABLE_DEFAULT
         bool "Disable the echo mode in default"
         default n
+        help
+            Disable character echo by default when shell starts.
+            
+            When disabled (echo off):
+            - Typed characters not displayed (useful for password input)
+            - Can be toggled at runtime with 'echo' command
+            
+            Normal configuration: Keep disabled (echo enabled by default)
+            
+            Enable this option to start with echo off, useful for:
+            - Security-sensitive applications
+            - Non-interactive serial protocols
+            - Automated test scripts
 
     config FINSH_USING_AUTH
         bool "shell support authentication"
         default n
+        help
+            Enable password authentication for shell access.
+            
+            Security features:
+            - Password prompt on shell connection
+            - Configurable password and length requirements
+            - Locks shell until correct password entered
+            
+            Use cases:
+            - Production systems with console access
+            - Security-critical applications
+            - Preventing unauthorized access via UART/Telnet
+            
+            Note: Password stored in plain text in firmware.
+            For strong security, combine with encrypted communication.
 
     if FINSH_USING_AUTH
         config FINSH_DEFAULT_PASSWORD
             string "The default password for shell authentication"
             default "rtthread"
+            help
+                Default password required to access the shell.
+                
+                Default: "rtthread"
+                
+                Security recommendations:
+                - Change from default in production systems
+                - Use strong passwords (mix of letters, numbers, symbols)
+                - Length between FINSH_PASSWORD_MIN and FINSH_PASSWORD_MAX
+                
+                Note: Password stored as plain text in firmware binary.
+                Anyone with firmware access can extract the password.
 
         config FINSH_PASSWORD_MIN
             int "The password min length"
             default 6
+            help
+                Minimum password length in characters.
+                
+                Default: 6 characters
+                
+                Enforces minimum password strength. Increase for better security
+                (recommended: 8+ characters for production).
 
         config FINSH_PASSWORD_MAX
             int "The password max length"
             default RT_NAME_MAX
+            help
+                Maximum password length in characters.
+                
+                Default: RT_NAME_MAX (typically 8)
+                
+                Limited by password buffer size. Increase RT_NAME_MAX if you
+                need longer passwords, but consider memory constraints.
     endif
 
     config FINSH_ARG_MAX
         int "The number of arguments for a shell command"
         default 10
+        help
+            Maximum number of arguments (including command name) that can be
+            passed to a single shell command.
+            
+            Default: 10 arguments
+            
+            Increase if you have commands that need many parameters.
+            Each argument slot uses ~4 bytes (pointer size).
+            
+            Total memory: FINSH_ARG_MAX × sizeof(char*)
 
     config FINSH_USING_OPTION_COMPLETION
         bool "command option completion enable"
         default y
+        help
+            Enable tab completion for command options and arguments.
+            
+            Features:
+            - Press Tab to auto-complete command names
+            - Complete file paths when using file system commands
+            - Show list of matches if multiple options available
+            
+            Greatly improves usability and reduces typing errors.
+            Minimal memory overhead (~200 bytes).
+            
+            Recommended to keep enabled for interactive shells.
 
 endif