I had been contemplating about buying a new laptop to replace my 5 years old ThinkPad X201. My criterion were:
1. It has to run Linux (preferably Ubuntu, as I'm most familiar with this) well, like really well as it'll be my main OS.
2. Small (13" would be the largest)
3. Perhaps with NVIDIA GPU so I can run CUDA stuffs (as I've been into machine learning stuffs these days) on it and so some casual gaming.
Through focusing on criteria (1) and (2), I came across Dell XPS 13 Developer Edition, which is a laptop with native Ubuntu OS. Because it didn't come with Windows, guess what? It actually costed cheaper than the non-developer options that came with Windows! And the best part is that Ubuntu is optimized to run well on the laptop. Tempting. Very tempting. As finding a decent laptop to run Ubuntu had indeed been challenging, I drooled over the one with 256GB SSD and i7 CPU. But still I didn't buy it.
Thankfully, it didn't have an NVIDIA GPU! If only it had it, I'd have already bought it. So what's the deal? Well, I realized that my combo of X201 with Ubuntu had been serving me really well. There had almost been no time I needed more performance than what it offered (except, of course, for casual-gaming purposes, which I rarely do and I already have dedicated gaming devices anyway) So I thought: if it only had Intel's integrated GPU, how would it serve me better than my X201? Not much, really. Moreover, I already had a docking station for my X201! If I were to buy a new laptop, for sure I'd want to get a dock for it, and that'd be like $100+ extra. Bummer..
Long story short, instead of having abandoning it, I decided to give my Thinkpad X201 some love. I treated it with a 500GB Samsung SSD 850 EVO. How did it go? Really sweet! With Ubuntu 14.04 (w/o any form of disk encryption enabled), it booted in 12 seconds! Going to/resuming from hibernate was almost instantaneous! So far I've been loving it so much :)
Random useful tech stuffs I write to remind myself. Hopefully useful for you!
Tuesday, October 6, 2015
Profile-based CPU controls to save power / improve perf
In order to save more power and hence improve on-battery life, in Ubuntu, CPU governor as well as clock speeds can be controlled more finely using cpufreqd. To illustrate how this can be useful, my ThinkPad X201 (running Ubuntu 14.04), always uses performance governor although the laptop isn't being plugged to wall-charger. What a waste of power! cpufreqd allows different profiles to be set,depending on the charging status or battery-level. In a particular profile, CPU governor as well as min/max CPU clock can be customized. Moreover, there's also indicator-cpufreq, which provides a nice status bar icon indicating current CPU configuration (both governor and speed).
Here's how to get them up and running:
1. sudo apt-get install indicator-cpufreq cpufreqd cpufrequtils
2. sudo vim /etc/cpufreqd.conf # This is the file to configure the profile
Below is snippet of what I modified (the rest stays default):
[Profile]
name=Performance High
minfreq=70%
maxfreq=100%
policy=performance
#exec_post=echo 8 > /proc/acpi/sony/brightness
[/Profile]
[Profile]
name=Performance Low
minfreq=60%
maxfreq=80%
policy=performance
[/Profile]
Furthermore, the followings are useful for debugging:
1. cpufreq-info. This can be used to see what governor and clock are currently running. Also useful to see whether the configuration selected via indicator-cpufreq (e.g. manually choosing a different governor) is applied fine. In the past, I've had issue where my CPU clock was locked to 1.2GHZ (this was back on Ubuntu 12.04, for further detail, see my other blog post)
2. 'cat /var/log/syslog', as cpufreqd logs are written onto this.
3. [Added 10/21/2015] If for some reasons, the rules written under /etc/cpufreqd.conf doesn't get applied, check if cpufreqd daemon is actually running. If it's not, you can start it manually through sudo '/etc/init.d/cpufreqd start'. On my Thinkpad X201, without cpufreqd running, its max frequency is somehow capped in a weird manner.
Here's how to get them up and running:
1. sudo apt-get install indicator-cpufreq cpufreqd cpufrequtils
2. sudo vim /etc/cpufreqd.conf # This is the file to configure the profile
Below is snippet of what I modified (the rest stays default):
[Profile]
name=Performance High
minfreq=70%
maxfreq=100%
policy=performance
#exec_post=echo 8 > /proc/acpi/sony/brightness
[/Profile]
[Profile]
name=Performance Low
minfreq=60%
maxfreq=80%
policy=performance
[/Profile]
Furthermore, the followings are useful for debugging:
1. cpufreq-info. This can be used to see what governor and clock are currently running. Also useful to see whether the configuration selected via indicator-cpufreq (e.g. manually choosing a different governor) is applied fine. In the past, I've had issue where my CPU clock was locked to 1.2GHZ (this was back on Ubuntu 12.04, for further detail, see my other blog post)
2. 'cat /var/log/syslog', as cpufreqd logs are written onto this.
3. [Added 10/21/2015] If for some reasons, the rules written under /etc/cpufreqd.conf doesn't get applied, check if cpufreqd daemon is actually running. If it's not, you can start it manually through sudo '/etc/init.d/cpufreqd start'. On my Thinkpad X201, without cpufreqd running, its max frequency is somehow capped in a weird manner.
Sunday, October 4, 2015
Simple Key Re-Mapping on Ubuntu 14.04
This tutorial shows how a simple key remapping can be done using XKB, which is the standard keyboard mapper that Ubuntu 14.04 uses.
To give a little background, I have a ThinkPad X201. Around the laptop's arrow keys, there are two keys that act as BACK and FORWARD (as in the Internet-browser sense), which I found really redundant since I always use the combo of "ALT+LEFT" or "ALT+RIGHT" to achieve the same goal. And so I decided to remap these keys to "PG DOWN" and "PG UP" respectively.
As I researched around achieving this, I found that XKB is pretty complex. For example, it allows remapping a key to different keys, depending on the modifiers (e.g. A becomes B, while Alt+A would become Alt+C) While what I wanted was very simple, most of the resources I found online were pages long trying to explain the quirks of XKB. Now that I've learned how to achieve my remapping, I'm doing a brain-dump here :)
Goal: To map "BACK" and "FORWARD" to "Pg Down" and "Pg Up"
Steps:
aharijanto@aharijanto-ThinkPad-X201:/usr/share/X11/xkb/symbols$ git diff
diff --git a/symbols/inet b/symbols/inet
index 5c4784e..8e522aa 100644
--- a/symbols/inet
+++ b/symbols/inet
@@ -144,8 +144,10 @@ xkb_symbols "evdev" {
key <I163> { [ XF86Mail ] };
key <I164> { [ XF86Favorites ] };
key <I165> { [ XF86MyComputer ] };
- key <I166> { [ XF86Back ] };
- key <I167> { [ XF86Forward ] };
+// key <I166> { [ XF86Back ] };
+ key <I166> { [ Prior ] };
+// key <I167> { [ XF86Forward ] };
+ key <I167> { [ Next ] };
// key <I168> { [ ] }; // KEY_CLOSECD (opposite of eject)
key <I169> { [ XF86Eject ] };
key <I170> { [ XF86Eject, XF86Eject ] };
To give a little background, I have a ThinkPad X201. Around the laptop's arrow keys, there are two keys that act as BACK and FORWARD (as in the Internet-browser sense), which I found really redundant since I always use the combo of "ALT+LEFT" or "ALT+RIGHT" to achieve the same goal. And so I decided to remap these keys to "PG DOWN" and "PG UP" respectively.
As I researched around achieving this, I found that XKB is pretty complex. For example, it allows remapping a key to different keys, depending on the modifiers (e.g. A becomes B, while Alt+A would become Alt+C) While what I wanted was very simple, most of the resources I found online were pages long trying to explain the quirks of XKB. Now that I've learned how to achieve my remapping, I'm doing a brain-dump here :)
Goal: To map "BACK" and "FORWARD" to "Pg Down" and "Pg Up"
Steps:
- Figure out the keycodes for "BACK", "FORWARD", "Pg Down", and "Pg Up"
- The codes can be found at /usr/share/X11/xkb/keycodes/evdev
- They are: I166, I167, PGUP, and PGDN
- Figure out how the keycodes are used
- Go to /usr/share/X11/xkb/
- Grep for the keys above:
- I166 and I167 are used by /usr/share/X11/xkb/symbols/inet, by default mapped to "XF86_Back" and "XF86_Forward"
- PGUP and PGDN are used by many files. One of them is /usr/share/X11/xkb/symbols/pc, whic shows that they map to "Prior" and "Next"
- Customize the keycodes' mapping:
- In accordance to the finding in (2), change "XF86_Back" and "XF86_Forward" that are used by I166 and I167 to "Prior" and "Next"
- Erase XKB cache files
- Remove all *.xkm files under /var/lib/xkb/
- Reboot
- Enjoy!
aharijanto@aharijanto-ThinkPad-X201:/usr/share/X11/xkb/symbols$ git diff
diff --git a/symbols/inet b/symbols/inet
index 5c4784e..8e522aa 100644
--- a/symbols/inet
+++ b/symbols/inet
@@ -144,8 +144,10 @@ xkb_symbols "evdev" {
key <I163> { [ XF86Mail ] };
key <I164> { [ XF86Favorites ] };
key <I165> { [ XF86MyComputer ] };
- key <I166> { [ XF86Back ] };
- key <I167> { [ XF86Forward ] };
+// key <I166> { [ XF86Back ] };
+ key <I166> { [ Prior ] };
+// key <I167> { [ XF86Forward ] };
+ key <I167> { [ Next ] };
// key <I168> { [ ] }; // KEY_CLOSECD (opposite of eject)
key <I169> { [ XF86Eject ] };
key <I170> { [ XF86Eject, XF86Eject ] };
Monday, May 4, 2015
Guide to Recovery your TF600T!
I recently got a TF600T. Sadly, I lost its password! So it's practically useless, as I can't get pass the lockscreen. There are some ways to recover the device: factory reset and re-flashing. Unfortunately, factory reset failed me for some reasons, while re-flashing wouldn't work as I didn't back up the original image.
After spending 2 weeks trying to understand Windows RT recovery system (most of the regards go to xda-developers forum), I've finally figured out how to restore my TF600T! :)
This post summarizes what I learned and provides the steps to recover your TF600T. Hope you can benefit from this
Important Notes:
- You can restore your TF600 even if you forgot to make a recovery image. For this, you'll have to use someone else's image. And fortunately, it's available here.
- You may not be able to use TF600TG or other variants' images on TF600T. How'd you check if you're using a proper image? Just try it! If it's incompatible, your device will simply refuse to boot with a certain error code. I spent a week to realize I was using a wrong image! The tricky part is that you'd still be able to enter recovery mode even with an incompatible image! Looks like the recovery image uses some kind of generic drivers?
- The USB drive that you would use for recovery has to have GPT partition table and is formatted to FAT32. I personally used GParted on Linux for this. How'd you check that you do this properly? Try getting into USB recovery mode. If you can't, chances are you didn't format your drive correctly.
Different modes and how to enter them:
1. Normal Mode:
a. Push power button
2. USB Recovery Mode:
a. Plug in a properly partitioned USB drive that has a proper image
b. Press and hold vol-down button when powering the device on. Keep holding the vol-button down until ASUS logo is shown. If you do this correctly, you'll get to a screen that prompts you for a language. If you don't see this, maybe there's a problem with your USB drive or the image on it.
3. Recovery Mode:
a. You can only go here if you have a proper installed OS
b. Push power button
c. Wait until you get to login screen
d. While holding the "Shift" keyboard-button, tap the power icon, and select restart
P.S. Recovery Mode is useful if you have a working operating system and also a recovery image specific to it. In this guide, we'll be using USB Recovery Mode to restore the device.
Steps:
1. Download the image that apatcas (from xda-developers) generously provided:
http://www.alexpatcas.com/vivort.rar
or from my mirror:
https://drive.google.com/open?id=0B7ufsmtTr_EjbVdQbVVJS19wX1U
2. Prepare a recovery USB drive
a. The image from (1) is 4.2GB, so you need at least that much of space
b. Format and partition your drive as GPT. If you're using Linux, I suggest using GParted. Instruction is as follow:
- Open GParted
- Select your USB drive from the dropdown on top right.
- Select "Device" -> "Create partition table" -> "GPT"
- Format the partition to FAT32 filesystem
c. Extract and paste the image from (1) onto the drive. You should see "boot", "sources", and "efi" directories on the top-level directory.
3. Prepare partitioning script to be run on your TF600T "USB Recovery Mode"
Save the script below as "X:\recovery.txt" (change X to your USB drive):
select disk 0
clean
convert gpt
create partition primary size=350
format quick fs=ntfs label="Windows RE tools"
assign letter="T"
set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac"
gpt attributes=0x8000000000000001
create partition efi size=260
format quick fs=fat32 label="System"
assign letter="S"
create partition msr size=128
create partition primary
shrink minimum=3072
format quick fs=ntfs label="Windows"
assign letter="W"
create partition primary
format quick fs=ntfs label="Recovery image"
assign letter="R"
set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac"
gpt attributes=0x8000000000000001
list volume
4. Enter "USB Recovery Mode" on your TF600T
5. Select English, select "Troubleshoot", select "Advanced", and select "Command Prompt"
6. Type: "diskpart"
7. On diskpart terminal, type: "list volume".
8. Remember the letter for your USB drive, on this tutorial, we'll refer to this as "X".
9. Quit from diskpart terminal by pressing "ctrl+c"
10. Format and partition your TF600T properly. Type: "diskpart /s X:\recovery.txt" (replace X with your USB drive)
11. Flash the image on your USB drive onto your TF600T:
- Type: "dism /apply-image /imagefile:X:\sources\install.wim /index:1 /applydir:W:"
- Grab a cup of coffee or two while waiting.
- Type: BOOTREC /FIXMBR
- Type: BOOTREC /FIXBOOT
- Type: BOOTREC /SCANOS
- Type: BOOTREC /REBUILDBCD
- Type: bcdboot w:\windows
14. Boot to windows normally! Enjoy!
Where I originally post this:
http://forum.xda-developers.com/showpost.php?p=60536721&postcount=127
Sunday, April 19, 2015
Using OpenCV 3.0
1. Generate OpenCV makefile using cmake (e.g. cmake CMakeLists.txt)
2. Compile using makefile generated at (1) (e.g. make -j8)
3. Install generated files (e.g. make install)
4. Export opencv shared library path:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
5. Compile your program like this: "g++ [source file goes here] `pkg-list opencv --config`"
2. Compile using makefile generated at (1) (e.g. make -j8)
3. Install generated files (e.g. make install)
4. Export opencv shared library path:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
5. Compile your program like this: "g++ [source file goes here] `pkg-list opencv --config`"
Wednesday, April 15, 2015
TCP/IP Programming in GO
Out of curiosity I googled around TCP/IP programming in Go! And guess what? It looks really beautiful! I found this great article explaining how to build a simple chat server in Go:
http://www.badgerr.co.uk/2011/06/20/golang-away-tcp-chat-server/
What's very interesting to me is the concept of "channel". In Android programming world, it's like a Handler. You can have any function posts something to it and it will magically get received by the handler function. And yes, channel posting and receiving is in a single thread, just like the default behavior of Handler in Android. Check out the article above, it explains many of the basic concepts really well.
http://www.badgerr.co.uk/2011/06/20/golang-away-tcp-chat-server/
What's very interesting to me is the concept of "channel". In Android programming world, it's like a Handler. You can have any function posts something to it and it will magically get received by the handler function. And yes, channel posting and receiving is in a single thread, just like the default behavior of Handler in Android. Check out the article above, it explains many of the basic concepts really well.
Monday, April 13, 2015
Synergy on ARM
I just recently got myself an NVIDIA Jetson TK1. Exciting! While developing using it, unfortunately it's quite slow to browse the website or listening to music through it.
So I had an idea to install Synergy client to it, while the server is on my laptop that's connected to it through Ethernet.
As there's no prebuilt Synergy for ARM 32bit, here's how you build it:
1. Download the source code from official synergy site
2. Download cmake, curl, and x11 dev libraries:
sudo apt-get install cmake libcurl4-openssl-dev libx11-dev libxtst-dev build-essential
3. After (2), compilation will still fail. You have to edit the include directory path on CMakeList.txt: Search for /usr/local/include and modify it to /usr/include
4. If you happened to had a compilation failure, try removing CMakeCache.txt and re-compile
5. If you encounter problem related to gmock, go to ext folder and extract gmock..zip to appropriate folder. There will be another cmake inside of it, build.
5. Enjoy!
Resource:
http://www.rootusers.com/compiling-synergy-from-source-on-the-raspberry-pi/
So I had an idea to install Synergy client to it, while the server is on my laptop that's connected to it through Ethernet.
As there's no prebuilt Synergy for ARM 32bit, here's how you build it:
1. Download the source code from official synergy site
2. Download cmake, curl, and x11 dev libraries:
sudo apt-get install cmake libcurl4-openssl-dev libx11-dev libxtst-dev build-essential
3. After (2), compilation will still fail. You have to edit the include directory path on CMakeList.txt: Search for /usr/local/include and modify it to /usr/include
4. If you happened to had a compilation failure, try removing CMakeCache.txt and re-compile
5. If you encounter problem related to gmock, go to ext folder and extract gmock..zip to appropriate folder. There will be another cmake inside of it, build.
5. Enjoy!
Resource:
http://www.rootusers.com/compiling-synergy-from-source-on-the-raspberry-pi/
Subscribe to:
Posts (Atom)




