Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Making "broken" Intel video BIOS play nice
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
ExZombie
Apprentice
Apprentice


Joined: 29 May 2004
Posts: 164

PostPosted: Fri Feb 10, 2006 4:40 pm    Post subject: Making "broken" Intel video BIOS play nice Reply with quote

This how-to is (being) deprecated
Please see the Gentoo Wiki article

What is the problem?
Integrated video adapters manufactured by Intel have only the most common video modes in their BIOS. Many laptops today have widescreen LCD panels whose native resolution is not in the BIOS. Laptop manufacturers are supposed to modify the BIOS to make it possible to utilize the panel, but most rely on the video driver they provide for Microsoft Windows to provide the modes. Since they don't provide drivers for linux (which I am quite happy with, given their lazyness) those of us who want to use an operating sistem instead of a gaming rig (especially with Intel's graphics :wink: ) have to find alternative solutions.

Solution
The optimal solution would be patching the video BIOS. I have been unable to find a tool to do it, however.
There are userspace tools which modify the RAM version of the BIOS. Such changes are in effect only as long as the computer is on, and are reset on reboot. This is okay as long as you are only toying around, or if you are only interested in running X11, since the tool can patch BIOS before X starts. But the only affected chipsets I am aware of are for laptops, and on a laptop you probably want more flexibility concerning power management than simple shutdown/reboot. Yes, I am talking about software suspend. You can fix that up easily for X. Or you can fix that (not as easy though) for framebuffer console. You can't fix it for both of them.

Obviously, the BIOS needs to be patched before any kind of graphics driver gets loaded and tries to read resolutions. That means both X and framebuffer drivers. The only way to do it, short of making the kernel do it (which is a no no), is using an initrd. For those who don't know what that is: it is an image containing a filesystem structure similar to an ordinary instalation. The kernel loads it into memory immediately after loading (before init). It can be used to load drivers and perform tasks before the rest of the system boots. After it's done, it mounts the root partition and continues the normal boot process.

Requirements
First, you need to have your kernel configured properly.

Include the support for initrd and ext2 as builtin:
Code:

Device Drivers  --->
     Block devices  --->
          <*> RAM disk support
          (16)  Default number of RAM disks
          (4096) Default RAM disk size (kbytes)
          [*]   Initial RAM disk (initrd) support

File systems  --->
     <*> Second extended fs support


You may want to increase 'Default RAM disk size', since this is the maximum size of the initrd.
And while you are at it, if you want to use the framebuffer console, have the framebuffer driver you want (vesa, probably) and framebuffer console compiled as modules. They are located under Graphics support.

Compile and install the kernel as usual.

You also need a tool to patch the BIOS. For most of the affected chipsets, 855resolution should be okay. I works on my i915GM. It's also in portage, so you can simply emerge it. You don't need to actually install it, however. The binary resulting from a merge is dinamicaly linked to shared libraries and thus useless in an initrd. Use emerge only to download the source:
Code:
# emerge -f 855resolution


Making an initrd
If you already use an initrd, you obviously don't need to read this section. Skip to the next one.
If you use genkernel, you too shouldn't need to read this. As far as I know, genkernel makes use of an initrd as well and you should be able to use that. However, I have never used genkernel and don't know how it's linuxrc script works. You are on your own. If someone would be kind enough to provide instructions for genkernel users, I will be happy to include them.
Correction: genkernel seems to use initramfs, proving I haven't a clue :) . Initramfs is another thing I have never used, so again, you are on your own. Gremo says it works though :) .

There are different ways to make an initrd. The end result must be a file that contains a linuxrc script (which can be anything) and the files necessary for it's execution. I have used a tool called mkinitrd. It's in portage.
Code:
# emerge -av mkinitrd

Go to a directory of your choice. Usually, initrd is used to load modules necessary to mount the root filesystem, so mkinitrd configures it in this way by default. If you don't want that, check the manual page on the proper options. For people like me who don't compile SCSI/RAID/LVM stuff as modules, it doesn't matter. Just type
Code:
# mkinitrd image_name kernel_version

where image_name is the resulting file you want and kernel_version is the kernel for which you want an initrd. In my case, this command was
Code:
# mkinitrd initrd-20060209.img.gz 2.6.15-suspend2-r2

The result is a gzip-compressed image of an ext2 filesystem. First make sure it works. Copy it over to your /boot and configure your bootloader. In the case of grub, add a line like this after the kernel line in grub.conf, with your image's filename of course:
Code:
initrd /boot/initrd_file.img.gz

