Tuesday, 19 July 2016

Upgrading WiFi on a Lenovo Ideapad Y500

I have been the happy owner of a Lenovo Ideapad Y500 laptop for a few years now. Recently I noticed that 5 GHz dual band WiFi cards are getting really cheap on eBay. Because my laptop only had a 2.4 GHz WiFi adaptor, and there are about 40 neighbours competing for a 2.4 GHz signal in my living room, I figured the time had come to get a new WiFi card.

While Lenovo uses standard mini-PCIe WiFi adaptors in this laptop, they combine it with a thing called a whitelist, apparently to prevent me as a so-far happy owner from turning this laptop into an illegal radio device. Unfortunately this would also force me to only use the hard-to-get Lenovo-approved WiFi cards, instead of better and much cheaper alternatives. But fortunately the whitelist is stored in the BIOS of the laptop, and the BIOS is stored in a flash chip. So in principle, I could change it.

A quick search across the Internet found an extensive community of people dealing with the whitelist phenomenon. There even was a hint of a tool to automatically patch a BIOS dump and generate a new version ready for flashing. But to make things more interesting, after googling every relevant term I could think of, I had to accept that it was not available as an easy download for me. My next plan was to get a dump of the BIOS and patch that myself to make it behave. 

Conceptually, this whitelist-thing can be fixed in two ways: make the computer ignore it, or put my new WiFi card on the list. As these things go, the former is the nicest and the latter the easiest. Removing the whitelist would need figuring out where the code sits that checks hardware against the whitelist and bypass it. This would have taken some serious effort with IDA, which I hadn't touched for years.  Changing the whitelist itself is potentially easier, assuming that the check is done against PCI IDs. But my Internet search had already turned up that this was the case, so in principle an s/APPROVED_ID/MY_ID/ would be all that was needed.

Getting the BIOS dump itself was straightforward using something called fpt.exe in FreeDOS. Unfortunately, since the 80s, BIOSes are compressed and checksummed and whatnot, so a tool is needed to deal with this before modifications can be made. The good news here is that such a tool exists: PhoenixTool.exe a.k.a. Andy's tool. The less good news: it errors out under wine, so we need a real Windows. The only copy of Windows in my house spends its marginal existence on a small part of the harddisk of the Lenovo laptop, only to be woken in cases of need like this one.

After an hour of overdue updating Windows, I downloaded PhoenixTool. Using it I managed to extract a MOD (essentially a BIOS section) file that contained the whitelist. After matching a list of Lenovo-approved cards and their PCI IDs against the bytes in the file, I knew what to change and where. 

After a few weeks of waiting, the new WiFi card fell on my doormat, fresh from China. I inserted the card in a mini-PCIe  to PCIe converter, put that in my desktop computer and used lspci to get the PCI IDs of the new card. Both the system and subsystem IDs were needed.

lspci data of the new WiFi card: ID=8086:08b1/8086:4160.

Using Jeex, I patched the IDs of a card that I do not own with the new one in the whitelist. I left in the ID of card that came with the laptop alone, just in case. Then back to Windows and PhoenixTool to replace the original mod with the hopefully improved one. After the replacement step, PhoenixTool had made a backup of my original BIOS file ("biosback.bin.old") and had minted a new "biosback.bin". 

Flashing the new BIOS proved tricky, as some kind of flash write protection was enabled and fpt.exe failed to update my new BIOS. The solution was using "prr.exe" that removed the protection. The next fpt run reported everything a-ok, so I hit the power button to switch off (FreeDOS, remember).

After restarting the laptop I went from a feeling of enthusiasm and suspense, via mild alarm, to full panic within a time span of about ten seconds. After the initial boot, the keyboard backlight switched off, the screen stayed blank and the fan started spinning at full speed. The only response of the laptop was a shrill beep when I removed the power plug, and the same beep when I put it back in. Bricked as it is called.

Some searching revealed that these laptops have a recovery mode ("Hurray"). The procedure to follow here is to remove the battery, unplug the power brick, insert an USB stick with a replacement BIOS image, press and hold a magic key combination, plug in the power brick, press the power button and only release the magic keys after 6 seconds or so. Important additional information here is what key combination, and what to name the replacement BIOS image. Searching the Internet revealed that the most likely  key-combo for a Lenovo ideapad laptop would be Fn+R. The name of the BIOS image was a bit more tricky. 

