Rabu, 03 April 2013

Port BlankOn ke ARM

Sebenarnya kalau bilang mau port suatu sistem operasi ke ARM, itu artinya bisa luas sekali. Seperti kita ketahui. ARM itu bukan nama sebuah prosesor, tapi adalah arsitektur prosesor. Arsitektur ini sendiri memiliki banyak versi gugus instruksi, ada ARMv1, ARMv2, dan seterusnya sampai ARMv8. Dan tiap-tiap versi memiliki keluarga implementasi yang berupa-rupa. Misalnya ARMv3 diimplementasikan pada keluarga ARM6 dan ARM7 (perhatikan tidak ada huruf v sekarang), ARMv11 diimplementasikan pada keluarga ARM Cortex-A8, ARM Cortex-A9 dan sebagainya. (Mudah-mudahan tidak pusing :D)

Keluarga ARM tadi juga diimplementasikan oleh beragam pabrik yang memegang hak lisensi ARM. Misalnya untuk ARM Cortex-A9 ada cukup banyak pabrik yang menyediakan sistem dalam chip (System-On-Chip alias SoC), misalnya Amlogic, NVIDIA Tegra 2, ST-Ericsson, dan sebagainya.

Tiap-tiap SoC punya konfigurasi sendiri-sendiri dengan menggunakan sistem jaringan, audio, grafik dan kawan-kawan yang berbeda-beda pula.

Dari keragaman tadi, tentunya berimplikasi bahwa walaupun kita punya satu sistem operasi yang jalan baik di sebuah sistem ARM, belum tentu akan jalan sempurna di sistem ARM yang lain. Tidak seperti di keluarga i386, sebuah sistem Linux dapat dipasang dengan mudah dalam beragam komputer dengan keluarga prosesor yang sama.


Saat melakukan porting, kita akan menentukan lingkup pekerjaan:

  • Seberapa banyak keluarga ARM yang mesti didukung?
  • Seberapa banyak SoC yang mesti didukung?


Lalu kalau kita bilang BlankOn ingin di-port ke ARM, maksudnya apa?

Di sini, kita cukup pilih salah satu keluarga ARM yang ada di tangan para pengembang, dan dari situ sudah cukup klaim bahwa BlankOn di-port ke ARM. Paling tidak saya ada Raspberry Pi (ARM11) dan tablet dengan prosesor Amlogic AML8726-M (ARM Cortex-A9). Jadi kita mulai saja dari kedua sistem tersebut. Ini artinya kita harus mengembangkan dua jenis ARM yang berbeda (ARMv7 untuk ARM Cortex-A9 dan ARMv6 untuk Raspberry Pi).

Lalu bagaimana prosesnya secara umum?
Pertama kali adalah menyiapkan toolchain, yaitu seperangkat alat untuk melakukan kompilasi program. Toolchain harus dikonfigurasikan sesuai dengan jenis prosesor, gugus instruksi, dan varian kompilasi. Sebagai contoh, BlankOn hendak menggunakan konfigurasi hard-float untuk ARMv7 dan ARMv6. Maka, kita perlu dua buah konfigurasi yang berbeda.

Lalu, apa yang mesti dibangun ulang? Mari kita lihat bagan di bawah ini.

Itu adalah bagan sederhana sebuah sistem komputer yang umum. Untuk memastikan port kita berhasil atau tidak, maka kita perlu menyelesaikan port pada semua bagian pada bagan.

Boot loader
Ini adalah sebuah program kecil yang ditanam pada sistem komputer. Program ini dijalankan saat pertama kali komputer dinyalakan, sebelum kernel dimuat. Bootloader ini bertugas memuat sistem operasi atau bahkan memuat bootloader lain. Pada beberapa sistem, bootloader dikunci sehingga tidak dapat memuat sistem operasi lain selain sistem operasi yang disediakan pabrik. Untuk memudahkan pekerjaan kita, lebih baik gunakan perangkat yang bootloadernya tidak terkunci.