It might be a good idea to keep a normal entry in the bootloader in case initrd doesn't work.
Also create a directory /initrd on your root filesystem, as this is where the initrd will move itself (via pivot_root system call) in order to continue normal booting.
Code:
# mkdir /initrd

The image created in this way worked for me. If it doesn't work for you, well, it'll need fixing :) .

Making the tool
You will recall that I told you not to install 855resolution, but only fetch it. This is because initrd contains only the bare minimum necessary to complete its tasks, and shared libraries have no place in this. All executables need to be linked statically.
First, unpack the source.
Code:
# tar xvzf /usr/portage/distfiles/855resolution-0.4.tgz
# cd 855resolution-0.4

Change the linker flags in Makefile to read
Code:
LDFLAGS:=-s -static

Then compile the thing.
Code:
# make


Now, run
Code:
# ./855resolution -l

You should get a list of resolutions your BIOS supports. Lines look like
Code:
Mode 5a : 1600x1200, 32 bits/pixel

Here, 5a is the name of the mode. Decide which mode you want to replace, preferably one which your monitor doesn't support anyway.
You can replace a mode by running (in my case):
Code:
# ./855resolution 5c 1680 1050

Thus mode 5c gets replaced, and also modes 4d and 3c, which held the same resolution but different color depth. As I said, these changes are gone after you reboot, so if you get it wrong, nothing is permanently damaged. You should test the new mode before proceeding.

Modifying the initrd
Once you have a working initrd, it's time to make it do what we want. First, you need to uncompress it. If you want, you might as well work directly on the file in your /boot.
Code:
# gunzip /boot/initrd_file.img.gz

Since this file is a filesystem image, you can mount it as if it were a drive, using a loopback device.
Code:
# mount -o loop /boot/initrd_file.img /mnt/temp

Now if you take a look at the contents of the image, you will see the linuxrc script. This is what the kernel runs after it decompresses the image into memory. mkinitrd uses nash as the interpreter. It's not a real shell, but is sufficient for most tasks you'd want to perform. But it won't be providing drivers on it's own. You need to copy stuff into the image. Copy the 855resolution binary you compiled into the bin directory:
Code:
# cp /your_directory/855resolution-0.4/855resolution /mnt/temp/bin

855resolution uses the /dev/mem device to access the part of memory where the BIOS image is stored. This device file is not created by mkinitrd, so you need to create it by hand:
Code:
# cd /mnt/temp/dev
# mknod mem c 1 1
# cd -


If you intend to use framebuffer, you need to copy the modules you need to /lib. The problem is, you need many modules besides your framebuffer driver and fbcon.ko, because these two depend on them. You'll need to resolve this yourself, but for vesafb-tng, which I used, you need these:

  • bitblit.ko
  • cfbcopyarea.ko
  • cfbfillrect.ko
  • cfbimgblt.ko
  • fbcon.ko
  • font.ko
  • softcursor.ko
  • vesafb-thread.ko
  • vesafb-tng.ko

They are located in /lib/modules/2.6.15-suspend2-r2/kernel/drivers/video/
and /lib/modules/2.6.15-suspend2-r2/kernel/drivers/video/console.
Update: this list changes with kernel versions. A way to find what you need is to boot without loading vesafb, use lsmod to see which modules are loaded, use modprobe to load vesafb, and use lsmod again to see which additional modules were pulled in. Note the order in which they were pulled in.

As far as hibernation (software suspend 2) goes, all you need is an entry in linuxrc. But if you're like me and want a textual progressbar, you also need the ui program:
Code:
cp /sbin/suspend2ui_text /mnt/temp/bin


Now it's time to edit the linuxrc script. If you're not using vesafb-tng, you'll need to figure out the proper order to load modules in yourself. Here's my script. Check the comments and decide what you need an what you don't. Everything after mounting /proc and setting up suspend2 was generated by mkinitrd.
Code:

#!/bin/nash

echo "Modifying video BIOS"
# This line patches the BIOS. Use the mode you tested before
/bin/855resolution 5c 1680 1050

echo "Loading vesa modules"
# If you don't use vesafb-tng, replace this with your own
insmod /lib/cfbfillrect.ko
insmod /lib/vesafb-thread.ko
insmod /lib/cfbimgblt.ko
insmod /lib/cfbcopyarea.ko
# vesafb needs to use General timing formula for nonstandard modes
insmod /lib/vesafb-tng.ko gtf=1 scroll=ywrap mode=1680x1050-16@60
insmod /lib/softcursor.ko
insmod /lib/bitblit.ko

echo "Loading framebuffer console modules"
# This seems to be indepentent of the framebuffer driver
insmod /lib/font.ko
insmod /lib/fbcon.ko


