Registered a URL and setup a forum as the IPCam stuff really needed its own site vs my irregular blog posts about IPCam hacking at

Author Topic: Building binary...  (Read 4737 times)

May 24, 2012, 04:45:21 am

I'm new here and i've bought a HEDENCAM v5.5 (CAMHED05IPW) which boot like this:

W90P745 Boot Loader [ Version 1.1 $Revision: 1 $ ] Rebuilt on May 11 2010
Memory Size is 0x1000000 Bytes, Flash Size is 0x400000 Bytes
Board designed by Winbond

I've read your Wiki and forum to learn how to use the serial port, download the BSP ( and try to compile xrelayd (a tiny stunnel replacement) to add a https fonctionnality to my webcam.

Unfortunately, my binaries don't work at all on my cam (i put them in the webui in /home/bin/)
Here is the result:

/home/bin> ./xrelayd
usage: [-c] [-v] [-d localip:port] [-r remoteip:port]

    -A      Server certificate file (may change to CA file in future)
    -p      private key and certificate chain PEM file name
    -c      client mode. remote is ssl, local plain
    -v      validate certificate
    -d      listen locally on this [host:]port
    -r      connect to remote machine on [host:]port
    -P      pidfile
    -f      foreground mode
    -D      syslog level (0...7)

  Options for private key and x509 certificate generation
    -K      generate private key and certificate. arg=keylen
    -U      subjectline for certificate. specify at least CN
    -Y      number of days before this cert becomes invalid

pid 35: failed 256

Strangely, the strace binary i got there :
produce the same result:

/home/bin> ./strace
usage: strace [-dffhiqrtttTvVxx] [-a column] [-e expr] ... [-o file]
              [-p pid] ... [-s strsize] [-u username] [command [arg ...]]
   or: strace -c [-e expr] ... [-O overhead] [-S sortby] [command [arg ...]]
-c -- count time, calls, and errors for each syscall and report summary
-f -- follow forks, -ff -- with output into separate files
-F -- attempt to follow vforks, -h -- print help message
-i -- print instruction pointer at time of syscall
-q -- suppress messages about attaching, detaching, etc.
-r -- print relative timestamp, -t -- absolute timestamp, -tt -- with usecs
-T -- print time spent in each syscall, -V -- print version
-v -- verbose mode: print unabbreviated argv, stat, termio, etc. args
-x -- print non-ascii strings in hex, -xx -- print all strings in hex
-a column -- alignment COLUMN for printing syscall results (default 40)
-e expr -- a qualifying expression: option=[!]all or
   options: trace, abbrev, verbose, raw, signal, read, or write
-o file -- send trace output to FILE instead of stderr
-O overhead -- set overhead for tracing syscalls to OVERHEAD usecs
-p pid -- trace process with process id PID, may be repeated
-s strsize -- limit length of print strings to STRSIZE chars (default 32)
-S sortby -- sort syscall counts by: time, calls, name, nothing (default
-u username -- run command as username handling setuid and/or setgid
pid 37: failed 256

- Am i using the right BSP ? (W90P745 != W90N745)
- Is there specific option to add to gcc ? (like -fpic)

I try to use theres sources: (patched xyssl library to work with xrelayd)

« Last Edit: May 24, 2012, 04:47:29 am by Flo_Wer »

  • No avatar
  • *****
May 30, 2012, 05:08:31 pm
Status 256.   

The value returned is -1 on error (e.g. fork(2) failed), and the return status of the command otherwise. This latter return status is in the format specified in wait(2). Thus, the exit code of the command will be WEXITSTATUS(status). In case /bin/sh could not be executed, the exit status will be that of a command that does exit(127).


Its trying to call the shell again to reload (as it seems yours dies on the last part), and failing.  Have you declared a valid shell?

May 31, 2012, 02:52:38 pm
Thank you for the reply thus i don't really understand what you mean by declare a valid shell... i just use the built-in sash shell through the serial console to execute command.

I finally found that i had to replace all fork in the xrelayd.c by vfork. (uClinux limit)
After recompiling (less than 100Ko) and generating a certificate, i have now to face another problem...

/home/bin> /home/bin/xrelayd -f -D7 -r localhost:80 -d 433 -p /bin/host.key -A /bin/host.crt
[info  ] May 28 18:07:52 xrelayd[0043] xrelayd.c:735 Loading the private key
[info  ] May 28 18:07:52 xrelayd[0043] xrelayd.c:785 Loading the server certificate
[notice] May 28 18:07:52 xrelayd[0043] xrelayd.c:820 Listening for ssl connections on server port 433

[info  ] May 28 18:07:56 xrelayd[0043] xrelayd.c:835 Got ssl connection from on server port 443
[info  ] May 28 18:07:56 xrelayd[0044] xrelayd.c:372 Attempting to connect to localhost:80
[info  ] May 28 18:07:56 xrelayd[0044] xrelayd.c:377 Connected to localhost:80
[info  ] May 28 18:07:56 xrelayd[0044] xrelayd.c:418 Initialized SSL for server mode
[info  ] May 28 18:07:56 xrelayd[0044] xrelayd.c:433 Performing ssl handshake
[info  ] May 28 18:08:00 xrelayd[0044] xrelayd.c:440 Handshake succeded
[notice] May 28 18:08:00 xrelayd[0044] xrelayd.c:443 Connected ssl client to plain server localhost:80
[debug ] May 28 18:08:00 xrelayd[0044] xrelayd.c:469 enter select. fdmax 5
[debug ] May 28 18:08:00 xrelayd[0044] xrelayd.c:479 select returned 1
[debug ] May 28 18:08:00 xrelayd[0044] xrelayd.c:485 ssl fd is set
[debug ] May 28 18:08:00 xrelayd[0044] xrelayd.c:487 trying to read from ssl fd 4
[debug ] May 28 18:08:00 xrelayd[0044] xrelayd.c:489 read: 1 bytes
[debug ] May 28 18:08:00 xrelayd[0044] xrelayd.c:491 trying to write on plain fd 3
[debug ] May 28 18:08:00 xrelayd[0044] xrelayd.c:493 write: plain complete
[debug ] May 28 18:08:00 xrelayd[0044] xrelayd.c:487 trying to read from ssl fd 4
[debug ] May 28 18:08:00 xrelayd[0044] xrelayd.c:489 read: 317 bytes
[debug ] May 28 18:08:00 xrelayd[0044] xrelayd.c:491 trying to write on plain fd 3
[info  ] May 28 18:08:00 xrelayd[0044] xrelayd.c:253 plain connection was reset by peer during write operation
[info  ] May 28 18:08:00 xrelayd[0044] xrelayd.c:528 Closed ssl connection from
[info  ] May 28 18:08:00 xrelayd[0044] xrelayd.c:531 Closed plain connection to localhost:80
[notice] May 28 18:08:00 xrelayd[0044] xrelayd.c:533 Closed connection between ssl client and plain server localhost:80

Looks like there is a problem to write on a file descriptor ?
The same code (with fork) works fine on a x86 OS while redirecting to the camera.

I'm quite stuck, this is at the far end of my knowledge and i'm not sure this soft can work on uClinux to bring https functionality...
« Last Edit: May 31, 2012, 03:01:45 pm by Flo_Wer »

  • No avatar
  • *****
May 31, 2012, 10:30:29 pm
Is the file system writeable?

Where is it trying to write to?


If its trying to setup a socket in /var/xxx   make sure you mount /var as a writable FS


mount -t ramfs none /var

You'll need to look at the code for your software to see what its writing to though, to check that.

You can take a look at the logs here -
to see what mine defaults to setting mounts as.

Good luck.