From Digisaster
Jump to: navigation, search

What is C ?

Read here for more information about C.

Why C ?

The klcd.cgi and the kfip.cgi are written in C. The reason is that if we launch a shell scripts consume far, far more memory! So the kiss will crash if we use shell these scripts during playback. The CGI written in C use far less memory so they can be run under most circumstances. Here we will collect different projects about CGI scripts written in C.

Compile tools for the Stage2 FW (env, flags & etc)

First download and unpack the following compiler for ARM here

Then set the following environment variables:

export CC=arm-elf-gcc
export CFLAGS="-D__uClinux__ -mtune=arm7tdmi -O2"
export LDFLAGS=-Wl,-elf2flt="-s262144"

Most configure scripts will accept these and use them. If not, you will have to edit the Makefiles to set them to correct values or use the correct options with the configure script.

When running the configure script (if applicable) you should also use the following flags (where available of course):

--prefix=/hdd/stage2 --host=arm-elf

Finally, when you have succeeded in compiling the tool, run the following command to compress the executable:

flthdr -z <ARM executable>

I have used these settings on a Red Hat FC4 machine successfully.

Compile your own C program with the croscompiler


  1. First you need a LINUX computer / server
  2. Next go to this page and download arm-elf-tools.
  3. Run this file as root
  4. To test if it work copy/paste the following source into a file called webhello.c
#include <stdio.h>

