---
title: "编译Android源码和Linux内核源码时候遇到的一些错误"
author: "fosa0989"
date: "2011-05-02T02:52:44Z"
tags: ["Android", "Google", "HTC", "Linux", "Ubuntu"]
categories: ["移动开发"]
slug: "android-linux"
draft: false
lastmod: "2011-05-31T08:05:13Z"
id: 1026001
url: "https://hchen229.iteye.com/blog/1026001"
---

1\. Ubuntu下执行命令 "adb reboot bootloader“ 或者 "adb start-server"得到如下错误：

 

error: device not found

原因1 可能是没有加usb 规则：

创建文件/etc/udev/rules.d/51-android.rules

在文件中加入：

#HTC phone

SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666"

#Google

SUBSYSTEM=="usb", SYSFS{idVendor}=="18d1", MODE="0666"

其它品牌手机编码在这个地方

http://developer.android.com/guide/developing/device.html#VendorIds

原因2 可能是手机没有设置允许usb debugger模式

Settings-&gt;Applications-&gt;Development-&gt;USB debugging选中

2\. 运行“adb devices” 得到如下错误：

 

List of devices attached 

???????????? no permissions

原因是没有使用root用户启动adb.

#sudo passwd root  //如果没有设置root的密码

#su

#cd out/host/linux-x86/bin

#./adb kill-server

#./adb start-server

#exit

再运行错误就没了。

 

3\. 各种各样的no permission错误

#su

使用root用户来执行命令

另外要设置好PATH=/home/&lt;user&gt;/&lt;android source root&gt;/out/host/linux-x86/bin/:$PATH

 

4\. fastboot -p passion -w flashall 获得如下错误

 

error: could not load android-info.txt

原因是没有unlock设备：

执行命令： fastboot oem unlock

用声音键选YES, 重启并且按住power和小白点进入fastboot模式。

5\. build linux kernel的错误

cc1: error: unrecognized command line option "-mlittle-endian"  
cc1: error: unrecognized command line option "-mapcs"  
cc1: error: unrecognized command line option "-mno-sched-prolog"  
cc1: error: unrecognized command line option "-mabi=aapcs-linux"  
cc1: error: unrecognized command line option "-mno-thumb-interwork"  
arch/arm/kernel/asm-offsets.c:1: error: bad value (armv5t) for -march= switch  
arch/arm/kernel/asm-offsets.c:1: error: bad value (strongarm) for -mtune= switch

原因是CROSS\_COMPILER路径没有设置正确

make ARCH=arm CROSS\_COMPILE=~/&lt;android source&gt;/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-

6\. implicit declaration of function 'kfree'

加入头文件 Linux/slab.h