2011-06-24 16:49:54 502 Bad Gateway - CGI app with BOA server
wag hanna (UNITED STATES)
Message: 101668
I’m running the ADI EZKIT LITE (blackfin 537) with uClinux kernel v2.6
$uname -a
Linux blackfin 2.6.34.7-ADI-2010R1 #23 Fri Jun 24 15:58:01 EDT 2011 blackfin GNU/Linux
With BOA web server running default ADI boa.conf except enabled CGI application extensions “AddType application/x-httpd-cgi cgi”
When I compile the example cgictest.c that comes with Boutell’s CGIC library (v2.05), producing the CGI app in the /home/httpd/cgi-bin/ directory.
On Firefox, it produces
---
502 Bad Gateway
The CGI was not CGI/1.1 compliant.
---
BOA daemon dumps the following
---
root:/home/httpd/cgi-bin> 192.168.100.117 - - [28/Apr/2012:04:12:59 +0000] request "GET /cgi-bin/ephonecgic HTTP/1.1" ("./ephonecgic"): Unable to execve/execl p
athname: "./ephonecgic"Exec format error
192.168.100.117 - - [28/Apr/2012:04:12:59 +0000] request "GET /cgi-bin/ephonecgic HTTP/1.1" ("./ephonecgic"): cgi_header: unable to find LFLF
---
I searched the uClinux Koop website and found a ‘closed’ bug thread #6175, that sounds very similar but it was closed with “change the shebang to /bin/sh and it'll work regardless of the shell enabled.”
Question: what shebang are you talking about?
Thank you.
QuoteReplyEditDelete
2011-06-24 17:15:22 Re: 502 Bad Gateway - CGI app with BOA server
Mike Frysinger (UNITED STATES)
Message: 101669
"Exec format error" usually means the binary is broken. make sure you're compiling with the right toolchain version (must match the version of software you're running on the board), you're executing the right file (it has to be FLAT or FDPIC), and you arent transferring it in a way that corrupted things.
people often try to transfer things using ftp/ascii mode, but that'll just break things. or they'll use bfin-uclinux-gcc to compile, but then send the ELF and not the FLAT.
forget about boa for now and try to execute it by hand from a shell:
./ephonecgic
QuoteReplyEditDelete
2011-06-24 17:52:13 Re: 502 Bad Gateway - CGI app with BOA server
wag hanna (UNITED STATES)
Message: 101670
Thanks for your response.
When I executed the CGI app from the shell the following message was produced
---
root:/home/httpd/cgi-bin> ./ephonecgic
ephonecgic: applet not found
---
the CGI app was built with the Blackfin toolchain, from the top Blackfin-uclinux-dist/ directory, and the generated uImage was then loaded (via u-boot bootp) to the EZKIT target using the CoLinux environment.
I also did the chmod 777 on the ephonecgi so it's executable. Other examples CGI apps such as cgi_demo (module cgi_generic) work okay. I've attached the project files, may be something incorrect in the Makefile.
cgictest.c
cgic.h
cgic.c
Makefile
QuoteReplyEditDelete
2011-06-24 18:02:39 Re: 502 Bad Gateway - CGI app with BOA server
Mike Frysinger (UNITED STATES)
Message: 101671
"applet not found" means about the same thing ... the file itself is not built correctly or you dont have the right libs installed.
run `file ephonecgic` on your development and see what it shows. if it says BFLT, then make sure you've got the flat format enabled in your kernel. if it says ELF, make sure it's dynamic and not static.
also if it's ELF, make sure you have the FDPIC libs in /lib/.
QuoteReplyEditDelete
2011-06-24 18:41:06 Re: 502 Bad Gateway - CGI app with BOA server
wag hanna (UNITED STATES)
Message: 101672
when i ran 'file ephonecgic' the following was produced.
---
colinux:/blackfin-linux-dist/user/ephone# file ephonecgic
ephonecgic: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.8, not stripped
---
I don't understand what the FDPIC is exactly, but when I searched for it in the blackfin-linux-dist/ directory the following was found:
---
colinux:/blackfin-linux-dist# find -name "*fdpic*"
./lib/libbfgdots/g729/src.fdpic
./lib/libbfgdots/g729/script/flat2fdpic.pl
./linux-2.6.x/arch/frv/mm/elf-fdpic.c
./linux-2.6.x/arch/blackfin/kernel/binfmt_elf_fdpic.c
./linux-2.6.x/arch/blackfin/kernel/.binfmt_elf_fdpic.o.cmd
./linux-2.6.x/arch/blackfin/kernel/binfmt_elf_fdpic.o
./linux-2.6.x/fs/binfmt_elf_fdpic.c
./linux-2.6.x/fs/.binfmt_elf_fdpic.o.cmd
./linux-2.6.x/fs/binfmt_elf_fdpic.o
./linux-2.6.x/include/config/binfmt/elf/fdpic.h
./linux-2.6.x/include/linux/elf-fdpic.h
----
Hope this gives us more information. Do I need to add an option in the kernel build (using menuconfig)?
BTW does my Makefile look okay?
Thanks
QuoteReplyEditDelete
2011-06-24 18:47:31 Re: 502 Bad Gateway - CGI app with BOA server
wag hanna (UNITED STATES)
Message: 101673
When I ran the kernel configuration (menuconfig), under 'Executable file formats-->' the options included were:
[*] Kernel support for FDPIC ELF binaries
[*] Kernel support for flat binaries
[*] Enable ZFLAT support
The 'Enable shared FLAT support' and 'Kernel support for MISC binaries' were not enabled.
QuoteReplyEditDelete
2011-06-24 20:53:15 Re: 502 Bad Gateway - CGI app with BOA server
Mike Frysinger (UNITED STATES)
Message: 101674
that `file` output shows you the problem. it didnt actually cross-compile; it's an ELF that's designed to run on Intel processors. you have to cross-compile the program to run on Blackfin systems.
QuoteReplyEditDelete
2011-06-25 00:05:13 Re: 502 Bad Gateway - CGI app with BOA server
wag hanna (UNITED STATES)
Message: 101677
I read about the cross compile options defined in config.arch and the bfin-linux- prefix, but I'm not clear on how to specify that for the source project. I copied the Makefile from another cgi_generic example, which invokes the compiler with $(CC) and $(CFLAGS). Could you please have a look at the attached Makefile and give me guidance on how to define cross-compiling?
Makefile
QuoteReplyEditDelete
2011-06-25 00:21:56 Re: 502 Bad Gateway - CGI app with BOA server
Mike Frysinger (UNITED STATES)
Message: 101678
the CC and such are set automatically only if uclinux-dist builds things for you. if you're running `make` by hand, you have to set CC to the appropriate cross-compiler yourself like bfin-uclinux-gcc.
QuoteReplyEditDelete
2011-06-26 19:06:09 Re: 502 Bad Gateway - CGI app with BOA server
wag hanna (UNITED STATES)
Message: 101686
Mike,
I was using uclinux-dis to build the project, and I had set the user/Makefile and user/KConfig with a different name for the executable, and so it wasn't building my project with the bfin-uclinux-gcc toolchain. I must've missed that instruction in Adding-User-Application-HOWTO, e.g. CONFIG_USER_ entry must be named exact match to the project directory and executable output. I corrected the CONFIG_ and USER_ names and then the 'file' command returned 'BFLT executable - version 4 ram' and it worked fine on the target.
Thanks for your help.
QuoteReplyEditDelete