Title: Hacking BitForce SC firmware with only free software Post by: Luke-Jr on July 25, 2013, 09:39:20 PM Ok, starting a thread here to deal with hacking on BitForce SC firmware using only free software (http://www.gnu.org/philosophy/free-sw.html).
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: Toolchain This is a pain. I'll document it later. For now, you can play with my (Gentoo-oriented) notes: Code: crossdev -t avr32 -s1 # this will fail! but sets up stuff for us Step 2: Building TODO. I haven't done this 100% yet. My BitForce_SC repository has a "make" branch (https://github.com/luke-jr/BitForce_SC/tree/make) that compiles to a .elf binary for now. Step 3: Flashing I decided to use the "TUMPA" JTAG interface (http://www.diygadget.com/jtag-cables/tiao-usb-multi-protocol-adapter-jtag-spi-i2c-serial.html) (WARNING: this shop closed almost right after I ordered, until Aug 17). There are many other options (http://urjtag.org/book/_system_requirements.html#_supported_jtag_adapters_cables) (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 (http://www.tiaowiki.com/w/TIAO_USB_Multi_Protocol_Adapter_User's_Manual#20_PIN_JTAG_Connector), and the BFL boards have a 10-pin JTAG connector (http://www.jtagtest.com/pinouts/avr), each with different pinouts (ie, you can't just match half the 20-pin with the 5-pin!) You want to connect these pins:
Next, you'll need to install a special version of UrJTAG. For some reason, they ignored AVR32 flash patches (http://www.mail-archive.com/urjtag-development@lists.sourceforge.net/msg00028.html) 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 (https://github.com/luke-jr/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 (http://luke.dashjr.org/programs/bitcoin/files/bitforce/1.2.5/BitForce_SC-1.2.5.hex) - 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: Code: srec_cat BitForce_SC-1.2.5.hex -intel -offset -0x80000000 -byte-swap 4 -o BitForce_SC-1.2.5.bin -binary 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: Code: cable ft2232 vid=0x0403 pid=0x8A98 Code: detect Before you flash, you must halt the CPU: Code: instruction HALT Code: instruction CHIP_ERASE Code: flashmem 0 BitForce_SC-1.2.5.bin Code: instruction HALT Step 4: Debugging OpenOCD 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:
Title: Re: Hacking BitForce SC firmware with only free software Post by: Flashman on July 25, 2013, 10:49:13 PM Thanks Luke, great to know it can be done with DIY tools. Now to decide which JTAG gizmo to build, I wanted something dirt cheap and easy, like a parallel port one, but word is they take forever to flash a larger ROM, would you have any experience that would allow you to comment on how long this might take to go over a parallel port JTAG?
Title: Re: Hacking BitForce SC firmware with only free software Post by: Luke-Jr on July 25, 2013, 11:27:56 PM Thanks Luke, great to know it can be done with DIY tools. Now to decide which JTAG gizmo to build, I wanted something dirt cheap and easy, like a parallel port one, but word is they take forever to flash a larger ROM, would you have any experience that would allow you to comment on how long this might take to go over a parallel port JTAG? Dunno, most PCs don't even have parports anymore.And IIRC the voltages they use vary - you don't want to use anything other than 3.3V for this! Title: Re: Hacking BitForce SC firmware with only free software Post by: tom99 on July 26, 2013, 04:06:03 AM Do you think will this jtag work http://www.seeedstudio.com/depot/bus-blaster-v4-p-1416.html?cPath=63_69
Bus Blaster v4 Title: Re: Hacking BitForce SC firmware with only free software Post by: Luke-Jr on July 26, 2013, 04:09:06 AM Do you think will this jtag work http://www.seeedstudio.com/depot/bus-blaster-v4-p-1416.html?cPath=63_69 Sounds like it.Wish I saw that one, would probably have got it instead (to support open hardware). Title: Re: Hacking BitForce SC firmware with only free software Post by: Red_Wolf_2 on August 19, 2013, 01:27:08 PM Spotted this and thought it might be interesting to work with...
https://github.com/synthetos/PiOCD/wiki/Using-a-Raspberry-Pi-as-a-JTAG-Dongle Anyone want to try it out? Title: Re: Hacking BitForce SC firmware with only free software Post by: kramble on August 19, 2013, 03:08:38 PM Spotted this and thought it might be interesting to work with... https://github.com/synthetos/PiOCD/wiki/Using-a-Raspberry-Pi-as-a-JTAG-Dongle Anyone want to try it out? I wrote this (https://github.com/kramble/DE0-Nano-BitCoin-Miner/blob/master/Programmer/prog_both.c) to program FPGAs from RasPi, its crude (sorry, not a professional programmer) but works. Unfortunately its not using JTAG, but could be adapted. The altera jrunner (https://www.altera.com/download/legacy/jrunner/dnl-jrunner.html) code is a useful starting point for JTAG. Its a bit hacky, so probably not worth following up, but I've written this now so I'll post it anyway (and its a weird coincidence that this thread was right above one on repurposing BFL FPGA rigs for litecoin,). Title: Re: Hacking BitForce SC firmware with only free software Post by: tom99 on August 19, 2013, 06:51:31 PM Bus Blaster v3 cheaper about 35usd http://www.seeedstudio.com/depot/bus-blaster-v3-p-1415.html
case about 4usd http://www.seeedstudio.com/depot/bus-blaster-v3-acrylic-case-v1-sobv1dp8049-p-1315.html?cPath=178_184 ps: free shipping order more than 50usd Title: Re: Hacking BitForce SC firmware with only free software Post by: Luke-Jr on August 19, 2013, 07:21:01 PM Looks nice, but for $10 more I'd rather use the device atmel studio expects This is the free software thread. Atmel Studio is off-topic.Title: Re: Hacking BitForce SC firmware with only free software Post by: tom99 on August 19, 2013, 07:26:28 PM Looks nice, but for $10 more I'd rather use the device atmel studio expects This is the free software thread. Atmel Studio is off-topic.+1 jtag open h/w and s/w. Title: Re: Hacking BitForce SC firmware with only free software Post by: bitpop on August 19, 2013, 07:40:23 PM Forgot deleted
Title: Re: Hacking BitForce SC firmware with only free software Post by: Red_Wolf_2 on August 23, 2013, 03:24:08 PM And I had success using the GPIO pins of my Raspberry Pi to reflash my Jalapenos, so you can get away without needing an actual JTAG dongle if you have a RPi lying around not doing much.
Full details at the URL below, and some over on the Experimenting with Jalapeno Firmware thread (or whatever its called) too http://randomcontent.wolfnexus.net/RandomSite/reflashing-a-butterfly-labs-jalapeno-with-only-a-raspberry-pi/ (http://randomcontent.wolfnexus.net/RandomSite/reflashing-a-butterfly-labs-jalapeno-with-only-a-raspberry-pi/) [URL]https://bitcointalk.org/index.php?topic=236875.0[URL] Title: Re: Hacking BitForce SC firmware with only free software Post by: stewdk on October 08, 2013, 09:31:17 PM I just wanted to report another success flashing a Jalapeno. Before flashing, it was hashing at about 5.3 GH/s, and after flashing it's up to 7.7GH/s.
I used a FT2232 based JTAG adapter that I had laying around (a EKC-LM3S6965 eval board to be exact) together with a modified floppy disk cable to convert from the 20-pin ARM JTAG pinout to the 10-pin AVR32 JTAG pinout. Luke-Jr's pinout table says to connect AVR32 JTAG pin 8 to ARMJTAG pin 3, but looking at the schematic pin 8 is N/C (SC-MainBoard-1.0-ToRelease.pdf). To get proper reset functionality via JTAG, you want to connect the signal nSRST, AVR32 pin 6 to ARMJTAG pin 15. Here's the table that I used:
On the software side, I compiled URJTAG from Luke-Jr's git repo using Cygwin on windows. To get it to compile properly, I had to install a bunch of cygwin packages, download the FTDI drivers, apply a patch from http://www.mail-archive.com/urjtag-development@lists.sourceforge.net/msg01342.html, run autogen.sh again, and run ./configure --with-ftd2xx="/cygdrive/c/CDMv2.08.30WHQLCertified/" --disable-svf --disable-bsdl Then, to get URJTAG to properly identify and work with my Jalapeno's AT32UC3A1128, I added the following line to /usr/local/share/urjtag/atmel/PARTS 0001111011100011 at32uc3a AT32UC3A1128 Other notes: I compiled my own firmware for the Jalapeno. Cygwin doesn't have the srecord package in its repositories so I used my Ubuntu machine for that particular command. Title: Re: Hacking BitForce SC firmware with only free software Post by: FalconFour on November 13, 2013, 10:50:38 AM Thanks to the info in this guide (and the UrJTAG clone), as well as several hours of Googling and debugging... I've got my Jalapeno being programmed by an Arduino right now.
I used the Arduiggler project as the basis of the programmer. Arduiggler was chosen over my Bus Pirate because of the support for it in UrJTAG - or at least, the potential thereof. My Bus Pirate promised god-honest JTAG support, but with no interface, relying only on OpenOCD which is an impossibly complicated program to try to use - and apparently the Jally's new-generation AVR32 UC3 chip isn't supported. Once I got everything to compile and talk to each other, on Ubuntu in VMware, it worked practically right off the bat. But the word "slow" could not even begin to describe how unusably slow the programming function went. Making some optimizations to both ends of the code helped with about a 2x improvement. 256 pages to program, and it's on page 109 now after nearly an hour and a half. I could probably type bits into the thing faster than it's programming. >.< So, yeah... bought one of those USB JTAG programmer sticks off eBay for $20. Now let's see if I still have a functioning Jally after this thing gets done programming... BTW, I can't seem to find much info about tweaking the firmware. I gave a good once-over through the config parameters code, but what settings are used in those "omg 8gh/s" binaries? For that matter, what about the settings of the stock Jalapeno firmware? Title: Re: Hacking BitForce SC firmware with only free software Post by: erk on December 23, 2013, 02:03:43 AM I am trying to program the BFL AT32UC3A1256 with either urjtag or avrdude.
The problem I have is my programer is a JTAGICE Mk1 clone. The Mk1 was an RS-232 device so the clones use a FTDI or in this case a CH341 USB-RS-232 converter chip to do their stuff. It's not recognized by Altmel/AVR-studio versions greater than 4.19 unforunately 4.19 doesn't support the AT32UC3A1256 chips, and later version of Atmelstudio don't support JTAGICE Mk1. You can't win! So far I haven't gotten urjtag to recognize the device either, although linux quite happily sees it on the USB port: Code: Bus 002 Device 004: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter And of course avrdude has no entry for programming the AT32UC3A1256 I feel like I am so close to flashing the jally. Any pointers on how to get urjtag working with this device would be greatly appreciated. Title: Re: Hacking BitForce SC firmware with only free software Post by: Aldur1 on January 05, 2014, 05:40:19 AM Probably A stupid question, but Have I missed something key in this process? I managed to successfully flash my Jalapeno using the RPI and Luke-Jr's URJTAG build, however now when I try and and do detect after declaring the GPIO Jtag cable i get:
Code: jtag> cable gpio tdo=9 tdi=10 tck=11 tms=25 Also since trying to connect the JTAG this time I do not get any hashrate, although my LED's on the Jalapeno indicate its booted. Any suggestions would be welcome. Thanks [UPDATE 05/01/2014] Figured it out, the connectors on my Jalapeno looked a bit grubby, co cleaned them with some electrical contact cleaner, tired again and worked first time :) |