Kernel
Kernel adalah jantung sistem operasi. Dia yang mengatur bagaimana sebuah berkas ditulis, bagaimana sebuat paket data dikirim, bagaimana tombol pada papan tik dapat bereaksi, dan seterusnya. Jika perangkat yang kita targetkan memiliki perangkat keras tertentu, maka kita memerlukan penggerak (driver) untuk perangkat keras tersebut agar dapat diatur oleh kernel. Banyak SoC yang memerlukan penggerak dengan lisensi tidak bebas sehingga menyulitkan proses porting.

Userspace
Userspace adalah program-program yang dijalankan sistem dan pengguna akhir. Jika kita sudah memiliki program-program yang dibangun dengan gugus instruksi prosesor yang serupa dengan perangkat target kita, maka kita tinggal menyalin saja program-program tersebut. Namun bila tidak ada, kita harus membangun ulang semua program di userspace dengan gugus instruksi prosesor yang kita gunakan di perangkat target kita. Contohnya, paket-paket yang dikompilasi untuk Raspberry Pi harus dibangun ulang untuk perangkat tablet dengan ARM Cortex-A9.

Dari bagan di atas, bagian-bagian yang diarsir adalah bagian yang spesifik ada di perangkat target kita. Untuk setiap target yang kita inginkan, bagian yang diarsir tersebut harus kita sediakan. Jika kita ingin mendukung 5 buah tablet dengan konfigurasi berbeda, maka kita perlu 5 salinan bagian yang diarsir tadi khusus untuk masing-masing perangkat.

Lalu, setelah semua beres dan sistem dapat melakukan boot ke terminal, apakah kita stop di sini? Tentu saja tidak. Hal-hal yang didiskusikan di atas adalah baru pondasi dari keseluruhan port. Langkah selanjutnya adalah:

  • Memastikan performa perangkat berjalan baik: jaringan berjalan dengan benar dengan kapasitas yang sesuai spesifikasi, memori dan sistem pemberkasan tidak ada yang rusak/korup, tidak ada program yang beku, dan sebagainya
  • Optimasi penggunaan daya
  • Penyesuaian aplikasi. Jika kita menargetkan sebuah tablet, tentu aplikasi-aplikasi kita harus jalan di tablet dengan baik. Jika perangkat kita ada perangkat keras khusus misalnya sensor, maka sensor harus dapat dibaca dari aplikasi dengan baik


Jadi, begitulah kira-kira perjuangan yang harus dilakukan demi mengatakan klaim: Saya melakukan port <masukkan nama distro Anda di sini> ke ARM.

Senin, 01 April 2013

Referensi obyek di JavaScript

Mari jalankan nodejs di terminal lalu ketik:
> a = 12

(tanda > adalah prompt nodejs, tidak perlu diketik).

di layar akan tampil bahwa nilai a adalah 12.

Kemudian kita ketik:
> b = a

Tentu kita harapkan bahwa nilai b adalah sama dengan nilai a, yaitu 12.
Kita bisa pastikan dengan cara mengetik:
> b

Mestinya tampil angka 12.

Lalu bagaimana kalau kita ganti nilai a?
Ketikkan:
> a = 42

Berapa nilai b sekarang? 42 atau tetap 12?
Ketikkan lagi di layar:

> b

Maka akan tampil angka 12. Artinya, nilai b tetap walaupun nilai a diubah.

Mari kita coba lagi dengan jenis lain, yaitu string.
Mari kita ketik:
> a = "saya"

Kemudian kita buat variabel b dan isi dengan nilai a.
> b = a

Kemudian lihat isi nilai b dengan cara mengetik:

> b

Tentu nilai b adalah "saya".
Lalu bagaimana jika kita ubah nilai a?

> a = "sayur"

Periksa isi nilai b:

> b

Maka akan tampil tulisan "saya". Artinya, nilai b juga tidak berubah walaupun nilai a kita ganti.

