MIPS下载运行busybox

1 准备工作

君正M200,下载最新的busybox-mipsel,push到设备

adb push busybox-mipsel /system/bin

2 运行

> adb shell
root@xxx:/ # busybox
BusyBox v1.31.0 (2019-06-10 15:54:51 CEST) multi-call binary.
BusyBox is copyrighted by many authors between 1998-2015.
Licensed under GPLv2. See source distribution for detailed
copyright notices.

Usage: busybox [function [arguments]...]
   or: busybox --list[-full]
   or: busybox --show SCRIPT
   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, arch, arp,
        arping, ash, awk, base64, basename, bc, beep, blkdiscard, blkid,
        blockdev, bootchartd, brctl, bunzip2, bzcat, bzip2, cal, cat, chat,
        chattr, chgrp, chmod, chown, chpasswd, chpst, chroot, chrt, chvt,
        cksum, clear, cmp, comm, conspy, cp, cpio, crond, crontab, cryptpw,
        cttyhack, cut, date, dc, dd, deallocvt, delgroup, deluser, depmod,
        devmem, df, dhcprelay, diff, dirname, dmesg, dnsd, dnsdomainname,
        dos2unix, dpkg, dpkg-deb, du, dumpkmap, dumpleases, echo, ed, egrep,
        eject, env, envdir, envuidgid, ether-wake, expand, expr, factor,
        fakeidentd, fallocate, false, fatattr, fbset, fbsplash, fdflush,
        fdformat, fdisk, fgconsole, fgrep, find, findfs, flock, fold, free,
        freeramdisk, fsck, fsck.minix, fsfreeze, fstrim, fsync, ftpd, ftpget,
        ftpput, fuser, getopt, getty, grep, groups, gunzip, gzip, halt, hd,
        hdparm, head, hexdump, hexedit, hostid, hostname, httpd, hush, hwclock,
        i2cdetect, i2cdump, i2cget, i2cset, i2ctransfer, id, ifconfig, ifdown,
        ifenslave, ifplugd, ifup, inetd, init, insmod, install, ionice, iostat,
        ip, ipaddr, ipcalc, ipcrm, ipcs, iplink, ipneigh, iproute, iprule,
        iptunnel, kbd_mode, kill, killall, killall5, klogd, last, less, link,
        linux32, linux64, linuxrc, ln, loadfont, loadkmap, logger, login,
        logname, logread, losetup, lpd, lpq, lpr, ls, lsattr, lsmod, lsof,
        lspci, lsscsi, lsusb, lzcat, lzma, lzop, makedevs, makemime, man,
        md5sum, mdev, mesg, microcom, mkdir, mkdosfs, mke2fs, mkfifo,
        mkfs.ext2, mkfs.minix, mkfs.vfat, mknod, mkpasswd, mkswap, mktemp,
        modinfo, modprobe, more, mount, mountpoint, mpstat, mt, mv, nameif,
        nanddump, nandwrite, nbd-client, nc, netstat, nice, nl, nmeter, nohup,
        nologin, nproc, nsenter, nslookup, ntpd, nuke, od, openvt, partprobe,
        passwd, paste, patch, pgrep, pidof, ping, ping6, pipe_progress,
        pivot_root, pkill, pmap, popmaildir, poweroff, powertop, printenv,
        printf, ps, pscan, pstree, pwd, pwdx, raidautorun, rdate, rdev,
        readahead, readlink, readprofile, realpath, reboot, reformime,
        remove-shell, renice, reset, resize, resume, rev, rm, rmdir, rmmod,
        route, rpm, rpm2cpio, rtcwake, run-init, run-parts, runlevel, runsv,
        runsvdir, rx, script, scriptreplay, sed, sendmail, seq, setarch,
        setconsole, setfattr, setfont, setkeycodes, setlogcons, setpriv,
        setserial, setsid, setuidgid, sh, sha1sum, sha256sum, sha3sum,
        sha512sum, showkey, shred, shuf, slattach, sleep, smemcap, softlimit,
        sort, split, ssl_client, start-stop-daemon, stat, strings, stty, su,
        sulogin, sum, sv, svc, svlogd, svok, swapoff, swapon, switch_root,
        sync, sysctl, syslogd, tac, tail, tar, taskset, tc, tcpsvd, tee,
        telnet, telnetd, test, tftp, tftpd, time, timeout, top, touch, tr,
        traceroute, traceroute6, true, truncate, ts, tty, ttysize, tunctl,
        ubiattach, ubidetach, ubimkvol, ubirename, ubirmvol, ubirsvol,
        ubiupdatevol, udhcpc, udhcpc6, udhcpd, udpsvd, uevent, umount, uname,
        unexpand, uniq, unix2dos, unlink, unlzma, unshare, unxz, unzip, uptime,
        users, usleep, uudecode, uuencode, vconfig, vi, vlock, volname, w,
        wall, watch, watchdog, wc, wget, which, who, whoami, whois, xargs, xxd,
        xz, xzcat, yes, zcat, zcip

使用find命令

root@xxx:/ # busybox find -name version
./sys/devices/platform/gpio-keys/input/input1/id/version
./sys/devices/platform/jz-i2c.2/i2c-2/2-0046/input/input0/id/version
./sys/module/bcm_pm_core/version
./sys/module/bt_power_bluesleep/version
./sys/module/jz_vpu_v12/version
./sys/module/jz_efuse_v12/version
./sys/module/ppp_mppe/version
./sys/module/GobiUSBNet/version
./sys/module/g_android/version
./sys/module/uinput/version
./sys/module/tda18271/version
./sys/module/jzmmc_v12/version
./sys/module/tcp_cubic/version
./proc/version
./proc/sys/kernel/version

链接快捷方式,命令前不用加busybox

ln -s /system/bin/busybox /system/bin/find

3 写脚本方便push到新设备

win10新建文件push_busybox_mipsel.bat

adb remount
adb push busybox-mipsel system/bin/busybox
adb shell chmod 777 system/bin/busybox
pause

Linux新建文件push_busybox_mipsel.sh

# !/bin/sh
adb remount
adb push busybox-mipsel system/bin/busybox
adb shell chmod 777 system/bin/busybox

if [ $? -eq 0 ]; then
    echo "succeed"
else
    echo "failed"
fi

read -n 1 -p "Press any key to continue..."

参考

BusyBox
https://busybox.net/

编译mips下的busybox - simmer_ken的专栏 - CSDN博客
https://blog.csdn.net/simmer_ken/article/details/45577185

MIPS busybox - 井朝天的专栏 - CSDN博客
https://blog.csdn.net/laojing123/article/details/8086714

Android的toolbox及busybox,toybox - rockly89的博客 - CSDN博客
https://blog.csdn.net/ly890700/article/details/72615465

轻松记住大端小端的含义(附对大端和小端的解释) - 五岳 - 博客园
https://www.cnblogs.com/wuyuegb2312/archive/2013/06/08/3126510.html

日志

19.11.27

直接下载busybox-x86_64,在win10,运行报错。

下载busybox-mips,放到MIPS设备,Android系统,还是运行不了。报错

sh: /system/bin/busybox: not executable: magic 7F45

下载busybox-x86_64到Ubuntu虚拟机可以运行。

怎么查看设备是什么架构?

cat /proc/cpuinfo 

mips 是32位大端字节序

mipsel 是32位小端字节序

mips64el 是64位小端字节序

怎么查看机器大端小端?

#include <stdlib.h>
#include <stdio.h>
int main(int argc, char **argv)
{
    union {
        short s;
        char c[sizeof(short)];
    } un;
    un.s = 0x0102;
    if(sizeof(short)==2) {
        if(un.c[0]==1 && un.c[1] == 2)
            printf("big-endian\n");
        else if (un.c[0] == 2 && un.c[1] == 1)
            printf("little-endian\n");
        else
            printf("unknown\n");
    } else
        printf("sizeof(short)= %d\n",sizeof(short));
    exit(0);
}

busybox-mipsel在君正M200可用。

vi会乱码,用不了。

toolbox

查看有哪些命令,在system/core/toolbox/Android.mk

posted @ 2020-01-07 10:21  奥巴荣  阅读(1020)  评论(0编辑  收藏  举报