Sign up here and you can log into the forum!

SMP Cross Compile Help - transmissionbt

Have a question about devices internals, memory layout, reverse engineering, etc---This is the place for anything so technical that it would cause a n00b's head to 'splode

SMP Cross Compile Help - transmissionbt   

Postby KAD » Tue Apr 01, 2014 11:15 pm

hey all, well I did what I could,

does anybody have idea's on either what I'm doing wrong, or what else I can try
compile in squeeze does not work due to wrong version of glibc (compile completes, just fine, but will not run outside of squeeze img)

so on to cross compiling
used ubuntu 12.04 and WD's official toolchain from GPL archive

transmission, does have a few dependancies, so I cross compile them as well
here's my steps
Code: Select all
*libevent
export PATH="/opt/mips-4.3/bin:$PATH"
export cross=mips-linux-gnu-
export CC="${cross}gcc"

./configure --host="mips-linux-gnu" --prefix="/home/smp/output/usr/local"
make
make install

*zlib
export PATH="/opt/mips-4.3/bin:$PATH"
export cross=mips-linux-gnu-
export CC="${cross}gcc

./configure --prefix="/home/smp/output/usr/local"
make
make install

*openssl
export PATH="/opt/mips-4.3/bin:$PATH"
export cross=mips-linux-gnu-

./Configure linux-generic32 --prefix="/home/smp/output/usr/local" shared zlib-dynamic -I"/home/smp/output/usr/local/include"
make CC="${cross}gcc" AR="${cross}ar r" RANLIB="${cross}ranlib"
make install

*libcurl
export PATH="/opt/mips-4.3/bin:$PATH"
export cross=mips-linux-gnu-
export CC="${cross}gcc"

./configure --prefix="/home/smp/output/usr/local" --target="mips-linux-gnu" --host="mips-linux-gnu" --with-zlib="/home/smp/output/usr/local" --with-ssl="/home/smp/output/usr/local"
make
make install

*transmission
export PATH="/opt/mips-4.3/bin:$PATH"
export cross=mips-linux-gnu-

lol - re-read this in the morning, and notice I put all dependency cmd's above but forgot to put the transmission compile cmd's, here they are from memory, you get the idea

./configure --host="mips-linux-gnu" --prefix="/home/smp/transmission-mips" --without-gtk --disable-libnotify --disable-mac --disable-wx --disable-beos --enable-utp --disable-nls --enable-inotify --enable-utp --enable-lightweight --enable-cli --enable-daemon --with-zlib="/home/smp/output/usr/local " PKG_CONFIG="="/home/smp/output/usr/bin/pkg-config" PKG_CONFIG_PATH="="/home/smp/output/usr/local/​lib/pkgconfig" CPPFLAGS=-DTR_EMBEDDED

make CC="${cross}gcc" AR="${cross}ar" RANLIB="${cross}ranlib"
make install


once completed I copy everything to WD
here's my output on WD

Code: Select all
# file ./transmission-cli
./transmission-cli: ELF 32-bit MSB executable, MIPS, MIPS32 rel2 version 1, dynamically linked (uses shared libs), for GNU/Linux 2.6.12, with unknown capability 0x41000000 = 0xf676e75, not stripped
# ldd ./transmission-cli
        not a dynamic executable
# ./transmission-cli
./transmission-cli: line 1: syntax error: unexpected word (expecting ")")
# ./transmission-cli --help
./transmission-cli: line 1: syntax error: unexpected word (expecting ")")


I'm up for idea's
I'd also be open to rtorrent as an alternative, but initially, I had the same issues
rtorrent compiles fine in squeeze, but will not run outside of squeeze due to wrong version of glibc

I also tried the files from recliq's transmission.app.bin with basically the same output on WD
If you like my work please consider a Donation. Donate
Please read the appropriate documentation before posting questions! READ ME FAQ WIKI
PM's are for private matters. Post support questions to the appropriate forum, or they will be ignored.
User avatar
KAD
Global Moderator
 
Posts: 5103
Joined: Mon Apr 12, 2010 4:59 pm
Location: Seattle, WA USA

