Forum des Objets Communicants et Solutions pour les Libérer...
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.

Forum des Objets Communicants et Solutions pour les Libérer...


 
AccueilAccueil  GalerieGalerie  RechercherRechercher  Dernières imagesDernières images  S'enregistrerS'enregistrer  Connexion  

 

 Fonctionnement du Karotz (OS)

Aller en bas 
4 participants
AuteurMessage
itsmorefun
Bronze Nabz
Bronze Nabz



Localisation : France
Nabaztag : itsmorefun
Nbr de messages : 158
Carottes : 6473

Fonctionnement du Karotz (OS) Empty
MessageSujet: Fonctionnement du Karotz (OS)   Fonctionnement du Karotz (OS) Icon_minitimeDim 21 Aoû 2011 - 18:43

->configuration du karotz via son port mini USB a l'aide du programme Konfigurator
( https://s3.amazonaws.com/karotz/installer/Karotz_setup.dmg / https://s3.amazonaws.com/karotz/installer/Karotz_setup.exe / http://karotz.s3.amazonaws.com/installer/Karotz_setup.jar ):

Le port mini usb est en faite une interface usb vers RS232, il est possible de se connecter à ce port à la place du Konfigurator, mais je n'ai pas réussi a trouver les commandes utilisées dans les échanges entre le Konfigurator et Karotz, je n'obtient que des "{"response": "ERROR"}". Mais visiblement c'est: ping / get_networks / get_wifi_status / is_connected / get_id / set_ip / reboot

Edit:
Les commandes sont dans yaffs/scripts/config.py:
Code:
#!/usr/bin/python

import os
import sys
import shutil
import network
#import time
from encodings import hex_codec
import simplejson as json

# answears "iamkarotz" to "karotz_ping"
def ping(line):
    return {'response':'OK'}

def start_syslogd(cmd):
    open('/etc/conf/enable_syslogd','w').close()
    res = 0
    running = os.system('pidof syslogd > /dev/null')
    if running != 0:
        res = os.system("/sbin/syslogd 2>/dev/null")
    if res != 0:
        return {'response':'ERROR'}
    else:
        return {'response':'OK'}

def stop_syslogd(cmd):
    if os.path.exists('/etc/conf/enable_syslogd'):
        os.unlink('/etc/conf/enable_syslogd')
    os.system("/bin/killall syslogd 2>/dev/null")
    return {'response':'OK'}

def get_syslogd(cmd):
    logs=""
    numLine = 100
    if "lines" in cmd:
        numLine = cmd["lines"]
    if os.path.exists('/var/log/messages'):
        logCmd = os.popen("tail -n %d /var/log/messages" % (numLine))
        logs = logCmd.read()
        logCmd.close()
    return {'response':'OK', 'log': logs}

def set_pass(cmd):
    if 'pwd' not in cmd:
        return {'response':'ERROR', 'desc':'need password'}

    try:
        file = open('/etc/conf/voos.conf', 'w')
        file.write('[voos]\n')
        file.write('id=')
        file.write(__get_id())
        file.write('\npwd=')
        file.write(cmd['pwd'])
        file.write('\n')
        file.close()
    except:
        return {'response':'ERROR', 'desc':'cannot write config'}

    return {'response':'OK'}

def reboot(cmd):
    os.system("(sleep 3 ; /sbin/reboot) &")
    return {'response':'OK'}

def get_id(cmd):
    return {'response':'OK', 'id': __get_id()}

def get_sys_version(cmd):
    file = "/etc/conf/sys_version"
    if not os.path.exists(file):
        return {'response':'ERROR', 'desc':'cannot find file'}
    fs_version_file = open(file)
    fs_version = fs_version_file.read().strip()
    fs_version_file.close()
    return {'response':'OK', 'version': fs_version}

def get_rootfs_version(cmd):
    file = "/etc/conf/rootfs_version"
    if not os.path.exists(file):
        return {'response':'ERROR', 'desc':'cannot find file'}
    fs_version_file = open(file)
    fs_version = fs_version_file.read().strip()
    fs_version_file.close()
    return {'response':'OK', 'version': fs_version}

def __get_mac(interface="wlan0"):
    if interface != "eth0":
        interface = "wlan0"
    macCmd = os.popen("ifconfig | egrep '^" + interface + "'")
    macAddress = macCmd.readline().strip().split()[-1]
    macCmd.close()
    return macAddress;

def get_mac(cmd):
    interface="wlan0"
    if 'interface' in cmd:
        interface = cmd['interface']
    try:
        return {'response':'OK', 'mac': __get_mac(interface)}
    except:
        return {'response':'ERROR'}

def get_networks(cmd):
    return {'response':'OK', 'networks': network.get_networks()}

def set_wifi(cmd, save=True):
    if 'encryption' not in cmd:
        return {'response':'ERROR', 'desc':'need encryption'}
    if 'ssid' not in cmd:
        return {'response':'ERROR', 'desc':'need ssid'}
       
    result = -1
    if cmd['encryption'] == 'open':
        result = network.connect_open(cmd['ssid'])
    elif cmd['encryption'] == 'wep':
        if 'key' not in cmd:
            return {'response':'ERROR', 'desc':'need key'}
        result = network.connect_wep(cmd['ssid'], cmd['key'])
    elif cmd['encryption'] == 'wpa' or cmd['encryption'] == 'wpa2':
        if 'settings' not in cmd:
            return {'response':'ERROR', 'desc':'need settings'}
        result = network.set_wpa_supplicant(cmd["settings"])
    if result == 0:
        if save:
            wifiFile = open("/etc/conf/wifi.conf", "w")
            wifiFile.write(cmd["__orig__"])
            wifiFile.close()
        return {'response':'OK'}
    else:
        return {'response':'ERROR'}
       
def load_wifi():
    wifiFile = open("/etc/conf/wifi.conf", "r")
    set_wifi(json.loads(wifiFile.read()), False);
    wifiFile.close()
       
def get_ip(cmd):
    interface = "wlan0"
    if 'interface' in cmd and cmd['interface']=="eth0":
        interface = "eth0"
    return {'response':'OK', 'ip' : network.get_ip(interface)};     
       
def set_ip(cmd, save=True):
    interface = "wlan0"
    if 'interface' in cmd and cmd['interface']=="eth0":
        interface = "eth0"
    if 'dhcp' in cmd and cmd['dhcp'] == True:
        network.set_dynamic_ip(interface)

    else:
        if 'ip' not in cmd:
            return {'response':'ERROR', 'desc':'need ip'}
        if 'netmask' not in cmd:
            return {'response':'ERROR', 'desc':'need netmask'}
        if 'gateway' not in cmd:
            return {'response':'ERROR', 'desc':'need gateway'}
        if 'nameserver' not in cmd:
            return {'response':'ERROR', 'desc':'need nameserver'}
       
        network.set_static_ip(cmd['ip'], cmd['netmask'], cmd['gateway'], cmd['nameserver'],interface)

    if save :
        ipFile = open("/etc/conf/ip_%s.conf" % (interface), "w")
        ipFile.write(cmd["__orig__"])
        ipFile.close()
    return {'response':'OK'}

def load_ip(interface):
    if interface != "eth0":
        interface = "wlan0"
    ipFile = open("/etc/conf/ip_%s.conf" % (interface), "r")
    set_ip(json.loads(ipFile.read()), False);
    ipFile.close()

def get_wifi_status(cmd):
    return {'response':'OK', 'status': network.get_wifi_status()}
   
def is_connected(cmd):
    if network.is_connected() == 0:
        return {'response':'OK'}
    else:
        return {'response':'ERROR'}

def __get_id():
    global uniqueId
    if uniqueId == None:
        macCmd = os.popen("echo "+ __get_mac() +" 'AC353EFA-2B04-45BA-9BDA-FEEFA43BB640' | md5sum | cut -d' ' -f1")
        uniqueId = macCmd.readline().strip()
        macCmd.close()
    return uniqueId

def set_country(cmd):
    if 'code' not in cmd:
        return {'response':'ERROR', 'desc':'need code'}
    result = network.set_wifi_country(cmd["code"])
    if result == 0:
        return {'response':'OK'}
    else:
        return {'response':'ERROR'}
    return

def get_iwlist(cmd):
    result = network.get_iwlist()
    return {'response':'OK', 'data': result}

def get_version(cmd):
    return {'response':'OK', 'version': 1.0}
   
uniqueId=None

cmdTab = {
    'ping':ping,
    'start_syslogd':start_syslogd,
    'stop_syslogd':stop_syslogd,
    'get_syslogd':get_syslogd,
    'set_pass':set_pass,
    'reboot':reboot,
    'get_id':get_id,
    'get_sys_version':get_sys_version,
    'get_rootfs_version':get_rootfs_version,
    'get_mac':get_mac,
    'get_networks':get_networks,
    'set_wifi':set_wifi,
    'set_ip':set_ip,
    'get_ip':get_ip,
    'is_connected':is_connected,
    'set_country':set_country,
    'get_iwlist':get_iwlist,
    'get_version':get_version,
    'get_wifi_status':get_wifi_status
}

def onReceivedLine(line):
    try:
        if len(line) > 0:
            cmdJson = json.loads(line)
            cmdJson["__orig__"]=line
            cmd = cmdJson["cmd"]
            if cmd in cmdTab:
                resultPython = cmdTab[cmd](cmdJson)
                resultJson = json.dumps(resultPython, sort_keys=True, indent=4)
                lines = resultJson.count('\n')
                serialFileW.write(str(lines+1)+'\n')
                serialFileW.write(resultJson+'\n')
            else:
                serialFileW.write('1\n')
                serialFileW.write(json.dumps({'response':'ERROR', 'desc':"command '%s' doesn't exists" % (cmd) })+'\n')
            return True;
        else:
            return False;
    except Exception, e:
        serialFileW.write('1\n')
        serialFileW.write(json.dumps({'response':'ERROR'})+'\n')
        raise e

def main():
    global serialFileW
    global serialFileR
    ttyDevice = "/dev/ttyGS0";
   

   
    cmd_line = raw_input().strip()
   
    if sys.argv.count('--cmd') > 0:
        serialFileR=sys.stdin
        serialFileW=sys.stdout
       
        onReceivedLine(cmd_line)
        sys.exit(0)
       
    serialFileW = open(ttyDevice, "w")
    serialFileR = open(ttyDevice, "r")
    # read command and obey
    while onReceivedLine(cmd_line):
        cmd_line = serialFileR.readline().strip()

if __name__ == "__main__":
    main()
et iwlist.py:
Code:
#!/usr/bin/python
#
# iwlistparse.py
# Hugo Chargois - 17 jan. 2010 - v.0.1
# https://bbs.archlinux.org/viewtopic.php?pid=761899
# Parses the output of iwlist scan into a table

import sys

def get_name(cell):
    return matching_line(cell,"ESSID:")[1:-1]

def get_quality(cell):
    quality = matching_line(cell,"Quality=").split()[0].split('/')
    return int(round(float(quality[0]) / float(quality[1]) * 100))

def get_channel(cell):
    return int(matching_line(cell,"Channel:"))

def get_encryption(cell):
    enc=""
    if matching_line(cell,"Encryption key:") == "off":
        enc="Open"
    else:
        for line in cell:
            matching = match(line,"IE:")
            if matching!=None:
                if detect(matching, "WPA Version"):
                    enc="WPA"
                if detect(matching, "IEEE 802.11i/WPA2 Version"):
                    enc="WPA2"
        if enc=="":
            enc="WEP"
    return enc

def get_encryption_detail(cell):
    enc=""
    for line in cell:
        matching = match(line,"Group Cipher : ")
        if matching!=None:
            enc=matching
        matching = match(line,"Authentication Suites (1) : ")
        if matching!=None:
            if matching == "802.1x":
                enc=enc+"/"+"EAP"
            else:
                enc=enc+"/"+matching
    return enc

def get_address(cell):
    return matching_line(cell,"Address: ")

# Here's a dictionary of rules that will be applied to the description of each
# cell. The key will be the name of the column in the table. The value is a
# function defined above.

rules={"Name":get_name,
      "Quality":get_quality,
      "Channel":get_channel,
      "Encryption":get_encryption,
      "Address":get_address,
      "Detail":get_encryption_detail,
      }

# Here you can choose the way of sorting the table. sortby should be a key of
# the dictionary rules.

def sort_cells(cells):
    sortby = "Quality"
    reverse = True
    cells.sort(None, lambda el:el[sortby], reverse)

# You can choose which columns to display here, and most importantly in what order. Of
# course, they must exist as keys in the dict rules.

columns=["Name","Address","Quality","Channel","Encryption", "Detail"]

# Below here goes the boring stuff. You shouldn't have to edit anything below
# this point

def matching_line(lines, keyword):
    """Returns the first matching line in a list of lines. See match()"""
    for line in lines:
        matching=match(line,keyword)
        if matching!=None:
            return matching
    return None

def match(line,keyword):
    """If the first part of line (modulo blanks) matches keyword,
    returns the end of that line. Otherwise returns None"""
    line=line.lstrip()
    length=len(keyword)
    if line[:length] == keyword:
        return line[length:]
    else:
        return None

def detect(line, keyword):
    line=line.lstrip()
    length=len(keyword)
    if line[:length] == keyword:
        return 1
    else:
        return 0


def parse_cell(cell):
    """Applies the rules to the bunch of text describing a cell and returns the
    corresponding dictionary"""
    parsed_cell={}
    for key in rules:
        rule=rules[key]
        parsed_cell.update({key:rule(cell)})
    return parsed_cell

def print_table(table):
    # widths=map(max,map(lambda l:map(len,l),zip(*table))) #functional magic

    justified_table = []
    for line in table:
        justified_line=[]
        for i,el in enumerate(line):
            justified_line.append(str(el).ljust(30))
            # justified_line.append(el.ljust(widths[i]+2))
        justified_table.append(justified_line)
   
    for line in justified_table:
        for el in line:
            print el,
        print

def get_networks(list):
    cells=[[]]
    parsed_cells=[]

    for line in list:
        cell_line = match(line,"Cell ")
        if cell_line != None:
            cells.append([])
            line = cell_line[-27:]
        cells[-1].append(line.rstrip())

    cells=cells[1:]

    for cell in cells:
        parsed_cells.append(parse_cell(cell))

    sort_cells(parsed_cells)

    return parsed_cells
et network.py:
Code:
#!/usr/bin/python

import os
import iwlist
import time
import re

# Network interfaces

def lo_up():
    return os.system("ifconfig lo up")

def wlan0_up():
    return os.system("ifconfig wlan0 up")

def wlan0_down():
    return  os.system("ifconfig wlan0 down")

def eth0_up():
    return os.system("ifconfig eth0 up")

def eth0_down():
    return  os.system("ifconfig eth0 down")


def reset_networks():
    os.system("killall -9 wpa_supplicant")
    # os.system("killall -9 udhcpc")
    os.system("echo nameserver 8.8.8.8 > /etc/resolv.conf")

def get_networks():
    wlan0_up()
    list = os.popen("iwlist wlan0 scan")
    tab = list.readlines()
    list.close()
    return iwlist.get_networks(tab)

def get_iwlist():
    wlan0_up()
    command = os.popen("iwlist wlan0 scan")
    result = command.read()
    command.close()
    return result

def set_wifi_country(alpha2):
    if not re.match("[A-Z]{2}", alpha2):
        return 1
    f = open("/etc/conf/wifi_country.conf", "w")
    f.write(alpha2)
    f.close()
    return 0

def connect_open(ssid):
    wlan0_down()
    wlan0_up()
    return os.spawnl(os.P_WAIT, '/sbin/iwconfig', '/sbin/iwconfig', 'wlan0', 'essid', ssid, 'channel', 'auto', 'key', 'off')

def connect_wep(ssid, key):
    wlan0_down()
    wlan0_up()
    return os.spawnl(os.P_WAIT, '/sbin/iwconfig', '/sbin/iwconfig', 'wlan0', 'essid', ssid, 'key', key)

def set_wpa_supplicant(dict):
    reset_networks()
    wlan0_down()
    wlan0_up()
    f = open("/etc/conf/wpa.conf", "w")
    f.write("network={\n")
   
    for k, v in dict.iteritems():
        f.write("%s=%s\n" % (k,v))   

    f.write("}\n")
    f.close()
    return os.system("wpa_supplicant -iwlan0 -Dwext -B -c /etc/conf/wpa.conf")

def get_wifi_status():
    result = "Not-Associated"
    command = os.popen("iwconfig wlan0 | grep 'Access Point'")
    try:
        result = re.search("Access Point: ([^ ]*)", command.read()).group(1)
    except:
        pass
    command.close()
    return result

def kill_dhcp(interface="wlan0"):
    if interface != "eth0":
        interface="wlan0"

    p_cmd = os.popen("ps | egrep 'udhcpc.*%s' | grep -v egrep" % (interface))
    p_str=p_cmd.read()
    p_cmd.close()
   
    if p_str != "":
        pid = p_str.strip().split()[0]
        os.system("kill -9 "+pid)


def set_dynamic_ip(interface="wlan0"):
    kill_dhcp(interface)
    if interface == "wlan0":
        os.system("udhcpc -A5 -i wlan0 -s /karotz/scripts/udhcpc_script.sh &")
    if interface == "eth0":
        if eth0_up() == 0:
            os.system("udhcpc -A5 -i eth0 -s /karotz/scripts/udhcpc_script.sh &")

def set_static_ip(ip, netmask, gateway, nameserver, interface="wlan0"):
    if ip == "" or netmask == "" or gateway == "" or nameserver == "" or interface == "":
        return 1

    kill_dhcp(interface)
   
    if interface == "wlan0":
        if os.spawnl(os.P_WAIT, '/sbin/ifconfig', '/sbin/ifconfig', 'wlan0', ip, 'netmask', netmask) !=0: return 1
    elif interface == "eth0":
        if eth0_up() == 0:
            if os.spawnl(os.P_WAIT, '/sbin/ifconfig', '/sbin/ifconfig', 'eth0', ip, 'netmask', netmask) !=0: return 1
    else:
        return 1

    if os.spawnl(os.P_WAIT, '/sbin/route', '/sbin/route', 'add', 'default', 'gw', gateway) !=0: return 1

    try:
        f = open("/etc/resolv.conf", "w")
        f.write("nameserver "+nameserver+"\n")
        f.close()
    except:
        return 1
   
    return 0

def is_connected():
    return os.system("ping -q -c1 platform.karotz.com")

def get_ip(interface="wlan0"):
    if interface != "eth0":
        interface = "wlan0"
    if interface == "wlan0":
        ifCmd = os.popen("ifconfig wlan0 | grep 'inet addr'")
    else:
        ifCmd = os.popen("ifconfig eth0 | grep 'inet addr'")

    try:
        result = re.search("inet addr:([^ ]*)", ifCmd.read()).group(1)
    except:
        result=""
   
    ifCmd.close()
    return result;

# Connection functions
def wait_wifi_status(timeout):
    start=time.time()
    while time.time() - start < timeout:
        res = get_wifi_status()
        if res != "Not-Associated": return True
        time.sleep(1)
    return False

def wait_ip(timeout):
    start=time.time()
    while time.time() - start < timeout:
        if is_connected() == 0: return True
        time.sleep(1)
    return False 

Des choses interessantes en décompressant ces differents fichiers.

Konfigurator demande via http://www.karotz.com/install?ulogin=adresse@mail.ducompte&upsw=mdpducompte&kid=0 si le compte est connu. Réponse en xml
Ensuite même chose avec http://www.karotz.com/install?ulogin=adresse@mail.ducompte&upsw=mdpducompte&kid=unIDde32caractèreshexadécimaux&force=true
On reçoit cette fois en réponse un mot de passe kpsw de 32 caractères hexadécimaux composer en 5 groupes (AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE)


le Konfigurator peut être ammener a demander de telecharger https://s3.amazonaws.com/karotz/installer/key-factory.zip via cette page: http://www.karotz.com/flashage
-> ce fichier contient une mise a jour de la partition roofs et cela se fait via une clé usb connecté sur le lapin.
-> notez la présence d'un fichier "autorun" qui s'execute donc dans un shell unix:

Code:
#!/bin/bash

ZIMAGE_MD5=b771be3ab18de244cb6556082de80b64
ZIMAGE_SIZE=2314316
ROOTFS_MD5=2b432f72035f6aa6c1e56362ff600bf7
ROOTFS_SIZE=3064162
YAFFS_MD5=160bda9334ce7d5a1b012fdfd9000cc9
YAFFS_SIZE=2178568

LED=/karotz/bin/led

function led_orange_pulse {
    killall led
    $LED -l ff6600 -p 000000 -d 700 &
}

function led_red {
    killall led
    $LED -l ff0000
}

function led_green {
    killall led
    $LED -l 00ff00
}

function error_fail {
 $LED -l ff0000
while /bin/true ; do
  $LED -l 000000
  sleep 1
  $LED -l ff0000
  sleep 1
done
exit 1
}

#parmam $1 : zimage  $2 : partition , $3 : taille de l image $4 md5
function write_partition {
   echo write /tmp/$1 dans /dev/$2 de taille $3 sz md5 $4
   cp /mnt/usbkey/$1 /tmp/$1
    ACTUAL_MD5=$(/bin/md5sum /tmp/$1 | cut -d' ' -f1)
    if [ ! "$4"    == "$ACTUAL_MD5" ] ; then
      led_red
      echo "bad $2 md5"
      error_fail
      exit 1
    fi   
    /sbin/flash_eraseall /dev/$2
    /sbin/nandwrite -pm /dev/$2 /tmp/$1
    nanddump -o -b -f  /tmp/${1}_dump  /dev/$2 # copie le contenu de la nand en ignorant les badbloc et octet de control interne de la flash
    head -c $3 /tmp/${1}_dump > /tmp/${1}_dumphead #le zimage se trouve en debut de partition
    diff /tmp/$1 /tmp/${1}_dumphead
    if [ $? -eq 0 ] ; then
        echo  write $1 ok
    else
        led_red
        echo error write $1
        error_fail
        exit 1
    fi
    rm /tmp/${1}*
}


cd $(dirname $0)

ps | grep "hotplug.sh" | grep -v grep
if [ $? -eq 0 ] ; then
    echo "hotplug found"
    exit 1
fi

led_orange_pulse

## verify md5sums
for FILE in zImage rootfs.img.gz yaffs_factory.tar.gz.encoded ; do
    [ -f "/mnt/usbkey/$FILE" ] || { echo "no file /mnt/usbkey/$FILE" ; error_fail ; exit 1 ;}
done

#ACTUAL_ZIMAGE_MD5=$(/bin/md5sum /mnt/usbkey/zImage | cut -d' ' -f1)
#ACTUAL_ROOTFS_DEV_MD5=$(/bin/md5sum /mnt/usbkey/rootfs-dev.img.gz | cut -d' ' -f1)
#ACTUAL_ROOTFS_PROD_MD5=$(/bin/md5sum /mnt/usbkey/rootfs-prod.img.gz | cut -d' ' -f1)
#ACTUAL_YAFFS_DEV_MD5=$(/bin/md5sum /mnt/usbkey/yaffs-dev.tar.gz | cut -d' ' -f1)
#ACTUAL_YAFFS_PROD_MD5=$(/bin/md5sum /mnt/usbkey/yaffs-prod.tar.gz | cut -d' ' -f1)

## okay everything is clear, let's rock

# flash zImage
echo "## zImage rescue"
write_partition zImage mtd3 $ZIMAGE_SIZE $ZIMAGE_MD5

echo "## rootfs.img.gz rescue"
write_partition rootfs.img.gz mtd4 $ROOTFS_SIZE $ROOTFS_MD5

echo "## yaffs_factory.tar.gz.encoded rescue"
write_partition yaffs_factory.tar.gz.encoded mtd5 $YAFFS_SIZE $YAFFS_MD5

echo "## zImage "
write_partition zImage mtd1 $ZIMAGE_SIZE $ZIMAGE_MD5

echo "## rootfs.img.gz "
write_partition rootfs.img.gz mtd2 $ROOTFS_SIZE $ROOTFS_MD5

# erase yaffs
echo "## erasing yaffs"
/bin/umount /usr
/sbin/flash_eraseall /dev/mtd6

# get yaffs_rescue
/bin/mount -t yaffs /dev/mtdblock6 /usr
/sbin/nanddump -nbo -f /tmp/yaffs_rescue /dev/mtd5
/sbin/yaffs_rescue_decode /tmp/yaffs_rescue - | gzip -d -c | tar x -C /usr/
rm /tmp/yaffs_rescue
sleep 1
/bin/umount /usr
led_green

echo "## All done. Remove USB and reboot."

while /bin/true ; do
  $LED -l 000000
  sleep 1
  $LED -l 00ff00
  sleep 1
done

-> Une fois le wifi paramêtré via le configuration le Karot reboot.
1) Envoie d'une trame LLC en broadcast contenant 80000000
2) DHCP
3) ping de la plateforme platform.karotz.com (46.137.117.66 - Cloud Amazon EC2 hébergé en Irlande)
4) récupération de http://update.karotz.com/rootfs_version?id=l'IDde32caractèreshexadécimauxutilisésparleKonfigurator pour mettre a jour la partition roofs (actuellement 11.03.12.00)
-> ce fichier n'est pas trouvé (404) (wget: server returned error: HTTP/1.1 404 Not Found / root: [UPDATE] could not load version.)
5) récupération de http://update.karotz.com/yaffs_version?id=l'IDde32caractèreshexadécimauxutilisésparleKonfigurator
-> Ce fichier contient:
2 codes de version: 11.04.01.01 et 11.03.11.03
1 adresse d'un fichier a telecharger avec son checksum md5: http://update.karotz.com/yaffs/yaffs-11.04.01.01.tar.gz c380e79ed13923608c65cdffd235edc3
une clé SHA1 GNUPG
6) récupération du fichier dont l'adresse a été récupérée précédemment: http://update.karotz.com/yaffs/yaffs-11.04.01.01.tar.gz pour mettre a jour la partition yaffs (46mo / 104mo décompressé, contient tout un tas de script et de fichiers, visiblement le contenu de /etc /bin /lib etc + une image de roofs):
Code:
root: [UPDATE] updating yaffs.
root: [UPDATE] sys version: 10.10.10.10.
root: [UPDATE] rootfs version: 11.03.12.00.
root: Stopping yaffs
killall: immortaldog: no process killed
killall: led: no process killed
root: [UPDATE] checking integrity.
root: Stopping yaffs
killall: immortaldog: no process killed
killall: led: no process killed
root: [UPDATE] cleanup_yaffs.
0: [UPDATE] extract.
   0: [UPDATE] pre_install.
