Tweaking Froyo for Nitrogen Part 3: housekeeping and custom WLAN
Published on August 31, 2010
So far in this series of posts on Froyo, we've mostly ignored the fact that the Nitrogen board isn't a Freescale Babbage board. We generally have fewer stock peripherals and have left the configuration of those untouched. In this post, I'll walk through the removal of GPS, Bluetooth and GSM and update the wireless LAN driver to support a different adapter, a Unigen USB dongle.
Housecleaning
Removal is fairly easy: just yanking the appropriate lines for the bluetooth, GPS, and GSM services. The following patch shows the pieces I pulled out:
diff --git a/imx5x/init.rc b/imx5x/init.rc index a0de583..349f897 100755 --- a/imx5x/init.rc +++ b/imx5x/init.rc @@ -159,8 +159,6 @@ loglevel 3 # create basic filesystem structure mkdir /data/misc 01771 system misc - mkdir /data/misc/bluetoothd 0770 bluetooth bluetooth - mkdir /data/misc/bluetooth 0770 system system mkdir /data/misc/keystore 0700 keystore keystore mkdir /data/misc/vpn 0770 system system mkdir /data/misc/systemkeys 0700 system system @@ -302,9 +300,6 @@ on boot # ReadMin, ReadInitial, ReadMax, WriteMin, WriteInitial, WriteMax, setprop net.tcp.buffersize.default 4096,87380,110208,4096,16384,110208 setprop net.tcp.buffersize.wifi 4095,87380,110208,4096,16384,110208 - setprop net.tcp.buffersize.umts 4094,87380,110208,4096,16384,110208 - setprop net.tcp.buffersize.edge 4093,26280,35040,4096,16384,35040 - setprop net.tcp.buffersize.gprs 4092,8760,11680,4096,8760,11680 # Set property for FSL specific feature # Init second display connection state @@ -384,18 +379,10 @@ on boot mkdir /data/misc/dhcp 0770 dhcp dhcp chown dhcp dhcp /data/misc/dhcp -# Prepare for bluetooth - chmod 666 /sys/class/rfkill/rfkill0/state - chown bluetooth bluetooth /sys/class/rfkill/rfkill0/state - write /sys/class/rfkill/rfkill0/state 0 - # Enable USB remote wakeup write /sys/bus/platform/drivers/fsl-ehci/fsl-ehci.0/power/wakeup enabled write /sys/bus/platform/drivers/fsl-ehci/fsl-ehci.1/power/wakeup enabled -# Prepare for RIL - setprop gsm.ril.delay 15 - class_start default ## Daemon processes to be run by init. @@ -432,18 +419,17 @@ service netd /system/bin/netd service debuggerd /system/bin/debuggerd -service ril-daemon /system/bin/rild -l /system/lib/libreference-ril.so -- -d /dev/ttyUSB3 -u /dev/ttyUSB0 - socket rild stream 660 root radio - socket rild-debug stream 660 radio system - user root - group radio cache inet misc audio - service zygote /system/bin/app_process -Xzygote /system/bin --zygote --start-system-server socket zygote stream 666 onrestart write /sys/android_power/request_state wake onrestart write /sys/power/state on onrestart restart media +service dbus /system/bin/dbus-daemon --system --nofork + socket dbus stream 660 bluetooth bluetooth + user bluetooth + group bluetooth net_bt_admin + service media /system/bin/mediaserver user media group system audio camera graphics inet net_bt net_bt_admin net_raw @@ -455,43 +441,6 @@ service bootanim /system/bin/bootanimation disabled oneshot -service dbus /system/bin/dbus-daemon --system --nofork - socket dbus stream 660 bluetooth bluetooth - user bluetooth - group bluetooth net_bt_admin - -service bluetoothd /system/bin/bluetoothd -n - socket bluetooth stream 660 bluetooth bluetooth - socket dbus_bluetooth stream 660 bluetooth bluetooth - # init.rc does not yet support applying capabilities, so run as root and - # let bluetoothd drop uid to bluetooth with the right linux capabilities - group bluetooth net_bt_admin misc - disabled - -service hfag /system/bin/sdptool add --channel=10 HFAG - user bluetooth - group bluetooth net_bt_admin - disabled - oneshot - -service hsag /system/bin/sdptool add --channel=11 HSAG - user bluetooth - group bluetooth net_bt_admin - disabled - oneshot - -service opush /system/bin/sdptool add --channel=12 OPUSH - user bluetooth - group bluetooth net_bt_admin - disabled - oneshot - -service pbap /system/bin/sdptool add --channel=19 PBAP - user bluetooth - group bluetooth net_bt_admin - disabled - oneshot - service installd /system/bin/installd socket installd stream 600 system system @@ -533,13 +482,3 @@ service wpa_supplicant /system/bin/logwrapper /system/bin/wpa_supplicant socket wpa_wlan0 dgram 660 wifi wifi oneshot -service pppd_gprs /etc/init.gprs-pppd - user root - group radio cache inet misc - disabled - oneshot - -service glgpsd /system/bin/glgps -c /etc/glconfig.xml normal - user root - group system - disabled
Because the init.rc
file goes into the RAM disk, it requires not only a rebuild, but also the mkimage
step.
user@host:~/myandroid$ make PRODUCT-imx51_bbg-eng
user@host:~/myandroid$ mkimage -A arm -O linux -T ramdisk -n "Initial Ram Disk"
-d ~/myandroid/out/target/product/imx51_bbg/ramdisk.img
./initrd.u-boot
Image Name: Initial Ram Disk
Created: Tue Aug 31 08:55:23 2010
Image Type: ARM Linux RAMDisk Image (gzip compressed)
Data Size: 212713 Bytes = 207.73 kB = 0.20 MB
Load Address: 00000000
Entry Point: 00000000
Because we now have adb
up and running, copying and re-starting is now a bit easier. No more fussing with SD cards!
user@host:~/myandroid$ adb push initrd.u-boot /boot && adb shell 'sync && reboot'
530 KB/s (212777 bytes in 0.391s)
Beyond the updates above, you can also reduce the footprint of the image by removing references to Bluetooth and GSM by editing devices/fsl/imx5x/BoardConfigCommon.mk
:
diff --git a/imx5x/BoardConfigCommon.mk b/imx5x/BoardConfigCommon.mk index 2a66124..3e7d910 100755 --- a/imx5x/BoardConfigCommon.mk +++ b/imx5x/BoardConfigCommon.mk @@ -16,16 +16,13 @@ TARGET_PROVIDES_INIT_RC := true #BOARD_USES_GENERIC_AUDIO := true BOARD_USES_ALSA_AUDIO := true BUILD_WITH_ALSA_UTILS := true -BOARD_HAVE_BLUETOOTH := true +BOARD_HAVE_BLUETOOTH := false USE_CAMERA_STUB := false BOARD_CAMERA_LIBRARIES := libcamera BOARD_HAVE_WIFI := true -BOARD_HAVE_MODEM := true -BOARD_MODEM_VENDOR := HUAWEI -BOARD_MODEM_ID := EM750M -BOARD_MODEM_HAVE_DATA_DEVICE := true +BOARD_HAVE_MODEM := false HAVE_FSL_IMX_CODEC := true BUILD_WITHOUT_FSL_DIRECTRENDER := false
This change will require a full make PRODUCT-imx51_bbg-eng
cycle to rebuild and may take a while. You should be able to update after this change by using adb sync
.
Wireless LAN
Wireless LAN configuration is a bit more complicated. What we're trying to do is replace the Atheros AR6000 driver with the Unigen RTL8172 driver.
To do this, we'll first need to trace the build dependencies for the Atheros driver.
In device/fsl/imx51_bbg/BoardConfig.mk
, there's a first level reference to the Atheros driver:
WIFI_DRIVER_MODULE_PATH := "/system/lib/modules/ar6000.ko"
WIFI_DRIVER_MODULE_ARG := ""
WIFI_DRIVER_MODULE_NAME := "ar6000"
WIFI_FIRMWARE_LOADER := ""
The code for the Atheros driver itself is in external/fsl_imx_wifi_atheros/2.2.1.83/AR6K_ANDROID_SDK.2.2.1.83
, and looking in that directory, we can find host/Android.mk
:
#Android makefile to build kernel as a part of Android Build
ifneq ($(TARGET_SIMULATOR),true)
LOCAL_PATH := $(call my-dir)
ATH_SRC := $(LOCAL_PATH)
ATH_LINUXPATH := kernel_imx
#export ATH_SRC_BASE=$(ATH_SRC)
#export ATH_BUILD_TYPE=FSL_ARM_NATIVEMMC
#export ATH_BUS_TYPE=sdio
#export ATH_OS_SUB_TYPE=linux_2_6
#export ATH_LINUXPATH=kernel_imx
#export ATH_ARCH_CPU_TYPE=arm
#export ATH_BUS_SUBTYPE=linux_sdio
export ATH_ANDROID_FW_PATH=yes
#export ATH_EEPROM_FILE_USED=no
#export ATH_SOFTMAC_USED=no
ATH_HIF_TYPE:=sdio
#ATH_SRC_BASE:= .
mod_file := $(TARGET_OUT)/lib/modules/ar6000.ko
$(mod_file) :
cd $(ATH_SRC) && ./comp.sh 2 ${PWD}/$(ATH_LINUXPATH)
cd $(ATH_SRC) && ./comp.sh 1 ${PWD}/$(ATH_LINUXPATH)
mkdir -p $(TARGET_OUT)/lib/modules
# $(MAKE) ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- -C $(ATH_LINUXPATH) ATH_HIF_TYPE=$(ATH_HIF_TYPE) SUBDIRS=${PWD}/$(ATH_SRC)/os/linux modules
$(ACP) $(ATH_SRC)/os/linux/ar6000.ko $(TARGET_OUT)/lib/modules/
ALL_PREBUILT+=$(mod_file)
endif
The operative piece of this makefile is the ALL_PREBUILT += $(mod_file)
clause. If we place a #
-sign in front of it, we can stop the build:
diff --git a/2.2.1.83/AR6K_ANDROID_SDK.2.2.1.83/host/Android.mk b/2.2.1.83/AR6K_ index ace527f..1a196c4 100644 --- a/2.2.1.83/AR6K_ANDROID_SDK.2.2.1.83/host/Android.mk +++ b/2.2.1.83/AR6K_ANDROID_SDK.2.2.1.83/host/Android.mk @@ -28,6 +28,6 @@ $(mod_file) : # $(MAKE) ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- -C $(ATH_LINUXPAT $(ACP) $(ATH_SRC)/os/linux/ar6000.ko $(TARGET_OUT)/lib/modules/ -ALL_PREBUILT+=$(mod_file) +# ALL_PREBUILT+=$(mod_file) endif
Taking the Atheros driver as an example, we can add an Android.mk
file to the Unigen driver and place it in external/rtl8712
.
user@host:~/myandroid$ mmm external/rtl8172
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=2.2
TARGET_PRODUCT=imx51_bbg
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=false
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=FRF85B
============================================
No private recovery resources for TARGET_DEVICE imx51_bbg
make: Entering directory `/home/user/myandroid'
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-
TOPDIR=/home/user/myandroid/external/rtl8172
KVER=2.6.31-00870-g8d80771
-C kernel_imx
M=/home/user/myandroid/external/rtl8172
modules
make[1]: Entering directory `/home/user/myandroid/kernel_imx'
cp: cannot stat `/home/user/myandroid/autoconf_rtl8712_usb_linux.h': No such file or directory
CC [M] /home/user/myandroid/external/rtl8172/cmd/rtl871x_cmd.o
CC [M] /home/user/myandroid/external/rtl8172/cmd/rtl8712_cmd.o
CC [M] /home/user/myandroid/external/rtl8172/crypto/rtl871x_security.o
CC [M] /home/user/myandroid/external/rtl8172/debug/rtl871x_debug.o
CC [M] /home/user/myandroid/external/rtl8172/eeprom/rtl871x_eeprom.o
CC [M] /home/user/myandroid/external/rtl8172/efuse/rtl8712_efuse.o
CC [M] /home/user/myandroid/external/rtl8172/hal/rtl8712/hal_init.o
CC [M] /home/user/myandroid/external/rtl8172/hal/rtl8712/usb_ops.o
CC [M] /home/user/myandroid/external/rtl8172/hal/rtl8712/usb_ops_linux.o
CC [M] /home/user/myandroid/external/rtl8172/hal/rtl8712/usb_halinit.o
CC [M] /home/user/myandroid/external/rtl8172/io/rtl871x_io.o
CC [M] /home/user/myandroid/external/rtl8172/io/rtl8712_io.o
CC [M] /home/user/myandroid/external/rtl8172/ioctl/rtl871x_ioctl_query.o
...
We can also copy the module to the Nitrogen board using adb
:
user@host:~/myandroid$ adb sync && adb shell 'sync && reboot'
After all of this, we're pretty close. We can manually insmod
the driver and see that the wlan0
device appears:
ericn@ericsony:~$ adb shell
# insmod /system/lib/modules/8712u.ko
# lsmod
8712u 324012 0 - Live 0xbf000000
# ls /sys/class/net/
lo
eth0
sit0
wlan0
#
This brings us back to Freescale's BoardConfig.mk
file. We can now replace the Atheros references with their Unigen equivalents:
diff --git a/imx51_bbg/BoardConfig.mk b/imx51_bbg/BoardConfig.mk index d06a01a..d7f5872 100755 --- a/imx51_bbg/BoardConfig.mk +++ b/imx51_bbg/BoardConfig.mk @@ -10,9 +10,9 @@ BOARD_SOC_CLASS := IMX5X BOARD_SOC_TYPE := IMX51 BOARD_SOC_REV := TO2 -WIFI_DRIVER_MODULE_PATH := "/system/lib/modules/ar6000.ko" +WIFI_DRIVER_MODULE_PATH := "/system/lib/modules/8712u.ko" WIFI_DRIVER_MODULE_ARG := "" -WIFI_DRIVER_MODULE_NAME := "ar6000" +WIFI_DRIVER_MODULE_NAME := "8712u" WIFI_FIRMWARE_LOADER := "" BOARD_HAVE_VPU := true
And once again, we'll need to sync up with the device:
user@host:~/myandroid$ adb sync && adb shell 'sync && reboot'