Devirginator/it

From Openmoko

(Difference between revisions)
Jump to: navigation, search
(User configuration)
(Script)
Line 104: Line 104:
  
 
==== Script ====
 
==== Script ====
* crc32.pl -Permette la funzione crc32, which computes the IEEE CRC-32. Questo script è usato da altri script Perl, con "do".
+
* crc32.pl -Permette la funzione crc32 che comanda la IEEE CRC-32. Questo script è usato da altri script Perl, con "do".
  
 
* envedit.pl
 
* envedit.pl

Revision as of 13:35, 30 July 2007

Il devirginator un è un programma utilizzato in combinazione con dfu-util, OpenOCD e Debug Board per reporogrammare alle impostazioni di fabbrica il telefono from scratch.


Contents

Codice sorgente

Il codice sorgente di devirginator è disponibile qui http://svn.openmoko.org/trunk/src/host/devirginator/


Documentazione

Template:Nota

Iniziare

Per iniziare,

% cp config.example config

e fai le modifiche necessarie. In particulare, devi configurare SNAPSHOT. Quindi

% make

Questo richiede Netpbm e transfig. Infine assicurati che openocd sia attivo, accendi il dispositivo, diventa root, ed esegui

# ./devirginate


Prerequisiti

Il dispositivo deve essere connesso con:

  • JTAG, con un'interfaccia supportatata da OpenOCD (necessaria per tutti gli stages)
  • USB, connesso alla su cui è in funzione "devirginate" (richiesto solo per lo stage 2 e successivi)

Inoltre, se una serial console è connessa al dispositivo, la progressione dell'installazione può essere monitorata.

Sono bnecessari i seguenti programmi:

dfu-util

  • dfu-util deve essere accessibile dalla macchina su chui è attivo "devirginate". Se dfu-util non è nel PATH, puoi selezionare un path specifico in "config".


Per fara il build di dfu-util, esegui:

cd $OMDIR/openmoko/trunk/src/host/dfu-util
./autogen.sh
./configure
make

OpenOCD

OpenOCD SVN revision 130 con libftdi 0.8 funziona. Altre combinazioni possono anche funzionarec. E' richiesto il seguente patch:

http://svn.openmoko.org/developers/werner/openocd-wait-patiently.patch

Per el istruzioni per il build, vedi http://svn.openmoko.org/developers/werner/notes/openocd

 Se stai usando la build di OpenOCD fatta dalla OpenMoko
 distribution (SVN revision 1180 o successiva), il patch è già
 applicato.

telnet

Oltre a tutto ciò, "devirginate" necessita di telnet.


netpbm, transfig, wget, perl

"setup.sh" può essere eseguito da un'altra macchian che ha in share la stessa gerarchia del file system. Necessita di Netpbm, transfig, wget, e Perl.


Setup

Innazitutto devirginator necessita di essere configurato. Questo include

  • scaricare i binari per u-boot, kernel, etc.
  • generare/convertire diversi files usando il processo di setup

Per il momento il setup deve essere fatto nella directory contente tutti i files riferiti a devirginator. I files generati durante il setup sono posizionati nella directory tmp/. I files in tmp/ sono inoltre usati durante l'uso di devirginator.

Per iniziare, copia config.example su "config" e applica le modifiche necessarie. Quasi tutte le configurazioni necessarie sono di defaults, ma una cosa che potresti voler fare è configurare SNAPSHOT con il date code dello the snapshot che desideri.

Poi esegui ./setup.sh o semplicemente make .

setup.sh ora scaricherà ogni file perduto ed eseguirà le varie conversioni. Se apapre qualche errore durante questo processo, ad esempio a causa della mancanza di strumenti o di un errore di configurazione, setup.sh si fermerà con un errore. Potrai quindi correggere l'errore e riprovare. I files già scaricati in tmp/ verranno saltati quando riprovi (setup.sh lo farà lo stessose i files avranno subito dei cambiamenti).

setup.sh inoltre controlla se gli esguibili sono disponibili durante l'uso di devirgination e segnalerà se manca qualcosa. In generale, si può eseguire setup.sh su una macchina diversa che "devirginate", in questo caso questi avvisi saranno ignorati.


Files

Script

  • crc32.pl -Permette la funzione crc32 che comanda la IEEE CRC-32. Questo script è usato da altri script Perl, con "do".
  • envedit.pl
  • openocdcmd.pl
  • scriptify.pl
  • setup.sh

