Sunday, September 18, 2016

Advanced Tonga BIOS editing


I recently decided to spend some time to figure out some of the low-level details of how the BIOS works on my R9 380 cards.  A few months ago I had found Tonga Bios Editor, but hadn't done anything more than modify the memory frequency table so the card would default to 1500Mhz instead of 1375.  My goal was to modify the memory timing and to reduce power usage.

The card I decided to test the memory timing mods on was a Club3D 4GB R9 380 with Elpida W4032BABG-60-F RAM.  Although the RAM is rated for 6Gbps/1.5Ghz, the default memory clock is 1475Mhz.  In my previous testing I found that the card was stable with the memory overclocked well above 1.5Ghz, but the mining performance was actually slower at 1.6Ghz compared to 1.5Ghz.  Unfortunately Tonga Bios Reader does not provide a way to edit the memory timings aka straps, so I'd have to use a hex editor.


I've highlighted the 1500Mhz memory timing in the screen shot above.  I found it by searching for the string F0 49 02, which you first have to convert from little-endian to get 249F0, and then from hex to get 150,000, which is expressed in increments of .01Mhz.  The timing for up to 1625Mhz (C4 7A 02) comes after it, and then 1750Mhz (98 AB 02).  The Club3D BIOS actually has 2 sets of timings, one for memory type 01 (the number after F0 49 02), as and for memory type 02 (not shown).  This is so the same BIOS can be used on a card that can be made with different memory.  Obviously one type of memory the BIOS supports is Elpida, and from comparing BIOS images from other cards, I determined that memory type 02 is for Hynix.

To reduce the chance of bricking my card, the first time I modified only the 1625Mhz memory timing.  Since the default memory timing is 1475Mhz, my modified timing would only be used when overclocking the memory over 1500Mhz.  So if the the card crashed on the 1625Mhz timing, it would be back to the safe 1500Mhz timing after a reboot.  To actually make the change I copied the 1500Mhz timing (starting with 77 71) to the 1625Mhz timing.  After the change, the BIOS checksum is invalid, so I simply loaded the BIOS in Tonga Bios Reader and re-saved it in order to update the checksum.

I used Atiflash 2.71 to flash the BIOS since I have found no DOS or Linux flash utilities for Tonga GPUs.  After flashing the updated BIOS, I overclocked the RAM to 1625Mhz, and my eth mining speed went from just under 21Mh to about 22.5Mh.  To get even faster timings, I copied the 1375Mhz timings from a MSI R9 380 with Elpida RAM to the Club3d 1625Mhz memory timing.  That boosted my mining speed at 1625Mhz to slightly over 23Mh

I then tried a number of ways to improve the timing beyond 1625Mhz, but I found nothing that was both stable and faster at 1700Mhz.  Different cards may overclock better, depending on both the GPU asic and the memory.  Hynix memory seems to overclock a bit better than Elpida, while Samsung memory, which seems rather rare on R9 380 cards, tends to overclock the best.  The memory controller on the GPU also needs to be able overclock from 1475Mhz.  Unlike the simple voltage modding the Hawaii BIOS, there is no easy way to modify the memory controller voltage (VDDCI) on Tonga.  The ability to over-volt the memory controller would make it easier to overclock the memory speed beyond 1625Mhz.

Since the Club3D BIOS supports both Elpida and Hynix memory, I improved the timing for both memory types.  This allows me to use a single BIOS image for cards that have either Elpida or Hynix memory.  It's also dependent on the card having a NCP81022 voltage controller, but all my R9 380 cards have the same voltage controller.  I've shared it on my google drive as 380NR.ROM if you want to try it (at the possible risk of bricking your card).  Atiflash checks the subsystem ID of the target card against the BIOS to be flashed, so it is necessary to use the command-line version of atiflash with the "-fs" option:
atiflash -p 0 380RN.ROM -fs

In addition to improving memory speeds, I wanted to reduce power usage of my 380 cards.  On Windows it is possible to use a tool like MSI Afterburner to reduce the core voltage (VDDC), but on Linux there is no similar tool.  To reduce the voltage in the BIOS, modify value0 in Voltage Table2 for the different DPM states.  After a lot of experimenting, I made two different BIOSes with different voltage levels since some cards under-volt better than others.  The first one has 975, 1050, and 1100 mV for dpm 5, 6, & 7, while the other has 1025, 1100, & 1150 mV.  These are also shared on my google drive as 380NR1100.ROM and 380NR1150.ROM.

