How to Cross Compile the Bash shell for Android 1.5
来源:互联网 发布:java类获取request 编辑:程序博客网 时间:2024/05/17 01:43
Introduction:
I just got a new G1 Android phone, and since it runs Linux I just hadto get the Bash shell running on it, the built in shell would just notdo. I do need my tab completion after all. Cross compilation is theprocess of compiling software on one platform that is meant to run onanother. With the following an ARM executable is compiled on a x86Linux machine.
Requirements (Not sure if all this is needed, but it is what I used):
- Cupcake 1.5 JS Build with root access: http://androidandme.com/2009/05/guides/beginners-guide-for-rooting-your-android-g1-to-install-cupcake/
- ARM Toolkit (The Cross Compiler): http://www.codesourcery.com/gnu_toolchains/arm/download.html
- Android SDK installed on Linux: http://developer.android.com/sdk/1.5_r2/index.htm
- A G1
- The source code for Bash 4.0: ftp://ftp.cwru.edu/pub/bash/bash-4.0.tar.gz
Step 1: Connect your pc to your phone with the SDK
You first have to be able to connect to your computer with adp which isincluded with the sdk. To do this with Ubuntu Januty Jackalope youfirst need to create a /etc/udev/rules.d/51-android.rules file with thefollowing contents:
1.
SUBSYSTEM==
"usb"
, SYSFS{idVendor}==
"0bb4"
, MODE=
"0666"
After this run the following to restart udev: ’sudo /etc/init.d/udevreload’. Lastly, on your phone make sure Settings :: Applications ::Development :: USB Debugging is enabled and the plug in your phone. When you run ‘./adp devices’ you should see a device listed.
Step 2: Build the Bash Shell
After installing ARM toolkit in /home/kbrandt/bin/arm-toolkit (used forthis example) set the following environment variables in your shell.
1.
CC=
'/home/kbrandt/bin/arm-toolkit/bin/arm-none-linux-gnueabi-gcc'
2.
PATH=
"$PATH:$HOME/bin/"
Then cd to the directory where you extracted the Bash source and run the following:
1.
./configure --prefix=/opt/arm_bash/ -host=arm-linux --enable-
static
-link --without-bash-malloc
Assuming that worked, edit the ‘Makefile’ file and change ‘CFLAGS =-g -O2′ to ‘CFLAGS = -g -O2 -static’ and then run ‘make’. If thisworks, it should create a bash executable in the current directory. Youcan verify that this has been compiled for the ARM architecture with‘file bash’. This should return:
bash: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, for GNU/Linux 2.6.14, not stripped
Step 3: Copy the File to your android.
From the host computer in the tools directory of the SDK run ‘./adbpush ~/src/bash-4.0/bash /data/’ to copy the executable to the phone.If you try to copy it to your sdcard, make sure the sdcard is notmounted with the noexec mount option as this disables the executablepermission bit.
Step 4: Run, Enjoy, and Find Bugs.
You can now connect to your phone with ‘./adp shell’ and cd to the datadirectory and run ‘./bash’ and you should get a bash prompt. You mightneed to ‘chmod 555 bash’ if you get permission denied.
References:
http://jiggawatt.org/badc0de/android/index.html
- How to Cross Compile the Bash shell for Android 1.5
- How to Cross Compile the Bash shell for Android 1.5 (为Android平台编译Bash shell)
- How to cross-compile OpenSSL for ARM
- How to cross-compile Chromium for ARM
- How to Cross Compile the Busybox
- How to cross compile the PPP to arm-xscale
- How to Cross Compile the wireless_tools(iwconfig iwlist)
- How To Compile OpenSSL for the iPhone
- how to cross compile valgrind on android platform
- Compile Bash for Android
- cross compile busybox for android
- (OK) how to compile the source code for Android-x86 (Android 7.1.1)
- How to compile kernel modules for the kernel 2.6
- How To Cross Compile Python 2.5.2 For ARM -- by Border
- How to Enable the Linux Bash Shell in Windows 10
- How to Compile SQLite for Android using NDK
- cross compile toolchain for arm/android
- cross compile tcpdump for Android devices script
- VC++显示弹出式菜单的两种方法
- GNU Bash 手册 (2)
- 学习笔记——数据库的创建
- Dynamips 路由器所支持模块列表
- GNU Bash 手册 (3)
- How to Cross Compile the Bash shell for Android 1.5
- 深度分析:Java和.NET谁领导移动开发平台
- 粉尘防爆设备-尘密性设备
- SQL Server 2005中的文件和文件组
- 我是新来的
- 【转】grep正则表达式
- Linux应用程序开发
- PowerShell笔记(三):调用MS SQL数据库
- vs2005下安装boost