diff options
author | Tudor Florea <tudor.florea@enea.com> | 2015-10-08 22:42:49 +0200 |
---|---|---|
committer | Tudor Florea <tudor.florea@enea.com> | 2015-10-08 22:42:49 +0200 |
commit | 635d320abfa6dc3c0e1d00e3ceae567dd0e55a5b (patch) | |
tree | dcd42fafb9189d3be13ef3d95f9ce6f4f5cfa267 /recipes-support/32b-env | |
download | meta-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.bb | 23 | ||||
-rwxr-xr-x | recipes-support/32b-env/files/set_32b_env_chroot.sh | 120 | ||||
-rwxr-xr-x | recipes-support/32b-env/files/set_32b_env_qemu.sh | 113 |
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 @@ | |||
1 | SUMMARY = "A simple set of shell scripts used for enabling support for \ | ||
2 | dynamic linked 32b application on hierofalcon boards." | ||
3 | DESCRIPTION = "The 32b-env package installs the set_32b_env_chroot.sh \ | ||
4 | and set_32b_env_qemu.sh shell scripts which enables support for dynamic \ | ||
5 | linked 32b application on hierofalcon boards until the multilib support \ | ||
6 | will be available for armv8 architecture." | ||
7 | |||
8 | SRC_URI = "file://set_32b_env_chroot.sh \ | ||
9 | file://set_32b_env_qemu.sh" | ||
10 | |||
11 | LICENSE = "MIT" | ||
12 | LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=4d92cd373abda3937c2bc47fbc49d690" | ||
13 | |||
14 | do_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 | |||
20 | do_patch[noexec] = "1" | ||
21 | do_configure[noexec] = "1" | ||
22 | do_compile[noexec] = "1" | ||
23 | do_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 | |||
3 | help() | ||
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 | |||
25 | usage() | ||
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 | |||
36 | if [[ $# -eq 0 ]] ; then | ||
37 | echo "[ERR]: Missing script parameters!" | ||
38 | echo "" | ||
39 | usage | ||
40 | fi | ||
41 | |||
42 | while getopts "hr:" OPTION; | ||
43 | do | ||
44 | case $OPTION in | ||
45 | |||
46 | r) | ||
47 | ROOTFS32b_PATH="$OPTARG" | ||
48 | ;; | ||
49 | |||
50 | ?) | ||
51 | help | ||
52 | ;; | ||
53 | |||
54 | esac | ||
55 | done | ||
56 | |||
57 | ABS_PATH=`cd "${ROOTFS32b_PATH}"; pwd` | ||
58 | ROOTFS32b_PATH=${ABS_PATH} | ||
59 | |||
60 | if [[ ! -d ${ROOTFS32b_PATH} ]] ; then | ||
61 | usage | ||
62 | fi | ||
63 | |||
64 | if [[ ! -d ${ROOTFS32b_PATH}/dev ]] ; then | ||
65 | mkdir ${ROOTFS32b_PATH}/dev | ||
66 | fi | ||
67 | |||
68 | if [[ ! -d ${ROOTFS32b_PATH}/proc ]] ; then | ||
69 | mkdir ${ROOTFS32b_PATH}/proc | ||
70 | fi | ||
71 | |||
72 | if [[ ! -d ${ROOTFS32b_PATH}/sys ]] ; then | ||
73 | mkdir ${ROOTFS32b_PATH}/sys | ||
74 | fi | ||
75 | |||
76 | if [[ ! -d ${ROOTFS32b_PATH}/etc ]] ; then | ||
77 | mkdir ${ROOTFS32b_PATH}/etc | ||
78 | fi | ||
79 | |||
80 | umount ${ROOTFS32b_PATH}/dev/pts 2>/dev/null | ||
81 | umount ${ROOTFS32b_PATH}/dev 2>/dev/null | ||
82 | mount --bind /dev ${ROOTFS32b_PATH}/dev | ||
83 | if [[ "$?" != "0" ]] ; then | ||
84 | echo "Failed to mount /dev folder" | ||
85 | exit | ||
86 | fi | ||
87 | |||
88 | umount ${ROOTFS32b_PATH}/proc 2>/dev/null | ||
89 | mount --bind /proc ${ROOTFS32b_PATH}/proc | ||
90 | if [[ "$?" != "0" ]] ; then | ||
91 | echo "Failed to mount /proc folder" | ||
92 | exit | ||
93 | fi | ||
94 | |||
95 | umount ${ROOTFS32b_PATH}/sys 2>/dev/null | ||
96 | mount --bind /sys ${ROOTFS32b_PATH}/sys | ||
97 | if [[ "$?" != "0" ]] ; then | ||
98 | echo "Failed to mount /sys folder" | ||
99 | exit | ||
100 | fi | ||
101 | |||
102 | mount --bind /dev/pts ${ROOTFS32b_PATH}/dev/pts | ||
103 | if [[ "$?" != "0" ]] ; then | ||
104 | echo "Failed to mount /dev/pts folder" | ||
105 | exit | ||
106 | fi | ||
107 | |||
108 | cp /etc/resolv.conf ${ROOTFS32b_PATH}/etc/resolv.conf | ||
109 | if [[ "$?" != "0" ]] ; then | ||
110 | echo "Failed to copy resolv.conf file" | ||
111 | exit | ||
112 | fi | ||
113 | |||
114 | PATH=/bin:/sbin:/usr/bin:/usr/sbin | ||
115 | |||
116 | echo "New root will be ${ROOTFS32b_PATH}/ type \"exit\" to return to /" | ||
117 | chroot ${ROOTFS32b_PATH}/ /bin/sh | ||
118 | if [[ "$?" != "0" ]] ; then | ||
119 | echo "Failed to start chroot!" | ||
120 | fi | ||
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 | |||
3 | help() | ||
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 | |||
25 | usage() | ||
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 | |||
41 | if [[ $# -eq 0 ]] ; then | ||
42 | echo "[ERR]: Missing script parameters!" | ||
43 | echo "" | ||
44 | usage | ||
45 | fi | ||
46 | |||
47 | while getopts "hr:l:" OPTION; | ||
48 | do | ||
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 | ||
68 | done | ||
69 | |||
70 | ABS_PATH=`cd "${ROOTFS32b_PATH}"; pwd` | ||
71 | ROOTFS32b_PATH=${ABS_PATH} | ||
72 | |||
73 | if [[ ! -d ${ROOTFS32b_PATH} ]] ; then | ||
74 | usage | ||
75 | fi | ||
76 | |||
77 | echo "Please wait..." | ||
78 | echo "" | ||
79 | QEMU_EXISTS=`which qemu-arm` | ||
80 | if [[ "${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 | ||
86 | fi | ||
87 | |||
88 | echo "." | ||
89 | mount -t binfmt_misc none /proc/sys/fs/binfmt_misc | ||
90 | if [[ "$?" != "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 | ||
97 | fi | ||
98 | |||
99 | BINFMT_INSTALLED=`cat /proc/sys/fs/binfmt_misc/status` | ||
100 | if [[ "${BINFMT_INSTALLED}" != "enabled" ]] ; then | ||
101 | echo "binfmt_misc not enabled!!" | ||
102 | break | ||
103 | fi | ||
104 | |||
105 | echo ".." | ||
106 | # configure qemu to run 32b armv7 applications | ||
107 | echo ":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 | |||
109 | export QEMU_LD_PREFIX=${ROOTFS32b_PATH} | ||
110 | export QEMU_SET_ENV="LD_LIBRARY_PATH=${LIBS_PATH}" | ||
111 | |||
112 | echo "Done!" | ||
113 | echo "Environment was set to run 32b applications!" | ||