Author Topic: How to run debian-mipsel application on dingux [again... thanks Dan!]  (Read 7430 times)

batman52 (OP)

  • Posts: 111
How to run debian-mipsel application on dingux (even if you're NOT a linux-ninja)

I'll try to keep all this as much simple as possible, so that (almost) everyone can read it (and hopefully report his experience) even if he's NOT a linux-ninja-developer (surely I'm not that). It could take a while though...

After having discussed the subject with cyberic99 in this thread

http://a320.freeforums.org/x-mplayer-xmms-dillo-strace-sort-of-running-on-dingux-t823.html

I finally managed to run a simple application (nano-tiny) that came from the debian-mipsel repository (www.debian.org). If the procedure I am suggesting here, will prove effective with other software, I think we can get a lot of useful application without the need of a custom recompilation (probabilly with some limitation regarding performance though).

The first thing I have to say is that as far as I know, the most of the applications included into a  generic linux distribution (like debian) are dinamically compiled. This means that the executable is *linked* to shared library files that are suposed to be available into the system (usually in the folder /lib, or /usr/lib, or /usr/local/lib ). This is useful in order to reduce the dimension of a single executable.

For instance, if you try to compile an "hello world" application dinamically (this is the default), your executable will be very small, since it doesn't actually contains the code of your printf() call, but just a *link* to it. Otherwise if you perform the same compilation statically (BTW: if you're using gcc, you just have to add the --static option), the executable will be noticeabily wider, since it will embed the printf() code. This is obviously a waste of space in your hd, since you still have the printf() code resident somewhere in your system.
The interesting thing of static compilation is that the whole code needed to run the executable is in that binary file, so that it can be executed into every machine that supports the same instruction code (=same cpu) an the same system calls (in the case of a UNIX-like system, POSIX compliant?).

Let's return to our favourite linux system (aka dingux)... it has a set of very optimized custom-compiled libraries generously provided us from booboo (lib-uClibc?). These are obviously not compatibile with any other system, but this doesn't mean that on dingux we can't run application not specifically compiled for it: as explained before, we could run every application statically compiled for the same cpu (mips with little endiannes, in short mipsel). We could even run dinamically compiled apps, if we provide the needed libraries. That's exactly what I've done ( thanks cyberic99 for explaining! ;-) ). In fact the debian guys provide us a bunch of compiled applications, ready to work on a mipsel system (and their libraries as well), so that we can just take them and run on our dingoo (well maybe it's actually not THAT easy)!

Every app is available from the debian repository in the form of a .deb file, which in a nutshell is a just compressed archive, containing the binary and eventually some libraries (and some other things too, but let's keep it short). Shared libraries are supplied themselves in the same way. So, chosen an application (let's say nano-tiny, available at http://packages.debian.org/unstable/editors/nano-tiny) in order to be able to make it run, we will need its package, and all its related *dependencies* archives as well. For instance, the nano-tiny package (nano-tiny_2.0.9-2_mipsel.dev) depends on libc6 (libc6_2.9-21_mipsel.deb) and libslang (libslang2_2.1.4-3_mipsel.deb) too. So how can get we the binary files included into this archives? The debian system provides us the proper tool: dpkg-deb. To extract the files we just have to type from a console shell of a debian system (like ubuntu), something like:
Code: [Select]
dpkg-deb -x my_deb_file.deb my_destination_folder
In order to make available a single library folder to our dingux system, we have to merge into one, all the /lib subfolders from the extracted archives, while the executable files (just like nano-tiny), are in the /bin subfolder. In short, in order to run a generic application we need just two things:
1) the binary file of the application itself
2) a folder that contains the library files needed (linked) by the application

