Getting Android Kernel modules onto the G1 PDF Print E-mail
Tuesday, 31 March 2009 09:45

By default /system/lib/modules (where kernel modules are stored) is read-only and and the adb remount command which remounts the /system partition read-write fails.  Changing this is relatively straightforward but I'm bound to forget how I did it so here goes:

  • Initially this is what happened when I tried to push the kernel modules to the phone
      cianer@Feegle:~/images$ adb push ../msm/drivers/usb/gadget/g_ether.ko /system/lib/modules
      failed to copy '../msm/drivers/usb/gadget/g_ether.ko' to '/system/lib/modules/g_ether.ko': Read-only file system
      cianer@Feegle:~/images$ adb remount
      remount failed: Operation not permitted
      cianer@Feegle:~/images$
  • To allow adb remount to work /default.prop needs to be changed from ro.secure=1 to ro.secure=0.  To do this I needed to repack the boot image, thus:
      cianer@Feegle:~/images/mtd2.img-ramdisk$ ls
      data          dev   init.goldfish.rc  init.rc        logo.rle  sbin  system
      default.prop  init  initlogo.rle      init.trout.rc  proc      sys
      cianer@Feegle:~/images/mtd2.img-ramdisk$ vi default.prop
                <edit the file so that ro.secure=0>
      cianer@Feegle:~/images$ repack-bootimg.pl kernel.gz mtd2.img-ramdisk img.ro_secure_0
      2266 blocks

      repacked boot image written at img.ro_secure_0
      cianer@Feegle:~/images$ adb push img.ro_secure_0 /sdcard
      1031 KB/s (1882112 bytes in 1.782s)
      cianer@Feegle:~/images$ adb shell
      $ su
      # cat /dev/zero > /dev/mtd/mtd2
      write: No space left on device
      # flash_image boot /sdcard/img.ro_secure_0
      # exit
      $ exit
      cianer@Feegle:~/images$
  • Reboot the ADP1 so that the new kernel takes effect & then try again.
      cianer@Feegle:~/images$ adb push drivers/usb/gadget/g_ether.ko /system/lib/modules
      failed to copy 'drivers/usb/gadget/g_ether.ko' to '/system/lib/modules/g_ether.ko': Read-only file system
      cianer@Feegle:~/images$ adb remount
      remount succeeded
      cianer@Feegle:~/images$ adb push drivers/usb/gadget/g_ether.ko /system/lib/modules
      1273 KB/s (718998 bytes in 0.551s)
      cianer@Feegle:~/images$
  • Another handy side-effect of this is that when you do the adb shell command you are automatically logged in as root so you don't have to type su.  Hours of mantime saved!
Of course if these are just test modules you can insmod them from /sdcard - the adb remount is only necessary if you want them to automagically work from /system/lib/modules.
 
Joomla Templates by Joomlashack