Cross compiling an app

screwface
Hi,

I need your help to understand something about cross compiling:

When building a new system, everything should be consistent. The same
compiler should be used for building the filesystem apps, compiling new
applications and so on. This ensures to have the correct libraries versions
in the file system to guarantee compatibility with applications.
This is the case using tools like pengutronix PTXdist, or buildroot and so
on

My question is more about using "general distro" like Debian. In that case,
you don't know which compiler was used to build the packages. How to be
sure to cross compile applications that won't have any conflicts with your
system? To be more precise, I have a debian 5.0.8 on my system, I don't
know the glibc version, and other libraries. There is no gcc compiler on
it. I would like to cross compile Transmission for this system, but I don't
know how to do it.
Should I just take the last CodeSourcery Gcc compiler and compile
transmission with armv5te option? Doing like this may create
incompatibilities as Debian 5 is quite old, and Gcc will be a new version.

Can somebody light my candle?
Thank you!

davef
As you seem to be familiar with PTXdist why not just use their toolchain?

I did that for msmtp before being encouraged to write my own rule files and
use their build system as well.

Screwface
Hi Dave,

Thanks for your reply. There are two reasons for which I don't use PTXDist:
- first, I'm curious and I would like to learn. I have this question since
a long time now
- but the best reason is I can't. In fact, the target for this question is
not a mini, but a Iomega Ix2-200 NAS. It has a firmware based on Linux
Debian 5.0.8, and it is installed onto image files. So each time the NAS
boots up, it uncompresses the image to get the root filesystem. As the
torrent client is very poor in term of functionnalities, I would like to
install transmission instead. I managed to make it work on my mini210s, but
now I need to have it working on the NAS itself.

Juergen explained me in another post it was important to have a consistant
filesystem with the toolchain, that's why I wonder how it works with
official distros as it's not as easy as PTXDist configurations.

davef
I think most of the time you get away with it.  However, in my experience I
didn't seem to get away with it often enough!  And if your debugging skills
are poorly-developed then you waste days and weeks trying to get things to
work.

How do the OpenEmebbed and BuildRoot guys handle these issues?  I have
never used either system.  Some groups use OpenEmbedded at work, but I am
not working with them so never hear how easy or difficult it is to use.

Reggie
I would look at the underlying processor of the whole thing and take it
from there, look for the source code (it should be gpl'd if it's running
debian) from iomega or openwrt would be a good place to look too.

Juergen Beisert
Debian based binary archives are built in nearly the same manner like
PTXdist does it: they use a specific toolchain, a tested patch set, a
valuable configuration for the package and at the end, the results are
packaged into a *.deb archive.
You should get in touch with the ARM Debian maintainers. Maybe they can
offer you a reliable way to create your own application's archives.
matching all the existing dependencies of your currently running root
filesystem. Keep in mind: also the Debian mainainers need a reliable way to
create their *.deb archive pool. We have a Debian maintainer here at
Pengutronix. I will ask her how to proceed. Please be patient.

Reggie
Screwface, check here for general info about your nas,
http://iomega.nas-central.org/wiki/Category:Ix2-200

More specifically here for how to put debian on it :-)
http://blog.nobiscuit.com/2011/08/06/installing-debian-to-disk-on-an-ix2...

Screwface
Hi,

Thank you very much Reggie for your links. I already knew those websites. I
don't want to install a fresh debian on the NAS because I will loose all
the functionnalities provided by supplier, I mean Web interface, all
servers and so on. I would need to reconfigure everything. But it could be
a good solution to do this, to get a full custom NAS installation. But it's
time to spend...

Juergen, thank you very much for your valuable help (as usual!). I didn't
know the process to create the packages, I thought there was an "official"
toolchain but was not sure. I'll wait for your advices.

Thanks again to help me on this issue

Juergen Beisert
Screwface,

it seems not that trivial how to generate matching deb packages for an
existing distribution. All I know right now is, they build their
distribution packages natively(!). It seems they do not use cross
compilers. But my information is still not complete. Give me some more
time.

Reggie
can't you grab a binary from the existing unit and query it to see how it
was built?  Of course I realise that it's not necessarily going to give you
the information you need but readelf and ldd can be quite useful,
especially if they left debugging turned on.

If it's based on debian then they probably didn't build it from the ground
up and it's probably based on armel.

Also, if it's got uboot on it, there is nothing to stop you test running
different kernels/rootfs, does it have an sd card on it, that should be
simple enough to boot from? Or with it being a NAS I expect it to have
networking, in theory you should be able to test tftp booting and nfs
rootfs, totally non destructive, you can set all your necessary commands to
boot the kernel via tftp and set bootargs to run from nfs rootfs, then once
you do a power cycle, any changes you made are gone, they're only committed
to flash when you do a 'saveenv' in uboot.

Lastly, did you actually go looking for the ix2-200 source code?

https://iomega-na-en.custhelp.com/app/answers/detail/a_id/22898
Downloading that will instantly tell you which glibc version it's using.

http://forum.nas-central.org/viewtopic.php?f=243&t=4205
Also hints at being able to update a non-cloud version of the ix2-200 to a
cloud version.

If you look through the source code, you will see the glib version, what's
not necessarily so apparent is the gcc version that they're using, it's 4.3
apparently.  I'll leave you to download the source and figure out the glibc
version :-)

