Friday, December 20, 2013

Replicant on Galaxy S3

I recently got my self and Galaxy S3 for testing out Replicant, an android image made out of only open source components.

Why Galaxy S3?

It is well supported in Replicant, almost every driver is already open source. The hardware specs are acceptable, 1.4Ghz quad core, 1GB ram, microsd, and all the peripheral chips one expects for a phone. Galaxy S3 has sold insanely (50 million units supposedly), meaning I won't run out of accessories and aftermarket spare parts any time soon. The massive installed base also means a huge potential user community. S3 is still available as new, with two years of warranty.

Why not

While the S3 is still available new, it is safe to assume production is ending already - 1.5 year old product is ancient history in mobile world! It remains to be seen how much the massive user base will defend against the obsolescence. Upstream kernel support for "old" cpu is open question, replicant is still basing kernel on vendor kernel. Bootloader is unlocked, but it can't be changed due to trusted^Wtreacherous computing, preventing things like boot from sd card. Finally, not everything is open source, the GPU (mali) driver while being reverse engineered, is taking it's time - and the GPS hasn't been reversed yet.

Installing replicant

Before install, from the original installation, you might want to take a copy of firmware files (since replicant won't provide them). enable developer mode on the S3 and:
sudo apt-get install android-tools
mkdir firmware
adb pull /system/vendor/firmware/  
adb pull /system/etc/wifi
After then, just follow official replicant install guide for S3. If you don't mind closed source firmwares, post-install you need to push the firmware files back:
adb shell
mount -o remount,rw /system
adb push . /system/vendor/firmware
Here was my first catch, the wifi firmwares from jelly bean based image were not compatible with older ICS based replicant.

Using replicant

Booting to replicant is fast, few seconds to the pin screen. You are treated with the standard android lockscreen, usual slide/pin/pattern options are available. Basic functions like phone, sms and web browsing have icons from the homescreen and work without a hitch. Likewise camera seems to work, really the only smartphone feature missing is GPS.

Sidenote - this image looks a LOT better on the S3 than on my thinkpad. No wonder people are flocking to phones and tablets when laptop makers use such crappy components.

The grid menu has the standard android AOSP opensource applications in the ICS style menu with the extra of f-droid icon - which is the installer for open source applications. F-droid is it's own project that complements replicant project by maintaining a catalog of Free Software.
F-droid brings hundreds of open source applications not only for replicant, but for any other android users, including platforms with android compatibility, such as Jolla's Sailfish OS. Of course f-droid client is open source, like the f-droid server (in Debian too). F-droid server is not just repository management, it can take care of building and deploying android apps.
The WebKit based android browser renders web sites without issues, and if you are not happy with, you can download Firefox from f-droid. Many websites will notice you are mobile, and provide mobile web sites, which is sometimes good and sometimes annoying. Worse, some pages detect you are android and only offer you to load their closed android app for viewing the page. OTOH I am already viewing their closed source website, so using closed source app to view it isn't much worse.

This keyboard is again the android standard one, but for most unixy people the hacker's keyboard with arrow buttons and ctrl/alt will probably be the one you want.

Closing thoughts

While using replicant has been very smooth, the lack of GPS is becoming a deal-breaker. I could just copy the gpsd from cyanogen, like some have done, but it kind of beats the purpose of having replicant on the phone. So it might be that I move back to cyanogen, unless I find time to help reverse engineering the BCM4751 GPS.

Monday, July 22, 2013

ACPI on ARM storm in teacup

A recent google+ post by Jon Masters caused some stormy and some less stormy responses.

A lot of BIOS/UEFI/ACPI hate comes X86, where ACPI is used from everything from suspending devices to reading buttons and setting leds. So when X86 kernel suspends, it does magic calls to ACPI and prays that the firmware vendor did not screw it up. Now vendors do screw up, hence lots of cursing and ugly workarounds in the kernel follows. My Lenovo has a firwmare bug where the FN-buttons and Fan stops working if the laptop is attached on AC adapter for too long. The fan is probably a simple i2c device the kernel could control directly without jumping through ACPI hiding layer hoops. But the X86 people hold the view it is better to trust the firmware engineer to control devices instead of having the kernel folk to write device drivers to ... control devices!

Now on ARM(64) the idea of using ACPI is to have none of that.

Instead the idea is to use ACPI only to provide tables for enumerating what devices are available in the platform. Just like what device tree does. Now if this is the same as device tree, why bother?

The main reason is to allow the distribution installer behave same on X86 / ARM / ARM64. This is crucial for distributions like fedora and RHEL where a cabal holds the point of view that X86 distribution development must not be constrained by ARM support. But it also important for everyone that the method of installing your favorite distribution to an ARM64 server is standard and works the same for any server from any vendor. Now while UEFI and ACPI are definitely not my preferred solutions, I can accept them as necessary evil for having a more standard platform.

Monday, February 4, 2013

On behalf of aarch64 porters

Public service announcement

When porting GNU/Linux applications to a new architecture, such as 64-Bit ARM, one gets familiar with the following error message:

checking build system type... x86_64-pc-linux-gnu
checking host system type... Invalid configuration `aarch64-oe-linux': machine `aarch64-oe' not recognized
configure: error: /bin/sh config.sub aarch64-oe-linux failed

This in itself is trivial to fix - run autoreconf or just copy in new versions of config.sub and config.guess. However, when bootstrapping a distribution of 12000+ packages, this becomes quickly tiresome. Thus we have a small request:

If you are an upstream of a software that uses autoconf - Please run autoreconf against autotools-dev 20120210.1 or later, and make a release of your software.

Aarch64 porters will be grateful as updated software trickles down to distributions.

This was the most discussed point during my FOSDEM talk "Porting applications to 64-Bit ARM".

Thursday, December 20, 2012

Sananen Ruuhkamaksusta

Ruuhkamaksun idea on yksinkertainen - mitä kovempi ruuhka, sitä kovempi maksu. Maaseudun hiljaisten teiden ajaminen olisi halpaa kun taas ruuhka-aikaan kaupunkiin ajaminen kallista. Itse asiassa kaupungissa ajamisesta voisi ylipäätään laskuttaa enemmän. Ruuhkamaksua pitäisi kerätä yksityisyyttä loukkaamatta, ja maksun kiertämisen pitäisi olla hankalaa.

Minulla on uutinen - Meillä on jo tuollainen ruuhkamaksu.

Sitä kutsutaan polttoaineveroksi.

Ruuhkamaksun keräyslaite

Ruuhkassa ajaminen on nykivää kaasun ja jarrun polkemista. Auton moottori syö ruuhkassa helposti 2-3 kertaa enemmän bensaa kuin tasainen ajaminen ruuhkattomilla teillä. Näin autoilija maksaa ruuhkassa jopa kolme kertaa enemmän polttoaineveroa. Polttomoottori mittaa tarkasti ajettua matkaa, ja maksattaa autoilijalle lisälaskua ruuhka-ajon lisäksi mm. isolla autolla ajamisesta, raskaan kaasujalan käyttämisestä ja turhasta ajamisesta ylipäätänsä. Polttoaineverosta ei kerry viranomaisille rekisteriä kansalaisten liikkeistä.

Polttoainevero on suoraan vero siitä kuinka paljon autoilija lämmittää maapalloa hiilidioksidipäästöillään. Ja ilmasto on kai pohjimmiltaan se syy miksi ruuhkamaksua halutaan! Polttoainevero tekee siis jo kaiken sen mitä ruuhkamaksu toivoo - ilman että tarvitsee rakentaa kallista valvontajärjestelmää.

Liikenneministeriön raportissa satelliittivalvontaan perustuva ruuhkamaksun luominen maksaisi kuulemma 200-300 miljoonaa, ja ylläpitokustannukset vuosittain 10% tästä eli 20-30 miljoonaa. Tieto ja Accenture tekee taattua laatua aikataulussa, budjetissa ja ilman yksityisyyttä vaarantavia bugeja - uskokoon ken tahtoo. Herääkin epäilys, että koko hankkeen tarkoitus on vain luoda työllisyyttä it-konsulteille ja autoasentajille.

Automatka töihin on useimmille mukavuus- eikä hintakysymys. Tämän voi jokainen itse todentaa katselemalla moniko länsiväylän ruuhkassa matelevista autoista on järkevä ja edullinen pikkuauto ja moniko kalliimpi ja mukavampi iso auto. Jos kaupunkiautoilua halutaan vähentää, pitää tehdä tehdä julkisista mukavampia ja kätevämpiä kuin autoista. Monelle julkiset ovatkin kätevämpiä - siksi julkisilla on paljon käyttäjiä Helsingissä. Miten vielä useammalla julkiset saataisiin kätevämmäksi, olisikin sitten toisen blogipostauksen asia.

Eturivin Audi jonottaa Helsinkiin siksi että se on halpaa?

ps. Ruuhkamaksu-työryhmää vetää Shellin hallituksen puheenjohtaja Jorma Ollila - ehkä siksi yksinkertaisemmat ratkaisut kuten esim. polttoaineveron korotus ei ole käynyt työryhmän mielessä.

Saturday, October 27, 2012

My 5 eurocents on the Rasberry Pi opengl driver debacle

The Linux community rather unenthusiastic about the open source shim to Raspberry PI GPU. I think the backslash is a bit unfair, even if the marketing from Raspberry was pompous - It is still a step in the right direction. More raspberry PI hardware enablement code is open source than before.

A step in the wrong direction is "locking firmware", where a loadable firmware is made read-only by storing it to a ROM. It has been planned by the GTA04 phone project, and Raspberry foundation also considers making a locked GPU ROM device. This is madness that needs to stop. It may fulfill the letter of FSF guidelines, but it is firmly against the spirit. It does not increase freedom - it takes away vendors ability to provide bugfixes to firmware, and communities possibility of reverse engineering the firmware.

Monday, October 22, 2012

F-droid store for android

Christopher complained that in android, you need a user account to install software. That is not true, there is F-droid which is a catalog of Free/Open Source Software, no user account needed.

Lack of multitasking is yes annoying sometimes, yes, but that is really a poweruser problem. Most users don't load web pages in background while playing. Most users will simply not bother with web pages that take too long to load. Given the choice, most users will prefer a snappy UI over a UI that allows proper multitasking. N900 was never snappy, stutters were common, and it would often hang for long times if you had too many apps or browser windows open at the same time. Even for Android there are way more complaints about non-fluid UI than lack of proper multitasking. It is thus only logical for the Android developers to concentrate in developing a snappier UI over improving multitasking.

The fact that Android has given 400+ million Linux computers out in the hands of consumers is one of the MOST AMAZING THINGS ever. But it seems others on FOSS community seem to consider Android a rather unfortunate event, because it's not "Real Linux" or "100% free software" or "because it's not bug free". Err, like Maemo or MeeGo ever is any of those...

It is fair to complain about usability quirks Android as enduser. But if you believe Free Software, you should also see the opportunity the open source parts of Android provides to you fix it to your needs. After all, the point of Free Software is that you don't need to depend on the upstream to fix you everything? Christoph complains that the stock email app is lacking. Android Email app is Open Source (Maemo and N9 email apps are not). Android email has been forked as K-9 Mail. The app lifecycle is fixable allowing you to return from browser to the mail you were at - at least a plenty of other apps manage to do that.

The question is, are we consumers or creators. If we are just sitting waiting to Google provide us a perfect shrinkwrapped Android, we could just as well use iPhone or Windows phone. We should instead see Android as an opportunity - when it's 90% open source, fix the remaining closed source bits like open source 3D drivers and open source replacements for proprietary interfaces.

Thursday, June 7, 2012

Adventures in perlsembly

Some Debian packages are missing important optimizations. This one was noticed when comparing openssl benchmarks by monkeyiq to the results got on a pandaboard (OMAP 4430). Being a Cortex-A9, it should have clearly been same or faster than the N9 in the benchmark (OMAP 3630). And it was, except for AES benchmarks. Since AES is quite important, that seemed a bit odd. Turns out, that Debian/Ubuntu package had some hand-crafted arm assembler optimizations missing. Enable them, and the results with openssl speed command benchmark were quite nice:
The 'numbers' are in 1000s of bytes per second processed.

benchmark    debian       with patch +%
sha1         55836.67k -> 73599.08k +31.811%
aes-128 cbc  18451.11k -> 36305.34k +96.765%
aes-256 cbc  13552.30k -> 27108.31k +100.027%
sha256       20092.25k -> 43469.45k +116.349%
sha512       8052.74k  -> 37194.28k +361.884 %
rsa 1024     1904.2v/S -> 3650.5v/s +91.708 %
Curiously, the assembler code is actually in perl files that output assembler code. This kind of code is affectionately called "perlsembly". A bug with patch has been filed, hopefully applied at the soonest.