Saturday, July 20, 2013

Eliminate ads and custom screen saver on the new Kindle 4



It has been a while since the last time I posted something in this blog.
It's not that there hasn't been something interesting to post - there's simply not enough time.

Let me note here that this post is not intended to be either a step by step guide either a how to and that I'm not interested on writing one in the foreseeable future.
This is just a post with some notes that I am happy to share with the internet.
So no questions in the comments about the procedure itself will be answered (except if I find them interesting / worth the discussion)
You've been warned.

Kindle is a wonderful ebook reader device with the best eink display in the world that happens to run linux in the background. I love mine, and love reading with/on it.

Recently a friend of mine asked me to help him add custom screen savers to his brand new Kindle 4.
I have my own Kindle (a kindle 3 - with a keyboard) which I have already jailbroken and added a symbolic link to the appropriate folder to add custom screensavers on it. This is not a dificult task, you can find detailed guides all over the internet.

But this Kindle came with ads enabled so I was introduced with a new kind of problem.
Having no exact memory of the procedure I followed for my kindle 3, I did what I do most of the times (and try to somehow support with this blog)

I googled :)

What I found was some guides (like this one) which in sort, instructed to replace the %kindle_disk%/system/.assets folder with a file named the same.

There was little success.





The ads where gone, but the banner "please connect wirelessly to download the latest Special Offers" was still there. There were again guides (like this one) that instructed "a new way" of removing the ads AND the banner, by restoring to factory defaults, replacing the %kindle_disk%/system/.assets folder with a file named the same, just before setting up a your account details in the newly restored kindle.

