Recent blog entries for fzort

22 Nov 2015 (updated 23 Nov 2015 at 01:55 UTC) »
Xperia E1 kernel tweaking (5)

Aaaand... another bug!

<4>[ 0.217984] WARNING: at /home/fzort/projects/xperia/kernel/fs/sysfs/dir.c:508 sysfs_add_one+0x88/0xb8()
<4>[ 0.218192] sysfs: cannot create duplicate filename '/class/sensors'

The device class sensors is registered twice, once by drivers/input/sensor_mgr.c, and then by (mainline kernel) drivers/sensors/sensors_class.c, which fails.

sensor_mgr.c seems to run first (is this deterministic?) so it's probably safe to remove sensors_class.c from the build. By the way, sensor_mgr.c also registers a device attribute called deviceInfor (yuck, camel case). Trying to read it on sysfs causes a kernel crash!

This bug is also present in stock software.

Edit: easy fix for the double /sys/class/sensors registration.

Edit 2: pretty awful kernel crash when doing a cat /sys/class/sensors/light/deviceInfor (or anything under /sys/class/sensors):

<1>[ 2909.524014] Unable to handle kernel NULL pointer dereference at virtual address 00000010
<1>[ 2909.524347] pgd = d4760000
<1>[ 2909.524610] [00000010] *pgd=00000000
<0>[ 2909.525297] Internal error: Oops: 805 [#1] PREEMPT SMP ARM

Edit 3: fixed
22 Nov 2015 (updated 22 Nov 2015 at 14:01 UTC) »
Xperia E1 kernel tweaking (4)

Looks like the msm-thermal driver (responsible for throttling the CPU frequency when things get hot) was not loading:

<4>[ 0.760658] msm_thermal: Wrong number of cpu

Relevant code in drivers/thermal/msm_thermal.c:

key = "qcom,cpu-sensors";
cpu_cnt = of_property_count_strings(node, key);
if (cpu_cnt != num_possible_cpus()) {
        pr_err("%s: Wrong number of cpu\n", KBUILD_MODNAME);
        ret = -EINVAL;
        goto hotplug_node_fail;

Looks like a mistake in the device tree (someone must have copy-pasted the qcom,msm-thermal section from a chipset with 4 cores, but this one only has 2). The fix was easy enough.

This also seems to happen with stock Sony software. If this were one of the flagship Xperia devices, I suppose I could submit a pull request, since the code for those phones is on github. But this is the lowest-end Xperia, only released on third-world markets - probably Sony won't care.
21 Nov 2015 (updated 22 Nov 2015 at 12:16 UTC) »
Xperia E1 kernel tweaking (3)

I was able to get rid of the error when trying to load the wlan.ko module by adding the option CONFIG_MODVERSIONS=n. But now I get another error:

<3>[ 21.083079] wlan: version magic '3.4.0-perf SMP preempt mod_unload modversions ARMv7 ' should be '3.4.0-perf SMP preempt mod_unload ARMv7 '

Trying to disable the checking on the kernel code made everything crash horribly. On a real Linux, I'd be able to try modprobe --force, but Android doesn't have modprobe. Sigh.

Edit: looks like the wlan.ko source code is on a separate repo after all. Not much much luck with it yet, though:
<6>[ 1601.775384] wlan: loading driver v3.2.3.185
<3>[ 1601.854994] wlan: driver load failure


Edit 2: after looking at the error messages displayed when the module is compiled with BUILD_DEBUG_VERSION and peeking around the code I could sort of guess that the configuration was incorrect and replaced the config files under /system/etc/firmware/wlan with the ones generated during the build. Now the module is loaded correctly with insmod, but for some reason is not loaded during boot. Still no wifi.

Edit 3: it works.
21 Nov 2015 (updated 22 Nov 2015 at 12:15 UTC) »
Xperia E1 kernel tweaking (2)

So I managed to get the kernel on the phone (gory details). But I don't get wifi - apparently because it's failing to load a module:

<6>[ 20.643671] wlan: disagrees about version of symbol module_layout

The module is not built with make modules - maybe it's closed-source. Sheesh.
19 Nov 2015 (updated 20 Nov 2015 at 05:54 UTC) »

So I tried to build a kernel for my lowly Xperia E1 smartphone today. Long story short, the kernel in the tarball I got from Sony's site didn't build out of the box, probably because I used gcc 4.8, which has the super nifty -Wsizeof-pointer-memaccess warning option.

It caught a bunch of facepalm-worthy bugs such as this one, in the akm8963 compass driver (drivers/misc/akm8963.c):

static ssize_t akm8963_sysfs_delay_show(
        struct akm8963_data *akm, char *buf, int pos)
        int64_t val;

        val = akm->delay[pos];

        return snprintf(buf,sizeof(buf), "%lld\n", val);

This one, in the BlueZ Bluetooth protocol stack (!) (net/bluetooth/hci_conn.c), reminded me of a recent rant by Linus Torvalds:

void hci_le_ltk_reply(struct hci_conn *conn, u8 ltk[16])
        struct hci_dev *hdev = conn->hdev;
        struct hci_cp_le_ltk_reply cp;
        BT_DBG("%p", conn);
        memset(&cp, 0, sizeof(cp));
        cp.handle = cpu_to_le16(conn->handle);
        memcpy(cp.ltk, ltk, sizeof(ltk));
        hci_send_cmd(hdev, HCI_OP_LE_LTK_REPLY, sizeof(cp), &cp);

I'm surprised this even works. Weirdly a similar memcpy is correct in the function immediately above this one.

After fixing these I eventually built the kernel, but couldn't get it to run on the phone yet (I think it should run with fastboot boot zImage-dtb). Ah well, I'll figure it out eventually.

By the way, it's very very nice of Sony to provide an official way to unlock the bootloader (that is, disable the kernel/ramdisk image checking in the bootloader), to provide instructions on how to build the kernel on their official blog, and to put the kernels for (most of) their smartphones on github. <3 you, Sony. Very different from a certain Korean smartphone manufacturer (won't name any names, but has a two-letter name).

20 Oct 2015 (updated 20 Oct 2015 at 15:46 UTC) »

This thing on?


So I'm on vacations until next Monday. I'll use this week to try to finish a little game I've been working on that I want to release on Google Play. Other than finishing the actual game code, I'll also try to add AdMob and Twitter integration. I'm paying someone to do the graphics.

I'll use my Advogato blog to post daily updates. No one reads it, which suits me just fine.

I'm rather enjoying C++11. Too bad I don't get paid to work with it. My main tool at work is Microsoft Outlook. Yikes. Someone please hire me to do development work. I'm really cheap.
20 Sep 2015 (updated 20 Sep 2015 at 04:24 UTC) »
sye: thanks for the link to "A Can of Worms". (Reminded me a bit of a small book I have...)
Further reason why I should be learning Mandarin.
davidw articulated very well something that has been on the back of my mind for a while.
19 Mar 2012 (updated 19 Mar 2012 at 20:21 UTC) »

After banging my head against Blender's interface for a while, I decided to leave behind any hope of modeling realistic 3D assets for the game I'm working on, and instead go for minimalistic, mid-1990s ciberspacey visuals. It's looking like this. Please ignore the pathetic FPS count.

I'm using textured billboard quads for the "antialiased wireframe" look. I have to sort all polygons in the scene back-to-front for proper transparency, so I'm using a BSP tree. Adding moving objects (like foes you can shoot at) to the BSP tree dynamically is presenting some interesting challenges.

I should upload a video soon.


Reading comments written by Americans on news sites like Yahoo under the story on the recent massacre in Afghanistan can get quite depressing. I'm sorry, I know I shouldn't, and I'll be the first to admit that my own country sucks, but it's really, really hard to avoid generalizing, you know.

207 older entries...

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!