Re: SMP Cross Compile Help - transmissionbt   

Postby mad_ady » Wed Apr 02, 2014 2:27 am

I'm not knowleadgeable in this and can't help you much, but I too would like to understand what the problem is. One question that comes to mind is - if it works inside squeeze - would it be possible to embed the squeeze libc and when interacting with the program to prefix the LIBDIR with the path to the libc that works? That would probably allow you to run apps in app.bins in an easier way...

One more thing - binaries for the older WDTVs are MIPS32-LSB, but your binary shows as MIPS32-MSB, so it might be missing a parameter in endianness (but if so, how does it run inside squeeze?)

Code: Select all
[root@aldebaran ~]# cd /DataVolume/Kits/wdtv-kits/1.02-wdlxtv-live/trunk/bin/
[root@aldebaran bin]# file busybox
busybox: ELF 32-bit LSB executable, MIPS, MIPS32 rel2 version 1 (SYSV), dynamically linked (uses shared libs), stripped
User avatar
mad_ady
Developer
 
Posts: 4549
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania

Re: SMP Cross Compile Help - transmissionbt   

Postby KAD » Wed Apr 02, 2014 7:56 am

the one from squeeze was a different binary
could and I'd guess, probably is MIPS32-LSB
I'll check later tonight

so sounds like that's what I need to start looking into LSB vs MSB

for for the different version of libc, haven't tried with transmission
back when I was having problems with sudo, I tried to preload the different verion of libc with a wrapper script,
but it did not work

edit: a quick google search suggest using mipsel instead of mips
WD's compiler does have mipsel-unknown-linux-gnu-*
but these are just wrapper scripts for code sourcery
and actually, I tried those, and they failed to compile anything
If you like my work please consider a Donation. Donate
Please read the appropriate documentation before posting questions! READ ME FAQ WIKI
PM's are for private matters. Post support questions to the appropriate forum, or they will be ignored.
User avatar
KAD
Global Moderator
 
Posts: 5103
Joined: Mon Apr 12, 2010 4:59 pm
Location: Seattle, WA USA

Re: SMP Cross Compile Help - transmissionbt   

Postby recliq » Wed Apr 02, 2014 11:03 am

Here's how I compiled transmission-2.52 for live:

WD toolchain (installen in /opt/mips-4.3) on Ubuntu 9.04

1) set compile environment
Code: Select all
recliq@wdtv-dev:/opt/src/transmission-2.52$ source /opt/mips-4.3/toolchain-path.env

Here's my content (remember this is for Live...)
Code: Select all
recliq@wdtv-dev:/opt/src/transmission-2.52$ cat /opt/mips-4.3/toolchain-path.env
# source this script to put your new compiler in the PATH.

PATH=/opt/mips-4.3/bin:$PATH
SMP86XX_TOOLCHAIN_PATH=/opt/mips-4.3
export SMP86XX_TOOLCHAIN_PATH
export COMPILKIND='codesourcery hardfloat glibc release'

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/buildroot-1.05/lib
export LD_RUN_PATH=$LD_RUN_PATH:/opt/buildroot-1.05/lib
export PKG_CONFIG_PATH=/opt/buildroot-1.05/lib/pkgconfig

# export CFLAGS="-I/opt/buildroot-1.05/include"
export CPPFLAGS="-I/opt/buildroot-1.05/include"
export LDFLAGS="-L/opt/buildroot-1.05/lib"

You might need to adjust the /opt/buildroot-1.05 path, that's my wdtv root tree... it's also somewhere in the wd gpl source once you compiled it ;))


2) Build transmission
Code: Select all
recliq@wdtv-dev:/opt/src/transmission-2.52$ ./configure --prefix=/apps/transmission --host=mipsel-linux --without-gtk --with-inotify --enable-cli --without-iconv --cache-file=config.cache --enable-shared
recliq@wdtv-dev:/opt/src/transmission-2.52$ make
recliq@wdtv-dev:/opt/src/transmission-2.52$ make install