echo Mounting /proc filesystem
mount -t proc /proc /proc
echo > /proc/suspend2/do_resume # Use this to enable hibernate/resume
echo "/sbin/suspend2ui_text" > /proc/suspend2/userui_program # Use this to get progressbar
echo Creating block devices
mkdevices /dev
echo Creating root device
mkrootdev /dev/root
echo 0x0100 > /proc/sys/kernel/real-root-dev
echo Mounting root filesystem
mount -o noatime --ro -t ext3 /dev/root /sysroot
pivot_root /sysroot /sysroot/initrd
umount /initrd/proc


This should do it. Unmount the image and compress it.
Code:
# umount /mnt/temp
# gzip -9 /boot/initrd_file.img

If you've done everything right, your system should boot and function normaly, X11 and hibernation too.

One more thing. You might have noticed that after booting, the image remains mounted on /initrd. You can safely unmount it.

DISCLAIMER: Don't hold me responsible if anything goes wrong. Whichever instructions you are following, you should always know what you are doing.


Last edited by ExZombie on Tue Dec 12, 2006 3:54 pm; edited 2 times in total
Back to top
View user's profile Send private message
Gremo
Guru
Guru


Joined: 27 Feb 2006
Posts: 450
Location: Udine (Italy)

PostPosted: Fri Sep 29, 2006 8:15 am    Post subject: Reply with quote

MAN I LOVE YOU! not kidding! :D :D
i'm using gentoo since december and i always looking for a perfect solution like this!
now all it's working, my laptop seems to have a native resolution, plus 1280x800 splash!
did it with initramfs and genkernel! (because i cannot get initrd works)!

thanks!!
_________________
In nome delle migliaia di innocenti assassinati vi auguro di passare il resto dell’eternità con le vostre 72 puttane ad arrostire a fuoco lento all’inferno. Stronzi cammellieri con l’asciugamano in testa, baciate le mie nobili palle irlandesi.
Back to top
View user's profile Send private message
ExZombie
Apprentice
Apprentice


Joined: 29 May 2004
Posts: 164

PostPosted: Fri Sep 29, 2006 9:53 am    Post subject: Reply with quote

I'm glad the how-to was useful to someone :) .

Indeed, initramfs seems to be the preffered way to do things nowadays, but I have never used it since initrd always worked very well for me. I might try using it some time, see what makes it better. I'll update the how-to in that case.
Back to top
View user's profile Send private message
herdentier
n00b
n00b


Joined: 28 Nov 2006
Posts: 9

PostPosted: Fri Dec 08, 2006 8:46 am    Post subject: Reply with quote

Ended up with this:
Code:
marcel-gentoo 855resolution # ./855resolution -l
855resolution version 0.4, by Alain Poirier

Chipset: 855GM (id=0x35808086)
Unknow VBIOS structure


Hardware is an Asus M5600N Notebook
Code:

00:00.0 Host bridge: Intel Corporation 82852/82855 GM/GME/PM/GMV Processor to I/O Controller (rev 02)
00:00.1 System peripheral: Intel Corporation 82852/82855 GM/GME/PM/GMV Processor to I/O Controller (rev 02)
00:00.3 System peripheral: Intel Corporation 82852/82855 GM/GME/PM/GMV Processor to I/O Controller (rev 02)
00:02.0 VGA compatible controller: Intel Corporation 82852/855GM Integrated Graphics Device (rev 02)
00:02.1 Display controller: Intel Corporation 82852/855GM Integrated Graphics Device (rev 02)
...
00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev 83)
...
00:1f.3 SMBus: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) SMBus Controller (rev 03)
...


the following appers everytime in my Xorg-log when the int10-module is (re-)loaded

(WW) I810(0): Bad V_BIOS checksum

Code:

(II) I810(0): initializing int10
(WW) I810(0): Bad V_BIOS checksum
(II) I810(0): Primary V_BIOS segment is: 0xc000
(II) I810(0): VESA BIOS detected
(II) I810(0): VESA VBE Version 3.0
(II) I810(0): VESA VBE Total Mem: 12288 kB
(II) I810(0): VESA VBE OEM: Intel(r)852MG/852MGE/855MG/855MGE Graphics Chip Accelerated VGA BIOS
(II) I810(0): VESA VBE OEM Software Rev: 1.0
(II) I810(0): VESA VBE OEM Vendor: Intel Corporation
(II) I810(0): VESA VBE OEM Product: Intel(r)852MG/852MGE/855MG/855MGE Graphics Controller
(II) I810(0): VESA VBE OEM Product Rev: Hardware Version 0.0


Any suggestions where this Problem comes from?
Back to top
View user's profile Send private message
ExZombie
Apprentice
Apprentice


