VGA support: Difference between revisions

From coreboot
Jump to navigation Jump to search
Line 121: Line 121:
== How to retrieve a good video bios ==
== How to retrieve a good video bios ==


=== Extracting from your vendor bios image ===
=== 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 awardeco/amideco/phnxdeco. These tools are available in Debian/Ubuntu. If your vendor bios is award, you would use awardeco, if it's AMI amideco, and if it's Phoenix phnxdeco.
The recommended method is to take your mainboard vendor's BIOS image and extract the VGA BIOS using a tool called awardeco/amideco/phnxdeco. These tools are available in Debian/Ubuntu. If your vendor bios is award, you would use awardeco, if it's AMI amideco, and if it's Phoenix phnxdeco.

Revision as of 17:10, 26 February 2009

VGA initialization in coreboot v2

General

You need to enable two CONFIG options in your Mainboard Option.lb

<source lang="bash">

  1. VGA Console

option CONFIG_CONSOLE_VGA=1 option CONFIG_PCI_ROM_RUN=1 </source>

CONFIG_PCI_ROM_RUN will use the embedded x86 emulator to run the BIOS image in the expansion ROM of a PCI device. CONFIG_CONSOLE_VGA will redirect console messages to the VGA screen once VGA card is initialized.

For add-on (PCI/PCIe/PCI-X/AGP) VGA cards, you don't have to do anything else besides these two CONFIG options. If your mainboard has an on-board VGA chip and you insert another VGA add-on card, the add-on VGA card will be used instead of the on-board VGA chip.

On-board Video Devices

If you want to use the onboard VGA chip, you have to add the following options in addition to the CONFIG options described above.

Mainboard Configuration

Note: This step is not necessary for the VIA CN700 chipset.

1. In the mainboard's Config.lb (./src/mainboard/<mfg>/<board>/Config.lb) You need to specify the device number for your on-board VGA and the address that the video bios will show up at in the system.

<source lang = bash>

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

</source>

Replace the 9.0 with the dev.fn of your vga device. You can find this number by doing a 'lspci' from the board booted under linux. Please make sure the device number is correct. Otherwise the config code can not compute the proper ROM address.


How to compute the "rom_address" value

ROM (called 'flash' a lot) chips are located directly below 4Gbyte (0xffffffff) boundary.

So you need to calculate the address by subtracting the flash chip size (and adding the offset within the image)

In coreboot the offset within the image is 0, because its the first thing in the coreboot image.

So you need to compute the address in the systems memory space where the start of the video bios will show up.

To do this you take the 4Gb of address and subtract the size of your coreboot image.

0x100000000 - (ROM size in Kb * 1024)

You can do this in bash by:

<source lang="bash"> biossize=256 printf "0x%x\n" $(( 0x100000000 - ($biossize*1024) )) </source>

Addresses for popular chip sizes:

256K  0xfffc0000
512k  0xfff80000
1024k 0xfff00000


Target Configuration

2. You still need to modify your target 'Config.lb' to reserve space for the additional video bios. Reduce the size of your coreboot image by the size of the video bios. You will prepend the video bios to the coreboot image in step 3.

in the normal section

<source lang="bash"> romimage "normal"

  # 48K for SCSI FW or ATI ROM
  option ROM_SIZE = 475136

</source>

or if you only have a "fallback" boot then use the "fallback" section instead.

In the above example the bios chip is 512Kb part. The video bios is 48Kb. So (512*1024)-(48*1024) = 475136.

Note: The Via CN700 chipset also requires legacy BIOS support. This can be found or at http://bochs.sourceforge.net/ or in the Debian package bochsbios, filename /usr/share/bochs/BIOS-bochs-legacy. You'll need to leave an additional 64k of space for the Bochs BIOS.

Creating an Image

3. Finally, prepend your video bios to the coreboot.rom

<source lang="bash"> cat videobios.bin coreboot.rom > final_coreboot.rom </source>

where videobios.bin is the name of your video bios image. You need to make sure the final_coreboot.rom size is the size of your ROM chip. Normally 256kb, 512kb, or 1024Kb.

See below for instructions on how to retrieve the video BIOS from your factory ROM.

For Via CN700: <source lang="bash"> cat videobios.bin bochsbios.bin coreboot.rom > final_coreboot.rom </source>

VGA initialization in coreboot v3

In coreboot v3 you have to set your PCI option ROM execution method under the Device menu. The default is x86emu. To get a smaller (and slightly more insecure) version, you can switch to vm86. If you don't want option rom execution, set it to Disabled.

On-board devices

To add option roms for on-board video cards to your coreboot image, you can just add the image using lar:

<source lang="bash"> lar -C lzma -a coreboot.rom vgabios.rom:pciXXXX,YYYY.rom </source>

In the above example, vgabios.rom is the name of your option rom on disk. XXXX is the PCI vendor ID of your on-board video adapter and YYYY is its PCI device ID.

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 awardeco/amideco/phnxdeco. These tools are available in Debian/Ubuntu. If your vendor bios is award, you would use awardeco, if it's AMI amideco, and if it's Phoenix phnxdeco.

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

With this method, you may need to pad the image to a certain size, e.g. 64k. This is necessary at least for VIA CN700 chipsets where the factory VGA bios is smaller.

Downloading

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

Extracting from the system

However you should be able to retrieve your own video bios as well with linux.

  • 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:
    <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.


<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.
Alternatively you can automatically generate it using this nice script from Peter Stuge:
<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