Merge branch 'master' into simplify_i2c_screen

This commit is contained in:
WantClue 2024-10-09 19:32:32 +02:00 committed by GitHub
commit d729a3a209
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
37 changed files with 541 additions and 214 deletions

View File

@ -456,7 +456,7 @@ static uint8_t _send_init(uint64_t frequency, uint16_t asic_count)
// unsigned char init137[11] = {0x55, 0xAA, 0x51, 0x09, 0x00, 0x14, 0x00, 0x00, 0x00, 0xFF, 0x08};
// _send_simple(init137, 11);
BM1366_set_job_difficulty_mask(BM1366_INITIAL_DIFFICULTY);
BM1366_set_job_difficulty_mask(BM1366_ASIC_DIFFICULTY);
unsigned char init138[11] = {0x55, 0xAA, 0x51, 0x09, 0x00, 0x54, 0x00, 0x00, 0x00, 0x03, 0x1D};
_send_simple(init138, 11);

View File

@ -291,7 +291,7 @@ uint8_t BM1368_init(uint64_t frequency, uint16_t asic_count)
vTaskDelay(pdMS_TO_TICKS(500));
}
BM1368_set_job_difficulty_mask(BM1368_INITIAL_DIFFICULTY);
BM1368_set_job_difficulty_mask(BM1368_ASIC_DIFFICULTY);
do_frequency_ramp_up((float)frequency);

View File

@ -264,7 +264,7 @@ static uint8_t _send_init(uint64_t frequency, uint16_t asic_count)
//set ticket mask
// unsigned char init11[11] = {0x55, 0xAA, 0x51, 0x09, 0x00, 0x14, 0x00, 0x00, 0x00, 0xFF, 0x08};
// _send_simple(init11, 11);
BM1370_set_job_difficulty_mask(BM1370_INITIAL_DIFFICULTY);
BM1370_set_job_difficulty_mask(BM1370_ASIC_DIFFICULTY);
//Analog Mux Control
unsigned char init12[11] = {0x55, 0xAA, 0x51, 0x09, 0x00, 0x54, 0x00, 0x00, 0x00, 0x03, 0x1D};

View File

@ -257,7 +257,7 @@ static uint8_t _send_init(uint64_t frequency, uint16_t asic_count)
unsigned char init4[9] = {0x00, CORE_REGISTER_CONTROL, 0x80, 0x00, 0x80, 0x74}; // init4 - init_4_?
_send_BM1397((TYPE_CMD | GROUP_ALL | CMD_WRITE), init4, 6, BM1937_SERIALTX_DEBUG);
BM1397_set_job_difficulty_mask(256);
BM1397_set_job_difficulty_mask(BM1397_ASIC_DIFFICULTY);
unsigned char init5[9] = {0x00, PLL3_PARAMETER, 0xC0, 0x70, 0x01, 0x11}; // init5 - pll3_parameter
_send_BM1397((TYPE_CMD | GROUP_ALL | CMD_WRITE), init5, 6, BM1937_SERIALTX_DEBUG);

View File

@ -8,7 +8,7 @@
#define ASIC_BM1366_JOB_FREQUENCY_MS 2000
#define CRC5_MASK 0x1F
#define BM1366_INITIAL_DIFFICULTY 256
#define BM1366_ASIC_DIFFICULTY 256
#define BM1366_SERIALTX_DEBUG false
#define BM1366_SERIALRX_DEBUG false

View File

@ -8,7 +8,7 @@
#define ASIC_BM1368_JOB_FREQUENCY_MS 500
#define CRC5_MASK 0x1F
#define BM1368_INITIAL_DIFFICULTY 256
#define BM1368_ASIC_DIFFICULTY 256
#define BM1368_SERIALTX_DEBUG false
#define BM1368_SERIALRX_DEBUG false

View File

@ -8,8 +8,7 @@
#define ASIC_BM1370_JOB_FREQUENCY_MS 500
#define CRC5_MASK 0x1F
#define BM1370_INITIAL_DIFFICULTY 256
#define BM1370_ASIC_DIFFICULTY 256
#define BM1370_SERIALTX_DEBUG true
#define BM1370_SERIALRX_DEBUG false

View File

@ -8,7 +8,7 @@
#define ASIC_BM1397_JOB_FREQUENCY_MS 20 //not currently used
#define CRC5_MASK 0x1F
#define BM1397_INITIAL_DIFFICULTY 256
#define BM1397_ASIC_DIFFICULTY 256
#define BM1937_SERIALTX_DEBUG false
#define BM1937_SERIALRX_DEBUG false

View File

@ -14,6 +14,7 @@ SRCS
"TPS546.c"
"vcore.c"
"work_queue.c"
"nvs_device.c"
"./http_server/http_server.c"
"./self_test/self_test.c"
"./tasks/stratum_task.c"
@ -27,6 +28,7 @@ INCLUDE_DIRS
"."
"tasks"
"http_server"
"self_test"
"../components/asic/include"
"../components/connect/include"
"../components/dns_server/include"

View File

@ -89,7 +89,7 @@ typedef struct
uint16_t voltage_domain;
AsicFunctions ASIC_functions;
double asic_job_frequency_ms;
uint32_t initial_ASIC_difficulty;
uint32_t ASIC_difficulty;
work_queue stratum_queue;
work_queue ASIC_jobs_queue;

View File