With the faster RAM timing and voltage modifications I've improved my eth mining hashrates by about 10%, without any material change in power use.  I've tried my custom ROM on four different cards.  Although two of them seem to be OK with 900/1650Mhz clocks, I'm playing it safe and running all four at 885/1625Mhz.  If you are lucky and have a card that is stable at 925/1700Mhz, you can mine eth at almost 25Mh/s.  With most cards you can expect to get between 23 and 24Mh/s.

2021-09 Update

I no longer recommend BIOS modifications, as runtime modification of GPU settings is much safer.  For the past few years I have been using tools like UMR and ROCm-SMI.  For people who still wish to access my BIOS mod files for educational reasons, Google has changed shared drive links, so this is the new link.


76 comments:

  1. Hi,
    i got Sapphire Nitro R9 380 Which has Elpida memory, can i flash you modified rom on this card without bricking it or should i dump the bios from it and do the same modifications as you do ?

    By the way thanks for the guide i was looking for a way to modify the straps:)

    ReplyDelete
    Replies
    1. The safest route is to modify your own BIOS, but as long as it has a NCP81022 regulator, I'm confident my BIOS will work. If you click on the i (information) button in MSI Afterburner it will tell you what kind of regulator your card has. HWinfo64 will also show you the regulator.
      I was a little nervous when I tried it on my MSI card, but I did have a back-up plan to fix the flash if I had bricked it to the point where it doesn't detect even as a secondary video card. The card has no backplate, and the W25X20 flash chip is visible on the back of the PCB. With flashrom (flashrom.org) I'd be able to re-flash it with an external programmer.

      Delete
    2. p.s. if you decide to modify your BIOS, check if it has a 1375Mhz timing record, and copy that instead of the one for 1500 for a little bit faster timings. For 380NR.ROM I found 1375Mhz straps for Elpida and Hynix from other ROMs, and copied them to the 1500, 1625, and 1750Mhz straps in what was originally the Club3D ROM.

      Delete
  2. i cannot find any info about NCP81022 on both msi afterburner and hwinfo64 but my card is identical to this
    cxzoid.blogspot.com/2015/08/sapphire-r9-380-nitro-review.html

    i will remove the card from the system and check it manually

    ReplyDelete
    Replies
    1. When you click the 'i' on afterburner, you should get some information that includes a line like this:
      "VDDC controller : NCP81022 on I2C bus 6, device 20h"

      Delete
  3. Hi,
    I have an ASUS R9 380 Strix. Can I try this bios mod on the GPU? It seems that ASUS has locked the voltage tweak on this card, as well as the overclocking features.

    ReplyDelete
    Replies
    1. What does MSI afterburner show for your VDDC controller?

      Delete
    2. When I click on the letter "i" in MSI afterburner, it does not show the VDDC controller. It only shows the Display device, display driver, bios, etc...

      Where can I find it in HWiNFO?

      Delete
    3. Look in the sensors data, below the GPU info.
      But if it's not showing in afterburner, I'm guessing it's not a NCP81022 on your card.

      Delete
    4. Did some more research on the ASUS cards, and they seem use a custom "Digi+" VRM chip.

      Delete
    5. I too have an Asus R9 380 Strix with Elpida memory. Received this message in Hive OS when trying to flash any of the 380NR roms : ROM file size is only 131072 bytes, there is something wrong with it, skipping... Has anyone found a rom for our Asus R9 380 Strix cards? Thanks

      Delete
  4. Thanks for posting these roms! The 1150 works great with 3/4 of my xfx 380x cards. The fourth had trouble with these roms - as soon as there was a load on the gpu I would get a black screen. Any ideas on what I can do to get that card stable?

    ReplyDelete
    Replies
    1. I think the DPM5 voltage is a bit too low. I think I'll bump it up another 25mV and re-upload it.
      For now you can go with 380NR.ROM, which doesn't do any under-volting.
      I'm also pleasantly surprised they work on 380x cards too.

      Delete
    2. dear sir...
      when I check 380x, I found out in gpuz that 380x have 2048 shader, while 380 got 17xx shader... and funny thing when I flash 380x rom to 380, the shader still 17xx, but when I flash 380 rom to 380x, the shader of 380x going down to 380 so its 17xx...
      do you have the mod for 380x rom ? I imagine the extra shader in 380x will help raise the hashrate a bit...

      Delete
  5. Hey Nerd Ralf, thank you so much for this guide and sharing, I wanted to ask you about recovering an undiscoverable device by atiflash, I have read about in circuit programming, however I'm a Psychology student, so I don't know much about what devices can be use to do some reflash a bricked un recognizable gpu. If you could point me towards one device, and maybe some info that will be great, I have being modding some gpus, but I'll feel so much better if im prepared for the worst case scenario

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. Also I found this video and it seems to be way easier and cheaper than reprogramming,maybe there are some microclamps that could be use to set to stick the cable to the pin 1 and 8 on the flash chip and you could set a toggle switch? what do you think?
      https://www.youtube.com/watch?v=eYm2BjagCP8

      Delete
    3. I have a SOIC clip like this one:
      https://www.sparkfun.com/products/13153
      I also have a hot air gun, so if I were to brick a card so that it was no longer detectable, I'd remove it and use the SOIC clip to re-flash it. Then I'd solder it back to the video card.
      While a number of people seem to have luck holding Chip Select high by connecting it to VCC, that could be bad for your card. That is because CS is brought low by another chip, and depending on the output low impedance of that chip, it may be exposed to much higher currents than it is rated for when connected to VCC.

      Delete
    4. Hey man thank you for sharing, I wanted do ask you if after using your 380nr.rom you still can connect a a monitor to that card, cause even when they mine fully stable at 24.5mhs( something like 800/1750) if I plug a monitor the pc turns on, but hangs after entering windows, I partially solved using the integrated vga, however if I do that for some reason claymore, speed fan and afterburner, all lose the ability to see the gpu Temps and to control the fans...

      Delete
    5. When I flash and test the cards I use them as the primary card in a Windoze box. If it hangs I drop the clock back. When it runs stable for a few hours, I switch it to one of my Linux mining rigs.
      Based on some discussion in bitcointalk, and some testing with my IR camera, RAM cooling seems to be an important factor. The MSI Armor 2x cards don't have heatsinks for the RAM, and a few of the RAM chips are positioned so they get hardly any airflow from the fans. For those cards 1625Mhz is about as high as I can push the RAM without getting any crashes after mining for hours/days.
      I have one MSI R9 380 gaming card that has heat spreader plates on the RAM, and that one is stable at 1700Mhz.

      Delete
  6. hi Ralph,
    how can we set the default clock speeds to 885/1625 or something similar without needing the 3rd party utilities.

    ReplyDelete
    Replies
    1. Personally I like the flexibility of modifying the frequency in software with aticonfig. You can change the top DPM state for the BIOS GPU & Mem tables, such as changing 1375 to 1625. I would not do that unless you've tested the card and confirmed it is stable at your chosen frequency.

      Delete
  7. This comment has been removed by a blog administrator.

    ReplyDelete
  8. Hi.
    I have a PCS+ R9 380 and the idle clock is 755 core / 1475 mem.

    I was using a windows registry fix to solve the "problem", but I'm getting some black screens and PC freezes in some low usage things like youtube (firefox). Gamming is fine.


    Flashing it with the BIOS from TechPowerUp can fix the high idle clock?

    ReplyDelete
    Replies
    1. That doesn't seem to be relevant to Tonga BIOS editing.

      Delete
  9. Thanks for much for these roms. Can you make some with some lower voltages?

    ReplyDelete
  10. This comment has been removed by the author.

    ReplyDelete
  11. Hi NerdRalph, firstly thank you for sharing your work.

    It looks like there hasn't been a lot of activity here for many months so I'm hoping you still check this occasionally...

    Anyway - I have two fo the MSI Gaming 4GB R9 380's that sound like the one you mentioned above, which have a backplate. I've never ROM flashed any of my mining cards before and it makes me nervous, but what the hell right? I have mostly 290s in my rigs. I have been running the 380s at core 820 mem 1500 for many months and getting 20-21mh/s out of them.

    What I'm wondering is this: is it worth the risk of doing this for just 2 cards? I'm guessing I may get 24-25mh/s out of them if I'm lucky but then I might brick one or both of them too right? Gven that I know very little about manually editing a GPU BIOS - I would probably just try one of yours. Which one are you using, or would recommend the MSI Gaming 4GB R9 380?

    ReplyDelete
    Replies
    1. The MSI R9 380 gaming card I had was 2GB with Samsung RAM. I sold it shortly after that stopped being enough for Eth mining. Before trying one of my custom BIOS files, make sure the card has Hynix or Elpida RAM. If it is Samsung, you'll need to do your own BIOS mod.

      Delete
  12. This comment has been removed by the author.

    ReplyDelete
  13. Hi Nerdralph, Both my MSI gaming 4GB cards are Elpida RAM. Are you saying that your ROMS should still be OK, even though they were for 2GB cards?

    ReplyDelete
    Replies
    1. The BIOS images are for 4GB cards, and should work with all 4GB R9 380s with either Hynix or Elpida RAM and that use the NCP81022 VRM.

      Delete
    2. Hi Ralph! Thanks for shareing your experience for free...
      Can I use your roms if I have Sapphire Nitro R9 380X WITH 4GB ELPIA? Thanks..

      Delete
  14. Hi Ralph,

    I found on your google drive https://drive.google.com/drive/folders/0BwLnDyLLT3WkRUQ4VU5kVm5qM0k 3 versions of the bios for the 380.

    Could you tell me wich one should be the best for a sapphire Nitro 4G 1010Mhz (elpida) http://www.sapphiretech.com/productdetial.asp?pid=37BE40BB-7273-46B8-9E32-A8C13262ABE9&lang=eng

    thanks in advance

    Rollingboy

    ReplyDelete
    Replies
    1. RTFM:
      To reduce the voltage in the BIOS, modify value0 in Voltage Table2 for the different DPM states. After a lot of experimenting, I made two different BIOSes with different voltage levels since some cards under-volt better than others. The first one has 975, 1050, and 1100 mV for dpm 5, 6, & 7, while the other has 1025, 1100, & 1150 mV. These are also shared on my google drive as 380NR1100.ROM and 380NR1150.ROM.

      Delete
  15. cannot you do a tutorial in how to do undervoltage! I managed to do the strapping myself :)but I would happely optimize further since I got an Asus card without the controller.

    ReplyDelete
    Replies
    1. See my previous comments on how to set the BIOS voltage for different DPM states.

      Delete
  16. Hello Ralph,

    Can you point me exactly how can I underclock/undervolt to 930/1650 -30mV? My cards seems to be stable in Afterburner but I want them with that BIOS.

    Regards,

    ReplyDelete
    Replies
    1. You're asking about setting a voltage offset in the BIOS, which I have not tried (because it's a lot more complicated).

      Delete
  17. Hello Ralph,

    I have an XFX R9 380X with the bios (https://drive.google.com/open?id=0B4ceh15grRjMLUVuc1Zwa1RCTGs).
    You explain very well how to overclock RAM, but I don't understand how the heck to undervolt my card.
    I have all the time in the world but there are so many DPMs and values that could be changed and I don't know where to start. I'm getting 21.3MH/s on Ethereum but at a toasty 81ºC while my room temperature goes up to 29ºC.

    Could you send me a picture of what values should I change to undervolt the GPU and OC the memory?

    ReplyDelete
    Replies
    1. I also have a Sapphire R9 380X hashing at 21.5 stock and i tried Ralphs Bios. But i guess they are made for 380's not the X version. After the bios mod i was getting 19 Mhs when i upped the memory clock i only got 8 mhs.

      I noticed that when dual mining my cards get very hot and particals start appearing on screen.

      Ralph - any possibility of modding our 380X bios??

      Delete
    2. Nut i must say Thank you Ralph. I loaded you bios on one of my Powercollour 380's and it went from 19.8 mhs to 22.8mhs. 950/1650 clocks

      Delete
    3. My R9 380 PowerColor makes 20 mh / s at 96 degrees celsius. With bios mod you can reduce the temperature?

      Delete
    4. Edit DPM value0 5, 6, 7 to lower values, Ignore the big number and type voltage you want in mv
      Actual voltage will be lower - my values for value0 dpm5 6 7 are 930 950 975 FOR 920Mhz core clock and it seems to give me about 925mv in gpuz stable. Experiment with these values for your desired frequency. Also power usage dropped from 220W to 155W (whole system) while GPUz reports 43W. I could have gone lower but got tired of bios flashing.

      Delete
  18. I don't know how can i edite my bios could you please help me edite my r9 380 bios ?

    ReplyDelete
  19. Ralph hello.
    I have 4 cards power color r9 380 with Elpida memory.
    The controller VDDC NCP81022 on the I2C bus 6, the device 20h.
    When Etherium is mined, even with the default timings in msiautoburner, same card falls off at 0.000 Mh / s after a while.
    Default timings for my cards: core clock 980, memory clock: 1475, Temp. limit: 100, Power limit: 0.
    When I try to increase timings core clock and memory clock and power limit, the card falls off even more often.
    In msiauburner the parameter coreVoltage disabled. This parameter can not be changed.
    What do I need and how to improve the situation?
    Which of your firmware files do I use for my cards to increase the hashrait and make the work stable?

    ReplyDelete
    Replies
    1. A custom BIOS is not a fix for a flaky card.

      Delete
    2. I can try for flash your custom BIOS 380NR.ROM or 380NR1100.ROM on my video card POWER COLOR R9 380 with Elpida memory and controller VDDC NCP81022?
      P.S. Memory clock default at my cards 1475 Mhz

      Delete
    3. P.S.
      P.S. My cards are not broken. When I try to overclock 4 cards increasing timings of the core and memory, one of them drop off after some time and restart pool

      Delete
  20. dear sir...
    I got 2 380 and already flash them... i flash using 380NR.ROM.. but i cannot get up to 23MHS.. the most i got only 19-20MHS.. i am using win10... and stratum mode of genoil and claymore... do i make any mistake? using latest radeon driver... 980/1625... my memory is elpida for both card...
    what should i do to hit 23MHS ?

    ReplyDelete
    Replies
    1. In my opinion it's a mistake for anyone to use Windoze for mining.

      Delete
    2. To hit 23mhz we need to use linux?

      Delete
  21. Hi, I recently found a totally new rx380 gigabyte 4gb in a shop in a town and decided to buy it I would like to know if any of your bios mod works for my card, now the card gives 20mh/s could you help me to rise it, i hace hinix memories

    ReplyDelete
  22. i have gpu asus strix r9 380 with memory elpida, what rom should i use ?

    ReplyDelete
    Replies
    1. I think Asus strix cards use a custom voltage regulator, so non of the ROMs I have posted will work. You'll have to customize it yourself.

      Delete
  23. Hi Ralph, Thanks for doing this.
    I'm struggling to find out my VDDC Controller information.
    I've got a Sapphire Nitro R9 380 4G with GPU Tonga & GDDR5 Hynix.
    I've tried MSI Afterburner, GPU-Z and HWinfo, still can't get my hand on the VDDC.
    Any advice on how to find it?
    Otherwise, could I apply any of your modded bios?
    Currently running 20.2Mh/s from the box with no overclock on windows 10.
    Thanks

    ReplyDelete
  24. Hello, I have a Sapphire Nitro 380 with SAMSUNG memory. I'm looking for 1375 straps, I don't have this timing on my bios, anyone who can help me? Thanks a lot for the guide btw!

    ReplyDelete
  25. hi, is this step would work in gigabyte r9 285 cards? some people said that r9 285 is the same with r9 380. and the specs are completely same, except for memory which r9 285 had smaller memory than r9 380

    ReplyDelete
    Replies
    1. It probably would work. I just checked, and in Linux, lspci identifies my R9 280 cards as, "Radeon R9 285/380"

      Delete
  26. Hi Ralph. Your post and knowledge have been really helpful. Thanks. I ended with a R9 380 with Samsung memory and certainly overclocks really nice (no problem getting north of 1600 on default voltage) but the clock speed didnt make any difference in mining, i found a sweet spot at 1000/1500 but i'm stuck at 19 Mh/sec, i don't know if the drivers are pulling me (like they do with Fiji) or if it's just the memory timing with Samsung. Any thoughts?

    ReplyDelete
    Replies
    1. It's something I've mentioned a couple times in bitcointalk, and maybe even in one of my blog posts. For GCN devices like Tonga & Polaris, the core clock needs to be a minimum of 1/2 the memory clock. Because of the L2 cache architecture, anything below 50% of the memory clock means the GPU can't keep up with the memory. For ethash, I've found the sweet spot to be 55-56% of the memory clock. That means with a 1625Mhz memory clock, the optimal core clock on a Tonga card is 900-910Mhz.

      Delete
  27. Hi Ralph, Just come to say thanks for sharing the information and your rom. Wish you all the best.

    ReplyDelete
  28. Hi Ralph, dont know if your still around, hopefully your looking for some help modify my straps struggling to find them in the hex editor

    ReplyDelete
    Replies
    1. It's been a couple years since I've done any GPU hacking. I'm mostly working on embedded stuff now.

      Delete
  29. Hi Ralph, thanks for sharing so much info about your ROM´s... And sure I´m here because I have a problem... When trying to flash any od your rom´s at my PCY R9 380 it says that the rom have the "wrong size". Can I have a word from you? Thanks

    ReplyDelete
    Replies
    1. My guess is your card has a smaller flash chip. The MSI and Gigabyte cards I worked with had 2Mbit flash chips, but I think it is possible to make a BIOS image that fits in 1Mbit.

      Delete
  30. Hello Ralph. First of all, congratulations for sharing your acknowledgement. Today, I was trying to overvolt my Gigabyte R9 380X. I can do it with an old version of Sapphire Trixx. Sapphire Trixx allowed me to overvolt by 40mv, which is enough for me. Unfortunately, I can't change the clocks. I have to use MSI AB and Trixx at the same time. So, I'll try to modify my bios. There are tables. The first one with 7 states, and the last works with 1150mv. The second table with 8 states, and DPM7 works with 1068mv. I think DPM7, of the Table 2, is what I'm looking for. Is it right? If I add 50mv to 1068mv, this will work? What about 62588 value? Do I need to change it? Thank you, Ralph. :)

    ReplyDelete
    Replies
    1. I no longer recommend BIOS editing, as there are tools like ROCm-smi to modify settings at runtime. I may update the post with more details on such techniques later this year.

      Delete
  31. Hy Ralph,
    I have a problem with a card with Tonga Bios , S7150x2 can pls help me i am using hiveos

    ReplyDelete
  32. Many thanks on the update my friend! Looking to that new update on your new techniques! Glad you're here!!!

    ReplyDelete
  33. Hi unknown, I have cca 500pcs of Tonga S7150x2 hashing about 45MH per card (2x 22.5MH) with following settings
    Core 850MHz
    Memory 1600MHz
    Voltage 900mV
    with those settings cards shows about 60-70w (under 80W hard limit) and runs very very cool (inside specjal housing).
    I mod their bios with instructions from this thread ( many thanks to Ralph) and in the end I used 1250Mz straps all the way up (until 1750). Those straps give about extra 3MH per card with settings I posted above. If you have AMD original S7150X2 I can post bios file. I am sure S7150x2 can run at least 55MH but I still did not find way to unlock power likit in BIOS from 80W.

    ReplyDelete
    Replies
    1. Hi, I have several dozen s7150 cards. Have you checked the voltage in the wall? For me it is 50% more than shown by Hiveos and this is a problem. I am trying to reduce power to increase profitability. If you are interested, we can exchange the effects of settings / bios modifications. Greetings

      Delete
    2. Dear Nikola, are You able to share Your modded BIOS for s7150x2 ? I'm still trying to lower the power consumption for this card and I'm no satisfied. Thanks in advance

      Delete
  34. Hey, i have a question, what if the max clock speed is set the base 1200 MHz GPU clock speed but you set the frequency table of max GPU clock to 1300 MHz? Would that cause the card to not go higher than 1200 MHz or the limit is just there for software like MSI afterburner?

    ReplyDelete