Matrox Thunderbolt Docking station after my USB ports broke down.

I have Macbook pro 8,2 that I got October/2011. I went to Korea for a performance, and my old macbook pro’s top board was completely broken. I needed to perform in few days, and the computer was getting old, so I put it into Apple Service, and I as well got the new one.

My finance was not so well, and I was traveling so that I didn’t get the Apple care. Then as you might guess, after 1 year of its use, something is breaking down : USB.

I had few issues with this computer. The first one was the thunderbolt port. I use an external monitor at home, and the screen was flickering sometimes. Strangely it doesn’t happen even once in Linux. So that I know it is the poor apple software issue, and a number of people were complaining. Then there were few updates, the frequency of the flickering was getting less. But still, it’s sometimes flickering.

Since a month ago, the USB ports were a bit weird. One of two ports was occasionally working: meaning, it doesn’t give power to any equipment, and when I pull and plug again, it sometimes worked.

Few days later, this poor one never worked again, and the other one was doing the same as the other: occasionally working.

I was scared that if I wouldn’t have any USB port, it must cause quite a serious issue. I would need to perform with this machine, and I might not be able to plug in any of controller. Well, forget about the performance. I couldn’t even use mouse/keyboard/harddrive/my phone and so on that are just so common and necessary.

Few days later, even after few reboots, it was working rarely. Yes I checked with the Apple Service, who couldn’t find any issue with the hardware, also did enough research. I was not the only person who had the issue. But any solution that people have given didn’t work for me. I needed to find another solution, rather than replacing my top board just because of USBs.

This was what I found. Matrox Docking Station.

Matrox Dock

Yes. It is quite expensive for me when I think of ‘USB.’ but cheaper than replacing the top board.

This machine has 2 USB 2.0, 1 USB 3.0 (yeah! something new is added to my laptop!), 1 ethernet, 1 DVI out, Audio in/out. It is pity that there is no Firewire.

The official price is 250 $. I got in the Netherlands, and it was around 220 euro. I ordered it and received it. Well, yes I spent some money with tears, but now I don’t need to worry about USB anymore. I was quite excited. Opened the box. then SIGH>>>…..

There was no Thunderbolt cable.. man… It was like, as my friend said, you get your phone without a charger.

This was really really¬†disappointing. Most of you know that this cable is quite expensive. I got it from Apple store, (because I couldn’t find anywhere else around this town) and that was 50 euro.. I would have gotten 5 USB hubs with this money..

So yes. I needed to spend even more money to use USB.

I do not, as much as you, want to become a complainer. But I don’t understand, how.. USB can be broken so quickly after just using 1 year, which never has happened to me my entire computer life. (oh yeah.. that’s quite a bit of years. ūüôā )And I don’t think the port is broken. I just think that the power management sucks with this machine. Do I need to spend almost 300 euro to use USB and having one more of Ethernet/Audio ports..? Wait, I got this laptop with money too! How much was that..?

Oh well, there is going to be even more expensive solution for this. The Belkin docking system, which is going to be released soon.

This machine will be 50 something euro more expensive, and probably no thunderbolt cable will be included. However there are two thunderbolt ports together with Firewire. 2 USB 3.0 ports too. So yes it is a bit different. But I think it’s too expensive.

But you know, I thought this is too much for replacing USB anyway. There should be another solution, or maybe I couldn’t find a nicer solution with this laptop.

Oh well, I don’t know if I’d buy another apple stuff again. Because I don’t think I would have prevented this by using differently. If anyone has a better idea of this, please let me know.. !

Good luck with your computers. Treat well, and even after you do and it betrays you, stay calm and meditate. ūüôā

 

How to install Archlinux on MacBook Pro 8,2[Part.2]

In Part 2, we are going to discuss how to install Xorg-server and work nicely with it. (Part 1) The problem is that, currently (if you have followed as Part.1) Xorg-server will run with framebuffer, not from the video card you have inside Mac. In Macbook Pro 8,2 there are two video cards ATI radeon and Intel. We are going to use ATI even though two graphical cards should work nicely with the strategy below.

The issue of not using video card without any tweak is because of¬†KMSmode. On EFI system, it is using EFI system bootloader, which is¬†different from bios one as in any os booting CD or Windows¬†system. This will prevent the KMS mode to be on, otherwise the system¬†won’t boot. Last time, we turn off the KMS setup by doing ‘nomodeset’¬†on the grub setting and this made the KMS to be turned off. However¬†without KMS, Xorg-server won’t work with the video card, rather it¬†will complain that the modeset is wrong for itself.

So what we need to do is
1. apply patches for Radeon video card on Linux kernel
2. compile the kernel for that
3. Create a vbios emulation which will be copied from any bootable CD
4. Set modeset to the other way around; turn on the KMS mode.

So I will go step by step.

1. Apply patches for radeon video card on Linux kernel.

Thankfully, there is a github of patches+kernel of ‘fooblahblah’ so that you can¬†download.

There is PKGBUILD file included so that you can patch them. However I wanted to add some patches for macbook pro so that I
corrected the PKGBUILD a bit and added some patches. The patches can be found here with explanations.

2. Compile the kernel

Before doing this, make a back of your files /boot/initramfs-linux.img and /boot/vmlinuz-linux (no need if you compile those files with different name, which is recommended)

Now we can compile. If you have made the pkg correctly, then you can use

pacman -U filename.tar.bz

to apply the patch, and it will create a new linux-mainline img file for you.

3. Create a vbios emulation which will be copied from any bootable CD

Now we are going to make video bios from any of bootable bios cd.
I used archlinux liveCD for that.

This is how to;
-boot from the CD
-type 
 dd if=/dev/mem of=vbios.bin bs=65536 skip=12 count=1
 dd if=/dev/mem of=/boot/int10.bin bs=4 skip=16 count=1
-copy the vbios.bin and int10.bin into /lib/firmware/radeon and /boot
That's all.

4. Now we are going to correct the grub.cfg file.

This is a part of my grub.cfg file. Go down through the file and find the right place.

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Arch Linux GNU/Linux, with Linux mainline kernel' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-mainline kernel-true-a8ca6c35-c261-4b1c-9858-88a12804302d' {
 load_video
 set gfxpayload=keep
 insmod gzio
 insmod part_gpt
 insmod ext2
 set root='hd0,gpt4'
 if [ x$feature_platform_search_hint = xy ]; then
 search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt4 --hint-efi=hd0,gpt4 --hint-baremetal=ahci0,gpt4 a8ca6c35-c261-4b1c-9858-88a12804302d
 else
 search --no-floppy --fs-uuid --set=root a8ca6c35-c261-4b1c-9858-88a12804302d
 fi
 loadbios /boot/vbios.bin /boot/int10.bin
 echo 'Loading Linux mainline kernel ...'
 linux /boot/vmlinuz-linux-mainline root=/dev/sda4 ro loglevel=7 radeon.modeset=1 i915_lvds_channels=2 i915.modeset=1 i915.lvds_use_ssc=0 acpi_backlight=vendor vt.handoff=7
 echo 'Loading initial ramdisk ...'
 initrd /boot/initramfs-linux-mainline.img
}

Then you will be able to boot and your video card should work now with KMS mode. If you have an external monitor, your now it will
automatically work as well.

To install Xorg-server and setting up the monitor, there are many documents for instance, here

Some Remarks

– Do not update your linux kernel after you compile it. Freeze pacman¬†into a certain date. I closed up ‘core’ repository on the mirror¬†file for pacman. (/etc/pacman.d/mirrorlist)
РIf anyone with another model of macbook pro with nVidia video card there is a patch for that too.
-Do not forget to install the video driver from pacman : xf86-video-ati, xf86-video-intel
-On the video card setup for Xorg-server, two videos are not working together so far. I use radeon.

References:
http://ubuntuforums.org/showthread.php?t=1695746&page=85
https://bugs.freedesktop.org/show_bug.cgi?id=26891
https://help.ubuntu.com/community/UEFIBooting#Apple_Mac_EFI_systems
http://www.b1c1l1.com/blog/
http://cgit.freedesktop.org/nouveau/linux-2.6/commit/?id=c9b07e9e85e5b7fe38c9f009967e8bed51d3760b

How To Install Archlinux on MacBook Pro 8,2 [Part.1]

After a long time struggling, finally I am able to write this post on Archlinux!

The reason why I choose Arch; simplicity/configurable/curiosity

I am not a long-term linux user yet, and this installation process has helped me to understand further how the system works. Especially, this apple product made it extra hard, which challenged me even more. I had so much fun(?) and quite happy for now.

I thought it is really necessary to post this, since when I was installing, I had lack of information especially on MacBook pro 8,2. Some existing post for me was very confusing ; this is probably because I am not mature enough on this world. I wish this can be a help for people like me.

Part 1 is going to be focused on the installation process, and Part 2 is to work with Xorg-server by configuring those two problematic video cards!

0. Before you install

-Install rEFit on OSX for choosing the boottable partition. I have seen some complains that this doesn’t work on OSX, but it works fine without any issue.

-check your harddrive name; in orx ->disk0s1 disk0s2 but in Linux -> sda0 sda1. You should know which hard drive you are going to use in order to avoid an accidental erase of your other system.

You need to be able to use either ‘nano’ or ‘vi’ in order to edit some files on the process.

1. Choosing the right installation method

You will need a cd room for installation. The UEFI system on apple machin makes tricky to install from USB. This is the same as any other installer such as Ubuntu.  I will not talk about how to make partition. This can be done with DiskUtility from OSX.

I installed first with the official iso, and yes you can install with this. But there is a bug when you meet the moment to choose which harddrive partition you would like to install. So I choose ‘Archboot‘ Download this iso for macbook pro.

Download it -> make a CD -> boot with CD (pressing C button when booting)

2. Remarks on Installation Process

Then there is setup process. I will explain only remarkable parts because the installer is quite friendly and there is a wonderful document ‘Beginner’s guide’¬†After you setup font/date etc, you will enter here.

   Menu2: Prepare hard drive 

Do not use the first option ‘Auto-Prepare’ which will erase all data from the harddrive. Go to the 4th option ‘Set Filesystem Mountpoints’

This is to set where you would like to install the system.

If you have an extra partition for swap, set up here too. I set one swap partition and one main one with ‘EXT3.’ (Some how EXT4 had more trouble with booting. Ext3 is more stable for me.)

It will ask for¬†label¬†and additional setup, which you can skip, but I set up the¬†label¬†only as ‘Arch.’

Then it will prepare the partition for you.

**warning message -> /boot is not set : you can ignore this unless you have a different partition for the booting sector. I did on .’/’ .

Then it will install the core system for you. Packages were already choosen by default and you can just follow it easily.

After that, it will show a menu for system¬†configuration. Please check the beginner’s guide for any other information

For MBP, here you need to do somethings like;

mkinitcpio.conf : add on the MODULE=”ahci libahci’

pacman.conf : go down to mirror connection-> remove ‘#’ mark for [core][extra][community] sections.

  Installing Bootloader

There are two options ‘Refind’ Grub2′. Either is okay, but I only tried here with Refind. This will be installed on your top partition for EFI drive. (/dev/sda1) I was frightened¬†when I realize that. rEFind is fine for anything, but your kernel will be uploaded up there, and then you will have to mount this partition all the time. So I recomment ‘Grub2’ which is easier to figure out, and many information is out there to help you.

The installer will lead you to the ‘editing’ the configuration for grub. Skip this part because any way you should come back and install grub again!

Then the installation finished.

3. After the installation; the real war

Reboot and come back to CD. then do;

 mkdir /mnt/arch
 mount /dev/sdXX /mnt/arch ###X is your system partition number. mine is sda4
 cd /mnt/arch
 mount -t proc proc proc/
 mount -t sysfs sys sys/
 mount -o bind /dev dev/
 chroot .

(You can do this whenever you need to configure the new system from the LiveCD.)

Now you get into your new system. Here you are going to install grub correctly and configure.

Install grub

mkdir -p /boot/efi

mount /dev/sdXX /boot/efi ### yes you are mount the disk you are in into the booting erea.sdXX for me is sda4 again.

