Launching Linux from Busybox (Pivot_Root or Switch_Root, or ? )

How to run Ubuntu utils from USB?

You need static linked binaries without external libraries (/lib/*.so files)

A major tool for many commands on embedded devices is: busybox

You probably find a static version for your os on: busybox.net

My busybox...

busybox
BusyBox v1.30.0 (2018-12-30 22:25:27 CET) 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, ar, arch, arp, arping, ash, awk, base64, basename, bc, 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, expand, expr, factor, fakeidentd, false, fatattr, fbset, fbsplash,
fdflush, fdformat, fdisk, fgconsole, fgrep, find, findfs, flash_eraseall, flash_lock, flash_unlock, flashcp, 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, id,
ifconfig, ifenslave, ifplugd, inetd, init, inotifyd, 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, losetup, lpd, lpq, lpr, ls, lsattr, lsmod, lsof, lspci, lsscsi, lsusb, lzcat, lzma,
lzop, lzopcat, 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, nbd-client, nc,
netstat, nice, nl, nmeter, nohup, nologin, nproc, 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, 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, tty, ttysize, tunctl, tune2fs, ubiattach, ubidetach, ubimkvol, ubirename, ubirmvol,
ubirsvol, ubiupdatevol, udhcpc, udhcpd, udpsvd, uevent, umount, uname, uncompress, unexpand, uniq, unix2dos, unlink, unlzma,
unlzop, 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

How to install GCC and/or apt on embedded linux Raspberry Pi

you've tagged this post as "yocto".
So the only thing I can advice you is using this wonderful tool :)
you don't want to compile your tools from your raspi, but from your killer linux machine :)

first, make sure you have all the prerequisists.
for fedora:

sudo yum install gawk make wget tar bzip2 gzip python unzip perl patch \
diffutils diffstat git cpp gcc gcc-c++ glibc-devel texinfo chrpath \
ccache perl-Data-Dumper perl-Text-ParseWords perl-Thread-Queue socat

for ubuntu / debian:

sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib \
build-essential chrpath socat

then, you can get yocto from git://git.yoctoproject.org/poky

git clone git://git.yoctoproject.org/poky -b daisy

then, you need to get the raspberrypi layer and its dependencies:

cd poky
git clone http://git.yoctoproject.org/git/meta-raspberrypi -b daisy
git clone git://git.openembedded.org/meta-openembedded -b daisy

then, setup the build environment:

source oe-init-build-env rpi-build

here rpi-build will be the name of the build directory, it can be whatever you want.
this will setup all the environment variables needed to use yocto, andmove you to the newly create build directory.

edit conf/bblayers.conf
and add the needed layers to BBLAYERS. it should look like something like this:

BBLAYERS ?= " \                                                                 
/path/to/poky/meta \
/path/to/poky/meta-yocto \
/path/to/poky/meta-yocto-bsp \
/path/to/poky/meta-openembedded/meta-oe \
/path/to/poky/meta-raspberrypi \
"

then, edit conf/local.conf
set the MACHINE variabel to raspberrypi:

MACHINE ?= "raspberrypi"

you can also tell yocto to generate deb files instead of the default rpms by changing:

PACKAGE_CLASSES ?= "package_rpm"

to:

PACKAGE_CLASSES ?= "package_deb"

in order to quickly have dpkg present in the build, just add the following line in your conf/local.conf

CORE_IMAGE_EXTRA_INSTALL="dpkg"

and create a basic image:

bitbake rpi-basic-image

this will take some time.... a LOT of time in fact (yocto will generate the whole rootfilesystem, it will download the sources and compile them, will create deb packages for each of them, and will generate a flashable s image).

during that time I suggest you read the yocto documentation in order to understand how to add more software to the resulting image and / or customise it.
Explaining how yocto works can't just be an answer in stackoverflow you'll need to read the documentation and practice a little bit.

but the main thing to understand is that yocto provides receipes. Basically, a receipe describes how to get a packages and how to compile it.
a simple example of receipe can be found in:

meta/recipes-devtools/rpm/rpmresolve_1.0.bb

the good thing with yocto, is that you can easily add your own receipes.
layers provide supersets of receipes, they also allow customisation.
here, we added the raspberrypi layer in order to add support for the raspberry board.
the raspberry layer provides all the receipes needed to configure the kernel, and the bootloader etc...

once compilation is done, in order to flash the resulting sd image just do:

dd bs=4M if=/path/to/rpi-build/tmp/deploy/images/raspberrypi/rpi-basic-image-raspberrypi.rpi-sdimg of=/dev/sd?

where "sd?" is your (unmounted) sdcard (think about saving it if needed)
plug back your sdcard to your raspi,
boot it.

in order to find out the raspi ip, you can scan your network for open ssh ports:

nmap -p 22 --open -sV YOU_SUBNET_ADDRESS/SUBNET_SIZE

example:

nmap -p 22 --open -sV 192.168.1.0/24

ssh root@RASPI-IP

and voila !

next time you'll need to build a new package, you can do:

bitbake package-name

and then just scp the resulting .deb file (from tmp/work/armv6-vfp-poky-linux-gnueabi/PACKAGE_NAME/PACKAGE_VERSION/deploy-debs/armv6-vfp/PACKAGE.ipk) to the raspi and use dpkg to install it.
you can also create your own image based on rpi-basic-image and adding your own selection of packages.

Exmple with htop:

bitbake htop
scp ./tmp/work/armv6-vfp-poky-linux-gnueabi/htop/1.0.3-r0/deploy-debs/armv6-vfp/htop_1.0.3-r0_armv6-vfp.deb root@myraspi

yocto will be very helpful to ease the cross compilation process for you.

sources:
https://github.com/djwillis/meta-raspberrypi
https://yoctoproject.org

kamou

Can't execute stat on android 2.3.4 command not found

the stat command is not available on the device. There is a very limited set of commands available. They are listed here:

http://developer.android.com/guide/developing/tools/adb.html

What are you trying to do?

busybox init script. Mount not found

You have to symlink all the applets you want, e.g. ln -s /bin/busybox /bin/mount. See USAGE in the busybox docs:

USAGE


BusyBox is a multi-call binary. A multi-call binary is an
executable program that performs the same job as more than one utility
program. That means there is just a single BusyBox binary, but that
single binary acts like a large number of utilities. This allows
BusyBox to be smaller since all the built-in utility programs (we call
them applets) can share code for many common operations.

You can also invoke BusyBox by issuing a command as an argument on the
command line. For example, entering

    /bin/busybox ls 

will also cause BusyBox to behave as 'ls'.

Of course, adding '/bin/busybox' into every command would be painful.
So most people will invoke BusyBox using links to the BusyBox binary.

For example, entering

    ln -s /bin/busybox ls
./ls

will cause BusyBox to behave as 'ls' (if the 'ls' command has been compiled into BusyBox). Generally speaking, you should never
need to make all these links yourself, as the BusyBox build system
will do this for you when you run the 'make install' command.

If you invoke BusyBox with no arguments, it will provide you with a
list of the applets that have been compiled into your BusyBox binary.

The commands that happen to work without it are the ones implemented as fork-free and therefore can be invoked as builtins.



Related Topics



Leave a reply



Submit