Sunday, October 26, 2014

Bluetooth Blues

While waiting for my monitor to be replaced, I got some time to spend on fixing the bluetooth. My understanding is that the BT is controlled through GPIOs and mine uses RockChip's own controller instead of the RealTek's 8723bs wireless chip.

There is a nice thread with tool to dump the GPIO. I followed the direction to dump the GPIO and I see some related names

<4>[ 738.864604] GPIO gpio1 195 bt_default_rts
<4>[ 738.866166] GPIO gpio3 278 bt_default_wake
<4>[ 738.866188] GPIO gpio3 279 bt_default_wake_host
<4>[ 738.866234] GPIO gpio3 281 bt_default_reset

I have also identified the source file for the BT driver (board-rk3188-box.c). However, the controls does not quite match. There is an entry in the source code for powering up the BT but nothing in my gpio dump above. I tried it anyway and I noticed no difference. After a few trial and error, I gave up.

As an alternative, I tried loading the stock kernel and noticed that the BT does not come up either. It turns out that there are more than just the kernel that needs replacing. It is best to work with one unknown at a time. I tried replacing the boot.img and even the WiFi is not coming up.

So I am afraid I will have to revert to a firmware with BT works and start from there. Unfortunately, it would mean I will need to wipe my stick and lose all my customizations (I'm not very comfortable in backing up the user files or the entire stick). No pain, no gain!

Sunday, October 19, 2014

Hardware Issues

After another trial run over the weekend, I think there are a couple of hardware issues. One issue is the overheating issue mentioned before. Even capping the clock speed to 1.2GHz, there was one reset after operating for 1 hour. 


Kids having fun with Monopoly

The stick is getting scorching hot. Looks like I need to figure out some way to cool this thing down. Since the plan is to embed the monitor inside an Ikea coffee table, the cooling is only going to be worse. A cooling fan would be too annoying. I've thinking of adding a real heat sink.

Another issue is related to the monitor. I think there is something wrong with the wiring. A few days ago, I have a hard time getting the stick to boot. I thought it is bricked until I realized it shuts down as soon as I connect the USB of the monitor. 

When I tried with a laptop, the touchscreen does not work if both video and USB is connected. I even hear a constant humming noise coming from the laptop which suggests some serious problem. If I first connect the USB, the touchscreen is recognized. If I then plug the video in (HDMI, VGA), I see a SPARK at the video connector and then the USB device disappears. There must be a short somewhere. Finally, I fixed it by changing the orientation of the monitor and then the problem disappears. But I think I need to send the monitor back for an exchange before my 30 days window is up. 

Which means I will be without my monitor for some time. I guess I can always work on fixing Bluetooth.

Tuesday, October 14, 2014

Closing the Loose Ends

A project just isn't complete without running into unexpected issues. While I get the touchscreen working and running Android, there are still some issues to complete. After a proof-of-concept test, I list down the problems.

 

Graphics does not look 1080p

The first thing I noticed when I power on the stick is that image does not look sharp. It is because it is not using 1080p despite what it claims to use. For some reasons, perhaps due to limitation in video playback, the stock firmware will not display in 1080p.

The solution is quite simple. Someone already figured it out and have it patched. I realized that just like I can load my custom, touch enabled, kernel on stock firmware, I can pair a custom firmware with my custom kernel. With that combination, I can see my display in 1080p glory.

Rotation does not work

One of the app I really want to run on my giant tablet is Monopoly. It even has a Tablet mode which you place the tablet on the table and up to 4 person can play. But the mode does not work because the OS forbids it from rotating. Of course, a TV cannot be rotated. But what I want is really to allow the App to change the orientation should it need to. It may not make a lot of sense for a TV but it makes perfect sense for a table!

I thought this is a simple problem. But I have tried many apps available, including free and paid apps. None would change the orientation. In fact, I cannot tell if they made any difference. 

And then I tried messing with build.prop and changing ro.sf.fakerotation and ro.sf.hwrotation. They don't work. Even worse is that it rotated my touchscreen without rotating the actual image. I come to the understanding that the screen rotation is intentionally disabled on these TV stick ROMs to prevent orientation to be changed. Well, I'm not sure if I would buy that as Apps designed for portrait looks ugly as hell.

Then it struck me that I have tried another custom firmware that puts a screen rotation button on menu bar. I decided to start over and try the firmware again. Sure enough, it worked! It isn't perfect but the App is able to change the orientation at will. Which is what I wanted in the first place.

Overheating and poor Wi-Fi

The stick runs very hot. I have seen some MK809III eBay listing that has a copper heatsink. But mine does not have it. To make it worst, it seems either the kernel or the firmware that I used overclocks the stick to run at 1.6GHz instead of the designed 1.4GHz. Fortunately, No-frill CPU Control is already bundled in the firmware and I can change it to 1.2GHz. But it appears to be running noticeably slower. Some day, I need to address it one way or the other.

Bluetooth not working

I have mentioned this previously. BT is not a deal breaker. But a BT keyboard is a perfect companion to a touchscreen with Android. Still working on this one...

Sunday, October 12, 2014

The Magic Touch

The HT231 and my TV stick seems to be born for each other. There is a recessed space in the back of the HT231 monitor for connectors. And it has just enough space for the TV stick. The stick can plug directly into the HDMI port without extension cord and it is secure enough to not disconnect.

I then hook up the USB A/B cable between the monitor and TV stick. Not surprisingly, there is no touch being recognized. I have also heard from previous discussion from freaktab that if I put all 10 fingers (the HT231 is a 10-point multitouch panel). A touch cursor will show up. Indeed. And I can sort of move it around by moving one of my hand. But it jumps around and completely not useable. 

Now it is time for some digging. The freaktab forum has a lot of information scattered around. There is a thread dedicated to touchscreen; however the only success reported so far was those monitors with 2-point multi-touch. I have read the entire thread before I started the project but I am confident that there will eventually be a way to make it work with 10-point multi-touch. Especially since all these new touch monitors are natively supported by Windows 8. There must be some standard which they are all following.

And then, someone reported that with another Android TV box and some custom firmware running kernel 3.10, the touchscreen works automatically. This is a huge encouragement for me.

I have basically 2 options. Try moving to 3.10 kernel (from current 3.0.36+) or try to get touchscreen working with my current 3.0.36+ kernel. The former is a step too big for me. I also recall seeing another interesting thread that is very useful. I decided that I will go making my own kernel.

There are several useful threads related to building kernels. I ended up returning to a thread specific for my TV Stick. Where an experienced forum member who had built custom kernel for the stick. There were reports of working Wi-Fi but Bluetooth does not work.

I decided to just replace my current kernel with the custom kernel. And it worked! Not only Wi-Fi worked. BT also worked! If it was a week ago, that alone would not be too useful for me because my rooted stock firmware is just as good. 

However, I learned about 1 thing. I can also build my own kernel. The member also wrote a thread about beginner's guide to building kernel. Which is perfect for me.

After switching between the 2 threads. I figured out the right source tree and git cloned the source. It didn't took too long to build the kernel. I also found some tool online to extract the kconfig from kernel.img. So I can build a kernel that is as close to the working one as possible. I bring out the flash tool and overwrite just the kernel.img.

And surprisingly, my kernel boots up! I can confirm that my kernel is being used from "About device" page. The Wi-Fi works. But BT does not. Exactly like many has reported. Although with me, the custom kernel works just fine. BT is nice to have but not a deal breaker. I proceed to touchscreen driver.

I see kernel config has several options for touch input and USB touchscreen. I enabled them and build. My stick won't even boot! Complaining No Command. No big deal. I can always revert back. Later I think it was likely because I tried to make certain drivers as loadable modules.

I restart the kernel config and followed the instructions from the thread I mentioned earlier. I carefully created entries for the USB device of my H231, which has Vendor ID of 0457 and Device ID 1057. The only thing not clear was what device type to pick within usbtouchscreen.c since I am using a different touch monitor as the author. I picked one that looks close to my vendor and build my kernel.

When the stick boot up, I immediately notice something different. Although the touchscreen is not working, I see a touch cursor jumping all over the screen. This is a good indication that my stick is now seeing the touchscreen differently. It means I am on the right track.

After some trial and errors, I landed on using the same device type as the author - 3M. Although Hannspree and 3M appears to bare no relationship, it worked! The touchscreen works perfectly! Every point, every corner. My touch is perfectly recognized. My plan is executing exceptionally well. 

I have a Giant Tablet in front of me!



Saturday, October 11, 2014

The monitor

Time for getting the monitor. I have been eyeing the Hannspree HT231HPBU for quite some time. It is a really great option for 3 reasons.
  1. It has HDMI with speakers. The TV stick has no separate audio output. So HDMI audio is my ideal choice. Besides, the less wires the better. Even better is the fact that the speakers are facing out. Which means they will not be blocked when laid flat.
  2. It has capacitive touch screen. There are several other options that uses IR sensor. I don't know how well they work, but it means their screens are recessed. A recessed touchscreen just does not feel right, especially not for a table.
  3. It is cheap. It was going for $150 shipped on both Amazon and Newegg. And I have even seen it for $130 for a refurbished one on Newegg. No other touchscreen monitors come close.
On top of that, the monitor has excellent reviews. So it is an easy choice for me.

When I received the monitor, I hook it up to a Windows 8.1 laptop. The touchscreen is excellent as others has suggested. 

The only downside is the viewing angle. I realized that the viewing angle is noticeably worse than my IPS monitor. Color is also not as accurate. I guess I was spoiled. The viewing angle can become an issue down the road but I cannot complain too much for $150.

There is no turning back now. Time to connect my TV stick.

Firmware hunting

The first thing that I need to do is to figure out what wireless chip that it is using. Just like there are many flavors of RK3188 devices, there are also many different components used within the same model. This can actually get quite annoying. 

One way to find out what firmware it is using is crack open the case. Which is actually quite easy. 



Unfortunately, someone painted the wireless chip over. There does not appear to be a way to tell what chip it is using. The soldering is also kind of messy. I don't understand the Android stick economy very well, I suspect the one I got is a counterfeit or using some counterfeit component. I get what I paid for.

There is a whole community dedicated to these Android sticks. Naturally, I turn to the community for help. But I didn't really get any useful response. However, there is a wealth of information in the archive.

Without figuring out what wireless chip it use, I decided to try flashing some custom firmwares. But first, I need to learn how to make a backup.

The backup instruction is actually simple. The trick is really getting the tool to recognize the stick. 2 things are needed. The first is to make the stick recognized as an USB device. This is done by pushing the reset/back button using a paper clip while connecting the micro USB cable and remain for 3 sec or so. The next thing is to install the right driver. This is actually quite simple as the driver is already included with the tool.

(Later, I felt lucky that I didn't bought a different type of MK809III / CX919 which has trouble connecting to PC)

Backup was quite simple. It is basically dumping the flash into images. After backing up, I tried burning custom firmwares. 

I tried a couple of firmwares for 2 popular chipsets. AP6210 and MTK. Both boots up fine but no Wi-Fi. This indicates mine is not using either chipsets. After trying the AP6210 firmware, I restore back to my stock firmware to confirm both Wi-Fi and BT works. Then I flashed the MTK version and flash back my stock firmware. This is the time I realized the stick won't boot!

Since I definitely had restored successfully, I was wondering why. I flash back the AP6210 and it boots up. I believe the reason I had trouble was because of the bootloader. The MTK firmware I tried is Android 4.2 whereas my stock and AP6210 firmware are both 4.4. Fortunately, the custom firmwares come bundled with bootloader so all I have to do is to flash another 4.4 bootloader and I am back to where I started.

Still not able to figure out what my chip is, I decided to poke around. It seems that in order to find out the chip. I need to identify the driver. And in order to identify the driver, I need to run dmesg and in order to run dmesg, I need to have root privilege.

I don't know much about rooting. I poked around and found 2 tools. One is called VROOT and the other is called KingoRoot. I decided to try the KingoRoot. Both of these tools appear to be identifying the device and download its custom rooting instruction from their server. Their blackbox operation makes me uncomfortable. So the activity are all done inside a disposable virtual machine. 

But then I had a lot of trouble letting the tool recognize my stick. While the flash tool had no trouble identifying my stick. KingoRoot refuses to proceed. After some more poking, it seems I really need to connect when the stick is up and running. And I must install the complete USB driver from RockChip. 

After installing the right driver (ADB?), KingRoot proceed without issue. And the stick indeed boots up rooted.

Using dmesg, I identified my wireless chip as Realtek 8723bs. Turns out it is also quite common. However, there does not appear to be a custom 4.4 firmware for it.

(I found out later that had I know what wireless chip it uses, I don't really need to root it as I will use custom firmware eventually)


The stick

As mentioned earlier. I picked the MK809III. It is based on RockChip RK3188-T - a Quad Core processor running at 1.4GHz. With 2GB RAM and 8GB flash. This is quite an impressive spec. It also comes with 2 USB ports, one full size and one micro USB. The former is perfect for USB touch interface. The latter is needed for connecting to PC. Which is important for what I am about to do. There is also a micro SD card slot for expanding storage.





Even more impressive is the price is less than $50! There are many variety of RK3188 based device, range from a stick stick to a set-top box. A TV stick is perfect for my project.

The stick does come with some drawbacks. It is known to have weak Wi-Fi. Mostly because it uses a tiny built-in antenna. Cracking open the case reveals the internals

Another drawback is that MK809III uses RK3188-T, which is clocked at 1.4GHz instead of 1.6GHz of RK3188. It is not an issue for me. But keep in mind that there are some RK3188 based TV stick that comes with just 1GB of RAM. They should be avoided.

Getting the stick is the easy part. It took a little over a week to ship from China. Hooking it up to TV, it boots up as expected. It has 2 Launchers to choose from. One is designed for big screen and the other is the familiar Android launcher. Since I wanted a giant tablet, I went with the latter for Android experience. 

Google Play Store is already installed. Most apps are visible, meaning Play Store thinks my stick is compatible. Which is a good sign consider how unusual my setup is. However, many games will not play with mouse. Mouse clicks aren't treated as touches. And therefore some games are incompatible. This is one of the things that I need to solve. 

One other issue with these devices is that I don't know who is behind the firmware. Security and privacy concern is an issue. The same applies to custom firmwares that I can download from the internet. It is difficult to rebuild everything from source, even if I can, I cannot prevent any backdoors. So my security measure of choice is to avoid using it for sensitive information. Definition not for logging into banks etc. I created an Google Account just for using it. Another aspect is the network. I have it connect to a router that is reserved for my guests. I am not planning to use it for streaming from my home PCs, so it is not an issue for me.

Basic sanity test involves Wi-Fi, Play Store apps, Bluetooth, HDMI, USB, microSD. All looks good so far. With the basics taken care of. It is time for some hacking!

Friday, October 10, 2014

The Plan

A successful project requires some good planning. I laid out the following plan:

  1. Get a TV stick
  2. Proof of concept that it can run Apps from Play store and Amazon App store
  3. Get a touch screen monitor
  4. Hook them up and confirm that they work together
  5. Get a coffee table
  6. Cut holes
  7. Put the set inside and run the wires
  8. Mission Accomplished!


Prologue

I first had the concept of making a Table PC back when I saw a demo of Microsoft Surface (now called PixelSense). It was a basically a coffee table made of a flat panel display. It was many years ago but I like the idea. But I also understand the price is prohibitive. Also there is virtually no software available with touch control.

Then the introduction of iPad changes everything. Suddenly, every PC company jumped on board for touch based PC.

A few years ago, I found the original Microsoft Surface (the Table, not the Tablet PC) in my local library. I believe it has a 40" display. It was quite exciting but unfortunately, it was either defective or poorly calibrated. Part of the screen seems to pick up "phantom touches" As a result, it is really difficult to use.

I had the idea of owning my own Table PC for some time. At the time, a 10" Android tablet can be found for as little as $200. But 10" is far from big enough.

Then I found out there is the Acer 21.5" Android display, costing less than $250 for an refurbished one. I almost pulled the trigger until I learned about the poor reviews. Reports of it being slow, poor App compatibility are alarming. The final blow is that many have its touch screen broken. An Android tablet with a broken touch screen is useless!

Finally, I see the light in the end of the tunnel. With the popularity of Windows 8, many laptops and even monitors are outfitted with touch screens. Even better is that the price has come down. I was surprised to learn that a 23" touchscreen monitor can be found for as little as $130. For the computer side, I have always wanted Android. There just aren't that many Small Form Factor PCs. Many SFF PCs' case alone cost $100+. Besides, I have accumulated a healthy library of Apps collected from Amazon Appstore.

Initially, I thought about using cheap android tablets. Such as the cheap HiSense tablets because it comes with HDMI port. But I have previous experience with Android tablet when hooked to a TV that the screen isn't an exact replica of the tablet (the bottom menu bar is cut off). On top of that, I don't know how to relay the touch interface to the tablet.

Enters the Chromecast. Google made a stick PC that plugs directly to TV's HDMI port and powered via USB. It is both practical and elegant. With a little bit of research, I found out that a little heard of Android stick, initially named as MK802, has gained a lot of popularity since introduction. I think an Android stick has only 1 display and there is no issue with multiple displays.

I decided it is time for some action. I like making things incrementally. So I go with the brain behind the display first. I pulled the trigger on the MK809III which is the 3rd generation Android Stick with a quad core processor.

To be continued.