# ThinkPad X220 and the upcoming FreeBSD 10



## esantoro (Oct 23, 2013)

Hello there!
It's been a while since last time I used FreeBSD (at the time, 7.<something> was out there.

Does anyone use a ThinkPad X220 with the latest FreeBSD release? (9.2)

I would like to know how good is hardware support, and if it will be improved with version 10.

And by the way, regarding FreeBSD 10: I've read that clang/llvm will be the default toolchain. As a student of computer engineering, I would like to know what would change for me by using llvm/clang instead of the good old GCC. Is is a mere change from `gcc -o myapp source.c` to `clang -o myapp source.c` or something deeper?

I'm more interested in the hardware support part.

Thanks in advance,
-- 
esantoro


----------



## jrm@ (Oct 23, 2013)

Hello @esantoro,

I'm running 9.2 on an X220.  The Intel HD 3000 is supported with the new Intel KMS driver.  I have no problems, but until the newcons work is finished, once you start Xorg, you can't go back to the console / virtual terminal.  See this Thread 41435.  I haven't messed with suspend/resume for awhile, but I don't think that works.  There has been a lot of discussion on the current@ mailing list, so you can check there for the latest news.  I couldn't boot with a GPT partition scheme, but that problem wasn't specific to FreeBSD.  I think there are ways around it now, but using an MBR partition scheme works.  Some people have complained about controlling brightness to extend battery life, but I haven't messed with that.  Other than that everything works very well.  I'm quite happy running FreeBSD (exclusively) on my X220.

Added: Oh, the wireless card (Advanced-N 6205) is supported out of the box, but Lenovo puts a restriction that doesn't permit swapping out wireless cards.  See this Thread 41778 and specifically the posts by @wblock and me.


----------



## esantoro (Oct 24, 2013)

jrm said:
			
		

> Hello @esantoro,
> 
> I'm running 9.2 on an X220.  The Intel HD 3000 is supported with the new Intel KMS driver.  I have no problems, but until the newcons work is finished, once you start Xorg, you can't go back to the console / virtual terminal.  See this Thread 41435.



It's funny.

The Thread 41435 you quoted links Intel_GPU wiki page.

In the FAQ section, question 4:



> Q - I cannot switch back to the text console. Or, immediately after loading the driver, the console went black.
> 
> A - The VT switching code is not implemented (yet). In fact, the real cause is that driver turns on modesetting right after the load. This way, it is easier for me to test the driver. *Eventually*, this will be changed.



*Eventually*. Does that mean that it will be fixed when it's not needed anymore?


----------



## jrm@ (Oct 28, 2013)

esantoro said:
			
		

> *Eventually*. Does that mean that it will be fixed when it's not needed anymore?



http://lists.freebsd.org/pipermail/freebsd-current/2013-October/045797.html


----------



## TzunTzai (Dec 27, 2013)

*Re:*



			
				jrm said:
			
		

> Hello @esantoro,
> 
> I'm running 9.2 on an X220.  The Intel HD 3000 is supported with the new Intel KMS driver.  I have no problems, but until the newcons work is finished, once you start Xorg, you can't go back to the console / virtual terminal.  See this Thread 41435.  I haven't messed with suspend/resume for awhile, but I don't think that works.  There has been a lot of discussion on the current@ mailing list, so you can check there for the latest news.  I couldn't boot with a GPT partition scheme, but that problem wasn't specific to FreeBSD.  I think there are ways around it now, but using an MBR partition scheme works.  Some people have complained about controlling brightness to extend battery life, but I haven't messed with that.  Other than that everything works very well.  I'm quite happy running FreeBSD (exclusively) on my X220.
> 
> Added: Oh, the wireless card (Advanced-N 6205) is supported out of the box, but Lenovo puts a restriction that doesn't permit swapping out wireless cards.  See this Thread 41778 and specifically the posts by @wblock and me.




So what was your solution for wireless access? I would love to run FreeBSD on my x220. But the fact that the built in wireless card isn*'*t compatible prevents me from completely swapping over to FBSD FreeBSD.


----------



## jrm@ (Dec 27, 2013)

As I said above, my wireless card (Advanced-N 6205) is supported out of the box.  I specifically chose that card when making the purchase because I knew it was supported.


