Why arm chroot environment will work.
Use build-arm-chroot to create a folder that is arm based environment:
root@neo-u910:~# apt-get install qemu-arm-static
root@neo-u910:~# build-arm-chroot karmic test-123
Remove qemu-arm-static for testing
root@neo-u910:~# apt-get remove qemu-arm-static
root@neo-u910:~# rm test-123/usr/bin/qemu-arm-static
File one file, then we know it's ARM executable file :
root@neo-u910:~# file test-123/usr/bin/lscpu
test-123/usr/bin/lscpu: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, stripped
And we can not execute it :
root@neo-u910:~# ./test-123/usr/bin/lscpu
bash: ./test-123/usr/bin/lscpu: cannot execute binary file
And we can not chroot into.
root@neo-u910:~# chroot test-123/
chroot: cannot run command `/bin/bash': Exec format error
Check our binfmt_misc setting, there is no arm related setting
root@neo-u910:~# ls /proc/sys/fs/binfmt_misc/
cli python2.6 register status
Now we install it back
root@neo-u910:~# apt-get install qemu-arm-static
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
qemu-arm-static
0 upgraded, 1 newly installed, 0 to remove and 185 not upgraded.
Need to get 0B/559kB of archives.
After this operation, 1,430kB of additional disk space will be used.
Selecting previously deselected package qemu-arm-static.
(Reading database ... 137788 files and directories currently installed.)
Unpacking qemu-arm-static (from .../qemu-arm-static_0.11.0-0ubuntu6.3_i386.deb) ...
Setting up qemu-arm-static (0.11.0-0ubuntu6.3) ...
vm.vdso_enabled = 0
vm.mmap_min_addr = 4097
And cp into target system ( recover what build-arm-chroot will do )
root@neo-u910:~# cp /usr/bin/qemu-arm-static test-123
Now binfmt_misc/arm exist.
root@neo-u910:~# ls /proc/sys/fs/binfmt_misc/
arm cli python2.6 register status
root@neo-u910:~# cat /proc/sys/fs/binfmt_misc/arm
enabled
interpreter /usr/bin/qemu-arm-static
flags:
offset 0
magic 7f454c4601010100000000000000000002002800
mask ffffffffffffff00fffffffffffffffffeffffff
Still can't execute it, but it's because of library path incorrect
root@neo-u910:~# ./test-123/usr/bin/lscpu
/lib/ld-linux.so.3: No such file or directory
Now chroot working
root@neo-u910:~# chroot test-123/
root@neo-u910:~# ./usr/bin/lscpu
Architecture: armv5tel
CPU(s): 2
Thread(s) per core: 1
Core(s) per socket: 2
CPU socket(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 15
Stepping: 6
CPU MHz: 1596.000
Virtualization: VT-x
L1d cache: 32K
L1i cache: 32K
L2 cache: 4096K
Exit out, and look into what postinst of qemu-arm-static done :
root@neo-u910:~# dpkg -e /var/cache/apt/archives/qemu-arm-static_0.11.0-0ubuntu6.3_i386.deb
root@neo-u910:~# cat DEBIAN/postinst
#!/bin/sh
set -e
if [ "$1" = configure ] && which update-binfmts >/dev/null; then
update-binfmts --import arm
fi
if [ "$1" = configure ]; then
sysctl -p /etc/sysctl.d/qemu-arm-static.sysctl.conf
fi
exit 0
Actually, we could execute both x86/arm application inside this chroot environment :
root@neo-u910:/# file /usr/bin/qemu-arm-static
/usr/bin/qemu-arm-static: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, for GNU/Linux 2.6.15, stripped
root@neo-u910:/# /usr/bin/qemu-arm-static -cpu ?
Available CPUs:
arm926
arm946
arm1026
arm1136
arm1136-r2
arm11mpcore
cortex-m3
cortex-a8
ti925t
pxa250
pxa255
pxa260
pxa261
pxa262
pxa270
pxa270-a0
pxa270-a1
pxa270-b0
pxa270-b1
pxa270-c0
pxa270-c5
any
Some explanation about binfmt_misc :
http://en.wikipedia.org/wiki/Binfmt_misc
Friday, February 26, 2010
Wednesday, February 17, 2010
debootstrap
debootstrap can be use to install a debian package based linux system.
Including same arch or not.
How to install a chroot arm linux environment :
https://wiki.ubuntu.com/ARM/BuildEABIChroot
So that can be use a powerful host system for native compile application for arm arch.
debootstrap is actually a generic script to install all kind version of debian based system.
Per distro/version specific information is store at /usr/share/debootstrap.
It will report to below information.
1. DEF_MIRROR
mirror site : where store the .deb files
per distro script will call default_mirror in /usr/share/debootstrap/functions, then export DEF_MIRROR
2. DOWNLOAD_DEBS, DOWNLOAD_INDICES
mirror style : release or main
1. parse necessary information
depends on 1st, 2nd stage, add necessary job item
2. include per distro script
3. run job item
for install a deb based linux system, it may need below step :
1. finddebs :
download_indices :
(1) get release file : http://ports.ubuntu.com/ubuntu-ports/dists/karmic/Release
(2) grep Components from release file, found main restricted universe multiverse
(3) get package.gz according to arch/distro, ex from :
http://ports.ubuntu.com/ubuntu-ports/dists/karmic/main/binary-armel/
http://ports.ubuntu.com/ubuntu-ports/dists/karmic/restricted/binary-armel/
http://ports.ubuntu.com/ubuntu-ports/dists/karmic/universe/binary-armel/
http://ports.ubuntu.com/ubuntu-ports/dists/karmic/multiverse/binary-armel/
work_out_debs :
work_out_debs parse out three catalog, from unpacked Package file.
required : for package that list as "Priority: required"
base : for package that list as "Priority: important"
if buildd then base will be "Build-Essential: yes"
if fakechroot, minbase then base will be "apt"
finally, set up all_debs="$required $base"
2. printdebs - if assigned
just echo $all_debs
3. dldebs
download all .deb into ${target}/var/lib/apt, ${target}/var/cache/apt
download_main will parse file name from Package, then download package, also check md5.
4. maketarball - if assigned
tar ${target}/var/lib/apt,${target}/ var/cache/apt into one tarball.
... stay tune ...
debootstrap can be use to install a debian package based linux system.
Including same arch or not.
How to install a chroot arm linux environment :
https://wiki.ubuntu.com/ARM/BuildEABIChroot
So that can be use a powerful host system for native compile application for arm arch.
debootstrap is actually a generic script to install all kind version of debian based system.
Per distro/version specific information is store at /usr/share/debootstrap.
It will report to below information.
1. DEF_MIRROR
mirror site : where store the .deb files
per distro script will call default_mirror in /usr/share/debootstrap/functions, then export DEF_MIRROR
2. DOWNLOAD_DEBS, DOWNLOAD_INDICES
mirror style : release or main
1. parse necessary information
depends on 1st, 2nd stage, add necessary job item
2. include per distro script
3. run job item
for install a deb based linux system, it may need below step :
1. finddebs :
download_indices :
(1) get release file : http://ports.ubuntu.com/ubuntu-ports/dists/karmic/Release
(2) grep Components from release file, found main restricted universe multiverse
(3) get package.gz according to arch/distro, ex from :
http://ports.ubuntu.com/ubuntu-ports/dists/karmic/main/binary-armel/
http://ports.ubuntu.com/ubuntu-ports/dists/karmic/restricted/binary-armel/
http://ports.ubuntu.com/ubuntu-ports/dists/karmic/universe/binary-armel/
http://ports.ubuntu.com/ubuntu-ports/dists/karmic/multiverse/binary-armel/
work_out_debs :
work_out_debs parse out three catalog, from unpacked Package file.
required : for package that list as "Priority: required"
base : for package that list as "Priority: important"
if buildd then base will be "Build-Essential: yes"
if fakechroot, minbase then base will be "apt"
finally, set up all_debs="$required $base"
2. printdebs - if assigned
just echo $all_debs
3. dldebs
download all .deb into ${target}/var/lib/apt, ${target}/var/cache/apt
download_main will parse file name from Package, then download package, also check md5.
4. maketarball - if assigned
tar ${target}/var/lib/apt,${target}/ var/cache/apt into one tarball.
... stay tune ...
Subscribe to:
Posts (Atom)