Post
Topic
Board Mining support
Re: Hacking The KNC Firmware: Overclocking
by
bondus
on 13/03/2014, 16:21:20 UTC

I made a new modifications to cgminer.sh to make the clock configuration easier to adapt and save between reboots.

The modification will read the clock settings from the file /config/clocks.conf and apply them when cg/bfgminer is started.
The syntax of the config file should be self explanatory.

Add in the beginning (where the other similar lines are) to cgminer.sh :

CLOCKS=/config/clocks.conf


And a bit further down:

        if [ -n "$good_ports" ] ; then
                if [ -f $CLOCKS ] ; then
                    clocks=$(cat $CLOCKS)
                else
                    clocks="0x02,0x01 0x02,0x01 0x02,0x01 0x02,0x01 0x02,0x01 0x02,0x01 0x02,0x01 0x02,0x01 0x02,0x01 0x02,0x01 0x02,0x01 0x02,0x01 0x02,0x01 0x02,0x01 0x02,0x01 0x02,0x01 "
                fi

                di=0
                for p in $good_ports ; do
                        # Re-enable PLL
                        i2cset -y 2 0x71 1 $((p+1))
                        for c in 0 1 2 3 ; do
                                cmd=$(printf "0x84,0x%02X,0,0" $c)
                                spi-test -s 50000 -OHC -D /dev/spidev1.0 $cmd >/dev/null
                                cl=$(echo $clocks $di | awk '{split($0,a," "); print a[a[NF]+1]}')
                                cmd=$(printf "0x86,0x%02X,%s" $c $cl)
                                spi-test -s 50000 -OHC -D /dev/spidev1.0 $cmd >/dev/null
                                cmd=$(printf "0x85,0x%02X,0,0" $c)
                                spi-test -s 50000 -OHC -D /dev/spidev1.0 $cmd >/dev/null
                                di=$((di+1))
                        done

                        # re-enable all cores
                        i=0
                        while [[ $i -lt 192 ]] ; do
                                i2cset -y 2 0x2$p $i 1
                                i=$((i+1))
                        done
                        spi_ena=$(( spi_ena | (1 << $p) ))
                done
        fi



Example /config/clocks.conf:

0x02,0x71 0x02,0x71 0x02,0x71 0x02,0x71
0x02,0x71 0x02,0x51 0x02,0x71 0x02,0x51
0x02,0x51 0x02,0x51 0x02,0x51 0x02,0x51
0x02,0x51 0x02,0x51 0x02,0x51 0x02,0x51

Spaces are very important in this file. Do not add a space after "0x02,".

I hope its useful Smiley