summaryrefslogtreecommitdiffstats
path: root/recipes-support/32b-env
diff options
context:
space:
mode:
authorTudor Florea <tudor.florea@enea.com>2015-10-08 22:42:49 +0200
committerTudor Florea <tudor.florea@enea.com>2015-10-08 22:42:49 +0200
commit635d320abfa6dc3c0e1d00e3ceae567dd0e55a5b (patch)
treedcd42fafb9189d3be13ef3d95f9ce6f4f5cfa267 /recipes-support/32b-env
downloadmeta-hierofalcon-635d320abfa6dc3c0e1d00e3ceae567dd0e55a5b.tar.gz
initial commit for Enea Linux 5.0 arm
Signed-off-by: Tudor Florea <tudor.florea@enea.com>
Diffstat (limited to 'recipes-support/32b-env')
-rw-r--r--recipes-support/32b-env/32b-env_1.0.bb23
-rwxr-xr-xrecipes-support/32b-env/files/set_32b_env_chroot.sh120
-rwxr-xr-xrecipes-support/32b-env/files/set_32b_env_qemu.sh113
3 files changed, 256 insertions, 0 deletions
diff --git a/recipes-support/32b-env/32b-env_1.0.bb b/recipes-support/32b-env/32b-env_1.0.bb
new file mode 100644
index 0000000..44142d5
--- /dev/null
+++ b/recipes-support/32b-env/32b-env_1.0.bb
@@ -0,0 +1,23 @@
1SUMMARY = "A simple set of shell scripts used for enabling support for \
2dynamic linked 32b application on hierofalcon boards."
3DESCRIPTION = "The 32b-env package installs the set_32b_env_chroot.sh \
4and set_32b_env_qemu.sh shell scripts which enables support for dynamic \
5linked 32b application on hierofalcon boards until the multilib support \
6will be available for armv8 architecture."
7
8SRC_URI = "file://set_32b_env_chroot.sh \
9 file://set_32b_env_qemu.sh"
10
11LICENSE = "MIT"
12LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=4d92cd373abda3937c2bc47fbc49d690"
13
14do_install () {
15 install -d ${D}${bindir}/
16 install -m 755 ${WORKDIR}/set_32b_env_chroot.sh ${D}${bindir}/
17 install -m 755 ${WORKDIR}/set_32b_env_qemu.sh ${D}${bindir}/
18}
19
20do_patch[noexec] = "1"
21do_configure[noexec] = "1"
22do_compile[noexec] = "1"
23do_build[noexec] = "1"
diff --git a/recipes-support/32b-env/files/set_32b_env_chroot.sh b/recipes-support/32b-env/files/set_32b_env_chroot.sh
new file mode 100755
index 0000000..8d450c4
--- /dev/null
+++ b/recipes-support/32b-env/files/set_32b_env_chroot.sh
@@ -0,0 +1,120 @@
1#!/bin/sh
2
3help()
4{
5 echo " The scope of this script is to setup an environment for 32b legacy applications."
6 echo " This is a replacement for MULTILIB mechanism which is not available yet for aarch64."
7 echo " chroot is used to setup an isolated environment for 32b applications"
8 echo " "
9 echo " Prerequisites:"
10 echo " - user must build a 32b amrv7 rootfs (e.q. build a image for qemuarm)"
11 echo " - user must copy 32b armv7 rootfs under 64b rootfs (e.q. /mnt/rootfs32)"
12 echo " - user must copy 32b application under 32b rootfs (e.q. /mnt/rootfs32/myapp)"
13 echo ""
14 echo " Run setup script to prepare the environment for 32b applications"
15 echo " > set_32b_env_chroot -r /mnt/rootfs32"
16 echo ""
17 echo " Run 32b applications"
18 echo " @> ./myapp/myexec"
19 echo ""
20 echo " In order to return to default root just type <exit>"
21 echo " @> exit"
22 exit
23}
24
25usage()
26{
27 echo "set_32b_env_chroot OPTIONS"
28 echo "OPTIONS:"
29 echo ""
30 echo " -r <32b_rootfs> : path to a 32b rootfs."
31 echo " -h : display help"
32 echo ""
33 exit
34}
35
36if [[ $# -eq 0 ]] ; then
37 echo "[ERR]: Missing script parameters!"
38 echo ""
39 usage
40fi
41
42while getopts "hr:" OPTION;
43do
44 case $OPTION in
45
46 r)
47 ROOTFS32b_PATH="$OPTARG"
48 ;;
49
50 ?)
51 help
52 ;;
53
54 esac
55done
56
57ABS_PATH=`cd "${ROOTFS32b_PATH}"; pwd`
58ROOTFS32b_PATH=${ABS_PATH}
59
60if [[ ! -d ${ROOTFS32b_PATH} ]] ; then
61 usage
62fi
63
64if [[ ! -d ${ROOTFS32b_PATH}/dev ]] ; then
65 mkdir ${ROOTFS32b_PATH}/dev
66fi
67
68if [[ ! -d ${ROOTFS32b_PATH}/proc ]] ; then
69 mkdir ${ROOTFS32b_PATH}/proc
70fi
71
72if [[ ! -d ${ROOTFS32b_PATH}/sys ]] ; then
73 mkdir ${ROOTFS32b_PATH}/sys
74fi
75
76if [[ ! -d ${ROOTFS32b_PATH}/etc ]] ; then
77 mkdir ${ROOTFS32b_PATH}/etc
78fi
79
80umount ${ROOTFS32b_PATH}/dev/pts 2>/dev/null
81umount ${ROOTFS32b_PATH}/dev 2>/dev/null
82mount --bind /dev ${ROOTFS32b_PATH}/dev
83if [[ "$?" != "0" ]] ; then
84 echo "Failed to mount /dev folder"
85 exit
86fi
87
88umount ${ROOTFS32b_PATH}/proc 2>/dev/null
89mount --bind /proc ${ROOTFS32b_PATH}/proc
90if [[ "$?" != "0" ]] ; then
91 echo "Failed to mount /proc folder"
92 exit
93fi
94
95umount ${ROOTFS32b_PATH}/sys 2>/dev/null
96mount --bind /sys ${ROOTFS32b_PATH}/sys
97if [[ "$?" != "0" ]] ; then
98 echo "Failed to mount /sys folder"
99 exit
100fi
101
102mount --bind /dev/pts ${ROOTFS32b_PATH}/dev/pts
103if [[ "$?" != "0" ]] ; then
104 echo "Failed to mount /dev/pts folder"
105 exit
106fi
107
108cp /etc/resolv.conf ${ROOTFS32b_PATH}/etc/resolv.conf
109if [[ "$?" != "0" ]] ; then
110 echo "Failed to copy resolv.conf file"
111 exit
112fi
113
114PATH=/bin:/sbin:/usr/bin:/usr/sbin
115
116echo "New root will be ${ROOTFS32b_PATH}/ type \"exit\" to return to /"
117chroot ${ROOTFS32b_PATH}/ /bin/sh
118if [[ "$?" != "0" ]] ; then
119 echo "Failed to start chroot!"
120fi
diff --git a/recipes-support/32b-env/files/set_32b_env_qemu.sh b/recipes-support/32b-env/files/set_32b_env_qemu.sh
new file mode 100755
index 0000000..e8c174d
--- /dev/null
+++ b/recipes-support/32b-env/files/set_32b_env_qemu.sh
@@ -0,0 +1,113 @@
1#!/bin/sh
2
3help()
4{
5 echo " The scope of this script is to setup an environment for 32b legacy applications."
6 echo " This is a replacement for MULTILIB mechanism which is not available yet for aarch64."
7 echo " qemu-arm(user mode) is used to set access to 32b libraries instead of the host's libs"
8 echo " "
9 echo " Prerequisites:"
10 echo " - user must build a 32b amrv7 rootfs (e.q. build a image for qemuarm)"
11 echo " - user must copy 32b armv7 rootfs under 64b rootfs (e.q. /mnt/rootfs32)"
12 echo " - user must copy 32b application under 32b rootfs (e.q. /mnt/rootfs32/myapp)"
13 echo " - user must configure properly the smart package manager in order to access"
14 echo " <qemu-arm> and <kernel-module-binfmt-misc> packages otherwise it is"
15 echo " expected that those packages are already installed"
16 echo ""
17 echo " Run setup script to prepare the environment for 32b applications( -l param is optional )"
18 echo " > set_32b_env_qemu -r /mnt/rootfs32 -l /usr/local/extlib:/usr/local/mylib"
19 echo ""
20 echo " After that user should be able to run any 32b application as usual!"
21 echo " >./myapp"
22 break
23}
24
25usage()
26{
27 echo "Setup environment to run 32b dynamically linked applications using qemu."
28 echo "Prerequisites:"
29 echo " It is expected that qemu and kernel-module-binfmt-misc packages are installed"
30 echo " It is expected that 32bit rootfs is already installed!"
31 echo ""
32 echo "set_32b_env_qemu -r <path to 32b rootfs> -l <ext_libs1:ext_libs2:...>"
33 echo " -r : [mandatory] path to 32b rootfs"
34 echo " -l : [optional] list of paths for nonstandard lib folders, paths must be relative to 32b rootfs"
35 echo " -h : [optional] display help"
36 echo ""
37 echo "Example: set_32b_env_qemu -r ./rootfs32b -l /usr/local/mylib:/usr/local/mylib2"
38 break
39}
40
41if [[ $# -eq 0 ]] ; then
42 echo "[ERR]: Missing script parameters!"
43 echo ""
44 usage
45fi
46
47while getopts "hr:l:" OPTION;
48do
49 case $OPTION in
50
51 r)
52 ROOTFS32b_PATH="$OPTARG"
53 ;;
54
55 l)
56 LIBS_PATH="$OPTARG"
57 ;;
58
59 h)
60 usage
61 ;;
62
63 ?)
64 help
65 ;;
66
67 esac
68done
69
70ABS_PATH=`cd "${ROOTFS32b_PATH}"; pwd`
71ROOTFS32b_PATH=${ABS_PATH}
72
73if [[ ! -d ${ROOTFS32b_PATH} ]] ; then
74 usage
75fi
76
77echo "Please wait..."
78echo ""
79QEMU_EXISTS=`which qemu-arm`
80if [[ "${QEMU_EXISTS}" == "" ]] ; then
81 echo "Please make sure smart package manager is configured !"
82 echo "Otherwise make sure <qemu> and <kernel-module-binfmt-misc> are installed!"
83 smart --quiet update
84 smart --quiet install qemu
85 smart --quiet install kernel-module-binfmt-misc
86fi
87
88echo "."
89mount -t binfmt_misc none /proc/sys/fs/binfmt_misc
90if [[ "$?" != "0" ]] ; then
91 echo "Failed to install binfmt_misc or the setup was already prepared for 32b"
92 echo ""
93 echo "Please, make sure the module is available into system"
94 echo "How to install the binfmt_misc package:"
95 echo " smart install binfmt_misc"
96 break
97fi
98
99BINFMT_INSTALLED=`cat /proc/sys/fs/binfmt_misc/status`
100if [[ "${BINFMT_INSTALLED}" != "enabled" ]] ; then
101 echo "binfmt_misc not enabled!!"
102 break
103fi
104
105echo ".."
106# configure qemu to run 32b armv7 applications
107echo ":arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-arm:" > /proc/sys/fs/binfmt_misc/register
108
109export QEMU_LD_PREFIX=${ROOTFS32b_PATH}
110export QEMU_SET_ENV="LD_LIBRARY_PATH=${LIBS_PATH}"
111
112echo "Done!"
113echo "Environment was set to run 32b applications!"