@ -4,6 +4,7 @@ import { RouterModule, Routes } from '@angular/router';
import { HomeComponent } from './components/home/home.component';
import { LogsComponent } from './components/logs/logs.component';
import { SettingsComponent } from './components/settings/settings.component';
import { NetworkComponent } from './components/network/network.component';
import { SwarmComponent } from './components/swarm/swarm.component';
import { AppLayoutComponent } from './layout/app.layout.component';
@ -20,6 +21,10 @@ const routes: Routes = [
path: 'logs',
component: LogsComponent
},
{
path: 'network',
component: NetworkComponent
},
{
path: 'settings',
component: SettingsComponent

View File

@ -11,9 +11,11 @@ import { ToastrModule } from 'ngx-toastr';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { EditComponent } from './components/edit/edit.component';
import { NetworkEditComponent } from './components/network-edit/network.edit.component';
import { HomeComponent } from './components/home/home.component';
import { LoadingComponent } from './components/loading/loading.component';
import { LogsComponent } from './components/logs/logs.component';
import { NetworkComponent } from './components/network/network.component';
import { SettingsComponent } from './components/settings/settings.component';
import { SwarmComponent } from './components/swarm/swarm.component';
import { AppLayoutModule } from './layout/app.layout.module';
@ -26,8 +28,10 @@ import { MessageModule } from 'primeng/message';
const components = [
AppComponent,
EditComponent,
NetworkEditComponent,
HomeComponent,
LoadingComponent,
NetworkComponent,
SettingsComponent,
LogsComponent
];

View File

@ -1,29 +1,5 @@
<ng-container *ngIf="form != null">
<form [formGroup]="form">
<div class="field grid p-fluid">
<label htmlFor="hostname" class="col-12 mb-2 md:col-2 md:mb-0">Hostname:</label>
<div class="col-12 md:col-10">
<input pInputText id="hostname" type="text" formControlName="hostname" />
</div>
</div>
<div class="field grid p-fluid">
<label htmlFor="ssid" class="col-12 mb-2 md:col-2 md:mb-0">WiFi SSID:</label>
<div class="col-12 md:col-10">
<input pInputText id="ssid" type="text" formControlName="ssid" />
</div>
</div>
<div class="field grid p-fluid">
<label htmlFor="wifiPass" class="col-12 mb-2 md:col-2 md:mb-0">WiFi Password:</label>
<div class="col-12 md:col-10 p-input-icon-right">
<i *ngIf="form.get('wifiPass')?.dirty" class="pi"
[ngClass]="{'pi-eye': !showWifiPassword, 'pi-eye-slash': showWifiPassword}"
(click)="toggleWifiPasswordVisibility()" style="cursor: pointer;"></i>
<input pInputText id="wifiPass" formControlName="wifiPass"
[type]="showWifiPassword ? 'text' : 'password'"
placeholder="Enter WiFi password" />
</div>
</div>
<div class="field grid p-fluid">
<label htmlFor="stratumURL" class="col-12 mb-2 md:col-2 md:mb-0">Stratum URL:</label>
<div class="col-12 md:col-10">
@ -81,8 +57,13 @@
</div>
<div class="field grid p-fluid">
<label htmlFor="fallbackStratumPassword" class="col-12 mb-2 md:col-2 md:mb-0">Fallback Stratum Password:</label>
<div class="col-12 md:col-10">
<input pInputText id="fallbackStratumPassword" formControlName="fallbackStratumPassword" type="password" />
<div class="col-12 md:col-10 p-input-icon-right">
<i *ngIf="form.get('fallbackStratumPassword')?.dirty" class="pi"
[ngClass]="{'pi-eye': !showFallbackStratumPassword, 'pi-eye-slash': showFallbackStratumPassword}"
(click)="toggleFallbackStratumPasswordVisibility()" style="cursor: pointer;"></i>
<input pInputText id="fallbackStratumPassword" formControlName="fallbackStratumPassword"
[type]="showFallbackStratumPassword ? 'text' : 'password'"
placeholder="Enter fallback stratum password" />
</div>
</div>
@ -172,7 +153,6 @@
</ng-container>
<div class="col-12 md:col-4">
<div class="field-checkbox">
<p-checkbox name="flipscreen" formControlName="flipscreen" inputId="flipscreen"

View File

@ -159,9 +159,6 @@ export class EditComponent implements OnInit {
stratumPassword: ['*****', [Validators.required]],
fallbackStratumUser: [info.fallbackStratumUser, [Validators.required]],
fallbackStratumPassword: ['password', [Validators.required]],
hostname: [info.hostname, [Validators.required]],
ssid: [info.ssid, [Validators.required]],
wifiPass: ['*****'],
coreVoltage: [info.coreVoltage, [Validators.required]],
frequency: [info.frequency, [Validators.required]],
autofanspeed: [info.autofanspeed == 1, [Validators.required]],
@ -198,12 +195,6 @@ export class EditComponent implements OnInit {
const form = this.form.getRawValue();
// Allow an empty wifi password
form.wifiPass = form.wifiPass == null ? '' : form.wifiPass;
if (form.wifiPass === '*****') {
delete form.wifiPass;
}
if (form.stratumPassword === '*****') {
delete form.stratumPassword;
}
@ -232,4 +223,9 @@ export class EditComponent implements OnInit {
this.showWifiPassword = !this.showWifiPassword;
}
showFallbackStratumPassword: boolean = false;
toggleFallbackStratumPasswordVisibility() {
this.showFallbackStratumPassword = !this.showFallbackStratumPassword;
}
}

View File

@ -103,13 +103,13 @@
<div class="card">
<h5>Power</h5>
<div class="grid text-center">
<div class="col-4">
<div class="col-6 sm:col-4">
<p-knob [min]="3" [max]="maxPower" [readonly]="true" [(ngModel)]="info.power"
valueTemplate="{value}W"></p-knob>
Power
</div>
<div class="col-4">
<div class="col-6 sm:col-4">
<p-knob [min]="4.5" [max]="5.5" [readonly]="true" [(ngModel)]="info.voltage"
valueTemplate="{value}V"
[valueColor]="info.voltage < 4.8 ? '#ff0000' : 'var(--primary-color, Black)'"></p-knob>
@ -117,7 +117,7 @@
<span class="danger" *ngIf="info.voltage < 4.8">&nbsp; Danger: Low voltage</span>
</div>
<div class="col-4">
<div class="col-6 sm:col-4">
<p-knob [min]="0.9" [max]="1.8" [readonly]="true" [(ngModel)]="info.coreVoltage"
valueTemplate="{value}V"></p-knob>
ASIC Voltage Requested

View File

@ -0,0 +1,34 @@
<ng-container *ngIf="form != null">
<form [formGroup]="form">
<div class="field grid p-fluid">
<label htmlFor="hostname" class="col-12 mb-2 md:col-2 md:mb-0">Hostname:</label>
<div class="col-12 md:col-10">
<input pInputText id="hostname" type="text" formControlName="hostname" />
</div>
</div>
<div class="field grid p-fluid">
<label htmlFor="ssid" class="col-12 mb-2 md:col-2 md:mb-0">WiFi SSID:</label>
<div class="col-12 md:col-10">
<input pInputText id="ssid" type="text" formControlName="ssid" />
</div>
</div>
<div class="field grid p-fluid">
<label htmlFor="wifiPass" class="col-12 mb-2 md:col-2 md:mb-0">WiFi Password:</label>
<div class="col-12 md:col-10 p-input-icon-right">
<i *ngIf="form.get('wifiPass')?.dirty" class="pi"
[ngClass]="{'pi-eye': !showWifiPassword, 'pi-eye-slash': showWifiPassword}"
(click)="toggleWifiPasswordVisibility()" style="cursor: pointer;"></i>
<input pInputText id="wifiPass" formControlName="wifiPass"
[type]="showWifiPassword ? 'text' : 'password'"
placeholder="Enter WiFi password" />
</div>
</div>
<div class="mt-2">
<button pButton [disabled]="form.invalid" (click)="updateSystem()"
class="btn btn-primary mr-2">Save</button>
<b style="line-height: 34px;">You must restart this device after saving for changes to take effect.</b>
</div>
</form>
</ng-container>

View File

@ -0,0 +1,5 @@
.pi {
right: 1rem;
font-size: 1.5rem;
top: 1rem;
}

View File

@ -0,0 +1,21 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { NetworkEditComponent } from './network.edit.component';
describe('NetworkEditComponent', () => {
let component: NetworkEditComponent;
let fixture: ComponentFixture<NetworkEditComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [NetworkEditComponent]
});
fixture = TestBed.createComponent(NetworkEditComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,70 @@
import { HttpErrorResponse } from '@angular/common/http';
import { Component, Input, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { ToastrService } from 'ngx-toastr';
import { startWith } from 'rxjs';
import { LoadingService } from 'src/app/services/loading.service';
import { SystemService } from 'src/app/services/system.service';
@Component({
selector: 'app-network-edit',
templateUrl: './network.edit.component.html',
styleUrls: ['./network.edit.component.scss']
})
export class NetworkEditComponent implements OnInit {
public form!: FormGroup;
@Input() uri = '';
constructor(
private fb: FormBuilder,
private systemService: SystemService,
private toastr: ToastrService,
private toastrService: ToastrService,
private loadingService: LoadingService
) {
}
ngOnInit(): void {
this.systemService.getInfo(this.uri)
.pipe(this.loadingService.lockUIUntilComplete())
.subscribe(info => {
this.form = this.fb.group({
hostname: [info.hostname, [Validators.required]],
ssid: [info.ssid, [Validators.required]],
wifiPass: ['*****'],
});
});
}
public updateSystem() {
const form = this.form.getRawValue();
// Allow an empty wifi password
form.wifiPass = form.wifiPass == null ? '' : form.wifiPass;
if (form.wifiPass === '*****') {
delete form.wifiPass;
}
this.systemService.updateSystem(this.uri, form)
.pipe(this.loadingService.lockUIUntilComplete())
.subscribe({
next: () => {
this.toastr.success('Success!', 'Saved.');
},
error: (err: HttpErrorResponse) => {
this.toastr.error('Error.', `Could not save. ${err.message}`);
}
});
}
showWifiPassword: boolean = false;
toggleWifiPasswordVisibility() {
this.showWifiPassword = !this.showWifiPassword;
}
}

View File

@ -0,0 +1,5 @@
<div class="card">
<h2>Network Configuration</h2>
<app-network-edit></app-network-edit>
</div>

View File

@ -0,0 +1,35 @@
input[type="text"],
input[type="number"],
input[type="password"],
input[type="range"] {
min-width: 250px;
max-width: 90%;
}
select {
min-width: 268px;
max-width: 90%;
}
.restart {
margin-bottom: 1.5rem;
}
@media only screen and (min-width:900px) {
input[type="text"],
input[type="password"],
input[type="number"],
input[type="range"] {
min-width: 500px
}
select {
min-width: 518px
}
}
a {
color: white;
}

View File

@ -0,0 +1,21 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { NetworkComponent } from './network.component';
describe('NetworkComponent', () => {
let component: NetworkComponent;
let fixture: ComponentFixture<NetworkComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [NetworkComponent]
});
fixture = TestBed.createComponent(NetworkComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,62 @@
import { HttpErrorResponse, HttpEventType } from '@angular/common/http';
import { Component } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { ToastrService } from 'ngx-toastr';
import { map, Observable, shareReplay, startWith } from 'rxjs';
import { LoadingService } from 'src/app/services/loading.service';
import { SystemService } from 'src/app/services/system.service';
@Component({
selector: 'app-network',
templateUrl: './network.component.html',
styleUrls: ['./network.component.scss']
})
export class NetworkComponent {
public form!: FormGroup;
public info$: Observable<any>;
constructor(
private fb: FormBuilder,
private systemService: SystemService,
private toastr: ToastrService,
private toastrService: ToastrService,
private loadingService: LoadingService,
) {
this.info$ = this.systemService.getInfo().pipe(shareReplay({refCount: true, bufferSize: 1}))
this.info$.pipe(this.loadingService.lockUIUntilComplete())
.subscribe(info => {
this.form = this.fb.group({
hostname: [info.hostname, [Validators.required]],
ssid: [info.ssid, [Validators.required]],
wifiPass: ['*****'],
});
});
}
public updateSystem() {
const form = this.form.getRawValue();
// Allow an empty wifi password
form.wifiPass = form.wifiPass == null ? '' : form.wifiPass;
if (form.wifiPass === '*****') {
delete form.wifiPass;
}
this.systemService.updateSystem(undefined, form)
.pipe(this.loadingService.lockUIUntilComplete())
.subscribe({
next: () => {
this.toastr.success('Success!', 'Saved.');
},
error: (err: HttpErrorResponse) => {
this.toastr.error('Error.', `Could not save. ${err.message}`);
}
});
}
}

View File

@ -71,8 +71,6 @@ export class SettingsComponent {
]],
stratumUser: [info.stratumUser, [Validators.required]],
stratumPassword: ['*****', [Validators.required]],
ssid: [info.ssid, [Validators.required]],
wifiPass: ['*****'],
coreVoltage: [info.coreVoltage, [Validators.required]],
frequency: [info.frequency, [Validators.required]],
autofanspeed: [info.autofanspeed == 1, [Validators.required]],
@ -116,12 +114,6 @@ export class SettingsComponent {
form.invertfanpolarity = form.invertfanpolarity == true ? 1 : 0;
form.autofanspeed = form.autofanspeed == true ? 1 : 0;
// Allow an empty wifi password
form.wifiPass = form.wifiPass == null ? '' : form.wifiPass;
if (form.wifiPass === '*****') {
delete form.wifiPass;
}
if (form.stratumPassword === '*****') {
delete form.stratumPassword;
}
@ -211,9 +203,4 @@ export class SettingsComponent {
});
this.toastr.success('Success!', 'Bitaxe restarted');
}
}

View File

@ -5,6 +5,8 @@
</ng-container>
<p-button (click)="restart()" id="restart" label="Restart" severity="danger"></p-button>
<li id="restart-container">
<p-button (click)="restart()" id="restart" label="Restart" severity="danger"></p-button>
</li>
</ul>

View File

@ -24,22 +24,19 @@ export class AppMenuComponent implements OnInit {
items: [
{ label: 'Dashboard', icon: 'pi pi-fw pi-home', routerLink: ['/'] },
{ label: 'Swarm', icon: 'pi pi-fw pi-share-alt', routerLink: ['swarm'] },
{ label: 'Network', icon: 'pi pi-fw pi-wifi', routerLink: ['network'] },
{ label: 'Settings', icon: 'pi pi-fw pi-cog', routerLink: ['settings'] },
{ label: 'Logs', icon: 'pi pi-fw pi-list', routerLink: ['logs'] },
]
}
];
}
public restart() {
this.systemService.restart().subscribe(res => {
});
this.toastr.success('Success!', 'Bitaxe restarted');
}
}