----------



## TzunTzai (Dec 27, 2013)

jrm said:
			
		

> As I said above, my wireless card (Advanced-N 6205) is supported out of the box.  I specially chose that card when making the purchase because I knew it was supported.



Ah ok, the Intel Centrino Advanced-N 6205 PCI Express Half Mini Card. Any major hurdles when installing this in your x220? I'm going to order one today.


----------



## jrm@ (Dec 27, 2013)

The only hurdles, which are surmountable, are the ones I mentioned above (newcons and having to go with MBR as opposed to GPT).  They might even be working out of the box now if you go with 10.  If you could report back if you get GPT booting working that would be helpful.  Good luck.


----------



## TzunTzai (Dec 27, 2013)

jrm said:
			
		

> The only hurdles, which are surmountable, are the ones I mentioned above (newcons and having to go with MBR as opposed to GPT).  They might even be working out of the box now if you go with 10.  If you could report back if you get GPT booting working that would be helpful.  Good luck.



Thanks for the feedback. I'll update this thread once the install is complete.


----------



## jrm@ (Dec 30, 2013)

I can confirm, even with the latest BIOS (1.39), you cannot boot from a GPT partition scheme with legacy boot and FreeBSD 10 does not yet support UEFI booting. I'm trying to get a bootable USB thumb drive that can boot the e_n_crypted ZFS partition on the hard drive, but so far no luck. My broken GRUB configuration is below.  GRUB reports 
	
	



```
error: no such device: zroot
```
 Any tips would be appreciated.


```
menuentry "FreeBSD 10.0RC3 ZFS" {
        insmod zfs
        search -s -l zroot
        kfreebsd /@/boot/kernel/kernel
        kfreebsd_module_elf /@/boot/kernel/opensolaris.ko
        kfreebsd_module_elf /@/boot/kernel/zfs.ko
        set kFreeBSD.vfs.root.mountfrom=zfs:zroot
}
```


----------



## TzunTzai (Dec 31, 2013)

UEFI BIOS Version 1.33 (Legacy Boot Only)

With FreeBSD 10 I'm able to boot from a GPT partition on a non-encrypted ZFS partition thus far. Everything works great on my x220 except for the NIC. I installed the new Advanced-N 6205 internal NIC however it would seem that I've stumbled across another problem.


```
1802: Unauthorized Network Card Is Plugged In
```

:\  Great! I need to flash this BIOS.



			
				jrm said:
			
		

