Samstag, 1. Februar 2020

Fix for ART-runtime in CM-11

Since two days the ART-runtime is broken on CM-11 (do not mix up with my A.R.T. - tool ;-). You will get an bootloop when you are running on ART and update to one of the latest nightlies.
For those who are building CM-11 from the sources, you can fix the bug by applying the following patch to the ART-runtime project:

diff --git a/runtime/native/dalvik_system_Zygote.cc b/runtime/native/dalvik_system_Zygote.cc
index d6cc249..4b24192 100644
--- a/runtime/native/dalvik_system_Zygote.cc
+++ b/runtime/native/dalvik_system_Zygote.cc
@@ -552,7 +552,7 @@ static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArra
   return pid;
 }
 
-static jint Zygote_nativeForkAndSpecialize_new(JNIEnv* env, jclass, jint uid, jint gid, jintArray gids,
+static jint Zygote_nativeForkAndSpecialize(JNIEnv* env, jclass, jint uid, jint gid, jintArray gids,
                                            jint debug_flags, jobjectArray rlimits,
                                            jint mount_external, jstring se_info, jstring se_name,
                                            jintArray fdsToClose) {
@@ -560,13 +560,6 @@ static jint Zygote_nativeForkAndSpecialize_new(JNIEnv* env, jclass, jint uid, ji
                                  se_info, se_name, false, fdsToClose);
 }
 
-static jint Zygote_nativeForkAndSpecialize(JNIEnv* env, jclass, jint uid, jint gid, jintArray gids,
-                                           jint debug_flags, jobjectArray rlimits,
-                                           jint mount_external, jstring se_info, jstring se_name) {
-  return ForkAndSpecializeCommon(env, uid, gid, gids, debug_flags, rlimits, 0, 0, mount_external,
-                                 se_info, se_name, false, NULL);
-}
-
 static jint Zygote_nativeForkSystemServer(JNIEnv* env, jclass, uid_t uid, gid_t gid, jintArray gids,
                                           jint debug_flags, jobjectArray rlimits,
                                           jlong permittedCapabilities, jlong effectiveCapabilities) {
@@ -590,8 +583,7 @@ static jint Zygote_nativeForkSystemServer(JNIEnv* env, jclass, uid_t uid, gid_t
 }
 
 static JNINativeMethod gMethods[] = {
-  NATIVE_METHOD(Zygote, nativeForkAndSpecialize_new, "(II[II[[IILjava/lang/String;Ljava/lang/String;[I)I"),
-  NATIVE_METHOD(Zygote, nativeForkAndSpecialize, "(II[II[[IILjava/lang/String;Ljava/lang/String;)I"),
+  NATIVE_METHOD(Zygote, nativeForkAndSpecialize, "(II[II[[IILjava/lang/String;Ljava/lang/String;[I)I"),
   NATIVE_METHOD(Zygote, nativeForkSystemServer, "(II[II[[IJJ)I"),
 };

Montag, 29. Juli 2013

Update Nexus 7 to Android 4.3 manually without loosing data

Sometimes one has modified some system files and OTA is failing due to those modifications. The easiest way in that case would be to do the update manually by using the factory image. Unfortunately applying the factory image directly does a factory reset, so all data will be lost, but knowing the principles behind, you can go to the lastest Androis version without loosing your data.

Get the factory image from Google and extract the following files from it:
  • bootloader-grouper-4.23.img
  • boot.img
  • system.img
If you have root and want to keep it, get
- UPDATE-SuperSU-v1.51.zip
and copy it to /sdcard and be sure, that you have a custom recovery installed on your device.

Then do a nandroid backup before starting (it's always better to have it) and then do a

fastboot flash bootloader bootloader-grouper-4.23.img
fastboot reboot-bootloader
fastboot flash boot boot.img
fastboot flash system system.img

reboot into recovery and flash UPDATE-SuperSU-v1.51.zip

Do a reboot system and, congrats, you should be on Android 4.3 without loosing any data.

Montag, 15. Juli 2013

Enable usbnet on ADS_Magpie / ezGingerbread

Currently I am playing around with my old G1 to set up a communication channel to a different android / Linux device. WiFi / Bluetooth is no problem at all, but I wanted to use a direct USB connection.
Having an USB Host mode available I was wondering how easy / complicate it would be to set up usbnet on the G1. As it turned out, it was surprisingly easy, because everything is already prepared within the kernel (which is available from Github):

echo 1 > /sys/devices/virtual/usb_composite/rndis


Afterwards one can configure an IP address and set the link up:

ip addr add dev usb0 10.0.0.2/24
ip link set usb0 up

There is only one thing to be regarded: after enabling usbnet, adb over usb will no longer work, so it's better to switch to WiFi before.

Mittwoch, 27. März 2013

Android Remote Toolkit

Some weeks ago, shortly after I bought my Nexus 7, I started on a new project, called Android Remote Toolkit (ART). The reason for this was very simple: I didn't find a suitable backup solution for my tablet.
  • CWM with nandroid is working, but stores the backup on the device itself. What's worth a backup on a device if it's later no longer accessible :(
  • TWRP offered the possibility to store the nandroid files to OTG, which is much better, but still uncomfortable.

I was looking for a solution where I could save the device backups directly to my PC or NAS. I looked around, but I didn't find any toolkit which was providing this functionality, to I started to write it by myself.

Looking around a bit, I found the Googles Tradefederation Project which provides many functions related to ADB and fastboot. I had a deeper look into it and decided to write a toolkit based on this lib. Today I finished what I would call Release 0.1 alpha, a set of useful functions which are working quite well, even if providing only a command line interface.
I will improve the toolkit step by step within the following weeks. Some ideas I have in mind are:
  • restore backup either using fastboot or using adb
  • create flashable zip from backup
  • provide a gui
  • integrate drivers (like +Adam Outler's +CASUAL)

ART is written in Java, so principally it's running on Linux / iOS and Windows.The sources can be found on Github/AndDiSa/ART. Binaries are nor available yet, but I will provide a first release soon.

Samstag, 23. Februar 2013

Print current branch of each project

When you are working on/with Android AOSP you are working with many projects and repositories having all their different bases and probably also different branches or tags.If you are doing your changes, generally you create a new branch, do your modifications, commit your changes, probably revert or switch to a different branch,execute the repo sync command and so on.
For me it happens often, that I do not exactly know, which project is currently checked out on which branch. If you are working on one single project, it's not a big problem. You execute
git branch
in the current working directory and you will get the info immediately. Working and switching between several projects, it's a pain to do it in that way. For that situation I wrote a small script which is doing that for all my projects:
while read line; do (cd $line; echo $line "`git branch`";) done <.repo/project.list

Creating a small shell script with the content shown above I can execute that script from the base directory of my projects and I am getting a full overview of the current status.

Dienstag, 19. Februar 2013

Native OTG USB disk support for Nexus 7 (WiFi) with Android 4.2.2

On XDA developers there was a discussion on native OTG USB stick support for the Nexus 7 and somebody provided also a patch which should enable this feature. Unfortunately he mixed up several things and the patch was not working. He was quite on a good way, but he missed some things, so I decided to dig around a bit to see how OTG-USB can be supported.

Since Android 4.2 the situation has become worse because of permissions and security changes and multi user support. The patch I am discribing here is not multi user compatible, i.e. all user will see all files on the external disk. So be warned if you want to use this feature.

First I want to describe a bit the modifications which need to be done to enable native OTG USB
  1. platform.xml is to be modified in such a way, that media_rw is allowed to access the external storage
    <permission name="android.permission.WRITE_EXTERNAL_STORAGE" >
       <group gid="sdcard_rw" />
       <group gid="media_rw" />
    </permission>
  2. vold.fstab is to be modified in such a way, that the usb is mounted automatically when the stick is plugged in
    # Mounts the first usable partition of the specified device
    dev_mount usbdisk /mnt/otg-usb auto /devices/platform/tegra-ehci.0
  3. init.grouper.rc is to be modified that on startup the mount directory is created
    on init
    ...
       mkdir /mnt/otg-usb 0777 sdcard_rw sdcard_rw
  4. storage_list.xml in framework-res.apk is to be modified that the external storage is added
    <!-- external USB OTG storage -->
    <storage android:mountPoint="/mnt/otg-usb"
       android:storageDescription="@string/storage_usb"
       android:primary="false"
       android:removable="true" />

As you can see on the different files to be modified, several components of the Android system are involved, i.e.
  • prepare a new ramdisk.img
  • prepare a new framework-res.apk
  • patch the platform.xml

I prepared an update.zip which applies the required modifications. The update.zip contains:
  • a new boot.img including my kernel (based on android-tegra3-grouper-3.1-jb-mr1.1, but I've added DM9601 and KSM support) and a ramdisk.img with the required modifications for the otg-usb support.
  • a patched framework-res.apk
  • a modified platform.xml

This update is compatible only with stock Android 4.2.2 (JDQ39) and it will break future OTA updates!
If you want to apply this patch, so be sure you know what you are doing and do it on your own risk. I am not responsible for any bricks, data loss, etc.
Please note: I've tested this only on the Nexus 7 (WiFi) and I am not sure, whether it will work on the GSM-version, too, even if I believe it should work, it's disabled in the updater script at the moment.

Another thing to note: Currently only vFAT partitions are recognized. NTFS principially is supported, but vold is not handling NTFS correctly and displays an empty filesystem / a partition to be formatted.

Update 21.02.2013: I've added a pached vold to the new otg-usb-enable-20130221.zip. Now it's possible to mount also NTFS filesystems, but read only at the moment.

Samstag, 16. Februar 2013

Using an Davicom 9601 based USB-Ethernet-Adapter with the Nexus 7

Some weeks ago I bought an USB ethernet adapter on Amazon. Unfortunately that adapter is not working with the Nexus 7, because the chipset is not supported by the kernel out of the box.
I found out, that the USB-Adapter (JP1082) is based on the Davicom 9601 chipset, which principally is supported by the linux kernel, so I decided to build a kernel which is supporting that adapter.

I did a git clone of the nexus 7 kernel sources from https://android.googlesource.com/kernel/tegra and a checkout of the latest kernel branch

git checkout android-tegra3-grouper-3.1-jb-mr1.1

after running

make ARCH=arm tegra3_android_defconfig

to create the default nexus kernel configuration the Davicom adapter needs to be added to the configuration by opening .config and changing the line

# CONFIG_USB_NET_DM9601 is not set

to

CONFIG_USB_NET_DM9601=y

Now the kernel is ready to be built:

make ARCH=arm zImage

after a successfull compilation the kernel can be booted by

fastboot boot arch/arm/boot/zImage

After booting the device and connecting the USB-ethernet adapter to the OTG-cable, you need to open a terminal window and call

/system/bin/dhcpcd eth0

to configure the ethernet link. That's all!