0: [UPDATE] extracting rootfs system from the yaffs package.
0: [UPDATE] installing EABI rootfs.
0: [ROOTFS INSTALL] flash erasing /dev/mtd1
Erasing 128 Kibyte @ 2e0000 -- 95 % complete.
0: [ROOTFS INSTALL] writing new zImage
Writing data to block 0
(…)
Writing data to block 220000
0: [ROOTFS INSTALL] flash erasing /dev/mtd2
Erasing 128 Kibyte @ 4e0000 -- 97 % complete.
0: [ROOTFS INSTALL] writing new rootfs
Writing data to block 0
Writing data to block 20000
(…)
Writing data to block 300000
0: [UPDATE] extract_sys.
0: [UPDATE] post_install.
0: [UPDATE] cleanup.
0: [UPDATE] Reboot !
save exit: isCheckpointed 1
killall: led: no process killed
save exit: isCheckpointed 1
umount: can't remount /dev/mtdblock6 read-only
umount: none busy - remounted read-only
The system is going down NOW!
Sent SIGTERM to all processes
Sent SIGKILL to all processes
save exit: isCheckpointed 1
Requesting system reboot

Boot de nouveau:
1) Envoie d'une trame LLC en broadcast contenant 80000000
2) DHCP
3) ping de la plateforme platform.karotz.com (46.137.117.66 - Cloud Amazon EC2 hébergé en Irlande)
4) récupération de http://update.karotz.com/eabi/rootfs_version?id=l'IDde32caractèreshexadécimaux pour mettre a jour la partition roofs (actuellement 11.03.12.00)
-> Ce fichier contient:
1 codes de version: 11.07.07.00
1 adresse d'un fichier a telecharger avec son checksum md5: http://update.karotz.com/eabi/rootfs/rootfs-11.07.07.00.tar.gz ab45241c4970e17d825340c3eeba2d90
une clé SHA1 GNUPG
6) récupération du fichier dont l'adresse a été récupérée précédemment: http://update.karotz.com/eabi/rootfs/rootfs-11.07.07.00.tar.gz pour mettre a jour la partition roofs (5,5mo contient zImage et rootfs.img:
Code:
root: [START] checking updates.
root: [UPDATE] updating rootfs.
root: [UPDATE] rootfs version: 11.04.01.00
root: [UPDATE] downloading new rootfs.
root: Stopping yaffs
killall: immortaldog: no process killed
killall: led: no process killed
killall: led: no process killed
root: [UPDATE] Checking integrity.
root: [UPDATE] installing new rootfs.
root: [ROOTFS INSTALL] flash erasing /dev/mtd1
Erasing 128 Kibyte @ 2e0000 -- 95 % complete.
root: [ROOTFS INSTALL] writing new zImage
Writing data to block 0 at offset 0x0
Writing data to block 1 at offset 0x20000
(…)
Writing data to block 17 at offset 0x220000
root: [ROOTFS INSTALL] flash erasing /dev/mtd2
Erasing 128 Kibyte @ 4e0000 -- 97 % complete.
root: [ROOTFS INSTALL] writing new rootfs
Writing data to block 0 at offset 0x0
Writing data to block 1 at offset 0x20000
(…)
Writing data to block 24 at offset 0x300000
root: [UPDATE] Reboot !
save exit: isCheckpointed 1
umount: /dev/mtdblock6 busy - remounted read-only
umount: none busy - remounted read-only
umount: ramfs busy - remounted read-only
The system is going down NOW!
Sent SIGTERM to all processes
Sent SIGKILL to all processes
Requesting system reboot