int main()
  // Open the HTML stuff
  printf("Content-type: text/html\n" // Necessary to specify the type
      "\n" /* This blank line is critical! */

  // Do the hello thing...
  printf("Hello, World!

  // Close the HTML stuff

  return 0;
  1. Now run the following command:
arm-elf-gcc -o webhello.cgi -Wl,-elf2flt webhello.c
  1. If you place this file on the kiss into the directory "/hdd/stage2/htmlroot/cgi-bin" (and change the file permission with chmod 755 webhello.cgi) you will have your first program compiled
  2. Run your program by pointing your webbrowser to "http://<your_Kiss_player_IP>/cgi-bin/webhello.cgi".


  1. Download the little 300kb-setup.exe from [www.cygwin.com Cygwin] (Just click on the black/green C-Logo on the right side).
  2. Doubleclick the downloaded setup.exe and choose a mirror near you. When you get to the screen where you choose the modules, you should have everything at default currently.
    1. Expand the Devel node (click on + sign) and select (click on the word 'Skip') the following binaries
      1. automake 1.9
      2. binutils
      3. cvs
      4. gcc-core
      5. make
    2. If any other applications are selected in the Devel category, leave them.
    3. Once you have selected them, finish the installation. You can always run the setup program again if you want to download more applications for cygwin.
    4. If cygwin-setup is finished (you should see a new created directory - by default it's C:\cygwin):
  3. Download the Windows arm-elf cross compiler
  4. Extract the file you just downloaded into C:\WhereYouPutCygwin\ it will be saved into the C:\WhereYouPutCygwin\usr\local folder.
    1. Now you are ready to start Cygwin with a doubleclick on the C:\WhereYouPutCygwin\cygwin.bat. You will find yourself in an emulated linux environment ready to start building...
  5. Don't forget to make the new installed .exe's executable (even if you have never made it before on a win32-box!! Trust 'lordguigui' and me) with:
chmod +x /usr/local/bin/*.exe
chmod +x /usr/local/lib/gcc-lib/arm-elf/2.95.3/*.exe
chmod +x /usr/local/arm-elf/bin/*.exe
chmod +x /usr/local/arm-elf/bin/ld
chmod +x /usr/local/arm-elf/bin/elf2flt
  1. Copy/Paste the blue webhello.c - code from martinb's post in a file (I made it in the C:\cygwin\usr\local\arm-elf\bin\webhello.c) This is possible with the "normal" windows-fileexplorer!
  2. Not sure if necessary, but I changed the directory to:
cd /usr/local/arm-elf/bin
  1. Execute the compile-command:
arm-elf-gcc -o webhello.cgi -Wl,-elf2flt webhello.c
    1. You should get no errors and 2 files:
      1. webhello.cgi.elf.bflt
      2. webhello.cgi.gdb
  1. Rename the webhello.cgi.elf.bflt file to webhello.cgi (also possible in windows file explorer!)
  2. Upload the renamed file webhello.cgi to the DP-558 in the /stage2/htmlroot/cgi/ - directory
  3. chmod 777 webhello.cgi the file on the DP-558. (I make it in a telnet-session, because I can't make it with Filezilla...)
  4. Run the file from the HTTP-Browser (http://DP-558-IP-Number/cgi/webhello.cgi) and have fun!

Install a C environment on PocketPC (compiler etc.)

  1. Surf to http://www.freewareppc.com/utilities/pocketgcc.shtml
  2. Download pgcc-native.zip (Requirements: • Pocket PC • ARM Processors)
  3. Install ONLY cmd.arm.cab and pocketconsole.arm.cab (copy to PocketPC and click there)
  4. Go to http://mamaich.uni.cc/fr_pocket.htm and download pgcc.rar
  5. And then (text in quote is from the Yahoo link above, you have done 1-3 so continue from 4):

Help file by jonglee1977

machine: toshiba e310 with 32mb rom and 32mb ram

os: pocketpc 2002

Installing PGCC

  1. download cmd and pocketconsole from symbolictools website
  2. Get pgcc.rar from mamaich's website
  3. install cmd to default directory
  4. install pocketconsole to default directory
  5. soft-reboot your pocketpc
  6. uncompress pgcc.rar in your pc
  7. copy pgcc to pocketpc root directory (memory) or to storage card (This takes long)
  8. Copy libc.dll and sdlgcc.dll to \windows directory in pocketpc
  9. Makes sure everything copied over ok.

Common Problems I've faced

  1. If you don't have enough memory then pocketpc will hang when compiling So install into storage card.
  2. installed libcfix and libcfix1 and spec and this broke gcc thus I don't use any of the updates.
  3. Got the wrong version of cmd or pocketconsole. It has to be for arm procesor not mips or others. xscale is arm type processor.
  4. I mistook a long compile time (5 minutes) as program hang because I am used to fast compile time on regular PCs

Compiling your first pocketpc program using pgcc.

If installed in root directory (memory), just run the included bat file in the sample directory:

\pgcc\bin\gcc \pgcc\samp\hello\hello.cpp -target=con -o \pgcc\samp\hello\hello.exe -Wl,-s

If installed in storage card

  1. make new directory in root called pgcc
  2. copy samp folder into directory pgcc
  3. open a bat file of the sample you want to compile and edit. Example of \pgcc\samp\iostream\cout.bat
rem start code
cd storage card
cd pgcc
cd bin
gcc \pgcc\samp\iostream\cout.cpp -target=con -o \pgcc\samp\iostream\cout.exe -Wl,-s
rem end code(your storage card maybe called different)

Optional but very useful programs

  • Tillanosoft pocketnotepad to write code
  • tillanosoft tGetFile.dll to access root directory

With this you can test c code on the run with your PocketPC (I know, it's small, but it is cool, and I wrote almoust the whole txt2kml on it when I was out of town). You start CMD and do "cd" to right directory (e.g. pgcc) and there write your commands and/or bat files. I use CEdit as editor on PocketPC.

Scheduling over http/cgi

Scheduling over http/cgi written in C

Scheduling over http/cgi (Piuslor, not tested and working)

This is a project, started by piuslor, with a aim to bulid html code and CGI code so you schedule recordings on your own http server.


Download here, more info here.

Scheduling over http/cgi (Belgabor)

Belgabor has started a new project. With this cgi you can schedule your 558 over httpd/cgi.


And here the [http://www.mpcclub.com/modules.php?name=Downloads&d_op=viewdownloaddetails&cid=81&lid=303&title=Belgabor%20KiSS%20Scheduler download


  • Insert at the correct position
  • Add and delete from tvbrowser with correct titles
  • included schedule viewer with the possibility to add/delete/modifiy schedules
  • improved possibilities: select quality/start before/extra time via GET variables
  • text reply mode for tvbrowser
  • automatic reboot (not yet implemented)

Check this link for more info


Channel Editor (Flummer)


Based on the Channel Browser SW from Belgabor I have now written a program for the DP558, that acts as a channel editor.

It's written in C

In the KISS there is a file with all channels (EPG, tuning, name etc.) listed. The KISS seems to load this file after reboot. It is this file this program can edit.

Funtionality in the program:

  1. Edit of channels.
  2. Backup and restore functionality.
  3. Turn KISS on / off and reboot it.
  4. Add a new channel (20060928)
  5. Delete channels (20060928)
  6. Rename channel (20060928)
  7. Copy a channel (20060929)
  8. Finetune channels, frequency is displayd as numbers (20061003)
  9. Frames used in webpage (20061003)
  10. Rearranging channels one by one (20061004)
  11. Channel position displayed in overview (20061004)
  12. Display of raw channel data in hex (20061020)
  13. Add an already deleted channel to the html overview for editing (20061020)

Step to install.

  1. Get the program (and source if requested) by sending your email in a PM to me
  2. Copy the channelhtml file to /hdd/stage2/htmlroot/cgi-bin/
  3. Change access rights to the channelhtml file. (telnet to KISS and write: chmod +x /hdd/stage2/htmlroot/cgi-bin/channelhtml)
  4. Copy the ChannelIndex.html and ChannelEditor.htm to /hdd/stage2/htmlroot/

Step to edit channel

  1. Enter KISS with browser: IP-address/ChannelIndex.html
  2. Edit channel (maybe take a backup first )
  3. Reboot KISS and wait until stage2 is ready.
  4. Watch for the change...

I hope someone will find this program useful as I do. If anyone has requests or ideas, do not hesitate to write them here or implement them by yourself.

The SW is currently tested on stage2f and with Firefox and IE.

Known issues

  1. Did not work with IE7. (20060928 Fixed)
  2. Tuner frequency is not displayed as numbers. (20061003 Fixed)
  3. Swapping of channels not implemented. (20061004 Done)
  4. Error in rearranging channels from eg. position 0 to 10 (20061029 - Being tested)
  5. Characters missing when editing long channel names (20061029 - Being tested)

Dumprom (Abbe & Erik)

Dumprom is a old program written by By Abbe & Erik

It will dump the nvram and we want to document all the results (so we can read the timezone written in the kiss etc etc)

If you have nothing better to do you can join We want to know ALL possible output!

You can download this little program (if you have stage2 firmware installed)

  • Go to "webupdate"
  • Click on "update.cgi"
  • Type "romd" and press [enter]

This will start downloading dumprom

dumprom is after the download in /hdd/stage2/bin/

Now you can use the command "dumprom" from telnet and you can start to give feedback on the output:

  • Run "dumprom"
  • Change ONE thing, eg. in the 558 menu
  • Run "dumprom" again

Compare the first and second dump, and find the difference

Where it differ, there is your place in nvram (where the "item" you changed is saved). You can also in this way see what possible values the "item" can have (eg. if you change to max->check dump, change to min ->check dump).

I have devided it like this:


.... X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 Xa Xb Xc Xd Xe Xf 



You can download Dumprom here

NVRAM (MarcoG)

Read here about NVRAM.

If you like, you can try marcogs application that shows all, today known, settings.

Do it like this:

Telnet to your player

cd \hdd\stage2\bin

wget http://people.cs.uct.ac.za/~gllmar013/mpc/nvram/nvram

wget http://people.cs.uct.ac.za/~gllmar013/mpc/nvram/nvram.conf


       nvram -list | -get <item1> [<item2> ... <itemN>] | -set <item1> <value1> [<item2> <value2> ... <itemN> <valueN>]
  • nvram -help = Gives info (for names for items)
  • nvram -list = Shows your settings (for examples on settings/values or look in nvram.conf)
  • nvram -get XXXX = Show setting/value for XXXX, e.g "nvram -get RSTZ" shows setting for Time Zone
  • nvram -set XXXX YYYY = Changes setting for XXXX to YYYY, e.g. "nvram -set RSML English"

More information you can find here

/hdd/stage2/bin # nvram -help
        nvram -list | -get <item1> [<item2> ... <itemN>] | -set <item1> <value1>
 [<item2> <value2> ... <itemN> <valueN>]

Where each item is one of the following:

      RSML (Regional Settings Menu Language)
      RSTZ (Regional Settings Time Zone)
      RSCO (Regional Settings Country)
      RDAL (Regional Settings DVD Audio Language)
      RDML (Regional Settings DVD Menu Language)
      RDSL (Regional Settings DVD Subtitle Language)
      VOCO (Video Output Connection)
      VOCM (Video Output Component Mode)
      VODF (Video Output Display Format)
      VOTS (Video Output TV system)
      AOMO (Audio Output Mode)
      TVCO (TV Tuner TV colour System)
      EDHC (Ethernet TCP/IP DHCP Client)
      ENTP (Ethernet TCP/IP NTP Client)
      EFTP (Ethernet TCP/IP FTP server)
      EPCL (Ethernet TCP/IP PClink server)
      EWEB (Ethernet TCP/IP WEB schedule)
      EIPA (Ethernet IP address)
      ESUB (Ethernet Subnet)
      EGTW (Ethernet Gateway)
      EDNS (Ethernet DNS server Address)
      PCIP (PCLink Address)
      MSFB (Misc Settings Front Panel Brightness)
      REQU (Recording Quality)
      TVIM (TV Input Mode)
       VOL (Volume Level)
      CHNL (Current Channel)
       PCL (Parental Control Level)
       PCP (Parental Control Password)
        FW (Firmware Version)
        BL (Bootloader Version)
      HMRC (Hidden Menu Region Code)
      ARPT (Audio Repeat)
       ARP (Audio Random Play)
      VRPT (Video Repeat)
       VRP (Video Random Play)
      PRPT (Picture Repeat)
       PRP (Picture Random Play)
      PSSF (Picture Slide Show Function)
/hdd/stage2/bin # nvram -list
Regional Settings Menu Language........... =       00 = English
Regional Settings Time Zone............... =       18 = CEST(GMT+2)
Regional Settings Country................. =       93 = Netherlands
Regional Settings DVD Audio Language...... =       00 = (Original)
Regional Settings DVD Menu Language....... =       00 = (Original)
Regional Settings DVD Subtitle Language... =       00 = (Original)
Video Output Connection................... =       01 = RGB SCART
Video Output Component Mode............... =       00 = Interlaced
Video Output Display Format............... =       02 = 16:9 Widescreen
Video Output TV system.................... =       00 = PAL
Audio Output Mode......................... =       01 = Digital
TV Tuner TV colour System................. =       00 = PAL B/G
Ethernet TCP/IP DHCP Client............... =       00 = Enabled
Ethernet TCP/IP NTP Client................ =        1 = Enabled
Ethernet TCP/IP FTP server................ =        0 = Disabled
Ethernet TCP/IP PClink server............. =        0 = Disabled
Ethernet TCP/IP WEB schedule.............. =        1 = Enabled
Ethernet IP address....................... = 0200a8c0 =
Ethernet Subnet........................... = 00ffffff =
Ethernet Gateway.......................... = 0100a8c0 =
Ethernet DNS server Address............... = 0100a8c0 =
PCLink Address............................ = c0a80114 =
Misc Settings Front Panel Brightness...... =       00 = Bright
Recording Quality......................... =       02 = Standard Quality (4Mbit)
TV Input Mode............................. =       05 = TV
Volume Level.............................. =       32 = 50
Current Channel........................... =       07 = 7
Parental Control Level.................... =       00 = Off
Parental Control Password................. =     0000 = 0000
Firmware Version.......................... =       d9 = 217
Bootloader Version........................ =       84 = 132
Hidden Menu Region Code................... =       02 = 2
Audio Repeat.............................. =       02 = Folder
Audio Random Play......................... =       00 = Off
Video Repeat.............................. =       02 = Folder
Video Random Play......................... =       00 = Off
Picture Repeat............................ =       02 = Folder
Picture Random Play....................... =       00 = Off
Picture Slide Show Function............... =       00 = 5 sec

00:    ff          01             00 00       ff ff
01: ff ff ff ff    0f 1e 00          ff    ff ff ff
02: ff ff ff ff ff ff ff ff    ff ff ff ff ff ff
04:    ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
05:    ff ff ff       00 00    ff ff ff 00 ff ff ff
06: ff ff ff    00 ff ff ff    ff ff ff 01 ff ff ff
07: ff ff ff ff ff ff ff ff    ff ff ff    ff ff ff
08: ff ff ff ff ff ff ff ff ff ff ff ff    00 00 ff
09:    ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
0a: 02 ff ff    00 ff ff ff ff ff ff ff ff ff ff ff
0b: ff ff ff ff    ff ff ff    ff ff ff    ff ff ff
0c:    ff ff ff 01 ff ff ff ff ff ff ff ff ff ff ff
0d: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
0e: ff ff ff ff ff ff ff ff ff ff ff ff 02 ff ff ff
0f:       ff ff 00    ff ff ff ff ff ff ff ff ff ff



You can download NVRAM here

Text2kml (Raffe)

Here you can find code and info about text2kml

Log (Flummer)

Log.cgi is a program written in C an can be used as a deamon.

The purpose of this little program is to generate a log file (/hdd/log.txt)of Free Memory, Disk Usage and Processes.

The default setting is to generate this log.txt at 22:00 and 4:00 and warns when memory will be <3MB

       log.cgi -options 

    -t, --time       GMT Hour of day to write the log. KISS offset is discarded
                     e.g. 22 and/or 4. => *-t22 -t04* (04 is default)
    -h, --help       Print this information.
    -m, --memory     Lower limit of when reset warning should be activated.
                     Enter in KB e.g. -m3000 for 3MB limit (3MB is default)
    -c, --crond      One entry will be placed in log and the program will stop
                     Useful when using together with crond or for testing.:-)
    -v, --verbose    Print verbose messages.

You can start the log at startup by add these lines in the initstage2f

WAIT /hdd/stage2/htmlroot/cgi-bin/log.cgi
WAIT /bin/klcd LOG


With Kissmail you can check your email on your player(LCD).

Note: you cannot read your mail!

Configure kissmail.conf

# Example kissmail.conf
# conf:  Check-Intervall(in sec) format(in printf syntax)
# pop3:  user password server port ShowAllFlag
# imap4: user password server port

conf      120 MAIL-%d
#conf      120 M-%02d-%02d
#conf      120 %02d-%02d-%02d
#conf      120 %02d%02d%02d%02d
pop3      user pass server  110 1
#imap4     user pass server  143

You can start Kissmail at startup by add these 2 lines in the initstage2f

WAIT /hdd/stage2/bin/kissmail

--X3m 10:04, 2 July 2007 (CEST)