Difference between revisions of "Autoloader for extra exeDSP plugins (B65x)"


From SamyGO
Jump to: navigation, search
(Steps)
(Useful links)
Line 193: Line 193:
  
  
--[[User:Geo650|Geo650]] 12:35, 9 May 2010 (UTC)
+
--[[User:Geo650|Geo650]] 15:36, 9 May 2010 (UTC)

Revision as of 15:36, 9 May 2010

Introduction

Plugin? What is this for ?

Extra exeDSP plugin is a dynamically-loaded library file (*.so) that may be executed using "Game" menu of the Content Library. Typically, such plugin (that may be called a "Game") is brought to you together with "clmeta.dat" XML file that points to the main library file to be started ("loader.so", for example). There are many plugins already made by SamyGO community. (Almost) all of them require to be run from Content Library "Game" submenu.

The problem is...

You cannot execute such plugins using starting script. You even cannot run them using telnet shell. So, they cannot be started automatically. Even if you make an application that run any plugin, then exeDSP functions (symbols) would be unknown. These functions are used by plugins for accessing of hardware layer easily.

Why to autostart ?

Some plugins are intended to be run in the background. Unfortunately, you have to enter Content Library to execute them. This is confusing in some situations. Autostarting is useful for staying resident applications that are waiting for a specified signal to execute a piece of its code. Starting plugins automatically will save your remote control, your fingers and... your nerves.

Then how to autostart my plugin ? What should I do ?

You have to load the plugins using exeDSP in a way like Content Library does. Content Library is started by exeDSP application. Then it loads the plugin and calls its Game_Main() function. The problem is that exeDSP is a closed-source binary and there is hard to modify its functions. So I decided to load our plugins (libraries) using another open-source library which is loaded by exeDSP. One of such libraries is libusb (libusb.so), typically loaded from /mtd_drv/Comp_LIB directory.

We have to force exeDSP to load our custom libusb library instead of original one. The directory with the original library file is read-only one, so we will modify LD_LIBRARY_PATH variable. The drawing below may be helpful to understand this method:

Libusb fig1.gif


Before you start...


WARNING!

Read the whole article first. Don't start if you doesn't understand anything. All problems can be solved on forum before bricking your TV. Please be careful. I am not responsible for your mistakes. You are doing it on your own risk.