Joined: 29 May 2004
Posts: 164

PostPosted: Sat Dec 09, 2006 11:56 am    Post subject: Reply with quote

Well, xorg claiming "Bad V_BIOS checksum" is nothing to worry about. But 855resolution obviously doesn't recognize your VBIOS type. You can try forcing it by using
Code:
855resolution -f n
where n is number 1, 2 or 3. When listing the modes, you should get some sane resolutions when you use the correct mode, and a bunch of nonsensical modes with the other two. For example, on my 915 using mode 1 I get
Code:

Mode 30 : 35x57377, 8 bits/pixel
Mode 32 : 21x22578, 8 bits/pixel
Mode 34 : 55x66, 8 bits/pixel
Mode 38 : 20x82, 8 bits/pixel
Mode 3a : 20x45155, 8 bits/pixel
Mode 3c : 20x41075, 8 bits/pixel
Mode 41 : 35x57377, 16 bits/pixel
Mode 43 : 21x22578, 16 bits/pixel
Mode 45 : 55x66, 16 bits/pixel
Mode 49 : 20x82, 16 bits/pixel
Mode 4b : 20x45155, 16 bits/pixel
Mode 4d : 20x41075, 16 bits/pixel
Mode 50 : 35x57377, 32 bits/pixel
Mode 52 : 21x22578, 32 bits/pixel
Mode 54 : 55x66, 32 bits/pixel
Mode 58 : 20x82, 32 bits/pixel
Mode 5a : 20x45155, 32 bits/pixel
Mode 5c : 20x41075, 32 bits/pixel
Mode 60 : 1x1, 8 bits/pixel
Mode 61 : 1x1, 16 bits/pixel
Mode 62 : 1x1, 32 bits/pixel
Mode 63 : 1x1, 8 bits/pixel
Mode 64 : 1x1, 16 bits/pixel
Mode 65 : 1x1, 32 bits/pixel
Mode 66 : 1x1, 8 bits/pixel
Mode 67 : 1x1, 16 bits/pixel
Mode 68 : 1x1, 32 bits/pixel
Mode 69 : 1x1, 8 bits/pixel
Mode 6a : 1x1, 16 bits/pixel
Mode 6b : 1x1, 32 bits/pixel
Mode 6c : 1x1, 8 bits/pixel
Mode 6d : 1x1, 16 bits/pixel
Mode 6e : 1x1, 32 bits/pixel
Mode 6f : 1x1, 8 bits/pixel
Mode 70 : 1x1, 16 bits/pixel
Mode 71 : 1x1, 32 bits/pixel

and using mode 2 I get
Code:

Mode 30 : 640x480, 8 bits/pixel
Mode 32 : 800x600, 8 bits/pixel
Mode 34 : 1024x768, 8 bits/pixel
Mode 38 : 1280x1024, 8 bits/pixel
Mode 3a : 1600x1200, 8 bits/pixel
Mode 3c : 1680x1050, 8 bits/pixel
Mode 41 : 640x480, 16 bits/pixel
Mode 43 : 800x600, 16 bits/pixel
Mode 45 : 1024x768, 16 bits/pixel
Mode 49 : 1280x1024, 16 bits/pixel
Mode 4b : 1600x1200, 16 bits/pixel
Mode 4d : 1680x1050, 16 bits/pixel
Mode 50 : 640x480, 32 bits/pixel
Mode 52 : 800x600, 32 bits/pixel
Mode 54 : 1024x768, 32 bits/pixel
Mode 58 : 1280x1024, 32 bits/pixel
Mode 5a : 1600x1200, 32 bits/pixel
Mode 5c : 1680x1050, 32 bits/pixel

Obviously mode 2 is the correct one.

If that doesn't work, you can try 915resolution. After that, I'm out of ideas. It might be that your vendor has modified the VBIOS in an unusual way.
Anyway, since these changes are reverted after a reboot, you can probably experiment freely, but I'm not taking any responsibility.
Back to top
View user's profile Send private message
Gremo
Guru
Guru


Joined: 27 Feb 2006
Posts: 450
Location: Udine (Italy)

PostPosted: Tue Dec 12, 2006 9:51 am    Post subject: Reply with quote

ExZombie,
how to hide:

Code:

855resolution version 0.4, by Alain Poirier

Chipset: 855GM (id=0x35808086)
Unknow VBIOS structure


on boot using initrd?

also, i started and article on gentoo wiki:

http://gentoo-wiki.com/Making_%22broken%22_Intel_video_BIOS_play_nice