When loading the BIOS image in PhoenixTool before, a dialog box popped up stating something about recovery. At the time I did not know nor care, so I just clicked it away. As it turned out, this was crucial information for recovering from a bad flash: it was the name of the recovery BIOS image file! Now please remember that this laptop was the only computer capable of running windows in my house, so I had no way to run PhoenixTool.

Fortunately I am often a bit stupid, but I do have my moments. Before flashing the BIOS, I had copied all files related to this adventure to another system. And one of these was a log-file generated by the PhoenixTool. Somewhere in there it stated "Recovery Filenames are: QIWY3.bi?". Yoohooo!

So I got an official Lenovo BIOS update file for this laptop, I managed to extract a rom-file from the .exe, put it on a FAT-formatted USB stick as qiwy3.bin, plugged the stick in the laptop, and followed the recovery procedure. And oh joy, the light on the USB stick flashed, there was a pause, and then a series of long flashes, consistent with reading a large file from the stick. After that there was a few seconds pause, and the laptop rebooted..... And it was still stuck. I gave it one more try and got the same results. Time to think things through.

By now, I knew I could start the recovery, that the USB stick was recognised, and that the BIOS image file was read (most likely). So the observed behaviour was consistent with an invalid BIOS image. After reading, it would be checksummed or otherwise verified (the few seconds pause), it would be rejected, and the flashing code would reboot the laptop.

So another BIOS image was needed. But the one I tried was from the manufacturer's website, and I had no way to get something else. Except for the original BIOS image that I started with, that is. So I tried that one, and... success! I had a working laptop again. And, for future experiments, I had a proven method to recover from a bad flash. So all in all this counted as a victory of sorts.

The next step was to figure out what went wrong with patching my BIOS. More searching on the Internet was sometimes confusing (for example: "Never start from a BIOS dump" according to one expert, "Start from a BIOS dump" according to another). But it turned out that my approach of editing mod files was somehow wrong. The proven way to make the modifications was to have PhoenixTool split the BIOS image into ROM-files, modify these, and let it reassemble the BIOS again from the ROM files. 

Once I figured this out, everything went smooth. I found the ROM file to patch, made the change, let PhoenixTool reassemble the BIOS, flashed it, and everything worked as it should. The new WiFi card reaches 300 MBps at 5GHz, and even gets better speeds than the original card in the 2.4GHz band. And I got this nice experience to share with you on this blog.

So in the end, I consider this a success...

Success!!!
(I am thinking about adding Tux as a boot logo, but for now I decided to keep things as they are.)

Friday, 3 January 2014

Again ARM boards

Introduction


During the Christmas holiday I got a brain wave that it would be nice if I could record television in Japan and watch it at home. In the past I had a recording system based on freevo and that worked quite nice. I should be able to have something similar when it was possible to install a small ARM based linux system back in Japan.
The figure below gives an idea about what I want to make:

Picture will follow!!


I am already the owner of a Beagleboard XM, a Pandaboard and a Raspberry Pi. All three were nice to play with, but not so suited for this new project. So I started to look for a board that would be more suited for this project.

Board comparison

I am looking for the following:
  • A separate network, usb and preferably Sata interface to prevent bottlenecks during recording and streaming/copying the contents.
    The Beagleboard, Pandaboard and Raspberry Pi do not score well on this point; the network and USB are connected over the same bus interface to the soc. And this proved (with old kernels) to be a clear bottleneck. Also no sata interface available.
  • A bit horsepower to encode the recordings in a smaller format.
    This disqualifies the Beagleboard and the Raspberry Pi. Both have some support from their DSP or graphical coprocessor, but that is not enough to re-encode movies from 1080p to something smaller.
  • A convenient form factor so that I can build it in a need box.
    This means that the board should be small and the connectors should be placed in a smart way. The Pandaboard has for instance the disadvantage of a large combined connector for ethernet and USB, which makes this board very high
I am not after real time decoding (and encoding) of HD streams and I am not using a GUI/Desktop on the board. This gives me the advantage that I don't need the (3D) GPU support and I don't count on much added value of the VPU. In general are those two not very well supported under Linux on this kind of boards due to all kind of IP issues.  I will be not hindered by the lack of support on this.  The support of the wireless module (wifi and bluetooth) can also be an issue in general but that is a functionality that I don't need. This makes that I can probably use an "early" adaptor board with only limited kernel and hardware support.  This opens a bigger range of possible boards.  

Someone has already spend some time on a nice overview of different development/hobby boards. This overview you can find; here. The table below summarises the comparison on the for my project important points:

Board name: Pandaboard Cubieboard2 Odroid-U3 Wandboard Quad
Processor: TI OMAP4430 Allwinner A20 Samsung Exynos4412 Freescale i.MX6 quad
Architecture: Cortex-A9 Cortex-A7 Cortex-A9 Cortex-A9
Cores: 2 2 4 4
Frequency: 1GHz 1GHz 1.7GHz 1GHz
Memory 1Gbyte 1Gbyte 2Gbyte 2Gbyte
Sata: No Yes No Yes
USB Host: 2 + 2 2 3 1
Ethernet: 10/100 10/100 10/100 10/100/1000
Shop: digikey Conrad Hardkernel Denx-cs
Price: 150 Euro
75 Euro
110 Euro 118,94 Euro
Advantage: Already available (no additional cost) Relative cheap and with Sata. Sold by Conrad Very fast Fast and Sata
Disadvantage: Ethernet and USB over the same channel proved already to be a bottleneck in the past.
Memory subsystem not that good.
SD card and USB are slow.
Relative expensive compared with the others.
Except for the interfacing not really an improvement: Cortex-A7 is less powerful than Cortex-A9 and the Pandaboard was already slowish Must come from Korea which adds time and costs (shipping + tax) (Passive) USB hub needed
A bit unknown... how will the support be?

The table above shows clearly that of the four boards the ODROID-U3 is the most powerful one. Therefore it would be the most suited to decode /encode the video data in a smaller format. However getting this board in time from Korea can be a problem. The Wandboard is a good runner up in terms of price and performance.  I have ordered both and will see if I get the Odriod board in time or not.

Wednesday, 26 December 2012

XBMC on ARM: PandaBoard vs Raspberry Pi an Introduction

At last a new post.

This post will be the first in a series about my long on going struggles to get my HTPC system up and running. 

About 2 years a go I bought a Beagleboard XM and PandaBoard to use as replacement for my freevo based media pc.  This did unfortunately never worked out as I hoped; due to dedicated media players, partly finished software support and difficulties to cross-compile  Freevo; I had to continue to use my Atom+ION system.

But now (end 2012) is a new kid in town the Raspberry Pi. The very popular board as generated quite some effort to get the popular media centre software XBMC working to make the Raspberry Pi a low power but high performance media player. The guy's (m/v) of XBMC where already for longer time working to get the XBMC software working on lower powered platforms by all kinds of optimizations and this very popular Raspberry Pi with a good video (decoding) hardware has accelerated the work on this. My brother mentioned that XBMC worked quite nicely on the Raspberry Pi and that I wanted to see for my self. A Raspberry Pi is on it's way and I would like to use this waiting time to look what  the PandaBoard is able to do now the software is a bit more mature.

The development of Freevo has in the past year not moved much; which makes that Freevo as HTPC platform is loosing it's attractiveness.  XBMC here I come.
  • I have found that for there are a couple possibilities to get xbmc up and running on the Pandaboard; most involve quite a lot of do-it-yourself; I choose to go for now with GeeXboX; this only because it advertises a more or less seamless experience on the PandaBoard.
  • For the Raspberry Pi are three possibilities at the time available. To me it looked that the OpenElec distribution is the one to take because of a more active development.   
 I hope it will be not become too much of a feature comparison between GeeXbox and OpenElec.

Next to this introduction post will a few more posts follow (I hope at least that they will follow):
  • How does PandaBoard vs Raspberry look on paper..
  • Pandaboard and XBMC
  • Raspberry Pi and XBMC
  • How does this compare....
 Probably I will have to add a few posts on my struggles in migrating from Freevo to xbmc. 

  

Sunday, 3 June 2012

Finally: something on this blog

While this blog was started ages ago, it just sat idle. To start things off, I'll make a list of stuff on my mental to-do list. Hopefully, I'll get to do some of them in the coming months, and write about them if they prove interesting. 

So in random order:
  • Upgrade my mythtv setup to 0.25
  • Add automatic power on/off to a Sony subwoofer
  • Unbrick my Chinese apad and turn it into something useful
  • Finish a USB-connected VFD and IR receiver
  • Continue work on a vintage (internet) radio
  • Add bluetooth remote control to a Sony STR-DE497P surround receiver
  • Fix some faulty UTP cables in my house that do not work with 1000 Mbit
  • Implement some kind of synthetic full backup for duplicity
  • Find a job for the BeagleBoard-xM that I got from my brother
  • Do something with the RP6 robot my wife gave me for my birthday
As said, I'll try to work on these and I'll try to write about it. However, with two children (one a very recent addition), these things tend to stay on the backburner.