Page 1 of 1

libGame.so launcher restrored for A/sh4 series

Posted: Sun Jul 10, 2011 5:13 pm
by tom_van
Long time I've been envious that almost every Samsung TV can load executable modules but my LE46A956 cannot.
It looked like good idea to re-implement short part of code which Samsung blocked. I didn't know that dynamic loader
issues and combining statically and dynamically linked libraries could make such hell. Never mind...launcher is working.

NO WARRANTY, YOU ARE DOING IT AT YOUR OWN RISK !
Launcher is only for LExxA756, LExxA856, LExxA956 with firmware T-RBYDEUC-1013.1
For the moment the installation requires working command line access to your TV (telnet or ex-link)
Download http://sourceforge.net/projects/samygo/ ... p/download
Unzip archive to an USB stick.
Insert the stick to the TV

Code: Select all

# cd /dtv/usb/sdb/launcher-sh_1.1_T-RBYDEUC-1013.1
# ./install-launcher.sh
Confirm the warning and pray.
The script will patch exeDSP and copy libraries to /exe directory, then reboots the TV.

Now you can press CONTENT, select USB by RED button and select library application to run.
Don't you see any app? Look for some here: https://sourceforge.net/projects/samygo ... lications/
Make directory /SEC_GAME in root of USB stick and unzip applications there.

RemoteLANcontrol-0.1sh.zip is port of similar app from B series. Use with http://wiki.samygo.tv/index.php5/Deskto ... AN_Control

Sdltest-sh.zip is just basic test of SDL graphics based on arris69 code.

I admit it is not a big selection - take it as a proof of concept. I'm not going to port every app from B series - I've opened the way in a hope that other developer will participate.

If you want an application to start at every TV boot, edit file /mtd_rwarea/libso.autoload

Sources are in svn: oe/branches/branch-0-0-1/oe/packages/launcher-sh and in applications archives.

Re: libGame.so launcher restrored for A/sh4 series

Posted: Mon Jul 11, 2011 10:54 am
by tom_van
Some technical details for developers (or for me when I forgot...)

inj-dbgin.elfpatch
Loads library sym.so at startup and inj.so later when ethernet/UPnP is initialised.
To obtain room for patch, one Samsung's stupid "safety measure" was removed:
Debug menu normally uses stdin/out. But if you entered SCL submenu (equivalent of on-screen service menu)
(only) input was taken directly from /dev/ttyAS0. Patched version uses stdin with no exception so if exeDSP is
started from telnet session, debug can be fully handled over network.
It also repairs annoying error in Debug / SubSystem / SsMon, where no return was possible from.

sym.so
Library contains symbols for exeDSP. Initializes itself as global symbols so exeDSP looks like a "dynamic executable" in higher series.
When sym.so initialization is finished, C code can access these function/variables directly or by dlsym(RTLD_DEFAULT, "name") without dlopen().
Of course by far not all symbols of exeDSP have been discovered.
sym.so loads libc_stub.so and libpthread_stub.so as dependencies.

libc_stub.so, libpthread_stub.so
Libraries contains symbols of static libc and libpthread linked in exeDSP. Symbols are not made global to enable dynamic loading of full libc.so
and libpthread.so. Use full and stub libraries are mutually exclusive for a module. stub version are suitable for short and fast applications.
IFAIK symbols from stub libraries cannot be versioned, so if a library requires versioned symbols, you have load full .so version.
C code can access these function/variables from stub libraries in compile time linking -Lstub_stripped -lc_stub -lpthread_stub
or in runtime using dlopen("libc_stub.so", RTLD_LAZY) and dlsym().

inj.so
Backend library loader. During TV startup loads all libraries listed in /mtd_rwarea/libso.autoload
Also registers an extension of internal http server. The internal http server has no security neither means to restrict access. If your TV is not in secure LAN better do not use launcher extension. The server is used only for UPnP and accepts only NOTIFY command. It is not ideal, but a short script with nc command can control it:

Code: Select all

#!/bin/bash
 
if [ -z "$1" ]; then
        echo $0 handler http-request
        exit 1
fi
 