OK. Sekarang mari kita bikin sebuah obyek.

> a = { nama: "cecep" }

Kemudian kita set variabel b dengan nilai a

> b = a

Kita periksa isi b:

> b
{ nama: 'cecep' }

Kemudian mari kita ubah nilai a menjadi:
> a.nama = "sodikin"

Periksa isi nilai a:

> a
{ nama: 'sodikin' }

Periksa isi b:
> b
{ nama: 'sodikin'}

Oh, ternyata sekarang isi b mengikuti isi a. Apa pun yang kita ubah di a, maka di b turut berubah, tidak seperti sebelumnya. Ini terjadi karena untuk jenis obyek, JavaScript akan menggunakan referensi. Ini mirip dengan pointer di bahasa C/C++. Ibaratnya, variabel b diikat dengan tali ke variabel a. Jika a diubah, maka saat membuka b, JavaScript akan mengikuti tali yang ada hingga ke ujungnya di variabel a, dan isinya dibaca. Jika bukan jenis obyek, isi nilai akan disalin mentah-mentah. Ibaratnya, setiap variabel memiliki kaleng. Setiap diset nilainya, nilai tersebut dimasukkan ke dalam kaleng. Jika nilai variabel yang ada di kaleng a diubah, maka nilai di kaleng di variabel b tidak terpengaruh.

Jika sekarang kita ubah jenis a ke jenis lain, maka jenis b akan tetap sebagai obyek dengan nilai yang tadinya dipegang oleh a.

> a = 12
> b
{ nama: 'sodikin' }

Sekarang bagaimana caranya kalau kita tidak ingin JavaScript mengikatkan tali ke obyek, namun benar-benar berlaku seperti kaleng? Silakan dijadikan PR. (Petunjuk, bisa gunakan Object.keys(b) untuk dapatkan semua kunci di obyek b, kemudian salin isi nilai yang ditunjuk oleh kunci-kunci tersebut ke obyek baru. Jangan lupa ini harus rekursif).

Minggu, 31 Maret 2013

Design and architecture of BlankOn Installer

BlankOn Installer is the central application used in BlankOn Live Media starting from BlankOn 8.0 Rote release. It is a full-screen application intended to take over the desktop when you are not using the live feature of the media.

It is an HTML5 application and the runtime is built with webkitgtk and Vala. The front-end is totally written in HTML, JavaScript and CSS while the back-end is written with various languages bridged by Vala.

The installer slated for BlankOn 9.0 Suroboyo consists of several subsystems below:

  • Partition Editor
  • File System Copier
  • Boot Loader Installer
  • Package Installer
  • File System Configurator

The subsystems are called in sequence according to the stage the user is in. The stage is started with a partition editor and ended with a boot loader installation.
The previous version of installer has similar subsystems but lacks of advanced partition editor and package installer.

Pattern

The software is written using a consistent pattern described as follows. The front-end will call the JS functions defined in the back-end part using JavaScriptCore which is passed in the webkitgtk. The back-end could implement the functionailites by it's own or just call third party libraries or scripts. The JS function defined in the back-end is simply a facade.



To enable developing front-end by just using a web browser, stubs of the JS functions to be defined in the back-end must be provided.

Partition Editor

The installer has an advanced partition editor called PartoEdi. The editor is using KineticJS to make the partition making interactive. The changes in the partitions are accumulated and then played back with libparted in the backend.



The output of the subsystem is a ready to use partition marked for installation and a swap partition. 

File System Copier

This subsystem copies the read only part of the live media into the marked partition. It copies everything without any modifications. The copying is done in the backend using rsync.



The rsync is chosen to get the progress of the copy and to be able to preserve the attributes of the copied files and directories.


File System Configurator

The configurator is run after the installer successfully copied all the files from the media. It creates user and groups defined by the installer. It sets the password. It sets the basic configuration of the system.



The configurations are made by the backend which runs the scripts.


Package Installer