This is for building an app, you should match the prefix dir the location later on WD! If this is something like /usr or /usr/local instead of /apps you better leave the make install, you'd need to gather the files from the build dir yourself (can be gathered from the makefile).
­WDLXTV Project Maintainer
-:] If you like my contributions feel free to donate for a beer or a new flash drive. ...and always remember: RTFM! (README, FAQ, WIKI) [:-
User avatar
recliq
WDLXTV Team
 
Posts: 5513
Joined: Thu Apr 15, 2010 8:09 am
Location: Kiel, Germany

Re: SMP Cross Compile Help - transmissionbt   

Postby KAD » Wed Apr 02, 2014 12:05 pm

:idea: I feel like the light just went on

thanks again for all your help

now I feel, I'm understanding this whole WD toolchain codesourcery wrapper bit

if I don't set the value's the wrappers require they fail to build anything :oops:

so this
Code: Select all
PATH=/opt/mips-4.3/bin:$PATH
SMP86XX_TOOLCHAIN_PATH=/opt/mips-4.3
export SMP86XX_TOOLCHAIN_PATH
export COMPILKIND='codesourcery hardfloat glibc release'


and a few other flag adjustments, should take care of this
If you like my work please consider a Donation. Donate
Please read the appropriate documentation before posting questions! READ ME FAQ WIKI
PM's are for private matters. Post support questions to the appropriate forum, or they will be ignored.
User avatar
KAD
Global Moderator
 
Posts: 5103
Joined: Mon Apr 12, 2010 4:59 pm
Location: Seattle, WA USA

Re: SMP Cross Compile Help - transmissionbt   

Postby KAD » Wed Apr 02, 2014 9:47 pm

I wish I could say that I had this working

toolchain wrapper scripts seem to work now

Code: Select all
smp@ubuntu:/opt/mips-4.3$ cat ./toolchain-path.env
# source this script to put your new compiler in the PATH.

PATH=/opt/mips-4.3/bin:$PATH
SMP86XX_TOOLCHAIN_PATH=/opt/mips-4.3
export SMP86XX_TOOLCHAIN_PATH
export COMPILKIND='codesourcery hardfloat glibc release'
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/smp/output/usr/local/lib
export LD_RUN_PATH=$LD_RUN_PATH:/home/smp/output/usr/local/lib
export PKG_CONFIG_PATH="/home/smp/output/usr/local/lib/pkgconfig"
export CPPFLAGS="-I/home/smp/output/usr/local/include"
export LDFLAGS="-L/home/smp/output/usr/local/lib"



here's the new steps I'm taking
Code: Select all
*libevent
source /opt/mips-4.3/toolchain-path.env

./configure --host="mipsel-linux" --prefix="/home/smp/output/usr/local"
make
make install

*zlib
source /opt/mips-4.3/toolchain-path.env

./configure --prefix="/home/smp/output/usr/local"
make
make install

*openssl
source /opt/mips-4.3/toolchain-path.env

./Configure linux-generic32 --prefix="/home/smp/output/usr/local" shared zlib-dynamic -I"/home/smp/output/usr/local/include"
make
make install

*libcurl
source /opt/mips-4.3/toolchain-path.env

./configure --prefix="/home/smp/output/usr/local" --target="mipsel-linux" --host="mipsel-linux" --with-zlib="/home/smp/output/usr/local" --with-ssl="/home/smp/output/usr/local"
make
make install

*transmission
source /opt/mips-4.3/toolchain-path.env

./configure --host="mipsel-linux" --prefix="/usr/share/transmission" --without-gtk --disable-mac --enable-utp --disable-nls --enable-utp --with-inotify --enable-lightweight --enable-cli --enable-shared --enable-daemon

make
make install




Here's some output and erros

Code: Select all
Configuration:

   Source code location:                              .
   Compiler:                                          mipsel-linux-g++

   Build libtransmission:                             yes
      * optimized for low-resource systems:           yes
      * µTP enabled:                                  yes

   Build Command-Line client:                         yes

   Build GTK+ client:                                 no
      * libappindicator for an Ubuntu-style tray:     no

   Build Daemon:                                      yes

   Build Mac client:                                  no


smp@ubuntu:~/kris/src/transmission-2.82$ make
Making all in extras
make[1]: Entering directory `/home/smp/kris/src/transmission-2.82/extras'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/smp/kris/src/transmission-2.82/extras'
Making all in third-party
make[1]: Entering directory `/home/smp/kris/src/transmission-2.82/third-party'
Making all in dht
make[2]: Entering directory `/home/smp/kris/src/transmission-2.82/third-party/dht'
  CC       dht.o
mips-linux-gnu-gcc: 2.82": No such file or directory
<command-line>: warning: missing terminating " character
dht.c: In function 'is_martian':
dht.c:358: warning: cast increases required alignment of target type
dht.c:366: warning: cast increases required alignment of target type
dht.c: In function 'storage_store':
dht.c:1286: warning: cast increases required alignment of target type
dht.c:1290: warning: cast increases required alignment of target type
dht.c: In function 'make_token':
dht.c:1413: warning: cast increases required alignment of target type
dht.c:1418: warning: cast increases required alignment of target type
make[2]: *** [dht.o] Error 1
make[2]: Leaving directory `/home/smp/kris/src/transmission-2.82/third-party/dht'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/smp/kris/src/transmission-2.82/third-party'
make: *** [all-recursive] Error 1



I can see the problem it's trying to use mips-linux-gnu-gcc
when the configure commands all point to mipsel-linux-*
as well as the depencies were built with mipsel-linux-*

any idea's on how to fix
I already checked output of env
and I don't see old value's that would point to wrong compiler

I do know that the dependencies are working
example
here's the version of curl I just compiled from steps above, all is just fine on WD
and it's a newer version, so I'll replace the WD's old version 7.20.1 with this working version 7.33
Only transmission fails to build
Code: Select all
# chmod a+x ./curl
# file ./curl
./curl: ELF 32-bit LSB executable, MIPS, MIPS32 rel2 version 1, dynamically linked (uses shared libs), for GNU/Linux 2.6.12, with unknown capability 0xf41 = 0x756e6700, not stripped
# ldd ./curl
        libcurl.so.4 => /lib/libcurl.so.4 (0x2aaaa000)
        libz.so.1 => /lib/libz.so.1 (0x2ab0c000)
        librt.so.1 => /lib/librt.so.1 (0x2ab32000)
        libc.so.6 => /lib/libc.so.6 (0x2ab4a000)
        libssl.so.0.9.8 => /lib/libssl.so.0.9.8 (0x2acac000)
        libcrypto.so.0.9.8 => /lib/libcrypto.so.0.9.8 (0x2ad24000)
        libdl.so.2 => /lib/libdl.so.2 (0x2af1e000)
        libpthread.so.0 => /lib/libpthread.so.0 (0x2af32000)
        /lib/ld.so.1 (0x55550000)
# curl --help
Usage: curl [options...] <url>
Options: (H) means HTTP/HTTPS only, (F) means FTP only
    --anyauth       Pick "any" authentication method (H)
-a/--append        Append to target file when uploading (F/SFTP)
    --basic         Use HTTP Basic Authentication (H)
    --cacert <file> CA certificate to verify peer against (SSL)
    --capath <directory> CA directory to verify peer against (SSL)
-E/--cert <cert[:passwd]> Client certificate file and password (SSL)
    --cert-type <type> Certificate file type (DER/PEM/ENG) (SSL)
    --ciphers <list> SSL ciphers to use (SSL)
    --compressed    Request compressed response (using deflate or gzip)
-K/--config <file> Specify which config file to read
    --connect-timeout <seconds> Maximum time allowed for connection
-C/--continue-at <offset> Resumed transfer offset
-b/--cookie <name=string/file> Cookie string or file to read cookies from (H)
-c/--cookie-jar <file> Write cookies to this file after operation (
If you like my work please consider a Donation. Donate
Please read the appropriate documentation before posting questions! READ ME FAQ WIKI
PM's are for private matters. Post support questions to the appropriate forum, or they will be ignored.
User avatar
KAD
Global Moderator
 
Posts: 5103
Joined: Mon Apr 12, 2010 4:59 pm
Location: Seattle, WA USA

Re: SMP Cross Compile Help - transmissionbt   

Postby recliq » Thu Apr 03, 2014 4:10 am

Code: Select all
mips-linux-gnu-gcc: 2.82": No such file or directory

I've seen that error before and it's kind of nasty and annoying.
AFAIR it's a problem with quoted strings with spaces that get passed through more than one script, having the effect that it's passed without the quotes which makes it two arguments instead of one for the following script. I fixed errors like that by eliminating the spaces... (eg. change "transmission 2.82" to "transmission_2.82" if possilbe).

Not sure why the make still wants to use mips instead of mipsel... have you issued a "make clean" or even "make distclean" before "./configure..." ?
To make sure remove the transmission dir and untar the source again, so you get a fresh source tree.

I will try to compile transmission 2.82 this evening on the build env I used to compile transmission 2.52.

I think your build environment setup is not quite correct yet, because transmission should find the openssl and curl libs coming from WDTV, that's what the CFLAGS/CPPFLAGS/LDFLAGS are for.
With those you tell the (cross-)compiler where to search for libraries (LD_*) and include files (C(PP)FFLAGS). These should poiunt to the MIPS libraries used on WDTV.
­WDLXTV Project Maintainer
-:] If you like my contributions feel free to donate for a beer or a new flash drive. ...and always remember: RTFM! (README, FAQ, WIKI) [:-
User avatar
recliq
WDLXTV Team
 
Posts: 5513
Joined: Thu Apr 15, 2010 8:09 am
Location: Kiel, Germany

Re: SMP Cross Compile Help - transmissionbt   

Postby KAD » Thu Apr 03, 2014 8:30 am

yeah, I did a make distclean first

when that didn't work, I went as far, as rm -rf ./transmblahblah blah
and then redownloaded transmission source

as for curl, openssl, zlib, libevent
the ./configure output is quite lengthy (only posted end portion above), but it did find those

I guess I could try passing CFLAGS as well
but I dont' think that will solve it,

I think your explanation about quotes being passed or not passed through scripts, makes more sense
next line of output also supports that
Code: Select all
<command-line>: warning: missing terminating " character


thanks again for your help on this
If you like my work please consider a Donation. Donate
Please read the appropriate documentation before posting questions! READ ME FAQ WIKI
PM's are for private matters. Post support questions to the appropriate forum, or they will be ignored.
User avatar
KAD
Global Moderator
 
Posts: 5103
Joined: Mon Apr 12, 2010 4:59 pm
Location: Seattle, WA USA

Re: SMP Cross Compile Help - transmissionbt   

Postby recliq » Thu Apr 03, 2014 11:17 am

Here's how I got it compiled for Live (2.82)
First off clean your build dir
Code: Select all
root@wdtv-dev:/opt/src/transmission-2.82# make distclean

Then export the cross-build env (or source a file containing these)
Code: Select all
root@wdtv-dev:/opt/src/transmission-2.82# cat /opt/toolchain-path.env
export COMPILKIND='codesourcery hardfloat glibc release'
BINPATH=/opt/mips-4.3/bin
PATH=$BINPATH:$PATH
SMP86XX_TOOLCHAIN_PATH=/opt/mips-4.3
export BUILDROOT=/opt/buildroot-1.05
export SMP86XX_TOOLCHAIN_PATH
export LDFLAGS=" -L$BUILDROOT/lib -L$BUILDROOT/usr/lib -liconv"
export CFLAGS="-Os -I$BUILDROOT/include -I$BUILDROOT/usr/include"
export CPPFLAGS="-Os -I$BUILDROOT/include -I$BUILDROOT/usr/include"
export CC="$BINPATH/mipsel-linux-gcc"
export CPP="$BINPATH/mipsel-linux-cpp"
export CXX="$BINPATH/mipsel-linux-g++"
export LD=$BINPATH/mipsel-linux-ld
export RANLIB=$BINPATH/mipsel-linux-ranlib
export PKG_CONFIG_PATH="$BUILDROOT/lib/pkgconfig:$BUILDROOT/usr/lib/pkgconfig"
export LD_RUN_PATH=$BUILDROOT/lib:$BUILDROOT/usr/lib

To build 2.82 it seems important to add -liconv to LDFLAGS, otherwise utils.c won't compile.

Now patch the configure file to avoid the buf from the previous posts:
Code: Select all
root@wdtv-dev:/opt/src/transmission-2.82# cat configure.patch
--- configure   2014-04-03 20:30:07.962049768 +0200
+++ configure   2014-04-03 20:27:16.257991892 +0200
@@ -591,7 +591,7 @@
PACKAGE_NAME='transmission'
PACKAGE_TARNAME='transmission'
PACKAGE_VERSION='2.82'
-PACKAGE_STRING='transmission 2.82'
+PACKAGE_STRING='transmission-2.82'
PACKAGE_BUGREPORT='http://trac.transmissionbt.com/newticket'
PACKAGE_URL=''

Code: Select all
root@wdtv-dev:/opt/src/transmission-2.82# patch < configure.patch

Code: Select all
root@wdtv-dev:/opt/src/transmission-2.82# ./configure --prefix=/apps/transmission --host=mipsel-linux --without-gtk --with-inotify --enable-cli --cache-file=config.cache --enable-shared --without-iconv --with-sysroot=/opt/buildroot-1.05
configure: WARNING: unrecognized options: --without-iconv, --with-sysroot
configure: loading cache config.cache
...
config.status: executing po/stamp-it commands


Configuration:

   Source code location:                              .
   Compiler:                                          /opt/mips-4.3/bin/mipsel-linux-g++

   Build libtransmission:                             yes
      * optimized for low-resource systems:           no
      * µTP enabled:                                  yes

   Build Command-Line client:                         yes

   Build GTK+ client:                                 no
      * libappindicator for an Ubuntu-style tray:     no

   Build Daemon:                                      yes

   Build Mac client:                                  no

Code: Select all
root@wdtv-dev:/opt/src/transmission-2.82# make
Making all in extras
..
             (Lots of warnings ;))
..
make[1]: Betrete Verzeichnis '/opt/src/transmission-2.82'
make[1]: Für das Ziel »all-am« ist nichts zu tun.
make[1]: Verlasse Verzeichnis '/opt/src/transmission-2.82'
root@wdtv-dev:/opt/src/transmission-2.82# make install
Making install in extras
make[1]: Betrete Verzeichnis '/opt/src/transmission-2.82/extras'
make[2]: Betrete Verzeichnis '/opt/src/transmission-2.82/extras'
...
make[2]: Für das Ziel »install-exec-am« ist nichts zu tun.
make[2]: Für das Ziel »install-data-am« ist nichts zu tun.
make[2]: Verlasse Verzeichnis '/opt/src/transmission-2.82'
make[1]: Verlasse Verzeichnis '/opt/src/transmission-2.82'
­WDLXTV Project Maintainer
-:] If you like my contributions feel free to donate for a beer or a new flash drive. ...and always remember: RTFM! (README, FAQ, WIKI) [:-
User avatar
recliq
WDLXTV Team
 
Posts: 5513
Joined: Thu Apr 15, 2010 8:09 am
Location: Kiel, Germany

Re: SMP Cross Compile Help - transmissionbt   

Postby KAD » Thu Apr 03, 2014 11:50 am

wow :o

thank you. that's a lot of digging, I never would have figured that out.

we'll see if I can do this for SMP tonight , your post seems pretty straight forward
If you like my work please consider a Donation. Donate
Please read the appropriate documentation before posting questions! READ ME FAQ WIKI
PM's are for private matters. Post support questions to the appropriate forum, or they will be ignored.
User avatar
KAD
Global Moderator
 
Posts: 5103
Joined: Mon Apr 12, 2010 4:59 pm
Location: Seattle, WA USA

Next

Return to WDTV Live

Who is online

Users browsing this forum: No registered users and 1 guest