This post gives two options for the creation of a kernel version with which your Samsung Galaxy S2 supports otherwise unknown USB client devices – see the problem description in the last post.
The kernel modifications described here are based on the kernel here with the initramfs (find its source code here). This original kernel could be used to enable basic root access on your phone.
Creating a kernel module for USB-to-serial connectors
In order to get the needed USB-to-serial kernel module different steps are necessary:
- First, the development environment has to be prepared by downloading the Samsung Kernel source code which is freely available as it is based on the open-source Android operating system. Also the tool-chain for cross-compiling the source code has to be installed [http://forum.xda-developers.com/showthread.php?t=1123643].
- Second, “USB serial converter support” and the respective driver for FTDI serial converter have to be selected for module compilation by calling menu “makeconfig”.
- Third, the kernel Makefile is modified changing the kernel version to ‘xyz’ to reflect the currently installed kernel version on the mobile phone. Additionally, the path to the used tool-chain for cross-compiling has to be changed according to the installation. E.g.:
CROSS_COMPILE ?= /opt/toolchains/arm-2009q3/bin/arm-none-eabi-
- Finally the following lines in the .config file have to be changed according to the xda-developer forum to successfully compile the driver:
CONFIG_DEBUG_PREEMPT
CONFIG_DEBUG_RT_MUTEXES
CONFIG_DEBUG_SPINLOCK
CONFIG_DEBUG_MUTEXES
CONFIG_PROFILING
CONFIG_PERF_EVENTS
CONFIG_PERF_COUNTERS
CONFIG_LATENCYTOP
CONFIG_FTRACE
With these steps the modules can be successfully compiled using the command “make modules”.
If you try to insert the drivers to the mobile device using the “insmod” command and this fails due to the following error: ‘unknown format?’, you can do the following: Using “dmesg” a more precise error description states that no symbol version was found for module layout. This information points to a missing
symbol table. In order to receive a symbol table the kernel was built again by using “make”, which builds the complete kernel including modules. The resulting new modules ‘usbserial.ko’ and ‘ftdi_sio.ko’ were then successfully installed using “insmod”. The order of inserting the modules is very important as the ‘ftdi_sio’ module depends on the ‘usbserial’ module.
If your external USB device then receives sufficient power from your S2 and is white-listed, it would be ready to use!
Removing the White-List Requirement for USB devices
If your USB device is still not recognised because it is not white-listed, the only solution for this problem is a custom kernel supporting both, the respective kernel modules and the deactivation of the USB OTG targeted peripherals list.
To achieve this the following steps are necessary:
The Kernel base
The kernel base we used for building the custom version is the “backslash-1.3″ kernel. It includes a modified “initramfs” from the “CF-Root 4.1″ Kernel and incorporates performance changes to the stock kernel “XXKG1″. The source code for the kernel and the “initramfs” have to be installed. It is important to check out the right branches for successfully compiling the source code. The branch ‘master’ was used for the kernel and ‘backslash-1.3-CF-Root-XXKG1′ for the initramfs.
Kernel changes
Different files need to be changed. First, the configuration file has to be updated. Therefore the line fololowing in file “/arch/arm/cong/c1 defcong”
CONFIG_USB_SEC_WHITELIST = y
has to be changed to
CONFIG_USB_SEC_WHITELIST = n
Second, the build script build “kernel.sh” is modified due to the differences in the development environment under which the kernel was originally created. Thus the following lines are changed:
INITRAMFS_SRC=”/home/ubuntu/dev/samsung/initramfs-galaxysii”
INITRAMFS_TMP=”/home/ubuntu/dev/samsung/master/initramfs-galaxysii”
export CROSS_COMPILE=/home/ubuntu/opt/toolchains/arm-2009q3/bin/arm-none-eabi-
With the command “make c1 defconfig” the configuration file “.config” for the kernel compilation has to be prepared and by using “make menuconfig” the missing modules, as mentioned above, can be selected as kernel-built-in modules.
Last, the kernel can be compiled executing the modified kernel build script.
Permission changes
In the “initramfs” access rights have to be modified to provide access to the devices using USB Serial ports for all applications. To achieve this, the “ueventd.rc” has to be modified adding the following lines at the end of the file:
/dev/ 0666 root root
/dev/ttyUSB* 0666 root root
These changes have the effect that, whenever a USB Serial device is connected, all users or applications can access the port. It is also necessary to change the permission for the parent directory to
allow access. Otherwise, e.g. the RXTXLibrary is not able to enumerate the available ports, which would cause a “no such port exception”.
If the kernel has been successfully compiled using the new conguration, it will result in a zImage usable to update your Samsung Galaxy S2. The following post shows how to install this kernel then.
Recent Comments