Compare commits
11 Commits
6a04694180
...
7844102336
Author | SHA1 | Date | |
---|---|---|---|
|
7844102336 | ||
|
2028613c4c | ||
|
14f4efce72 | ||
|
a94f3ff151 | ||
|
30075fb015 | ||
|
df06ff17eb | ||
|
a05f666031 | ||
|
93cc2a1a88 | ||
|
de10ecad99 | ||
|
4df5d3615e | ||
|
fb36c60738 |
@ -3,7 +3,6 @@
|
||||
#ifdef T_DISPLAY
|
||||
|
||||
#include <TFT_eSPI.h>
|
||||
#include "media/images_320_170.h"
|
||||
#include "media/myFonts.h"
|
||||
#include "media/Free_Fonts.h"
|
||||
#include "version.h"
|
||||
@ -11,6 +10,12 @@
|
||||
#include "OpenFontRender.h"
|
||||
#include "rotation.h"
|
||||
|
||||
#ifdef NERD_NOS
|
||||
#include "media/images_NOS_320_170.h"
|
||||
#else
|
||||
#include "media/images_320_170.h"
|
||||
#endif
|
||||
|
||||
#define WIDTH 340
|
||||
#define HEIGHT 170
|
||||
|
||||
@ -83,9 +88,9 @@ void tDisplay_MinerScreen(unsigned long mElapsed)
|
||||
// Total hashes
|
||||
render.setFontSize(18);
|
||||
render.rdrawString(data.totalMHashes.c_str(), 268, 138, TFT_BLACK);
|
||||
// Block templates
|
||||
// ASIC temp
|
||||
render.setFontSize(18);
|
||||
render.drawString(data.templates.c_str(), 186, 20, 0xDEDB);
|
||||
render.drawString(data.currentTemperature.c_str(), 186, 20, 0xDEDB);
|
||||
// Best diff
|
||||
render.drawString(data.bestDiff.c_str(), 186, 48, 0xDEDB);
|
||||
// 32Bit shares
|
||||
|
@ -48,6 +48,8 @@ typedef struct __attribute__((__packed__))
|
||||
|
||||
static const char *TAG = "bm1397Module";
|
||||
|
||||
static const uint8_t chip_id[] = {0xAA, 0x55, 0x13, 0x97, 0x18, 0x00};
|
||||
|
||||
uint32_t increment_bitmask(const uint32_t value, const uint32_t mask);
|
||||
|
||||
/// @brief
|
||||
@ -204,9 +206,8 @@ static uint8_t _send_init(uint64_t frequency, uint16_t asic_count)
|
||||
|
||||
int chip_counter = 0;
|
||||
while (true) {
|
||||
int received = SERIAL_rx(buf, 11, 1000);
|
||||
if (received > 0) {
|
||||
//ESP_LOG_BUFFER_HEX(TAG, asic_response_buffer, received);
|
||||
int received = SERIAL_rx(buf, 9, 1000);
|
||||
if (received > 0 && !memcmp(chip_id, buf, sizeof(chip_id))) {
|
||||
chip_counter++;
|
||||
} else {
|
||||
break;
|
||||
@ -361,24 +362,23 @@ bool BM1397_receive_work(uint16_t timeout, asic_result *result)
|
||||
{
|
||||
uint8_t *rcv_buf = (uint8_t*) result;
|
||||
|
||||
// wait for a response, wait time is pretty arbitrary
|
||||
int received = SERIAL_rx(rcv_buf, 9, timeout);
|
||||
// non blocking read
|
||||
int received = SERIAL_rx_non_blocking(rcv_buf, 9);
|
||||
|
||||
if (received < 0)
|
||||
{
|
||||
Serial.println("Error in serial RX");
|
||||
return false;
|
||||
}
|
||||
else if (received == 0)
|
||||
else if (!received)
|
||||
{
|
||||
// Didn't find a solution, restart and try again
|
||||
// we have not received any data
|
||||
return false;
|
||||
}
|
||||
|
||||
if (received != 9 || rcv_buf[0] != 0xAA || rcv_buf[1] != 0x55)
|
||||
{
|
||||
Serial.println("Serial RX invalid. Resetting receive buffer ...");
|
||||
//ESP_LOG_BUFFER_HEX(TAG, asic_response_buffer, received);
|
||||
SERIAL_clear_buffer();
|
||||
return false;
|
||||
}
|
||||
|
3410
src/drivers/nerd-nos/nos_images/nos_clock.bin
Normal file
3410
src/drivers/nerd-nos/nos_images/nos_clock.bin
Normal file
File diff suppressed because it is too large
Load Diff
BIN
src/drivers/nerd-nos/nos_images/nos_clock.png
Normal file
BIN
src/drivers/nerd-nos/nos_images/nos_clock.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 41 KiB |
3410
src/drivers/nerd-nos/nos_images/nos_globalHash.bin
Normal file
3410
src/drivers/nerd-nos/nos_images/nos_globalHash.bin
Normal file
File diff suppressed because it is too large
Load Diff
BIN
src/drivers/nerd-nos/nos_images/nos_globalHash.png
Normal file
BIN
src/drivers/nerd-nos/nos_images/nos_globalHash.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 40 KiB |
3410
src/drivers/nerd-nos/nos_images/nos_hashscreen.bin
Normal file
3410
src/drivers/nerd-nos/nos_images/nos_hashscreen.bin
Normal file
File diff suppressed because it is too large
Load Diff
BIN
src/drivers/nerd-nos/nos_images/nos_hashscreen.png
Normal file
BIN
src/drivers/nerd-nos/nos_images/nos_hashscreen.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 49 KiB |
3410
src/drivers/nerd-nos/nos_images/nos_initScreen.bin
Normal file
3410
src/drivers/nerd-nos/nos_images/nos_initScreen.bin
Normal file
File diff suppressed because it is too large
Load Diff
BIN
src/drivers/nerd-nos/nos_images/nos_initScreen.png
Normal file
BIN
src/drivers/nerd-nos/nos_images/nos_initScreen.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 58 KiB |
3410
src/drivers/nerd-nos/nos_images/nos_priceScreen.bin
Normal file
3410
src/drivers/nerd-nos/nos_images/nos_priceScreen.bin
Normal file
File diff suppressed because it is too large
Load Diff
BIN
src/drivers/nerd-nos/nos_images/nos_priceScreen.png
Normal file
BIN
src/drivers/nerd-nos/nos_images/nos_priceScreen.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 73 KiB |
@ -57,6 +57,28 @@ size_t SERIAL_check_for_data() {
|
||||
return length;
|
||||
}
|
||||
|
||||
/// @brief waits for a serial response from the device
|
||||
/// @param buf buffer to read data into
|
||||
/// @param buf number of ms to wait before timing out
|
||||
/// @return number of bytes read, or -1 on error
|
||||
int16_t SERIAL_rx_non_blocking(uint8_t *buf, uint16_t size) {
|
||||
// check how much data we have
|
||||
size_t available = SERIAL_check_for_data();
|
||||
|
||||
// no data available, return 0
|
||||
if (!available) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// check for incomplete data
|
||||
if (available && available < size) {
|
||||
Serial.printf("not returning incomplete data ... %d vs %d\n", (int) available, (int) size);
|
||||
return 0;
|
||||
}
|
||||
// timeout 0 means non_blocking read
|
||||
return SERIAL_rx(buf, size, 0);
|
||||
}
|
||||
|
||||
|
||||
/// @brief waits for a serial response from the device
|
||||
/// @param buf buffer to read data into
|
||||
@ -64,13 +86,6 @@ size_t SERIAL_check_for_data() {
|
||||
/// @return number of bytes read, or -1 on error
|
||||
int16_t SERIAL_rx(uint8_t *buf, uint16_t size, uint16_t timeout_ms)
|
||||
{
|
||||
// don't return incomplete data
|
||||
size_t available = SERIAL_check_for_data();
|
||||
if (available && available < size) {
|
||||
Serial.printf("not returning parts of data ... %d vs %d\n", (int) available, (int) size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int16_t bytes_read = uart_read_bytes(UART_NUM_1, buf, size, timeout_ms / portTICK_PERIOD_MS);
|
||||
// if (bytes_read > 0) {
|
||||
// printf("rx: ");
|
||||
@ -83,21 +98,6 @@ int16_t SERIAL_rx(uint8_t *buf, uint16_t size, uint16_t timeout_ms)
|
||||
return bytes_read;
|
||||
}
|
||||
|
||||
void SERIAL_debug_rx(void)
|
||||
{
|
||||
int ret;
|
||||
uint8_t buf[CHUNK_SIZE];
|
||||
|
||||
ret = SERIAL_rx(buf, 100, 20);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "unable to read data\n");
|
||||
return;
|
||||
}
|
||||
|
||||
memset(buf, 0, 1024);
|
||||
}
|
||||
|
||||
void SERIAL_clear_buffer(void)
|
||||
{
|
||||
uart_flush(UART_NUM_1);
|
||||
|
@ -4,8 +4,8 @@
|
||||
|
||||
int SERIAL_send(uint8_t *, int, bool);
|
||||
void SERIAL_init(void);
|
||||
void SERIAL_debug_rx(void);
|
||||
int16_t SERIAL_rx(uint8_t *, uint16_t, uint16_t);
|
||||
int16_t SERIAL_rx_non_blocking(uint8_t *buf, uint16_t size);
|
||||
void SERIAL_clear_buffer(void);
|
||||
void SERIAL_set_baud(int baud);
|
||||
|
||||
|
23844
src/media/images_NOS_320_170.h
Normal file
23844
src/media/images_NOS_320_170.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -29,6 +29,8 @@ extern pthread_mutex_t job_mutex;
|
||||
extern double best_diff;
|
||||
extern unsigned long mLastTXtoPool;
|
||||
|
||||
extern uint32_t shares;
|
||||
extern uint32_t valids;
|
||||
|
||||
// we can have 32 different job ids
|
||||
#define ASIC_JOB_COUNT 32
|
||||
@ -98,6 +100,9 @@ static void calculate_hashrate(history_t *history, uint32_t diff) {
|
||||
}
|
||||
|
||||
history->newest++;
|
||||
|
||||
// Increment the global shares counter
|
||||
shares++;
|
||||
}
|
||||
|
||||
// triggers the job creation
|
||||
@ -150,34 +155,34 @@ void runASIC(void * task_id) {
|
||||
uint32_t current_difficulty = 0;
|
||||
|
||||
while (mMiner.inRun) {
|
||||
// Temperature check
|
||||
unsigned long currentTime = millis();
|
||||
if (currentTime - lastTempCheck > TEMP_CHECK_INTERVAL) {
|
||||
float currentTemp = nerdnos_get_temperature(); // Get ASIC temperature
|
||||
|
||||
if (currentTemp > MAX_SAFE_TEMP) {
|
||||
gpio_set_level(NERD_NOS_GPIO_PEN, 0); // Disable Buck
|
||||
Serial.println("ASIC temperature too high. Disabling power.");
|
||||
|
||||
// Wait for temperature to drop
|
||||
while (nerdnos_get_temperature() > (MAX_SAFE_TEMP - 15)) { // 15 degree hysteresis
|
||||
vTaskDelay(2000 / portTICK_PERIOD_MS); // Check every 2 second
|
||||
}
|
||||
|
||||
gpio_set_level(NERD_NOS_GPIO_PEN, 1); // Enable Buck again
|
||||
Serial.println("Temperature safe. Re-enabling ASIC.");
|
||||
BM1397_init(200, 1); // Re-Init ASIC
|
||||
}
|
||||
|
||||
lastTempCheck = currentTime;
|
||||
}
|
||||
|
||||
// wait for the timer to start a new job
|
||||
// also yields the CPU
|
||||
pthread_mutex_lock(&job_interval_mutex);
|
||||
pthread_cond_wait(&job_interval_cond, &job_interval_mutex);
|
||||
pthread_mutex_unlock(&job_interval_mutex);
|
||||
|
||||
// Temperature check
|
||||
unsigned long currentTime = millis();
|
||||
if (currentTime - lastTempCheck > TEMP_CHECK_INTERVAL) {
|
||||
float currentTemp = nerdnos_get_temperature(); // Get ASIC temperature
|
||||
|
||||
if (currentTemp > MAX_SAFE_TEMP) {
|
||||
gpio_set_level(NERD_NOS_GPIO_PEN, 0); // Disable Buck
|
||||
Serial.println("ASIC temperature too high. Disabling power.");
|
||||
|
||||
// Wait for temperature to drop
|
||||
while (nerdnos_get_temperature() > (MAX_SAFE_TEMP - 15)) { // 15 degree hysteresis
|
||||
vTaskDelay(2000 / portTICK_PERIOD_MS); // Check every 2 second
|
||||
}
|
||||
|
||||
gpio_set_level(NERD_NOS_GPIO_PEN, 1); // Enable Buck again
|
||||
Serial.println("Temperature safe. Re-enabling ASIC.");
|
||||
BM1397_init(200, 1); // Re-Init ASIC
|
||||
}
|
||||
|
||||
lastTempCheck = currentTime;
|
||||
}
|
||||
|
||||
// increment extranonce2
|
||||
extranonce_2++;
|
||||
|
||||
@ -191,13 +196,15 @@ void runASIC(void * task_id) {
|
||||
// make sure that another task doesn't mess with the data while
|
||||
// we are using it
|
||||
pthread_mutex_lock(&job_mutex);
|
||||
if (current_difficulty != mMiner.poolDifficulty) {
|
||||
current_difficulty = mMiner.poolDifficulty;
|
||||
nerdnos_create_job(&mWorker, &mJob, &asic_jobs[asic_job_id], extranonce_2, mMiner.poolDifficulty);
|
||||
pthread_mutex_unlock(&job_mutex);
|
||||
|
||||
// don't send difficulty while the job mutex is locked
|
||||
if (current_difficulty != asic_jobs[asic_job_id].pool_diff) {
|
||||
current_difficulty = asic_jobs[asic_job_id].pool_diff;
|
||||
nerdnos_set_asic_difficulty(current_difficulty);
|
||||
Serial.printf("Set difficulty to %lu\n", current_difficulty);
|
||||
}
|
||||
nerdnos_create_job(&mWorker, &mJob, &asic_jobs[asic_job_id], extranonce_2, current_difficulty);
|
||||
pthread_mutex_unlock(&job_mutex);
|
||||
|
||||
// send the job and
|
||||
nerdnos_send_work(&asic_jobs[asic_job_id], asic_job_id);
|
||||
|
Loading…
Reference in New Issue
Block a user