2023年6月26日发(作者:)
Rockie’s Android Porting Guide
Rockie Cheng(阿虚)
aokikyon@
/aokikyon
Rockie's Android Porting Guide(1)——Build your own board
(1)在android跟目录下执行
. build/
(2)建立自己的board
copy build/target/board/generic to build/target/board/idea6410
修改build/target/product/,添加
$(LOCAL_DIR)/
copy build/target/product/ to build/target/product/
修改
# Overrides
PRODUCT_BRAND := idea6410
PRODUCT_DEVICE := idea6410
PRODUCT_NAME := idea6410
(3)tapas
[kyon@SEP4020 android2.0]$ tapas
Build for the simulator or the device?
1. Device
2. Simulator
Which would you like? [1]
Build type choices are:
1. release
2. debug
Which would you like? [1] 1
Which product would you like? [generic] idea6410
Variant choices are:
1. user 2. userdebug
3. eng
Which would you like? [eng]
============================================
PLATFORM_VERSION_CODENAME=Eclair
PLATFORM_VERSION=Eclair
TARGET_PRODUCT=idea6410
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=false
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=ECLAIR
============================================
[kyon@SEP4020 android2.0]$
以上只是基于generic简单的复制,需要更详细的定制开发板设备
附录:
1)build/target/product/内容
# This is a generic product that isn't specialized for a specific device.
# It includes the base Android platform. If you need Google-specific features,
# you should derive from generic_with_
PRODUCT_PACKAGES :=
AccountAndSyncSettings
AlarmClock
AlarmProvider
Bluetooth
Calculator
Calendar
Camera
CertInstaller
DrmProvider
Gallery
LatinIME
Mms
Music
Settings Sync
Updater
CalendarProvider
SyncProvider
$(call inherit-product, $(SRC_TARGET_DIR)/product/)
# Overrides
PRODUCT_BRAND := idea6410
PRODUCT_DEVICE := idea6410
PRODUCT_NAME := idea6410
产品名称及包含的应用程序
2)build/target/board/idea6410/
#
#
# Product-specific compile-time definitions.
#
# The generic product target doesn't have any hardware-specific pieces.
TARGET_NO_BOOTLOADER := true
TARGET_NO_KERNEL := true
TARGET_CPU_ABI := armeabi
HAVE_HTC_AUDIO_DRIVER := true
BOARD_USES_GENERIC_AUDIO := true
不编译bootloader及内核
使用arm eabi编译器
使用HTC和通用音频(没有使用ALSA)
如果需要添加HAL层驱动,需要修改此文件
3)build/target/board/idea6410/
LOCAL_PATH := $(call my-dir)
file := $(TARGET_OUT_KEYLAYOUT)/
ALL_PREBUILT += $(file)
$(file) : $(LOCAL_PATH)/ | $(ACP)
$(transform-prebuilt-to-target)
include $(CLEAR_VARS)
LOCAL_SRC_FILES :=
include $(BUILD_KEY_CHAR_MAP)
目前看来加入了一些键盘映射文件 Rockie's Android Porting Guide(2)——add USB WIFI to your system
手中zd1211b无线网卡已经可使用wpa_supplicant连接无线网络,
最近的工作主要为修改android的HAL层,使android能够识别该无线网卡。
Android默认使用wifi.c加载无线网卡驱动模块,如果直接编译进内核需要做一定修改。
(1)build/target/board/idea6410/
add
# Wifi related defines
BOARD_WPA_SUPPLICANT_DRIVER := WEXT
(2)externalwpa_
# CONFIG_NO_WPA=y
CONFIG_OS=unix
CONFIG_IEEE8021X_EAPOL=y
CONFIG_EAP_MD5=y
CONFIG_EAP_MSCHAPV2=y
CONFIG_EAP_TLS=y
CONFIG_EAP_PEAP=y
CONFIG_EAP_TTLS=y
CONFIG_EAP_GTC=y
CONFIG_EAP_OTP=y
CONFIG_EAP_SIM=y
CONFIG_EAP_AKA=y
CONFIG_EAP_PSK=y
CONFIG_EAP_SAKE=y
CONFIG_EAP_GPSK=y
CONFIG_EAP_PAX=y
CONFIG_EAP_LEAP=y
CONFIG_PKCS12=y
CONFIG_SMARTCARD=y
CONFIG_WIRELESS_EXTENSION=y
CONFIG_CTRL_IFACE=y
CONFIG_DRIVER_WEXT=y
(3)hardware/libhardware_legacy/wifi/wifi.c
将驱动直接编译进内核
int wifi_load_driver()
{
char driver_status[PROPERTY_VALUE_MAX];
int count = 100; /* wait at most 20 seconds for completion */ LOGE("wifi driver loaded !");
return 0;
}
int wifi_unload_driver()
{
int count = 20; /* wait at most 10 seconds for completion */
LOGE("wifi driver unloaded by rockie!");
return 0;
注意这个定义static const char IFACE_DIR[] = "/data/system/wpa_supplicant";
(4)编译整个android系统,确认编译完bin目录中含有wpa_supplicant、wpa_cli
(5)修改文件
add
mkdir /data/misc/wifi 0770 system system
mkdir /data/misc/wifi/sockets 0770 system system
mkdir /data/system/wpa_supplicant 0770 system system
chmod 0660 /data/misc/wifi/wpa_
add at the end
service wpa_supplicant /system/bin/wpa_supplicant -Dwext -iwlan0 -d -c
/data/misc/wifi/wpa_
# user wifi
# group wifi system
socket wpa_eth0 dgram 0660 wifi system
disabled
oneshot
service dhcpcd /system/bin/dhcpcd -f /system/etc/dhcpcd/ -d eth0
disabled
oneshot
on property:_supplicant=stopped
stop dhcpcd
(6)添加system/etc/wifi/wpa_ update_config=1
ctrl_interface=/data/system/wpa_supplicant //这个一定要和IFACE_DIR对应并保证目录权限
eapol_version=1
ap_scan=1
fast_reauth=1
(7)boot and try
Rockie's Android Porting Guide(3)——Add correct keymap to your system
We already have a keyboard dirver in Linux kernel.
Next, let us notice Android that we have a keyboard.
/* gpio buttons from linux*/
static struct gpio_keys_button gpio_buttons[] = {
{
.gpio = S3C64XX_GPN(0),
.code = 116,
.desc = "ENDCALL",
.active_low = 1,
.wakeup = 0,
},
{
.gpio = S3C64XX_GPN(1),
.code = 139,
.desc = "MENU",
.active_low = 1,
.wakeup = 0,
},
{
.gpio = S3C64XX_GPN(2),
.code = 99,
.desc = "ROTATE",
.active_low = 1,
.wakeup = 0,
},
{
.gpio = S3C64XX_GPN(3),
.code = 102,
.desc = "HOME",
.active_low = 1,
.wakeup = 0,
},
{ .gpio = S3C64XX_GPN(4),
.code = 42,
.desc = "BACK",
.active_low = 1,
.wakeup = 0,
},
{
.gpio = S3C64XX_GPN(5),
.code = 158,
.desc = "BACK",
.active_low = 1,
.wakeup = 0,
}
};
(1)Let me see logcat information.
I/EventHub( 58): New device: path=/dev/input/event1 name=S3C TouchScreen id=0x10000
(of 0x1) index=1 fd=45 classes=0x4
E/EventHub( 58): could not get driver version for /dev/input/mice, Not a typewriter
I/EventHub( 58): New keyboard: publicID=65537 device->id=0x10001 devname='gpio-keys'
propName='e' keylayout='/system/usr/keylayout/'
<<<<<<< I/EventHub( 58): New device: path=/dev/input/event0 name=gpio-keys id=0x10001 (of 0x2) index=2 fd=47 classes=0x1 E/EventHub( 58): could not get driver version for /dev/input/mouse0, Not a typewriter I/KeyInputQueue( 58): Device added: id=0x0, name=gpio-keys, classes=1 I/KeyInputQueue( 58): Device added: id=0x10000, name=S3C TouchScreen, classes=4 I/KeyInputQueue( 58): X: min=0 max=480 flat=0 fuzz=0 I/KeyInputQueue( 58): Y: min=0 max=272 flat=0 fuzz=0 I/KeyInputQueue( 58): Pressure: min=0 max=1 flat=0 fuzz=0 I/KeyInputQueue( 58): Size: unknown values I/KeyInputQueue( 58): No virtual keys found (2)make a file build/target/board/idea6410/ key 158 BACK WAKE_DROPPED key 139 MENU WAKE_DROPPED key 102 HOME WAKE key 116 ENDCALL WAKE_DROPPED key 99 ROTATOR key 42 POWER WAKE (3)make the another build/target/board/idea6410/ First,I just copy it from ,but it does not work. So I find this form the net,just a little change. It seems like 9 number keyboard more than qwerty. [type=QWERTY] # keycode display number base caps fn caps_fn A 'A' '2' 'a' 'A' '#' 0x00 B 'B' '2' 'b' 'B' '<' 0x00 C 'C' '2' 'c' 'C' '9' 0x00E7 D 'D' '3' 'd' 'D' '5' 0x00 E 'E' '3' 'e' 'E' '2' 0x0301 F 'F' '3' 'f' 'F' '6' 0x00A5 G 'G' '4' 'g' 'G' '-' '_' H 'H' '4' 'h' 'H' '[' '{' I 'I' '4' 'i' 'I' '$' 0x0302 J 'J' '5' 'j' 'J' ']' '}' K 'K' '5' 'k' 'K' '"' '~' L 'L' '5' 'l' 'L' ''' '`' M 'M' '6' 'm' 'M' '!' 0x00 N 'N' '6' 'n' 'N' '>' 0x0303 O 'O' '6' 'o' 'O' '(' 0x00 P 'P' '7' 'p' 'P' ')' 0x00 Q 'Q' '7' 'q' 'Q' '*' 0x0300 R 'R' '7' 'r' 'R' '3' 0x20AC S 'S' '7' 's' 'S' '4' 0x00DF T 'T' '8' 't' 'T' '+' 0x00A3 U 'U' '8' 'u' 'U' '&' 0x0308 V 'V' '8' 'v' 'V' '=' '^' W 'W' '9' 'w' 'W' '1' 0x00 X 'X' '9' 'x' 'X' '8' 0xEF00 Y 'Y' '9' 'y' 'Y' '%' 0x00A1 Z 'Z' '9' 'z' 'Z' '7' 0x00 # on pc keyboards COMMA ',' ',' ',' ';' ';' '|' PERIOD '.' '.' '.' ':' ':' 0x2026 AT '@' '0' '@' '0' '0' 0x2022 SLASH '/' '/' '/' '?' '?' '' SPACE 0x20 0x20 0x20 0x20 0xEF01 0xEF01 ENTER 0xa 0xa 0xa 0xa 0xa 0xa TAB 0x9 0x9 0x9 0x9 0x9 0x9 0 '0' '0' '0' ')' ')' ')' 1 '1' '1' '1' '!' '!' '!' 2 '2' '2' '2' '@' '@' '@' 3 '3' '3' '3' '#' '#' '#' 4 '4' '4' '4' '$' '$' '$' 5 '5' '5' '5' '%' '%' '%' 6 '6' '6' '6' '^' '^' '^' 7 '7' '7' '7' '&' '&' '&' 8 '8' '8' '8' '*' '*' '*' 9 '9' '9' '9' '(' '(' '(' GRAVE '`' '`' '`' '~' '`' '~' MINUS '-' '-' '-' '_' '-' '_' EQUALS '=' '=' '=' '+' '=' '+' LEFT_BRACKET '[' '[' '[' '{' '[' '{' RIGHT_BRACKET ']' ']' ']' '}' ']' '}' BACKSLASH '' '' '' '|' '' '|' SEMICOLON ';' ';' ';' ':' ';' ':' APOSTROPHE ''' ''' ''' '"' ''' '"' STAR '*' '*' '*' '*' '*' '*' POUND '#' '#' '#' '#' '#' '#' PLUS '+' '+' '+' '+' '+' '+' (4)add these to file := $(TARGET_OUT_KEYLAYOUT)/ ALL_PREBUILT += $(file) $(file) : $(LOCAL_PATH)/ | $(ACP) $(transform-prebuilt-to-target) include $(CLEAR_VARS) LOCAL_SRC_FILES := include $(BUILD_KEY_CHAR_MAP) (5)add these to -keys = /system/usr/keylayout/ -keys = /system/usr/keychars/ (6)build your system again Now we can see the different: I/EventHub( 63): New device: path=/dev/input/event1 name=S3C TouchScreen id=0x10000 (of 0x1) index=1 fd=50 classes=0x4 E/EventHub( 63): could not get driver version for /dev/input/mice, Not a typewriter E/KeyLayoutMap( 63): /system/usr/keylayout/:10: expected keycode, got 'ROTATOR' I/EventHub( 63): New keyboard: publicID=0 device->id=0x10001 devname='gpio-keys' propName='e' keylayout='/system/usr/keylayout/'<<<<<<< I/EventHub( 63): New device: path=/dev/input/event0 name=gpio-keys id=0x10001 (of 0x2) index=2 fd=52 classes=0x1 E/EventHub( 63): could not get driver version for /dev/input/mouse0, Not a typewriter I/KeyInputQueue( 63): Device added: id=0x0, name=gpio-keys, classes=1 I/KeyInputQueue( 63): Device added: id=0x10000, name=S3C TouchScreen, classes=4 I/KeyInputQueue( 63): X: min=0 max=480 flat=0 fuzz=0 I/KeyInputQueue( 63): Y: min=0 max=272 flat=0 fuzz=0 I/KeyInputQueue( 63): Pressure: min=0 max=1 flat=0 fuzz=0 I/KeyInputQueue( 63): Size: unknown values I/KeyInputQueue( 63): No virtual keys found System do not know the word "ROTATOR" presently. You can add a USB-KEYBOARD too. Rockie's Android Porting Guide(4)——Add SD card to your system Andorid uses vold to manage SD card and it is easy to use. But I meet many troubles and finally find that the real problem is in the Linux Kernel. Thanks to the Android Mail List. Part I (kernel) (1)make sure thus kernel configuration in MMC driver CONFIG_MMC=y # CONFIG_MMC_DEBUG is not set CONFIG_MMC_UNSAFE_RESUME=y # CONFIG_MMC_EMBEDDED_SDIO is not set CONFIG_MMC_PARANOID_SD_INIT=y # # MMC/SD Card Drivers # CONFIG_MMC_BLOCK=y CONFIG_MMC_BLOCK_BOUNCE=y # CONFIG_MMC_BLOCK_PARANOID_RESUME is not set # CONFIG_SDIO_UART is not set # CONFIG_MMC_TEST is not set # # MMC/SD Host Controller Drivers # CONFIG_MMC_SDHCI=y (2)Disable this option General Setup -> Create deprecated sysfs layout for older userspace tools Before I did this,vold showed a lot of trouble. And ,my media_path is not right media_path /devices/platform/s3c-sdhci.0/mmc_host:mmc0<--my path before turn off that option media_path /devices/platform/s3c-sdhci.0/mmc_host/mmc0 <--this is the right one Vold may be unhappy to accept my old path,and it didn't work. D/vold ( 42): Accepted connection from framework D/vold ( 42): dispatch_cmd(send_ums_status): D/vold ( 42): dispatch_cmd(mount_volume:/sdcard): E/vold ( 42): Cannot start volume '/sdcard' (volume is not bound) D/MountListener( 59): handleEvent volume_nomedia:/sdcard D/MountListener( 59): handleEvent ums_disabled D/MountListener( 59): handleEvent ums_disconnected (3) rebuild your linux kernel PART II(android system) (1) creat a in build/target/board/idea6410 ## vold configuration file for idea6410 volume_sdcard { ## This is the direct uevent device path to the SD slot on the device media_path /devices/platform/s3c-sdhci.0/mmc_host/mmc0 media_type mmc mount_point /sdcard ums_path /devices/platform/usb_mass_storage/lun0 } (2)add those below to include $(CLEAR_VARS) LOCAL_MODULE_CLASS := ETC LOCAL_MODULE := LOCAL_SRC_FILES := $(LOCAL_MODULE) include $(BUILD_PREBUILT) (3)rebuild the system and check service vold /system/bin/vold socket vold stream 0660 root mount (4)enjoy D/vold ( 42): Accepted connection from framework D/vold ( 42): dispatch_cmd(send_ums_status): D/vold ( 42): dispatch_cmd(mount_volume:/sdcard): I/vold ( 42): Evaluating dev '/devices/platform/s3c-sdhci.0/mmc_host/mmc0/mmc0:e624/block/mmcblk0' for mountable filesystems for '/sdcard' D/MountListener( 61): handleEvent volume_unmounted:/sdcard D/MountListener( 61): handleEvent ums_disabled D/MountListener( 61): handleEvent ums_disconnected D/MountListener( 61): handleEvent volume_checking:/sdcard Rockie's Android Porting Guide(5) ——Change your location and add the screenlock Today ,I just solved two small questions. One is changing the system location to CHINA, the other one likes a gift more , --a screen lock--and I don not know how to get it. (I) Change the system location simple and simple at the end of build/target/product/ add this: CUSTOM_LOCALES := zh_CN Of coures, you have many choises: ldpi hdpi mdpi en_US en_GB en_CA en_AU en_NZ en_SG ja_JP fr_FR fr_BE fr_CA fr_CH it_IT it_CH es_ES de_DE de_AT de_CH de_LI nl_NL nl_BE cs_CZ pl_PL zh_CN zh_TW ru_RU ko_KR (II) Add the screenlock I have wasted the whole morning online to serch a way to add the screenlock, but no answer. Then ,I find that build/target/product/ has more apps than ,so I decide to put them in my . Luckly,the Screenlock appears and the keyboard(lock & unclok) is working well. That must be one of the apks ,who can tell one which one? SoftKeyboardLiveWallpapersPicker or Fallback? AccountAndSyncSettings AlarmClock Camera Calculator Development DrmProvider Email Fallback GPSEnable Launcher Music Mms Settings SdkSetup CustomLocale gpstest sqlite3 LatinIME PinyinIME OpenWnn libWnnEngDic libWnnJpnDic libwnndict CertInstaller LiveWallpapersPicker ApiDemos GestureBuilder SoftKeyboard AccountAndSyncSettings AlarmClock AlarmProvider Bluetooth Calculator Calendar Camera CertInstaller DrmProvider Email Gallery LatinIME Mms Music Settings Sync Updater CalendarProvider SyncProvider BTW: Fix a bug about KCM files W/KeyCharacterMap( 401): Can't open keycharmap file W/KeyCharacterMap( 401): Error loading keycharmap file '/system/usr/keychars/'. e='gpio-keys' W/KeyCharacterMap( 401): Can't open keycharmap file E/KeyCharacterMap( 401): Can't find any keycharmaps (also tried /system/usr/keychars/) I/DEBUG ( 414): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** I/DEBUG ( 414): Build fingerprint: 'idea6410/idea6410/idea6410/:Eclair/ECLAIR/.20091226.183935:eng/test-keys' I/DEBUG ( 414): pid: 401, tid: 401 >>> <<< I/DEBUG ( 414): signal 11 (SIGSEGV), fault addr 00000004 I rebuild the whole codes for more than ten times and finally find that keypoint "No Read Right" Solution: add this to your chmod 777 system/usr/keychars/ Rockie's Android Porting Guide(6)——Add ALSA to your system (1)First,you need download alsa libs and tools from Android GIT. git clone git:///platform/external/ git clone git:///platform/external/ git clone git:///platform/hardware/alsa_ check each fold and run below command: git branch -a git checkout origin/eclair (2)build/target/board/idea6410/ #HAVE_HTC_AUDIO_DRIVER := true #BOARD_USES_GENERIC_AUDIO := true BOARD_USES_ALSA_AUDIO := true BUILD_WITH_ALSA_UTILS := true (3)make clean and rebuild (4)add to your final system/etc/ # # # # Mixer devices # # dPlayback { type hw card 0 # Can replace with drivers name from /proc/asound/cards } dRecord { type hw card 0 } # # # # Playback devices # # dPlayback { type hw card 0 device 0 } dPlayback_Speaker { type hw card 0 device 0 } dPlayback_Speaker_normal { type hw card 0 device 0 } dPlayback_Speaker_ringtone { type hw card 0 device 0 } dPlayback_Speaker_incall { type hw card 0 device 0 } dPlayback_Earpiece { type hw card 0 device 0 } dPlayback_Earpiece_normal { type hw card 0 device 0 } dPlayback_Earpiece_ringtone { type hw card 0 device 0 } dPlayback_Earpiece_incall { type hw card 0 device 0 } dPlayback_Bluetooth { type hw card 0 device 0 } dPlayback_Bluetooth_normal { type hw card 0 device 0 } dPlayback_Bluetooth_ringtone { type hw card 0 device 0 } dPlayback_Bluetooth_incall { type hw card 0 device 0 } dPlayback_Headset { type hw card 0 device 0 } dPlayback_Headset_normal { type hw card 0 device 0 } dPlayback_Headset_ringtone { type hw card 0 device 0 } dPlayback_Headset_incall { type hw card 0 device 0 } dPlayback_Bluetooth-A2DP { type hw card 0 device 0 } dPlayback_Bluetooth-A2DP_normal { type hw card 0 device 0 } dPlayback_Bluetooth-A2DP_ringtone { type hw card 0 device 0 } dPlayback_Bluetooth-A2DP_incall { type hw card 0 device 0 } dRecord { type hw card 0 device 0 } dRecord_Microphone { type hw card 0 device 0 }
发布者:admin,转转请注明出处:http://www.yc00.com/xiaochengxu/1687753232a39500.html
评论列表(0条)