I later found that the new version of the kindle OS (the 4.1.1) had this bug fixed, and since then, no workaround has been posted on the internet (or maybe I haven't found it) although I found some user comments that claimed that they successfully followed the guides.
But in my case nothing seemed to work, so I had to search more.

I wanted some insight/control of the OS so I searched for a way to open a terminal and look around. I remembered creating a file named %kindle_disk%/ENABLE_DIAGS and rebooting the device started the diagnostics mode in which I could find the "usbnet" and connect to the kindle through ssh. Although I could ping the device, the ssh port seemed to be closed and my connection was refused. I found out that these new kindles have the usbnet blocked(/disabled?). So my problem was now enabling the usbnet somehow...

I decided to try and jailbreak it first. I found the latest jailbreak for the previous version of kindle OS (4.1.0) (from here)  and gave it a try. It was successful, but I still couldn't connect with ssh in the diagnostics mode.

I decided to take it home and devote more time to it when I had some.



After a few days, I started trying again.
Now, what the kindle jailbreake actually does is (according to the "kindle-jailbreak-k4-1.6.N.zip" README file) "...NOTHING except open the door for other packages. Do not expect ads to magically disappear or internet to be unrestricted just by jailbreaking. In fact, don't expect those things at all."

Darn it.


Before getting the kindle home with me, I had already planned my next step. I had already found this thread and already downloaded the kindle-usbnetwork-0.49.N.zip file. After reading the README.FIRST file (that was harsh with windows users - and I liked it) and searching what the hell did it mean with "Nothing fancy, as usual, with a jailbroken Kindle, just use the appropriate update file." under the install section I was able to install the package just by placing the "update_usbnetwork_0.49.N_k4_install.bin" file in the  %kindle_disk%/ root folder and set my kindle to update.

Now, after reading some more of the readme file, I discovered that I can send commands through the search bar!

The commands I used:
 ;debugOn  
 ~usbNetwork  

Basically, when you hit enter, each command runs - it took me a while to figure this out...
I read somewhere that while debug mode is on, the power save mode is off and the battery will drain quicker. Anyways...

When I did that, I connected the kindle and voila! My ubuntu machine told me it found a new network connection. I had to set my ip on usb0 at 192.168.2.1

I did it with this command:
  $ ifconfig usb0 192.168.2.1  
Later I used the gui too

After that, when I tried to ssh to 192.168.2.2 I was successful.

I entered "mario" as my password and I connected to a secure shell. But the second time I tried to connect, my password was refused. After wondering for a while, I remembered that there is a way to generate a kindle root password with an algorithm using the device’s serial number.


I found the following python code:
  #!/usr/bin/env python  
 import hashlib  
 print("fiona%s"%hashlib.md5("XXXYOURSERIALXXX\n".encode('utf-8')).hexdigest()[7:11])  
Which gave me the password that logged me in successfully!


So now I started testing and searching all kinds of stuff. For example, I searched for every piece of image inside the kindle just to find the banner and delete it. I found them much later in /mnt/base-mmc/amazon/screen_saver/adunits/600x800/

I have to note here that I was getting tired copying with cp all the images i found in some folder in /mnt/base-us/ and reconnecting with usbNetwork off to see if any of the images had something to do with the banner. So I discovered a command named scp which copies files through ssh!


For example:
  $ scp -r root@192.168.2.2:/mnt/base-mmc/amazon/screen_saver/adunits/600x800 /home/%user%/Desktop  
Copies everything from .../600x800/ to the desktop


Neat!


Of course, amazon  coders had to do it a little harder than that. After deleting these images and connecting to the wifi for a while, the banner redownloaded and I was able to see it again. So I had to search a little more. I searched for "adunits" and found another folder at /var/local/adunits

I renamed the folder and created a file with the same name and chmoded it to 444 so that the system cannot change it

  $ chmod 444 adunits  


Note: I tend to do that to everything I change - that is backup and create a file with the old filename with different rights, because of two reasons:
Firstly, if I brake something, I can always recover it that way and
Secondly, if the system tries to change somthing, most of the time it won't be successfull.
And sometimes, if you're lucky enough, the code will just be satisfied with the existence of the filename itself, whether it is actually a file or a folder and wont sent a crash signal which will result in an unusable system. I found out later, after googling "adunits" that what I did was actually good (here) except I didn't restart the process mentioned. The reason I didn't find this article earlier was that it describes the procedure for kindle touch, which I rejected as non compatible after I clicked in some results and reading some instructions and tips.
I also tested the stop and start "framework" commands from this thread and it seems that the kindle 4 doesn't support these commands or doesn't have the framework process running in the same way.

Anyways

I had Success!!!




The banner was gone from the homescreen and from the screensavers! Now it was a matter of  creating a symlink from the screensavers folder to a folder in the kindle’s root folder /mnt/base-us/

I didn't bother to remember the syntax of  ln, I googled, found the code (here) and changed it a bit

 $ mntroot rw  
 $ mkdir /mnt/base-us/screensaver  
 $ mv /opt/amazon/screen_saver/600x800 /opt/amazon/screen_saver/600x800.old  
 $ ln -sfn /mnt/base-us/screensaver /opt/amazon/screen_saver/600x800  

I also copied the old 600x800 folder with the stock screensavers in another folder in case I wanted to use some of them.

Now, I just rebooted, disconnected, plugged in the kindle and loaded some screensavers in the newly created screensavers folder. After rebooting, the screensavers loaded successfully






So now, the kindle has custom screensavers and no ads!





Moral implications:   Removing ads from kindle is bad, mmkay?

This device is to be used for some free english e-guides and mostly greek e-books. Amazon’s ads clients aren't losing a potential customer.
Also, as it is mentioned here, Amazon is nice enough to sometimes unlock the ads for free to customers outside the ads’s main target countries. So, in a manner, I just made their job a little easier...




TODO:

Make ssh connection wirelessly posible by default

While I was lurking around with the terminal via usbnetwork-ssh, I was trying to get ssh work wirelessly. I wanted this for the following reasons:

1) Every time I had to reboot, I had to enter the commands to the homescreen to enable usbnetwork... a time consuming process since there is no keyboard and the typing is done thtough a keypad! (that's the main reason I got a kindle with a keyboard instead of the 4)
2)Every time I had to send or copy a file, I had to unplug, disable usbnetwork, plug it in, manage the files, unplug it and enable the usb network again...

So enabling wireless ssh by default would be nice and give me more free time to tether the kindle more.
What I've found already (and used) is this

 $ iptables -A INPUT -i wlan0 -p icmp -j ACCEPT  
 $ iptables -A INPUT -i wlan0 -p tcp --dport ssh -j ACCEPT  

Using either of these commands enables ssh over wifi.
Iptables configures firewall options. Porblem is, the firewall options are reset everytime the device reboots.

I stumbled upon an entry in /etc/init.d/network while trying to create a script to be run at startup that stated:

 # Install firewall  
   cat /etc/sysconfig/iptables | iptables-restore  
   msg "Installed Firewall" I  