Well, once we got those two things we could just copy them into our SD card, but...
Unfortunately library folders often contain special files called "symbolic links", that cannot be created into a FAT32 partition (=filesystem) like that of our dingux-powered SDcard. Disappointing issue! As far as i can understand, in order to keep the system "lightweight", at the moment dingux supports just two kinds of filesystem: FAT32 and romfs.
Romfs... What's that? Do you remember that file called rootfs, that you copied into the SD? It's just a filesystem (=directories+files structure) in a romfs format. As the name suggest (R.O.M.= Read Only Memory) is a read-only filesystem, so how can we create it? A proper tool named genromfs can be used for that. For instance I created a folder where I copied the /lib subfolder containing all nano-tiny dependencies and the nano-tiny executable itself, then I moved to that directory and from a shell typed:
Code: [Select]
genromfs -f nano.goo
if you do the same, you'll can see that a nano.goo file will have been created, that you can (finally!) copy into the SD into the /local folder.

Let's switch to dingux! Power your dingoo while pressing select!MMMM... I was just wondering that nano is a console application, so we'll have to get a console access. Just plug the dingoo to your computer through the usb cable, then from a shell you can connect to a serial console using the command:
Code: [Select]
telnet 10.1.0.2
Congratulations! You are now "into" the dingux system (just entered the matrix)! Well, all the files into the /local folder are mapped into the /usr/local folder of the dingux system, so you'd better switch to that typing:
Code: [Select]
cd /usr/local
now, typing
Code: [Select]
ls
you should see an entry named nano.goo that represents the file we're intrerested in. You got it? We need now to get back those file we had extracted from the .deb files, and then repacked into the .goo file. All we have to do in this case is to *mount* the filesystem.

Quote from: About mount from wikipedia:
The Unix command line utility mount instructs the operating system a file system is ready to use, and associates it with a particular point in the system's file system hierarchy (its mount point)

First we have to get a mount point, then. It's a simple empty directory that we can create typing
Code: [Select]
mkdir /usr/local/nano
Then we can mount our filesystem
Code: [Select]
mount -t romfs -o loop nano.goo /usr/local/nano

Now that we can access the files, we have to instruct the system to execute the binary /usr/local/nano/nano-tiny, using the libraries contained into the /usr/local/nano/lib folder. *In theory* one could point the new library folder changing the value of the environment variable $LD_LIBRARY_PATH, but neither in my ubuntu system, nor in dingux i've been able to read it value (can someone explain this?). So i had to follow the other known way...

This implies calling explicitly the system loader from the shell and specify to it the library folder. The libc6 library we put in the /lib subfolder contains a system loader (ld-2.9.so), we can (finally!) tell him to execute our nano-tiny with this command
Code: [Select]
/usr/local/nano/lib/ld-2.9.so --library-path /usr/local/nano/lib /usr/local/nano/nano-tiny

« Last Edit: October 29, 2009, 10:36:44 am by batman52 »

vimrc

  • Posts: 66
Re: How to run debian-mipsel application on dingux [again... thanks Dan!]
« Reply #1 on: October 28, 2009, 11:09:10 pm »
Hey, batman52. I keep looking for this post since the last accident.
I really don't know you're the author. Thanks a lot! ;)

batman52 (OP)

  • Posts: 111
Re: How to run debian-mipsel application on dingux [again... thanks Dan!]
« Reply #2 on: October 29, 2009, 08:33:38 am »
You're welcome vimrc!
I didn't think this would really care someone, since it has been posted quite long ago, but i didn't get any feedback about it. Anyway i noticed that it was lost in the "Dan Bang", so when cleaning my desktop i discovered that i had an hidden backup file, i decided to post it again.

Unfortunately it seems that our community lost cyberic99, who started this topic and was able to set up an x environment and use xmms as well as other apps from debian. He also told me he finally was able to correctly configure the mouse to be used with dingux, even though he never clearly explained how.

My "secret plan" is to grab this way xpdf from debian, and maybe in a far far future fbreader too. In order to achieve this, i still need to automate the procedure, since fbreader depends on GTK2, so that would be a big pain in the arse to download and extract all dependencies by hand!
« Last Edit: October 29, 2009, 10:41:28 am by batman52 »

vimrc

  • Posts: 66
Re: How to run debian-mipsel application on dingux [again... thanks Dan!]
« Reply #3 on: October 29, 2009, 12:19:08 pm »
Have you noted this thread?
http://code.google.com/p/jz-hacking/wiki/qemujz
We can get more clues from it (including "cyberic99", you will find his/her??  ;D comment in this thread).

