Thursday, August 26, 2010

A Note on the Enabled Serial Port for Nexus One

It worked! Then, I flashed it to the phone and it persisted on reboot!


However, our apps could not access the newly-enabled serial port without superuser permissions. We fixed that this way.
$ ./adb shell
$ su
# chmod 777 /dev/ttyMSM0
Then, after rebooting the phone, the permissions for /dev/ttyMSM0 went back to normal (or were re-written on boot up).



For a phone running Cyanogen 6, I ran:
$ adb shell
$ su
# mount -o remount,rw /dev/block/mtdblock3 /system
I then pushed a file named 99foo to the phone's /etc/init.d/ directory (/etc/ is a symlink to /system/etc). The complete contents of 99foo:
#!/system/bin/sh
#makes USB-serial available to all users
chmod 777 /dev/ttyMSM0

I changed the permissions for 99foo so that they matched the permissions of the rest of the numbered files in this folder. I saw the existing permissions for 99foo as well as the rest of the numbered files by running this command:
# cd /etc/init.d
# ls -l
Then, I used chmod to add and take permissions as necessary. Then, I rebooted the phone. Now, the serial port is accessible to all users all the time!




For the phone running Android 2.2 with our hacked kernel, I will either edit the init.rc to allow access to /dev/ttyMSM0 for all users or, more likely, I will edit the init.rc file to run another file that I will write. Since I cannot edit init.rc while it's on the phone, I used this command (from my comPuter) to copy the init.rc to a location on my computer:
$ adb pull /init.rc /home/myname/init.rc
I will edit it. Then, I'll put it back with this command.
$ adb push /home/myname/init.rc /init.rc


I'm using this page for help.
http://www.androidenea.com/2009/08/init-process-and-initrc.html


I won't get to this very soon, as I have a more pressing matter to resolve. I'll blog more about it after I make some more progress.

No comments:

Post a Comment