Configurazione utente

File di configiurazione statici

I file seguenti contengono script ed altra informazioni di configurazione "statici" che sono usati nel processo di devirgination. Normalmente basta editare questi file per cambiare le funzioni del processo di setup.

Ognuno di questi file è convertito in qualche maniera da setup.sh. Qui sotto dopo la freccia sono indicati i rispettivi file risultanti.

  • openocd.in -> tmp/script.ocd

Commands to execute by OpenOCD in phase 0. To perform variable expansion, each line of this file is processed by the shell with eval "echo $line". Due to this, shell meta-characters should be avoided.

If changing any addresses in openocd.in, you also need to update u-boot.in.

  • u-boot.in -> tmp/u-boot.out

Commands to execute in u-boot during stage 0. This file is converted to an image understood by u-boot, and then executed from memory with u-boot's "autoscr" command.

  • environment.in -> tmp/environment

Environment settings for the regular u-boot environment. Note that the changes in this file are made on top of the interim environment produced in stage 0. In particular, the "mtdparts" variable is retained from that stage.

Long lines can be split in environment.in by simply indenting the continuation. Note that the newline and the indentation are replaced with one space. E.g.,

foo=some
    thing

would yield foo=some thing

  • smiley.fig -> tmp/smiley.gz

The stage 0 splash screen, a smiling face on a green background.

Download cache

  • tmp/System_boot.png -> tmp/splash.gz

This is a copy of the OpenMoko logo, which then gets converted to a gzip-ed raw framebuffer image.

  • tmp/openmoko-devel-image-*.rootfs.jffs2
  • tmp/lowlevel_foo-*.bin
  • tmp/u-boot-*.bin
  • tmp/uImage-*.bin
  • tmp/env.old
  • tmp/env.new
  • tmp/preboot_override
  • tmp/preboot_override.noscrub
  • tmp/preboot_override.scrub


Scripts

The first few messages should look like this:

Open On-Chip Debugger
> script /home/moko/om/trunk/src/host/devirginator/tmp/script.ocd
reset halt
wait_halt
waiting for target halted...
Target 0 halted
target halted in ARM state due to debug request, current mode: Supervisor
cpsr: 0x400000d3 pc: 0x00000000
[...]

The "pc: 0x00000000" is important. If the number is different, e.g., something like "pc: 0xffffffed", the device is probably not turned on. In this case, you can try to restart, or, if openocd is stuck,

  • kill openocd
  • pull and then replace the USB plug of the JTAGkey or debug v2 board
  • start openocd


Stages

The setup process is divided into three stages (plus a special zero stage, see below). Each stage leaves the device in a stable state. An installation run can include all or only some stages. Each stage requires successful completion of all previous ones.

  • Stage 1: erases all previous NAND content, installs u-boot, and makes the device ready to receive further updates by DFU.
  • Stage 2: installs Linux and the root file system.
  • Stage 3: To be defined.

Note that you most likely require privileges for some of the USB operations "devirginate" performs. Therefore, do all this as "root".

To perform all stages, run

# ./devirginate

from the trunk/src/host/devirginator/ directory.

To run only individual stages, specify the stage numbers, each prefixed by "-", e.g.,

# ./devirginate -1


Stage 0

If the NAND bad block table is invalid, it can be erased at the beginning of stage 1. We call this "stage 0".

In general, this is not a desirable option, because if the last NAND blocks are defective, this information will be lost, and unreliable operation may result. By default, stage 0 is not performed.

Stage 1

Immediately after starting, the screen lights up, showing random junk. This is an indication that the setup process has started. Note that the screen content may change ("decay") during all this. This is normal.

After 10-30 seconds, the screen will go dark. This indicates that we now a have u-boot running on the device.

About 60-90 seconds later, the screen will light up again and show a smiling face on a green background. This indicates that the first stage has completed. The smiling face will appear each time you activate the device.

The device now contains:

  • a bad block table (BBT)
  • u-boot, with DFU capability
  • a basic set of u-boot environment variables
  • the interim splash screen

What is still missing:

  • the Linux kernel
  • the root file system
  • the final environment
  • the final splash screen


Stage 2

To begin phase 2, activate the device. The stage 1 smiley will show.

