Menu

Cross Compiling Busybox - Biên dịch chéo Busybox


Biên dịch chéo Busybox cho Android ARM


Bước 1:
Tải mã nguồn busybox từ trang gốc: http://www.busybox.net/downloads/busybox-1.20.2.tar.bz2
giải nén:
tar -jzvf busybox-1.20.2.tar.bz2
Bước 2:
Tải công cụ biên dịch chéo cho ARM, ví dụ:  Sourcery G++ Lite arm-2010q1-202 for ARM GNU /Linux
giải nén:
tar -jzvf arm-2010q1-202-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
Bước 3: Cấu hình
gõ lênh:

cd busybox-1.20.2
make menuconfig


Busybox Settings -> Build Options -> 

chọn chế độ build static binary
[*] Build BusyBox as a static binary (no shared libs)

add đường dẫn đến cross compiler và set static cho các cờ
(/yourpath/arm-2010q1/bin/arm-none-linux-gnueabi-) Cross Compiler prefex (NEW)
(-static) Additional CFLAGS
(-static) Additional LDFLAGS 

Busybox Settings -> Installation Options->  (không thấy phần này)
[*] Don’t use /usr

Chọn các lệnh muốn Build ở phía dưới

Bước 4: Biên dịch
gõ lệnh: make

Nếu không cấu hình như bước 3 thì ta sử dụng lệnh sau:

make CROSS_COMPILE=/yourpath/arm-2010q1/bin/arm-none-linux-gnueabi- LDFLAGS=”–static” CFLAGS=”–static”

Bước 4: Đẩy xuống mạch đích

adb push busybox /system/bin/

Chạy thử nếu được như sau là thành công:


root@android:/ # busybox                                                       
BusyBox v1.20.2 (2015-07-18 16:09:04 ICT) multi-call binary.
Copyright (C) 1998-2011 Erik Andersen, Rob Landley, Denys Vlasenko
and others. Licensed under GPLv2.
See source distribution for full notice.

Usage: busybox [function] [arguments]...
   or: busybox --list[-full]
   or: busybox --install [-s] [DIR]
   or: function [arguments]...

        BusyBox is a multi-call binary that combines many common Unix
        utilities into a single executable.  Most people will create a
        link to busybox for each function they wish to use and BusyBox
        will act like whatever it was invoked as.

Currently defined functions:
        [, [[, acpid, add-shell, addgroup, adduser, adjtimex, arp, arping, ash,
        awk, base64, basename, beep, blkid, blockdev, bootchartd, brctl,
        bunzip2, bzcat, bzip2, cal, cat, catv, chat, chattr, chgrp, chmod,
        chown, chpasswd, chpst, chroot, chrt, chvt, cksum, clear, cmp, comm,
        ......................................

Link gốc: 

https://thangamaniarun.wordpress.com/2013/04/22/cross-compiling-busybox-1-20-2-for-android-4-0-3ti-omaparmadillo-810armdaillo-410-on-ubuntu-12-04/

Cross Compiling Busybox 1.20.2 for Android-4.0.3(TI OMAP)/Armadillo-810/Armdaillo-410 on Ubuntu-12.04


Development Environment is Ubuntu-12.04 Linux
Step1: Download BusyBox source code from Busybox official website 
wget http://www.busybox.net/downloads/busybox-1.20.2.tar.bz2
tar -jzvf busybox-1.20.2.tar.bz2
Step2: Download the ARM Toolkit, e.g. Sourcery G++ Lite arm-2010q1-202 for ARM GNU /Linux
wget 
http://www.codesourcery.com/sgpp/lite/arm/portal/package6488/public/arm-none-linux-gnueabi/arm-2010q1-202-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
tar -jzvf arm-2010q1-202-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
note: using the newest toolchain compile busybox-1.20.2 failed, use this toolchain 4.2.3 compiled ok.
Step3: Configure
cd busybox-1.20.2
make menuconfig
Busybox Settings -> Build Options ->
[*] Build BusyBox as a static binary (no shared libs)
(/yourpath/arm-2010q1/bin/arm-none-linux-gnueabi-) Cross Compiler prefex
Busybox Settings -> Installation Options->
[*] Don’t use /usr
Step4: Compile
if not set Cross Compiler prefix at step 3
make CROSS_COMPILE=/yourpath/arm-2010q1/bin/arm-none-linux-gnueabi- LDFLAGS=”–static” CFLAGS=”–static”
else
make LDFLAGS=”–static” CFLAGS=”–static”
Step5: Busybox ready to use
file busybox
busybox: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, for GNU/Linux 2.6.16, stripped
Step6: Upload to Target device
adb push busybox /data/local/tmp/
adb shell chmod 755 /data/local/tmp/busybox
Enjoy :-)

Không có nhận xét nào :

Đăng nhận xét