After some research, I found out that iptables-restore does exactly that - it restores the iptables to its default configuration (I don't know though who and what decides the "default" configuration)

So I commented the lines. No luck...

I decided to ignore this problem and focus to the main one at the time. Now that I finished I will devote time to it again when I have some.

'Till then, thanks for reading!


Update:

So it seems a little more reading would get me through eventually.
 cat /etc/sysconfig/iptables | iptables-restore   
This line pipes the output of cat to iptables-restore...

So whatever I wrote in /etc/sysconfig/iptables would be run if this line was uncommented
So I did.
And I run it just to check it’s output and found that I made a little mistake in the syntax of some iptables configuration.
I fixed that but nothing seemed to work.



So I tried to make my own script that runs at boot

Meanwhile, I found this fellow (seems greek to me) that made a nice startup script and after a little research in linux init.d scripts I made this:
 #!/bin/sh  
 iptables -A INPUT -i wlan0 -p tcp --dport ssh -j ACCEPT  
 exit 0  
and saved it in /etc/init.d/wlanssh and made a symbolic link to /etc/rc0.d/K09wlanssh

After the reboot nothing happened of course.

Then I started understanding, the problem was that sshd wasn't running, because kindle 4 has it disabled by default and only by running usbnet can we enable it and make use of it.

True, running usbnet enabled wifi ssh too. There is a config file in %kindledir%/usbnet/etc/config
But I didn't know that. Or I didn't remembered. It seems that when I was playing around with ssh I first discovered the iptables command and then enabled the wifi in the config file (that runs exactly the same command at startup) but I didn't give it any other attention or meaning (I was propably to tired with the problem already)

I know it seems like a mess. It is.
It happens some times...

Before I re-discovered the config file and its uses, I tried to make a complete copy of the usbnet services and rename every non shared variable to something like "wifinet" I won't go into details here, they are lengthy and this post is already long. I found many things inside the code of usbnet and I have to say the kids that did it did a great job. Note to whom it may concern: Yes I rtfm, thank you.

So the code itself pointed me in the config file in which I found the solution
Simply change the following variable to true in %kindledir%/usbnet/etc/config :
 K3_WIFI_SSHD_ONLY="true"  
The guys who wrote usbnet had already taken care of it.

So,
1) There must be a file named %kindledir%/usbnet/auto
2) %kindledir%/usbnet/etc/config enable wifi and make it wifi only
3) Restart kindle

Note that when the kindle is in sleep mode you cannot ssh to it via wifi and that it is recommended to ssh to your kindle in usb mode first to obtain the key...

So that's it! Now if an update ever occurs that re-enables the ads, I have already set up a simple and easy wifi ssh connection to explore my option further.



Amazon, the next move is yours

Saturday, April 27, 2013

Living room PC


This is a project I had a few months ago
I can't show you it's progress but I can show you the result

So the basic problem was that I couldn't find a desktop case small enough to fit under the TV furniture

Well at least not one cheap enough...

I was using a regular one and had it standing beside the TV furniture...

So I found this case for 10 euros after a very long day in the center of Athens!






You can tell it fits almost perfectly. It's a little bit long but the TV furniture isn't so close to the wall so it doesn't bother me at all.



 
Take a first look inside









What you see here is an ATX size motherboard inside a micro-ATX horizontal desktop case destined for a micro-power supply but having a normal one instead!





It also incorporates an HDD and an SSD  under the DVD drive... which despite my best efforts you cannot see clearly.
 



The inputs of the bolts for the old micro-ATX as well as many other things were taken apart from the case. The hole you see is for a future planned HDMI connection.

I used a metal base for the motherboard from an old unused ATX case which I extracted with an electric saw... And glued it on the (now) clear base of this case.
I also removed the metal bracket from the graphics card because there wasn't any room left underneath for it to hold in place.


 The back of the case is a mess, but I couldn't care less.
The front panel DOES work, there's a usb wireless keyboard and mouse receiver in this view.
I had to take the floppy drive from the case so it could fit the hard drives. I could find though a cap with a fitting color. I plan replacing it if I stumble upon a grey-black one at my work...



With a Core2Duo dual core processor at 2.6GHz, 1GB of ram, an Nvidia 210 with 512MB of RAM graphics card, an 60GB SSD an 80GB HDD and a DVD drive and Ubuntu 10.04 LTS OS this is a perfect living room PC more than capable of playing movies and web surfing.

And  it can sit nicely inside the TV furniture



So that's it! Stay tuned for more!








Friday, April 5, 2013

Chromebook!


My first post will just be a geeky praise to one of my favorite gadgets!
I've long decided that my first post in this blog will be about the google chromebook.
And not any google chromebook... My google chromebook.




Take a first look!
First of all I would like to thank once more a friend. Without him I wouldn't have this super gadget in my possession. He knows who he is ;)



Anyways

Some specs:
Model: XE303C12-A01US
Samsung Exynos 5 Dual core CPU
2 gigs of ram
16GB SSD drive
11.6'' LED HD screen
1366x768 resolution
2 USB ports (1 x USB 2.0, 1 x USB 3.0)
SD card slot
0.3MP webcam
HDMI output