> I can confirm, even with the latest BIOS (1.39), you cannot boot from a GPT partition scheme with legacy boot and FreeBSD 10 does not yet support UEFI booting. I'm trying to get a bootable USB thumb drive that can boot the e_n_crypted ZFS partition on the hard drive, but so far no luck. My broken GRUB configuration is below. GRUB reports "error: no such device: zroot".  Any tips would be appreciated.
> 
> 
> ```
> ...


----------



## TzunTzai (Dec 31, 2013)

Updated the BIOS to both 1.38 and v1.39 since you mentioned the NIC was working for you @jrm, but no luck. Did you flash a custom BIOS?


----------



## jrm@ (Jan 1, 2014)

@TzunTzai, I've always used an unmodified  BIOS from Lenovo and never had any problems with the card.  Did you add the card yourself after the purchase?  Lenovo apparently restricts after-market Ethernet cards.

What I am having a heck of a hard time with is getting anything other than an MBR/UFS system to boot.  If I try any ZFS installation with MBR I get a 'Missing operationg system' message.  If I try anything with GPT I get a screen with a list of drives to boot from, but it will just return to the screen over and over if you select the drive.

I'm very interested in how you were able to boot with a GPT-partitioned disk.  It's widely documented that the X220 can't/won't boot a GPT-partitioned disk with Legacy boot set in the BIOS.  For example: Problems with the Thinkpad X220 and GPT, UEFI, MBR and Legacy BIOS Booting, Installing Gentoo on a Lenovo X220 with UEFI and GPT, X220.  This also came up on some of the FreeBSD mailing lists.

Does this work for you with BIOS version 1.39?


----------



## TzunTzai (Jan 2, 2014)

WiFi is up and running! I had to install a modified x220 BIOS. The steps I took follow below.

I installed Windows 8 on my x220 in order to install the original Lenovo x220 BIOS v1.38 http://download.lenovo.com/ibmdl/pub/pc/pccbbs/mobiles/8duj24us.exe
I rebooted and then installed the modified x220 BIOS v1.38 http://forums.mydigitallife.info/threads/5866-LENOVO-(IBM)-Bioses-especially-Thinkpad/page556.
Once the modified BIOS was installed, I shut down to physically install the Intel Advanced-N 6205. I turned on the PC and loaded into Windows 8 with no problems. I tested WiFi successfully. (Cracked open a beer!)
*FreeBSD Installation*

Using a USB image, I installed FreeBSD 10-RC3.
GPT + ZFS – FreeBSD 10-R3: Unsuccessful. @jrm, it looks like it didn*'*t work. GPT *WAS* working with BIOS v1.33. This setting didn't give me an error. It just caused the laptop to loop between PXE boot and the BIOS boot menu.
MBR + ZFS – FreeBSD 10-R3:  Unsuccessful. No bootable device found.
I know PC-BSD uses the GRUB boot manager. So I decided to give that a try.

GPT + GRUB + ZFS – PC-BSD 10-R2:  Unsuccessful. The same problem as above.
MBR + GRUB + ZFS - PC-BSD 10-R2:  Successful!

It looks like GRUB may offer a solution for MBR + FreeBSD. I've had no luck with GPT since the BIOS modification though.


----------



## TzunTzai (Jan 2, 2014)

jrm said:
			
		

> @TzunTzai, I've always used an unmodified  BIOS from Lenovo and never had any problems with the card.  Did you add the card yourself after the purchase?  Lenovo apparently restricts after-market ethernet cards.
> 
> What I am having a heck of hard time with is getting anything other than an MBR/UFS system to boot.  If I try any ZFS installation with MBR I get a 'Missing operationg system' message.  If I try anything with GPT I get a screen with a list of drives to boot from, but it will just return to the screen over and over if you select the drive.
> 
> ...


A question, which version of the x220 do you have? 

I have the x220-4286. Maybe I'll put a request in for a modified WiFi White List version of 1.33.


----------



## jrm@ (Jan 3, 2014)

Hey @kauntem.  I have the 4286 as well.

Your results match mine exactly.  The only way I managed to get a ZFS-based install to boot was with MBR/GRUB.

For anyone trying to get the memory card reader and the headphone/microphone jack working try this in /boot/loader.conf:

```
# Drivers for memory card reader
mmc_load="YES"
mmcsd_load="YES"
sdhci_load="YES"

