crosspoint-reader/platformio.ini

79 lines
2.3 KiB
INI
Raw Normal View History

2025-12-08 23:13:33 +11:00
[platformio]
2026-01-03 19:42:14 +11:00
crosspoint_version = 0.12.0
2025-12-08 23:13:33 +11:00
default_envs = default
2025-12-03 22:00:29 +11:00
2025-12-08 23:13:33 +11:00
[base]
2025-12-23 12:16:42 +11:00
platform = espressif32 @ 6.12.0
2025-12-03 22:00:29 +11:00
board = esp32-c3-devkitm-1
framework = arduino
monitor_speed = 115200
upload_speed = 921600
check_tool = cppcheck
check_flags = --enable=all --suppress=missingIncludeSystem --suppress=unusedFunction --suppress=unmatchedSuppression --suppress=*:*/.pio/* --inline-suppr
check_skip_packages = yes
2025-12-03 22:00:29 +11:00
board_upload.flash_size = 16MB
board_upload.maximum_size = 16777216
board_upload.offset_address = 0x10000
build_flags =
-DARDUINO_USB_MODE=1
-DARDUINO_USB_CDC_ON_BOOT=1
-DMINIZ_NO_ZLIB_COMPATIBLE_NAMES=1
-DEINK_DISPLAY_SINGLE_BUFFER_MODE=1
-DDISABLE_FS_H_WARNING=1
2025-12-08 23:13:33 +11:00
# https://libexpat.github.io/doc/api/latest/#XML_GE
-DXML_GE=0
-DXML_CONTEXT_BYTES=1024
-std=c++2a
# Enable UTF-8 long file names in SdFat
-DUSE_UTF8_LONG_NAMES=1
Fix WiFi file transfer lockup and add performance optimizations This commit resolves critical stability issues causing WiFi file transfer crashes in STA mode and adds aggressive performance optimizations for maximum upload/download throughput. CRITICAL BUG FIXES: 1. Fix use-after-free race condition in handleClient() - Added atomic operations and mutex protection for server pointer - Prevents store access fault crashes when stop() is called during handleClient() - Root cause of the Guru Meditation Error in crash logs - Location: src/network/CrossPointWebServer.cpp:135-158 2. Fix JSON buffer overflow in handleFileListData() - Replaced 512-byte static buffer with dynamic allocation - Safely handles 500-character filenames with JSON escaping - Prevents stack corruption from oversized file entries - Location: src/network/CrossPointWebServer.cpp:253-306 3. Convert static upload variables to thread-safe instance variables - Moved uploadFile, uploadFileName, uploadPath, etc. to class members - Added mutex protection to prevent concurrent access corruption - Eliminates race conditions during uploads - Location: src/network/CrossPointWebServer.h:44-54, CrossPointWebServer.cpp:311-313 4. Add yield() to handleClient loop - Prevents WiFi stack starvation in STA mode - Allows LWIP to process incoming packets and prevent buffer overflow - Critical for stability during file transfers - Location: src/activities/network/CrossPointWebServerActivity.cpp:304-311 5. Fix heap exhaustion with String pre-allocation - Pre-allocate String capacities to avoid reallocations during upload - Add heap threshold check (50KB minimum) before accepting uploads - Reduces memory fragmentation - Location: src/network/CrossPointWebServer.cpp:323-376 ROBUSTNESS IMPROVEMENTS: 6. Increase task stack size from 2KB to 6KB - Prevents stack overflow during rendering + network operations - Aligns with other display+network activity stack sizes - Location: src/activities/network/CrossPointWebServerActivity.cpp:51 PERFORMANCE OPTIMIZATIONS: 7. Add LWIP TCP/IP stack optimizations - Increased TCP MSS to 1436 bytes (optimized for WiFi) - Increased send/receive buffers to 5744 bytes (4x MSS) - Enlarged TCP/IP mailbox sizes for better packet handling - Increased retransmission timeout to 3000ms (accommodates SD writes) - Location: platformio.ini:31-49 8. Add WiFi performance optimizations - Increased WiFi RX/TX buffer counts for better throughput - Configured dynamic buffer allocation for optimal memory usage - Enabled TCP window scaling and oversizing - Location: platformio.ini:41-49 9. Maximize WiFi TX power - Set WiFi TX power to maximum (19.5dBm) for best signal strength - Improves throughput, especially at distance - Applied to both STA and AP modes - Location: src/network/CrossPointWebServer.cpp:58, src/activities/network/CrossPointWebServerActivity.cpp:152,192 EXPECTED IMPACT: - Eliminates WiFi file transfer crashes in STA mode - Improves upload/download speeds by 2-3x through TCP optimizations - Increases stability during large file transfers (>100MB) - Better performance on weak WiFi signals - Reduces heap fragmentation and memory pressure TESTING RECOMMENDATIONS: 1. Test large file uploads (>50MB) in both STA and AP modes 2. Verify system stability during concurrent uploads 3. Monitor heap usage during file transfers 4. Test with long filenames (400+ characters) 5. Verify performance improvement with speed tests Fixes: WiFi lockup bug causing Guru Meditation Errors during file transfer
2026-01-09 22:03:16 +00:00
# LWIP TCP/IP stack optimizations for WiFi file transfer performance
# These settings optimize buffer sizes and TCP parameters for maximum throughput
-DCONFIG_LWIP_MAX_SOCKETS=10
-DCONFIG_LWIP_TCP_MSS=1436
-DCONFIG_LWIP_TCP_SND_BUF_DEFAULT=5744
-DCONFIG_LWIP_TCP_WND_DEFAULT=5744
-DCONFIG_LWIP_TCP_RECVMBOX_SIZE=12
-DCONFIG_LWIP_UDP_RECVMBOX_SIZE=12
-DCONFIG_LWIP_TCPIP_RECVMBOX_SIZE=32
-DCONFIG_LWIP_TCP_RTO_TIME=3000
# WiFi performance optimizations
-DCONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=16
-DCONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=32
-DCONFIG_ESP32_WIFI_TX_BUFFER_TYPE=1
-DCONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=32
# TCP optimizations for file uploads
-DCONFIG_LWIP_TCP_OVERSIZE=1
-DCONFIG_LWIP_WND_SCALE=1
-DCONFIG_LWIP_TCP_RCV_SCALE=2
2025-12-03 22:00:29 +11:00
2025-12-08 23:13:33 +11:00
; Board configuration
board_build.flash_mode = dio
board_build.flash_size = 16MB
board_build.partitions = partitions.csv
Add connect to Wifi and File Manager Webserver (#41) ## Summary - **What is the goal of this PR?** Implements wireless EPUB file management via a built-in web server, enabling users to upload, browse, organize, and delete EPUB files from any device on the same WiFi network without needing a computer cable connection. - **What changes are included?** - **New Web Server** ([`CrossPointWebServer.cpp`](src/CrossPointWebServer.cpp), [`CrossPointWebServer.h`](src/CrossPointWebServer.h)): - HTTP server on port 80 with a responsive HTML/CSS interface - Home page showing device status (version, IP, free memory) - File Manager with folder navigation and breadcrumb support - EPUB file upload with progress tracking - Folder creation and file/folder deletion - XSS protection via HTML escaping - Hidden system folders (`.` prefixed, "System Volume Information", "XTCache") - **WiFi Screen** ([`WifiScreen.cpp`](src/screens/WifiScreen.cpp), [`WifiScreen.h`](src/screens/WifiScreen.h)): - Network scanning with signal strength indicators - Visual indicators for encrypted (`*`) and saved (`+`) networks - State machine managing: scanning, network selection, password entry, connecting, save/forget prompts - 15-second connection timeout handling - Integration with web server (starts on connect, stops on exit) - **WiFi Credential Storage** ([`WifiCredentialStore.cpp`](src/WifiCredentialStore.cpp), [`WifiCredentialStore.h`](src/WifiCredentialStore.h)): - Persistent storage in `/sd/.crosspoint/wifi.bin` - XOR obfuscation for stored passwords (basic protection against casual reading) - Up to 8 saved networks with add/remove/update operations - **On-Screen Keyboard** ([`OnScreenKeyboard.cpp`](src/screens/OnScreenKeyboard.cpp), [`OnScreenKeyboard.h`](src/screens/OnScreenKeyboard.h)): - Reusable QWERTY keyboard component with shift support - Special keys: Shift, Space, Backspace, Done - Support for password masking mode - **Settings Screen Integration** ([`SettingsScreen.h`](src/screens/SettingsScreen.h)): - Added WiFi action to navigate to the new WiFi screen - **Documentation** ([`docs/webserver.md`](docs/webserver.md)): - Comprehensive user guide covering WiFi setup, web interface usage, file management, troubleshooting, and security notes - See this for more screenshots! - Working "displays the right way in GitHub" on my repo: https://github.com/olearycrew/crosspoint-reader/blob/feature/connect-to-wifi/docs/webserver.md **Video demo** https://github.com/user-attachments/assets/283e32dc-2d9f-4ae2-848e-01f41166a731 ## Additional Context - **Security considerations**: The web server has no authentication—anyone on the same WiFi network can access files. This is documented as a limitation, recommending use only on trusted private networks. Password obfuscation in the credential store is XOR-based, not cryptographically secure. - **Memory implications**: The web server and WiFi stack consume significant memory. The implementation properly cleans up (stops server, disconnects WiFi, sets `WIFI_OFF` mode) when exiting the WiFi screen to free resources. - **Async operations**: Network scanning and connection use async patterns with FreeRTOS tasks to prevent blocking the UI. The display task handles rendering on a dedicated thread with mutex protection. - **Browser compatibility**: The web interface uses standard HTML5/CSS3/JavaScript and is tested to work with all modern browsers on desktop and mobile. --------- Co-authored-by: Dave Allie <dave@daveallie.com>
2025-12-19 09:05:43 -05:00
extra_scripts =
pre:scripts/build_html.py
2025-12-03 22:00:29 +11:00
; Libraries
lib_deps =
BatteryMonitor=symlink://open-x4-sdk/libs/hardware/BatteryMonitor
2025-12-06 12:35:41 +11:00
InputManager=symlink://open-x4-sdk/libs/hardware/InputManager
EInkDisplay=symlink://open-x4-sdk/libs/display/EInkDisplay
SDCardManager=symlink://open-x4-sdk/libs/hardware/SDCardManager
ArduinoJson @ 7.4.2
QRCode @ 0.0.1
2025-12-08 23:13:33 +11:00
[env:default]
extends = base
build_flags =
${base.build_flags}
-DCROSSPOINT_VERSION=\"${platformio.crosspoint_version}-dev\"
[env:gh_release]
extends = base
build_flags =
${base.build_flags}
-DCROSSPOINT_VERSION=\"${platformio.crosspoint_version}\"