Avalon6: Difference between revisions

From Bitcoin Wiki
Jump to navigation Jump to search
Mikeqin (talk | contribs)
Mikeqin (talk | contribs)
 
(105 intermediate revisions by 3 users not shown)
Line 1: Line 1:
= Basic Information =
= Basic Information =
Hashrate:
  Hashrate: 3.5Ths ± 5%
    '''3.65T (+-10%)'''
  Power Consumption: ≈ 1050 Watt (with assumption of 90% power conversion ratio)
  Overclocking: Support automatically optimizes frequency, no need to overclock manually.
Power consumption:
  PSU ouput pin: 4 x 6PIN PCIe power connector.
    990W (measure on 12V port of the device)
  Controller: Raspberry Pi (version B or B+) Raspberry Pi 2 is not supported yet.
    1100W (on the wall, with assumption of 90% power conversion ratio)
  AUC: Each AUC can connect up to 6 devices.
  Dimensions: 340 mm x 136 mm x 150 mm
Power per hash:
  Operating Temperature: -10 °C to 38°C
    270J/THash (device only)
  Fan Specs: 12038, Current less then 2.4A
    295J/THash (on the wall, with assumption of 90% power conversion
  Protection Degree: IP20
ratio)
  Net weight: 4.8kg
  Gross weight: 5kg
Overclocking:
 
    Support automatically optimize frequency, no need to overclock manually.
== Pictures ==
=== Control board ===
PSU ouput pin:
[[File: AvalonMiner6_CTRL.png | none | 640 px]]
    4x6PIN PCIe power connector. *All must be connected.*
* NC means not connect
 
PSU requirements:
=== Fan & Temp control algorithm ===
    Minimum 1100W output, recommend to use high quality PSU for server
* RPi firmware 20160530
with more than 1200W output and high quality power cable.
  [[File:Avalon6 fan adj 601605-256e0f00.png | none | 640px]]
    Input voltage no lower than 11.7V and no higher than 12.2V (numbers
* RPi firmware 20160125
take from the controller)
  [[File:Avalon6 fan adj 601601-5d8a1270.png | none | 640px]]
    Lower voltage leads to lower hashrate and higher voltage leads to
possible device burning down.
    NOTICE: Poor quality cable may result in low voltage.
Fan:
    Specs: 12038
    Current: between 1.6A and 2.8A.
    Minimum RPM: 3800.
    *NOTICE* If the fan is broken or the fan's RPM cannot be measure,
the device will not start.
Controller:
    Raspberry Pi (version B or B+)
    Raspberrt Pi 2 is not supported yet.
    Each RPi can control approximate 60 devices.
AUC:
    Each AUC can connect up to 6 devices.
Dimensions:
    354x136x150mm
Net weight:
    ~4.2kg
   
Protection Degree:
    IP20


== LED ==
== LED ==
Power on: White
=== Avalon6 LED ===
Hashing: Blue
{| class="wikitable sortable" border="1"
Idle: Yellow blinking
|+
  Detect fan: Green blinking
|-
  Error(Software, Power, Temperature): Red blinking
! LED Status
  Manually turn on LED: While blinking
! MEMO
|- valign="top"
| White
| Power on
|- valign="top"
| Blue
| Working normally
|- valign="top"
| Yellow blinking
| Idle normally
|- valign="top"
| Green blinking
| Detect fan and mcu
|- valign="top"
| White blinking
| Turn on LED manually
|- valign="top"
| Red blinking
| Toohot/Loopback failed/PG failed/Coretest failed/Voltage error/Temperature sensor error/No fan
|}
 
=== AUC2 LED ===
{| class="wikitable sortable" border="1"
|+
|-
! LED Status
! MEMO
|- valign="top"
| Blue
| Initializing or Idle normally
|- valign="top"
| Green
| Working normally
|- valign="top"
| Red
| Communication failed
|}
 
== IIC ==
[[File:IIC_Link_Avalon6.png]]
 
== MM Error Codes ==
'''[https://canaan.io/downloads/querystatus.html <span style="color:red">Query EC here</span>]'''
{| class="wikitable sortable" border="1"
|-
! CODE
! NAME
! TYPE
! MEMO
! What to do
|- valign="top"
| 1
| CODE_IDLE
| WARN
| Idle
| Check if the network is ok or AUC is work normally
|- valign="top"
| 2
| CODE_TOOHOT
| FATAL
| Too hot
| Check if the fan is connect successfully
|- valign="top"
| 4
| CODE_LOOP0FAILED
| FATAL
| Channel 0 loopback failed
| Replace a new hash unit  for channel 0 if PG0 is ok
|- valign="top"
| 8
| CODE_LOOP1FAILED
| FATAL
| Channel 1 loopback failed
| Replace a new hash unit  for channel 1 if PG1 is ok
|- valign="top"
| 16
| CODE_INVALIDMCU
| FATAL
| MCU cann't be detected
| Replace a new CTRL board
|- valign="top"
| 32
| CODE_NOSTRATUM
| WARN
| No stratum
| Check if the network is ok or AUC is work normally
|- valign="top"
| 64
| CODE_RBOVERFLOW
| WARN
| Nonce ringbuffer overflow
| Ignore it please, If CGMiner is restart, It will be ok.
|- valign="top"
| 128
| CODE_MMCRCFAILED
| WARN
| Ignore it please, If CGMiner is restart, It will be ok.
| Find iic rx crc mismatch
|- valign="top"
| 256
| CODE_MCUCRCFAILED
| WARN
| Find mcu rx irc mismatch
| Ignore it please, If CGMiner is restart, It will be ok.
|- valign="top"
| 512
| CODE_NOFAN
| FATAL
| Fan cann't be found
| Check the fan connection
|- valign="top"
| 1024
| CODE_PG0FAILED
| FATAL
| Channel 0 power good failed
| Check the PSU for channel 0
|- valign="top"
| 2048
| CODE_PG1FAILED
| FATAL
| Channel 1 power good failed
| Check the PSU for channel 1
|- valign="top"
| 4096
| CODE_CORETESTFAILED
| FATAL
| Find bad chip on channel 0 or channel 1
| Replace a new hash unit if hash rate is too low, or else you can ignore it.
|- valign="top"
| 8192
| CODE_ADC0_ERR
| FATAL
| Temperature sensor cann't be detected on channel 0
| Replace a new hash unit  for channel 0
|- valign="top"
| 16384
| CODE_ADC1_ERR
| FATAL
| Temperature sensor cann't be detected on channel 1
| Replace a new hash unit for channel 1
|- valign="top"
| 32768
| CODE_VOL_ERR
| FATAL
| MM is not permit to run at the voltage for safety
| Change another PSU for the machine
|- valign="top"
| 65536
| CODE_LOCK
| FATAL
| MM is not permit to run without decrypt
| Ask service for help
|- valign="top"
| 131072
| CODE_HOTBEFORE
| WARN
| Toohot is found on MM
| It's just a note on toohot
|- valign="top"
| 262144
| CODE_APIFIFOOVERFLOW
| WARN
| API fifo overflow flag
| It's just a note on api fifo
|}
TYPE meaning:
  '''WARN'''-It designates potentially harmful situations, but you can ignore it.
  '''FATAL'''-It designates very severe error events that will presumably lead the Avalon6 to crash.


