├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── gendef.py ├── gendump.py ├── parse.c └── strapmod.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | *.ko 4 | *.obj 5 | *.elf 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Libraries 12 | *.lib 13 | *.a 14 | *.la 15 | *.lo 16 | 17 | # Shared objects (inc. Windows DLLs) 18 | *.dll 19 | *.so 20 | *.so.* 21 | *.dylib 22 | 23 | # Executables 24 | *.exe 25 | *.out 26 | *.app 27 | *.i*86 28 | *.x86_64 29 | *.hex 30 | 31 | # Debug files 32 | *.dSYM/ 33 | *.su 34 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Ralph Doncaster 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | parse: parse.c strap.h strapd.c 3 | $(CC) parse.c -o $@ 4 | 5 | strapd.c: gendump.py 6 | ./gendump.py > $@ 7 | 8 | strap.h: gendef.py 9 | ./gendef.py > $@ 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # strapread 2 | AMD GCN BIOS strap reader 3 | 4 | I am no longer maintaining utilitu 5 | 6 | strapmod.py is still useful to do simple timinging optimizations. 7 | My focus for future development is runtime timing tweaking with no BIOS flashing required. 8 | My fork of amdmeminfo can be used to show timing at runtime, and will be updated to allow modifications. 9 | https://github.com/nerdralph/amdmeminfo 10 | -------------------------------------------------------------------------------- /gendef.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # generate union def given a list of members and register name 4 | def genunion(reg): 5 | name = reg.pop() 6 | print 'typedef union', '_' + name, '{' 7 | print ' u32 data;' 8 | print ' struct {' 9 | for i in reg: 10 | print ' u32', i + ';' 11 | print ' } fields;' 12 | print '}', name + ';' + '\n' 13 | 14 | genunion(['tRCDW:5', 'tRCDWA:5', 'tRCDR:5', 'tRCDRA:5', 'tRRD:4', 'tRC:7', 'SEQ_RAS_TIMING']) 15 | genunion(['tNOPW:2', 'tNOPR:2', 'tR2W:5', 'tCCDL:3', 'tR2R:4', 'tW2R:8', 'tCL:8', 'SEQ_CAS_TIMING']) 16 | genunion(['tRP_WRA:7', 'tRP_RDA:7', 'tRP:6', 'tRFC:9', 'SEQ_MISC_TIMING']) 17 | genunion(['PA2RDATA:4', 'PA2WDATA:4', 'FAW:5', 'tREDC:3', 'tWEDC:5', 't32AW:7', 'tWDATATR:4', 'SEQ_MISC_TIMING2']) 18 | genunion(['tCKSRE:4', 'tCKSRX:4', 'tCKE_PULSE:4', 'tCKE:6', 'SEQ_IDLE:5', 'tCKE_PULSE_MSB:1', 'SEQ_IDLE_SS:8', 'SEQ_PMG_TIMING']) 19 | genunion(['RAS2RAS:8', 'RP:8', 'WRPLUSRP:8', 'BUS_TURN:8', 'ARB_DRAM_TIMING2']) 20 | 21 | -------------------------------------------------------------------------------- /gendump.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # swap bytes in little-endian hex string to big endian 4 | def swapb(hex8): 5 | return hex8[6:8] + hex8[4:6] + hex8[2:4] + hex8[0:2] 6 | 7 | # generate dump function 8 | def gendump(reg, data): 9 | name = reg.pop() 10 | print ' ' + name, name + '_d = {0x' + swapb(data) + '};' 11 | print ' printf("' + name + '\\n");' 12 | for i in reg: 13 | i = i[0:-2] 14 | print ' printf("' + i + ':%d ",' + name + '_d.fields.' + i + ');' 15 | print ' printf("\\n");' 16 | 17 | # Rx470 Samsung 1500 18 | #strap = '555000000000000022CC1C00AD515A3EC0570E142D4A64080048C700030114207A8900A003000000150E2A3186272E16' 19 | # Rx470 Samsung 1625 20 | #strap = '555000000000000022CC1C00CE596B44D0570F1531CB2409004AE7000B0314207A8900A003000000170F2E36922A3217' 21 | # Rx470 Samsung 1750 22 | #strap = '777000000000000022CC1C0010626C49D0571016B50BD509004AE700140514207A8900A003000000191131399D2C3617' 23 | # Rx470 Samsung 1900 24 | #strap = '777000000000000022CC1C00106A7D4FE0571117B98CA50A004C07011C0714207A8900A0030000001B11353FAA2F3A18' 25 | # custom 1625 w RRD=5, RC=3E, FAW&32AW=0, 555->777, OK@2000 26 | #strap = '777000000000000022CC1C00CE595B3ED0570F1531CB2409004007000B0314207A8900A003000000170F2E36922A3217' 27 | # custom 1750 w RRD=5, FAW&32AW=0 28 | #strap = '777000000000000022CC1C0010625C49D0571016B50BD50900400700140514207A8900A003000000191131399D2C3617' 29 | #laik2 + RAS2RAS 150, ACTRD=16 30 | #strap = '777000000000000022CC1C00CE615C45C0571016B30CD50900400700140514207A8900A00300000010103139962C3617' 31 | # Rx470 Hynix 1500 32 | strap = '777000000000000022339D00CE516A3D9055111230CB4409004AE600740114206A8900A002003120150F292F94273116' 33 | # H1500C 34 | strap = '777000000000000022339D00CE515A3D9055111230CB440900400600740114206A8900A002003120100F292F94273116' 35 | # H1625C - MISC from 1500 36 | strap = '999000000000000022559D0010DE5B4480551312B74C450A00400600750414206A8900A00200312010112D34A42A3816' 37 | # laik2 custom Hynix 1500 38 | #strap = '777000000000000022339D00CE515A398055111230CB440900408400740114206A8900A002003120150F292F94273116' 39 | 40 | #gendump(['tCKSRE:4', 'tCKSRX:4', 'tCKE_PULSE:4', 'tCKE:6', 'SEQ_IDLE:5', 'tCKE_PULSE_MSB:1', 'SEQ_IDLE_SS:8', 'SEQ_PMG_TIMING'], strap[16:24]) 41 | gendump(['tRCDW:5', 'tRCDWA:5', 'tRCDR:5', 'tRCDRA:5', 'tRRD:4', 'tRC:7', 'SEQ_RAS_TIMING'], strap[24:32]) 42 | gendump(['tNOPW:2', 'tNOPR:2', 'tR2W:5', 'tCCDL:3', 'tR2R:4', 'tW2R:8', 'tCL:8', 'SEQ_CAS_TIMING'], strap[32:40]) 43 | gendump(['tRP_WRA:7', 'tRP_RDA:7', 'tRP:6', 'tRFC:9', 'SEQ_MISC_TIMING'], strap[40:48]) 44 | gendump(['PA2RDATA:4', 'PA2WDATA:4', 'FAW:5', 'tREDC:3', 'tWEDC:5', 't32AW:7', 'tWDATATR:4', 'SEQ_MISC_TIMING2'], strap[48:56]) 45 | gendump(['RAS2RAS:8', 'RP:8', 'WRPLUSRP:8', 'BUS_TURN:8', 'ARB_DRAM_TIMING2'], strap[88:96]) 46 | 47 | -------------------------------------------------------------------------------- /parse.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | typedef uint32_t u32; 5 | 6 | 7 | int main(void) 8 | { 9 | #include "strap.h" 10 | 11 | #include "strapd.c" 12 | } 13 | 14 | -------------------------------------------------------------------------------- /strapmod.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # modifies strap with typical timing improvements 3 | 4 | import sys 5 | 6 | strap = sys.argv[1] 7 | 8 | if strap[4] == '0': 9 | print "Rx strap detected" 10 | RAS=24 11 | else: 12 | print "R9 strap detected" 13 | RAS=16 14 | 15 | print "Old, new RRD:", strap[RAS+4], ", 5" 16 | strap = strap[:RAS+4] + '5' + strap[RAS+5:] 17 | 18 | print "Old, new FAW:", strap[RAS+27], ", 0" 19 | strap = strap[:RAS+27] + '0' + strap[RAS+28:] 20 | 21 | t32AW = int(strap[RAS+28],16)/2 + int(strap[RAS+31])*8 22 | print "Old, new 32AW:", t32AW, ", 0" 23 | strap = strap[:RAS+28] + '0' + strap[RAS+29:RAS+31] + '0' + strap[RAS+32:] 24 | 25 | print "Old, new ACTRD:", strap[80:82], ", 0x10" 26 | strap = strap[:80] + '10' + strap[82:] 27 | 28 | print sys.argv[1] 29 | print strap 30 | --------------------------------------------------------------------------------