Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Readers > Amazon Kindle > Kindle Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 06-28-2012, 11:38 AM   #1
mmatej
Connoisseur
mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.
 
Posts: 91
Karma: 14730
Join Date: Jun 2012
Device: none
Loading accelerometer driver in 5.1.0

Hi all!
I wanted to experiment with the accelerometer built into the Kindle Touch, but the FW version 5.1.0 doesn't load necessary driver automatically when booted in main (unlike the previous versions), so there's not /dev/input/event* for the accelerometer device. I tried to load the driver manually from the diags partition:
Code:
mount /dev/mmcblk0p2 /mnt/mmc/
insmod /mnt/mmc/lib/modules/2.6.31-rt11-lab126/kernel/drivers/hwmon/hwmon.ko
insmod /mnt/mmc/lib/modules/2.6.31-rt11-lab126/kernel/arch/arm/mach-mx5/mx50_yoshi_mma8453.ko
lsmod now shows the module:
Code:
Module                  Size  Used by
mx50_yoshi_mma8453      8836  0
hwmon                   2160  1 mx50_yoshi_mma8453
but there is still not event file in /dev/input. Have I missed something? Thanks for help!
mmatej is offline   Reply With Quote
Old 06-28-2012, 11:46 AM   #2
geekmaster
Carpe diem, c'est la vie.
geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.
 
geekmaster's Avatar
 
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
Quote:
Originally Posted by mmatej View Post
Hi all!
I wanted to experiment with the accelerometer built into the Kindle Touch, but the FW version 5.1.0 doesn't load necessary driver automatically when booted in main (unlike the previous versions), so there's not /dev/input/event* for the accelerometer device. I tried to load the driver manually from the diags partition:
Code:
mount /dev/mmcblk0p2 /mnt/mmc/
insmod /mnt/mmc/lib/modules/2.6.31-rt11-lab126/kernel/drivers/hwmon/hwmon.ko
insmod /mnt/mmc/lib/modules/2.6.31-rt11-lab126/kernel/arch/arm/mach-mx5/mx50_yoshi_mma8453.ko
lsmod now shows the module:
Code:
Module                  Size  Used by
mx50_yoshi_mma8453      8836  0
hwmon                   2160  1 mx50_yoshi_mma8453
but there is still not event file in /dev/input. Have I missed something? Thanks for help!
Although a bit out of my experience, don't you have to manually create the device node with "mknod" for the driver to use? And perhaps you need to tell it which event device number to use when loading, or when configuring it via some /sys interface (or ioctl call). I do not have a K5 with me to test this on, so this is just helpful guessing, but worth investigating...

On the K5 5.0.0, you can use the "waitforkey" command to see accelerometer rotation events (which return key codes just like the home button press and touch events).

You can also interrogate events with "evtest".

Last edited by geekmaster; 06-28-2012 at 11:49 AM.
geekmaster is offline   Reply With Quote
Advert
Old 06-28-2012, 11:56 AM   #3
knc1
Going Viral
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
Quote:
Originally Posted by mmatej View Post
Hi all!
I wanted to experiment with the accelerometer built into the Kindle Touch, but the FW version 5.1.0 doesn't load necessary driver automatically when booted in main (unlike the previous versions), so there's not /dev/input/event* for the accelerometer device. I tried to load the driver manually from the diags partition:
Code:
mount /dev/mmcblk0p2 /mnt/mmc/
insmod /mnt/mmc/lib/modules/2.6.31-rt11-lab126/kernel/drivers/hwmon/hwmon.ko
insmod /mnt/mmc/lib/modules/2.6.31-rt11-lab126/kernel/arch/arm/mach-mx5/mx50_yoshi_mma8453.ko
lsmod now shows the module:
Code:
Module                  Size  Used by
mx50_yoshi_mma8453      8836  0
hwmon                   2160  1 mx50_yoshi_mma8453
but there is still not event file in /dev/input. Have I missed something? Thanks for help!
They probably change (like in: removed) the udev rule that would have handled that device node creation.
Look in /etc/udev and /etc/udev.d of a copy of both versions of the image. The missing or commented out rule(s) should be easy to find.
knc1 is offline   Reply With Quote
Old 06-28-2012, 12:55 PM   #4
mmatej
Connoisseur
mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.
 
