Browse Source

Tweaks to make ztex work on a tp-link router with openwrt

nfactor-troky
nelisky 13 years ago
parent
commit
608a520573
  1. 3
      cgminer.c
  2. 14
      ztex.c

3
cgminer.c

@ -1528,6 +1528,8 @@ static bool submit_upstream_work(const struct work *work)
res = json_object_get(val, "result"); res = json_object_get(val, "result");
if (!QUIET) { if (!QUIET) {
#ifndef MIPSEB
// This one segfaults on my router for some reason
isblock = regeneratehash(work); isblock = regeneratehash(work);
if (isblock) if (isblock)
found_blocks++; found_blocks++;
@ -1535,6 +1537,7 @@ static bool submit_upstream_work(const struct work *work)
sprintf(hashshow, "%08lx.%08lx.%08lx%s", sprintf(hashshow, "%08lx.%08lx.%08lx%s",
(unsigned long)(hash32[7]), (unsigned long)(hash32[6]), (unsigned long)(hash32[5]), (unsigned long)(hash32[7]), (unsigned long)(hash32[6]), (unsigned long)(hash32[5]),
isblock ? " BLOCK!" : ""); isblock ? " BLOCK!" : "");
#endif
} }
/* Theoretically threads could race when modifying accepted and /* Theoretically threads could race when modifying accepted and

14
ztex.c

@ -125,6 +125,11 @@ static bool ztex_checkNonce (struct libztex_device *ztex,
uint32_t *hash2_32 = (uint32_t *)hash2; uint32_t *hash2_32 = (uint32_t *)hash2;
int i; int i;
#if defined(__BIGENDIAN__) || defined(MIPSEB)
hdata->nonce = swab32(hdata->nonce);
hdata->hash7 = swab32(hdata->hash7);
#endif
work->data[64 + 12 + 0] = (hdata->nonce >> 0) & 0xff; work->data[64 + 12 + 0] = (hdata->nonce >> 0) & 0xff;
work->data[64 + 12 + 1] = (hdata->nonce >> 8) & 0xff; work->data[64 + 12 + 1] = (hdata->nonce >> 8) & 0xff;
work->data[64 + 12 + 2] = (hdata->nonce >> 16) & 0xff; work->data[64 + 12 + 2] = (hdata->nonce >> 16) & 0xff;
@ -135,8 +140,11 @@ static bool ztex_checkNonce (struct libztex_device *ztex,
sha2(swap, 80, hash1, false); sha2(swap, 80, hash1, false);
sha2(hash1, 32, hash2, false); sha2(hash1, 32, hash2, false);
#if defined(__BIGENDIAN__) || defined(MIPSEB)
if (hash2_32[7] != ((hdata->hash7 + 0x5be0cd19) & 0xFFFFFFFF)) {
#else
if (swab32(hash2_32[7]) != ((hdata->hash7 + 0x5be0cd19) & 0xFFFFFFFF)) { if (swab32(hash2_32[7]) != ((hdata->hash7 + 0x5be0cd19) & 0xFFFFFFFF)) {
#endif
ztex->errorCount[ztex->freqM] += 1.0/ztex->numNonces; ztex->errorCount[ztex->freqM] += 1.0/ztex->numNonces;
applog(LOG_DEBUG, "%s: checkNonce failed for %0.8X", ztex->repr, hdata->nonce); applog(LOG_DEBUG, "%s: checkNonce failed for %0.8X", ztex->repr, hdata->nonce);
return false; return false;
@ -207,7 +215,7 @@ static uint64_t ztex_scanhash(struct thr_info *thr, struct work *work,
ztex->errorWeight[ztex->freqM] = ztex->errorWeight[ztex->freqM] * 0.995 + 1.0; ztex->errorWeight[ztex->freqM] = ztex->errorWeight[ztex->freqM] * 0.995 + 1.0;
for (i=0; i<ztex->numNonces; i++) { for (i=0; i<ztex->numNonces; i++) {
nonce = hdata[i].nonce; nonce = swab32(hdata[i].nonce);
if (nonce > noncecnt) if (nonce > noncecnt)
noncecnt = nonce; noncecnt = nonce;
if ((nonce >> 4) < (lastnonce[i] >> 4)) { if ((nonce >> 4) < (lastnonce[i] >> 4)) {
@ -234,7 +242,7 @@ static uint64_t ztex_scanhash(struct thr_info *thr, struct work *work,
if (backlog_p >= GOLDEN_BACKLOG) { if (backlog_p >= GOLDEN_BACKLOG) {
backlog_p = 0; backlog_p = 0;
} }
#ifdef __BIG_ENDIAN__ #if defined(__BIGENDIAN__) || defined(MIPSEB)
nonce = swab32(nonce); nonce = swab32(nonce);
#endif #endif
work->blk.nonce = 0xffffffff; work->blk.nonce = 0xffffffff;

Loading…
Cancel
Save