From d23a55608c977f4ceb430f097ff111fdf93d2291 Mon Sep 17 00:00:00 2001 From: Skot Croshere Date: Tue, 30 May 2023 20:40:39 -0400 Subject: [PATCH] added default difficulty to menuconfig and got rid of the I2C pin config --- main/DS4432U.c | 6 +++--- main/EMC2101.c | 4 ++-- main/INA260.c | 4 ++-- main/Kconfig.projbuild | 39 +++++++++++++++++++++++---------------- main/miner.c | 19 ++++++++++--------- main/system.c | 4 +++- 6 files changed, 43 insertions(+), 33 deletions(-) diff --git a/main/DS4432U.c b/main/DS4432U.c index 450c794f..7718cb32 100644 --- a/main/DS4432U.c +++ b/main/DS4432U.c @@ -3,8 +3,8 @@ #include "esp_log.h" #include "driver/i2c.h" -#define I2C_MASTER_SCL_IO CONFIG_I2C_MASTER_SCL /*!< GPIO number used for I2C master clock */ -#define I2C_MASTER_SDA_IO CONFIG_I2C_MASTER_SDA /*!< GPIO number used for I2C master data */ +#define I2C_MASTER_SCL_IO 48 /*!< GPIO number used for I2C master clock */ +#define I2C_MASTER_SDA_IO 47 /*!< GPIO number used for I2C master data */ #define I2C_MASTER_NUM 0 /*!< I2C master i2c port number, the number of i2c peripheral interfaces available will depend on the chip */ #define I2C_MASTER_FREQ_HZ 400000 /*!< I2C master clock frequency */ #define I2C_MASTER_TX_BUF_DISABLE 0 /*!< I2C master doesn't need buffer */ @@ -120,7 +120,7 @@ bool DS4432U_set_vcore(float core_voltage) { reg_setting = voltage_to_reg(core_voltage); - ESP_LOGI(TAG, "Test set %.3fV = 0x%02X", core_voltage, reg_setting); + ESP_LOGI(TAG, "Set BM1397 voltage = %.3fV [0x%02X]", core_voltage, reg_setting); DS4432U_set(reg_setting); ///eek! diff --git a/main/EMC2101.c b/main/EMC2101.c index 4a5d7d2e..47577ad6 100644 --- a/main/EMC2101.c +++ b/main/EMC2101.c @@ -4,8 +4,8 @@ #include "EMC2101.h" -#define I2C_MASTER_SCL_IO CONFIG_I2C_MASTER_SCL /*!< GPIO number used for I2C master clock */ -#define I2C_MASTER_SDA_IO CONFIG_I2C_MASTER_SDA /*!< GPIO number used for I2C master data */ +#define I2C_MASTER_SCL_IO 48 /*!< GPIO number used for I2C master clock */ +#define I2C_MASTER_SDA_IO 47 /*!< GPIO number used for I2C master data */ #define I2C_MASTER_NUM 0 /*!< I2C master i2c port number, the number of i2c peripheral interfaces available will depend on the chip */ #define I2C_MASTER_FREQ_HZ 400000 /*!< I2C master clock frequency */ #define I2C_MASTER_TX_BUF_DISABLE 0 /*!< I2C master doesn't need buffer */ diff --git a/main/INA260.c b/main/INA260.c index 0f8c6f60..270f5371 100644 --- a/main/INA260.c +++ b/main/INA260.c @@ -4,8 +4,8 @@ #include "INA260.h" -#define I2C_MASTER_SCL_IO CONFIG_I2C_MASTER_SCL /*!< GPIO number used for I2C master clock */ -#define I2C_MASTER_SDA_IO CONFIG_I2C_MASTER_SDA /*!< GPIO number used for I2C master data */ +#define I2C_MASTER_SCL_IO 48 /*!< GPIO number used for I2C master clock */ +#define I2C_MASTER_SDA_IO 47 /*!< GPIO number used for I2C master data */ #define I2C_MASTER_NUM 0 /*!< I2C master i2c port number, the number of i2c peripheral interfaces available will depend on the chip */ #define I2C_MASTER_FREQ_HZ 400000 /*!< I2C master clock frequency */ #define I2C_MASTER_TX_BUF_DISABLE 0 /*!< I2C master doesn't need buffer */ diff --git a/main/Kconfig.projbuild b/main/Kconfig.projbuild index 96e3f356..12e5f1ca 100755 --- a/main/Kconfig.projbuild +++ b/main/Kconfig.projbuild @@ -1,44 +1,51 @@ -menu "Example Configuration" +menu "Bitaxe Configuration" - config I2C_MASTER_SCL - int "SCL GPIO Num" - default 6 if IDF_TARGET_ESP32C3 - default 48 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 + config BM1397_VOLTAGE + int "ASIC Core Voltage (mV)" + range 1000 1800 + default 1400 help - GPIO number for I2C Master clock line. + The core voltage to set the BM1397 ASIC to. +endmenu - config I2C_MASTER_SDA - int "SDA GPIO Num" - default 5 if IDF_TARGET_ESP32C3 - default 47 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 - help - GPIO number for I2C Master data line. +menu "Stratum Configuration" - config EXAMPLE_STRATUM_URL + config STRATUM_URL string "Stratum Address" default "solo.ckpool.org" help The example will connect to this Stratum pool address. - config EXAMPLE_STRATUM_PORT + config STRATUM_PORT int "Stratum Port" range 0 65535 default 3333 help The stratum server port to connect to. - config EXAMPLE_STRATUM_USER + config STRATUM_USER string "Stratum username" default "" help Stratum user to use with pool - config EXAMPLE_STRATUM_PW + config STRATUM_PW string "Stratum password" default "x" help Stratum password to use with pool + config STRATUM_DIFFICULTY + int "Stratum default difficulty" + range 0 4294967296 + default 1000 + help + A starting difficulty to use with the pool. + +endmenu + +menu "Example Configuration" + choice EXAMPLE_SOCKET_IP_INPUT prompt "Socket example source" default EXAMPLE_SOCKET_IP_INPUT_STRING diff --git a/main/miner.c b/main/miner.c index 85019b5c..0ef1fad0 100755 --- a/main/miner.c +++ b/main/miner.c @@ -27,13 +27,15 @@ #include -#define PORT CONFIG_EXAMPLE_STRATUM_PORT -#define STRATUM_URL CONFIG_EXAMPLE_STRATUM_URL -#define STRATUM_USER CONFIG_EXAMPLE_STRATUM_USER -#define STRATUM_PW CONFIG_EXAMPLE_STRATUM_PW +#define PORT CONFIG_STRATUM_PORT +#define STRATUM_URL CONFIG_STRATUM_URL +#define STRATUM_USER CONFIG_STRATUM_USER +#define STRATUM_PW CONFIG_STRATUM_PW + +#define STRATUM_DIFFICULTY CONFIG_STRATUM_DIFFICULTY -static const char *TAG = "stratum client"; +static const char *TAG = "miner"; TaskHandle_t sysTaskHandle = NULL; TaskHandle_t serialTaskHandle = NULL; @@ -146,7 +148,7 @@ static void AsicTask(void * pvParameters) if (nonce_diff > stratum_difficulty) { - print_hex((uint8_t *)&job, sizeof(struct job_packet), sizeof(struct job_packet), "job: "); + //print_hex((uint8_t *)&job, sizeof(struct job_packet), sizeof(struct job_packet), "job: "); submit_share(sock, STRATUM_USER, active_jobs[nonce.job_id]->jobid, active_jobs[nonce.job_id]->ntime, active_jobs[nonce.job_id]->extranonce2, nonce.nonce); } @@ -265,13 +267,12 @@ static void admin_task(void * pvParameters) ESP_LOGI(TAG, "Extranonce: %s", extranonce_str); ESP_LOGI(TAG, "Extranonce 2 length: %d", extranonce_2_len); - suggest_difficulty(sock, 100); + suggest_difficulty(sock, STRATUM_DIFFICULTY); while (1) { char * line = receive_jsonrpc_line(sock); - ESP_LOGI(TAG, "Received line: %s", line); - ESP_LOGI(TAG, "Received line length: %d", strlen(line)); + ESP_LOGI(TAG, "%s", line); //debug incoming stratum messages stratum_method method = parse_stratum_method(line); if (method == MINING_NOTIFY) { diff --git a/main/system.c b/main/system.c index daf49733..0c3c5b62 100644 --- a/main/system.c +++ b/main/system.c @@ -14,6 +14,8 @@ static const char *TAG = "system"; +#define BM1397_VOLTAGE CONFIG_BM1397_VOLTAGE + void init_system(void) { //test the LEDs @@ -32,7 +34,7 @@ void init_system(void) { ADC_init(); //DS4432U tests - DS4432U_set_vcore(1.4); + DS4432U_set_vcore(BM1397_VOLTAGE / 1000.0); //Fan Tests EMC2101_init();