Posts: 91
Karma: 14730
Join Date: Jun 2012
Device: none
I compared folders /etc/udev/ and /usr/libexec/rules.d/ from FW versions 5.0.0 and 5.1.0 in WinMerge. They are identical, except one irrelevant change about USB/charger. I can't figure out how it could work in 5.0.0.
mmatej is offline   Reply With Quote
Old 06-28-2012, 02:06 PM   #5
knc1
Going Viral
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
Quote:
Originally Posted by mmatej View Post
I compared folders /etc/udev/ and /usr/libexec/rules.d/ from FW versions 5.0.0 and 5.1.0 in WinMerge. They are identical, except one irrelevant change about USB/charger. I can't figure out how it could work in 5.0.0.
Then it wasn't automated in 5.0.0, it was scripted somewhere.
knc1 is offline   Reply With Quote
Advert
Old 06-28-2012, 02:21 PM   #6
geekmaster
Carpe diem, c'est la vie.
geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.
 
geekmaster's Avatar
 
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
Quote:
Originally Posted by knc1 View Post
Then it wasn't automated in 5.0.0, it was scripted somewhere.
Probably scripted on 5.1.0 as well, with an upstart rule to run it on orientation activated from the settings (or app) menu, and perhaps kill it on orientation disabled from the menu. If I had my K5 with me, I would look in the upstart scripts. For now, I will have to leave it up to others to look there...
geekmaster is offline   Reply With Quote
Old 06-28-2012, 03:25 PM   #7
mmatej
Connoisseur
mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.
 
Posts: 91
Karma: 14730
Join Date: Jun 2012
Device: none
Quote:
Originally Posted by geekmaster View Post
Probably scripted on 5.1.0 as well, with an upstart rule to run it on orientation activated from the settings (or app) menu, and perhaps kill it on orientation disabled from the menu. If I had my K5 with me, I would look in the upstart scripts. For now, I will have to leave it up to others to look there...
I've compared upstart scripts from versions 5.0.0/5.1.0 and 5.1.0 main/5.1.0 diags and I can't find anything serious about accelerometer. They must have buried it really good.
mmatej is offline   Reply With Quote
Old 06-28-2012, 04:40 PM   #8
geekmaster
Carpe diem, c'est la vie.
geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.
 
geekmaster's Avatar
 
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
Quote:
Originally Posted by mmatej View Post
I've compared upstart scripts from versions 5.0.0/5.1.0 and 5.1.0 main/5.1.0 diags and I can't find anything serious about accelerometer. They must have buried it really good.
I seem to recall some accelerometer init stuff in u-boot source code (but not sure). I wonder if that is different. Hmm... Not in the kernel or the scripts? I wonder if there is a lipc command for it, called from the framework menu?

Last edited by geekmaster; 06-29-2012 at 07:29 AM.
geekmaster is offline   Reply With Quote
Old 06-29-2012, 04:40 AM   #9
mmatej
Connoisseur
mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.
 
Posts: 91
Karma: 14730
Join Date: Jun 2012
Device: none
I've found some stuff in uboot sources about accelerometer (probably checking if the accelerometer is connected to the bus), but it is not very helpful. I'm giving up. They've really screwed Kindle with this FW version.
mmatej is offline   Reply With Quote
Old 06-30-2012, 09:54 AM   #10
baf
Evangelist
baf ought to be getting tired of karma fortunes by now.baf ought to be getting tired of karma fortunes by now.baf ought to be getting tired of karma fortunes by now.baf ought to be getting tired of karma fortunes by now.baf ought to be getting tired of karma fortunes by now.baf ought to be getting tired of karma fortunes by now.baf ought to be getting tired of karma fortunes by now.baf ought to be getting tired of karma fortunes by now.baf ought to be getting tired of karma fortunes by now.baf ought to be getting tired of karma fortunes by now.baf ought to be getting tired of karma fortunes by now.
 
Posts: 404
Karma: 2200000
Join Date: May 2012
Device: kt
In 5.1 kernel they build it without mma8453. In arch/arm/mach-mx5/mx50_yoshi.c:
Code:
static struct i2c_board_info mxc_i2c0_board_info[] = {
        {
         .type = "MX50_Proximity",
         .addr = 0x0D,
        },
        #ifdef CONFIG_MX50_YOSHI_MMA8453
        {
         .type = "mma8453",
         .addr = 0x1C,
        },
        #endif

};
So i2c device is not instantiated automagically.

However I scanned i2c bus and device with address 0x1c is located on bus 0:

Code:
[root@kindle test]# ./i2cdetect 0
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c/0.
I will probe address range 0x03-0x77.
Continue? [Y/n] 
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- 1c -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --
To instantiate it manualy I did:

