Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -583,9 +583,11 @@ <h4 class="white-space-nowrap overflow-hidden text-overflow-ellipsis">Hashrate R
<td *ngIf="asicAmount > 1" class="text-500 text-left">
{{ i + 1 }}
</td>
<td *ngFor="let domain of asic?.domains; trackBy: trackByIndex"
[style.backgroundColor]="getHeatmapColor(info, domain)"
<td *ngFor="let domain of asic?.domains; let domainIndex = index; trackBy: trackByIndex"
[style.backgroundColor]="isHashDomainStalled(asic, domainIndex) ? 'var(--red-700)' : getHeatmapColor(info, domain)"
[style.height]="(asicAmount <= 2 ? '2rem' : null)"
[pTooltip]="isHashDomainStalled(asic, domainIndex) ? 'Hash domain counter stopped incrementing' : undefined"
tooltipPosition="bottom"
class="text-center">
<span class="text-xs">{{ domain | hashSuffix }}</span>
</td>
Expand Down
10 changes: 10 additions & 0 deletions main/http_server/axe-os/src/app/components/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type MessageType =
| 'VERSION_MISMATCH'
| 'NOT_SOLO_MINING'
| 'NO_MINING_REWARD'
| 'HASH_DOMAIN_STALLED'
| 'HARDWARE_FAULT';

