Boot IP-STB with HTTP

Note! KreaTV HTTP boot were introduced with KreaTV Firmware version 3.03.
Only parts of HTTP 1.1 specification are implemented, only simple non escaped URLs can be used and server redirect with code 301, 302 and 303 are supported.

KreaTV HTTP boot is a two step download mechanism where the first step is always an HTTP GET from HTTP server, the second step can be all protocols except from SAP, i.e. TFTP, Infocast, Local Storage or HTTP.

The HTTP server address and port is configured via DHCP (VIP19xx DHCP options), KreaTV Firmware menu or production parameters.

Downloading the meta data file in the first step is done by requesting a page from the server's root using the bootcast id, i.e. for VIP1903 the request will be http://www.example.com/motorola-vip1903.

For making the HTTP boot more dynamic and configurable on the server side, the requests to the HTTP server will add product (i.e., bootcastid), serial number, firmware version, software version and splash version as parameters to the request, i.e. http://www.example.com/motorola-vip1903?product=motorola-vip1903&serial=1931690851&fw_version=3.03&kernel_version=1.0&splash_version=1.0.

In the second step the KreaTV HTTP boot will start to download the splash and bootimage with the protocols specified in the meta data file, see "Types of URLs in Stb Config" below for protocol syntax and "Stb Config meta data file example" for a meta data file example.

For HTTP protocol in the second step it has the same limitations as the first step and the parameters is also added to the request for making this step scriptable on the server side.

StbConfig

Stb Config DTD

<!ELEMENT StbConfig (BootParams)>
<!ELEMENT BootParams (KernelUrl, KernelVersion?, SplashUrl, SplashVersion?)>
<!ELEMENT KernelUrl (#PCDATA)>
<!ELEMENT KernelVersion (#PCDATA)>
<!ELEMENT SplashUrl (#PCDATA)>
<!ELEMENT SplashVersion (#PCDATA)>

Types of URLs in Stb Config

[] = Required
<> = Optional

Infocast: infocast://[multicast group]<:port>/[object name]
TFTP    : tftp://[server ip]<:port>/[path/to/file]
Local   : local://
HTTP    : http://[server name or ip]<:port>/[path/to/file]

Stb Config meta data file example

Create the following motorola-vip1903 file in your WWW/html/ folder and change the Kernel and Splash URLs according to "Types of URLs in Stb Config".

<?xml version="1.0"?>
<!DOCTYPE StbConfig SYSTEM "stbconfig.dtd">
<StbConfig>
  <BootParams>
    <KernelUrl>http://download.motorola.com/bootimage</KernelUrl>
    <KernelVersion>1.0</KernelVersion>
    <SplashUrl>http://download.motorola.com/splashimage</SplashUrl>
    <SplashVersion>1.0</SplashVersion>
  </BootParams>
</StbConfig>

Example Apache2 configurations

Simple internal redirect using mod_rewrite

Make sure that AllowOverride All is set in the Apache configuration file and restart the server.

Create the following .htaccess file in your WWW root folder.

RewriteEngine on
RewriteRule   ^motorola-vip(.*)$ cgi-bin/stbconfig [L]

Simple external redirect using mod_rewrite

Make sure that AllowOverride All is set in the Apache configuration file and restart the server.

Create the following .htaccess file in your WWW root folder.

RewriteEngine on
RewriteRule   ^motorola-vip1900$ http://www.example1.com/cgi-bin/stbconfig [R]
RewriteRule   ^motorola-vip1903$ http://www.example2.com/cgi-bin/stbconfig [R]

Example CGI script

Create the following file, stbconfig, in you cgi-bin folder, remember to make the file executable.

#!/usr/bin/python

import os
import traceback

def generate_stbconfig(server, image, splash):
    out = """<?xml version="1.0"?>
<!DOCTYPE StbConfig SYSTEM "stbconfig.dtd">
<StbConfig>
  <BootParams>
    <KernelUrl>%s/%s</KernelUrl>
    <KernelVersion>1.0</KernelVersion>
    <SplashUrl>%s/%s</SplashUrl>
    <SplashVersion>1.0</SplashVersion>
  </BootParams>
</StbConfig>
"""
    return out % (server, image, server, splash)

def parse_qs(qs):
    d = {}
    for item in qs.split('&'):
        name, value = item.split('=')
        if name in d:
            d[name].append(value)
        else:
            d[name] = [value]
    return d

serial_db = {'1931690851' : 'kreatv-bi-special_1903.bin'}
product_db = {'motorola-vip1903' : ('kreatv-bi-default_1903.bin',
                                    'splash-1903.bmp'),
              'motorola-vip1900' : ('kreatv-bi-default_1900.bin',
                                    'splash-1900.bmp')}
output = ''
try:
    http_server = 'http://%s' % os.getenv('SERVER_ADDR')
    parameters = parse_qs(os.getenv('QUERY_STRING'))

    default_bi, splash = product_db[parameters['product'][0]]
    image = serial_db.get(parameters['serial'][0],
                          default_bi)
    output += generate_stbconfig(http_server,
                                 image,
                                 splash)
    output = 'Content-type: text/xml\n\n' + output
except Exception, e:
    output = 'Status: 500 Internal Server Error\n'
    output += 'Content-type: text/html\n\n'
    output += '<html><body>HTTP/1.1 500 Internal Server Error\n'
    output += '<br>%s</body></html>' % traceback.format_exc()

print output