博文

Android7.1编译Out of memory error问题

在Android7.1编译过程中出现如下错误: Starting build with ninja ninja: Entering directory `.'  [  0% 8/30301] Ensure Jack server is installed and started Jack server already installed in "/home/guochongxin/.jack-server" Launching Jack server java -XX:MaxJavaStackTraceDepth=-1 -Djava.io.tmpdir=/tmp -Dfile.encoding=UTF-8 -XX:+TieredCompilation -cp /home/guochongxin/.jack-server/launcher.jar com.android.jack.launcher.ServerLauncher [  0% 10/30301] Building with Jack: out/target/common/obj/JAVA_LIBRARIES/libprotobuf-java-micro_intermediates/classes.jack [  0% 12/30301] Building with Jack: out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/with-local/classes.dex FAILED: /bin/bash out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/with-local/classes.dex.rsp Out of memory error (version 1.2-rc4 'Carnac' (298900 f95d7bdecfceb327f9d201a1348397ed8a843843 by android-jack-team@google.com)). GC overhead limit exceeded. Try increasing heap size with java opt...

关于USB HID Report Descriptors

图片
  最近有需要调试一款USB HID设备,拿到了该款HID设备的Report Descriptors,找了一些资料学习了下,下面转发讲解清晰易懂的一篇内容(http://eleccelerator.com/tutorial-about-usb-hid-report-descriptors/):   Tutorial about USB HID Report Descriptors   A USB HID report descriptor is one of the descriptors that a USB host can request from a USB device. HID devices send data to the host using reports, and the descriptor tells the host how to interpret the data. I will try to show you how to write one of these descriptors.   First, go to this page http://www.usb.org/developers/hidpage/ and find the document titled “Device Class Definition for HID”. What I will be talking about is essentially paraphrasing the important sections of that document.   Second, go get the HID descriptor tool from the same page. You’ll want to play with it as you go through this tutorial. It is an absolute headache to write the HID report descriptors manually (converting between binary and hex and looking up the meanings of the numbers) so...

Android源码下进行APK签名

  在Android源码下如何对APK手动签名呢?需要如下几个步骤:   1、编译signapk JAR包:     在Android源码目录下执行make signapk命令,即可在out/host/linux-x86/framework/目录下生成signapk.jar文件。   2、对已编译好的普通APK进行签名:     java -jar out/host/linux-x86/framework/signapk.jar build/target/product/security/platform.x509.pem build/target/product/security/platform.pk8 xinu.apk xinu_new.apk     以上都是在Android源码目录下执行,对xinu.apk进行签名,签名后名为xinu_new.apk,其中pem和pk8是签名时要用到的key文件,使用Android源码下的key可在编译出来系统上运行时获取System权限等。   参考网址:   http://www.android123.com.cn/kaifafaq/815.html   http://chroya.iteye.com/blog/803028   http://www.android123.com.cn/androidkaifa/173.html   http://www.91linux.com/html/article/qianrushiyingyong/google_android/20100920/20670.html

Android系统在小内存下的使用

  最近在调试的方案,硬件配置是512MB的DDR,这在Android4.4这号称优化很大的系统版本上运行还是很吃力,找了一些资料,发现我们的方案上使用到了ZRAM这一技术,直接使用压缩内存来作为交换分区,其中涉及到的内核配置如下:   CONFIG_SWAP=y   CONFIG_CGROUP_MEM_RES_CTLR=y   CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y   CONFIG_ZRAM=y   CONFIG_ZSMALLOC=y   接下来运行起来后(如上述编译失败,需要把SYSFS和BLOCK相关配置加上),可以看到有/dev/block/zram0 这一结点,然后我们的方案在init.rc里加了一个service,其为oneshot类型,就是执行一个脚本了,脚本内容如下:   #!/system/bin/sh   echo $((256*1024*1024))  > /sys/block/zram0/disksize   mkswap /dev/block/zram0   swapon /dev/block/zram0   sleep 1   mkfs.ext2 -b 4096 /dev/block/zram0   sleep 1   mount -t rootfs -o remount -rw rootfs /   mkdir /swap_zram0   sleep 1   mount -t rootfs -o remount -r rootfs /   mount -t ext2 -o rw /dev/block/zram0 /swap_zram0   这样的话,我们就有了一个交换分区来使用了,但发现使用free -m命令查看时,SWAP分区一直没有使用,并且一直有lowmemorykiller的操作,后来发现是我们的/sys/module/lowmemorykiller/parameters/minfree参数还是1GB DDR的配置,故而将其按一定比例调小后就可以了。...

Android下制作OTA包及验证

  当我们拿到一份Android源码后,要如何制作OTA升级包(实质上是Recovery升级的ZIP包,OTA升级是基于Recovery的机制再加上下载ZIP包和ZIP包版本管理等功能实现)呢?(注:下面命令如无特别说明,则均在Android源码目录下执行)   1.进入Android源码目录下执行如下命令来初始化环境变量:    source build/envsetup.sh    lunch    其中,lunch命令运行后会要求选择所要编译的产品名。   2.编译生成OTA包(前提是Android需先完整编译过一次)    make otapackage    执行上述命令后,会生成out/target/product/XXX/YYY-ota-eng.guochongxin.zip和out/target/product/XXX/obj/PACKAGING/target_files_intermediates/YYY-target_files-eng.guochongxin.zip两个后期需要使用到的包,其中前一个为完整升级包,后一个为后期制作增量升级包时的对比包,那么如何制作增量升级包呢?假如系统里的软件是A版本,然后我们刚使用make otapackage命令制作了B版本,此时我们可以在之前保留的A版本的临时目标文件基础上制作增量包,过程如下(在Android源码根目录下执行):    ./build/tools/releasetools/ota_from_target_files -v -i A-target_files-eng.guochongxin.zip out/target/product/XXX/obj/PACKAGING/target_files_intermediates/YYY-target_files-eng.guochongxin.zip YYY-eng.guochongxin_incremental.zip    执行上述命令后,会在当前目录下生成YYY-eng.guochongxin_incremental.zip增量包,其中A-target_f...

Android UART触摸框调试

  在Android系统里调试UART口触摸框时,需要使用到Linux内核的SERIO框架,涉及的配置项为CONFIG_SERIO=y和CONFIG_SERIO_SERPORT=y,而我们需要的驱动里会包含module_serio_driver()宏注册的驱动接口,可以在内核源码drivers/input/touchscreen目录下搜索上述的这个宏就可以搜索到相关的驱动,我们可以找最相近的作为参考来修改,有了这个驱动后,我们还需要有一个上层应用程序inputattach,该程序用于将实际使用的串口设备与这个驱动关联上,实际上该程序里面最重要的是ioctl(fd, SPIOCSTYPE, &devt)这一操作,就是实现关联操作。如在init*.rc里有如下服务:   service irtouch /system/bin/inputattach --baud 9600 --boray /dev/ttyS1     class main     oneshot   上述提及相关资料可以参考如下网址:   http://lwn.net/Articles/122577/   http://sourceforge.net/p/linuxwacom/input-wacom/ci/master/tree/inputattach/

通过Netlink检测USB设备的插拔

    在Android的Vold里面可以了解到,其检测USB的插拔是通过Netlink机制来实现的,那我们也来尝试下如何在Linux下写个程序检测USB设备的插拔,下面我们将使用Netlink的NETLINK_KOBJECT_UEVENT类型套接字与Kernel进行通信,然后使用setsocketopt()来利用该套接字,再使用select()并发检测相应的套接写是否可操作,具体的代码实现 如下: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <fcntl.h> #include <sys/socket.h> #include <linux/netlink.h> #define UEVENT_BUFFER_SIZE 2048 int main(void) {     struct sockaddr_nl client;     struct timeval tv;     int fd, rcvlen, ret;     fd_set fds;     int buffersize = 1024;     fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_KOBJECT_UEVENT);     memset(&client, 0, sizeof(client));     client.nl_family = AF_NETLINK;     client.nl_pid = getpid();     client.nl_groups = 1; /* receive broadcast message*/     setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &buffe...