Code:
[root@kindle test]# echo mma8453 0x1c > /sys/devices/virtual/i2c-adapter/i2c-0/new_device
In dmesg:

Code:
i2c-adapter i2c-0: The new_device interface is still experimental and may change in a near future
input: mma8453 as /devices/virtual/i2c-adapter/i2c-0/0-001c/input/input5
check mma8453 chip ID
mma8453 0-001c: build time Nov  9 2011 15:38:29
i2c-adapter i2c-0: new_device: Instantiated device mma8453 at 0x1c
Also /dev/input/event4 is created, which gives some output when I move device.
baf is offline   Reply With Quote
Old 06-30-2012, 10:19 AM   #11
geekmaster
Carpe diem, c'est la vie.
geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.
 
geekmaster's Avatar
 
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
Quote:
Originally Posted by baf View Post
In 5.1 kernel they build it without mma8453. In arch/arm/mach-mx5/mx50_yoshi.c:
...
So i2c device is not instantiated automagically.

However I scanned i2c bus and device with address 0x1c is located on bus 0:
...
To instantiate it manualy I did:

Code:
[root@kindle test]# echo mma8453 0x1c > /sys/devices/virtual/i2c-adapter/i2c-0/new_device
...
Also /dev/input/event4 is created, which gives some output when I move device.
Awesome detective work! Thanks!
geekmaster is offline   Reply With Quote
Old 06-30-2012, 04:56 PM   #12
mmatej
Connoisseur
mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.
 
Posts: 91
Karma: 14730
Join Date: Jun 2012
Device: none
Thank you all very much for the help (especially baf)! It works great.
mmatej is offline   Reply With Quote
Old 06-30-2012, 05:27 PM   #13
mmatej
Connoisseur
mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.mmatej is less competitive than you.
 
Posts: 91
Karma: 14730
Join Date: Jun 2012
Device: none
Here's small auto-rotate script I've created:
Code:
#!/bin/sh
mount /dev/mmcblk0p2 /mnt/mmc
insmod /mnt/mmc/lib/modules/2.6.31-rt11-lab126/kernel/drivers/hwmon/hwmon.ko
insmod /mnt/mmc/lib/modules/2.6.31-rt11-lab126/kernel/arch/arm/mach-mx5/mx50_yoshi_mma8453.ko
umount /dev/mmcblk0p2
echo mma8453 0x1c > /sys/devices/virtual/i2c-adapter/i2c-0/new_device
while true; do
ROTATION=`hexdump -n16 /dev/input/event4|line|cut -f7 -d' '|cut -c4`;
[ "$ROTATION" == "b" ] && SET_TO='U';
[ "$ROTATION" == "c" ] && SET_TO='D';
[ "$ROTATION" == "d" ] && SET_TO='L';
[ "$ROTATION" == "e" ] && SET_TO='R';
lipc-set-prop com.lab126.winmgr orientationLock "$SET_TO";
done
Maybe someone will find it useful.
mmatej is offline   Reply With Quote
Old 07-01-2012, 07:11 AM   #14
baf
Evangelist
baf ought to be getting tired of karma fortunes by now.baf ought to be getting tired of karma fortunes by now.baf ought to be getting tired of karma fortunes by now.baf ought to be getting tired of karma fortunes by now.baf ought to be getting tired of karma fortunes by now.baf ought to be getting tired of karma fortunes by now.baf ought to be getting tired of karma fortunes by now.baf ought to be getting tired of karma fortunes by now.baf ought to be getting tired of karma fortunes by now.baf ought to be getting tired of karma fortunes by now.baf ought to be getting tired of karma fortunes by now.
 
Posts: 404
Karma: 2200000
Join Date: May 2012
Device: kt
I noticed that driver writes current orientation to /sys/devices/system/mma8453_rotation/mma8453_rotation0/mma8453_rotation
It is easier to read it from this file.
baf is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing accelerometer data from kindle touch sptrks Kindle Developer's Corner 18 01-14-2012 03:18 AM
Accelerometer bart34 Which one should I buy? 5 07-13-2011 02:38 PM
903 How to turn off accelerometer? osowiecki PocketBook 4 02-21-2011 03:38 AM
PB360: 3D Accelerometer funktioniert nicht kbaerwald PocketBook 13 11-02-2010 06:31 AM
How to disable the accelerometer ? askyn PocketBook 4 05-23-2010 12:38 PM


All times are GMT -4. The time now is 07:19 AM.


MobileRead.com is a privately owned, operated and funded community.