= Firmware =
= Firmware =
== RPi Firmware ==
== RPi Firmware ==
=== [https://canaan.io/downloads/software/avalon6/openwrt/20160726/ 20160726] ===
* Support Raspberry Pi 3 Model B
* Sync with OpenWrt master branch (cac971da)
=== [http://downloads.canaan-creative.com/software/avalon6/openwrt/20160530/ 20160530] ===
* CGMiner:Add more options to optimize hashrate when toohot occus.
* CGMiner:Support AV4 miner detect through iic
* CGMiner:Double check data size when use avalon4_auc_xfer
* CGMiner:Update adjust_fan to avoid fan overshoot, Thanks to ckolivas
* CGMiner:Update default target temperature for AvalonMiner 6.(68℃ to 65℃)
* CGMiner:Support 6 machines maximum on a AUC
=== [http://downloads.canaan-creative.com/software/avalon6/openwrt/20160125/ 20160125] ===
* Fix duplicate address
* Update GHS counter to fix the gap between miner and mm
* Add a new smart speed option (mode 3), and change it to default.
* Update mm count when scan hash
=== [http://downloads.canaan-creative.com/software/avalon6/openwrt/20151225/ 20151225] ===
* OpenWrt:Update to 15.05
* OpenWrt:Support Raspberry Pi 2 Model B
* LuCI:Sync with for-15.05 branch (ab31abd244979d1ff234a15a4a3cf69ac1b73688)
* CGMiner:Sync with ckolivas's master (5a456afbfa028162060afd66636b7cb266b35a53)
* CGMiner:Add more options for smartspeed (Only support MM version >= 601512-xxxxxxxx)
=== [http://downloads.canaan-creative.com/software/avalon6/openwrt/20151111/ 20151111] ===
*CGMiner:Fix divide by zero in Avalon4 driver
*CGMiner:Add stratum difficulty in pool api
*CGMiner:Update option for Avalon6
*CGMiner:Update Vol api display in Avalon4 driver for Avalon6
*CGMiner:Update fan adjust for Avalon6
*CGMiner:Update target temp settting for Avalon6
*LuCI:Update display information for Avalon6
*LuCI:Update device name for Avalon6
*LuCI:Update CGMiner configuration for Avalon6
*LuCI:Update CGMiner setting for Avalon theme
=== [http://downloads.canaan-creative.com/software/avalon6/openwrt/20151031/ 20151031] ===
=== [http://downloads.canaan-creative.com/software/avalon6/openwrt/20151031/ 20151031] ===
* Fix nonce counter for multiple miners
* Fix nonce counter for multiple miners
Line 78: Line 255:


=== [http://downloads.canaan-creative.com/software/avalon6/openwrt/nexttesting/ NEXT-TESTING] ===
=== [http://downloads.canaan-creative.com/software/avalon6/openwrt/nexttesting/ NEXT-TESTING] ===
* NOTICE: Only for testing
* Notice: Only for testing purpose
* Update cgminer config for Avalon6 in LuCI
* Display PLL information for modular


== MM Firmware ==
== MM Firmware ==
=== [https://canaan.io/downloads/software/avalon6/mm/2016-08-15/ 2016-08-15] ===
* Version: '''601608-6dffde40'''
* Update: Update led status
=== [https://canaan.io/downloads/software/avalon6/mm/2016-07-15/ 2016-07-15] ===
* Version: '''601607-2a78bc90'''
* Fix: 50% off hash rate bug
=== [http://downloads.canaan-creative.com/software/avalon6/mm/2016-05-11/ 2016-05-11] ===
* Version: '''601605-256e0f00'''
* The minimum stratum pool difficulty should >= 32 for better performance
* Check api fifo overflow
* Add CODE_HOTBEFORE for hot notify
* Add a new package AVA4_P_SET_FREQ
* Support device hardware error
* Fix duplicate share
* Move stratum file to a lib
* Update temp check
=== [http://downloads.canaan-creative.com/software/avalon6/mm/2016-01-25/ 2016-01-25] ===
* Version '''601601-5d8a1270'''
* Add mm package header verify
* Update pll couter for separate module
* Update iic address free mechanism
* Update fan rpm detect
* Fix duplicate address during detect
* Fix freq setting lost cause by mm was toot
=== [http://downloads.canaan-creative.com/software/avalon6/mm/2015-12-28/ 2015-12-28] ===
* Version '''601512-57532250'''
* Fix:Don't touch fan by miner when mm is too hot
* Fix:Update idle process with toohot detect, stratum detect, and invalid mcu protect
* Fix:Fix coretest failed cause by incorrect pll setting
* Update:Update API_TIMEOUT_CONST
* Add:Support adjust freq by CGMiner when mm is working
=== [http://downloads.canaan-creative.com/software/avalon6/mm/2015-11-24/ 2015-11-24] ===
* Version '''601511-f4f59c70'''
* Update Core test check rules
* Update Input voltage check rules (Input voltage should not >= 12.8V)
* Fix result when run test scripts
=== [http://downloads.canaan-creative.com/software/avalon6/mm/2015-11-11/ 2015-11-11] ===
* Version '''601511-e3d244c0 '''
* Add voltage range detect
* Check maximum rpm when detect fan polar
* Check temp for bad ntc resistor
* Check voltage when MM is starting
* Monitor powergood when power on
* Update temperature check
* Update nonce process
* Update frequency table
* Fix conflict address
* Enable 25MHz clock for debug purpose
* Disable pll when if miner is invalid when process FREQ_WORK
=== [http://downloads.canaan-creative.com/software/avalon6/mm/2015-10-31/ 2015-10-31] ===
=== [http://downloads.canaan-creative.com/software/avalon6/mm/2015-10-31/ 2015-10-31] ===
* Version '''601510-afa837a0'''
* Version '''601510-afa837a0'''
Line 108: Line 339:


=== [http://downloads.canaan-creative.com/software/avalon6/mm/nexttesting/ NEXT-TESTING] ===
=== [http://downloads.canaan-creative.com/software/avalon6/mm/nexttesting/ NEXT-TESTING] ===
* NOTICE: Only for testing
* Notice: Only for testing purpose
* Display more details about modular
* Add more protect to make modular safe
* Frequency algo opt
* Use a better way to detect fan


== MCU Firmware ==
== MCU Firmware ==
Line 118: Line 345:
* Version '''6C1508-afa837a0'''
* Version '''6C1508-afa837a0'''
* For adc and temperature capture use MM protocal
* For adc and temperature capture use MM protocal
== AUC2 Firmware ==
=== [http://downloads.canaan-creative.com/software/avalon6/auc2/2015-12-08 20151208] ===
* AUC version: '''AUC-20151208'''
* First release
=== [http://downloads.canaan-creative.com/software/avalon6/auc2/NEXT-TESTING/ NEXT-TESTING] ===
* NOTICE: Only for testing


= Software Development =
= Software Development =
== CGMiner Under Ubuntu 14.04 ==
== Controller firmware ==
# Daily building: '''http://build.canaan-creative.com:8080/~buildbot/avalon6/'''
=== [http://build.canaan-creative.com:8080/~buildbot/avalon6/ Daily building] ===
#Inside your home directory, download Cgminer
=== CGMiner Under Ubuntu 14.04 ===
git clone https://github.com/Canaan-Creative/cgminer
* Download & Compile
cd cgminer
# git clone https://github.com/Canaan-Creative/cgminer
git checkout origin/avalon4 -b avalon4
# cd cgminer
./autogen.sh --enable-avalon4
# git checkout origin/avalon4 -b avalon4
make -j 4
# ./autogen.sh --enable-avalon4
# Run
# make -j 4
  sudo ./cgminer --avalon4-freq 200 --avalon4-voltage 7125 -o http://stratum.pool:3333 -u  work -p pass  
 
  or
* Run
sudo ./cgminer --avalon4-freq 200 --avalon4-voltage 7125 -o http://stratum.pool:3333 -u  work -p pass --api-allow W:192.168.2,W:192.168.2.1 --api-listen $@ 2>./log
# Run with AUC
#;sudo ./cgminer --avalon4-freq 200 --avalon4-voltage 7125 -o http://stratum.pool:3333 -u work -p pass
#;or
#;sudo ./cgminer --avalon4-freq 200 --avalon4-voltage 7125 -o http://stratum.pool:3333 -u  work -p pass --api-allow W:192.168.2,W:192.168.2.1 --api-listen $@ 2>./log
#;
# Run with AUC and IIC interface
#;sudo ./cgminer --avalon4-iic-detect --avalon4-freq 200 --avalon4-voltage 7125 -o http://stratum.pool:3333 -u work -p pass
#;or
#;sudo ./cgminer --avalon4-iic-detect --avalon4-freq 200 --avalon4-voltage 7125 -o http://stratum.pool:3333 -u  work -p pass --api-allow W:192.168.2,W:192.168.2.1 --api-listen $@ 2>./logA
 
=== Frequency Statechart ===
  [[File:A6 frequency state.png | none|  640px]]


== MM ==
== MM ==
* Daily building: '''http://build.canaan-creative.com:8080/~buildbot/mm60/'''
=== [http://build.canaan-creative.com:8080/~buildbot/mm60/ Daily building] ===
* Avalon6 TB2 ===
=== Avalon6 TB2 ===
  $ make -C firmware PLATFORM=MM60_TB2
  $ make -C firmware PLATFORM=MM60_TB2
* Avalon6.0 S ===
=== Avalon6.0 S ===
  $ make -C firmware
  $ make -C firmware
== AUC2 ==
=== [http://build.canaan-creative.com:8080/~buildbot/auc2/ Daily building] ===
=== USB Bootloader ===
==== Support USB-DFU Mode ====
We can use dfu-util under Ubuntu 14.04 or later updata new firmware for AUC2.
==== Using USB-DFU Protocol ====
{| border=1 class="wikitable" style="width: 100%; height: 100px"
|+<big><big>DFU Device Descriptor</big></big>
!Offset!!Field!!Size!!Value!!Descripton
|-
| 0 || bLength || 1 || 12h || Size of this descriptor,in bytes.
|-
| 1 || bDescriptorType || 1 || 01h || DEVICE descriptor type.
|-
| 2 || bcdUSB || 2 || 0100h || USB specification release number in binary coded decimal.
|-
| 4 || bDeviceClass || 1 || 00h || See interface.
|-
| 5 || bDeviceSubClass || 1 || 00h || See interface
|-
| 6 || bDeviceProtocol || 1 || 00h || See interface.
|-
| 7 || bMaxPacketSize0 || 1 || 8,16,32,64 || Maximum packet size for endpoint.
|-
| 8 || idVendor || 2 || ID || Vendor ID. Assigned by the USB-IF.
|-
| 10 || idProduct || 2 || ID || Product ID. Assigned by manufacturer.
|-
| 12 || bcdDevice || 2 || BCD || Device release number in binary coded decimal.
|-
| 14 || iManufacturer || 1 || index || index of string descriptor.
|-
| 15 || iProduct || 1 || index || index of string descriptor.
|-
| 16 || iSerialNumber || 1 || index || index of string descriptor.
|-
| 17 || bNumConfigurations || 1 || 01h || One configuration only for DFU.
|}
{| border=1 class="wikitable" style="width: 100%; height: 100px"
|+<big><big>DFU Interface Descriptor</big></big>
! Offset !! Field !! Size !! Value !! Descripton
|-
| 0 || bLength || 1 || 09h || Size of this descriptor,in bytes.
|-
| 1 || bDescriptorType || 1 || 04h || INTERFACE descriptor type.
|-
| 2 || bInterfaceNumber || 1 || Number || Number of this interface.
|-
| 3 || bAlternateSetting || 1 || 00h || Alternate setting. Must be zero.
|-
| 4 || bNumEndpoints || 1 || 00h || Only the control pipe is used.
|-
| 5 || bInterfaceClass || 1 || FEh || Application Specific Class Code.
|-
| 6 || bInterfaceSubClass || 1 || 01h || Device Firmware Upgrade Code.
|-
| 7 || bInterfaceProtocol || 1 || 01h || Runtime protocol.
|-
| 8 || iInterface || 1 || index || Index of string descriptor for this interface.
|}
{| border=1 class="wikitable" style="width: 100%; height: 100px"
|+<big><big>DFU Functional Descriptor</big></big>
! Offset !! Field !! Size !! Value !! Descripton
|-
| 0 || bLength || 1 || 09h || Size of this descriptor,in bytes.
|-
| 1 || bDescriptorType || 1 || 21h || DFU FUNCTIONAL descriptor type.
|-
| 2 || bmAttributes || 1 || Bit mask || DFU attributes<br />
Bit 7……4: reserved<br />
Bit 3: device will perform a bus detach-attach sequence when it receives a DFU_DETACH request. The host must not issue a USB Reset. (bitWillDetach)<br />
0 = no<br />
1 = yes<br />
Bit 2: device is able to communicate via USB afeter Manifestation phase.(bitManifestationTolerant)<br />
0 = no, must see bus reset<br />
1 = yes<br />
Bit1: upload capable(bitCanUpload)<br />
0 = no<br />
1 = yes<br />
Bit0: download capable(bitCanDnload)<br />
0 = no<br />
1 = yes<br />
|-
| 3 || wDetachTimeOut || 2 || Number || Time,in milliseconds, that the device will wait after receipt of the DFU_DETACH request. if this time elapses without a USB reaset, then the device will terminate the Reconfiguration phase and revert back to normal operation . This repreents the maximum time that the device can wait(depending on its timers, etc.).The host may specify a shorter timeout in the DFU_DETACH request.
|-
| 5 || wTransferSize || 2 || Number || Maximum number of bytes that the device can accept per control-write transaction.
|-
| 7 || bcdDFUVersion || 2 || BCD || Numeric expression identifying the version of the DFU Specification release.
|}
{| border=1 class="wikitable" style="width: 100%; height: 100px"
|+<big><big>DFU Mode Interface Descriptor</big></big>
! Offset !! Field !! Size !! Value !! Descripton
|-
| 0 || bLength || 1 || 09h || Size of this descriptor,in bytes.
|-
| 1 || bDescriptorType || 1 || 04h || INTERFACE descriptor type.
|-
| 2 || bInterfaceNumber || 1 || Number || Number of this interface.
|-
| 3 || bAlternateSetting || 1 || 00h || Alternate setting. Must be zero.
|-
| 4 || bNumEndpoints || 1 || 00h || Only the control pipe is used.
|-
| 5 || bInterfaceClass || 1 || FEh || Application Specific Class Code.
|-
| 6 || bInterfaceSubClass || 1 || 01h || Device Firmware Upgrade Code.
|-
| 7 || bInterfaceProtocol || 1 || 02h || DFU mode protocol.
|-
| 8 || iInterface || 1 || index || Index of string descriptor for this interface.
|}
==== USB-DFU Product's USB Descriptor ====
[[File:USB-DFU Descriptor.png]]
==== DFU Updata Process Diagram ====
[[File:UpdataProcess.png]]
==== Judge Updating Program Or Application Program ====
I used a updata flag which is a four bytes word and is writed at fixd flash address (0x8000 - 4)
The flag's value is 0xAABBCCDD
When the bootloader program run, first it judge the updata flag, if the updata falg is not equal 0xAABBCCDD, it will jump to application program.
Otherwise it will run to updata program.
==== Jump To Application Program ====
When we don't want to updata application program, the bootloader program should run to application program.
In order to achieve this goal, we can add under code in your bootloader program.
<font color="red">asm volatile("ldr r0, =0x4000");</font> <font color="blue">//"the 0x4000 is my application program's MSP point, you must change it adapt to your"</font>
<font color="red">asm volatile("ldr r0, [r0]");</font>
<font color="red">asm volatile("mov sp, r0");</font>
   
<font color="red">asm volatile("ldr r0, =0x4004");</font> <font color="blue">//"the 0x4004 is my application program reset-function entry address, you must change it adapt to your"</font>
<font color="red">asm volatile("ldr r0, [r0]");</font>
<font color="red">asm volatile("mov pc, r0");</font>
==== Modify dfu-util For Ubuntu 14.04 ====
#Inside your home directory, download dfu-util
git clone git://git.openezx.org/dfu-util.git
cd dfu-util
wget https://raw.githubusercontent.com/Johnson-Fan/Avalon-USB-converter/master/patches/001-add-milli_sleep.patch
patch -p0 < 001-add-milli_sleep.patch
./autogen.sh
./configure
make
The resulting binary is dfu-util/src/dfu-util.
=== Add DFU In AUC2 Firmware ===
==== Modify The AUC2 Firmware Flash And RAM Address ====
1. We modify the Flash start address at 0x4000, because the bootloader's size is 0x4000.<br />
2. We modify the RAM start address at 0x10000200, because we remap the NVIC table at the RAM 0x10000000,
    and the NVIC table size is 0x200 bytes.<br />
3. We modify the *.ld file. And my *.ld file is avalon-usb-converter.ld, you can find your *.ld file.
:{|class="wikitable" border="1"
|-
! <big>Before Modification</big>
! <big>After  Modification</big>
|-
|MEMORY
{
    /* Define each memory region */
    MFlash32 (rx) : ORIGIN = 0x0, LENGTH = 0x8000 /* 32K bytes */
    RamLoc4 (rwx) : ORIGIN = 0x10000000, LENGTH = 0x1000 /* 4K bytes */
    RamUsb2 (rwx) : ORIGIN = 0x20004000, LENGTH = 0x800 /* 2K bytes */
}
    /* Define a symbol for the top of each memory region */
    __top_MFlash32 = 0x0 + 0x8000;
    __top_RamLoc4 = 0x1000000 + 0x1000;
    __top_RamUsb2 = 0x20004000 + 0x800;
|MEMORY
{
    /* Define each memory region */
    MFlash32 (rx) : ORIGIN = 0x4000, LENGTH = 0x4000 /* 16K bytes */
    RamLoc4 (rwx) : ORIGIN = 0x10000200, LENGTH = 0xe00 /* 3.5K bytes */
    RamUsb2 (rwx) : ORIGIN = 0x20004000, LENGTH = 0x800 /* 2K bytes */
}
    /* Define a symbol for the top of each memory region */
    __top_MFlash32 = 0x4000 + 0x4000;
    __top_RamLoc4 = 0x10000200 + 0xe00;
    __top_RamUsb2 = 0x20004000 + 0x800;
|}
==== Remap The NVIC Table ====
1. Add Under Function Code In Your Program.
    /* copy the nvic table to ram */
    static void copy_nvic_to_ram(void)
    {
        volatile uint32_t *dst, size;
        volatile const uint32_t *src;<br />
        src = (volatile uint32_t *)APP_START_ADDR;//APP_START_ADDR Is The Application Program's Start Address.
        dst = (volatile uint32_t *)RAM_START_ADDR;//RAM_START_ADDR Is The RAM Start Address.
        size = NVIC_TABLE_LEN >> 2;//NVIC_TABLE_LEN Is The NVIC Table's Size.
        do {
            *dst++ = *src++;
        } while (--size);<br />
        /* NVIC remap to RAM */
        Chip_SYSCTL_Map(0x01);<br />
    }
2. Config The Register To Remap NVIC Table To RAM
:[[File:LPC11u14 NVIC Table Remap1.png | none | 640px ]]
<big><big>More See UM10462 LPC11U3x/2x/1x User manual,At The Page 22.</big></big>
=== Issues ===
<big>1. About Bootloader USB Descriptor:</big>
Note the DFU Functional Descriptor' wTransferSize size, It must equal the USBD_DFU_INIT_PARAM_T's wTransferSize.
<big>2. About IAP Transmission Data Size </big>
The data size should be 256 or 512 or 1024 or 4096 Bytes.
<big>3. About IAP Transmission Data Address </big>
The data address should be a 256 byte boundary.
<big>3. Why sometimes updata failed ?</big>
Now, I didn't find the real reason. But, I think the reason is the time of communication is not correct.
<big>3. Why sometimes updata finished, but the program don't run normally ?</big>
I think that I didn't check the flash address and the data address are right.<br />
I will add the check in the program later.
=== References And Links ===
* [https://www.lpcware.com/lpcxpresso/download LPCXpress IDE Download]
* [http://www.usb.org/developers/docs/devclass_docs/DFU_1.1.pdf See More About DFU Protocol]
* [https://github.com/Canaan-Creative/Avalon-USB-converter Source Code]
* [http://docs.lpcware.com/usbromlib/v1.0/ USBD ROM Stack]
* [http://www.nxp.com/documents/user_manual/UM10462.pdf LPC11U1X User Manual]
* [http://www.lpcware.com/content/nxpfile/lpcopen-software-development-platform-lpc11xx-packages-0 LPCOpen sourcecode]
* [http://docs.lpcware.com/lpcopen/v1.03/ LPCOpen docs]
* [http://www.lpcware.com/system/files/LPCXpressoLPC11U14revA_0.pdf LPC11U14 Rev A Schematic]
* [http://www.nxp.com/documents/errata_sheet/ES_LPC11U1X.pdf Errata sheet LPC11U1x]
* [http://support.code-red-tech.com/CodeRedWiki/UsingGDB?highlight=%28LPC\-Link%29 Using command line GDB]


== TODO ==
== TODO ==
=== OpenWrt ===
# Upgrade OpenWrt branch to master
# Support Raspberry Pi 2B
# Commit cgminer package for OpenWrt packages
# Update with the master branch
 
# Support Avalon6 in LuCI (Advanced version)
# Keep more coding on LuCI (Avalon theme)


=== CGMiner ===
=== CGMiner ===
# Add auto speed option
# Merge the Avalon6 code to CK's master


=== MM ===
=== MM ===
# New board Avalon 6.2 support
# POST
# Temperature support
# LPC11U14 program/update
# Change stratum code to libstratum.a
# Support diff = 1


== Known Issues ==
== Known Issues ==
# MM Firmware upgrade failed
# MM can be upgrade by mismatch firmware.
# local hashrate (GHS av) cann't match with the pool's hashrate
 
= FAQ =
1. How to deal with the red blinking machine?
  [[File:A6 EC PROC.png | none|  640px]]
2. How to boot the machine or hashboard unit safely?
  [[File:A6 BOOT.png | none |  640px]]
3. AUC always appear and then disappear in CGMiner status ?
  It maybe damaged. Take a new one instead.

Latest revision as of 07:59, 15 August 2016

Basic Information

 Hashrate: 3.5Ths ± 5%
 Power Consumption: ≈ 1050 Watt (with assumption of 90% power conversion ratio)
 Overclocking: Support automatically optimizes frequency, no need to overclock manually.
 PSU ouput pin: 4 x 6PIN PCIe power connector.
 Controller: Raspberry Pi (version B or B+) Raspberry Pi 2 is not supported yet.
 AUC: Each AUC can connect up to 6 devices.
 Dimensions: 340 mm x 136 mm x 150 mm
 Operating Temperature: -10 °C to 38°C
 Fan Specs: 12038, Current less then 2.4A
 Protection Degree: IP20
 Net weight: 4.8kg
 Gross weight: 5kg

Pictures

Control board

  • NC means not connect

Fan & Temp control algorithm

  • RPi firmware 20160530
  • RPi firmware 20160125

LED

Avalon6 LED

LED Status MEMO
White Power on
Blue Working normally
Yellow blinking Idle normally
Green blinking Detect fan and mcu
White blinking Turn on LED manually
Red blinking Toohot/Loopback failed/PG failed/Coretest failed/Voltage error/Temperature sensor error/No fan

AUC2 LED

LED Status MEMO
Blue Initializing or Idle normally
Green Working normally
Red Communication failed

IIC

MM Error Codes

Query EC here

CODE NAME TYPE MEMO What to do
1 CODE_IDLE WARN Idle Check if the network is ok or AUC is work normally
2 CODE_TOOHOT FATAL Too hot Check if the fan is connect successfully
4 CODE_LOOP0FAILED FATAL Channel 0 loopback failed Replace a new hash unit for channel 0 if PG0 is ok
8 CODE_LOOP1FAILED FATAL Channel 1 loopback failed Replace a new hash unit for channel 1 if PG1 is ok
16 CODE_INVALIDMCU FATAL MCU cann't be detected Replace a new CTRL board
32 CODE_NOSTRATUM WARN No stratum Check if the network is ok or AUC is work normally
64 CODE_RBOVERFLOW WARN Nonce ringbuffer overflow Ignore it please, If CGMiner is restart, It will be ok.
128 CODE_MMCRCFAILED WARN Ignore it please, If CGMiner is restart, It will be ok. Find iic rx crc mismatch
256 CODE_MCUCRCFAILED WARN Find mcu rx irc mismatch Ignore it please, If CGMiner is restart, It will be ok.
512 CODE_NOFAN FATAL Fan cann't be found Check the fan connection
1024 CODE_PG0FAILED FATAL Channel 0 power good failed Check the PSU for channel 0
2048 CODE_PG1FAILED FATAL Channel 1 power good failed Check the PSU for channel 1
4096 CODE_CORETESTFAILED FATAL Find bad chip on channel 0 or channel 1 Replace a new hash unit if hash rate is too low, or else you can ignore it.
8192 CODE_ADC0_ERR FATAL Temperature sensor cann't be detected on channel 0 Replace a new hash unit for channel 0
16384 CODE_ADC1_ERR FATAL Temperature sensor cann't be detected on channel 1 Replace a new hash unit for channel 1
32768 CODE_VOL_ERR FATAL MM is not permit to run at the voltage for safety Change another PSU for the machine
65536 CODE_LOCK FATAL MM is not permit to run without decrypt Ask service for help
131072 CODE_HOTBEFORE WARN Toohot is found on MM It's just a note on toohot
262144 CODE_APIFIFOOVERFLOW WARN API fifo overflow flag It's just a note on api fifo

TYPE meaning:

 WARN-It designates potentially harmful situations, but you can ignore it.
 FATAL-It designates very severe error events that will presumably lead the Avalon6 to crash.

Firmware

RPi Firmware

20160726

  • Support Raspberry Pi 3 Model B
  • Sync with OpenWrt master branch (cac971da)

20160530

  • CGMiner:Add more options to optimize hashrate when toohot occus.
  • CGMiner:Support AV4 miner detect through iic
  • CGMiner:Double check data size when use avalon4_auc_xfer
  • CGMiner:Update adjust_fan to avoid fan overshoot, Thanks to ckolivas
  • CGMiner:Update default target temperature for AvalonMiner 6.(68℃ to 65℃)
  • CGMiner:Support 6 machines maximum on a AUC

20160125

  • Fix duplicate address
  • Update GHS counter to fix the gap between miner and mm
  • Add a new smart speed option (mode 3), and change it to default.
  • Update mm count when scan hash

20151225

  • OpenWrt:Update to 15.05
  • OpenWrt:Support Raspberry Pi 2 Model B
  • LuCI:Sync with for-15.05 branch (ab31abd244979d1ff234a15a4a3cf69ac1b73688)
  • CGMiner:Sync with ckolivas's master (5a456afbfa028162060afd66636b7cb266b35a53)
  • CGMiner:Add more options for smartspeed (Only support MM version >= 601512-xxxxxxxx)

20151111

  • CGMiner:Fix divide by zero in Avalon4 driver
  • CGMiner:Add stratum difficulty in pool api
  • CGMiner:Update option for Avalon6
  • CGMiner:Update Vol api display in Avalon4 driver for Avalon6
  • CGMiner:Update fan adjust for Avalon6
  • CGMiner:Update target temp settting for Avalon6
  • LuCI:Update display information for Avalon6
  • LuCI:Update device name for Avalon6
  • LuCI:Update CGMiner configuration for Avalon6
  • LuCI:Update CGMiner setting for Avalon theme

20151031

  • Fix nonce counter for multiple miners
  • Display ASIC counts as TA in CGMiner status
  • Update maximum difficulty for Avalon4 and Avalon6
  • Update temperature check for Avalon6
  • Add GHSmm for hash rate comparison
  • Display PLL information for Avalon6
  • Turn on nonce check as default for Avalon6
  • Correct on voltage decode
  • Enable adjust frequency automatically as default for Avalon6
  • Decode voltage and temperature decode for Avalon6
  • Support err code for Avalon6

20151001

  • First version of Avalon6 firmware

NEXT-TESTING

  • Notice: Only for testing purpose

MM Firmware

2016-08-15

  • Version: 601608-6dffde40
  • Update: Update led status

2016-07-15

  • Version: 601607-2a78bc90
  • Fix: 50% off hash rate bug

2016-05-11

  • Version: 601605-256e0f00
  • The minimum stratum pool difficulty should >= 32 for better performance
  • Check api fifo overflow
  • Add CODE_HOTBEFORE for hot notify
  • Add a new package AVA4_P_SET_FREQ
  • Support device hardware error
  • Fix duplicate share
  • Move stratum file to a lib
  • Update temp check

2016-01-25

  • Version 601601-5d8a1270
  • Add mm package header verify
  • Update pll couter for separate module
  • Update iic address free mechanism
  • Update fan rpm detect
  • Fix duplicate address during detect
  • Fix freq setting lost cause by mm was toot

2015-12-28

  • Version 601512-57532250
  • Fix:Don't touch fan by miner when mm is too hot
  • Fix:Update idle process with toohot detect, stratum detect, and invalid mcu protect
  • Fix:Fix coretest failed cause by incorrect pll setting
  • Update:Update API_TIMEOUT_CONST
  • Add:Support adjust freq by CGMiner when mm is working

2015-11-24

  • Version 601511-f4f59c70
  • Update Core test check rules
  • Update Input voltage check rules (Input voltage should not >= 12.8V)
  • Fix result when run test scripts

2015-11-11

  • Version 601511-e3d244c0
  • Add voltage range detect
  • Check maximum rpm when detect fan polar
  • Check temp for bad ntc resistor
  • Check voltage when MM is starting
  • Monitor powergood when power on
  • Update temperature check
  • Update nonce process
  • Update frequency table
  • Fix conflict address
  • Enable 25MHz clock for debug purpose
  • Disable pll when if miner is invalid when process FREQ_WORK

2015-10-31

  • Version 601510-afa837a0
  • Update IIC and UART communication
  • Support core test by AVA4_P_TEST
  • Update ASIC_FREQMIN to 100MHz
  • Detect ASIC counts by LOOPBACK
  • Fix upgrade failed caused by i2c FIFO overflow
  • Update timer function
  • Use GPIO led as address indicator
  • Always disable the invalid miner when PG or LOOPBACK failed
  • Add PLL status in P_STATUS_M
  • Add err code
  • Support ADC capture
  • Keep free run if MCU can't be detected
  • Update led status
  • Rewrite boot loader with c code

2015-09-30

  • Version 601509-a2613610
  • First MM firmware for Avalon6.0 S
  • Support 2 miners
  • Detect asic counts when start
  • Support target filter

NEXT-TESTING

  • Notice: Only for testing purpose

MCU Firmware

2015-10-31

  • Version 6C1508-afa837a0
  • For adc and temperature capture use MM protocal

AUC2 Firmware

20151208

  • AUC version: AUC-20151208
  • First release

NEXT-TESTING

  • NOTICE: Only for testing

Software Development

Controller firmware

Daily building

CGMiner Under Ubuntu 14.04

  • Download & Compile
  1. git clone https://github.com/Canaan-Creative/cgminer
  2. cd cgminer
  3. git checkout origin/avalon4 -b avalon4
  4. ./autogen.sh --enable-avalon4
  5. make -j 4
  • Run
  1. Run with AUC
    sudo ./cgminer --avalon4-freq 200 --avalon4-voltage 7125 -o http://stratum.pool:3333 -u work -p pass
    or
    sudo ./cgminer --avalon4-freq 200 --avalon4-voltage 7125 -o http://stratum.pool:3333 -u work -p pass --api-allow W
    192.168.2,W:192.168.2.1 --api-listen $@ 2>./log
  2. Run with AUC and IIC interface
    sudo ./cgminer --avalon4-iic-detect --avalon4-freq 200 --avalon4-voltage 7125 -o http://stratum.pool:3333 -u work -p pass
    or
    sudo ./cgminer --avalon4-iic-detect --avalon4-freq 200 --avalon4-voltage 7125 -o http://stratum.pool:3333 -u work -p pass --api-allow W
    192.168.2,W:192.168.2.1 --api-listen $@ 2>./logA

Frequency Statechart

MM

Daily building

Avalon6 TB2

$ make -C firmware PLATFORM=MM60_TB2

Avalon6.0 S

$ make -C firmware

AUC2

Daily building

USB Bootloader

Support USB-DFU Mode

We can use dfu-util under Ubuntu 14.04 or later updata new firmware for AUC2.

Using USB-DFU Protocol

DFU Device Descriptor
Offset Field Size Value Descripton
0 bLength 1 12h Size of this descriptor,in bytes.
1 bDescriptorType 1 01h DEVICE descriptor type.
2 bcdUSB 2 0100h USB specification release number in binary coded decimal.
4 bDeviceClass 1 00h See interface.
5 bDeviceSubClass 1 00h See interface
6 bDeviceProtocol 1 00h See interface.
7 bMaxPacketSize0 1 8,16,32,64 Maximum packet size for endpoint.
8 idVendor 2 ID Vendor ID. Assigned by the USB-IF.
10 idProduct 2 ID Product ID. Assigned by manufacturer.
12 bcdDevice 2 BCD Device release number in binary coded decimal.
14 iManufacturer 1 index index of string descriptor.
15 iProduct 1 index index of string descriptor.
16 iSerialNumber 1 index index of string descriptor.
17 bNumConfigurations 1 01h One configuration only for DFU.


DFU Interface Descriptor
Offset Field Size Value Descripton
0 bLength 1 09h Size of this descriptor,in bytes.
1 bDescriptorType 1 04h INTERFACE descriptor type.
2 bInterfaceNumber 1 Number Number of this interface.
3 bAlternateSetting 1 00h Alternate setting. Must be zero.
4 bNumEndpoints 1 00h Only the control pipe is used.
5 bInterfaceClass 1 FEh Application Specific Class Code.
6 bInterfaceSubClass 1 01h Device Firmware Upgrade Code.
7 bInterfaceProtocol 1 01h Runtime protocol.
8 iInterface 1 index Index of string descriptor for this interface.


DFU Functional Descriptor
Offset Field Size Value Descripton
0 bLength 1 09h Size of this descriptor,in bytes.
1 bDescriptorType 1 21h DFU FUNCTIONAL descriptor type.
2 bmAttributes 1 Bit mask DFU attributes

Bit 7……4: reserved

Bit 3: device will perform a bus detach-attach sequence when it receives a DFU_DETACH request. The host must not issue a USB Reset. (bitWillDetach)

0 = no

1 = yes

Bit 2: device is able to communicate via USB afeter Manifestation phase.(bitManifestationTolerant)

0 = no, must see bus reset

1 = yes

Bit1: upload capable(bitCanUpload)

0 = no

1 = yes

Bit0: download capable(bitCanDnload)

0 = no

1 = yes

3 wDetachTimeOut 2 Number Time,in milliseconds, that the device will wait after receipt of the DFU_DETACH request. if this time elapses without a USB reaset, then the device will terminate the Reconfiguration phase and revert back to normal operation . This repreents the maximum time that the device can wait(depending on its timers, etc.).The host may specify a shorter timeout in the DFU_DETACH request.
5 wTransferSize 2 Number Maximum number of bytes that the device can accept per control-write transaction.
7 bcdDFUVersion 2 BCD Numeric expression identifying the version of the DFU Specification release.


DFU Mode Interface Descriptor
Offset Field Size Value Descripton
0 bLength 1 09h Size of this descriptor,in bytes.
1 bDescriptorType 1 04h INTERFACE descriptor type.
2 bInterfaceNumber 1 Number Number of this interface.
3 bAlternateSetting 1 00h Alternate setting. Must be zero.
4 bNumEndpoints 1 00h Only the control pipe is used.
5 bInterfaceClass 1 FEh Application Specific Class Code.
6 bInterfaceSubClass 1 01h Device Firmware Upgrade Code.
7 bInterfaceProtocol 1 02h DFU mode protocol.
8 iInterface 1 index Index of string descriptor for this interface.

USB-DFU Product's USB Descriptor

DFU Updata Process Diagram

Judge Updating Program Or Application Program

I used a updata flag which is a four bytes word and is writed at fixd flash address (0x8000 - 4)
The flag's value is 0xAABBCCDD
When the bootloader program run, first it judge the updata flag, if the updata falg is not equal 0xAABBCCDD, it will jump to application program.
Otherwise it will run to updata program.

Jump To Application Program

When we don't want to updata application program, the bootloader program should run to application program.
In order to achieve this goal, we can add under code in your bootloader program.
asm volatile("ldr r0, =0x4000"); //"the 0x4000 is my application program's MSP point, you must change it adapt to your"
asm volatile("ldr r0, [r0]");
asm volatile("mov sp, r0");
    
asm volatile("ldr r0, =0x4004"); //"the 0x4004 is my application program reset-function entry address, you must change it adapt to your"
asm volatile("ldr r0, [r0]");
asm volatile("mov pc, r0");

Modify dfu-util For Ubuntu 14.04

#Inside your home directory, download dfu-util
git clone git://git.openezx.org/dfu-util.git
cd dfu-util
wget https://raw.githubusercontent.com/Johnson-Fan/Avalon-USB-converter/master/patches/001-add-milli_sleep.patch
patch -p0 < 001-add-milli_sleep.patch
./autogen.sh
./configure
make
The resulting binary is dfu-util/src/dfu-util.

Add DFU In AUC2 Firmware

Modify The AUC2 Firmware Flash And RAM Address

1. We modify the Flash start address at 0x4000, because the bootloader's size is 0x4000.
2. We modify the RAM start address at 0x10000200, because we remap the NVIC table at the RAM 0x10000000, and the NVIC table size is 0x200 bytes.
3. We modify the *.ld file. And my *.ld file is avalon-usb-converter.ld, you can find your *.ld file.
Before Modification After Modification
MEMORY

{

   /* Define each memory region */
   MFlash32 (rx) : ORIGIN = 0x0, LENGTH = 0x8000 	/* 32K bytes */
   RamLoc4 (rwx) : ORIGIN = 0x10000000, LENGTH = 0x1000 /* 4K bytes */
   RamUsb2 (rwx) : ORIGIN = 0x20004000, LENGTH = 0x800 /* 2K bytes */

}

   /* Define a symbol for the top of each memory region */
   __top_MFlash32 = 0x0 + 0x8000;
   __top_RamLoc4 = 0x1000000 + 0x1000;
   __top_RamUsb2 = 0x20004000 + 0x800;
MEMORY

{

   /* Define each memory region */
   MFlash32 (rx) : ORIGIN = 0x4000, LENGTH = 0x4000 	/* 16K bytes */
   RamLoc4 (rwx) : ORIGIN = 0x10000200, LENGTH = 0xe00 /* 3.5K bytes */
   RamUsb2 (rwx) : ORIGIN = 0x20004000, LENGTH = 0x800 /* 2K bytes */

}

   /* Define a symbol for the top of each memory region */
   __top_MFlash32 = 0x4000 + 0x4000;
   __top_RamLoc4 = 0x10000200 + 0xe00;
   __top_RamUsb2 = 0x20004000 + 0x800;

Remap The NVIC Table

1. Add Under Function Code In Your Program.
   /* copy the nvic table to ram */
   static void copy_nvic_to_ram(void)
   {
       volatile uint32_t *dst, size;
       volatile const uint32_t *src;
src = (volatile uint32_t *)APP_START_ADDR;//APP_START_ADDR Is The Application Program's Start Address. dst = (volatile uint32_t *)RAM_START_ADDR;//RAM_START_ADDR Is The RAM Start Address. size = NVIC_TABLE_LEN >> 2;//NVIC_TABLE_LEN Is The NVIC Table's Size. do { *dst++ = *src++; } while (--size);
/* NVIC remap to RAM */ Chip_SYSCTL_Map(0x01);
}
2. Config The Register To Remap NVIC Table To RAM
More See UM10462 LPC11U3x/2x/1x User manual,At The Page 22.

Issues

1. About Bootloader USB Descriptor:

Note the DFU Functional Descriptor' wTransferSize size, It must equal the USBD_DFU_INIT_PARAM_T's wTransferSize.

2. About IAP Transmission Data Size

The data size should be 256 or 512 or 1024 or 4096 Bytes.

3. About IAP Transmission Data Address

The data address should be a 256 byte boundary.

3. Why sometimes updata failed ?

Now, I didn't find the real reason. But, I think the reason is the time of communication is not correct. 

3. Why sometimes updata finished, but the program don't run normally ?

I think that I didn't check the flash address and the data address are right.
I will add the check in the program later.

References And Links

TODO

  1. Upgrade OpenWrt branch to master
  2. Commit cgminer package for OpenWrt packages


CGMiner

MM

Known Issues

  1. MM can be upgrade by mismatch firmware.
  2. local hashrate (GHS av) cann't match with the pool's hashrate

FAQ

1. How to deal with the red blinking machine?

2. How to boot the machine or hashboard unit safely?

3. AUC always appear and then disappear in CGMiner status ?

 It maybe damaged. Take a new one instead.