Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Parallel port

    Scheduled Pinned Locked Moved General pfSense Questions
    34 Posts 5 Posters 9.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      matumbo
      last edited by

      Okey. I guess I will try to boot up some computer with FreeBSD 8.1 or use another Distro and make sure I have got all libs.
      Thanks for the help!

      1 Reply Last reply Reply Quote 0
      • stephenw10S
        stephenw10 Netgate Administrator
        last edited by

        There aren't that many FreeBSD based distros to choose from. BSD is not Linux.  ;)
        If your program is sufficiently basic then it will probably work across FreeBSD versions. The various lcdproc drivers that connect via the parallel port continued to function between pfSense 1.2.3 (FreeBSD 7.3) and 2.0 (FreeBSD 8.1).

        Steve

        Edit: you could try this: http://forum.pfsense.org/index.php/topic,52691.0.html
        You might want to use 32bit sources, whatever is appropriate for you.

        1 Reply Last reply Reply Quote 0
        • M
          matumbo
          last edited by

          Are there any restrictions to execute programs aswell? I tried to execute a program as root that I compiled on another distro but it returns Permission Denied.

          1 Reply Last reply Reply Quote 0
          • C
            cmb
            last edited by

            I'd just install a virtual machine of FreeBSD 8.1 (assuming you're running 2.0.1, you can get the 8.1 iso from ftp-archive.freebsd.org), compile it there, copy it over. The only thing you'll have to do after copying over a binary is make it executable, chmod +x filename.

            1 Reply Last reply Reply Quote 0
            • M
              matumbo
              last edited by

              I tried the thing with chroot, but it seems like I don't have the rsync-command supported.
              I installed FreeBSD 8.1 on another computer in VirtualBox. I compiled my program there and copied it to my pfsense router, made it executable and tried to run it. It seems like somthing else is missing because I got the following error: /libexec/ld-elf.so.1: /root/program/a.out: Shared object has no run-time symbol table

              When I tried to run it on my Virtual machine with FreeBSD it worked just fine except that I could write anything to the parallel port due to segfault. I suspect that it might be because it's in a Virtual machine.

              1 Reply Last reply Reply Quote 0
              • stephenw10S
                stephenw10 Netgate Administrator
                last edited by

                Hmm, you have probably included a library that isn't present in pfSense. Which you probably don't need anyway.
                I included code in my arm/disarm LED program to switch a single pin on the parallel port, in this case it switches the LCD backlight in the Firebox. Have a look at the code I used and try not to laugh too hard at my terrible coding style.  ;)
                http://forum.pfsense.org/index.php/topic,32013.msg270534.html#msg270534

                Steve

                1 Reply Last reply Reply Quote 0
                • M
                  matumbo
                  last edited by

                  Can't say that I am good at programming, so I am not in a position to laugh at anything ;)
                  From what I understand I need ioperm to access the parallel port and I guess that is included in one of these:
                  #include <machine cpufunc.h="">#include <machine sysarch.h="">Since I have no libs nor headers at all in pfsense I guess it is not possible to include anything in the code? Or how does it work?</machine></machine>

                  1 Reply Last reply Reply Quote 0
                  • M
                    matumbo
                    last edited by

                    I've managed with help from a friend to create a program that should work and I compile it in my VirtualBox FreeBSD 8.1 and it seems to work there but when I copy it to PFsense it doesn't. It complains about
                    /libexec/ld-elf.so.1: /root/program/a.out: Shared object has no run-time symbol table
                    or
                    Exec format error. Binary file not executable.
                    or
                    /libexec/ld-elf.so.1: /usr/lib/: invalid file format.

                    1 Reply Last reply Reply Quote 0
                    • stephenw10S
                      stephenw10 Netgate Administrator
                      last edited by

                      Hmm, something odd here. As is says in the code I cut and pasted from lcdproc:

                      Use i386_get_ioperm, i386_set_ioperm from <machine sysarch.h="">and inb and outb from <machine cpufunc.h="">(FreeBSD)</machine></machine>

                      Compiles and runs using gcc no problems for me.  :-\

                      Steve

                      1 Reply Last reply Reply Quote 0
                      • M
                        matumbo
                        last edited by

                        Did you compile it on another machine and copy it to PFsense?
                        I tried to run your program on pfsense and it worked just fine, but if I compiled it on my virtual box and moved it to Pfsense it wouldn't work. I thought that should work since it's the same release of FreeBsd.

                        Edit: Do I need to use any special options with gcc to compile it or just "gcc code.c" ?

                        1 Reply Last reply Reply Quote 0
                        • G
                          gderf
                          last edited by

                          @matumbo:

                          Do I need to use any special options with gcc to compile it or just "gcc code.c" ?

                          Just a guess, but you probably want to compile and statically link to all libraries that are not available on your pfsense box.

                          1 Reply Last reply Reply Quote 0
                          • M
                            matumbo
                            last edited by

                            @gderf:

                            @matumbo:

                            Do I need to use any special options with gcc to compile it or just "gcc code.c" ?

                            Just a guess, but you probably want to compile and statically link to all libraries that are not available on your pfsense box.

                            How can I do that? I am not very good at programming nor compiling.

                            1 Reply Last reply Reply Quote 0
                            • stephenw10S
                              stephenw10 Netgate Administrator
                              last edited by

                              I am using a real machine, an old laptop, and the only other option I specified was the output file:

                              root@.box/home/admin# gcc -o WGXepc WGXepc.c
                              
                              

                              Is this a 32bit vs 64bit problem?

                              Steve

                              1 Reply Last reply Reply Quote 0
                              • M
                                matumbo
                                last edited by

                                Okey, but it should work with a Virtual Machine aswell. I am running a 32bit-machine.

                                1 Reply Last reply Reply Quote 0
                                • stephenw10S
                                  stephenw10 Netgate Administrator
                                  last edited by

                                  Yep, should work.  :-
                                  I'm out of my depth here.  ;)

                                  Steve

                                  1 Reply Last reply Reply Quote 0
                                  • M
                                    matumbo
                                    last edited by

                                    Found out that this means that the libraries the headers refer to are not found in the system:
                                    /libexec/ld-elf.so.1: /root/program/a.out: Shared object has no run-time symbol table

                                    Are there no libs present in pfsense? And can someone tell me how to statically link libraries to the program?

                                    1 Reply Last reply Reply Quote 0
                                    • stephenw10S
                                      stephenw10 Netgate Administrator
                                      last edited by

                                      About the only thing I can think you may have done is used some cut down version of FreeBSD. Alternatively I have installed some extra stuff in my FreeBSD install.  :-
                                      I don't remember doing that but some package or other may have pulled in some dependencies. It's a few years since I installed it.

                                      Steve

                                      1 Reply Last reply Reply Quote 0
                                      • M
                                        matumbo
                                        last edited by

                                        I installed with the dvd image, which I think is the full version and I installed all standard packets or something like that. But it seems like the problem is not with my virtual FreeBSD, it's with my pfsense missing libraries which I suppose is normal. From what I understand, the only possible solution is for me to somehow statically link the required libraries into the program so that they are not needed on pfsense when I execute the program. But what I really don't understand is why I can run your program with no problem but if I compile it by myself it won't work. Especially when you didn't use any option with gcc to compile it.

                                        1 Reply Last reply Reply Quote 0
                                        • stephenw10S
                                          stephenw10 Netgate Administrator
                                          last edited by

                                          @matumbo:

                                          what I really don't understand is why I can run your program with no problem but if I compile it by myself it won't work. Especially when you didn't use any option with gcc to compile it.

                                          It's exactly that reason makes me think it's a problem with your compile box.
                                          One way to test would be if I compile your code (unless it's top secret).

                                          Steve

                                          1 Reply Last reply Reply Quote 0
                                          • M
                                            matumbo
                                            last edited by

                                            @stephenw10:

                                            It's exactly that reason makes me think it's a problem with your compile box.
                                            One way to test would be if I compile your code (unless it's top secret).

                                            Steve

                                            You are welcome to compile it, maybe that would do the trick :P But I'm not sure the program is working correctly yet since I haven't been able to try it at all.

                                            code.c.png

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post
                                            Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.