De nouveau boot du lapin, puis:
Code:
root: [START] checking updates.
root: [UPDATE] updating rootfs.
root: [UPDATE] rootfs version: 11.07.07.00
root: [UPDATE] up to date.
root: [UPDATE] updating yaffs.
root: [UPDATE] sys version: 11.04.01.01.
root: [UPDATE] rootfs version: 11.07.07.00.
4) récupération de http://update.karotz.com/eabi/yaffs_version?id=l'IDde32caractèreshexadécimaux pour mettre a jour la partition yaffs (actuellement 11.04.01.01)
-> Ce fichier contient:
2 codes de version: 11.07.07.00 et 11.07.07.00
1 adresse d'un fichier a telecharger avec son checksum md5: http://update.karotz.com/eabi/yaffs/yaffs-11.07.07.00.tar.gz 1c0bdec68e7f3455dac35ab5216ce047
une clé SHA1 GNUPG
6) récupération du fichier dont l'adresse a été récupérée précédemment: http://update.karotz.com/eabi/yaffs/yaffs-11.07.07.00.tar.gz (33,3mo / 86,5 décompressé, contient tout un tas de script et de fichiers, visiblement le contenu de /etc /bin /lib etc + une image de rootfs):

Reboot de nouveau.

Boot normal du Karots, téléchargement des applications initialisation du SIP etc…
Note: les tts utilisés sont hébergés sur des serveurs OVH:
fr=http://188.165.228.65/tts/Suzanne
en=http://188.165.228.64/tts/Katherine
de=http://188.165.228.64/tts/Alex
es=http://188.165.228.65/tts/Sara