Another thread:
http://hissorii.blog45.fc2.com/blog-entry-106.html  (Japanese version, but you can use google translation)

Cyberic99's X-environment package:
http://cyberic.free.fr/Dingoo/big_pack.zip

PS: I am quite interested in the qemu-hack project, at least we can ask for help from its author if
we met problem. 

batman52 (OP)

  • Posts: 111
Re: How to run debian-mipsel application on dingux [again... thanks Dan!]
« Reply #4 on: October 29, 2009, 12:43:22 pm »
Have you noted this thread?
http://code.google.com/p/jz-hacking/wiki/qemujz
We can get more clues from it (including "cyberic99", you will find his/her??  ;D comment in this thread).
PS: I am quite interested in the qemu-hack project, at least we can ask for help from its author if
we met problem.  

I followed the progress of both linux and rockbox on onda vx747 before buying my dingoo, since onda would have definitively better suited my needs. Unfortunatley, i believe that rockbox is reductive for such a good SoC, but linux on onda is stalled, and noone seems to be interested on it. I believe it's a shame, since it could become a sort of cheap ipod touch. Anyway it should be out of production now so my arguments may be pointless.

BTW: I'm really looking forward to see qtopia on dingoo, too...

I also have a quemu-mipsel VM on my pc, that can natively compile console apps for dingux (never tried with graphic ones), but i stopped working on it when i realized that almost all dingux apps can easily be compiled (and run) on our x86 machines.

Have you noted this thread?
Another thread:
http://hissorii.blog45.fc2.com/blog-entry-106.html  (Japanese version, but you can use google translation)

Nice! It explains tha use of x2x... but what if we wanted not to keep our dingoo hooked to a pc?

Have you noted this thread?
Cyberic99's X-environment package:
http://cyberic.free.fr/Dingoo/big_pack.zip

Already have on my pc... useful for other people though ;-)

« Last Edit: October 29, 2009, 09:49:20 pm by batman52 »

vimrc

  • Posts: 66
Re: How to run debian-mipsel application on dingux [again... thanks Dan!]
« Reply #5 on: November 03, 2009, 07:39:06 pm »
Hi, batman52,

Just find an interesting post here:
http://nanl.de/blog/2009/10/gtk2-running-on-top-of-directfb-on-openwrt/

It seems the GTK2 without X should be feasible for A320 (Consider the Qi only used JZ4720,
A320 used JZ4740.) Cool!

Source:
http://projects.qi-hardware.com/index.php/p/openwrt-packages/source/tree/master/libdirectfb
http://www.directfb.org/wiki/index.php/Projects:GTK_on_DirectFB

« Last Edit: November 03, 2009, 08:07:28 pm by vimrc »

batman52 (OP)

  • Posts: 111
Re: How to run debian-mipsel application on dingux [again... thanks Dan!]
« Reply #6 on: November 03, 2009, 08:33:02 pm »
I already knew about gtk over directfb because i found it on the ingenic ftp site. I tried for some time compiling it, but i finally gave up when i discovered that gtk2 cannot be compiled on a uclibc toolchain because of lack of internationalization support required by glib2. :-(

Therefore i believe that qi-hardware guys are using a full glibc toolchain (please someone says me i wrong!). Just to be sure, I have posted the question to the author of the article on the comments space.

GTK1.2 should be possible, even though I don't know how much it could be useful.

We could compile ourselves GTK2 over directfb with glibc, but why should we care about it, since debian provides us a mipsel binary?

EDIT: wow they used uclibc! They also have a patch here:
https://dev.openwrt.org/browser/packages/libs/glib2
I definitively have to give it a try! Cross your fingers!
« Last Edit: November 03, 2009, 09:01:34 pm by batman52 »

vimrc

  • Posts: 66
Re: How to run debian-mipsel application on dingux [again... thanks Dan!]
« Reply #7 on: November 03, 2009, 09:17:18 pm »
I just saw your comments. You guy rocks.

PS: I don't know if I followed your point, but It seems the latest dingux toolchain have included the "iconv" lib, is it related to your international char-set problems?

batman52 (OP)

  • Posts: 111
Re: How to run debian-mipsel application on dingux [again... thanks Dan!]
« Reply #8 on: November 03, 2009, 10:17:49 pm »
PS: I don't know if I followed your point, but It seems the latest dingux toolchain have included the "iconv" lib, is it related to your international char-set problems?

As far as i can remember libiconv was included from the start, but there was something wrong with some linking to a function included in it, which debugging was far beyond my skills.

I remember i found several reportings of the same problem, like this one:

http://old.nabble.com/glib-configuration-issues-with-arm-linux-uclibc-toolchain-td25544718.html


And i found different patches, but they weren't suited for the glib version included in the ingenics release, like this:
 

http://old.nabble.com/uclibc-%2B-glib-2---possible--td24348863.html


Let's hope this last one is the good one!

vimrc

  • Posts: 66
Re: How to run debian-mipsel application on dingux [again... thanks Dan!]
« Reply #9 on: November 03, 2009, 10:51:47 pm »
OK, I see. It's very promising, I will focus on this topic recently.  Maybe we need to rebuild the necessary libs including libiconv from openwrt ourselves:
https://dev.openwrt.org/browser/packages/libs

Maybe this one?
https://dev.openwrt.org/browser/packages/libs/gettext/Makefile?rev=6164

Never mind, I'll try it anyway if I have time.
« Last Edit: November 03, 2009, 11:06:58 pm by vimrc »

vimrc

  • Posts: 66
Re: How to run debian-mipsel application on dingux [again... thanks Dan!]
« Reply #10 on: November 06, 2009, 11:11:02 pm »
Hi, batman52,

I just complied the glib2 sucessfully via uclibc. It should work, but I am sorry because I'm busy with my own work and don't have time to realize the GTK+DirectFB. I believe you or somebody can make it finally :), so I post the procedures:

1. Get the necessary sources:

Code: [Select]
svn co svn://svn.openwrt.org/openwrt/trunk/                          
svn co svn://svn.openwrt.org/openwrt/packages/

When you finished this, you can find the necessary gettext and glib2 in the /packages/lib/gettext and /packages/lib/glib2
, normally there are a makefile and patch directory. So just add one line in the makefile like:

Code: [Select]
TOPDIR=/home/yourname/trunk  (Include the "rule.mk" in the trunk directory)

Now you can run make to download and patch the necessary library. It's quite convenient. However, the makefile will be interrupted because of the path problem (such as "can't find sed" or sth else). It's all right, because the necessary libraries have been downloaded and patched, just go to /trunk/build_dir/target-_-/, you will find them.  :)

2. Compile the gettext lib:

Go to /trunk/build_dir/target/gettext/, run:

Code: [Select]
./configure --host=mipsel-linux --target=mipsel-linux --prefix=/justtest/usr/
Code: [Select]
make; make install
2b. Make sure you have installed gettext in your host PC:

For Debian users, just type:
Code: [Select]
apt-get install gettextIf you skip this step, when you try to configure the glib2, you will meet problems such as "can't find msgfmt"...

3. Complie the glib2:
Go to /trunk/build_dir/target-_-/glib-2.22.2, copy the config.cache file from the following link, and run:

Code: [Select]
./configure --host=mipsel-linux --target=mipsel-linux --prefix=/justtest/usr/ --cache-file=config.cache
Code: [Select]
make; make install
Note: I met several annoying problems when I tried to configure it, such as several errors on "cross_compiling" and "config.cache". I patched these files (you can use diff to check it.), so I can make the glib2 successfully.  

You can get the patched files from:

http://bossninja.googlepages.com/configure
http://bossninja.googlepages.com/config.cache
http://bossninja.googlepages.com/config.h

4. Enjoy it!  
Or you can get the complied library including gettext and glib2 from:
http://bossninja.googlepages.com/gettext_glib2.tar.bz2

