Skip to content

Conversation

@mutatrum
Copy link
Collaborator

@mutatrum mutatrum commented Sep 17, 2025

Skip statistics and bap when no PSRAM detected, adds warnings.

Runs with ~30kb free memory. Without this change, everything starts crashing and AxeOS is not reachable if PSRAM is not there or not configured correctly.

image image

See #1234 and #826

@github-actions
Copy link

github-actions bot commented Sep 17, 2025

Test Results

19 tests  ±0   19 ✅ ±0   0s ⏱️ ±0s
 1 suites ±0    0 💤 ±0 
 1 files   ±0    0 ❌ ±0 

Results for commit 33de6e3. ± Comparison against base commit 91be798.

♻️ This comment has been updated with latest results.

@mutatrum mutatrum added the enhancement New feature or request label Sep 17, 2025
BitMaker-hub pushed a commit to BitronicsLabs/ESP-Miner that referenced this pull request Nov 27, 2025
Add conditional initialization to support devices without PSRAM,
preventing crashes and ensuring basic functionality remains operational.

Changes:
- Skip BAP initialization when PSRAM unavailable
- Skip statistics and hashrate monitor tasks when no PSRAM detected
- Add clear warning messages for low memory mode
- Mining core functionality remains unaffected

Based on upstream PR: bitaxeorg#1239

This allows devices with misconfigured or missing PSRAM to boot
successfully and mine normally, with only non-critical features
disabled (BAP, statistics logging). Web UI remains fully accessible.
@duckaxe
Copy link
Collaborator

duckaxe commented Nov 27, 2025

@mutatrum Can you pls resolve conflicts so I can push some frontend improvements.

BitMaker-hub pushed a commit to BitronicsLabs/ESP-Miner that referenced this pull request Nov 28, 2025
Additional fixes to prevent crashes on devices without PSRAM by
adding fallback to internal RAM for critical allocations.

Changes:
- ASIC task: Use malloc() fallback for job buffers when no PSRAM
- LVGL display: Use MALLOC_CAP_INTERNAL when no PSRAM
- Websocket task: Disable completely in low memory mode

These allocations were causing immediate crashes on boot before
the conditional task creation in main.c could take effect.

Related to: bitaxeorg#1239
BitMaker-hub pushed a commit to BitronicsLabs/ESP-Miner that referenced this pull request Nov 28, 2025
Critical fix: Disable forced PSRAM requirements in ESP-IDF config
to allow device to boot when PSRAM is not present or misconfigured.

Changes:
- Disable CONFIG_SPIRAM_MODE_OCT (was forcing Octal mode)
- Disable CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY (crash if no PSRAM)
- Enable CONFIG_SPIRAM_IGNORE_INIT_FAIL (boot even if PSRAM init fails)
- Keep CONFIG_SPIRAM_IGNORE_NOTFOUND enabled

This prevents the bootloader from aborting with:
'E cpu_start: Failed to init external RAM!'

Related to: bitaxeorg#1239
BitMaker-hub pushed a commit to BitronicsLabs/ESP-Miner that referenced this pull request Nov 28, 2025
Self-test was aborting boot when PSRAM not found, preventing
device from running in low memory mode.

Changes:
- Skip PSRAM test failure in low memory mode
- Show 'PSRAM:NONE' message instead of 'PSRAM:FAIL'
- Continue self-test execution when no PSRAM detected
- Only fail if PSRAM was expected but initialization failed

This allows factory self-test to complete successfully on
devices without PSRAM, entering low memory mode normally.

Related to: bitaxeorg#1239
BitMaker-hub pushed a commit to BitronicsLabs/ESP-Miner that referenced this pull request Dec 15, 2025
Critical fix: hashrate_monitor_task is essential for display updates,
it cannot be disabled even in low memory mode. Instead, make it use
internal RAM when PSRAM is unavailable.

Problem:
- Previous implementation disabled hashrate_monitor_task without PSRAM
- This task updates SYSTEM_MODULE->current_hashrate shown on display
- Display would show "Gh/s: --" and appear frozen without this task

Solution:
- Modified hashrate_monitor_task to use MALLOC_CAP_INTERNAL when no PSRAM
- Task stack also uses internal RAM via task_mem_caps variable
- Only statistics_task remains disabled (non-critical for display/mining)

Impact:
- Display now works perfectly in low memory mode
- Hashrate, temperature, and all stats update normally
- Small RAM footprint (~3KB for measurements + 8KB stack)

Related to: bitaxeorg#1239
BitMaker-hub pushed a commit to BitronicsLabs/ESP-Miner that referenced this pull request Dec 15, 2025
Comprehensive audit revealed 3 more critical hardcoded SPIRAM usages
that would cause crashes without PSRAM. Added automatic fallback to
internal RAM for all of them.

Problems fixed:
1. LVGL memory pool (lv_conf.h) - MOST CRITICAL
   - All LVGL allocations were hardcoded to SPIRAM
   - Would crash immediately on any display operation
   - Now tries SPIRAM first, falls back to internal RAM

2. DNS server task (dns_server.c) - CRITICAL
   - Task creation hardcoded to SPIRAM
   - Would crash when enabling AP mode (captive portal)
   - Now falls back to internal RAM automatically

3. Stratum heartbeat task (stratum_task.c) - CRITICAL
   - Heartbeat task hardcoded to SPIRAM
   - Would crash when connecting to mining pool
   - Now falls back to internal RAM automatically

Solution:
Changed all from MALLOC_CAP_SPIRAM to
MALLOC_CAP_SPIRAM | MALLOC_CAP_INTERNAL
This makes FreeRTOS automatically use internal RAM if SPIRAM unavailable.

Impact:
- Prevents 3 different crash scenarios in low memory mode
- Mining, display, WiFi AP, and pool connection all work now
- Total additional RAM usage: ~24KB (3 x 8KB task stacks)

Related to: bitaxeorg#1239
BitMaker-hub pushed a commit to BitronicsLabs/ESP-Miner that referenced this pull request Dec 15, 2025
After comprehensive RAM analysis, determined that ESP32-S3 has sufficient
internal RAM (~320KB) to run both statistics and websocket features even
without PSRAM. Memory usage analysis shows safe margins.

Changes:
1. Statistics task - ENABLED with internal RAM fallback
   - Modified statistics_task.c buffer allocation to use fallback
   - Task always created, uses MALLOC_CAP_SPIRAM | MALLOC_CAP_INTERNAL
   - Buffer grows gradually (0→32KB over 1 hour)
   - Enables historical stats graphs in AxeOS

2. Websocket logs - ENABLED with internal RAM fallback
   - Modified http_server.c to always create websocket task
   - Modified websocket.c queue to use standard xQueueCreate
   - Only ~8.5KB overhead, mostly unused without connected clients
   - Enables live log streaming in Web UI for debugging

RAM Analysis (see MEMORY_ANALYSIS.md):
- Base system: ~130-140KB
- With statistics + websocket at boot: ~173KB used, 147KB free (46%)
- Worst case after 1 hour: ~217KB used, 103KB free (32%)
- Minimum recommended free: 80KB (25%)
- Safety margin: Excellent ✅

Benefits:
- Full AxeOS functionality (statistics graphs work)
- Better debugging experience (websocket logs)
- Only BAP remains disabled (rarely used, 26KB overhead)

Impact: Low memory mode now has nearly full feature parity with PSRAM mode,
only missing BAP protocol which is non-essential for most users.

Related to: bitaxeorg#1239
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants