Добавить в FacebookДобавить в Google BookmarksДобавить в TwitterДобавить в OdnoklassnikiДобавить в Vkcom

Just recently, my friend had a need for a file manager   Midnight Commander on the network drive NAS Seagate Central. In the standard firmware it is not and is not expected. The search for the compiled MC was also unsuccessful - all the arm versions built for the processor do not work on this device. If you do not want to, you'll have to collect mc (Midnight Commander) for NAS Seagate Central by yourself.

First you need to go to the device by ssh and find out its architecture.

To find out the architecture, execute the following commands:

$ cat /etc/*release
MontaVista Linux 6, (.dev-snapshot-20130726)

and

$ cat /proc/cpuinfo
Processor : ARMv6-compatible processor rev 4 (v6l)
BogoMIPS : 279.34
Features : swp half thumb fastmult vfp edsp java
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xb02
CPU revision : 4

Hardware : Cavium Networks CNS3420 Validation Board
Revision : 0000
Serial : 0000000000000000

A further search on the Internet led me to the forum stackowerflow, where this issue was discussed and A solution was proposed. Actually, the problem lies in the following: the Seagate Central processor uses page size / offset 0x10000, whereas the default for ARM GCC is 0x8000. It is for this reason that the Internet, compiled by MC, found on the Internet has not been launched on this device. It was also suggested to use the flags -march = armv6k -Wl, -z, max-page-size = 0x10000, -z, common-page-size = 0x10000, -Ttext-segment = 0x10000. Separately, I want to note an interesting method to find the correct text-segment offset in the title of the section and the size of the page in the headers of the program. To do this, you need to run the #readelf -a / usr / bin / nano command for one of the built-in programs, for example nano. So the idea is clear, it's time to start assembling. On the Internet, I found a wonderful article called "Cross compilation Midnight Commander for arm". The rest of the presentation will be done in the same style as the author of this article, including only the flags necessary for the target architecture. On my netbook I use the operating system Ubuntu 14.04. For it, you need to install tools for cross-compilation. I perform all actions with the rights of the supervisor. Execute the command  #apt-get install gcc-4.7-arm-linux-gnueabi arm-linux-gnueabi-gcc pkg-config-arm-linux-gnueabi libglib2.0-dev. I decided that  Midnight Commander   on the network drive NAS will be located in the /opt/mc folder. Create the necessary folders in our system (I created them in my Ubuntu system) by running #mkdir /opt/mc, #mkdir /opt/mc/sources, #mkdir /opt/mc/builds. The purpose of the folders is quite clear. What is this for? We will compile MS and libraries with static linking. That's why you need to create a folder structure identical to the one we plan to use on our device.

Go my Google+ page(the author's link below) and look at the sources there. Put the source code in the /opt/mc/source folder. Further, as well as the author of the above article, we will create scripts in the catalog of the compiled library. All source code must be in the /opt/mc/sources folder. Again, note that this will be a compilation with static link libraries.

Compilation check-0.10.0:

Create a script file - #nano /opt/mc/sources/check-0.10.0/my_make

and add the code

#!/bin/bash
ARCH=armv6k \
CFLAGS="-march=armv6k -Wl,-z,max-page-size=0x10000,-z,common-page-size=0x10000,-Ttext-segment=0x10000" \
CC=arm-linux-gnueabi-gcc ./configure \
--host=arm-linux-gnueabi \
--prefix=/opt/mc/builds/build_check-0.10.0/ \
--enable-static=yes
make
sudo make install

Save the file by pressing the key combination ctrl+o. In this case, nano will ask whether to save? Let's say Y means Yes. After that, press ctrl+x.

Give the file the right to execute #chmod 755 /opt/mc/sources/check-0.10.0/my_make.

Let's move to the source folder #cd /opt/mc/sources/check-0.10.0/ and execute the script #./my_make.

At the end of the run, the compiled library will be in the folder /opt/mc/builds/build_check-0.10.0.

In the same way, we compile the rest of the libraries and the MC itself. I cite the contents of the files.

Compilation libffi-3.2.1:

#!/bin/bash
ARCH=armv6k \
CFLAGS="-march=armv6k -Wl,-z,max-page-size=0x10000,-z,common-page-size=0x10000,-Ttext-segment=0x10000" \
CC=arm-linux-gnueabi-gcc ./configure \
--host=arm-linux-gnueabi \
--prefix=/opt/mc/builds/build_libffi-3.2.1 \
--enable-static=yes
make
sudo make install

Compilation zlib-1.2.8:

#!/bin/bash
ARCH=armv6k \
CFLAGS="-march=armv6k -Wl,-z,max-page-size=0x10000,-z,common-page-size=0x10000,-Ttext-segment=0x10000" \
CC=arm-linux-gnueabi-gcc ./configure \
--static
make
sudo make install DESTDIR=/opt/mc/builds/build_zlib-1.2.8

Compilation ncurses-5.9:

#!/bin/bash
ARCH=armv6k \
CFLAGS="-march=armv6k -Wl,-z,max-page-size=0x10000,-z,common-page-size=0x10000,-Ttext-segment=0x10000" \
CC=arm-linux-gnueabi-gcc ./configure \
--target=arm-linux-gnueabi \
--with-gcc=arm-linux-gnueabi-gcc \
--host=arm-linux-gnueabi \ --prefix=/opt/mc/builds/build_ncurses-5.9 \
--enable-static=yes
make
sudo make install


Compilation glib-2.16.6 (This library has a separate history. New libraries do not work с libc.so.6 (GLIBС 2.11). By empirical way, analyzing the packages Debian Lenny, it was revealed that the assembly was done with the library glib-2.16.6) :

#!/bin/bash
echo "glib_cv_stack_grows=no" > arm-linux.cache
echo "glib_cv_uscore=no" >> arm-linux.cache
echo "ac_cv_func_posix_getpwuid_r=no" >> arm-linux.cache
echo "ac_cv_func_posix_getgrgid_r=no" >> arm-linux.cache

ARCH=armv6k \
CFLAGS="-march=armv6k -Wl,-z,max-page-size=0x10000,-z,common-page-size=0x10000,-Ttext-segment=0x10000" \
CC=arm-linux-gnueabi-gcc ./configure \
ZLIB_CFLAGS="-I/opt/mc/builds/build_zlib-1.2.8/usr/local/include/" \
ZLIB_LIBS="-L/opt/mc/builds/build_zlib-1.2.8/usr/local/lib -lz" \
LIBFFI_CFLAGS="-I/opt/mc/builds/build_libffi-3.2.1/lib/libffi-3.2.1/include" \
LIBFFI_LIBS="-L/opt/mc/builds/build_libffi-3.2.1/lib -lffi" \
--host=arm-linux-gnueabi \
--prefix=/opt/mc/builds/build_glib-2.16.6 \
--enable-static=yes \
--cache-file=arm-linux.cache
make
sudo make install

Compilation mc-4.8.14:

#!/bin/bash
ARCH=armv6k \
CFLAGS="-march=armv6k -Wl,-z,max-page-size=0x10000,-z,common-page-size=0x10000,-Ttext-segment=0x10000" \
CC=arm-linux-gnueabi-gcc ./configure \
CHECK_CFLAGS="-I/opt/mc/builds/build_check-0.10.0/include/" \
CHECK_LIBS="-L/opt/mc/builds/build_check-0.10.0/lib/ -lcheck" \
GLIB_CFLAGS="-I/opt/mc/builds/build_glib-2.16.6/include/glib-2.0 -I/opt/mc/builds/build_glib-2.16.6/lib/glib-2.0/include" \
GLIB_LIBS="-L/opt/mc/builds/build_glib-2.16.6/lib -lglib-2.0" \
GMODULE_CFLAGS="-I/tmp/mc/builds/build_glib-2.16.6/include/glib-2.0 -I/opt/mc/builds/build_glib-2.16.6/lib/glib-2.0/include" \
GMODULE_LIBS="-L/opt/mc/builds/build_glib-2.16.6/lib/glib-2.0 -lgmodule-2.0" \
--host=arm-linux-gnueabi \
--prefix=/opt/mc/builds/build_mc-4.8.14 \
--enable-static=yes \
--with-screen=ncurses \
--with-ncurses-includes="/opt/mc/builds/build_ncurses-5.9/include" \
--with-ncurses-libs="/opt/mc/builds/build_ncurses-5.9/lib"
make
sudo make install

After a sequential transition to the source folder and running all my_make files, you will have folders with compiled libraries and MC in the directory opt/mc/builds.

Now we are packing the builds folder in the archive  #tar -cvzf mc.tar.gz /opt/mc/builds. Copy the archive to the NAS using the command scp /path_to_archive/builds.tar.gz root@nas:/opt. Connect to NAS via ssh. Go to the desired folder # cd /opt. Extract the archive # tar -xvzf mc.tar.gz. We check the efficiency of the command #/opt/mc/builds/build_mc-4.8.14/bin/mc. At me with the friend all is perfectly started and works. In principle, after validating the operation, you can add the environment variable export PATH=/opt/mc/builds/build_mc-4.8.14/bin:$PATH. Then you can just start the Midnight Commander with the #mccommand. In order for this to work permanently from under the supervisor, you need to execute the command user@FC3> sudo nano /etc/profile find the line PATH="/usr/local/bin:/usr/bin:/bin"
And rewrite it like this: PATH="/usr/local/bin:/usr/bin:/bin:/opt/mc/builds/build_mc-4.8.14/bin"
And save the file. In order for the MS to work from under the NAS user account, it is necessary to make the user the owner of the /opt/mc folder and all the files in it. This is done by the command #chown -R user:root /opt/mc, where user - is the username on the device. For the Russian language, you need to configure the locale in the menu.

At the request in the comments, I post the finished assembly, follow the link with the tag "author:" at the bottom of the page on my Google+ profile and look there. Yandex bans the whole site for direct links to compiled programs. Do not blame me.

Here, perhaps, that's all. Have fun.

Good luck.

Автор: Darkeye.  

Another interesting thing in the network.

  

 

Похожие материалы

Go to the article feed