Realtek USB WiFi dongle on Pine64 with Debian

I have had a Pine64 since a while ago and just a few days ago I finally tried to turn it on! xD I plan to use it as a main home router since it has a gigabit ethernet.. well scrap that, I think I found a better device for that. Anyway, I still want to use it but now as another kind of (wireless) router that will route and bridge all my tiny bitty wireless devices based on ESP8266. I intentionally wanted to have them separated from the main home network.

So, also a while ago, I bought a USB wireless dongle because I didn’t buy the WiFi module from Pine64 guys. Apparently the dongle uses a Realtek chipset, RTL8188CUS. I plugged the device into my Pine64 and then.. nothing xD nothing showed up on the ifconfig -a device list. Ah, I used the Debian Base (Debian Base (3.10.102 BSP 2) to be precise) distribution for the Pine64 btw.

Google around, and I found a page on Debian Wiki that says I would need to have rtl8192cu module loaded. Sure enough, it’s not there. The search continued, this time with a more specific keyword. I then ended up on a GitHub page and looks like some is having a similar problem as mine. After trying here and there I finally made the device showed up! I haven’t configured it thogh.. but anyway.. here’s what I did.

  1. Apparently I had to upgrade the kernel of the Debian installed on the Pine64. It used to use Linux 3.10.65-7-pine64-longsleep. After the upgrade, it changed to 3.10.104-1-pine64-longsleep. What I had to do was just running the following command.

    $ sudo

    The script should come already with the distribution. It will download, verify, and install a new kernel. After it finished, you will be asked to restart the device.

  2. I tried to replug the USB dongle and nothing still showed up. I check the log using journalctl and found the following message.

    Nov 19 04:20:28 localhost.localdomain kernel: usb 2-1: new high-speed USB device number 3 using sunxi-ehci
    Nov 19 04:20:28 localhost.localdomain kernel: rtl8192cu: Chip version 0x10
    Nov 19 04:20:28 localhost.localdomain kernel: rtl8192cu: MAC address: 01:23:455:67:89:0a
    Nov 19 04:20:28 localhost.localdomain kernel: rtl8192cu: Board Type 0
    Nov 19 04:20:28 localhost.localdomain kernel: rtlwifi: rx_max_size 15360, rx_urb_num 8, in_ep 1
    Nov 19 04:20:28 localhost.localdomain kernel: rtl8192cu: Loading firmware rtlwifi/rtl8192cufw_TMSC.bin
    Nov 19 04:20:28 localhost.localdomain kernel: rtlwifi: Loading alternative firmware rtlwifi/rtl8192cufw.bin
    Nov 19 04:20:28 localhost.localdomain kernel: rtlwifi: Firmware rtlwifi/rtl8192cufw_TMSC.bin not available

    Looked like the kernel finally recognized the device but it could not continue to activate it because it did not have and could not load the suitable firmware.

    After I checked the GitHub page again, one comment there says I need to install a package named linux-firmware. So that’s what I did next.

    $ sudo apt-get install linux-firmware
  3. I then tried the dongle again.. now it seemed to be a success! If I typed ipconfig -a, I could see a new device albeit with a weird naming: wlx01234567890a.

So.. the setup can now continue. Hope this helps.

Penyanggahan standar tentang tulisan terkait elektronika

Sudah hampir satu tahun saya mulai ngoprek2 hal yang sedikit berbeda. Masih berbau2 dunia teknologi namun tidak sepenuhnya di dunia perangkat lunak: Elektronika! Yang dimaksud dengan elektronika ini adalah hal2 yang terkait dengan resistor, transistor, microcontroller, pcb, arduino dan sekitarnya. Walau dulu saya pernah ikutan tim robot di Univesitas Indonesia, namun saat itu saya hanya mengerjakan bagian perangkat lunaknya saja.

Nah ceritanya saya pengen menuliskan pengalaman terkait ngoprek2 elektronika di blog ini. Namun berhubung saya tidak punya pendidikan dan pengalaman formal, maka saya ingin membuat pernyataan “penyanggahan standar” terkait tulisan saya yang berhubungan dengan elektronika.

* * *

Saya tidak memiliki latar belakang pendidikan dan pengalaman formal di bidang elektronika. Dalam kegiatan ngoprek elektronika, saya hanya mencomot informasi dari sana-sini yang tersebar di jagad Internet. Saya tidak menjamin keakuratan rancangan dan kalkulasi yang saya lakukan. Jika Anda melihat kesalahan yang saya lakukan atau punya saran, tolong kasih tau saya! 🙂

PERHATIAN! Ngoprek2 dengan elektronika bisa sangat berbahaya terutama jika sudah berurusan dengan arus/voltase tinggi termasuk listrik di rumah. Tolong gunakan akal sehat dan penuh kehati-hatian selama ngoprek. Saya tidak bertanggung jawab atas musibah/kecelakaan yang mungkin terjadi.

* * *

I don’t have a formal education nor experience in electronics. I only gather information here and there mainly from the Internet during my electronics experimentation. I don’t guarantee the accuracy of my design or calculation. If you spot errors or have suggestions, please let me know! 🙂

WARNING! Working with electronics can be extremely dangerous, especially when you are dealing with high voltage/current, including the electricity at house. Please use common sense and be careful when experimenting. I do not take responsibility for any accident that may happen.

JSON formatter bookmarklet

At work I need to read JSON document pretty often and making it pretty will help me pretty much. Last time I showed how to prettify a JSON document using Python script. But since I am working mostly in a browser, having to switch from browser to terminal is a bit cumbersome. There are a lot of online JSON formatter out there but I think it’s too much if I need to make a remote request just to do the formatting. Also the JSON document I need to format can be a sensitive document so it’s also not a good idea to use an online service.