View File

@ -135,6 +135,10 @@
}
#restart {
padding: 2rem 1rem;
display: block;
display: inline-block;
}
#restart-container {
margin: 2rem 1rem;
display: flex;
}

View File

@ -17,6 +17,9 @@
#include "stratum_task.h"
#include "user_input_task.h"
#include "i2c_bitaxe.h"
#include "adc.h"
#include "nvs_device.h"
#include "self_test.h"
static GlobalState GLOBAL_STATE = {
.extranonce_str = NULL,
@ -27,7 +30,6 @@ static GlobalState GLOBAL_STATE = {
};
static const char * TAG = "bitaxe";
static const double NONCE_SPACE = 4294967296.0; // 2^32
void app_main(void)
{
@ -40,132 +42,47 @@ void app_main(void)
//wait for I2C to init
vTaskDelay(100 / portTICK_PERIOD_MS);
ESP_ERROR_CHECK(nvs_flash_init());
//Init ADC
ADC_init();
GLOBAL_STATE.POWER_MANAGEMENT_MODULE.frequency_value = nvs_config_get_u16(NVS_CONFIG_ASIC_FREQ, CONFIG_ASIC_FREQUENCY);
ESP_LOGI(TAG, "NVS_CONFIG_ASIC_FREQ %f", (float)GLOBAL_STATE.POWER_MANAGEMENT_MODULE.frequency_value);
GLOBAL_STATE.device_model_str = nvs_config_get_string(NVS_CONFIG_DEVICE_MODEL, "");
if (strcmp(GLOBAL_STATE.device_model_str, "max") == 0) {
ESP_LOGI(TAG, "DEVICE: Max");
GLOBAL_STATE.device_model = DEVICE_MAX;
GLOBAL_STATE.asic_count = 1;
GLOBAL_STATE.voltage_domain = 1;
} else if (strcmp(GLOBAL_STATE.device_model_str, "ultra") == 0) {
ESP_LOGI(TAG, "DEVICE: Ultra");
GLOBAL_STATE.device_model = DEVICE_ULTRA;
GLOBAL_STATE.asic_count = 1;
GLOBAL_STATE.voltage_domain = 1;
} else if (strcmp(GLOBAL_STATE.device_model_str, "supra") == 0) {
ESP_LOGI(TAG, "DEVICE: Supra");
GLOBAL_STATE.device_model = DEVICE_SUPRA;
GLOBAL_STATE.asic_count = 1;
GLOBAL_STATE.voltage_domain = 1;
} else if (strcmp(GLOBAL_STATE.device_model_str, "gamma") == 0) {
ESP_LOGI(TAG, "DEVICE: Gamma");
GLOBAL_STATE.device_model = DEVICE_GAMMA;
GLOBAL_STATE.asic_count = 1;
GLOBAL_STATE.voltage_domain = 1;
} else {
ESP_LOGE(TAG, "Invalid DEVICE model");
// maybe should return here to now execute anything with a faulty device parameter !
// this stops crashes/reboots and allows dev testing without an asic
GLOBAL_STATE.device_model = DEVICE_UNKNOWN;
GLOBAL_STATE.asic_count = -1;
GLOBAL_STATE.voltage_domain = 1;
}
GLOBAL_STATE.board_version = atoi(nvs_config_get_string(NVS_CONFIG_BOARD_VERSION, "000"));
ESP_LOGI(TAG, "Found Device Model: %s", GLOBAL_STATE.device_model_str);
ESP_LOGI(TAG, "Found Board Version: %d", GLOBAL_STATE.board_version);
GLOBAL_STATE.asic_model_str = nvs_config_get_string(NVS_CONFIG_ASIC_MODEL, "");
if (strcmp(GLOBAL_STATE.asic_model_str, "BM1366") == 0) {
ESP_LOGI(TAG, "ASIC: %dx BM1366 (%" PRIu64 " cores)", GLOBAL_STATE.asic_count, BM1366_CORE_COUNT);
GLOBAL_STATE.asic_model = ASIC_BM1366;
AsicFunctions ASIC_functions = {.init_fn = BM1366_init,
.receive_result_fn = BM1366_proccess_work,
.set_max_baud_fn = BM1366_set_max_baud,
.set_difficulty_mask_fn = BM1366_set_job_difficulty_mask,
.send_work_fn = BM1366_send_work,
.set_version_mask = BM1366_set_version_mask};
//GLOBAL_STATE.asic_job_frequency_ms = (NONCE_SPACE / (double) (GLOBAL_STATE.POWER_MANAGEMENT_MODULE.frequency_value * BM1366_CORE_COUNT * 1000)) / (double) GLOBAL_STATE.asic_count; // version-rolling so Small Cores have different Nonce Space
GLOBAL_STATE.asic_job_frequency_ms = ASIC_BM1366_JOB_FREQUENCY_MS; //2000ms
GLOBAL_STATE.initial_ASIC_difficulty = BM1366_INITIAL_DIFFICULTY;
GLOBAL_STATE.ASIC_functions = ASIC_functions;
} else if (strcmp(GLOBAL_STATE.asic_model_str, "BM1370") == 0) {
ESP_LOGI(TAG, "ASIC: %dx BM1370 (%" PRIu64 " cores)", GLOBAL_STATE.asic_count, BM1370_CORE_COUNT);
GLOBAL_STATE.asic_model = ASIC_BM1370;
AsicFunctions ASIC_functions = {.init_fn = BM1370_init,
.receive_result_fn = BM1370_proccess_work,
.set_max_baud_fn = BM1370_set_max_baud,
.set_difficulty_mask_fn = BM1370_set_job_difficulty_mask,
.send_work_fn = BM1370_send_work,
.set_version_mask = BM1370_set_version_mask};
//GLOBAL_STATE.asic_job_frequency_ms = (NONCE_SPACE / (double) (GLOBAL_STATE.POWER_MANAGEMENT_MODULE.frequency_value * BM1370_CORE_COUNT * 1000)) / (double) GLOBAL_STATE.asic_count; // version-rolling so Small Cores have different Nonce Space
GLOBAL_STATE.asic_job_frequency_ms = ASIC_BM1370_JOB_FREQUENCY_MS; //500ms
GLOBAL_STATE.initial_ASIC_difficulty = BM1370_INITIAL_DIFFICULTY;
GLOBAL_STATE.ASIC_functions = ASIC_functions;
} else if (strcmp(GLOBAL_STATE.asic_model_str, "BM1368") == 0) {
ESP_LOGI(TAG, "ASIC: %dx BM1368 (%" PRIu64 " cores)", GLOBAL_STATE.asic_count, BM1368_CORE_COUNT);
GLOBAL_STATE.asic_model = ASIC_BM1368;
AsicFunctions ASIC_functions = {.init_fn = BM1368_init,
.receive_result_fn = BM1368_proccess_work,
.set_max_baud_fn = BM1368_set_max_baud,
.set_difficulty_mask_fn = BM1368_set_job_difficulty_mask,
.send_work_fn = BM1368_send_work,
.set_version_mask = BM1368_set_version_mask};
//GLOBAL_STATE.asic_job_frequency_ms = (NONCE_SPACE / (double) (GLOBAL_STATE.POWER_MANAGEMENT_MODULE.frequency_value * BM1368_CORE_COUNT * 1000)) / (double) GLOBAL_STATE.asic_count; // version-rolling so Small Cores have different Nonce Space
GLOBAL_STATE.asic_job_frequency_ms = ASIC_BM1368_JOB_FREQUENCY_MS; //500ms
GLOBAL_STATE.initial_ASIC_difficulty = BM1368_INITIAL_DIFFICULTY;
GLOBAL_STATE.ASIC_functions = ASIC_functions;
} else if (strcmp(GLOBAL_STATE.asic_model_str, "BM1397") == 0) {
ESP_LOGI(TAG, "ASIC: %dx BM1397 (%" PRIu64 " cores)", GLOBAL_STATE.asic_count, BM1397_SMALL_CORE_COUNT);
GLOBAL_STATE.asic_model = ASIC_BM1397;
AsicFunctions ASIC_functions = {.init_fn = BM1397_init,
.receive_result_fn = BM1397_proccess_work,
.set_max_baud_fn = BM1397_set_max_baud,
.set_difficulty_mask_fn = BM1397_set_job_difficulty_mask,
.send_work_fn = BM1397_send_work,
.set_version_mask = BM1397_set_version_mask};
GLOBAL_STATE.asic_job_frequency_ms = (NONCE_SPACE / (double) (GLOBAL_STATE.POWER_MANAGEMENT_MODULE.frequency_value * BM1397_SMALL_CORE_COUNT * 1000)) / (double) GLOBAL_STATE.asic_count; // no version-rolling so same Nonce Space is splitted between Small Cores
GLOBAL_STATE.initial_ASIC_difficulty = BM1397_INITIAL_DIFFICULTY;
GLOBAL_STATE.ASIC_functions = ASIC_functions;
} else {
ESP_LOGE(TAG, "Invalid ASIC model");
AsicFunctions ASIC_functions = {.init_fn = NULL,
.receive_result_fn = NULL,
.set_max_baud_fn = NULL,
.set_difficulty_mask_fn = NULL,
.send_work_fn = NULL};
GLOBAL_STATE.ASIC_functions = ASIC_functions;
// maybe should return here to now execute anything with a faulty device parameter !
//initialize the ESP32 NVS
if (NVSDevice_init() != ESP_OK){
ESP_LOGE(TAG, "Failed to init NVS");
return;
}
bool is_max = GLOBAL_STATE.asic_model == ASIC_BM1397;
uint64_t best_diff = nvs_config_get_u64(NVS_CONFIG_BEST_DIFF, 0);
uint16_t should_self_test = nvs_config_get_u16(NVS_CONFIG_SELF_TEST, 0);
if (should_self_test == 1 && !is_max && best_diff < 1) {
//parse the NVS config into GLOBAL_STATE
if (NVSDevice_parse_config(&GLOBAL_STATE) != ESP_OK) {
ESP_LOGE(TAG, "Failed to parse NVS config");
return;
}
//should we run the self test?
if (should_test(&GLOBAL_STATE)) {
self_test((void *) &GLOBAL_STATE);
vTaskDelay(60 * 60 * 1000 / portTICK_PERIOD_MS);
}
SYSTEM_init_system(&GLOBAL_STATE);
// pull the wifi credentials and hostname out of NVS
char * wifi_ssid = nvs_config_get_string(NVS_CONFIG_WIFI_SSID, WIFI_SSID);
char * wifi_pass = nvs_config_get_string(NVS_CONFIG_WIFI_PASS, WIFI_PASS);
char * hostname = nvs_config_get_string(NVS_CONFIG_HOSTNAME, HOSTNAME);
// copy the wifi ssid to the global state
strncpy(GLOBAL_STATE.SYSTEM_MODULE.ssid,
wifi_ssid,
sizeof(GLOBAL_STATE.SYSTEM_MODULE.ssid));
strncpy(GLOBAL_STATE.SYSTEM_MODULE.ssid, wifi_ssid, sizeof(GLOBAL_STATE.SYSTEM_MODULE.ssid));
GLOBAL_STATE.SYSTEM_MODULE.ssid[sizeof(GLOBAL_STATE.SYSTEM_MODULE.ssid)-1] = 0;
// init and connect to wifi
wifi_init(wifi_ssid, wifi_pass, hostname);
SYSTEM_init_peripherals(&GLOBAL_STATE);
xTaskCreate(SYSTEM_task, "SYSTEM_task", 4096, (void *) &GLOBAL_STATE, 3, NULL);
xTaskCreate(POWER_MANAGEMENT_task, "power mangement", 8192, (void *) &GLOBAL_STATE, 10, NULL);
//start the API for AxeOS
start_rest_server((void *) &GLOBAL_STATE);
EventBits_t result_bits = wifi_connect();
@ -195,11 +112,6 @@ void app_main(void)
free(wifi_pass);
free(hostname);
SYSTEM_init_system(&GLOBAL_STATE);
xTaskCreate(SYSTEM_task, "SYSTEM_task", 4096, (void *) &GLOBAL_STATE, 3, NULL);
xTaskCreate(POWER_MANAGEMENT_task, "power mangement", 8192, (void *) &GLOBAL_STATE, 10, NULL);
// set the startup_done flag
GLOBAL_STATE.SYSTEM_MODULE.startup_done = true;
GLOBAL_STATE.new_stratum_version_rolling_msg = false;

147
main/nvs_device.c Normal file
View File

@ -0,0 +1,147 @@
#include <string.h>
#include "esp_event.h"
#include "esp_log.h"
#include "nvs_flash.h"
#include "nvs_config.h"
#include "nvs_device.h"
#include "connect.h"
#include "global_state.h"
static const char * TAG = "nvs_device";
static const double NONCE_SPACE = 4294967296.0; // 2^32
esp_err_t NVSDevice_init(void) {
esp_err_t err = nvs_flash_init();
if (err == ESP_ERR_NVS_NO_FREE_PAGES) {
ESP_ERROR_CHECK(nvs_flash_erase());
err = nvs_flash_init();
}
return err;
}
esp_err_t NVSDevice_get_wifi_creds(GlobalState * GLOBAL_STATE, char ** wifi_ssid, char ** wifi_pass, char ** hostname) {
// pull the wifi credentials and hostname out of NVS
*wifi_ssid = nvs_config_get_string(NVS_CONFIG_WIFI_SSID, WIFI_SSID);
*wifi_pass = nvs_config_get_string(NVS_CONFIG_WIFI_PASS, WIFI_PASS);
*hostname = nvs_config_get_string(NVS_CONFIG_HOSTNAME, HOSTNAME);
// copy the wifi ssid to the global state
strncpy(GLOBAL_STATE->SYSTEM_MODULE.ssid, *wifi_ssid, sizeof(GLOBAL_STATE->SYSTEM_MODULE.ssid));
GLOBAL_STATE->SYSTEM_MODULE.ssid[sizeof(GLOBAL_STATE->SYSTEM_MODULE.ssid)-1] = 0;
return ESP_OK;
}
esp_err_t NVSDevice_parse_config(GlobalState * GLOBAL_STATE) {
GLOBAL_STATE->POWER_MANAGEMENT_MODULE.frequency_value = nvs_config_get_u16(NVS_CONFIG_ASIC_FREQ, CONFIG_ASIC_FREQUENCY);
ESP_LOGI(TAG, "NVS_CONFIG_ASIC_FREQ %f", (float)GLOBAL_STATE->POWER_MANAGEMENT_MODULE.frequency_value);
GLOBAL_STATE->device_model_str = nvs_config_get_string(NVS_CONFIG_DEVICE_MODEL, "");
if (strcmp(GLOBAL_STATE->device_model_str, "max") == 0) {
ESP_LOGI(TAG, "DEVICE: Max");
GLOBAL_STATE->device_model = DEVICE_MAX;
GLOBAL_STATE->asic_count = 1;
GLOBAL_STATE->voltage_domain = 1;
} else if (strcmp(GLOBAL_STATE->device_model_str, "ultra") == 0) {
ESP_LOGI(TAG, "DEVICE: Ultra");
GLOBAL_STATE->device_model = DEVICE_ULTRA;
GLOBAL_STATE->asic_count = 1;
GLOBAL_STATE->voltage_domain = 1;
} else if (strcmp(GLOBAL_STATE->device_model_str, "supra") == 0) {
ESP_LOGI(TAG, "DEVICE: Supra");
GLOBAL_STATE->device_model = DEVICE_SUPRA;
GLOBAL_STATE->asic_count = 1;
GLOBAL_STATE->voltage_domain = 1;
} else if (strcmp(GLOBAL_STATE->device_model_str, "gamma") == 0) {
ESP_LOGI(TAG, "DEVICE: Gamma");
GLOBAL_STATE->device_model = DEVICE_GAMMA;
GLOBAL_STATE->asic_count = 1;
GLOBAL_STATE->voltage_domain = 1;
} else {
ESP_LOGE(TAG, "Invalid DEVICE model");
// maybe should return here to now execute anything with a faulty device parameter !
// this stops crashes/reboots and allows dev testing without an asic
GLOBAL_STATE->device_model = DEVICE_UNKNOWN;
GLOBAL_STATE->asic_count = -1;
GLOBAL_STATE->voltage_domain = 1;
return ESP_FAIL;
}
GLOBAL_STATE->board_version = atoi(nvs_config_get_string(NVS_CONFIG_BOARD_VERSION, "000"));
ESP_LOGI(TAG, "Found Device Model: %s", GLOBAL_STATE->device_model_str);
ESP_LOGI(TAG, "Found Board Version: %d", GLOBAL_STATE->board_version);
GLOBAL_STATE->asic_model_str = nvs_config_get_string(NVS_CONFIG_ASIC_MODEL, "");
if (strcmp(GLOBAL_STATE->asic_model_str, "BM1366") == 0) {
ESP_LOGI(TAG, "ASIC: %dx BM1366 (%" PRIu64 " cores)", GLOBAL_STATE->asic_count, BM1366_CORE_COUNT);
GLOBAL_STATE->asic_model = ASIC_BM1366;
AsicFunctions ASIC_functions = {.init_fn = BM1366_init,
.receive_result_fn = BM1366_proccess_work,
.set_max_baud_fn = BM1366_set_max_baud,
.set_difficulty_mask_fn = BM1366_set_job_difficulty_mask,
.send_work_fn = BM1366_send_work,
.set_version_mask = BM1366_set_version_mask};
//GLOBAL_STATE.asic_job_frequency_ms = (NONCE_SPACE / (double) (GLOBAL_STATE.POWER_MANAGEMENT_MODULE.frequency_value * BM1366_CORE_COUNT * 1000)) / (double) GLOBAL_STATE.asic_count; // version-rolling so Small Cores have different Nonce Space
GLOBAL_STATE->asic_job_frequency_ms = 2000; //ms
GLOBAL_STATE->ASIC_difficulty = BM1366_ASIC_DIFFICULTY;
GLOBAL_STATE->ASIC_functions = ASIC_functions;
} else if (strcmp(GLOBAL_STATE->asic_model_str, "BM1370") == 0) {
ESP_LOGI(TAG, "ASIC: %dx BM1370 (%" PRIu64 " cores)", GLOBAL_STATE->asic_count, BM1370_CORE_COUNT);
GLOBAL_STATE->asic_model = ASIC_BM1370;
AsicFunctions ASIC_functions = {.init_fn = BM1370_init,
.receive_result_fn = BM1370_proccess_work,
.set_max_baud_fn = BM1370_set_max_baud,
.set_difficulty_mask_fn = BM1370_set_job_difficulty_mask,
.send_work_fn = BM1370_send_work,
.set_version_mask = BM1370_set_version_mask};
//GLOBAL_STATE.asic_job_frequency_ms = (NONCE_SPACE / (double) (GLOBAL_STATE.POWER_MANAGEMENT_MODULE.frequency_value * BM1370_CORE_COUNT * 1000)) / (double) GLOBAL_STATE.asic_count; // version-rolling so Small Cores have different Nonce Space
GLOBAL_STATE->asic_job_frequency_ms = 500; //ms
GLOBAL_STATE->ASIC_difficulty = BM1370_ASIC_DIFFICULTY;
GLOBAL_STATE->ASIC_functions = ASIC_functions;
} else if (strcmp(GLOBAL_STATE->asic_model_str, "BM1368") == 0) {
ESP_LOGI(TAG, "ASIC: %dx BM1368 (%" PRIu64 " cores)", GLOBAL_STATE->asic_count, BM1368_CORE_COUNT);
GLOBAL_STATE->asic_model = ASIC_BM1368;
AsicFunctions ASIC_functions = {.init_fn = BM1368_init,
.receive_result_fn = BM1368_proccess_work,
.set_max_baud_fn = BM1368_set_max_baud,
.set_difficulty_mask_fn = BM1368_set_job_difficulty_mask,
.send_work_fn = BM1368_send_work,
.set_version_mask = BM1368_set_version_mask};
//GLOBAL_STATE.asic_job_frequency_ms = (NONCE_SPACE / (double) (GLOBAL_STATE.POWER_MANAGEMENT_MODULE.frequency_value * BM1368_CORE_COUNT * 1000)) / (double) GLOBAL_STATE.asic_count; // version-rolling so Small Cores have different Nonce Space
GLOBAL_STATE->asic_job_frequency_ms = 500; //ms
GLOBAL_STATE->ASIC_difficulty = BM1368_ASIC_DIFFICULTY;
GLOBAL_STATE->ASIC_functions = ASIC_functions;
} else if (strcmp(GLOBAL_STATE->asic_model_str, "BM1397") == 0) {
ESP_LOGI(TAG, "ASIC: %dx BM1397 (%" PRIu64 " cores)", GLOBAL_STATE->asic_count, BM1397_SMALL_CORE_COUNT);
GLOBAL_STATE->asic_model = ASIC_BM1397;
AsicFunctions ASIC_functions = {.init_fn = BM1397_init,
.receive_result_fn = BM1397_proccess_work,
.set_max_baud_fn = BM1397_set_max_baud,
.set_difficulty_mask_fn = BM1397_set_job_difficulty_mask,
.send_work_fn = BM1397_send_work,
.set_version_mask = BM1397_set_version_mask};
GLOBAL_STATE->asic_job_frequency_ms = (NONCE_SPACE / (double) (GLOBAL_STATE->POWER_MANAGEMENT_MODULE.frequency_value * BM1397_SMALL_CORE_COUNT * 1000)) / (double) GLOBAL_STATE->asic_count; // no version-rolling so same Nonce Space is splitted between Small Cores
GLOBAL_STATE->ASIC_difficulty = BM1397_ASIC_DIFFICULTY;
GLOBAL_STATE->ASIC_functions = ASIC_functions;
} else {
ESP_LOGE(TAG, "Invalid ASIC model");
AsicFunctions ASIC_functions = {.init_fn = NULL,
.receive_result_fn = NULL,
.set_max_baud_fn = NULL,
.set_difficulty_mask_fn = NULL,
.send_work_fn = NULL};
GLOBAL_STATE->ASIC_functions = ASIC_functions;
// maybe should return here to not execute anything with a faulty device parameter !
return ESP_FAIL;
}
return ESP_OK;
}

12
main/nvs_device.h Normal file
View File

@ -0,0 +1,12 @@
#ifndef MAIN_NVS_DEVICE_H
#define MAIN_NVS_DEVICE_H
#include <stdbool.h>
#include "esp_err.h"
#include "global_state.h"
esp_err_t NVSDevice_init(void);
esp_err_t NVSDevice_parse_config(GlobalState *);
esp_err_t NVSDevice_get_wifi_creds(GlobalState *, char **, char **, char **);
#endif // MAIN_NVS_DEVICE_H

View File

@ -20,6 +20,16 @@
static const char * TAG = "self_test";
bool should_test(GlobalState * GLOBAL_STATE) {
bool is_max = GLOBAL_STATE->asic_model == ASIC_BM1397;
uint64_t best_diff = nvs_config_get_u64(NVS_CONFIG_BEST_DIFF, 0);
uint16_t should_self_test = nvs_config_get_u16(NVS_CONFIG_SELF_TEST, 0);
if (should_self_test == 1 && !is_max && best_diff < 1) {
return true;
}
return false;
}
static void display_msg(char * msg, GlobalState * GLOBAL_STATE) {
SystemModule * module = &GLOBAL_STATE->SYSTEM_MODULE;

View File

@ -2,5 +2,6 @@
#define SELF_TEST_H_
void self_test(void * pvParameters);
bool should_test(GlobalState * GLOBAL_STATE);
#endif

View File

@ -1,24 +1,3 @@
#include "system.h"
#include "esp_log.h"
#include "i2c_bitaxe.h"
#include "EMC2101.h"
//#include "INA260.h"
#include "adc.h"
#include "connect.h"
#include "led_controller.h"
#include "nvs_config.h"
#include "oled.h"
#include "vcore.h"
#include "driver/gpio.h"
#include "esp_app_desc.h"
#include "esp_netif.h"
#include "esp_timer.h"
#include "esp_wifi.h"
#include "lwip/inet.h"
#include <inttypes.h>
#include <math.h>
#include <stdint.h>
@ -30,13 +9,33 @@
#include "freertos/task.h"
#include "freertos/queue.h"
#include "driver/gpio.h"
#include "esp_log.h"
#include "driver/gpio.h"
#include "esp_app_desc.h"
#include "esp_netif.h"
#include "esp_timer.h"
#include "esp_wifi.h"
#include "lwip/inet.h"
#include "system.h"
#include "i2c_bitaxe.h"
#include "EMC2101.h"
#include "INA260.h"
#include "adc.h"
#include "connect.h"
#include "led_controller.h"
#include "nvs_config.h"
#include "oled.h"
#include "vcore.h"
static const char * TAG = "SystemModule";
static void _suffix_string(uint64_t, char *, size_t, int);
static esp_netif_t * netif;
static esp_netif_ip_info_t ip_info;
QueueHandle_t user_input_queue;
@ -95,11 +94,15 @@ void SYSTEM_init_system(GlobalState * GLOBAL_STATE)
// set the wifi_status to blank
memset(module->wifi_status, 0, 20);
}
void SYSTEM_init_peripherals(GlobalState * GLOBAL_STATE) {
// Initialize the core voltage regulator
VCORE_init(GLOBAL_STATE);
VCORE_set_voltage(nvs_config_get_u16(NVS_CONFIG_ASIC_VOLTAGE, CONFIG_ASIC_VOLTAGE) / 1000.0, GLOBAL_STATE);
//init the EMC2101, if we have one
switch (GLOBAL_STATE->device_model) {
case DEVICE_MAX:
case DEVICE_ULTRA:
@ -110,6 +113,20 @@ void SYSTEM_init_system(GlobalState * GLOBAL_STATE)
default:
}
//initialize the INA260, if we have one.
switch (GLOBAL_STATE->device_model) {
case DEVICE_MAX:
case DEVICE_ULTRA:
case DEVICE_SUPRA:
if (GLOBAL_STATE->board_version < 402) {
// Initialize the LED controller
INA260_init();
}
break;
case DEVICE_GAMMA:
default:
}
vTaskDelay(500 / portTICK_PERIOD_MS);
// Ensure overheat_mode config exists
@ -118,6 +135,7 @@ void SYSTEM_init_system(GlobalState * GLOBAL_STATE)
ESP_LOGE(TAG, "Failed to ensure overheat_mode config");
}
//Init the OLED
switch (GLOBAL_STATE->device_model) {
case DEVICE_MAX:
case DEVICE_ULTRA:
@ -143,8 +161,6 @@ void SYSTEM_init_system(GlobalState * GLOBAL_STATE)
_init_connection(GLOBAL_STATE);
}
void SYSTEM_task(void * pvParameters)
{
GlobalState * GLOBAL_STATE = (GlobalState *) pvParameters;
@ -276,7 +292,7 @@ void SYSTEM_notify_found_nonce(GlobalState * GLOBAL_STATE, double found_diff, ui
// Calculate the time difference in seconds with sub-second precision
// hashrate = (nonce_difficulty * 2^32) / time_to_find
module->historical_hashrate[module->historical_hashrate_rolling_index] = GLOBAL_STATE->initial_ASIC_difficulty;
module->historical_hashrate[module->historical_hashrate_rolling_index] = GLOBAL_STATE->ASIC_difficulty;
module->historical_hashrate_time_stamps[module->historical_hashrate_rolling_index] = esp_timer_get_time();
module->historical_hashrate_rolling_index = (module->historical_hashrate_rolling_index + 1) % HISTORY_LENGTH;
@ -319,6 +335,7 @@ void SYSTEM_notify_found_nonce(GlobalState * GLOBAL_STATE, double found_diff, ui
static void _show_overheat_screen(GlobalState * GLOBAL_STATE)
{
SystemModule * module = &GLOBAL_STATE->SYSTEM_MODULE;
esp_netif_ip_info_t ip_info;
switch (GLOBAL_STATE->device_model) {
case DEVICE_MAX:
@ -384,6 +401,7 @@ static void _update_screen_two(GlobalState * GLOBAL_STATE)
{
SystemModule * module = &GLOBAL_STATE->SYSTEM_MODULE;
switch (GLOBAL_STATE->device_model) {
case DEVICE_MAX:
case DEVICE_ULTRA:

View File

@ -4,6 +4,7 @@
#include "global_state.h"
void SYSTEM_init_system(GlobalState * GLOBAL_STATE);
void SYSTEM_init_peripherals(GlobalState * GLOBAL_STATE);
void SYSTEM_task(void * parameters);
void SYSTEM_notify_accepted_share(GlobalState * GLOBAL_STATE);

View File

@ -15,8 +15,6 @@ void ASIC_result_task(void *pvParameters)
{
GlobalState *GLOBAL_STATE = (GlobalState *)pvParameters;
char *user = nvs_config_get_string(NVS_CONFIG_STRATUM_USER, STRATUM_USER);
while (1)
{
task_result *asic_result = (*GLOBAL_STATE->ASIC_functions.receive_result_fn)(GLOBAL_STATE);
@ -45,6 +43,7 @@ void ASIC_result_task(void *pvParameters)
if (nonce_diff > GLOBAL_STATE->ASIC_TASK_MODULE.active_jobs[job_id]->pool_diff)
{
char * user = GLOBAL_STATE->SYSTEM_MODULE.is_using_fallback ? nvs_config_get_string(NVS_CONFIG_FALLBACK_STRATUM_USER, FALLBACK_STRATUM_USER) : nvs_config_get_string(NVS_CONFIG_STRATUM_USER, STRATUM_USER);
int ret = STRATUM_V1_submit_share(
GLOBAL_STATE->sock,
user,
@ -53,6 +52,7 @@ void ASIC_result_task(void *pvParameters)
GLOBAL_STATE->ASIC_TASK_MODULE.active_jobs[job_id]->ntime,
asic_result->nonce,
asic_result->rolled_version ^ GLOBAL_STATE->ASIC_TASK_MODULE.active_jobs[job_id]->version);
free(user);
if (ret < 0) {
ESP_LOGI(TAG, "Unable to write share to socket. Closing connection. Ret: %d (errno %d: %s)", ret, errno, strerror(errno));

View File

@ -134,8 +134,6 @@ void POWER_MANAGEMENT_task(void * pvParameters)
// The power reading from the TPS546 is only it's output power. So the rest of the Bitaxe power is not accounted for.
power_management->power += SUPRA_POWER_OFFSET; // Add offset for the rest of the Bitaxe power. TODO: this better.
} else {
INA260_init();
if (INA260_installed() == true) {
power_management->voltage = INA260_read_voltage();
power_management->current = INA260_read_current();

View File

@ -37,7 +37,6 @@ uint8_t VCORE_init(GlobalState * global_state) {
// case DEVICE_HEX:
default:
}
ADC_init();
return result;
}