You can put them to /opt/mipsel-uclibc/usr/ if you like, but I don't have time to test it, so maybe you need to recompile the libraries.

Good luck and success!




 






« Last Edit: November 07, 2009, 11:45:38 am by vimrc »

batman52 (OP)

  • Posts: 111
Re: How to run debian-mipsel application on dingux [again... thanks Dan!]
« Reply #11 on: November 07, 2009, 08:24:42 am »
You are great vimrc!
I would never be able to do that!
I'll try as soon as i can, but it could take some days, since i wanted to release the gui for mplayer taken from your greader2x, first. BTW: incidentally i have "ported" it to x86 to fasten debugging.

Kalisiin

  • Guest
Re: How to run debian-mipsel application on dingux [again... thanks Dan!]
« Reply #12 on: November 07, 2009, 09:00:36 am »
How to run debian-mipsel application on dingux (even if you're NOT a linux-ninja)

[/snip]


   ???   <----me with my head about to explode.
Hey, don't mean to derail anything here, but what is the reason you would want to run this application...in other words, when you do this, what are you trying to accomplish?  I'm trying to learn how to do this stuff, and the only way one learns is by asking questions, so, if anyone could provide a short, easy-to-understand answer...my thanks!

batman52 (OP)

  • Posts: 111
Re: How to run debian-mipsel application on dingux [again... thanks Dan!]
« Reply #13 on: November 07, 2009, 10:03:31 am »
@kalisiin

Debian is one of the most diffused and supported linux distributions. From that comes that it has a quite large community working on it, as well as a big number of architectures (included x86, powerpc, arm and mipsel) and  applications supported.

As you can see, there are a lot of people asking for this or that application being ported on dingoo, but there are just a few developers willing/able to do that atm.

Since on the hw side dingoo is capable to run applications from the debian distro, this could be a (I have to admit: not-so-)easy way to go to have a lot of general purpose applications potentially running on our favourite pmp. Obviously the procedure i am suggesting here, have to be improved and automated.

« Last Edit: November 07, 2009, 10:11:42 am by batman52 »

Kalisiin

  • Guest
Re: How to run debian-mipsel application on dingux [again... thanks Dan!]
« Reply #14 on: November 07, 2009, 11:05:24 am »
@kalisiin

Debian is one of the most diffused and supported linux distributions. From that comes that it has a quite large community working on it, as well as a big number of architectures (included x86, powerpc, arm and mipsel) and  applications supported.

As you can see, there are a lot of people asking for this or that application being ported on dingoo, but there are just a few developers willing/able to do that atm.

Since on the hw side dingoo is capable to run applications from the debian distro, this could be a (I have to admit: not-so-)easy way to go to have a lot of general purpose applications potentially running on our favourite pmp. Obviously the procedure i am suggesting here, have to be improved and automated.



Thanks.  Didn't understand everything you said, but I got the general gist, anyway.
Basically, the answer is...why re-invent the wheel...why not use what's out there that already works, and just modify it to our needs...instead of starting from scratch.  Is that basically right?

batman52 (OP)

  • Posts: 111
Re: How to run debian-mipsel application on dingux [again... thanks Dan!]
« Reply #15 on: November 07, 2009, 11:59:21 am »
Quote
Basically, the answer is...why re-invent the wheel...why not use what's out there that already works, and just modify it to our needs...instead of starting from scratch.  Is that basically right?

Right! ^_^

vimrc

  • Posts: 66
Re: How to run debian-mipsel application on dingux [again... thanks Dan!]
« Reply #16 on: November 07, 2009, 05:33:50 pm »
You are great vimrc!
I would never be able to do that!
I'll try as soon as i can, but it could take some days, since i wanted to release the gui for mplayer taken from your greader2x, first. BTW: incidentally i have "ported" it to x86 to fasten debugging.

It's good news. So if you met any problem during compiling GTK+, just post it here (or open a new thread to attract more attentions), we can discuss it and try to move on.  

If we can handle this problem, we can start to port the FBReader. :)
« Last Edit: November 07, 2009, 07:42:49 pm by vimrc »