A view of the usb, the HDMI and the power input ports
A view of the headphones jack and the sd card slot
A close up of the 0.3MP camera - there are some light sensors and maybe a mic on its sides
A photo taken from the chromebooks webcam


All pretty straight forward... except the cpu.
So what about the exynos cpu?
Samsung has designed this new system-on-a-chip called Exynos 5 which holds an 1.7GHz Dual core ARM Cortex A15 CPU and an ARM Mali-T604 Quad core GPU (4x533MHz)
It also holds support for USB 3.0 and SATA 3.0 and other I/O ports and interfaces such as HDMI.
Also, some features such as a separate chip which is responsible for the linkage between the CPUs, MMUs, graphics, memory and ethernet controllers which I won't fool you by pretending that I fully understand...
But the  ARM core is generally known in being used in mobile phones and devices, what is it doing powering a laptop?

This new ARM core - the ARM Cortex A15 - is designed for providing more computing power whilst maintaining the chips's low power consumption. Its competitors Intel, AMD and Nvidia are hardly keeping up, with only Intel, with its quad core Atom and the i3, being more powerful. But it is still lacking in areas like power consumption compared to the ARM chip.
I'll analyze the CPU architecture later in the OS part of this post.


The laptop doesn't have any fans. It doesn't need any. Even after many hours of use it just feels a little warm. And it's also completely silent. And that is because of the ARM chip combined with the 16GB SSD drive.

No openings anywhere under the chromebook - except for the speakers in the upper corners

The battery can hold the laptop powered for up to 6.5 hours (as advertised)
Well, this always depends on the type of usage. I've witnessed the battery draining from 3.x hours of usage (brightness full, wlan on, usb devices attached and video streaming) to something less than 9 hours (brightness low, wlan off, no usb devices - just reading and watching a movie)
Still, I know many laptops that can only be powered for only up to 2.5 hours. So having it's lowest guaranteed battery autonomy at 3.x hours is excellent!
Closing the lid

Lid closed

If you close the lid, the device enters sleep mode automatically and there isn't a way to change this setting. Not that you'll need to anyways. Ever. Sleeping consumes nearly no power at all! I've kept my chromebook in sleep mode by the time I arrived from a trip and didn't use it for a couple of weeks. When I opened it, I was able to use it for at least an hour. Not to mention waking up from sleep mode... This is just crazy, I never seen something like this before. It feels like unlocking a smartphone. It literally needs less than a second to wake up. If you have a youtube video or a movie file playing at the time you close the lid, go ahead and leave it there for days. When you open the lid, the video will immediately resume from where you left it. Even if you don't want it to! So, every time I don't need my chromebook any more, I just close the lid and put it in its bag, not worrying if it'll have any battery remaining for any possible future use. It wont disappoint me for sure.


A close up on the keyboard - No windows key!! The F keys are replaced by some function keys...

A close up on the keyboard and screen - browsing in a random webpage...

Everyday usage is just a joy. The keyboard is very comfortable. Although I've heard complaints about the lower-case layout of it, I don't see were the problem is, the spacing between the keys is good, the feel of the key while being pressed is smooth and anyways, who watches their keyboard while typing nowadays? The trackpad is flat and empty without any buttons, You can tell it is inspired from a macbook trackpad, although it doesn't have all of its capabilities. It supports right clicking and scrolling with two finger gestures, which I find very handy. I've caught myself trying to use this feature in old laptops at my job and find their lack of it very time consuming... How have I lived without it all this time?

This is a very portable laptop. With an 11" screen and this autonomy, you can carry it anywhere - even in long trips. I never get it's charger with me when I go out and I've never had to stop what I was doing with it because the battery was getting low. I use my chromebook for youtube videos, movies (SD,HD,Full HD), email, facebook chat - posting - browsing, googling, backing up my friends's camera photos using the sd card slot and even charging usb devices (although this drains the battery very quick) I haven't tried to play flash games or anything like that, but I imagine the cpu usage is about the same - if not a little more - than that of watching an HD movie.