handler=$1
shift
len=$(echo $* | wc -c)
(
sleep 0.1
echo -e "NOTIFY /ExtHandle/$handler HTTP/1.1\r"
echo -e "Content-Length: $(( len + 1 ))\r"
echo -e "\r"
echo -e "$*\r"
sleep 0.5
) | tee /dev/tty | nc your-tv-addres 52396
http commands for inj.so:

Code: Select all

samy-http.sh inj load [n] library.so
samy-http.sh inj call [[n] function_name par1]
samy-http.sh inj unload [n | library.so]
samy-http.sh inj break
// where n is 0..9, index to hLibs array


launcher.so
Extension of content library launcher. Must be listed in /mtd_rwarea/libso.autoload to be loaded by inj.so


libpthread.so.0
Standard libpthread.so.0 fails to load from static executable. Fixed version is installed to /mtd_exe, which precedes /lib in LD_LIBRARY_PATH.

libSDL.so
Only 16-bit per pixel mode is working despite STi7109 offers 32-bit depth and other parts of exeDSP use it.

Re: libGame.so launcher restrored for A/sh4 series

Posted: Mon Jul 11, 2011 2:58 pm
by tom_van
If you develop or port some great app to A series, you need metadata file in silly hex coded unicode.
Following perl script samyAmeta.pl may help you:

Code: Select all

#!/usr/bin/perl
 
use POSIX qw/strftime/;
use File::Basename;
 
binmode STDOUT, ":utf8:crlf";
 
sub encode_str {
  my $str= shift;
  foreach my $ch (split //, $str) {
    printf "0x%04x,", ord $ch;
  }
  print "0x0000,\n";
}
 
sub encode_str4 {
  my $str= shift;
  foreach my $i (1,2,3,4) {
    encode_str($str);
  }
}
 
my $myname= fileparse($0);
if ($#ARGV < 0 || $ARGV[0] eq "-h") {
  die "$myname: libGame.so metadata converter
  $myname -d file .... decode metadata file
  $myname -s string... encode a string
  $myname -m name category description icon...make metadata file
";
}
 
my $mode = shift;
if ($mode eq "-d") {
  open(my $f, "<", shift) or die "Can't open input $!";
  while ( <$f> ) {
    if ( $_ =~ /^0x/ ) {
      foreach my $hex (split /,/) {
        print chr hex $hex;
      }
      print "\n";
    } else {
      print;
    }
  }
} elsif ($mode eq "-s") {
  encode_str(shift);
} elsif ($mode eq "-m") {
  print "[Name]\n";
  encode_str4(shift);
  print "[Category]\n";
  encode_str4(shift);
  print "[Size]\n";
  encode_str4("1 MB");
  print "[Vendor]\n";
  encode_str4("SamyGO");
  print "[Release_Date]\n";
  encode_str4(strftime('%Y/%m/%d',localtime));
  print "[Description]\n";
  encode_str4(shift);
  print "[JoyStick_Support]\n";
  print "0\n";
  print "[icon_path]\n";
  printf "%s\n", shift;
}

Re: libGame.so launcher restrored for A/sh4 series

Posted: Thu Jul 28, 2011 5:45 pm
by tom_van
Version 1.1 of SamyGO-launcher-sh:
Added libSDL_gfx to package

If you have installed version 1.0, you don't need reinstall, just manually copy libSDL_gfx.so.0 to /mtd_exe

Download from https://sourceforge.net/projects/samygo ... %20Series/

Re: libGame.so launcher restrored for A/sh4 series

Posted: Fri Sep 09, 2011 9:10 am
by tom_van
Names from /mtd_rwarea/libso.autoload are just passed to dlopen(). It searches in LD_LIBRARY_PATH. So libraries from /mtd_exe are loaded by basename,
others need full path.
If you've started any libGame.so app manually from launcher screen, you've also confirmed autoload - it is used for launcher.so start.
daliv wrote:+ are persist developers toolchains? or need to recompile own gcc+binutils (in such case want to knew -mcpu -march -mtune... parameters )?
Your mileage may vary. I use OE toolchain from svn.