Phase 2 can take several minutes. Progress of the download procedure is indicated by hash signs (#) printed on the terminal where "devirginate" runs.

At the end of phase 2, the device resets, displays a partial OpenMoko splash screen, then resets again, displays the correct splash screen and finally boots Linux.


Stage 3

TBD.

Personal tools

Il devirginator un è un programma utilizzato in combinazione con dfu-util, OpenOCD e Debug Board per reporogrammare alle impostazioni di fabbrica il telefono from scratch.


Codice sorgente

Il codice sorgente di devirginator è disponibile qui http://svn.openmoko.org/trunk/src/host/devirginator/


Documentazione

Template:Nota

Iniziare

Per iniziare,

% cp config.example config

e fai le modifiche necessarie. In particulare, devi configurare SNAPSHOT. Quindi

% make

Questo richiede Netpbm e transfig. Infine assicurati che openocd sia attivo, accendi il dispositivo, diventa root, ed esegui

# ./devirginate


Prerequisiti

Il dispositivo deve essere connesso con:

  • JTAG, con un'interfaccia supportatata da OpenOCD (necessaria per tutti gli stages)
  • USB, connesso alla su cui è in funzione "devirginate" (richiesto solo per lo stage 2 e successivi)

Inoltre, se una serial console è connessa al dispositivo, la progressione dell'installazione può essere monitorata.

Sono bnecessari i seguenti programmi:

dfu-util

  • dfu-util deve essere accessibile dalla macchina su chui è attivo "devirginate". Se dfu-util non è nel PATH, puoi selezionare un path specifico in "config".


Per fara il build di dfu-util, esegui:

cd $OMDIR/openmoko/trunk/src/host/dfu-util
./autogen.sh
./configure
make

OpenOCD

OpenOCD SVN revision 130 con libftdi 0.8 funziona. Altre combinazioni possono anche funzionarec. E' richiesto il seguente patch:

http://svn.openmoko.org/developers/werner/openocd-wait-patiently.patch

Per el istruzioni per il build, vedi http://svn.openmoko.org/developers/werner/notes/openocd

 Se stai usando la build di OpenOCD fatta dalla OpenMoko
 distribution (SVN revision 1180 o successiva), il patch è già
 applicato.

telnet

Oltre a tutto ciò, "devirginate" necessita di telnet.


netpbm, transfig, wget, perl

"setup.sh" può essere eseguito da un'altra macchian che ha in share la stessa gerarchia del file system. Necessita di Netpbm, transfig, wget, e Perl.


Setup

Innazitutto devirginator necessita di essere configurato. Questo include

  • scaricare i binari per u-boot, kernel, etc.
  • generare/convertire diversi files usando il processo di setup

Per il momento il setup deve essere fatto nella directory contente tutti i files riferiti a devirginator. I files generati durante il setup sono posizionati nella directory tmp/. I files in tmp/ sono inoltre usati durante l'uso di devirginator.

Per iniziare, copia config.example su "config" e applica le modifiche necessarie. Quasi tutte le configurazioni necessarie sono di defaults, ma una cosa che potresti voler fare è configurare SNAPSHOT con il date code dello the snapshot che desideri.

Poi esegui ./setup.sh o semplicemente make .

setup.sh ora scaricherà ogni file perduto ed eseguirà le varie conversioni. Se apapre qualche errore durante questo processo, ad esempio a causa della mancanza di strumenti o di un errore di configurazione, setup.sh si fermerà con un errore. Potrai quindi correggere l'errore e riprovare. I files già scaricati in tmp/ verranno saltati quando riprovi (setup.sh lo farà lo stessose i files avranno subito dei cambiamenti).

setup.sh inoltre controlla se gli esguibili sono disponibili durante l'uso di devirgination e segnalerà se manca qualcosa. In generale, si può eseguire setup.sh su una macchina diversa che "devirginate", in questo caso questi avvisi saranno ignorati.


Files

Script

  • crc32.pl -Permette la funzione crc32, which computes the IEEE CRC-32. Questo script è usato da altri script Perl, con "do".
  • envedit.pl
  • openocdcmd.pl
  • scriptify.pl
  • setup.sh

Configurazione utente

File di configiurazione statici

I file seguenti contengono script ed altra informazioni di configurazione "statici" che sono usati nel processo di devirgination. Normalmente basta editare questi file per cambiare le funzioni del processo di setup.

Ognuno di questi file è convertito in qualche maniera da setup.sh. Qui sotto dopo la freccia sono indicati i rispettivi file risultanti.

  • openocd.in -> tmp/script.ocd

Commands to execute by OpenOCD in phase 0. To perform variable expansion, each line of this file is processed by the shell with eval "echo $line". Due to this, shell meta-characters should be avoided.

If changing any addresses in openocd.in, you also need to update u-boot.in.

  • u-boot.in -> tmp/u-boot.out

Commands to execute in u-boot during stage 0. This file is converted to an image understood by u-boot, and then executed from memory with u-boot's "autoscr" command.

  • environment.in -> tmp/environment

Environment settings for the regular u-boot environment. Note that the changes in this file are made on top of the interim environment produced in stage 0. In particular, the "mtdparts" variable is retained from that stage.

Long lines can be split in environment.in by simply indenting the continuation. Note that the newline and the indentation are replaced with one space. E.g.,

foo=some
    thing

would yield foo=some thing

  • smiley.fig -> tmp/smiley.gz

The stage 0 splash screen, a smiling face on a green background.

Download cache

  • tmp/System_boot.png -> tmp/splash.gz

This is a copy of the OpenMoko logo, which then gets converted to a gzip-ed raw framebuffer image.

  • tmp/openmoko-devel-image-*.rootfs.jffs2
  • tmp/lowlevel_foo-*.bin
  • tmp/u-boot-*.bin
  • tmp/uImage-*.bin
  • tmp/env.old
  • tmp/env.new
  • tmp/preboot_override
  • tmp/preboot_override.noscrub
  • tmp/preboot_override.scrub


Scripts

The first few messages should look like this:

Open On-Chip Debugger
> script /home/moko/om/trunk/src/host/devirginator/tmp/script.ocd
reset halt
wait_halt
waiting for target halted...
Target 0 halted
target halted in ARM state due to debug request, current mode: Supervisor
cpsr: 0x400000d3 pc: 0x00000000
[...]

The "pc: 0x00000000" is important. If the number is different, e.g., something like "pc: 0xffffffed", the device is probably not turned on. In this case, you can try to restart, or, if openocd is stuck,

  • kill openocd
  • pull and then replace the USB plug of the JTAGkey or debug v2 board
  • start openocd


Stages

The setup process is divided into three stages (plus a special zero stage, see below). Each stage leaves the device in a stable state. An installation run can include all or only some stages. Each stage requires successful completion of all previous ones.

  • Stage 1: erases all previous NAND content, installs u-boot, and makes the device ready to receive further updates by DFU.
  • Stage 2: installs Linux and the root file system.
  • Stage 3: To be defined.

Note that you most likely require privileges for some of the USB operations "devirginate" performs. Therefore, do all this as "root".

To perform all stages, run

# ./devirginate

from the trunk/src/host/devirginator/ directory.

To run only individual stages, specify the stage numbers, each prefixed by "-", e.g.,

# ./devirginate -1


Stage 0

If the NAND bad block table is invalid, it can be erased at the beginning of stage 1. We call this "stage 0".

In general, this is not a desirable option, because if the last NAND blocks are defective, this information will be lost, and unreliable operation may result. By default, stage 0 is not performed.

Stage 1

Immediately after starting, the screen lights up, showing random junk. This is an indication that the setup process has started. Note that the screen content may change ("decay") during all this. This is normal.

After 10-30 seconds, the screen will go dark. This indicates that we now a have u-boot running on the device.

About 60-90 seconds later, the screen will light up again and show a smiling face on a green background. This indicates that the first stage has completed. The smiling face will appear each time you activate the device.

The device now contains:

  • a bad block table (BBT)
  • u-boot, with DFU capability
  • a basic set of u-boot environment variables
  • the interim splash screen

What is still missing:

  • the Linux kernel
  • the root file system
  • the final environment
  • the final splash screen


Stage 2

To begin phase 2, activate the device. The stage 1 smiley will show.

Phase 2 can take several minutes. Progress of the download procedure is indicated by hash signs (#) printed on the terminal where "devirginate" runs.

At the end of phase 2, the device resets, displays a partial OpenMoko splash screen, then resets again, displays the correct splash screen and finally boots Linux.


Stage 3

TBD.