Another super feature of the processor is, as I mentioned above, the capability of viewing HD movies. Quoting wikipedia: " This SoC will have a memory interface providing 12.8 GB/sec of memory bandwidth, have support for USB 3.0 and SATA 3, decode full 1080p video at 60  fps along with simultaneously displaying WQXGA-resolution (2560x1600) on a mobile display as well as 1080p over HDMI." Although technically it is useless to play an Full HD movie (1920x1080) on this 1366x768 chromebooks' screen, it won't complain at all. Movies play smoothly. Now, talking about the supporting formats... Well, I usually download my movies in HD which are (usually) in mkv's, mp4's and avi's. The chromebook can play them all, although sometimes it needs a little tweaking. Generally, if you rename the extension of a video file to .mp4 it will play fine - my only problem until now was with two video files - in one mkv I couldn't hear any audio and in another, only part of the audio channel could be heard (I suspect it had a 5.1 audio stream or something) (UPDATE: more mkvs with no audio...) Subtitle support is currently on the works, to view them you have to get your device in dev mode, convert your subtitle files in .vtt format and open the video file from a html file you wrote... Not for the everyday user for sure! I expected better from google, although the vtt format sounds very promising as far as encoding problems are concerned... I would be glad to finally get rid of this bugger!
The chromebook booting up (in literally seconds)



The chromebooks login screen - it will show more users if more users have been using it recently


ChromeOS is a very smooth experience. Most of the features just work as long as you don't ask for too much. You have to keep in mind that this isn't a desktop replacement laptop but an ultra portable internet browsing device with some extra features you have to be grateful about.
I will propably start an arguement, but I have to say this is a Linux based OS. I don't even know why do some people argue about that. Is "Linux" a bad word? Is it scary for some? (or for their costumers?) I was in a BestBuy in LA and asked about the OS, a friend of mine asked if this was a Linux based OS... The answer was something like "eeeerrrrr, eeeehhhh, no, not exactly, naaaah, you can't say that" My question is: why?. I later learned that he had tried some linux distirbution himself. So I am very confused about this person. Even the google representative in the store had about the same reaction. I am not going to accuse a whole corporation for confusing people and even their staff but, wtf Google?
I mean, common, how much proof do you want, it has a shell (press ctrl+alt+t > type shell in dev mode) in which you can run various common unix and linux commands and programs, the filesystem is linux/unix like... Google doesn't hide the fact that this OS has a "patched" linux kernel. Just read the documentation in the dev pages, both in chromeOS and chromiumOS (the open source - community supported/maintained - development version of chromeOS) websites. Not to mention that this isn't the first time that google is using a linux kernel in an OS...

What ChromeOS currently supports: Being an OS with basically only a browser, this device generally supports web-based applications. Its google-chrome browser is in many ways the same with any google-chrome browser in any other OS. This means that with every update, its embedded flash player is updated to the newest version. So - generally - every flash (and of course, HTML5) content on the internet is probably going to run on the chromebook - fairly fast. Some of the applications that  are included except the browser are: a file manager, a camera viewer, a media player, a "scratchpad" and a calculator. Everything else must be run from the cloud.
So we can easily understand what this device cannot support: Everything that needs to be "installed" in an OS. This includes but it is not limited to: Skype(!), MSOffice, Adobe suite, bittorent clients, extra media codecs, alternative browsers, Viruses...

The internet connectivity of this model is limited to a wifi module only. The 3g model costs about a 100$ more. Well, in 2013, wifi is everywhere, but there are still places that wifi isn't as available as you might have wanted ($$) so an option for a 3g connection is always desired in a device that is designed to be run with an internet connection... Problem is... usb 3g dongles aren't supported. Basically, the only usb devices that this device supports are usb storage devices, keyboards, mice and I've found reports that usb headsets are also supported (then again, I've found possitive reports about usb 3g dongles...) So the only solution that I've found is either using my smartphone as an access point using its 3g connection or a mifi. The only downside is, I have yet to find a smartphone or a mifi device capable of maintaining its connection as long as the chromebook has battery!


Before I end this post: This device has a locked "BIOS". However, you can still install an alterative OS (without many options - but still) I have already installed Ubuntu linux (which are called chrUbuntu when you install them in this device)which are basicaly the chromeOS linux kernel with Ubuntu on top (and the chromebook in developer mode) It's a whole new story - it deserves a post of its own...

Concluding: This is an ultraportable device with more than basic capabilities for everyday use on-the-go. It is not a desktop replacement. You need to know what you are asking if you're considering bying it...





Saturday, March 16, 2013

Welcome

Ok, so this is a welcome to anyone that just discovered this blog.
This blog is an effort of me writing down my insights thoughts and everyday stumble-up-ons regarding anything around computer technology.

PC, Linux, Mac-OS, hardware, software problems - solutions - tips - thoughts - stories - weird stuff - normal stuff...

Everything I feel like posting around tech will be posted here.

Any notes, tips, help, suggestions, love expressions, hate expressions are always welcome either in the comments or via my e-mail and/or my google+ page.