Ok, starting a thread here to deal with hacking on BitForce SC firmware using
only free software.
Non-free software is off-topic here. Note that closed-source software is always non-free, even if you don't have to pay for it.
Needless to say, if you damage your mining devices doing this, you're on your own.
Neither I nor BFL are likely to provide compensation or any warranty for hacking firmware.
Overview:
1. Toolchain (success, docs WIP)
2. Building (WIP)
3. Flashing (complete)
4. Debugging (nothing done)
Step 1: ToolchainThis is a pain. I'll document it later.
For now, you can play with my (Gentoo-oriented) notes:
crossdev -t avr32 -s1 # this will fail! but sets up stuff for us
# BEGIN binutils
mkdir -p /etc/portage/patches/cross-avr32/binutils/
cd /etc/portage/patches/cross-avr32/binutils/
PATCHES="
20-binutils.2.20.1-avr32-autoconf.patch
30-binutils-2.20.1-avr32-bfd.patch
31-binutils-2.20.1-avr32-binutils.patch
32-binutils-2.20.1-avr32-gas.patch
33-binutils-2.20.1-avr32-include.patch
34-binutils-2.20.1-avr32-ld.patch
35-binutils-2.20.1-avr32-opcodes.patch
40-binutils-2.20.1-avr32-fixes.patch
41-binutils-2.20.1-avr32-fpu.patch
42-binutils-2.20.1-avr32-bug-7435.patch
50-binutils-2.20.1-avr32-mxt768e.patch
51-binutils-2.20.1-avr32-uc3c.patch
52-binutils-2.20.1-avr32-uc3l0128.patch
53-binutils-2.20.1-avr32-uc3a4.patch
54-binutils-2.20.1-avr32-uc3d.patch
55-binutils-2.20.1-avr32-uc3l3l4.patch
"
for patch in $PATCHES; do
wget http://distribute.atmel.no/tools/opensource/avr32-gcc/binutils-2.20.1/$patch
done
# Possibly change make.conf to MAKEOPTS=-j1 - not sure if necessary
USE='-* multitarget' emerge =cross-avr32/binutils-2.20.1-r1
# interrupt build (Ctrl-Z) immediately after patches are applied
cd /var/tmp/portage/cross-avr32/binutils-2.20.1-r1/work/binutils-2.20.1
$EDITOR opcodes/Makefile.am # find avr-dis.c and add under it: avr32-asm.c avr32-dis.c avr32-opc.c
for d in . gold intl libiberty gprof ld binutils etc gas opcodes bfd; do ( cd "$d"; autoreconf; ); done
fg
aclocal -I config
autoconf
automake
autoheader
for d in bfd opcodes binutils gas ld; do
pushd $d
autoconf
automake
autoheader
popd
done
fg
# interrupt build (Ctrl-Z) after bfd has configured
cd /var/tmp/portage/cross-avr32/binutils-2.20.1-r1/work/build/bfd
make headers
fg
# DONE binutils
# BEGIN gcc
mkdir -p /etc/portage/patches/cross-avr32/gcc/
cd /etc/portage/patches/cross-avr32/gcc/
PATCHES="
30-gcc-4.4.3-avr32.patch
31-gcc-4.4.3-avr32-rmw.patch
32-gcc-4.4.3-avr32-sleep-builtin.patch
33-gcc-4.4.3-avr32-ucr3fp.patch
34-gcc-4.4.3-avr32-fpu.patch
35-gcc-4.4.3.avr32-delay-cycles.patch
36-gcc-4.4.3.avr32-list-devices.patch
40-gcc-4.4.3-avr32-fpemul-fixes.patch
41-gcc-4.4.3-avr32-fix-const_int_addr.patch
42-gcc-4.4.3-avr32-fix-reorg_opt_bug11763.patch
43-gcc-4.4.3-avr32-4_4_3-upgrade.patch
44-gcc-4.4.3-avr32-bug-12671.patch
45-gcc-4.4.3-avr32-bug-7435.patch
46-gcc-4.4.3-avr32-bug-9675.patch
50-gcc-4.4.3-avr32-mxt768e.patch
51-gcc-4.4.3-avr32-uc3c.patch
52-gcc-4.4.3-avr32-uc3l0128.patch
53-gcc-4.4.3-avr32-uc3a4.patch
54-gcc-4.4.3-avr32-uc3d.patch
55-gcc-4.4.3-avr32-uc3l3l4u.patch
"
for patch in $PATCHES; do
wget http://distribute.atmel.no/tools/opensource/avr32-gcc/gcc-4.4.3/$patch
done
USE='-*' ACCEPT_KEYWORDS=** emerge =cross-avr32/gcc-4.4.3-r3
# DONE gcc
# BEGIN atmel-headers
layman -a luke-jr
ACCEPT_KEYWORDS=** emerge cross-avr32/atmel-headers
# DONE atmel-headers
# BEGIN newlib
mkdir -p /etc/portage/patches/cross-avr32/newlib/
cd /etc/portage/patches/cross-avr32/newlib/
# skip 10-newlib-1.16.0-avr32-atmel-version.patch
PATCHES="
30-newlib-1.16.0-avr32.patch
31-newlib-1.16.0-flashvault.patch
"
for patch in $PATCHES; do
wget http://distribute.atmel.no/tools/opensource/avr32-gcc/newlib-1.16.0/$patch
done
ln -s /usr/portage/sys-libs/newlib /usr/portage/local/crossdev/cross-avr32/
USE=-* ACCEPT_KEYWORDS=** emerge =cross-avr32/newlib-2.0.0
# interrupt build (Ctrl-Z) immediately after source unpacks
cd /var/tmp/portage/cross-avr32/newlib-2.0.0/work/newlib-2.0.0/
for patch in $PATCHES; do
patch -p0 <"/etc/portage/patches/cross-avr32/newlib/$patch"
done
cd newlib
autoreconf
fg
# interrupt build (Ctrl-Z) immediately after you see:
# >>> Install newlib-2.0.0 into /var/tmp/portage/cross-avr32/newlib-2.0.0/image/ category cross-avr32
mkdir -p /var/tmp/portage/cross-avr32/newlib-2.0.0/image//usr/avr32/lib
# DONE newlib
ln -s /usr/lib/binutils/avr32/2.20.1/ldscripts/ /usr/avr32/lib/
Step 2: BuildingTODO. I haven't done this 100% yet.
My
BitForce_SC repository has a "make" branch that compiles to a .elf binary for now.
Step 3: FlashingI decided to use the
"TUMPA" JTAG interface (WARNING: this shop closed almost right after I ordered, until Aug 17).
There are
many other options (including some nice open hardware you have to build yourself), but I don't have any experience with them (note that it
must work at 3.3V!).
NOTE: I think Atmel's "Dragon" adapter will
not work for this!
This board has a
20-pin JTAG connector, and the BFL boards have a
10-pin JTAG connector, each with different pinouts (ie, you can't just match half the 20-pin with the 5-pin!)
You want to connect these pins:
Name | 20-pin/TUMPA | 10-pin/BFL |
VCC/VREF/VTAR | 1 | 4 |
nTRST | 3 | 8 |
TDI | 5 | 9 |
TMS | 7 | 5 |
TCK | 9 | 1 |
TDO | 13 | 3 |
GND | 20* | 10* |
You can use any GND pin on both ends, only one needs to be connected.
Next, you'll need to install a special version of UrJTAG.
For some reason, they ignored
AVR32 flash patches in 2009.
We need that. We also need a part definition for the AVR32 chip in BFL's devices.
I've put all this together in
a git clone of UrJTAG for simplicity.
Build this from source and install it.
If you have an Intel HEX firmware (such as
the 1.2.5 release binary - which is, by the way,
probably compiled only for one particular model), you can convert it to the format needed for UrJTAG using this command:
srec_cat BitForce_SC-1.2.5.hex -intel -offset -0x80000000 -byte-swap 4 -o BitForce_SC-1.2.5.bin -binary
Note that UrJTAG for some reason needs the firmware with all the words flipped backward (hence the -byte-swap 4 option).
This may be a bug in the aforementioned AVR32 flash patches, and if so, I may fix it at some point.
Now plug in the TUMPA (or equivalent) and start UrJTAG.
The first thing you need to do is configure your JTAG cable.
For TUMPA, this is:
cable ft2232 vid=0x0403 pid=0x8A98
Next, configure it for the AVR32:
detect
initbus avr32 HSBU
Before you flash, you must halt the CPU:
instruction HALT
shift ir
dr 1
shift dr
shift dr
If the chip is locked (BFL seems to ship at least some this way), you must unlock it (this erases the firmware on it too):
instruction CHIP_ERASE
shift ir
Now, flash the binary:
flashmem 0 BitForce_SC-1.2.5.bin
Once this completes, you can reenable the CPU:
instruction HALT
shift ir
dr 0
shift dr
shift dr
Step 4: DebuggingOpenOCD doesn't seem to have usable AVR32 support yet.
I probably won't give this any attention myself, but feel free to contribute.
See also: