Difference between revisions of "VGA support"

From coreboot
Jump to: navigation, search
m
(Extracting from the system (if everything else fails))
(39 intermediate revisions by 8 users not shown)
Line 1: Line 1:
There are two kinds of VGA devices
+
== VGA initialization in coreboot ==
    1. onboard vga
+
    2. addon card.
+
  
You need to enable two CONFIG options in your Mainboard Option.lb
+
Since coreboot v4 you can configure VGA initialization in Kconfig. For older versions of coreboot check the history of this page.
    #VGA Console
+
    option CONFIG_CONSOLE_VGA=1
+
    option CONFIG_PCI_ROM_RUN=1
+
  
CONFIG_PCI_ROM_RUN will use the embedded x86 emulator to run the BIOS image in the expansion ROM of a PCI device.
+
First do:
CONFIG_CONSOLE_VGA will redirect console messages to the VGA screen once VGA card is initialized.
+
  
For addon VGA cards, you don't have to do anything else besides these two CONFIG options.
+
<source lang="bash">
If your mainboard has an onboard VGA chip and you insert another VGA addon card, the addon
+
$ make menuconfig
VGA card will be used instead of the onboard VGA chip.
+
</source>
  
If you want to use the onboard VGA chip, you have to add the following options in addition to the CONFIG options described above.
+
Then go
 +
    Chipset  --->
 +
      [*] Setup bridges on path to VGA adapter
 +
      [*] Run VGA option ROMs
 +
      Option ROM execution type (Native mode)  --->
  
1. In the mainboard Config.lb (./src/mainboard/<mfg>/<board>/Config.lb) You need to specify for your onboard VGA
+
Alternatively you can choose the "Secure mode" to run the VGA option rom in a contained environment.
device pci 9.0 on  # PCI
+
        chip drivers/pci/onboard
+
                device pci 9.0 on end
+
                register "rom_address" = "0xfff80000" #512k image
+
                #register "rom_address" = "0xfff00000" #1M image
+
        end
+
end
+
  
Please make sure the device number is correct. Otherwise it the config code can not compute the proper ROM address.
+
If you have no on-board graphics, you are done configuring coreboot at this point. You may exit configuration, and run make to get your VGA enabled coreboot image.
  
2. You still need to modify your target Config.lb.
+
=== On-board Video Devices ===
in normal section
+
  
      romimage "normal"
+
If you run coreboot on a system with on-board graphics, you have to embed a VGA  on the top level, enter the file name of your option rom and the PCI ID of the associated graphics device in the form <vendor_id>,<device_id>:
      #      48K for SCSI FW or ATI ROM
+
      option ROM_SIZE = 475136
+
  
It will leave space for vga option rom in flash.
+
    VGA BIOS  --->
 +
    [*] Add a VGA BIOS image
 +
    (oprom-0.rom) VGA BIOS path and filename
 +
    (8086,27a2) VGA device PCI IDs
  
3. So at last for your linuxbios.rom, you should do
+
That's it, exit configuration, and run make to get your VGA enabled coreboot image.
      cat atix.rom linuxbios.rom > final_linuxbios.rom
+
  
you need to make sure the final_linuxbios.rom size is 512k or 1M.
+
== How to retrieve a good video bios ==
  
please use dd to get you atix.rom when running Normal BIOS.
+
=== RECOMMENDED: Extracting from your vendor bios image ===
  
