Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

ioctl32 error after compiling to Synology x86

Help
Mikkle
2012-10-22
2012-12-05
  • Mikkle
    Mikkle
    2012-10-22

    Thanks for this wonderful project. I'm running into an issue after cross-compiling for my Synology DS1512+ (x86_64) NAS on Ubuntu 12.04, per Rene's instructions here:  https://www.lonelycoder.com/redmine/boards/4/topics/3706?r=4330#message-4330

    I'm seeing the same issue reported by sirgadget here two months ago: https://github.com/SynoCommunity/spksrc/issues/161

    No compilation errors whatsoever. I first compiled for DSM 4.0 (Linux 2.6.32), and subsequently DSM 4.1 (Linux 3.2.11) with the same ioctl32 error in hdhomerun_control.

    Here is my log file and dmesg output:

    Running as user: root
    Num of devices = 1

    Device 1311f531 is type 1 and has 3 tuners

    Name of device: xxxxxxxx-0
    Tuner type set to "ATSC" based on conf file
    Tuner: 0
    Set initial pass-all filter for tuner: 1

    Name of device: xxxxxxxx-1
    Tuner type set to "ATSC" based on conf file
    Tuner: 1
    Set initial pass-all filter for tuner: 1

    Name of device: xxxxxxxx-2
    Tuner type set to "ATSC" based on conf file
    Tuner: 2
    Set initial pass-all filter for tuner: 1

    Couldn't create tuner! ioctl failed. This means the kernel module is either not loaded or has malfunctioned. Check dmesg.
    Couldn't create tuner! ioctl failed. This means the kernel module is either not loaded or has malfunctioned. Check dmesg.
    Couldn't create tuner! ioctl failed. This means the kernel module is either not loaded or has malfunctioned. Check dmesg.

    DS> dmesg
    HDHomeRun: Begin init, version 0.0.11
    HDHomeRun: Waiting for userspace to connect
    HDHomeRun: End init
    hdhomerun: userhdhomerun connected
    hdhomerun: userhdhomerun connected
    ioctl32(userhdhomerun:22131): Unknown cmd fd(6) cmd(c01c7600){t:'v';sz:28} arg(ffd1f8f4) on /dev/hdhomerun_control
    hdhomerun: userhdhomerun connected
    ioctl32(userhdhomerun:22131): Unknown cmd fd(7) cmd(c01c7600){t:'v';sz:28} arg(ffd1f8f4) on /dev/hdhomerun_control
    hdhomerun: userhdhomerun connected
    ioctl32(userhdhomerun:22131): Unknown cmd fd(8) cmd(c01c7600){t:'v';sz:28} arg(ffd1f8f4) on /dev/hdhomerun_control
    hdhomerun: userhdhomerun connected

    I'm not sure what additional information to include, but if anything else would be helpful I can provide it. Thanks!

     
  • Villy Thomsen
    Villy Thomsen
    2012-10-22

    Well, the ioctl32 error certainly stands out. Have you somehow accidently compiled the userhdhomerun as a 32 bit application? That won't work together with a 64 bit kernel.  There is ways around that using compat_ioctl instead, but it is of course much easier just to build it as 64 bit app. ;-)

    Check with:

    file /bin/userhdhomerun

    Which gives something like this on my box:

    /bin/userhdhomerun: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID=0x3419483eeecfab367de9cd2d7c3796ebd4aed17e, stripped

     
  • Mikkle
    Mikkle
    2012-10-23

    Thank you so much for the prompt reply!

    You're absolutely right. Somehow I had assumed that by compiling dvbhdhomerun directly on the NAS, the proper architecture would automatically be used. That's evidently not the case.

    Here is the output from file userhdhomerun:

    DS> file userhdhomerun
    userhdhomerun: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.4.3, not stripped

    And here is the output from uname -a on the NAS:

    DS> uname -a
    Linux DS 3.2.11 #2647 SMP Wed Sep 26 03:42:47 CST 2012 x86_64 GNU/Linux

    Would you mind letting me know what parameters should be used to compile a x86_64 binary instead?

    Thanks again!

     
  • Villy Thomsen
    Villy Thomsen
    2012-10-23

    It's a bit of a surprise to me too that you default g++ compiler doesn't default to 64 bit when you are obviously on a 64 bit machine. I suppose you could have installed a wrong tool chain somewhere along the line (or the default tool chain is just weird) and/or there are installed both 32 bit and 64 bit compilers on Synology.

    Just to be curious, what is the output of:

    g++ -v

    ?

    And also try a:

    which g++

    In the location that pops up, see what else you have that starts with g++  (ls /usr/bin/g++* for example).

     
  • Mikkle
    Mikkle
    2012-10-23

    DS> g++ -v
    Using built-in specs.
    Target: i686-linux-gnu
    Configured with: ../gcc-4.2.1/configure -build=i386-pc-linux-gnu -host=i686-linux-gnu -target=i686-linux-gnu -prefix=/opt -disable-nls -disable-static -with-as=/home/slug/optware/syno-i686/toolchain/gcc-4.2.1-glibc-2.3.6/i686-linux-gnu/bin/i686-linux-gnu-as -with-ld=/home/slug/optware/syno-i686/toolchain/gcc-4.2.1-glibc-2.3.6/i686-linux-gnu/bin/i686-linux-gnu-ld -enable-languages=c,c++ -disable-multilib
    Thread model: posix
    gcc version 4.2.1

    DS> which g++
    /opt/bin/g++

    This is the only version of g++ on the system. Here is the build output:

    DS> make clean
    rm -rf build
    DS> make
    cd build; cmake ..
    - The C compiler identification is GNU 4.2.1
    - The CXX compiler identification is GNU 4.2.1
    - Check for working C compiler: /opt/bin/gcc
    - Check for working C compiler: /opt/bin/gcc - works
    - Detecting C compiler ABI info
    - Detecting C compiler ABI info - done
    - Check for working CXX compiler: /opt/bin/c++
    - Check for working CXX compiler: /opt/bin/c++ - works
    - Detecting CXX compiler ABI info
    - Detecting CXX compiler ABI info - done
    - Performing Test HAVE_HDHOMERUN_TUNER_COUNT
    - Performing Test HAVE_HDHOMERUN_TUNER_COUNT - Success
    - Configuring done
    - Generating done
    - Build files have been written to: /opt/dvbhdhomerun/userhdhomerun/build
    make -C build  all
    make: Entering directory `/opt/dvbhdhomerun/userhdhomerun/build'
    make: Entering directory `/opt/dvbhdhomerun/userhdhomerun/build'
    make: Entering directory `/opt/dvbhdhomerun/userhdhomerun/build'
    Scanning dependencies of target userhdhomerun
    make: Leaving directory `/opt/dvbhdhomerun/userhdhomerun/build'
    make: Entering directory `/opt/dvbhdhomerun/userhdhomerun/build'
    Building CXX object CMakeFiles/userhdhomerun.dir/main.o
    Building CXX object CMakeFiles/userhdhomerun.dir/conf_inifile.o
    Building CXX object CMakeFiles/userhdhomerun.dir/hdhomerun_control.o
    Building CXX object CMakeFiles/userhdhomerun.dir/hdhomerun_controller.o
    Building CXX object CMakeFiles/userhdhomerun.dir/hdhomerun_tuner.o
    Building CXX object CMakeFiles/userhdhomerun.dir/log_file.o
    Building CXX object CMakeFiles/userhdhomerun.dir/thread_pthread.o
    Linking CXX executable userhdhomerun
    make: Leaving directory `/opt/dvbhdhomerun/userhdhomerun/build'
    Built target userhdhomerun
    make: Leaving directory `/opt/dvbhdhomerun/userhdhomerun/build'
    make: Leaving directory `/opt/dvbhdhomerun/userhdhomerun/build'

    The reason why I am trying to compile directly on the NAS is that I am following the directions here: https://www.lonelycoder.com/redmine/boards/4/topics/3706?r=4330#message-4330

    When I cross-compiled the drivers from Ubuntu, I used the following instead:
    make ARCH=x86_64 \ CROSS_COMPILE=/usr/local/x86_64-linux-gnu/bin/x86_64-linux-gnu-

    I'm not sure if it makes more sense to try to compile userhdhomerun on Ubuntu or directly on the NAS.

    Thanks again for all your help!

     
  • Villy Thomsen
    Villy Thomsen
    2012-10-23

    Well, first off, that is a 32 bit compiler you have there. So that explains why it doesn't work (just checking ;-) ).

    I suspect the instructions works for Rene simply because that toolchain happens to output 32 bit kernel modules for ARM (and he is on a 32 bit ARM machine).

    It's been a while since I've played with cross compilation, but how about a simple test first - since you are on a 64 bit Ubuntu, and your NAS is a 64 bit - try compile userhdhomerun on your Ubuntu without any kind of cross compilation - just a make inside your userhdhomerun directory - then copy it over and see what happens? :)

     
  • Villy Thomsen
    Villy Thomsen
    2012-10-23

    BTW, also worth a try to see if your 32 bit compiler on the NAS can generate 64 bit executable. Just add the following to userhdhomerun/CMakelists.txt

    SET(CMAKE_CXX_FLAGS -m64)

    Just chuck below the CMAKE_BUILD_TYPE in CMakelists.txt.  It probably won't work - but worth a shot.

     
  • Mikkle
    Mikkle
    2012-10-23

    Here is the output from make after adding the CMAKE_CXX_FLAGS to CMakelists.txt:

    DS> make
    cd build; cmake ..
    - The C compiler identification is GNU 4.2.1
    - The CXX compiler identification is GNU 4.2.1
    - Check for working C compiler: /opt/bin/gcc
    - Check for working C compiler: /opt/bin/gcc - works
    - Detecting C compiler ABI info
    - Detecting C compiler ABI info - done
    - Check for working CXX compiler: /opt/bin/c++
    - Check for working CXX compiler: /opt/bin/c++ - works
    - Detecting CXX compiler ABI info
    - Detecting CXX compiler ABI info - done
    - Performing Test HAVE_HDHOMERUN_TUNER_COUNT
    - Performing Test HAVE_HDHOMERUN_TUNER_COUNT - Success
    - Configuring done
    - Generating done
    - Build files have been written to: /opt/dvbhdhomerun/userhdhomerun/build
    make -C build  all
    make: Entering directory `/opt/dvbhdhomerun/userhdhomerun/build'
    make: Entering directory `/opt/dvbhdhomerun/userhdhomerun/build'
    make: Entering directory `/opt/dvbhdhomerun/userhdhomerun/build'
    Scanning dependencies of target userhdhomerun
    make: Leaving directory `/opt/dvbhdhomerun/userhdhomerun/build'
    make: Entering directory `/opt/dvbhdhomerun/userhdhomerun/build'
    Building CXX object CMakeFiles/userhdhomerun.dir/main.o
    /opt/dvbhdhomerun/userhdhomerun/main.cpp:1: sorry, unimplemented: 64-bit mode not compiled in
    make: ***  Error 1
    make: Leaving directory `/opt/dvbhdhomerun/userhdhomerun/build'
    make: ***  Error 2
    make: Leaving directory `/opt/dvbhdhomerun/userhdhomerun/build'
    make: ***  Error 2
    make: Leaving directory `/opt/dvbhdhomerun/userhdhomerun/build'
    make: ***  Error 2

    When I cross-compiled the drivers on Ubuntu a few days ago, that was from Ubuntu 12.04 32-bit (using ARCH=x86_64 \ CROSS_COMPILE=path_to_x64_tools). However this morning, immediately after reading your post #4 I installed Ubuntu 12.04 64-bit, thinking it would compile the correct binary. It compiled a 64-bit executable just fine and I copied it over to the NAS, but I ran into what seemed to be another issue and gave up, thinking I was on the wrong track:

    DS> file userhdhomerun
    userhdhomerun: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID=0xbb141f11669115f3ab36415c95d6e40e8d6e6775, not stripped
    DS> ./userhdhomerun
    ./userhdhomerun: error while loading shared libraries: libhdhomerun.so: cannot open shared object file: No such file or directory

    Now that I'm looking at this again per your post #6, I wonder: Does the libhdhomerun library have to reside in the same path on my Ubuntu machine and on my NAS? In other words, I set LIBHDHOMERUN_PATH in Ubuntu's CMakelists.txt to /home/mikkle/src/libhdhomerun. Will the compiled binary expect libhdhomerun to be in the exact same path on my NAS as well? (It's in /opt/libhdhomerun on the NAS.) Does the path to the library get "baked in" to the compiled executable? Sorry if these questions are primitive, I'm coming from a Windows background.

    Thanks again for all your help.

     
  • Mikkle
    Mikkle
    2012-10-24

    Well, that was easy enough to try. I recompiled using the same path (/opt/libhdhomerun) on both Ubuntu and the NAS, and see the same "libhdhomerun.so: cannot open shared object file: No such file or directory" problem mentioned in post #8.

    Both libhdhomerun.so and hdhomerun_config were compiled on the NAS itself, and I notice that they are 32-bit executables:

    DS> file libhdhomerun.so
    libhdhomerun.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, not stripped
    DS> file hdhomerun_config
    hdhomerun_config: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.4.3, stripped

    If I compile them on the Ubuntu x64 system and copy them over to the NAS, I get different errors altogether:

    DS> file libhdhomerun.so
    libhdhomerun.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID=0xa243eba95c9b9c1279a5d8845c61ce9507a8dfb2, not stripped
    DS> ./userhdhomerun
    ./userhdhomerun: /lib64/libc.so.6: version `GLIBC_2.4' not found (required by ./userhdhomerun)
    ./userhdhomerun: /lib64/libc.so.6: version `GLIBC_2.7' not found (required by libhdhomerun.so)
    ./userhdhomerun: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by libhdhomerun.so)
    ./userhdhomerun: /lib64/libc.so.6: version `GLIBC_2.15' not found (required by libhdhomerun.so)
    ./userhdhomerun: /lib64/libc.so.6: version `GLIBC_2.4' not found (required by libhdhomerun.so)

    Not sure where to go from here.

     
  • Villy Thomsen
    Villy Thomsen
    2012-10-24

    Ok, so obviously just compiling on a 64 bit Ubuntu produces an executable that doesn't really fit the Synology environment - I'm guessing the Synology uses a way older LIBC than your Ubuntu.

    Going over the instructions from Rene, I think the obvious solution would be to use the cross compiler toolchain you've already used for compiling the kernel modules to also compile the userhdhomerun application and the libhdhomerun needed by userhdhomerun.

    I haven't played with cross compilation and CMake yet but it seems fairly straightforward (http://www.cmake.org/Wiki/CMake_Cross_Compiling)  I may have the time to play around a bit with that tomorrow. For libhdhomerun, try compiling that in the same way as you did for the kernel module (with ARCH and CROSS_COMPILE) and see what that gives you.

     
  • Villy Thomsen
    Villy Thomsen
    2012-10-24

    Actually. Remember the "compat_ioctl" I mentioned earlier - if that works it would be a much simpler fix for you - a bit hackish but hey. :)

    You need to build the kernel modules again - and simply use the userhdhomerun you build on the NAS.

    In kernel/dvb_hdhomerun_control.c - locate:

    #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)
       .unlocked_ioctl = hdhomerun_control_ioctl,

    Add a line more so you have:

    #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)
       .unlocked_ioctl = hdhomerun_control_ioctl,
       .compat_ioctl = hdhomerun_control_ioctl,

    Build the kernel modules - copy to NAS. Run the userhdhomerun you build on the NAS. Profit?

     
  • Mikkle
    Mikkle
    2012-11-12

    Hi Villy,

    I'm so sorry I never got around to trying either of your solutions, life got really busy these past two weeks trying to get ready for a newborn. Just wanted to follow up and say I did not mean to ignore your posts.

    Another member on the Synology forums posted his binaries last week, I did get a few minutes to try them and they seemed to be compatible. Still, I would like to be able to compile dvbhdhomerun for myself.  I am hoping to give it another go later this week, if my son isn't born by then :)

    Thanks again for all your help!