diff --git a/main/http_server/axe-os/src/app/components/home/home.component.html b/main/http_server/axe-os/src/app/components/home/home.component.html
index 3c6529bb9..4dcd3ea0f 100644
--- a/main/http_server/axe-os/src/app/components/home/home.component.html
+++ b/main/http_server/axe-os/src/app/components/home/home.component.html
@@ -29,6 +29,10 @@
Overview
Version: |
{{info.version}} |
+
+ Board Version: |
+ {{info.boardVersion}} |
+
diff --git a/main/http_server/axe-os/src/app/services/system.service.ts b/main/http_server/axe-os/src/app/services/system.service.ts
index d380918d4..8b528906f 100644
--- a/main/http_server/axe-os/src/app/services/system.service.ts
+++ b/main/http_server/axe-os/src/app/services/system.service.ts
@@ -43,6 +43,7 @@ export class SystemService {
stratumUser: "bc1q99n3pu025yyu0jlywpmwzalyhm36tg5u37w20d.bitaxe-U1",
frequency: 485,
version: "2.0",
+ boardVersion: "204",
flipscreen: 1,
invertscreen: 0,
invertfanpolarity: 1,
diff --git a/main/http_server/axe-os/src/models/ISystemInfo.ts b/main/http_server/axe-os/src/models/ISystemInfo.ts
index bcd33aa03..23fc8cf99 100644
--- a/main/http_server/axe-os/src/models/ISystemInfo.ts
+++ b/main/http_server/axe-os/src/models/ISystemInfo.ts
@@ -24,6 +24,7 @@ export interface ISystemInfo {
stratumUser: string,
frequency: number,
version: string,
+ boardVersion: string,
invertfanpolarity: number,
autofanspeed: number,
fanspeed: number,
diff --git a/main/http_server/http_server.c b/main/http_server/http_server.c
index 4ae5ceb80..2bd5824da 100644
--- a/main/http_server/http_server.c
+++ b/main/http_server/http_server.c
@@ -335,8 +335,9 @@ static esp_err_t GET_system_info(httpd_req_t * req)
char * ssid = nvs_config_get_string(NVS_CONFIG_WIFI_SSID, CONFIG_ESP_WIFI_SSID);
char * stratumURL = nvs_config_get_string(NVS_CONFIG_STRATUM_URL, CONFIG_STRATUM_URL);
char * stratumUser = nvs_config_get_string(NVS_CONFIG_STRATUM_USER, CONFIG_STRATUM_USER);
+ char * board_version = nvs_config_get_string(NVS_CONFIG_BOARD_VERSION, 'unknown');
- cJSON * root = cJSON_CreateObject();
+ cJSON * root = cJSON_CreateObject();
cJSON_AddNumberToObject(root, "power", GLOBAL_STATE->POWER_MANAGEMENT_MODULE.power);
cJSON_AddNumberToObject(root, "voltage", GLOBAL_STATE->POWER_MANAGEMENT_MODULE.voltage);
cJSON_AddNumberToObject(root, "current", GLOBAL_STATE->POWER_MANAGEMENT_MODULE.current);
@@ -360,6 +361,7 @@ static esp_err_t GET_system_info(httpd_req_t * req)
cJSON_AddStringToObject(root, "stratumUser", stratumUser);
cJSON_AddStringToObject(root, "version", esp_app_get_description()->version);
+ cJSON_AddStringToObject(root, "boardVersion", board_version);
cJSON_AddStringToObject(root, "runningPartition", esp_ota_get_running_partition()->label);
cJSON_AddNumberToObject(root, "flipscreen", nvs_config_get_u16(NVS_CONFIG_FLIP_SCREEN, 1));
@@ -372,8 +374,9 @@ static esp_err_t GET_system_info(httpd_req_t * req)
free(ssid);
free(stratumURL);
free(stratumUser);
+ free(board_version);
- const char * sys_info = cJSON_Print(root);
+ const char * sys_info = cJSON_Print(root);
httpd_resp_sendstr(req, sys_info);
free(sys_info);
cJSON_Delete(root);
diff --git a/main/system.c b/main/system.c
index 073dc6ac8..45c87094a 100644
--- a/main/system.c
+++ b/main/system.c
@@ -69,10 +69,6 @@ static void _init_system(GlobalState * global_state, SystemModule * module)
// ledc_init();
// led_set();
- // Playing with BI level
- gpio_set_direction(GPIO_NUM_10, GPIO_MODE_OUTPUT);
- gpio_set_level(GPIO_NUM_10, 0);
-
// Init I2C
ESP_ERROR_CHECK(i2c_master_init());
ESP_LOGI(TAG, "I2C initialized successfully");
diff --git a/main/tasks/power_management_task.c b/main/tasks/power_management_task.c
index a8d4eea8e..4f74873e7 100644
--- a/main/tasks/power_management_task.c
+++ b/main/tasks/power_management_task.c
@@ -12,7 +12,7 @@
#include "serial.h"
#include
-#define POLL_RATE 5000
+#define POLL_RATE 2000
#define MAX_TEMP 90.0
#define THROTTLE_TEMP 75.0
#define THROTTLE_TEMP_RANGE (MAX_TEMP - THROTTLE_TEMP)
@@ -42,6 +42,12 @@ void POWER_MANAGEMENT_task(void * pvParameters)
power_management->frequency_multiplier = 1;
+ char * board_version = nvs_config_get_string(NVS_CONFIG_BOARD_VERSION, "unknown");
+ power_management->HAS_POWER_EN =
+ (strcmp(board_version, "202") == 1 || strcmp(board_version, "203") == 1 || strcmp(board_version, "204") == 1);
+ power_management->HAS_PLUG_SENSE = strcmp(board_version, "204") == 1;
+ free(board_version);
+
int last_frequency_increase = 0;
bool read_power = INA260_installed();
@@ -50,6 +56,23 @@ void POWER_MANAGEMENT_task(void * pvParameters)
uint16_t auto_fan_speed = nvs_config_get_u16(NVS_CONFIG_AUTO_FAN_SPEED, 1);
+ // Configure GPIO12 as input(barrel jack) 1 is plugged in
+ gpio_config_t barrel_jack_conf = {
+ .pin_bit_mask = (1ULL << GPIO_NUM_12),
+ .mode = GPIO_MODE_INPUT,
+ };
+ gpio_config(&barrel_jack_conf);
+ int barrel_jack_plugged_in = gpio_get_level(GPIO_NUM_12);
+
+ gpio_set_direction(GPIO_NUM_10, GPIO_MODE_OUTPUT);
+ if (barrel_jack_plugged_in == 1 || !power_management->HAS_PLUG_SENSE) {
+ // turn ASIC on
+ gpio_set_level(GPIO_NUM_10, 0);
+ } else {
+ // turn ASIC off
+ gpio_set_level(GPIO_NUM_10, 1);
+ }
+
vTaskDelay(3000 / portTICK_PERIOD_MS);
while (1) {
@@ -124,11 +147,18 @@ void POWER_MANAGEMENT_task(void * pvParameters)
if (power_management->chip_temp > THROTTLE_TEMP &&
(power_management->frequency_value > 50 || power_management->voltage > 1000)) {
ESP_LOGE(TAG, "OVERHEAT");
- nvs_config_set_u16(NVS_CONFIG_ASIC_VOLTAGE, 990);
- nvs_config_set_u16(NVS_CONFIG_ASIC_FREQ, 50);
- nvs_config_set_u16(NVS_CONFIG_FAN_SPEED, 100);
- nvs_config_set_u16(NVS_CONFIG_AUTO_FAN_SPEED, 0);
- exit(EXIT_FAILURE);
+
+
+ if (power_management->HAS_POWER_EN) {
+ gpio_set_level(GPIO_NUM_10, 1);
+ } else {
+ nvs_config_set_u16(NVS_CONFIG_ASIC_VOLTAGE, 990);
+ nvs_config_set_u16(NVS_CONFIG_ASIC_FREQ, 50);
+ nvs_config_set_u16(NVS_CONFIG_FAN_SPEED, 100);
+ nvs_config_set_u16(NVS_CONFIG_AUTO_FAN_SPEED, 0);
+ exit(EXIT_FAILURE);
+ }
+
}
}
@@ -139,6 +169,16 @@ void POWER_MANAGEMENT_task(void * pvParameters)
}
// ESP_LOGI(TAG, "target %f, Freq %f, Volt %f, Power %f", target_frequency, power_management->frequency_value,
// power_management->voltage, power_management->power);
+
+ // Read the state of GPIO12
+ if (power_management->HAS_PLUG_SENSE) {
+ int gpio12_state = gpio_get_level(GPIO_NUM_12);
+ if (gpio12_state == 0) {
+ // turn ASIC off
+ gpio_set_level(GPIO_NUM_10, 1);
+ }
+ }
+
vTaskDelay(POLL_RATE / portTICK_PERIOD_MS);
}
}
diff --git a/main/tasks/power_management_task.h b/main/tasks/power_management_task.h
index 9a8e98c0d..9d32b3ef4 100644
--- a/main/tasks/power_management_task.h
+++ b/main/tasks/power_management_task.h
@@ -10,6 +10,8 @@ typedef struct
float frequency_value;
float power;
float current;
+ bool HAS_POWER_EN;
+ bool HAS_PLUG_SENSE;
} PowerManagementModule;
static void automatic_fan_speed(float chip_temp);