Screwface
I already downloaded the source code, and already thought about modifying
kernel or creating a new system, but it's a huge workload for a non
professional person. Iomega delivers the kernel, the vanilla one if I'm
right, and they give some patches to apply. But the kernel is common to
several NAS (ix4-200), and I'm a bit lost and confused. Furthermore, I'm
not familiar with patch command and process. But I already used tftp boot
when I tinker a bit too much, the nas didn't boot. So there is no SD-Card
slot, but yes, uboot allows to connect to tftp and nfs servers.
I executed libc yesterday. It's version is 2.8, compiled with Gnu CC 4.3.2
But it's not so easy to tweak the system as it uses a non common
architecture compared to mini or other bevboards: the filesystem is not
written to a partition and accessed by the kernel directly. There are 5
main image files written to a partition. Mainly, one contains the binaries
(Apps image file), another the kernel, a third one contains initrd. I
understood roughly how it works, but there are some details I have not
discovered yet. Apps filesystem is mounted in RAM, so each time you make
modifications or try to install an application, it is lost at next reboot.
It is very instructive and I learn a lot digging into minis or this NAS.
The problem is I used the NAS also as my tftp/nfs server for mini210 /
mini2440, and it is unusable for the moment :-)

I found this way to install transmission, but I thought it was not a good
idea to use non debian packages because of library consistency. I feared
the glibc and cross compile tool chain used to compile those packages may
differ from my system's one and may cause failures.

To be honnest, everything is not clear in my mind. I understand the correct
way is to generate all the binaries, libraries and so on with the same
toolchain. PTXdist case is ok.
But using NSLU2 packages on other systems is not clear for me, is the fact
that is works pure luck, or is there another reason I don't understand?
And if I go farther in this way, when you have a linux distribution on your
PC, let's say i386. You have Gcc already installed and you are able to
generate binaries consistent with your system. But you can also install
third party compiler like CodeSourcery one. In this last case, libraries
(glibc or other) may differ from the host system, so I'm a bit confused.

So for the moment, the only way I found, as Juergen explained it is quite
hard to generate debian binaries, is to extract NSLU2 repository *.ipk
packages files, mount the Apps image, integrate *.ipk content in the image,
and install the whole customized system this way:
http://iomega.nas-central.org/wiki/Category:Ix2-200-usb-init

It's not the perfect way, but it's a try. I'll let you know!
I'll also have to write the /etc/rcX.d/SXX_transmission file, another topic
to understand and learn!

PS: correct source code is this one
https://iomega-na-en.custhelp.com/app/answers/detail/a_id/26776

One last thing: I'm sorry to debate this non FriendlyARM subject here, but
I didn't know where to get embedded systems development answers to my
questions. And as there are here very qualified persons like you both...

Again, thanks a lot for your help

Screwface
I forgot to give the link of NSLU2 transmission package installation on
ix2-200:

http://techmonks.net/installing-transmission-and-dnsmasq-on-a-nas/

Reggie
It seems to me that as long as you've got access to uboot then you can mess
around however you like (as long as you don't wipe uboot).

As for 'building' it yourself, with debian etc. you essentially don't
really build much yourself, just the kernel, everything is pre-built, you
just have to bootstrap the image.

For instance, I recently 'built' my own ubuntu for the mini210S, it starts
with me compiling a kernel, that's about all you have to do for the
compiling stage, the rest of the install is done for you.  you use a 'first
stage' installer, this gets enough of a simple rootfs onto a system to
allow you to complete the 2nd stage which will involve a fair bit of
downloading from ubuntu repos but again, everything is done for you.  You
just have to 'apt-get' any extra stuff you might want.

Also, don't worry about it not being an FA subject, I think I had a moan at
someone a while back for discussing a competitors board but I'm over that
stuff now :D

Lastly, if you can recover the NAS to its original state then I probably
wouldn't worry so much about breaking stuff if I were you.

Very Lastly, I would at the very least join that forum
http://forum.nas-central.org and ask some questions.


Very, very lastly this time, looking at the techmonks post, it's all very
well explained there for you, it might be using nslu2 repos but the
tutorial is written for a stock ix-2 so I would take a strong guess that
they're binary compatible :-)

Screwface
Reggie,

In fact, when I said it's a huge workload to create a non system, I didn't
mean I wanted to create all by myself. Of course, installing a newer Debian
distribution would be easy (and I think I saw a webpage explaining that). I
was more talking about configuring everything, and designing a new web
interface to manage everything. I don't want to have to connect to a ssh
session each time I want to start or stop a mediaserver for example. But
yes, I already dreamed about an armel version of FreeNAS, or some open
source NAS software which can be installed on many different systems
(Synology, Netgear, Qnap...). So installing a complete system would be
quite easy, the same way it can be done on a desktop PC, but having a fully
functionnal system is much more work. Maybe one day, when I'll have more
time, I'll do it. But you're right, I could use uboot tftp/nfs abilities to
create a new system without risk for the embedded system.

Regarding nas-central forum, unfortunately it is more a 'NAS usage' forum
than a 'developper / improvement' one. That's why I preffered to post here,
and I think my questions are not really system specific. Everybody can ask
the same principle questions about using debian and creating apps for the
minis.

By the way, as I explained in my previous post, I'll adapt techmonks
method, and create new installation files in which many people will be
interested in (according to Iomega forum).

But I still have my questions! :D
Maybe Juergen will be helpful to me to understand!

Thanks

Reggie
wrt. the nas-central site, yes, it's a nas usage site but there are
actually people on there that discuss development for NAS units, so at the
very least it's a starting point with people that might actually know your
project :)  I'm not saying stop asking about it here, just saying that
you're more likely to find someone that can help directly rather than
giving the random advice that I'm giving.

as for techmonks, I don't think you need to adapt it at all, it's written
for ix2 units :-)