Skip to content

Commit bca7092

Browse files
authored
Merge pull request #14 from Advanced-Crypto-Services/ACSOS-RELEASE-v0.1
ACSOS v0.1 Initial release - Adding CRC Functions for Bitaxe Touch - ACSOS WebUI - Autotune framework directly in ACS-ESP-MINER - Better theme syncing - Better Model Management for Bitaxe Touch
2 parents 8095fad + cf80496 commit bca7092

File tree

103 files changed

+11628
-197
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+11628
-197
lines changed

.DS_Store

10 KB
Binary file not shown.

.github/.DS_Store

6 KB
Binary file not shown.

.gitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ dependencies.lock
55

66
# Visual Studio Code
77
.vscode/*
8-
!.vscode/settings.json
9-
!.vscode/tasks.json
10-
!.vscode/launch.json
11-
!.vscode/extensions.json
128
.history/*
139

1410
# Production folder

autotune.md

Lines changed: 268 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,268 @@
1+
# Autotune and Presets Documentation
2+
3+
## Overview
4+
5+
The ESP miner implements two complementary systems for power management optimization:
6+
7+
1. **Presets System**: Pre-configured settings for different performance profiles
8+
2. **Autotuning Logic**: Dynamic adjustment of mining parameters based on real-time conditions
9+
10+
## Presets System
11+
12+
### Device Model Support
13+
14+
The presets system supports four device models, each with tailored configurations:
15+
16+
- **DEVICE_MAX**: 1x BM1397 Asic from the S17 series
17+
- **DEVICE_ULTRA**: 1x BM1366 Asic from S19XP
18+
- **DEVICE_SUPRA**: 1x BM1368 Asic from S21
19+
- **DEVICE_GAMMA**: 1x BM1370 Asic from S21 Pro
20+
21+
### Preset Profiles
22+
23+
Each device model supports three preset profiles:
24+
25+
#### Quiet Mode
26+
- **Purpose**: Low power consumption and noise
27+
- **Characteristics**: Conservative voltage and frequency settings
28+
- **Use Case**: Home mining, noise-sensitive environments
29+
30+
#### Balanced Mode
31+
- **Purpose**: Optimal performance-to-efficiency ratio
32+
- **Characteristics**: Moderate voltage and frequency settings
33+
- **Use Case**: General purpose mining
34+
35+
#### Turbo Mode
36+
- **Purpose**: Maximum performance
37+
- **Characteristics**: High voltage and frequency settings
38+
- **Use Case**: Maximum hashrate scenarios
39+
40+
### Preset Configuration Examples
41+
42+
| Device Model | Profile | Voltage (mV) | Frequency (MHz) | Fan Speed (%) |
43+
|--------------|---------|--------------|-----------------|---------------|
44+
| DEVICE_MAX | quiet | 1100 | 450 | 50 |
45+
| DEVICE_MAX | balanced| 1200 | 550 | 65 |
46+
| DEVICE_MAX | turbo | 1400 | 750 | 100 |
47+
| DEVICE_ULTRA | quiet | 1130 | 420 | 25 |
48+
| DEVICE_ULTRA | balanced| 1190 | 490 | 35 |
49+
| DEVICE_ULTRA | turbo | 1250 | 625 | 95 |
50+
51+
### Preset Application Process
52+
53+
When a preset is applied:
54+
55+
1. **Safety First**: Fan speed is temporarily set to 100% for safety
56+
2. **Parameter Setting**: Voltage, frequency, and fan speed are configured
57+
3. **NVS Storage**: Settings are persisted to non-volatile storage
58+
4. **Autotune Enable**: Autotune flag is activated
59+
5. **Logging**: Configuration change is logged to database
60+
61+
### NVS Configuration Keys
62+
63+
- `NVS_CONFIG_ASIC_VOLTAGE`: Core voltage in millivolts
64+
- `NVS_CONFIG_ASIC_FREQ`: ASIC frequency in MHz
65+
- `NVS_CONFIG_FAN_SPEED`: Fan speed percentage
66+
- `NVS_CONFIG_AUTOTUNE_PRESET`: Applied preset name
67+
- `NVS_CONFIG_AUTOTUNE_FLAG`: Autotune enable/disable flag
68+
- `NVS_CONFIG_AUTO_FAN_SPEED`: Automatic fan control flag
69+
70+
## Autotuning Logic
71+
72+
### Purpose
73+
74+
The autotuning system dynamically adjusts mining parameters to:
75+
- Maintain optimal operating temperature (60°C target)
76+
- Maximize hashrate within power and thermal limits
77+
- Prevent overheating and hardware damage
78+
- Optimize performance-per-watt efficiency
79+
80+
### Key Parameters
81+
82+
#### Target Values
83+
- **Target Temperature**: 60°C (optimal ASIC operating temperature)
84+
- **Temperature Tolerance**: ±2°C around target
85+
- **Hashrate Target**: Calculated based on frequency and core count
86+
87+
#### Safety Limits
88+
- **Maximum Power**: Device-specific power limit
89+
- **Maximum Voltage**: Device-specific voltage limit
90+
- **Maximum Frequency**: Device-specific frequency limit
91+
- **Thermal Limits**: 75°C throttle, 90°C emergency shutdown
92+
93+
### Timing Mechanism
94+
95+
#### Warmup Period
96+
- **Duration**: 15 minutes (900 seconds) from startup
97+
- **Purpose**: Allow system to reach thermal equilibrium
98+
- **Behavior**: No adjustments during warmup if temperature < target
99+
100+
#### Adjustment Intervals
101+
- **Normal Operation**: 5 minutes (300 seconds) when temp ≤ 68°C
102+
- **High Temperature**: 5 seconds when temp > 68°C
103+
- **Purpose**: Faster response during thermal stress
104+
105+
### Temperature-Based Adjustments
106+
107+
#### Temperature Within Target Range (-2°C to +2°C)
108+
**Condition**: Temperature is 58°C - 62°C
109+
110+
**Action**: Hashrate optimization
111+
- If hashrate < 80% of target: Increase voltage by 10mV
112+
- If hashrate ≥ 80% of target: No adjustment needed
113+
114+
#### Temperature Below Target (< -2°C)
115+
**Condition**: Temperature < 58°C
116+
117+
**Actions**: Performance increase
118+
- Increase frequency by 2% (if within limits)
119+
- Increase voltage by 0.2% (if within limits)
120+
- Check power consumption limits before adjustment
121+
122+
**Safety Checks**:
123+
- Frequency must be below maximum frequency limit
124+
- Power consumption must be below maximum power limit
125+
- Voltage must be below maximum voltage limit
126+
127+
#### Temperature Above Target (> +2°C)
128+
**Condition**: Temperature > 62°C
129+
130+
**Actions**: Performance reduction
131+
- Decrease frequency by 2%
132+
- Decrease voltage by 0.2%
133+
134+
**Purpose**: Reduce heat generation to bring temperature back to target
135+
136+
### Safety and Monitoring
137+
138+
#### Prerequisites for Autotune Operation
139+
- Temperature sensor must be initialized (temp ≠ 255)
140+
- Hashrate must be > 0 (system actively mining)
141+
- Autotune flag must be enabled in NVS configuration
142+
143+
#### Overheat Protection
144+
- **Throttle Temperature**: 75°C - Triggers Overheat Mode
145+
- **VR Temperature Limit**: 105°C throttle, 145°C maximum
146+
- **Actions**: Fan to 100%, voltage/frequency reduction, system shutdown if needed
147+
148+
#### Data Logging
149+
All autotune adjustments are logged to the database with:
150+
- Timestamp and event type
151+
- Current and target values
152+
- Adjustment reasons and amounts
153+
- System state information
154+
155+
### Algorithm Flow
156+
157+
```
158+
1. Check Prerequisites
159+
├── Autotune enabled?
160+
├── Valid temperature reading?
161+
├── Hashrate > 0?
162+
└── Outside warmup period?
163+
164+
2. Timing Check
165+
├── Sufficient time elapsed since last adjustment?
166+
└── Use appropriate interval (normal vs high temp)
167+
168+
3. Temperature Analysis
169+
├── Calculate temperature difference from target (60°C)
170+
└── Determine adjustment strategy
171+
172+
4. Parameter Adjustment
173+
├── Within target range → Optimize hashrate
174+
├── Below target → Increase performance
175+
└── Above target → Decrease performance
176+
177+
5. Safety Validation
178+
├── Check power limits
179+
├── Check voltage limits
180+
├── Check frequency limits
181+
└── Apply changes if safe
182+
183+
6. Logging and Monitoring
184+
├── Log adjustment to database
185+
├── Update NVS configuration
186+
└── Monitor for next cycle
187+
```
188+
189+
### Integration with Hardware Control
190+
191+
#### Voltage Control
192+
- **Module**: VCORE (TPS546 voltage regulator)
193+
- **Range**: Device-specific minimum to maximum voltage
194+
- **Precision**: 1mV increments
195+
- **Response Time**: Immediate
196+
197+
#### Frequency Control
198+
- **Module**: BM1397 ASIC frequency control
199+
- **Range**: 50 MHz to device maximum
200+
- **Precision**: 1 MHz increments
201+
- **Response Time**: Requires frequency transition process
202+
203+
#### Temperature Monitoring
204+
- **Sensor**: EMC2101 temperature controller
205+
- **ASIC Temperature**: External sensor reading
206+
- **VR Temperature**: TPS546 internal temperature
207+
- **Update Rate**: Every 2 seconds (POLL_RATE)
208+
209+
### Performance Optimization Features
210+
211+
#### Adaptive Learning
212+
- System learns optimal settings through operation
213+
- Adjustments become more refined over time
214+
- Historical performance data influences decisions
215+
216+
#### Power Efficiency
217+
- Monitors power consumption vs hashrate
218+
- Optimizes for maximum GH/s per watt
219+
- Prevents power limit violations
220+
221+
#### Thermal Management
222+
- Proactive temperature control
223+
- Coordinated fan speed adjustment
224+
- Prevents thermal damage to components
225+
226+
## Configuration and Usage
227+
228+
### Enabling Autotune
229+
```c
230+
nvs_config_set_u16(NVS_CONFIG_AUTOTUNE_FLAG, 1); // Enable
231+
nvs_config_set_u16(NVS_CONFIG_AUTOTUNE_FLAG, 0); // Disable
232+
```
233+
234+
### Applying Presets
235+
```c
236+
// Apply preset by name
237+
apply_preset(DEVICE_MAX, "balanced");
238+
apply_preset(DEVICE_ULTRA, "turbo");
239+
apply_preset(DEVICE_SUPRA, "quiet");
240+
```
241+
242+
### Manual Override
243+
Individual parameters can be manually set to override autotune:
244+
```c
245+
nvs_config_set_u16(NVS_CONFIG_ASIC_VOLTAGE, 1200); // Set voltage
246+
nvs_config_set_u16(NVS_CONFIG_ASIC_FREQ, 600); // Set frequency
247+
nvs_config_set_u16(NVS_CONFIG_AUTO_FAN_SPEED, 0); // Disable auto fan
248+
```
249+
250+
## Best Practices
251+
252+
### Recommended Usage
253+
1. **Initial Setup**: Start with "balanced" preset for your device model
254+
2. **Break-in Period**: Allow 24-48 hours for thermal stabilization
255+
3. **Environment Consideration**: Adjust for ambient temperature and ventilation
256+
4. **Monitoring**: Watch logs for adjustment patterns and stability
257+
258+
### Troubleshooting
259+
- **Frequent Adjustments**: Check ambient temperature and cooling
260+
- **Poor Hashrate**: Verify power supply capacity and connections
261+
- **Overheating**: Improve ventilation or reduce ambient temperature
262+
- **Instability**: Consider using "quiet" preset for more conservative operation
263+
264+
### Safety Considerations
265+
- Never disable overheat protection
266+
- Ensure adequate power supply capacity
267+
- Monitor system logs regularly
268+
- Maintain proper ventilation and cooling

components/.DS_Store

6 KB
Binary file not shown.

components/asic/include/serial.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ esp_err_t SERIAL_set_baud(int baud);
1313

1414
esp_err_t SERIAL_init_BAP(void);
1515
int SERIAL_send_BAP(uint8_t *, int, bool);
16-
int16_t SERIAL_rx_BAP(uint8_t *, uint16_t, uint16_t);
16+
//int16_t SERIAL_rx_BAP(uint8_t *, uint16_t, uint16_t);
1717
void SERIAL_clear_buffer_BAP(void);
1818
void SERIAL_set_baud_BAP(int baud);
1919

components/connect/connect.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#include "esp_event.h"
32
#include "esp_log.h"
43
#include "esp_system.h"

config-403.cvs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
key,type,encoding,value
22
main,namespace,,
3-
hostname,data,string,bitaxe
4-
wifissid,data,string,myssid
5-
wifipass,data,string,password
3+
hostname,data,string,acsbitaxe
4+
wifissid,data,string,Bitaxe
5+
wifipass,data,string,satoshi256
66
stratumurl,data,string,public-pool.io
77
stratumport,data,u16,21496
8-
stratumuser,data,string,bc1qnp980s5fpp8l94p5cvttmtdqy8rvrq74qly2yrfmzkdsntqzlc5qkc4rkq.bitaxe
8+
stratumuser,data,string,bc1qa2500jc3cwjnklv4tdme4e6ascvvl5w8jezxlh.bitaxe
99
stratumpass,data,string,x
1010
fbstratumurl,data,string,solo.ckpool.org
1111
fbstratumport,data,u16,3333
12-
fbstratumuser,data,string,bc1qnp980s5fpp8l94p5cvttmtdqy8rvrq74qly2yrfmzkdsntqzlc5qkc4rkq.bitaxe
12+
fbstratumuser,data,string,bc1qa2500jc3cwjnklv4tdme4e6ascvvl5w8jezxlh.bitaxe
1313
fbstratumpass,data,string,x
14-
asicfrequency,data,u16,490
15-
asicvoltage,data,u16,1166
14+
asicfrequency,data,u16,575
15+
asicvoltage,data,u16,1200
1616
asicmodel,data,string,BM1368
1717
devicemodel,data,string,supra
1818
boardversion,data,string,403
1919
flipscreen,data,u16,1
2020
invertfanpol,data,u16,1
21-
autofanspeed,data,u16,1
22-
fanspeed,data,u16,100
21+
autofanspeed,data,u16,0
22+
fanspeed,data,u16,30
2323
selftest,data,u16,1
24-
overheat_mode,data,u16,0
24+
overheat_mode,data,u16,0
25+
serialnumber,data,string,MAC123451370
26+
builddate,data,string,06052025
27+
autotune,data,u16,1
28+
preset,data,string,balanced

config-601.cvs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
key,type,encoding,value
22
main,namespace,,
3-
hostname,data,string,bitaxe
4-
wifissid,data,string,myssid
5-
wifipass,data,string,password
3+
hostname,data,string,acsbitaxe
4+
wifissid,data,string,Bitaxe
5+
wifipass,data,string,satoshi256
66
stratumurl,data,string,public-pool.io
77
stratumport,data,u16,21496
8-
stratumuser,data,string,bc1qnp980s5fpp8l94p5cvttmtdqy8rvrq74qly2yrfmzkdsntqzlc5qkc4rkq.bitaxe
8+
stratumuser,data,string,bc1qa2500jc3cwjnklv4tdme4e6ascvvl5w8jezxlh.bitaxe
99
stratumpass,data,string,x
1010
fbstratumurl,data,string,solo.ckpool.org
1111
fbstratumport,data,u16,3333
12-
fbstratumuser,data,string,bc1qnp980s5fpp8l94p5cvttmtdqy8rvrq74qly2yrfmzkdsntqzlc5qkc4rkq.bitaxe
12+
fbstratumuser,data,string,bc1qa2500jc3cwjnklv4tdme4e6ascvvl5w8jezxlh.bitaxe
1313
fbstratumpass,data,string,x
14-
asicfrequency,data,u16,525
15-
asicvoltage,data,u16,1150
14+
asicfrequency,data,u16,490
15+
asicvoltage,data,u16,1090
1616
asicmodel,data,string,BM1370
1717
devicemodel,data,string,gamma
1818
boardversion,data,string,601
1919
flipscreen,data,u16,1
2020
invertfanpol,data,u16,1
21-
autofanspeed,data,u16,1
22-
fanspeed,data,u16,100
21+
autofanspeed,data,u16,0
22+
fanspeed,data,u16,35
2323
selftest,data,u16,1
24-
overheat_mode,data,u16,0
24+
overheat_mode,data,u16,0
25+
serialnumber,data,string,MAC123451370
26+
builddate,data,string,06052025
27+
autotune,data,u16,1
28+
preset,data,string,balanced

config.cvs.example

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,8 @@ invertfanpol,data,u16,1
1717
autofanspeed,data,u16,1
1818
fanspeed,data,u16,100
1919
selftest,data,u16,1
20-
overheat_mode,data,u16,0
20+
overheat_mode,data,u16,0
21+
serialnumber,data,string,ACSBAT_BM1368_11232
22+
builddate,data,string,05262025
23+
autotune,data,u16,1
24+
preset,data,string,balanced

0 commit comments

Comments
 (0)