46 Commits

Author SHA1 Message Date
mutatrum
e5c317fb97 Improve PLL calculation for BM1366/BM1368/BM1370 (#1051)
* Accept and store float frequency values

* Unify PLL resolver for 1366/1368/1370

Pick the closest frequency to the requested target. If there are multiple PLL settings, pick the one with first the lowest VDO frequency, and finally the lowest posdividers.

Merged frequency ramp start and loop. This solves overshooting when requesting a target frequency within the current step size. It also eliminates the duplicate setting of the target frequency is that's on a step boundary.

Cleaned up several unused defines.

* Restore postdiv2 < postdiv1 condition for BM1368 and BM1370

* Whitespace

* Clean up intermediate functions

Simplify frequency_transition further, finally fix overshoot

* Code cleanup

* Add debug logging for BM1397

* Fix log

* Flip postdiv condition for readability

* Add test

* Fix BM1370 fb_range

* EOF line in test_pll.c
2025-08-07 13:16:36 +02:00
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
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
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
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
WantClue
00a301020e fix: spelling error fix (#849) 2025-04-16 22:16:00 +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
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
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
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
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
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
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
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
Erik Olof Gunnar Andersson
b9126910d6 Make sure we are done writing before setting a new baudrate (#503) 2024-11-20 18:54:10 -05:00
Benjamin Wilson
488473e10e temp sensor fixes (#484)
* temp sensor fixes

* fix emc2101 external temp sign reading

* reset self test file

* Make the emc2101 changes specific to BM1370

---------

Co-authored-by: Benjamin Wilson <admin@opensourceminer.com>
2024-11-16 20:09:32 -05:00
adammwest
df0c9ed745 add warnings for consecutive timeout responses (no rx) from the chip (#378)
* add common vars to control rx warning behavoir
* rename vars, reduce rx timout value, add warning when 20s of consecutive rx timeouts occour
* rename device to asic
* better naming of warning condition variable

* move counter variables into the ASIC source files
* move constants to defines and counters to local vars
* fix stray semicolon

Co-authored-by: Skot <skot@bitnet.cx>
2024-10-09 18:59:45 -04:00
Skot
2c41cc9255 Fix a couple missed issues from the fix_warnings PR (#393)
* move ADC_init() before start_http_server() because the UI reads the ADC
* split SYSTEM_init() into separate functions. cleaned up nvs init.
* fix my dumb INA260_init() memory leak
* SYSTEM_init_peripherals() cleanup
2024-10-09 12:52:55 -04:00
Skot
e1bf30b26e Fix compiler warnings (#381)
Fix all compiler warnings and migrate off depreciated ADC and I2C libraries.
---------
Co-authored-by: Erik Olof Gunnar Andersson <eandersson@users.noreply.github.com>
2024-10-08 11:27:32 -04:00
adammwest
f130b05511 ASIC version mask now based on pool stratum version mask msg (#349)
* make set version mask a function call

* update name

* update init fuc to support version mask setting

* update parameter spec for bm1397

* parametrize set version rolling and update init func for BM136X +

* add default stratum mask

* update all bmchips with a new set_version_mask ASIC function which can be called in main

* update init func prototype params

* update self test to remove extra vmask call in init

* fix compiler errors

* fix compiler errors in main

* add version_mask_given bool to tell the next job to set a new version mask to the chip when a smg comes in
2024-09-26 11:30:06 -04:00
Benjamin Wilson
7b5e3ef2eb increasing delay to 100ms again 2024-09-22 21:18:58 -04:00
Benjamin Wilson
0b0881d025 decrease ramp up 2024-09-22 21:06:53 -04:00
Benjamin Wilson
a94bf8e95e increase ramp_up delay 2024-09-21 15:12:22 -04:00
Benjamin Wilson
b700c6bbf0 Fix overtemp and self tests for gamma (#343) 2024-09-20 19:30:20 -04:00
Skot
f795fc7df5 move job frequency constants to the respective ASIC include files 2024-09-18 11:03:15 -05:00
WantClue
3ee6ac25bc add frequency rampup bm1368 2024-09-06 09:56:30 +02:00
Skot
9577b1a531 add serial buffer framing fix to bm1397 2024-09-05 19:53:02 -04:00
Skot
706fadfc8c add 1370 support for resyncing the ASIC RX buffer on errors 2024-09-03 14:16:20 -04:00
Skot
29f7e0b1b2 moved send_hash_frequency() and do_frequency_ramp_up() over from esp-miner-multichip 2024-08-29 20:50:16 -04:00
Skot
edd39e0071 add frequency ramp up from S21 Pro 2024-08-17 00:26:44 -04:00
Skot
be1242ec61 added TPS546 static power offset. Increased delay for power_management_task.c to start 2024-08-16 22:32:22 -04:00
Skot
3c27ad599f crap, one more asic_response_buffer size fix 2024-08-15 19:28:13 -04:00
Skot
dd0df1ae31 asic_response_buffer size fix 2024-08-15 19:23:57 -04:00
Skot
4cd7a38b9f rebasing gamma-support on 2.1.10 2024-08-15 18:51:05 -04:00