This subsystem, as the name suggests, installs additional packages chosen by user. In the installation, user can choose a certain installation profile. This effectively installs the packages described by the profile. The profile is simply a meta package containing the list of additional packages.



This imperatively says that the packages installed in the live media are the packages shared by all of these profiles. A profile could also ask to remove certain packages installed in the media. The installation is made from local repository self contained in the media itself.

Boot Loader Installer

This subsystem installs the GRUB2 (and optionally with EFI support) into the boot partition.





As you can see the installer is pretty simple and straightforward. At the time of writing this article, the advanced partition, package installer and EFI support is not yet implemented.

Senin, 25 Februari 2013

Running popular mobile platform SDKs in BlankOn 64 bit

For Linux developers, at least both Nokia and BlackBerry suggest to use 32-bit installation. This is to avoid incompatibilities because they only provide their tools in 32-bit. However, it is possible to run them in 64-bit installation by following the guidelines below. The key is to install correct 32-bit packages. These SDKs provided tools are unfortunately very silent when they are missing some packages. The list of packages here were obtained by doing tracing and troubleshooting with strace and ldd tools.

I use 64-bit BlankOn 9.0 Suroboyo alpha daily release. It is compatible with Debian Sid, so the guidelines here applies also to Debian or Ubuntu or other Debian derivatives. The method described here is the multiarch. By using this guide, I can successfully run Nokia Web Tools for Asha and BlackBerry 10 Native Development Kit.

First, we need to register the i386 architecture into the dpkg system:

sudo dpkg --add-architecture i386

Then we need to refresh the package database:
sudo apt-get update
Then we start to install the necessary packages. The packages we install are the GTK+ and friends, Bluetooth, SSL and XUL runner packages:
sudo apt-get  -f -o Dpkg::Options::="--force-overwrite" install ia32-libs gtk2-engines-murrine:i386 libgtk2.0-bin:i386 libgtkmm-2.4-dbg:i386 libbluetooth3:i386 xulrunner-7.0:i386  libstartup-notification0:i386 libssl0.9.8:i386
And that's it. Now you can install the SDKs and enjoy coding for the platforms you desire.



Rabu, 20 Februari 2013

My book is out

Yes, I know many of you think that development environment evolves very quickly and not suitable for printed books, but printed books is still better than having nothing for the developers who have hard time to get a decent internet connection.

Enough said, here it is: GNOME 3 Application Development Beginner's Guide

Minggu, 20 Januari 2013

Icons which are meaningless to (most) people today

Nowadays, too many people in young ages use computers, be it a laptop, smart phone or tablet. Yet, the software are still using icons which are only meaningful to older people. How old? It depends. The line is drawn until a certain person knows or has access to the technology or the metaphors represented by the icons.

Let's see one by one. Note: the icons are not mine, they are from openclipart.org and wikipedia.

Floppy disk for Save

When was the last time you saw this old man's USB stick? Maybe never. Yet, the floppy disk is still used to represent save operation.




Phone handset for Phone


When was the last time you saw this handset? Maybe we still have this in some countries, but I haven't seen it in the last 3 countries I visited in last 3 years (except in museum).




Magnetic tape reel for voice mail

Did you see Mission Imposible TV series in the 1960s? Then you are familiar with the magnetic tape reel :D But how come the object become the voice mail icons?






Hourglass for waiting

This may make sense for most people, but maybe not. In another hand, hourglass shows remaining time left, and not to say that you need to wait. Even if you use hourglass in your apps which the audience is toddlers or kids, maybe they will not get it immediately and will start to hit and punch the device when they're tired of waiting.



Desk calendar for calendar

This is another rarely seen object around the house. If you have the days and dates shown on the icon maybe it is fine, but if just shows tables, maybe it is not.





Rolodex for address book


I personally never seen this in real life, so I event did not get what this thing suppose to mean :D














But hey, we forgot the most important thing. Do we need to keep them or replace them? If we want to replace, replace with what?