What do I need?

  • Samsung LExxB65xT2W model with 2005.0 firmware (I don't know if it works on other models)
  • telnet access to your TV (see: How to enable Telnet on samsung TV's), or firmware update will enable telnet for you
  • very basic knowledge of Linux operating system

Optional things:

  • ex-link cable + terminal with RS232C port (for recovery purposes)
  • compilation toolchain environment (see: Setting up a cross-compilation toolchain)
  • FTP server running on your TV (or you can copy binary files using pendrive)


Steps

1. Download geoPATCHER for your firmware (only T-CHL7DEUC 2005.0 is supported at the moment) firmware patcher archive for Linux and Windows

NOTE: You can use this patcher as telnet enabler, too.

CAUTION! This firmware patcher is incompatible with today's SamyGO rules. It uses /mtd_rwarea/SamyGO directory only with autorun.sh and exeDSP.sh scripts inside. It doesn't run /mtd_rwarea/SamyGO.sh script! For more information go to this thread. But this is not a big problem. You can make it compatible with today's SamyGO rules, though: see step 14 of this documentation.

2. Instructions how to make patched firmware are included in the archive. Read and apply enclosed instructions (i.e. for Windows: extract firmware patcher to any directory, put the T-CHL7DEUC.exe firmware archive beside scripts and run geo1patch.bat script to patch the firmware, then copy T-CHL7DEUC folder to a pendrive and flash your TV).

NOTE: Remember to save TV channels, make backups and disable special scripts on your TV before flashing!

3. After flashing, your TV should start as usual. Continue TV's installation process.

4. Optional: you can re-enable DEBUG MODE for RS232C service port in the service menu.

5. Login to your TV using telnet (make sure you know your TV's IP address before).

6. Create directory tree:

mkdir /mtd_rwarea/SamyGO
mkdir /mtd_rwarea/SamyGO/exe
mkdir /mtd_rwarea/SamyGO/exe/lib
mkdir /mtd_rwarea/SamyGO/exe/conf

NOTE: Why everything is located inside "exe" subdirectory? Because maybe some day, modified exeDSP will be started from that directory. I am going to put modified exeDSP in there. In the other hand, you can create individual subdirectories for every plugin in this place.

7. Create /mtd_rwarea/SamyGO/exeDSP.sh file containing:

#!/bin/sh

export LD_LIBRARY_PATH="$SamyGOpath/exe/lib:$LD_LIBRARY_PATH"
cd /mtd_exe
./exeDSP

where $SamyGOpath is exported from /mtd_exe/rc.local calling script and equals to "/mtd_rwarea/SamyGO".

HINT: To create new text file in linux, you can use vi comand like this:

vi /mtd_rwarea/SamyGO/exeDSP.sh

then you press [i] key, enter your text, then press the following keys: [ESC], [:], [w], [q], [ENTER] and your file will be saved.

8. Set executable flag to exeDSP.sh script:

chmod a+x /mtd_rwarea/SamyGO/exeDSP.sh

9. Download modified LIBUSB.

10. Unzip libusb.so and copy to /mtd_rwarea/exe/lib directory.

(for advanced readers: here is the source code)

11. Create new configuration file in /mtd_rwarea/exe/conf directory:

vi /mtd_rwarea/exe/conf/libusb.conf

This file may contain full paths to your plugins, for example:

# list of modules started automatically with exeDSP and libusb:
/mtd_rwarea/SamyGO/exe/remote/loader.so
/mtd_rwarea/SamyGO/exe/geopvr/loader.so
/mtd_rwarea/SamyGO/exe/arfix2/arfix2.so

# NOTE: use full paths to '*.so' file of plugin
# NOTE: lines starting with # and ; characters are ignored
# NOTE: empty lines are ignored, too 

Plugins are loaded by libusb one-by-one and Game_Main() functions are executed immediately.

NOTE: It would be good thing to create libusb.test file instead of libusb.conf to test if your plugins work well. Then this test configuration file will be renamed to libusb.back at next boot.

12. Copy your plugins (*.so files) to folders specified in the configuration file.

13. Reboot your TV to test your plugins. Of course, you may reboot it before creating configuration file to test if exeDSP is starting. Configuration file can be empty if you aren't using any plugins.

14. Next, you can create your own /mtd_rwarea/SamyGO/autorun.sh script for other things to be started automatically (FTP server for example). Remember to start telnet first, because if that script exists, then telnet is not started in rc.local (but can be in autorun.sh). The simplest autorun.sh script can look like this:

#!/bin/sh

mount -t devpts devpts /dev/pts
telnetd

If you want this to be compatible with today's SamyGO rules, please create autorun.sh script containing:

# calling old SamyGO.sh script
/mtd_rwarea/SamyGO.sh

only. Then your old /mtd_rwarea/SamyGO.sh script will be executed on start.

15. Don't forget to set executable flag to your autorun.sh script:

chmod a+x /mtd_rwarea/SamyGO/autorun.sh

16. You are done.


How to test and add a new plugin

To test a new plugin (let's name it "test.so"), create a new directory for it (for example: /mtd_rwarea/SamyGO/exe/test), copy it to that directory, then create test configuration file (/mtd_rwarea/SamyGO/exe/conf/libusb.test) with full path to that plugin (i.e. /mtd_rwarea/SamyGO/exe/test/test.so). Restart your TV to check your test plugin. If plugin works, add its full path to the main configuration file (i.e. /mtd_rwarea/SamyGO/exe/conf/libusb.conf).


How to remove a plugin

To disable and remove plugin you must edit /mtd_rwarea/SamyGO/exe/conf/libusb.conf configuration file, remove or comment its path, then restart your TV and delete plugin file(s) after that.




Emergency operations in case of bootloop

One important advice: DON'T PANIC. Take a deep breath, rest for a minute and think what could cause this situation.

In case of a bootloop, you can connect your TV via ex-link cable to the RS232C terminal (settings: 115200bps, 8 data bits, 1 stop bit, parity:NONE, handshaking:NONE), then send such commands to turn your TV back to life:

debug
{CTRL+C - i.e. code 0x03}
/mtd_boot/MicomCtrl 23 {ENTER}
/etc/telnetd_start.sh {ENTER}

then enter telnet via the same connection (hit ENTER and you'll see # prompt) and delete, rename or edit your badly-written /mtd_rwarea/SamyGO/autorun.sh script. For example:

mv /mtd_rwarea/SamyGO/autorun.sh /mtd_rwarea/SamyGO/autorun.bad

If your plugins caused TV to loop at boot, then delete them from your configuration file, or just delete or rename your configuration file:

mv /mtd_rwarea/SamyGO/exe/conf/libusb.conf /mtd_rwarea/SamyGO/exe/conf/libusb.bad

Or disable /mtd_rawarea/SamyGO/exeDSP.sh script causing exeDSP to load without modified libusb at all.

mv /mtd_rwarea/SamyGO/exeDSP.sh /mtd_rwarea/SamyGO/exeDSP.bad

or you can delete your bad plugins even if they exist in the configuration file (but don't do this while they are running).

Then power off and reboot your TV. Next, you will need to repair your autorun script or configuration file.

If it didn't work, you may still ask on forum for help.



Useful links

forum thread.


--Geo650 15:36, 9 May 2010 (UTC)