# Out : speaker + headphones
hint.hdac.0.cad0.nid25.config="as=1 seq=15 device=Headphones"
# In : mic + external mic
hint.hdac.0.cad0.nid27.config="as=2 seq=15"
hint.hdac.0.cad0.nid35.config="as=2"
```


----------



## TzunTzai (Mar 19, 2014)

*[SOLVED] (Kind of) Re: ThinkPad X220 and the upcoming FreeBS*



			
				jrm said:
			
		

> @TzunTzai, I've always used an unmodified  BIOS from Lenovo and never had any problems with the card.  Did you add the card yourself after the purchase?  Lenovo apparently restricts after-market Ethernet cards.
> 
> What I am having a heck of a hard time with is getting anything other than an MBR/UFS system to boot.  If I try any ZFS installation with MBR I get a 'Missing operationg system' message.  If I try anything with GPT I get a screen with a list of drives to boot from, but it will just return to the screen over and over if you select the drive.



Hi Jrm,

Figured I'd share this with you...

ZFS (Encrypted) + MBR = Success

Obviously we were having problems with the boot manager so I decided to do a little reading which eventually provided the following results...

I ran the ZFS Automatic Root-on-ZFS install using a FreeBSD USB image.

```
- Stripe on ada0 (Or which ever drive you use)
- Force 4k Sectors = Yes
- Encrypt Disk = Yes
- Partition Scheme = MBR
- Swap Size = 4G
```

Once the install was complete, I restarted the laptop and booted from the FreeBSD USB image once more. This time, at the welcome screen, I chose to use the "Shell" and ran the following commands to modify the boot manager. (Note: If you try to use the shell at the end of the installation before rebooting, you'll receive an error while issuing the commands below.)


```
# gpart bootcode -b /boot/mbr ada0 (Reflecting my drives of coarse)
# gpart set -a active -i 1 ada0
# gpart bootcode -b /boot/boot ada0s1
# dd if=/boot/zfsboot of=/dev/ada0s1 count=1
# dd if=/boot/zfsboot of=/dev/ada0s1a skip=1 seek=1024
# dd if=/boot/zfsboot of=/dev/ad4s1 count=1
# dd if=/boot/zfsboot of=/dev/ad4s1a skip=1 seek=1024
```

Remove USB flash drive


```
# reboot
```

Using the steps above, I am able to Install and run FreeBSD on a MBR/ZFS encrypted partition.

Do note, it'll seem as if FreeBSD is frozen while loading the drivers. It is actually waiting for you to enter your encryption password. Press <enter> once or twice then you'll see the encryption prompt. 

Let me know if you have any questions.


----------



## TzunTzai (Mar 19, 2014)

Hi @jrm,

One more thing. Could you send me your xorg.conf configuration? I'm having some problems setting it up again.


----------



## jrm@ (Mar 20, 2014)

@TzunTzai, below is my xorg.conf that works with _9-STABLE_ on my X220.  Can you report back if you are successful or not getting Xorg up and running on 10?  If you think there is a bug, please report it.

```
Section "ServerLayout"
	Identifier     "X.org Configured"
	Screen      0  "Screen0" 0 0
	Screen      1  "Screen1" Above "Screen0"
	InputDevice    "Mouse0" "CorePointer"
	InputDevice    "Keyboard0" "CoreKeyboard"
	#Option		   "AutoAddDevices" "Off"
	Option "BlankTime" "0"
	Option "DPMS" "true"
	Option "StandbyTime" "0"
	Option "SuspendTime" "0"
	Option "OffTime" "0"
EndSection

Section "Files"
	ModulePath   "/usr/local/lib/xorg/modules"
	FontPath     "/usr/local/lib/X11/fonts/misc/"
	FontPath     "/usr/local/lib/X11/fonts/TTF/"
	FontPath     "/usr/local/lib/X11/fonts/OTF/"
	FontPath     "/usr/local/lib/X11/fonts/Type1/"
	FontPath     "/usr/local/lib/X11/fonts/100dpi/"
	FontPath     "/usr/local/lib/X11/fonts/75dpi/"
	FontPath     "/usr/local/lib/X11/fonts/dejavu/"
	FontPath     "/usr/local/lib/X11/fonts/webfonts/"
EndSection

Section "Module"
	Load  "extmod"
	Load  "record"
	Load  "dbe"
	Load  "glx"
	Load  "dri"
	Load  "dri2"
	Load  "freetype" # added manually
EndSection

Section "InputDevice"
	Identifier  "Keyboard0"
	Driver      "kbd"
EndSection

Section "InputDevice"
	Identifier  "Mouse0"
	Driver      "mouse"
	Option	    "Protocol" "auto"
	Option	    "Device" "/dev/sysmouse"
	Option	    "ZAxisMapping" "4 5 6 7"
EndSection

Section "Monitor"
	Identifier   "Laptop Monitor"
	Option "Monitor-LVDS1" "Laptop Monitor"
EndSection

Section "Monitor"
	Identifier   "External Monitor"
	Option "Monitor-VGA1" "External Monitor"
EndSection

Section "Device"
	Identifier  "Card0"
	Driver      "intel"

	BusID       "PCI:0:2:0"
EndSection

Section "Device"
	Identifier  "Card1"
	Driver      "intel"
	BusID       "PCI:0:2:0"
EndSection

Section "Screen"
	Identifier "Screen0"
	Device     "Card0"
	Monitor    "Laptop Monitor"
	SubSection "Display"
		Viewport   0 0
		Depth     24
	EndSubSection
EndSection

Section "Screen"
	Identifier "Screen1"
	Device     "Card1"
	Monitor    "External Monitor"
	SubSection "Display"
		Viewport   0 0
		Depth     24
	EndSubSection
EndSection
```


----------