can you help me completing it?
thanks a lot!
_________________
In nome delle migliaia di innocenti assassinati vi auguro di passare il resto dell’eternità con le vostre 72 puttane ad arrostire a fuoco lento all’inferno. Stronzi cammellieri con l’asciugamano in testa, baciate le mie nobili palle irlandesi.
Back to top
View user's profile Send private message
ExZombie
Apprentice
Apprentice


Joined: 29 May 2004
Posts: 164

PostPosted: Tue Dec 12, 2006 12:48 pm    Post subject: Reply with quote

You could use
Code:
855resolution | grep -v Unknow

but you need to make sure there is grep present in the initrd. The easiest way to make the basic utilities present is to put busybox there. Then use
Code:
855resolution | busybox grep -v Unknow


As for the wiki, I'll be happy to help :) . Actually, it might not be a bad idea to deprecate this topic in favor of the wiki.
Is it possible for two people to make major changes to an article simultaneously?
Back to top
View user's profile Send private message
Gremo
Guru
Guru


Joined: 27 Feb 2006
Posts: 450
Location: Udine (Italy)

PostPosted: Tue Dec 12, 2006 1:40 pm    Post subject: Reply with quote

ExZombie wrote:
You could use
Code:
855resolution | grep -v Unknow

but you need to make sure there is grep present in the initrd. The easiest way to make the basic utilities present is to put busybox there. Then use
Code:
855resolution | busybox grep -v Unknow


As for the wiki, I'll be happy to help :) . Actually, it might not be a bad idea to deprecate this topic in favor of the wiki.
Is it possible for two people to make major changes to an article simultaneously?


for the wiki, i really don't know. feel free to make any change, as you can see it is quite most copy and paste from this thread.
btw, dow you know how i can compile statically busibox?

thanks!
_________________
In nome delle migliaia di innocenti assassinati vi auguro di passare il resto dell’eternità con le vostre 72 puttane ad arrostire a fuoco lento all’inferno. Stronzi cammellieri con l’asciugamano in testa, baciate le mie nobili palle irlandesi.
Back to top
View user's profile Send private message
ExZombie
Apprentice
Apprentice


Joined: 29 May 2004
Posts: 164

PostPosted: Tue Dec 12, 2006 1:49 pm    Post subject: Reply with quote

Quote:
for the wiki, i really don't know. feel free to make any change, as you can see it is quite most copy and paste from this thread.
btw, dow you know how i can compile statically busibox?


Simply emerge it with 'static' USE flag.
Back to top
View user's profile Send private message
justcme
n00b
n00b


Joined: 17 Nov 2005
Posts: 20

PostPosted: Sat Dec 16, 2006 5:25 am    Post subject: Reply with quote

First of all, thanks SOO mucH! this works great! i followed your guide (approximately) as written up on gentoo-wiki and now have framebuffer working at native resolutions!!! (1280x800) woohoo!!

may i add, that for some reason, mkinitrd (from portage) creates an initramfs file! not the old initrd block device! after i did 'gzip -d initrd.img.gz' i found that the inird.img was actually a cpio archive! not a block device at all 8O
mkinitrd also used /init as the startup script, instead of linuxrc... not that it matters, but another indication that it is initramfs...
hope the info helps :)


ExZombie wrote:
And while you are at it, if you want to use the framebuffer console, have the framebuffer driver you want (vesa, probably) and framebuffer console compiled as modules. They are located under Graphics support.

last thing... atm i have compiled framebuffer support directly into the kernel (no modules), but left vesafb-tng as a module... and it still works! 915resolution still sets the correction resolution and my gensplash theme comes up!
so, it looks like we don't need to have framebuffer support compiled as modules :lol:

(this is for you too Gremo, since on the wiki it says you are still writing it up)

thank you again! it's great, i hope more development can continue to make this easier
Back to top
View user's profile Send private message
ExZombie
Apprentice
Apprentice


Joined: 29 May 2004
Posts: 164

PostPosted: Sat Dec 16, 2006 12:44 pm    Post subject: Reply with quote

Thanks for the input, much appreciated.

Seems you're right, to an extent. sys-apps/mkinitrd-4.2.0.3 really does create initramfs images, while sys-apps/mkinitrd-3.5.7 creates initrd images. I'll update the how-to to reflect that.

As for the modules, I admit the sentence I wrote is a bit unclear. Reader should refer to kernel config below. Updating.

justcme, if you have the time, could you please write up a guide to making an initramfs using >=initrd-4.2 ? You could possibly just expand and finish gremo's section, since modifying the initramfs might work the same way as for genkernel method, but it's up to you.

herdentier: did you manage to fix your problem? If the fix worked, I'd like to add it to the wiki.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum