Showing posts with label gnu/linux. Show all posts
Showing posts with label gnu/linux. Show all posts

Saturday, 21 January 2017

JOURNEY TO THE FREEDOM PART II.

Liberating PC

 

0. Preparation and optional steps

Optional steps are marked as optional, all the other ones are mandatory. Also review Part I. of this series.

SSD (optional 69,99) - you might want to keep the original disk, but SSD will speed it up significantly.
I've chosen Silicon Power SSD S55 240 GB, due to its price and performance. It's often performing in the same performance level as more expensive models. You can read the review for example here Silicon Power SSD review (czech language), or you can find the reviews in your language on the internet. One note: according to the reviews the 240GB version perfoms better than the 120GB one.

Thermal grease 5- I will need to change the original grease due to its age and performance. I picked up well known and one of the best: Arctic MX4 (specs here). You can also borrow one from a friend as you will not spend all of it for this task.

OS and installation media - I have created bootable live USB with Trisquel 7 on it. I'm not using CDs for installation due to the speed and also using the USB is more convenient in terms of experimenting with various OS installations. I've used tool called Unetbootin to create the live bootable USB, but there are many other ways on how to do it using plenty of different tools and using Windows/GNU+Linux or MacOS. The reason to choose Trisuqel was that it seems to be widely used in the community which (hopefully) means better support. You can also choose different OS which is fully free when you take a look on the list in the 1st part of this series.

Installation of Trisquel 7 - I have installed it on the SSD right after I replaced it. The replacement of HDDs itself takes few minutes. I want to have the Trisquel installed before I flash the Libreboot just to be sure, although nowadays it's possible to reinstall OS when using Libreboot  without reflashing the ROM. Installation itself is pretty straightforward - you can find the guide here.

Determining the ROM size (optional) - This step is optional if you're going to follow my recommendations to buy both 8 and 16pin SOIC clips because there are 2 possible ROM sizes available on these laptops - 8Mb (16pin) and 4Mb (8 pin). You can get the size by booting any live linux distro and running: dmidecode | grep ROM\ Size . My is 8MB one so now I know which SOIC clip to use without disassembling the laptop.


EC update - It is recommended that you update to the latest EC firmware version as per Libreboot documentation before flashing to Libreboot. Fortunately my T400 had already the newest version of EC (checked by Lenovo tool in Windows 7 OS). Can be done in Linux as well, instructions here.

RAM (optional) -  according to the specs and rules mentioned in Part I.  I was able to buy 2x2GB for 20 which are compatible with Libreboot.


Checking Odroid C1 GPIO compatibility with the Raspberry  Pi - Odroid C1 specs . Since all of the tutorials on the internet are written for Raspberry Pi, I've decided to use my Odroid C1 to demonstrate it can be done with it as well. This is mandatory in order to know what to connect and where even though the GPIO on C1 is compatible with Raspbbery PI. I've put together excel table with pin layout and cable colors based on my setup on SOIC clip which is shown below.

SOIC clips
GIANT WARNING - if you don't have HUGE amount patience and don't want to loose many hours trying I suggest you tu buy POMONA clips instead of the clips I've bought - Pomonca 5250 (8pin) and Pomona 5252(16pin). The reason I've bought SOIC clips from China was the price  (cca 4x cheaper than Pomona). I did one mistake at the time of ordering as I didn't notice that the pins on chinese clips are way too close to each other to use them with the jumper cables without modification.


Comparation of Chinese and Pomona(blue) clips:



If you have already ordered the same clips as I did, or you just think that 20$ is way too much for 1 piece of little plastic thing, you will need to modify those clipsand wires as I did. The basic concept is to connect the jumper wires in the way that they they are isolated from each other so there is no short circuit at the end.

How I did it:
The first thing to do is to remove black plastic cover at one end from the jumper wires. After that you will need to use pliers to push the naked connector to make it thinner a little bit more to have enough space for all the jumper wires. If you push it too much you will not be able to conenct it to the clip pins. It takes some practice and few damaged/unusable wires to get used to it. Next step is to use heat shrinkable tube for every 2nd wire to insulate it. The reason to use it on every 2nd only is again to have as much free space between the pins as possible. I've bought the thinnest shrinkable tubes available in my city. Final step is to fix all the connected jumper wires altogether - I've used bigger heat shrinkable tube to fix them with the clip. The reason for this is simple - you don't want to touch exposed wires when flashing and you don't want the wires to be moving and potentially disconnecting from the clip during the manipulation.
   Of course you need to use multimeter to ensure that there's no short circuit at the end between any of the pins and to ensure that you have connectivity from the end of connected jumper wire and the corresponding connector on the clip. DO NOT try to flash the chip without verifying these with multimeter.










I. Laptop disassembling

I've used following video to disassembly the laptop fully. As mentioned in the Part I, the T400 model requires complete disassembly to expose the chip. Experienced user can do it in ~ 1 hour, so it may take few hours to disassembly it completely for non-experienced users. You can use following link to see step-by-step disassembly with photos as well. I have also taken some photos during the process with my smartphone as this model contains many small parts / cabling so I can use it later on when building it back .





II. Locating the SOIC chip and connecting the SOIC clip

The chip itself is located between the chipset chip and ram slots as shown here (photos taken from here:


Second picure also shows the pin numbering and orientation on this 16pin chip. I have downloaded Odroic C1 GPIO specs and also the Macronix chip diagram: 













Be sure to have your Odroid/Raspberry/any flashing device powered off before connecting the SOIC clip to the BIOS chip.

Odroid C1 GPIO numbering is printed on the board so it can be easily determined how to connect to the correct pins when  using the previous tables:











After I have connected everything and checked 2-3 times if the order is correct I have turned on my Odroid C1. Btw I have Ubuntu 16.04 running on my Odroid, Also I have connected it to my LAN via ethernet cable so I can do the flashing  remotely via SSH so I don"t have to attach any display to the Odroid.

III. Flashing

I suggest you to do everything as a root to have full permissions. 
First thing to do was to download flashrom/other utilities needed and extract them:









I had to download libreboot ROM which had to match my bios chip size as well:



Then I needed to load SPI modules in order to be able to read/modify the ROM as I didn't see any spi device under /dev. After little bit of digging I've found following on Odroid forum, so I just had to execute following:

root@odroid:~# modprobe spicc
root@odroid:~# modprobe spidev
root@odroid:~# ls /dev/spidev0.0
/dev/spidev0.0
root@odroid:~#

So now when I have the modules loaded, I've tested to read the ROM chip afterwards which was not successful at a first time, so I had to power off Odroid, check if the clip is connected correctly and repeat the check again. Luckily it was successful for the 2nd time :) and I saw following:


Next step was to change the MAC address inside the libreboot image to match the MAC of the integrated gigabit LAN I have on the T400. This MAC can be found either on the sticker located on the motherboard and/or sticker on the back of laptop. You can see couple of my typos :).


Of course, in case of any problems I had to do the backup of the original Lenovo ROM. This procedure also involves rom read check - saving at least 3 attempts to read the original ROM and comparing their md5sums. All the sums must mach and you must not continue without md5sums being the same for all the attempts. As you can see I had luck and all the attempts to read the ROM yielded into the same result and all the md5sums matched. So I was confident that the setup is 100% correct:



Now let's proceed to the flashing itself. I was lucky enough to get it flashed on the 1st attempt, but that's not always like that as per Libreboot documentation:

"You might see errors, but if it says Verifying flash... VERIFIED at the end, then it's flashed and should boot. If you see errors, try again (and again, and again); the message Chip content is identical to the requested image is also an indication of a successful installation. "

Also it's recommended to use short jumper wires for better signal, in my case I've used 10cm ones, This makes the manipulation complicated though. But that's maybe why I've done it on the 1st attempt:


IV. Assembling the laptop back.

Nothing special here, I just had to be careful as there are few tiny parts. Also I have changed the thermal grease for CPU and northbridge on the motherboard during the process.
  As I was not sure whether the whole process was really successful I did try to boot it without palmrest and keyboard fully assembled back, I just connected the wires. Btw I've used the same video to assemble it as to disassemble it among with photos taken during the disassembling. Also photos from Libreboot documentation are helpful as well.

V. Boot it!

So I held my breath and pushed the power button. Voila ! It booted successfully :


























And a screenshot from Trisuqel 7 booted via Libreboot:


















Conclusion

Now I have my hardware paired with pure free software, but journey to the freedom is only at the beginning. There are many other challenges awaiting to free myself from the proprietary world where possible. I will share my progress here, so you can expect bunch of other blogs related to this topic in the future. I'm going to flash the MB with 4mb chip (8pin) as well so I  will put a brief update here.



Sources used:
https://libreboot.org/docs/install/t400_external.html
https://github.com/bibanon/Coreboot-ThinkPads/wiki/X200-X201-Hardware-Flashing
https://github.com/bibanon/Coreboot-ThinkPads/wiki/Hardware-Flashing-with-Raspberry-Pi
http://pi4j.com/pins/odroid-c1.html

Monday, 12 December 2016

JOURNEY TO THE FREEDOM PART I.

Liberating PC  

 

 Disclaimer 

It's not a purpose of this post to describe what free software, libreboot and other terms mean.
Following are good sources for such information:
http://www.fsf.org/
https://www.gnu.org/
https://stallman.org/
https://libreboot.org/
... and many more

There are plenty of videos/presentations on the internet where Mr. Stallman and other people describe what free software is and why do we need it, just use your favorite web search engine to find it out (apart from Google - see here why https://stallman.org/google.html).


I. Introduction

It all began when I've randomly found a video presentation where Mr. Stallman presented his view and why we should be using free software. Although I already knew some of the things before, I didn't firstly realize that it's so important to be free (not only) in terms of software and why.

The aim I've set to myself was to have a HW paired with SW without any proprietary software used or needed to operate fully, which includes BIOS/firmware/OS etc. Also I consider this blog as kind of "donation" to FSF/GNU/Libreboot by spreading their word to the public.

II. Hardware

 

This is the most important part as there are not that many options when I want my platform to be completely free. No new recent HW is supported by libreboot, you can find why for example here: https://stallman.org/intel.html
https://libreboot.org/faq/#amd
 
So I'm limited to the HW which is being supported by libreboot currently. Here is the Libreboot's Hardware compatibility list: https://libreboot.org/docs/hcl/

I've made list of available options for me:

Option A:

Buy a refurbished HW preinstalled with libreboot and GNU/Linux, some suppliers are listed here: https://libreboot.org/suppliers/.
This way I can support the community as some of their profit goes to FSF / Libreboot as well. Unfortunately there are few reason I won't go this way:
 ➧ too expensive IMO
 ➧ I'm kind of DIY guy and I'd like to liberate my HW by myself

Option B:

Buy used/supported HW and liberate your HW by myself. I've chosen this way as I like to hack stuff.

III. My approach 



I've managed to buy ThinkPad T400 for 120€ among with the power cable and docking station. I've also bought couple of spare parts for 50€ (monitor, motherboard, CPU, palmrest etc) in case I break something.
The specs are:
CPU: Intel Core2 Duo P8600 (2x2,4GHz)
GPU: integrated GM45 (some T400 models come with dedicated ATi which is disabled by libreboot after the flash due to lack of free drivers)
RAM: 2GB
HDD: 250GB
Display: 14,1 inch  1440x900 resolution
Battery: still lasts for 1,5hrs

It came preinstalled with Windows 7, which will be soon reinstalled with one of the FSF endorsed GNU/Linux distributions - https://www.gnu.org/distros/free-distros.html.
It looks fairly OK in overall- even though I didn't change anything yet:









I think it fits my requirements pretty well - size, build quality - and what's the most important is that it's libreboot compatible. Also I wanted to use the most up to date HW supported by Libreboot.

Please note that the T400 (not only) requires disassemble of the laptop and messing with external flashing device to successfully flash BIOS ROM in order to replace it with libreboot and someone may find it as overkill. If that's the case you can choose Lenovo ThinkPad X60/X60s instead, which are flashable directly from the operating system. The downside of those models for me is that they are older than my T400. Also it's worth to mention that there are models which do not need complete disassemble - e.g. ThinkPad X200 to be able to flash the ROM.

IV. Additional HW/accessories needed

  • Flashing device - Beaglebone black, Raspberry Pi, anything RPI GPIO compatible - I have Raspbeery PI Model B and Odroid C1 already at home :)
  • Jumper wires - female to female - I have ordered 40pcs for US $0.64 from China: https://www.aliexpress.com/item/Free-Shipping-1lot-40pcs-lot-10cm-2-54mm-1pin-femal-to-femal-jumper-wire-Dupont-cable/32329983091.html
  • SOIC clips - I recommend to buy both 8 and 16 pin as in case your current MB fails you are still safe to flash both types of ROMs in case you buy another MB, without wondering what type of ROM does the new MB have. I have ordered following again from China, for ~US $7:
    https://www.aliexpress.com/item/Free-Shipping-1pcs-lot-Programmer-Testing-Clip-SOP16-SOP-SOIC-16-SOIC16-DIP16-DIP-16-Pin/32483896048.html
    https://www.aliexpress.com/item/Programmer-Testing-Clip-SOP8-SOP-SOIC-8-SOIC8-DIP8-DIP-8-Pin-IC-Test-Clamp-no/32584191276.html
  • Thermal grease - since I'll be disassembling the laptop completely I'll need one to replace the old grease which has often worse attributes than e.g Arctic grease
  • WiFi card - I need to replace it for the one with Atheros AR5B95 chip (Libreboot's recommendation) as it's working with free drivers (the original Intel requires proprietary blob).
    I've already bought used AzureWave AW-NE785/NE785H (AR5B95) 802.11b/g/n Wireless PCI-e Module for 6€
    It is important to know that this wifi card will be only functional after the ROM flash as the original Lenovo BIOS doesn't allow to use non-whitelisted cards
  • SSD (optional) - to speed the little T400 up. I will buy some cheap 256GB SSD and update here the specs once I have it. I want to install it to the laptop right before I flash the ROM, among with GNU/Linux
  • RAM (optional) - again to give it a little bit of more horsepower. I plan to buy 2x4GB somewhere on eBay. It is important to take Libreboot's recommendation into account
    "
    You need DDR3 SODIMM PC3-8500 RAM installed, in matching pairs (speed/size). Non-matching pairs won't work. You can also install a single module (meaning, one of the slots will be empty) in slot 0.Make sure that the RAM you buy is the 2Rx8 density

V. Outstanding tasks

  • Buy SSD, thermal grease and RAM modules bearing in mind all the requirements ( I will update the results and specs here)
  • Decide which GNU/Linux distribution to use
  • Study the flashing process using the Raspberry Pi

Conclusion 

Once I have all the hardware parts ready I will start with OS installation and ROM flashing. I expect this to happen around mid January 2017. I will publish the whole process in Part II of this series trying to explain as much as possible.


Let's go to see how I performed in the next part - Part II.