interface ISystemMessage {
Expand Down Expand Up @@ -1005,6 +1006,7 @@ export class HomeComponent implements OnInit, OnDestroy {
updateMessage(!!info.overheat_mode, 'DEVICE_OVERHEAT', 'error', 'Device has overheated - See settings');
updateMessage(!!info.power_fault, 'POWER_FAULT', 'error', `${info.power_fault} Check your Power Supply.`);
updateMessage(!!info.hardware_fault, 'HARDWARE_FAULT', 'error', `${info.hardware_fault}`);
updateMessage(this.hasStalledHashDomains(info), 'HASH_DOMAIN_STALLED', 'warn', 'One or more ASIC hash domains stopped incrementing. Check power supply, voltage and frequency settings.');
updateMessage(!info.frequency || info.frequency < 400, 'FREQUENCY_LOW', 'warn', 'Device frequency is set low - See settings');
updateMessage(!!info.isUsingFallbackStratum, 'FALLBACK_STRATUM', 'warn', 'Using fallback pool - Share stats reset. Check Pool Settings and / or reboot Device.');
updateMessage(info.version !== info.axeOSVersion, 'VERSION_MISMATCH', 'warn', `Firmware (${info.version}) and AxeOS (${info.axeOSVersion}) versions do not match. Please make sure to update both www.bin and esp-miner.bin.`);
Expand Down Expand Up @@ -1072,6 +1074,14 @@ export class HomeComponent implements OnInit, OnDestroy {
return info.hashrateMonitor?.asics?.[0]?.domains?.length ?? 0;
}

public hasStalledHashDomains(info: ISystemInfo): boolean {
return info.hashrateMonitor?.asics?.some(asic => asic.stalledDomains?.some(Boolean)) ?? false;
}

public isHashDomainStalled(asic: { stalledDomains?: boolean[] }, domainIndex: number): boolean {
return asic.stalledDomains?.[domainIndex] ?? false;
}

public getHeatmapColor(info: ISystemInfo, domainHashrate: number): string {
const expectedHashrate = info.expectedHashrate || 1;
const ratio = Math.max(0, Math.min(2, (domainHashrate / expectedHashrate) * this.getAsicsAmount(info)) * this.getAsicDomainsAmount(info));
Expand Down
1 change: 1 addition & 0 deletions main/http_server/axe-os/src/app/services/system.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ export class SystemApiService {
asics: [{
total: 441.2579,
domains: [114.9901, 98.6658, 103.8136, 122.7133],
stalledDomains: [false, false, false, false],
errorCount: 4,
}],
hashrate: 441.2579,
Expand Down
6 changes: 6 additions & 0 deletions main/http_server/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ components:
required:
- total
- domains
- stalledDomains
- errorCount
properties:
total:
Expand All @@ -105,6 +106,11 @@ components:
description: Hashrate per domain
items:
type: number
stalledDomains:
type: array
description: Whether each hash domain counter has stopped changing
items:
type: boolean
errorCount:
description: Number of errors
type: number
Expand Down
3 changes: 3 additions & 0 deletions main/http_server/system_api_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,11 @@ static void system_api_add_hashrate_monitor(cJSON *root, GlobalState *g) {

cJSON *domains = cJSON_CreateArray();
cJSON_AddItemToObject(asic, "domains", domains);
cJSON *stalled_domains = cJSON_CreateArray();
cJSON_AddItemToObject(asic, "stalledDomains", stalled_domains);
for (int j = 0; j < hash_domains; j++) {
cJSON_AddItemToArray(domains, cJSON_CreateNumber(g->HASHRATE_MONITOR_MODULE.domain_measurements[i][j].hashrate));
cJSON_AddItemToArray(stalled_domains, cJSON_CreateBool(g->HASHRATE_MONITOR_MODULE.domain_stalled[i][j]));
}
}
}
Expand Down
44 changes: 40 additions & 4 deletions main/tasks/hashrate_monitor_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#define HASHRATE_1H_SIZE 6
#define DIV_10M (HASHRATE_1M_SIZE)
#define DIV_1H (HASHRATE_10M_SIZE * DIV_10M)
#define DOMAIN_STALL_POLLS 30

static unsigned long poll_count = 0;
static float hashrate_1m[HASHRATE_1M_SIZE];
Expand Down Expand Up @@ -55,6 +56,8 @@ void hashrate_monitor_reset_measurements(void *pvParameters)
pthread_mutex_lock(&HASHRATE_MONITOR_MODULE->lock);
memset(HASHRATE_MONITOR_MODULE->total_measurement, 0, asic_count * sizeof(measurement_t));
memset(HASHRATE_MONITOR_MODULE->domain_measurements[0], 0, asic_count * hash_domains * sizeof(measurement_t));
memset(HASHRATE_MONITOR_MODULE->domain_stall_counts[0], 0, asic_count * hash_domains * sizeof(uint8_t));
memset(HASHRATE_MONITOR_MODULE->domain_stalled[0], 0, asic_count * hash_domains * sizeof(bool));
memset(HASHRATE_MONITOR_MODULE->error_measurement, 0, asic_count * sizeof(measurement_t));
pthread_mutex_unlock(&HASHRATE_MONITOR_MODULE->lock);
}
Expand Down Expand Up @@ -87,6 +90,33 @@ void update_hash_counter(measurement_t * measurement, uint32_t value, uint64_t t
measurement->time_us = time_us;
}

static void update_domain_hash_counter(HashrateMonitorModule *module, uint8_t asic_nr, uint8_t domain_nr, uint32_t value, uint64_t time_us)
{
measurement_t *measurement = &module->domain_measurements[asic_nr][domain_nr];
uint32_t previous_value = measurement->value;
uint64_t previous_time_us = measurement->time_us;

update_hash_counter(measurement, value, time_us);

if (previous_time_us == 0 || measurement->time_us == previous_time_us) {
return;
}

if (value == previous_value) {
if (module->domain_stall_counts[asic_nr][domain_nr] < DOMAIN_STALL_POLLS) {
module->domain_stall_counts[asic_nr][domain_nr]++;
}
} else {
module->domain_stall_counts[asic_nr][domain_nr] = 0;
module->domain_stalled[asic_nr][domain_nr] = false;
}

if (module->domain_stall_counts[asic_nr][domain_nr] >= DOMAIN_STALL_POLLS && !module->domain_stalled[asic_nr][domain_nr]) {
ESP_LOGW(TAG, "ASIC %d domain %d hash counter stalled", asic_nr, domain_nr);
module->domain_stalled[asic_nr][domain_nr] = true;
}
}

static void init_averages()
{
float nan_val = nanf("");
Expand Down Expand Up @@ -153,8 +183,14 @@ void hashrate_monitor_task(void *pvParameters)
HASHRATE_MONITOR_MODULE->total_measurement = heap_caps_malloc(asic_count * sizeof(measurement_t), MALLOC_CAP_SPIRAM);
measurement_t* data = heap_caps_malloc(asic_count * hash_domains * sizeof(measurement_t), MALLOC_CAP_SPIRAM);
HASHRATE_MONITOR_MODULE->domain_measurements = heap_caps_malloc(asic_count * sizeof(measurement_t*), MALLOC_CAP_SPIRAM);
uint8_t* stall_count_data = heap_caps_malloc(asic_count * hash_domains * sizeof(uint8_t), MALLOC_CAP_SPIRAM);
HASHRATE_MONITOR_MODULE->domain_stall_counts = heap_caps_malloc(asic_count * sizeof(uint8_t*), MALLOC_CAP_SPIRAM);
bool* stalled_data = heap_caps_malloc(asic_count * hash_domains * sizeof(bool), MALLOC_CAP_SPIRAM);
HASHRATE_MONITOR_MODULE->domain_stalled = heap_caps_malloc(asic_count * sizeof(bool*), MALLOC_CAP_SPIRAM);
for (size_t asic_nr = 0; asic_nr < asic_count; asic_nr++) {
HASHRATE_MONITOR_MODULE->domain_measurements[asic_nr] = data + (asic_nr * hash_domains);
HASHRATE_MONITOR_MODULE->domain_stall_counts[asic_nr] = stall_count_data + (asic_nr * hash_domains);
HASHRATE_MONITOR_MODULE->domain_stalled[asic_nr] = stalled_data + (asic_nr * hash_domains);
}
HASHRATE_MONITOR_MODULE->error_measurement = heap_caps_malloc(asic_count * sizeof(measurement_t), MALLOC_CAP_SPIRAM);

Expand Down Expand Up @@ -223,16 +259,16 @@ void hashrate_monitor_register_read(void *pvParameters, register_type_t register
update_hash_counter(&HASHRATE_MONITOR_MODULE->total_measurement[asic_nr], value, timestamp_us);
break;
case REGISTER_DOMAIN_0_COUNT:
update_hash_counter(&HASHRATE_MONITOR_MODULE->domain_measurements[asic_nr][0], value, timestamp_us);
update_domain_hash_counter(HASHRATE_MONITOR_MODULE, asic_nr, 0, value, timestamp_us);
break;
case REGISTER_DOMAIN_1_COUNT:
update_hash_counter(&HASHRATE_MONITOR_MODULE->domain_measurements[asic_nr][1], value, timestamp_us);
update_domain_hash_counter(HASHRATE_MONITOR_MODULE, asic_nr, 1, value, timestamp_us);
break;
case REGISTER_DOMAIN_2_COUNT:
update_hash_counter(&HASHRATE_MONITOR_MODULE->domain_measurements[asic_nr][2], value, timestamp_us);
update_domain_hash_counter(HASHRATE_MONITOR_MODULE, asic_nr, 2, value, timestamp_us);
break;
case REGISTER_DOMAIN_3_COUNT:
update_hash_counter(&HASHRATE_MONITOR_MODULE->domain_measurements[asic_nr][3], value, timestamp_us);
update_domain_hash_counter(HASHRATE_MONITOR_MODULE, asic_nr, 3, value, timestamp_us);
break;
case REGISTER_ERROR_COUNT:
update_hash_counter(&HASHRATE_MONITOR_MODULE->error_measurement[asic_nr], value, timestamp_us);
Expand Down
3 changes: 3 additions & 0 deletions main/tasks/hashrate_monitor_task.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "asic_common.h"
#include <pthread.h>
#include <stdbool.h>

typedef struct {
uint32_t value;
Expand All @@ -13,6 +14,8 @@ typedef struct {
typedef struct {
measurement_t* total_measurement;
measurement_t** domain_measurements;
uint8_t** domain_stall_counts;
bool** domain_stalled;
measurement_t* error_measurement;

pthread_mutex_t lock;
Expand Down