===== How to retrieve a good video bios =====
+
The recommended method is to take your mainboard vendor's BIOS image and extract the VGA BIOS using a tool called [http://cgit.freedesktop.org/~libv/bios_extract bios_extract].
There are sites that have video bios roms on their website. (I know of this one for nvidia cards: [http://whitebunny.demon.nl/hardware/chipset_nvidia.html])
+
  
However you should be able to retrieve your own video bios as well with linux.
+
This is the most reliable way:
* Boot up a machine with a commercial bios (not linux bios) with the video card you wish to work under linux bios.
+
* You are guaranteed to get an image that fits to your onboard VGA
* From the command line enter:<br /><code>dd if=/dev/mem of=vgabios.bin skip=1536 count=128 or <br />dd if=/dev/mem of=vgabios.bin bs=1k count=64 skip=768<br />This assumes you card's bios is cached at 0xc0000, and is 64K long.  You<br />can see where and how much your card's bios is using by<br />doing a cat iomem | grep "Video ROM"<br /></code>
+
* Even if your VGA BIOS uses self-modifying code you get a correct image
** dd Explained (man dd to learn more):
+
***  if is the location to retrieve from.
+
***  of is the output file (your rom image)
+
***  skip jumps n blocks where the default n is 512 bytes
+
***  count is how many blocks you wish to read
+
***  bs is the block size
+
* You now have a video bios image
+
  
===== Perl script to dump out your video bios =====
+
Decompress your rom image with:
 +
<script lang="bash">
 +
$ ./bios_extract hdmag217.rom
 +
</script>
  
This is a simple script that computes the size and offset then uses
+
If bios_decode fails with a message like
the command dd to dump your video bios to a file.
+
Using file "hdmag217.rom" (513kB)
 +
Found Phoenix BIOS "Phoenix ServerBIOS 3 Release 6.0    "
 +
Version "DEVEL4E0", created on 03/20/06 at 14:37:39.
 +
Error: Invalid module signature at 0x80581
  
  #!/usr/bin/perl
+
then you have to cut the flash chip description off the image. In this case the BIOS image is 512KB, so you do
 +
  $ dd if=hdmag217.rom of=hdma.rom bs=512k count=1
 +
1+0 records in
 +
1+0 records out
 +
524288 bytes transferred in 0.000883 secs (593688784 bytes/sec)
 +
 
 +
 
 +
You will get an output similar to this:
 +
 
 +
Using file "hdma.rom" (512kB)
 +
Found Phoenix BIOS "Phoenix ServerBIOS 3 Release 6.0    "
 +
Version "DEVEL4E0", created on 03/20/06 at 14:37:39.
 +
0x715FC ( 27134 bytes)  ->  romexec_0.rom
 +
0x6E1CB ( 13338 bytes)  ->  strings_0.rom (29401 bytes)
 +
0x6D65D (  2899 bytes)  ->  display_0.rom (4128 bytes)
 +
0x6B62E (  8208 bytes)  ->  update_0.rom
 +
0x6B1E3 (  1072 bytes)  ->  decompcode_0.rom [0x5000:0xB6D0]
 +
0x6564F ( 23421 bytes)  ->  oprom_0.rom (36864 bytes)
 +
0x65608 (    44 bytes)  ->  tcpa_H_0.rom (32 bytes)
 +
0x65592 (    91 bytes)  ->  acpi_1.rom (116 bytes)
 +
0x65519 (    94 bytes)  ->  acpi_2.rom (244 bytes)
 +
0x654ED (    13 bytes)  ->  tcpa_*_0.rom
 +
0x64D4F (  1927 bytes)  ->  bioscode_0.rom (31382 bytes) [0xF000:0x856A]
 +
0x60020 ( 19728 bytes)  ->  romexec_1.rom
 +
0x570D9 ( 36656 bytes)  ->  oprom_1.rom (61440 bytes)
 +
0x4DB9D ( 38177 bytes)  ->  oprom_2.rom (63488 bytes)
 +
0x46493 ( 30447 bytes)  ->  oprom_3.rom (65536 bytes)
 +
0x41DAB ( 18125 bytes)  ->  logo_0.rom (310162 bytes)
 +
0x39CA5 ( 25439 bytes)  ->  oprom_4.rom (51200 bytes)
 +
0x36005 ( 15493 bytes)  ->  setup_0.rom (37682 bytes)
 +
0x325D7 ( 14867 bytes)  ->  template_0.rom (37728 bytes)
 +
0x2FA36 ( 11142 bytes)  ->  miser_0.rom (16208 bytes)
 +
0x2E63C (  5087 bytes)  ->  tcpa_Q_0.rom (16096 bytes)
 +
0x2D7C3 (  3678 bytes)  ->  acpi_0.rom (10464 bytes)
 +
0x1FA2A ( 41023 bytes)  ->  bioscode_1.rom (56080 bytes) [0xE000:0x40F0]
 +
0x14FE0 ( 43567 bytes)  ->  bioscode_2.rom (62416 bytes) [0x6000:0xCC30]
 +
0x0EB4C ( 25721 bytes)  ->  bioscode_3.rom (36976 bytes) [0x6000:0x3BC0]
 +
0x0D0A0 (  6801 bytes)  ->  bioscode_4.rom (31856 bytes) [0x5000:0xBF50]
 +
 
 +
Now you can check the option roms (oprom_?.rom) with the tool romheaders which is part of the [http://openbios.info/FCode_Suite FCode Suite]:
 +
 
 +
$ romheaders oprom_0.rom
 
   
 
   
  ($range, $info) = split /:/, `grep "Video ROM" /proc/iomem`;
+
  Image 1:
  ($start, $end) = split /-/, $range;
+
  PCI Expansion ROM Header:
 +
  Signature: 0x55aa (Ok)
 +
  CPU unique data: 0x48 0xeb 0x7b 0x01 0x76 0x00 0x00 0x00
 +
                    0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
 +
  Pointer to PCI Data Structure: 0x017c
 
   
 
   
  if( $start eq "" ) {
+
  PCI Data Structure:
        print "Couldn't find Video ROM in /proc/iomem\n";
+
  Signature: 0x50434952 'PCIR' (Ok)
        exit;
+
  Vendor ID: 0x1002
  }
+
  Device ID: 0x4752
 +
  Vital Product Data: 0x0000
 +
  PCI Data Structure Length: 0x0018 (24 bytes)
 +
  PCI Data Structure Revision: 0x00
 +
  Class Code: 0x030000 (VGA Display controller)
 +
  Image Length: 0x0048 blocks (36864 bytes)
 +
  Revision Level of Code/Data: 0x0421
 +
  Code Type: 0x00 (Intel x86)
 +
  Last-Image Flag: 0x80 (last image in rom)
 +
  Reserved: 0x0000
 
   
 
   
  $offset = hex "0x$start";
+
  Platform specific data for x86 compliant option rom:
$tmp = hex "0x$end";
+
  Initialization Size: 0x48 (36864 bytes)
$size = 1 + $tmp - $offset;
+
  Entry point for INIT function: 0x80
+
 
$command = "dd if=/dev/mem of=saved_vgabios.bin bs=1c count=$size skip=$offset";
+
Congratulations, that's your option rom (compare PCI IDs and Class Code to find it among the option roms).
print "range = $range, start = $start, size = $size\n";
+
 
print "$command\n";
+
=== Downloading ===
system $command;
+
 
 +
There are sites that have video bios roms on their website. (I know of this one for nvidia cards: [http://whitebunny.demon.nl/hardware/chipset_nvidia.html])
 +
 
 +
For Intel onboard graphics you can download the vbios(vga bios) from Intel's download section. The vbios is included with some versions of the graphics driver. The summary will say something like "NOTE:These materials are intended for use by developers.Includes VBIOS". The actual vbios file is the *.dat file included with the graphics driver.
 +
 
 +
=== Extracting from the system (if everything else fails) ===
 +
 
 +
However you might be able to retrieve your on-board video bios with Linux as well.
 +
 
 +
* Boot up a machine with a commercial bios (not coreboot) with the video card you wish to work under coreboot.
 +
* You can see where and how much your card's bios is using by doing a
 +
<source lang="bash">cat /proc/iomem | grep 'Video ROM'</source>
 +
* From the command line enter:<br /><source lang="bash">dd if=/dev/mem of=vgabios.bin bs=1k count=64 skip=768</source> This assumes you card's bios is cached at 0xc0000, and is 64K long.
 +
<br /><source lang="bash">dd if=/dev/mem of=video.bios.bin.4 bs=65536 count=1 skip=12</source>
 +
This works for many of the VIA Epia boards.<br>
 +
Alternatively you can automatically generate it using this nice script from Peter Stuge:<br />
 +
<source lang="bash">
 +
cat /proc/iomem | grep 'Video ROM' | (read m; m=${m/ :*}; s=${m/-*}; e=${m/*-}; \
 +
dd if=/dev/mem of=vgabios.bin bs=1c skip=$[0x$s] count=$[$[0x$e]-$[0x$s]+1])
 +
</source>
 +
* You now have a video bios image

Revision as of 21:04, 29 July 2011

VGA initialization in coreboot

Since coreboot v4 you can configure VGA initialization in Kconfig. For older versions of coreboot check the history of this page.

First do:

 $ make menuconfig

Then go

    Chipset  --->
     [*] Setup bridges on path to VGA adapter 
     [*] Run VGA option ROMs
     Option ROM execution type (Native mode)  --->

Alternatively you can choose the "Secure mode" to run the VGA option rom in a contained environment.

If you have no on-board graphics, you are done configuring coreboot at this point. You may exit configuration, and run make to get your VGA enabled coreboot image.

On-board Video Devices

If you run coreboot on a system with on-board graphics, you have to embed a VGA on the top level, enter the file name of your option rom and the PCI ID of the associated graphics device in the form <vendor_id>,<device_id>:

   VGA BIOS  --->
    [*] Add a VGA BIOS image
    (oprom-0.rom) VGA BIOS path and filename
    (8086,27a2) VGA device PCI IDs

That's it, exit configuration, and run make to get your VGA enabled coreboot image.

How to retrieve a good video bios

RECOMMENDED: Extracting from your vendor bios image

The recommended method is to take your mainboard vendor's BIOS image and extract the VGA BIOS using a tool called bios_extract.

This is the most reliable way:

  • You are guaranteed to get an image that fits to your onboard VGA
  • Even if your VGA BIOS uses self-modifying code you get a correct image

Decompress your rom image with: <script lang="bash"> $ ./bios_extract hdmag217.rom </script>

If bios_decode fails with a message like

Using file "hdmag217.rom" (513kB)
Found Phoenix BIOS "Phoenix ServerBIOS 3 Release 6.0     "
Version "DEVEL4E0", created on 03/20/06 at 14:37:39.
Error: Invalid module signature at 0x80581

then you have to cut the flash chip description off the image. In this case the BIOS image is 512KB, so you do

$ dd if=hdmag217.rom of=hdma.rom bs=512k count=1
1+0 records in
1+0 records out
524288 bytes transferred in 0.000883 secs (593688784 bytes/sec)


You will get an output similar to this:

Using file "hdma.rom" (512kB)
Found Phoenix BIOS "Phoenix ServerBIOS 3 Release 6.0     "
Version "DEVEL4E0", created on 03/20/06 at 14:37:39.
0x715FC ( 27134 bytes)   ->   romexec_0.rom
0x6E1CB ( 13338 bytes)   ->   strings_0.rom	(29401 bytes)
0x6D65D (  2899 bytes)   ->   display_0.rom	(4128 bytes)
0x6B62E (  8208 bytes)   ->   update_0.rom
0x6B1E3 (  1072 bytes)   ->   decompcode_0.rom			 [0x5000:0xB6D0]
0x6564F ( 23421 bytes)   ->   oprom_0.rom	(36864 bytes)
0x65608 (    44 bytes)   ->   tcpa_H_0.rom	(32 bytes)
0x65592 (    91 bytes)   ->   acpi_1.rom	(116 bytes)
0x65519 (    94 bytes)   ->   acpi_2.rom	(244 bytes)
0x654ED (    13 bytes)   ->   tcpa_*_0.rom
0x64D4F (  1927 bytes)   ->   bioscode_0.rom	(31382 bytes)	 [0xF000:0x856A]
0x60020 ( 19728 bytes)   ->   romexec_1.rom
0x570D9 ( 36656 bytes)   ->   oprom_1.rom	(61440 bytes)
0x4DB9D ( 38177 bytes)   ->   oprom_2.rom	(63488 bytes)
0x46493 ( 30447 bytes)   ->   oprom_3.rom	(65536 bytes)
0x41DAB ( 18125 bytes)   ->   logo_0.rom	(310162 bytes)
0x39CA5 ( 25439 bytes)   ->   oprom_4.rom	(51200 bytes)
0x36005 ( 15493 bytes)   ->   setup_0.rom	(37682 bytes)
0x325D7 ( 14867 bytes)   ->   template_0.rom	(37728 bytes)
0x2FA36 ( 11142 bytes)   ->   miser_0.rom	(16208 bytes)
0x2E63C (  5087 bytes)   ->   tcpa_Q_0.rom	(16096 bytes)
0x2D7C3 (  3678 bytes)   ->   acpi_0.rom	(10464 bytes)
0x1FA2A ( 41023 bytes)   ->   bioscode_1.rom	(56080 bytes)	 [0xE000:0x40F0]
0x14FE0 ( 43567 bytes)   ->   bioscode_2.rom	(62416 bytes)	 [0x6000:0xCC30]
0x0EB4C ( 25721 bytes)   ->   bioscode_3.rom	(36976 bytes)	 [0x6000:0x3BC0]
0x0D0A0 (  6801 bytes)   ->   bioscode_4.rom	(31856 bytes)	 [0x5000:0xBF50]

Now you can check the option roms (oprom_?.rom) with the tool romheaders which is part of the FCode Suite:

$ romheaders oprom_0.rom 

Image 1:
PCI Expansion ROM Header:
  Signature: 0x55aa (Ok)
  CPU unique data: 0x48 0xeb 0x7b 0x01 0x76 0x00 0x00 0x00
                   0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
  Pointer to PCI Data Structure: 0x017c

PCI Data Structure:
  Signature: 0x50434952 'PCIR' (Ok)
  Vendor ID: 0x1002
  Device ID: 0x4752
  Vital Product Data:  0x0000
  PCI Data Structure Length: 0x0018 (24 bytes)
  PCI Data Structure Revision: 0x00
  Class Code: 0x030000 (VGA Display controller)
  Image Length: 0x0048 blocks (36864 bytes)
  Revision Level of Code/Data: 0x0421
  Code Type: 0x00 (Intel x86)
  Last-Image Flag: 0x80 (last image in rom)
  Reserved: 0x0000

Platform specific data for x86 compliant option rom:
  Initialization Size: 0x48 (36864 bytes)
  Entry point for INIT function: 0x80

Congratulations, that's your option rom (compare PCI IDs and Class Code to find it among the option roms).

Downloading

There are sites that have video bios roms on their website. (I know of this one for nvidia cards: [1])

For Intel onboard graphics you can download the vbios(vga bios) from Intel's download section. The vbios is included with some versions of the graphics driver. The summary will say something like "NOTE:These materials are intended for use by developers.Includes VBIOS". The actual vbios file is the *.dat file included with the graphics driver.

Extracting from the system (if everything else fails)

However you might be able to retrieve your on-board video bios with Linux as well.

  • Boot up a machine with a commercial bios (not coreboot) with the video card you wish to work under coreboot.
  • You can see where and how much your card's bios is using by doing a
cat /proc/iomem | grep 'Video ROM'
  • From the command line enter:
    dd if=/dev/mem of=vgabios.bin bs=1k count=64 skip=768
    This assumes you card's bios is cached at 0xc0000, and is 64K long.

dd if=/dev/mem of=video.bios.bin.4 bs=65536 count=1 skip=12

This works for many of the VIA Epia boards.
Alternatively you can automatically generate it using this nice script from Peter Stuge:

cat /proc/iomem | grep 'Video ROM' | (read m; m=${m/ :*}; s=${m/-*}; e=${m/*-}; \
dd if=/dev/mem of=vgabios.bin bs=1c skip=$[0x$s] count=$[$[0x$e]-$[0x$s]+1])
  • You now have a video bios image