232 Commits

Author SHA1 Message Date
mutatrum
1cf656b411 Several refactors and cleanups (#1102)
- Extract BM##_set_job_difficulty_mask into a single function
- Set self_test difficulty before ASIC_init to eliminate ASIC_set_job_difficulty_mask
- Fixed some capitalisations of GLOBAL_STATE and some others
- Thermal.c: pass DEVICE_CONFIG by pointer instead of by value
2025-07-05 20:58:58 -04:00
Erik Olof Gunnar Andersson
5c849397da Fix last parsed request id not being updated (#1125) 2025-07-04 21:52:10 +02:00
Ahmed Al-Alousi
1669d456a7 Fix strncpy buffer overflow warning in WiFi configuration (#1106)
- Ensure null termination of SSID string
- Fixes -Werror=stringop-truncation compilation error
- Prevents potential buffer overflow when SSID length equals buffer size

Co-authored-by: Johnny <johnny9dev@pm.me>
2025-07-01 20:18:22 -04:00
mutatrum
903418f2a5 Extranonce subscribe and suggested difficulty pool options (#1064)
* Add config for xnsub and suggested difficulty

Added cards for primary and fallback pool configuration

mining.set_extranonce messages are not handled yet. Nicehash wants KYC.

* Move buttons outside card

* Fixed pool view layout

* Remove unused defines

* Implement mining.set_extranonce

* Fix pool xnsub checkboxes

* Re-order pool fields

* Change tooltip wording

* Extract pool configuration component

Author: @duckAxe

* Fix broken merge

* Fix another broken merge

* Number 3

* Number 4

* Fix comment

* Free previous old_extranonce_str

* version_mask is not a char *...

* Move stratum rx logging to stratum_api

* Rename new fields for clarity and add to openapi.yaml

---------

Co-authored-by: duckAxe <>
2025-06-26 16:26:41 +02:00
WantClue
a904d5138b Add stratum response time (#1063)
* feat: add stratum response time

* fix: use esp_timer and move the response tracking to it's dedicated function call

* feat: add response time to UI

* feat: tie to the stratum id

* fix: refactor parsing

* fix: start a bit later

* fix: refactor style

* fix: modulo the request id

* Update main/tasks/stratum_task.c

Co-authored-by: Johnny <johnny9dev@pm.me>

* Update main/tasks/stratum_task.c

Co-authored-by: Johnny <johnny9dev@pm.me>

---------

Co-authored-by: Johnny <johnny9dev@pm.me>
2025-06-25 21:50:43 +02:00
mutatrum
47a5516f35 Custom board config (#1018)
* Initial commit
* Fix NVS field name length
* Add config-custom.cvs example
* Extend example config
* Update self_test.c
* Add documentation
2025-06-21 15:50:36 +02:00
mutatrum
3b8598b333 Self_test check and Wi-Fi code moved to modules (#979)
* Move self_test check and Wi-Fi state into their modules

Also removed main.h and superfluous GlobalState inits.

* Fix compile error

* EOL

* Fix compile error
2025-06-15 22:12:21 +02:00
mutatrum
87b439eaaa Send mining.suggest_difficulty after authorization (#913)
* Send mining.suggest_difficulty after authorization

Refactor set_difficulty passing to mining jobs

* Missed test file
2025-06-09 17:16:05 +02:00
mutatrum
0d0643caa8 Make logging tags uniform (#977) 2025-06-09 17:12:37 +02:00
mutatrum
6414e06161 Clean up duplicate ASIC reset code (#986)
* Unify ASIC reset code

* Add missing include

Build was fine in vscode, not sure why it's failing on GitHub

* Move asic_reset  into separate file
2025-06-09 17:11:10 +02:00
fromport
28b43a85e1 Updated version of CrC calculations by Mecanix (#933)
* Update crc.c

crc files from Mecanix

* Create crc.h

Part of the crc alternative suggested by Mecanix

* Update crc.h

Wrong cut& paste, sorry

* Delete components/asic/crc.h

File in wrong directory

* Update crc.h

* Update TPS546.c

Initialize variables so the code can be compiled with -O2 option.
2025-05-23 08:21:24 +02:00
mutatrum
1d20711af2 Fix stratum parse if there's no error field (#917) 2025-05-15 22:52:29 +02:00
mutatrum
0aa8c359fb Device model cleanup (#857)
* Add mock-up of device name and model on logo screen

* Remove nvs_get_wifi_credits

* Proof of concept for code review

* Fix merge

* Refactored vcore.c

* Log simplification

* Fix missed field rename

* Refactor self-test

* Refactor power.c

* Move Power_disable into VCORE_set_voltage

* Restore ASIC log line

* Clean up self-test.c

* Remove unused constants

* Ultra uses EMC2101 internal temperature sensor

* Simplify thermal configuration

* Set power_offset to 10W for GT (#867)

* Hex is BM1366

* Add board_version 600

* Use boardVersion from config in http response

* Fix GammaTurbo EMC2103 init

* Add Max 0.11 and Ultra 2.2 board versions

* Flip 0.11 and 2.2

* Merge branch 'dev-latest' into HEAD

* Move frequency and voltage options and defaults to device_config.h

* Fix voltage_options loop

* Fix missing frequency and voltage options for BM1368

* Add swarm colors

* Add new fields to openapi.yaml

* Fix asic_job_frequency for Max

* Fix merge
2025-05-15 22:51:21 +02:00
mutatrum
1184810a12 Clean up NVS Wi-Fi credentials code (#859)
* Remove nvs_get_wifi_credits

* Remove function from header
2025-05-15 07:20:54 +02:00
WantClue
00a301020e fix: spelling error fix (#849) 2025-04-16 22:16:00 +02:00
mutatrum
6c7f65e8d9 Handle all Wi-Fi error messages (#819)
* Improve Wi-Fi connection error messages

This refactor is a bit of an oil-spill:
 * Add all Wi-Fi error codes
 * Improve errors on display
 * Set Wi-Fi fields in GlobalState
 * Remove EventGroupHandle for Wi-Fi
 * Remove callback functions from main
 * Generate ap_ssid only once
 * Move packet_type_t from bk1397.h to serial.h
 * Remove asic specific header includes from global_state.h
 * Use NVSDevice_get_wifi_creds in main.c instead of duplicated code

* Remove superfluous zero fill

* Remove bm#### includes

* Show connected status on screen

* Remove hidden flag from self_test finish label

* Remove whitespace

* Remove unused structs

* Add newline at end of file

* Misc cleanup

 * Disable BM1370_SERIALTX_DEBUG
 * Log IP instead of print
 * Fix console error

* Clean up bm13##.h includes

* Try to improve incorrect password errors

* Revert self-test label cleanup

* Revert some more screen cleanup code

* Fix unrelated changes
2025-04-08 13:43:48 +02:00
mutatrum
1dfdfd6e25 Clean up bm13##.h includes 2025-04-04 15:09:45 +02:00
mutatrum
3742bd1025 Misc cleanup
* Disable BM1370_SERIALTX_DEBUG
 * Log IP instead of print
 * Fix console error
2025-04-04 14:38:35 +02:00
Erik Olof Gunnar Andersson
de3b95e39e Improve AP mode stability by stopping unnecessary Wi-Fi reconnections (#815)
* Don't retry wifi when connected to AP

* Update based on feedback
2025-04-03 17:55:13 +02:00
mutatrum
d766493725 Add asic failure status screen (#777)
* Add an asic-status screen and graceful continuation

Fixes #311

* Remove asic_state when model_name is unknown
2025-03-27 19:12:32 +01:00
Erik Olof Gunnar Andersson
a3b7c98845 Expose Wifi RSSI to API endpoint (#739) 2025-03-26 20:58:49 +01:00
mutatrum
6862f763bd Remove bm1397 module (#778)
* global_state: Remove unused bm1397Module

The asic frequency is stored in POWER_MANAGEMENT_MODULE->frequency_value.

Signed-off-by: Robin van der Gracht <robinvandergracht@gmail.com>

* Remove unused bm1397Module

---------

Signed-off-by: Robin van der Gracht <robinvandergracht@gmail.com>
Co-authored-by: Robin van der Gracht <robinvandergracht@gmail.com>
2025-03-20 18:32:15 +01:00
WantClue
c5609dfce1 fix: ports over everything to bitaxeorg (#774) 2025-03-15 22:41:10 +01:00
mutatrum
a5842a54b3 Verify CHIP_ID response (#745)
* Verify CHIP_ID response

Fixes #740

* Log warning on CHIP_ID mismatch

* Fix CHIP_ID checksum calculation

* On BM1397, CORE_NUM should be 0x18

* CORE_NUM and ADDR log only and early exit when no chips are detected

* Fix compile error

* Refactored out duplicated code

Moved count_asic_chips and receive_work functions to common.c
Moved asic_response_buffer to local scope
Unified preamble and crc check on serial rx
Fixed typo in proccess_work
Moved CRC5_MASK define to proper location

* Change receive_work read timeout log to debug

* Changed wrong log to debug

* Fix merge

* Fix length check for bm1397

* add ASIC TX dubugging on BM1397 (crap, does this fix the ticket mask?!)

---------

Co-authored-by: Skot <skot@bitnet.cx>
2025-03-12 22:45:33 +01:00
Erik Olof Gunnar Andersson
deaa291675 Revert "Refactor Stratum code for Seamless Failover (#717)" (#754)
This reverts commit 1eeb303672.
2025-03-10 13:30:31 +01:00
WantClue
d032f2da4a feat: frequency transition (#747)
* feat: frequency transition

* remove floats that are unnecessary

* fix: callback of set_freq function

* refactor asic model code to asic.c

* fix: change namining scheme
2025-03-09 13:58:13 +01:00
Erik Olof Gunnar Andersson
1eeb303672 Refactor Stratum code for Seamless Failover (#717)
* Refactor stratum code

* No need to abandon work when switching connection

* Bump primary task priority slightly

* Reduce watchdog stack size

* Revert debug changes

* Removed unused code

* Removed unused unit test code

* Handle jobs more aggressively

* Fix merge conflict
2025-03-09 13:55:58 +01:00
Erik Olof Gunnar Andersson
6e1205f30a Remove unit test workaround for qemu (#743) 2025-03-08 23:15:59 +01:00
mutatrum
a0c9710a90 Show share reject reasons (#746)
* Show share reject reasons

Fixes #264

* Fix string assignment
2025-03-08 13:07:16 +01:00
mutatrum
ad5d1291b9 Remove undefined method headers (#704) 2025-02-15 19:40:09 +01:00
Erik Olof Gunnar Andersson
b8c748be69 Restore Max support (#705) 2025-02-15 12:14:27 +01:00
Skot
7dcb69ebdc GammaTurbo support and HW abstraction (#698)
* initial changes for the gammaturbo bringup
* added preliminary TPS546 changes
* added preliminary EMC2103 support
* ASIC temp seems to be maybe working.
* magically now fan seems to have the right polarity
* added in ideality and beta constants (currently unused). Fixed EMC2103_get_fan_speed()
* abstract fan and ASIC temp into thermal functions
* abstracted voltage regulator specifics out of tasks and into power.c and vcore.c functions
* add TPS546 support for multiple models
* move TPS40305/DS4432U vout setter to DS4432U.c
* move all ASIC specific functions to asic.c
* bad device_model nvs handling
* remove old code
* add workaround for TPS546 VIN_UV_WARN_LIMIT silicon bug.
2025-02-11 22:46:56 -05:00
Erik Olof Gunnar Andersson
678809a5f8 Improved pool fallback code (#693)
* Disconnect if no data received in more than 10 minutes

* Minor socket fix

* Removed unused code and minor nit fix
2025-02-06 18:48:04 +01:00
WantClue
cbb02389ba Wifi scan fix (#690)
* feature: wifi reconnect disable wifi connect

* fix: scanning flag to prevent reconnect attempts

* fix: add external bool, define globally

* fix: wifi scan on missing ssid

* fix: remove unused connected flag
2025-02-04 03:40:06 +01:00
WantClue
980d213445 SSID WiFi lookup (#679)
* init

* fix: filter out poor networks
2025-02-01 18:19:30 +01:00
Brett Rowan
c98ac818c9 Grandma knows what Wifi means! (#623)
* Grandma knows what Wifi means!

Use Wifi instead of SSID on screen, and add short `(join for setup)` message instead of `Configuration SSID`.
This should be easier to understand, but does add 2 characters, which will fill the screen completely.

* Change NVS configs to init wifi with empty strings, and check for empty string when initializing wifi

* Change `WiFi` to `Wi-Fi` in `connect.c`

* Change what information shows on screen during inital setup and on wifi error

* fix: remove camelCase

remove Bitaxe camel case

---------

Co-authored-by: Upstream Data <brett@upstreamdata.ca>
Co-authored-by: WantClue <86001033+WantClue@users.noreply.github.com>
2025-02-01 18:19:06 +01:00
Erik Olof Gunnar Andersson
f40972ced2 Reduce invalid job found log from error to warning (#480)
* Reduce invalid job found from error to info

* Standarized on LOGW for Invalid job
2025-01-27 19:25:02 +01:00
adammwest
e7b037df10 use length rather than static 4 for hex2bin func of extranonce2_generate (#660) 2025-01-27 18:46:58 +01:00
Erik Olof Gunnar Andersson
c8671cf69c Enable Unit Test CI (#634)
* Enable Unit Test CI

* Remove non-functional entrypoint

* symlink CMakeLists.txt
2025-01-27 18:25:38 +01:00
mutatrum
244dacc26a Tine header define cleanup (#535) 2025-01-16 22:21:59 +01:00
tdb3
b5d1e366c6 test: fix stratum alternative error test (#608)
The test now checks for the expected id and reject-reason

Co-authored-by: WantClue <86001033+WantClue@users.noreply.github.com>
2025-01-08 11:47:22 +01:00
tdb3
3bf8997a72 test: add boundary check for implicit response method (#548)
Test the boundary of STRATUM_RESULT and STRATUM_RESULT_SETUP more completely
2025-01-04 23:57:27 +01:00
tdb3
5e56bcdccc test: fix failing unit test for large stratum id (#546)
PR #243 changes the type of id to int64_t,
allowing for ids exceeding a 16-bit integer.
Adjusts an associated unit test to ensure that
16-bit rollover wouldn't occur.
2025-01-04 23:57:05 +01:00
mutatrum
61042d93ae Configure GPIO in Kconfig (#566)
* Put all GPIO defines in gpio_bitaxe.h

* Whitespace

* Use Kconfig.projbuild

* Missing Kconfig
2025-01-04 01:53:56 +01:00
Erik Olof Gunnar Andersson
695d84ac2a Tune HTTP and System Stability (#571) 2024-12-11 23:23:07 +01:00
mutatrum
848c7807ec LVGL All The Things! (#539) 2024-12-11 23:03:58 +01:00
mutatrum
6283480fa1 Parse stratum api reject reason (#472)
* Parse stratum api reject reason

* Remove superfluous nullcheck
2024-12-09 16:35:13 +01:00
WantClue
b03045d37d Update bm1366.h
disable debugging
2024-11-30 18:59:33 +01:00
Skot
e05839b007 Fix hashing on BM1366 (#532)
* remove erroneous ASIC baudrate change

* add calculated frequency ramp up function. uncomment set_max_baudrate
2024-11-30 10:02:29 -05:00
Skot
22cb8bf4e2 Make selftest failing non-fatal (#524)
* switched selftest fail to be non fatal

* switched to BOOT longpress to reboot after selftest

* lots and lots of error handling cleanup. <slippery slope>

* move around the DS4432U_Init() function call
2024-11-30 10:02:09 -05:00