User:GNUtoo/X60 GPU init: Difference between revisions
No edit summary |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 40: | Line 40: | ||
* http://git.stuge.se/?p=gnutoo-chromiumos-coreboot.git;a=summary : it's an historic tree, containing code that is based on the replay of the option rom, before the native GPU init worked(so it doesn't work). | * http://git.stuge.se/?p=gnutoo-chromiumos-coreboot.git;a=summary : it's an historic tree, containing code that is based on the replay of the option rom, before the native GPU init worked(so it doesn't work). | ||
* http://git.stuge.se/?p=gnutoo-i915tool-x60.git;a=summary : contains an historic version of the i915tool | * http://git.stuge.se/?p=gnutoo-i915tool-x60.git;a=summary : contains an historic version of the i915tool | ||
* http://www.gitorious.org/gnutoo-for-coreboot/coreboot/ : I pushed there the code that I useed. It was often pushed BEFORE trying it on real hardware. | |||
I often contained work on the following topics: | |||
* Native GPU init for i945 | |||
* The fallback mecanism | |||
* The removal of the microcode | |||
So I often have cherry-picked patches from gerrit and have some updated copies of some of them. | |||
The microcode removal is probably not in gerrit because it won't be accepted as-is, instead the microcodes have to be moved/removed in a cleaner way for master | |||
== Native X60 GPU init stuff == | |||
=== scripts to help getting rid of the vbios of the x60 === | |||
==== Script 1: generate the io access for the coreboot driver ==== | |||
* follow "Case study: new laptop (not complete, sorry)" in https://docs.google.com/document/d/1g8FMob25VZYxbWri2iFB8YiSL8gwF9vKJH3HGxr0xQU/edit?pli=1 | |||
* pacman -S plan9port | |||
* cp /opt/plan9/bin/ssam ./ | |||
* replace the following line in ./ssam: | |||
#!/usr/local/plan9/bin/rc | |||
by the following line: | |||
#!/opt/plan9/bin/rc | |||
* create the ssamfix file with: | |||
,s/\[ *[0-9]+\..[0-9]+\]//g | |||
,s/^ *//g | |||
y/^[RWU]/s/^/M /g | |||
,s/\nU/ ;;;UDELAY/g | |||
,|uniq -c | |||
,s/^ *//g | |||
,s/(^[0-9]+) ([MRW])/\2 \1/g | |||
,s/"/\\"/g | |||
,s/^M ([0-9]+) *(\[.*)/{M, \1, "\2"},/g | |||
,s/^M ([0-9]+) *(.*)/{M, \1, "\2"},/g | |||
,s/: */:/g | |||
,s/...UDELAY *([0-9]+)/\1/g | |||
,s/^([RW]) ([0-9]+) (.*):0x([0-9a-f]+)(.*)/{\1, \2, "", \3, 0x\4, \5},/g | |||
* run the following commands: | |||
. /etc/profile.d/plan9.sh | |||
cat dmesg| ./ssam -f ssamfix > foo.c | |||
==== Script2: compare the io access that were too fast ==== | |||
* Replace {V,0,}, with {V,7,}, in src/mainboard/vendor/device/i915io.c | |||
* cat /dev/ttyUSB0 > accesses.txt | |||
* Use that script against accesses.txt to find the guilty accesses: | |||
#!/usr/bin/env python2 | |||
import sys,re | |||
def main(args): | |||
try: | |||
f = open(args[1],'ro') | |||
except: | |||
print args[0], " <file>" | |||
for line in f: | |||
if re.match("0x[0-9]*: Got .*, expect .*",line): | |||
line = line.replace('\r\n','').replace(", expect ",':').replace(": Got ",':') | |||
split = line.split(':') | |||
#print split | |||
if split[1] != split[2]: | |||
print line | |||
if __name__ == '__main__': | |||
main(sys.argv) | |||
=== How to get semantic IOs === | |||
In i915tool: | |||
* import your IOs in prettyregs.c | |||
* compile prettyregs.c | |||
* run prettyregs | |||
=== How to get rid of the vbios of the x60 [New Version] === | |||
WARNING: DO NOT ATTEMPT TO DO THAT WITHOUT A FLASH RECOVERY MECANISM | |||
Apply the [http://review.coreboot.org/#/c/3277/ coreboot patches], and adapt them for your mainboard | |||
Then configure coreboot with: | |||
[*] Output verbose x86emu debug messages | |||
[ ] Trace JMP/RETF | |||
[ ] Trace all opcodes | |||
[ ] Log Plug&Play accesses | |||
[ ] Log Disk I/O | |||
[ ] Log PMM | |||
[ ] Debug VESA BIOS Extensions | |||
[ ] Redirect INT10 output to console | |||
[ ] Log intXX calls | |||
[ ] Log special memory accesses | |||
[ ] Log all memory accesses | |||
[*] Log IO accesses | |||
Build and flash coreboot. | |||
git clone [https://code.google.com/r/gnutoo-i915tool-x60/source/list my fork of the i915tool] until the code is merged in the [https://code.google.com/p/i915tool/ official i915tool]. | |||
Get the [http://www.coreboot.org/images/4/42/Dennis.tar.gz tarball] that contains the generated code, extract it. | |||
Also get the [http://www.coreboot.org/images/3/39/I915_reg.h.gz i915_regs.h.gz] file, decompress it and put it in final/ | |||
Then go into i915tool and apply some patches for the x60 or redo them for your mainboard. | |||
Run make: | |||
$ cd i915tool | |||
$ make | |||
Then go into the x60 directory(or the directory of your device): | |||
$ cd x60 | |||
use picocom -b 115200 /dev/ttyUSB0 or stty to set the bauds of the Serial port. | |||
Then get logs: | |||
$ cat /dev/ttyUSB0 | tee coreboot.log | |||
Then remove the binary symbols, dos2unix will help identifying where they are: | |||
$ dos2unix coreboot.log | |||
dos2unix: Binary symbol found at line 136332 | |||
dos2unix: Skipping binary file coreboot.log | |||
Then do: | |||
$ dos2unix coreboot.log | |||
Then remove the lines before and after the log, the log looks like that: | |||
[0047229e]c000:51cb outl(0x80001014, 0x0cf8) | |||
[0047325f]c000:51d4 inw(0x0cfc) = 0x50a1 | |||
Then run make and fix the errors: | |||
$ make | |||
Then copy to coreboot as it says. | |||
Then if necessary try to compact the source code a bit, here for me I have a really long list of: | |||
io_i915_write32(0xcffbe001,0x8001); | |||
io_i915_write32(0xcffbe001,0x8005); | |||
io_i915_write32(0xcffbe001,0x8009); | |||
io_i915_write32(0xcffbe001,0x800d); | |||
io_i915_write32(0xcffbe001,0x8011); | |||
That can be replaced with: | |||
int i = 0; | |||
for (i=0x8001;i<0x3fffa;i+=4){ | |||
io_i915_write32(0xcffbe001,i); | |||
} | |||
Import the final code into the chromium fork of coreboot with my patches on top. |
Latest revision as of 22:45, 17 January 2015
Native GPU init
With the native (intel) GPU initialisation, coreboot itself initialises the GPU.
Initialisation method | Free software, based on | Advantages | Drawbacks |
---|---|---|---|
non-free VGA option rom | No, extracted from the BIOS. |
|
|
Linux kernel i915 driver | Yes, in the linux kernel |
|
|
Native GPU initialisation (by coreboot) | Yes, based on a replay of the kernel initialisation |
|
|
Related historic git trees
- http://git.stuge.se/?p=gnutoo-chromiumos-coreboot.git;a=summary : it's an historic tree, containing code that is based on the replay of the option rom, before the native GPU init worked(so it doesn't work).
- http://git.stuge.se/?p=gnutoo-i915tool-x60.git;a=summary : contains an historic version of the i915tool
- http://www.gitorious.org/gnutoo-for-coreboot/coreboot/ : I pushed there the code that I useed. It was often pushed BEFORE trying it on real hardware.
I often contained work on the following topics:
- Native GPU init for i945
- The fallback mecanism
- The removal of the microcode
So I often have cherry-picked patches from gerrit and have some updated copies of some of them. The microcode removal is probably not in gerrit because it won't be accepted as-is, instead the microcodes have to be moved/removed in a cleaner way for master
Native X60 GPU init stuff
scripts to help getting rid of the vbios of the x60
Script 1: generate the io access for the coreboot driver
- follow "Case study: new laptop (not complete, sorry)" in https://docs.google.com/document/d/1g8FMob25VZYxbWri2iFB8YiSL8gwF9vKJH3HGxr0xQU/edit?pli=1
- pacman -S plan9port
- cp /opt/plan9/bin/ssam ./
- replace the following line in ./ssam:
#!/usr/local/plan9/bin/rc
by the following line:
#!/opt/plan9/bin/rc
- create the ssamfix file with:
,s/\[ *[0-9]+\..[0-9]+\]//g ,s/^ *//g y/^[RWU]/s/^/M /g ,s/\nU/ ;;;UDELAY/g ,|uniq -c ,s/^ *//g ,s/(^[0-9]+) ([MRW])/\2 \1/g ,s/"/\\"/g ,s/^M ([0-9]+) *(\[.*)/{M, \1, "\2"},/g ,s/^M ([0-9]+) *(.*)/{M, \1, "\2"},/g ,s/: */:/g ,s/...UDELAY *([0-9]+)/\1/g ,s/^([RW]) ([0-9]+) (.*):0x([0-9a-f]+)(.*)/{\1, \2, "", \3, 0x\4, \5},/g
- run the following commands:
. /etc/profile.d/plan9.sh cat dmesg| ./ssam -f ssamfix > foo.c
Script2: compare the io access that were too fast
- Replace {V,0,}, with {V,7,}, in src/mainboard/vendor/device/i915io.c
- cat /dev/ttyUSB0 > accesses.txt
- Use that script against accesses.txt to find the guilty accesses:
#!/usr/bin/env python2 import sys,re def main(args): try: f = open(args[1],'ro') except: print args[0], " <file>" for line in f: if re.match("0x[0-9]*: Got .*, expect .*",line): line = line.replace('\r\n',).replace(", expect ",':').replace(": Got ",':') split = line.split(':') #print split if split[1] != split[2]: print line if __name__ == '__main__': main(sys.argv)
How to get semantic IOs
In i915tool:
- import your IOs in prettyregs.c
- compile prettyregs.c
- run prettyregs
How to get rid of the vbios of the x60 [New Version]
WARNING: DO NOT ATTEMPT TO DO THAT WITHOUT A FLASH RECOVERY MECANISM
Apply the coreboot patches, and adapt them for your mainboard
Then configure coreboot with:
[*] Output verbose x86emu debug messages [ ] Trace JMP/RETF [ ] Trace all opcodes [ ] Log Plug&Play accesses [ ] Log Disk I/O [ ] Log PMM [ ] Debug VESA BIOS Extensions [ ] Redirect INT10 output to console [ ] Log intXX calls [ ] Log special memory accesses [ ] Log all memory accesses [*] Log IO accesses
Build and flash coreboot.
git clone my fork of the i915tool until the code is merged in the official i915tool.
Get the tarball that contains the generated code, extract it.
Also get the i915_regs.h.gz file, decompress it and put it in final/
Then go into i915tool and apply some patches for the x60 or redo them for your mainboard.
Run make:
$ cd i915tool $ make
Then go into the x60 directory(or the directory of your device):
$ cd x60
use picocom -b 115200 /dev/ttyUSB0 or stty to set the bauds of the Serial port. Then get logs:
$ cat /dev/ttyUSB0 | tee coreboot.log
Then remove the binary symbols, dos2unix will help identifying where they are:
$ dos2unix coreboot.log dos2unix: Binary symbol found at line 136332 dos2unix: Skipping binary file coreboot.log
Then do:
$ dos2unix coreboot.log
Then remove the lines before and after the log, the log looks like that:
[0047229e]c000:51cb outl(0x80001014, 0x0cf8) [0047325f]c000:51d4 inw(0x0cfc) = 0x50a1
Then run make and fix the errors:
$ make
Then copy to coreboot as it says. Then if necessary try to compact the source code a bit, here for me I have a really long list of:
io_i915_write32(0xcffbe001,0x8001); io_i915_write32(0xcffbe001,0x8005); io_i915_write32(0xcffbe001,0x8009); io_i915_write32(0xcffbe001,0x800d); io_i915_write32(0xcffbe001,0x8011);
That can be replaced with:
int i = 0; for (i=0x8001;i<0x3fffa;i+=4){ io_i915_write32(0xcffbe001,i); }
Import the final code into the chromium fork of coreboot with my patches on top.