Saturday, February 3, 2018

Did a really brick my graphics card with that bios flash?

So over the holidays I got excited about cryptocurrency mining and decided to build myself an alt - coin mining rig.  This was going to be a first for me, so naturally I was going to learn a lot and make a ton of mistakes.  I might write more fully about the whole process later, but I though the most interesting thing I learned was how to recover a couple of cards that I thought I had bricked (during an attempted bios flash), and the mistakes I made to get them into that bad state.

I decided on using AMD Radeon RX 570's mainly because (1) they were available and (2) they had a  reasonable power consumption to hash ratio based on what I was reading.

So for my first cards I got 2 MSI gaming cards.  One had 4 GBs of ram and the other had 8 GBs of ram.  My windows 10 box had 2 slots and a large enough power supply to run both, as I hadn't built a rig yet I just dropped them in and started running.

I was pretty disappointed with the initial results.  I was getting ~19 MegaHash out of the 8 GB card and ~21 out of the 4 GB card.   Not to fear though, I had read you could switch the Radeon graphics driver into "Compute" mode.  This was super easy and got the 8 GB card doing ~21 MH while the 4GB card moved up to ~24MH.  I let the cards run like this for a few days as I researched ways to improve my hash rate further.

Not long after that I read about the Holy Grail for improving performance,  modding and flashing your bios.  I read all kinds of things that suggested a modded bios on a 570 might get me all the way to 30 MH.  That was a pretty big possible improvement, so I had to give it a try.  I saved my original bioses and then I tried some simple mods.   The Polaris bios editor offered some one click timing mods that involved adjusting the memory straps.  I decided I would start out with these changes.  So after modding and saving the new bioses, I flashed my cards with winatiflash.  As a final step I also patched my Radeon driver (see: https://www.youtube.com/watch?v=IAiScXPisAY) so that windows would recognize my cards after the bios flash.  I then rebooted.

OR

I should say I tried to reboot.  Instead I experienced a heart stopping nightmare as windows would not BOOT!  After I freaked out a bit and rebooted several times with the same result I tried to boot with one card at a time.   I discovered that I could actually boot with the 4GB card installed, but the video had all kinds of artifacts,  and the card wasn't recognized when I tried to run my mining software.

Well I figured at least I could re-flash this guy and get it back to the old state..  So I opened winatiflash load the old bios and flashed it.

Reboot and .... Nothing.  Same artifacts, same failure to be recognized.

What followed as a series of reboots, driver re-installs, and eventually reading about the 1 + 8 pin trick that would supposedly reset the bios on the Radeon RX 480 (see: https://forum.ethereum.org/discussion/9443/bricked-your-rx-480-due-to-bad-flash).  I was hoping this would work on the 570, so I gave it a shot.  More precisely I gave it several shots.... On both cards.   No dice.  I couldn't get anything good to happen.  So in a last ditch effort to save 2 increasingly expensive cards from the trash heap, I found an e-bay store that sold actual bios chips.  I am not practiced at soldering at all, but I had been at this in spare time for more than a week at this point.  I figured I couldn't make them less useful to me than they already were.

When I inquired as to whether this 'bios store' had chips for my cards they responded by asking me what memory type the cards had (Elplida, Samsung, etc).  I wasn't sure I remembered so I opened up the original bios for the 4GB card in a hex editor to try and see if I could figure out what type of memory was used.  As I was muddling through this, I saw something that stopped me:

 MSI_POLARIS20_D000XL_H_8GB_HYX5GQ2BALL

Wait a minute, this is the original 4GB rom.... Isn't it?  Checking the filename, I discovered that it was indeed the ROM I thought was the 4GB card, but after a moment I realized what must have happened.

Apparently I had mis-identified which card was the 4GB and which was the 8GB when I was saving and flashing the bioses.  So I had ended up swapping bioses on the two cards.  Even when I restored the 4GB card's "original" bios, I had actually been putting a 8GB card's bios on.

Well, as GI Joe said, "Knowing is half the battle".  I flashed the 4GB card with the bios I now knew to be the correct bios and rebooted.  Problem solved for that card, but I was left with one bricked card to deal with.  Since this one wouldn't boot, I wasn't sure how to proceed.

After sitting on that for a while I decided I would drop the 8 GB card into a machine running ubuntu linux 16.04.   This was the operating system I was going to use for the mining rig and I thought maybe, JUST MAYBE linux would boot with the card installed.  After all I wasn't even booting to a GUI, I was just booting to a terminal.

So on to the moment of truth.  Drop the card in, turn on the power, wait several seconds AND SUCCESS!!!!  

After a successful boot, I flashed the card successfully with the linux version of atiflash, and now both cards were mining just as well as they had before my misadventure.  Note: You have to run atiflash as root.  If you aren't running as root, atiflash simply says there are no compatible devices (or something to that effect).  The application should detect that it needs to be run as root and tell you, but instead it just behaves like you have a bricked card.  If you happen to have what you believe to be a bricked card, this isn't very heartening.


So my new rules for bios flashing are: 


  1. Never have more than one card in the machine during a bios flash
  2. Always use linux for flashing and testing flashes.


Note: I found that you don't need to do any driver patching to run a new bios on linux, which I really appreciate.