Then I realized browser nowadays has in-browser JSON formatter function: JSON.stringify. I just need to find a way to make using it a bit easier. So I made the following bookmarklet.

Prettify JSON

Drag the link above to bookmark bar in your browser. If you need to format a JSON document, you can click it, then paste the JSON document (make sure it’s valid), and finally click the button there. Voila!

Reverse Proxy from HTTP to HTTPS with Apache

The other day, I had problem accessing an HTTPS site from a Python script. Since I had no time to spend figuring out why (it was for a personal project anyway), I decided to make a reverse proxy using Apache. However, unlike the commonly setup reverse proxy, this one is to make an HTTPS site available as HTTP site.

This is what I needed to put in my Apache config.

    SSLProxyEngine On
    ProxyPass /
    ProxyPassReverse /

I also had to enable mod_proxy and mod_ssl which can be done easily (on Debian based system) by running the following command

# a2enmod proxy ssl

Then reload or restart Apache

# service apache2 reload

The most important bit in the config above is SSLProxyEngine On. Without this the proxy would not work!

JSON prettifier

Once in a while I need to prettify a JSON document (read: add indentations and new lines) to make it (more) readable. Usually what I will do is finding an online prettifier and copy-paste the JSON onto there. What I usually don’t realize is that I already have that tool in my toolbox! I figured this out from a post somewhere on the net, sorry I don’t remember exactly where.

If you have Python installed, that means you already have a tool that can make a JSON document pretty. Just use it as the following.

$ python -m json.tool document.json

Or if you are an stdin fan, it can also read from there.

$ python -m json.tool < document.json

There you have it!

Log of Debian/Ubuntu packages

I have a plan to do a little research about packages in Debian and/or Ubuntu repositories. For this, I think I need a preferably complete log of packages that coming in and out of the repositories.

A friend of mine pointed me the following two mailing list archives where Debian and Ubuntu seem to be logging the packages.

If somebody knows the other sources, or if the above sources are unsuitable for the purpose I am looking for, please let me know 🙂

Blogger to WordPress

When I merged all of my scattered blogs few days ago, I tried to import my blog posts from Blogger to this WordPress installation. My first shot was to use WordPress’ own Blogger Importer but apparently the result was not so good (I think). Some texts were garbled and gone. For example, the iframe tag from SoundCloud in my post about OS X’ Text-To-Speech “Improvisation” was eaten by either the converter script or WordPress. Either way, it didn’t work flawlessly and I had to find out another way to export the posts.

Then I realized that Blogger provides a tool to download all of our blog posts, including comments (and I assume the pages as well, but I didn’t test it since I don’t have pages). I tried this out and got a machine readable XML file. Wohoo!

WordPress has it’s own way to do data migration between WordPress blogs. The good thing is it’s also an XML file! If somehow I can convert the XML file from Blogger to the one that WordPress uses, everything should be set 😀

A couple hours later, I got this very simple converter script. It may not be efficient and it also has several hardcoded values (check the categories part) but it suits what I wanted 😀

Have fun!

Ubuntu Repository: Total Packages and Sizes

Long time ago, I made a chart that shows Ubuntu Repositories’ size over several releases. At that time, there were only 6 releases and 1 release that was still being worked on. Fast forward almost 6 years later, now we have 18 Ubuntu releases, yay! How does that chart look like now?

Well, here we go! I just made some new charts!

Ubuntu Releases - Packages and SIzes

The full charts can be seen at

As you can see, the repositories are constantly growing. Ubuntu starts with about 8 GB of packages and now it has more than 50 GB. The number of packages is also growing from just over 12.5 thousands and now it almost three times larger.

How did I count the numbers? I took the package index files (a.k.a. Packages file) and counted the number of packages inside. I also summed the size of each packages to get the size of the repository. The files are from the at-release repository which means I excluded the -updates and -security repositories. The at-release repository is presumably frozen and therefore the size won’t change anymore, where the latest two repositories are for the updates, which by definition are always updated. Well.. except when the release is not supported anymore.

I put all of the codes I wrote and use in my GitHub repository Feel free to check, modify, and update it. I release the whole thing as public domain!

Transparent video?

For the past few days, I have been wondering how to show a transparent video on an OpenGL scene. I can already extract video frames from a movie file using ffmpeg and display them as a video. But how about a transparent video?

Is there a compression format that supports alpha channel? How is the compression ratio, is it still good? If I simply use chroma key, how can I candle a fade-in/out images (I don’t want to deal with a complicated math formula here)?

All of my questions here were answered after reading this StackOverflow question. Well not answered per se :P, but I immediately what I need to do to show a transparent video. Basically I need to store the alpha mask. But instead of using the alpha channel in a RGBA video stream (I still need to make experiments with this though), I can use an additional area of the video to store the mask. With this, I can use the regular RGB-channel video with those already-known compression format, ratio, and what-not. But in exchange, I need to enlarge the video dimension to store the alpha mask. Hopefully the compression algorithm is clever enough to compress more this part of the video 😛

Having that, all I need to do next is to modify the already-simple fragment shader that I use. So now I need to take the first half of video and use the RGB values of it. Then take the second half and get the Red value (or Blue or Green) and use it as the alpha channel of the RGB.

varying vec2 texcoord;
uniform sampler2D textureId;

void main() {
    vec2 tc_rgb = texcoord * vec2(1.0, 0.5);
    vec2 tc_alpha = tc_rgb + vec2(0.0, 0.5);
    vec4 frame = texture2D(textureId, tc_rgb)
    vec4 alpha = texture2D(textureId, tc_alpha);
    gl_FragColor = vec4(frame.rgb, alpha.r);

Yippy, that’s all! Ah yes, don’t forget to enable GL_BLEND and set the blend function otherwise you will have a bad time 😛