grub-install --directory=/usr/lib/grub/x86_64-efi --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=arch_grub --boot-directory=/boot --recheck --debug

Create the configuration file;

grub-mkconfig -o /boot/grub/grub.cfg

That’s it.

Then let’s check the grub.cfg file. Go down a bit and find like this;

/boot/grub/grub.cfg
menuentry 'Arch Linux GNU/Linux, with Linux mainline kernel' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-mainline kernel-true-a8ca6c35-c261-4b1c-9858-88a12804302d' {
 load_video
 set gfxpayload=keep
 insmod gzio
 insmod part_gpt
 insmod ext2
 set root='hd0,gpt4'
 if [ x$feature_platform_search_hint = xy ]; then
 search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt4 --hint-efi=hd0,gpt4 --hint-baremetal=ahci0,gpt4 a8ca6c35-xxxx-xxxx-xxxx-xxxx
 else
 search --no-floppy --fs-uuid --set=root a8ca6c35-c261-4b1c-9858-88a12804302d
 fi
 echo 'Loading Linux mainline kernel ...'
 linux /boot/vmlinuz-linux root=/dev/sda4 ro nomodeset
 echo 'Loading initial ramdisk ...'
 initrd /boot/initramfs-linux.img
}

-‘root’ part will be shown up with UUID. check your UUID of your disk and see if that matches. (don’t worry if it looks not exactly the same as this. I added some things too. We’ll discuss it later.)

ls -l /dev/disk/by-uuid/

-Important!!! : there in the middle of the ‘grub.cfg’ file, you can see ‘ro’ and you won’t see ‘nomodeset’, which you will need to add like I did. Otherwise your videocard will prevent from booting. We are going to do the videocard set up later on. For now we set up like this.

-Copy ‘grubx64.efi’ in /boot/efi/EFI/arch_grub/ into¬†/boot/efi/EFI/boot/bootx64.efi in order to make a backup. This will prevent any problem from linux kernel upgrade.

Now you need to re-generate initramfs-linux.img file. Do it as below;

mkinitcipio -p linux

Then please check on /boot directory if you have those two files;

initramfs-linux.img 
vmlinuz-linux

Then go boot to OSX. We are going to set the efi booting.

on terminal :

mkdir /Volumes/esp
 sudo mount -t msdos /dev/disk0s1 /Volumes/esp   ####disk0s1 here should be your linux system partition; it can be disk0s2, disk0s3 etc.
 sudo bless --mount /Volumes/esp --setBoot --file /Volumes/esp/EFI/arch_grub/grub.efi

This worked for me only once, and I cannot explain why it is not working anymore.

If this doesn’t for you, try to install ‘OSXFUSE’ together with ‘fuse-ext2’ on OSX, which will support mounting ext2, ext3 format on osx.
This is the way to do with those tool;

sudo fuse-ext2 /dev/disk0s4 /Volumes/arch -o force

If bless doesn’t work after all you have tried, this worked for me too;

sudo /usr/sbin/bless --device /dev/disk0s1 --mount /Volumes/esp --setBoot --file /Volumes/esp/EFI/arch_grub/grub.efi

Now you should be able to boot to the new system. Check if refit can show your partition.

Please feel free to ask any question. I have spent quite a few days to figure this out, and I think I know all possible errors it can take. I did this procedure over 10 times, and wrote this by heart.

Blacklist some modules;
 go to /etc/modprobe.d/modprobe.conf and add
blacklist sdhci-pci
blacklist sdhci

I didn’t explain how to configure all the other files such as /etc/rc.conf. Those can be found on the arch wiki page below. So please do not think that this is all that you need.

I will see you on Part2 soon!

References :
grub2: https://wiki.archlinux.org/index.php/GRUB2
MBP on arch: https://wiki.archlinux.org/index.php/MacBook_Pro_8,1_/_8,2_/_8,3_(2011_Macbook_Pro)
https://wiki.archlinux.org/index.php/MacBook_Pro_8,1_/_8,2_/_8,3_(2011_Macbook_Pro)
https://bbs.archlinux.org/viewtopic.php?pid=1117490