Code:
POST /tts/Suzanne HTTP/1.1
Host: 188.165.228.65
Accept: */*
Content-Length: 138
Content-Type: application/x-www-form-urlencoded
<s><break time="200ms" /><voice emotion="sad">Je suis d..sol.. ! Je n'ai pas compris. Essaie .. nouveau.</voice><break time="150ms" /></s>

De même, 2 serveurs sont utilisé pour la reconnaissance de voix (ASR):
server0=188.165.228.64
server1=188.165.228.65

La suite bientôt.


Dernière édition par itsmorefun le Mar 22 Nov 2011 - 23:30, édité 7 fois
Revenir en haut Aller en bas
RedoX
Platinum Nabz
Platinum Nabz
RedoX


Localisation : France
Nbr de messages : 1287
Carottes : 6471

Fonctionnement du Karotz (OS) Empty
MessageSujet: Re: Fonctionnement du Karotz (OS)   Fonctionnement du Karotz (OS) Icon_minitimeDim 21 Aoû 2011 - 18:51

Pas mal, pas mal yellownabzsmile J'comptais faire un truc du genre quand j'aurais eu fini de jouer avec le v1, mais si quelqu'un le fait à ma place c'est bien aussi ^^

Si j'peux m'permette, quand tu postes un output de debug du Karotz, mets le entre balises [code] on y verra plus clair yellownabzwink

Si tu trouves le principe des id en 5 groupes, je prend :p Le lapin n'a l'air de discuter que par ça...

Edit: y'a p'tet des pistes du côté du SDK Mindscape...
Revenir en haut Aller en bas
https://openjabnab.fr/
rtp
Lapin nain
Lapin nain



Localisation : paris
Nbr de messages : 12
Carottes : 6319

Fonctionnement du Karotz (OS) Empty
MessageSujet: Re: Fonctionnement du Karotz (OS)   Fonctionnement du Karotz (OS) Icon_minitimeJeu 29 Sep 2011 - 9:53

itsmorefun a écrit:
->configuration du karotz via son port mini USB a l'aide du programme Konfigurator
( https://s3.amazonaws.com/karotz/installer/Karotz_setup.dmg / https://s3.amazonaws.com/karotz/installer/Karotz_setup.exe / http://karotz.s3.amazonaws.com/installer/Karotz_setup.jar ):

Le port mini usb est en faite une interface usb vers RS232, il est possible de se connecter à ce port à la place du Konfigurator, mais je n'ai pas réussi a trouver les commandes utilisées dans les échanges entre le Konfigurator et Karotz, je n'obtient que des "{"response": "ERROR"}". Mais visiblement c'est: ping / get_networks / get_wifi_status / is_connected / get_id / set_ip / reboot

Finalement, j'ai achete un petit frere a mon tag tag et donc j'ai trouve ce post interessant. Je complete donc un peu sur le point des commandes. Apres avoir telecharge les tarballs indiques, dans le tarball "yaffs", y a le script config.py dans scripts qui liste les commandes:

Code:

cmdTab = {
    'ping':ping,
    'start_syslogd':start_syslogd,
    'stop_syslogd':stop_syslogd,
    'get_syslogd':get_syslogd,
    'set_pass':set_pass,
    'reboot':reboot,
    'get_id':get_id,
    'get_sys_version':get_sys_version,
    'get_rootfs_version':get_rootfs_version,
    'get_mac':get_mac,
    'get_networks':get_networks,
    'set_wifi':set_wifi,
    'set_ip':set_ip,
    'get_ip':get_ip,
    'is_connected':is_connected,
    'set_country':set_country,
    'get_iwlist':get_iwlist,
    'get_version':get_version,
    'get_wifi_status':get_wifi_status
}
Le format, c'est visiblement du json (genere avec python simplejson). Donc, par exemple, pour le ping:
Code:

{ "cmd": "ping" }

J'ai pas encore compris le format de toutes les commandes genre set_wifi mais ca doit pouvoir se deviner a partir du config.py. La reponse est de la forme: nombre de lignes de la reponse + reponse.
Je ne sais pas ce que fait exactement le Konfigurator mais avec ca, doit pas etre dur de reimplementer une partie des fonctionnalites telles que la conf reseau si besoin.
Revenir en haut Aller en bas
EricBetts
Lapin nain
Lapin nain



Localisation : Portland, Oregon, USA
Nbr de messages : 2
Carottes : 4475

Fonctionnement du Karotz (OS) Empty
MessageSujet: Re: Fonctionnement du Karotz (OS)   Fonctionnement du Karotz (OS) Icon_minitimeDim 22 Jan 2012 - 5:47

Please pardon my not posting in French, I don't know it.

I thought it would be useful to mention that if you visit http://www.karotz.com/my/usbkey and fill out your WiFi SSID and key, it will produce a .zip with a network.conf that gives examples of these commands in action.

Code:

{"cmd":"set_wifi","encryption":"wpa2","settings":{"scan_ssid":1,"key_mgmt":"WPA-PSK","ssid":"\"2303\"","psk":"\"mysecretkey\"","proto":"RSN"},"ssid":"2303"}
{"cmd":"set_ip","dhcp":true,"interface":"wlan0"}
{"cmd":"get_ip","interface":"wlan0"}
Revenir en haut Aller en bas
Contenu sponsorisé





Fonctionnement du Karotz (OS) Empty
MessageSujet: Re: Fonctionnement du Karotz (OS)   Fonctionnement du Karotz (OS) Icon_minitime

Revenir en haut Aller en bas
 
Fonctionnement du Karotz (OS)
Revenir en haut 
Page 1 sur 1
 Sujets similaires
-
» Assistant Open Karotz. Libérez votre lapin sans passer par le site officiel !
» Karotz rouge: épidémie de mixomatose sur les serveurs Karotz
» Que fera le Karotz libéré ?
» Open Karotz Pour les nuls
» Le blog de Karotz http://blog.karotz.com

Permission de ce forum:Vous ne pouvez pas répondre aux sujets dans ce forum
Forum des Objets Communicants et Solutions pour les Libérer... :: II. Nabaztag, Karotz, mir:ror, Dal:Dal (Violet Object Operating System) :: Le monde de Karotz-
Sauter vers: