8
144 145 TELE-audiovision International — The World‘s Largest Digital TV Trade Magazine — 07-08/2013 — www.TELE-audiovision.com www.TELE-audiovision.com — 07-08/2013 — TELE-audiovision International — 全球发行量最大的数字电视杂志 AZBox Ultra HD Wieder- belebung • auch scheinbar "tote" Receiver lassen sich wiederbeleben • oft gibt es mehrere Wege, Receiver wiederzubeleben • Mut und Mühe lohnen sich, um alte Receiver mit neuer Software upzudaten • YAMON und JTAG sind zwei wesentliche Bestandteile für die Receiver-Wiederbelebung AZBox Ultra HD Recovery

Vitor s Workshop

Embed Size (px)

Citation preview

Page 1: Vitor s Workshop

144 145TELE-audiovision International — The World‘s Largest Digital TV Trade Magazine — 07-08/2013 — www.TELE-audiovision.com www.TELE-audiovision.com — 07-08/2013 — TELE-audiovision International — 全球发行量最大的数字电视杂志

AZBox Ultra HD Wieder-

belebung

• auch scheinbar "tote" Receiver lassen sich wiederbeleben• oft gibt es mehrere Wege, Receiver wiederzubeleben• Mut und Mühe lohnen sich, um alte Receiver mit neuer Software upzudaten• YAMON und JTAG sind zwei wesentliche Bestandteile für die Receiver-Wiederbelebung

AZBox Ultra HD Recovery

Page 2: Vitor s Workshop

146 TELE-audiovision International — The World‘s Largest Digital TV Trade Magazine — 07-08/2013 — www.TELE-audiovision.com

AZBox Ultra HD Recovery

Brick (Ziegelstein): so wird im englischen ein Receiver genannt, der sich nicht mehr wiederbeleben läßt - er ist tot und läßt sich gera-de noch zum Hausbau verwenden... Genau das passierte mir mit einem

AZBox Ultra HD, bei dem ich Lust am Experimentieren einfach mal eine aktuelle E2 Firmware aufspielen wollte. Wie üblich habe ich natürlich NICHT die Anleitung zum Firmwa-re-Wechsel gelesen und ruck zuck

wurde meine AZBox Ultra HD zu ei-nem Ziegelstein: nichts ging mehr. Was also tun? Ein Haus bauen oder der Sache auf den Grund gehen? Sie ahnen es, ich entschied mich für die letztere Variante.

Wie aus einem Ziegelstein wieder ein Receiver wirdVitor Martins Augusto

A look into Vitor's real-life Workshop: doing the TTL recovery makes your bench look as if you were doing open heart surgery. Seeing that the otherwise dead receiver is still responding to Putty is a great reassurance.

In TELE-audiovision 08-09/2010 we presented the AZBox Ultra HD. In our current report we describe how to recover a "dead" AZBox Ultra HD.http://www.TELE-audiovision.com/TELE-satellite-1009/eng/azbox.pdf

Page 3: Vitor s Workshop

1

2

3

4 5

6

7

8

148 149TELE-audiovision International — The World‘s Largest Digital TV Trade Magazine — 07-08/2013 — www.TELE-audiovision.com www.TELE-audiovision.com — 07-08/2013 — TELE-audiovision International — 全球发行量最大的数字电视杂志

Die älteren AZBox Receiver, zu denen auch mein Ultra HD gehörte, verfügen über eine interne serielle Schnittstelle. Über diese kann man sich in den Boot-loader einklinken und die Firmware er-neut flashen. Doch ganz so einfach ist es nicht, denn die interne serielle Schnitt-stelle funktioniert mit TTL-Pegeln (3.3 Volt) statt den üblichen 12 Volt einer RS232 Schnittstelle. Würde man direkt die interne serielle Schnittstelle des Re-ceivers mit einem Nullmodem-Kabel an den COM-Port des Computers anschlie-ßen, dann wäre ein Hardware-Defekt vorprogrammiert. Man braucht also in diesem Fall einen TTL-Adapter, wie man sie z.B. sehr günstig bei eBay für unter 2 Euro ersteigern kann. Es handelt sich um einen USB-TTL Adapter, der am PC automatisch als COM-Port erkannt wird. Diese Adapter benutzen den bekannten Prolific 2303 Chip, der auch in den meis-ten USB-RS232 Adaptern vorkommt. Einziger Unterschied ist, dass in diesem Fall noch ein MAX232 für die Pegel-Wandlung zum Einsatz kommt.

Aber ich entschied mich für eine an-dere Lösung: ich benutzte ein altes No-

kia DLR-2L Datenkabel. Da ich das Kabel sowieso nicht mehr benutze schnitt ich einfach den Nokia-Stecker ab. Durch Probieren am Oszilloskop konnte ich schnell ermitteln, dass der rote Leiter RX, der grüne TX und der schwarze Leiter wie erwartet GND überträgt. Ein altes CD-ROM Audiokabel für Computer bietet einen passenden Stecker für die AZBox, so dass die entsprechenden Lei-ter nur noch verbunden werden muss-ten. Nach einem ersten Test fiel mir natürlich gleich der jedem Bastler be-kannte einschlägige Fehler jeder seriel-len Übertragung auf: TX und RX müssen natürlich gekreuzt verbunden werden. Und dann funktionierte es auch schon.

Mit Putty, einem sehr bekannten Free-ware Terminal-Programm, konnte ich den Bootloader der AZBox verfolgen und dieser meldete eine ungültige Firmware. Dieser Bootloader nennt sich YAMON („Yet Another MONitor“) und ist viel um-fangreicher als gewöhnliche Bootloader älterer Receiver und bietet eine Kom-mando-Ebene, die es unter anderem er-laubt, über das Netzwerk Dateien in den RAM-Speicher zu lesen oder von diesem

1. The Nokia DLR-2L cable features a TTL to RS232 converter and can be used to connect the COM-Port of a PC with a TTL interface. If your computer does not have a COM-port anymore, you can just use a RS232 to USB converter. Bear in mind that neither the Nokia-cable, nor the RS232 to USB converter cross the TX and RX lines: you will need to cross them yourself. Pay special attention to just use TX, RX and GND. The second pin on the AZBox PCB is not to be used. Doing so can quickly fry the circuit on the AZBox and then you are definitely locked out of any TTL restoration.2. See the white dot on the PCB, close to the 4 TTL pins? It marks the pin #1. On the different AZBox receivers the pins have always the same function:

Pin 1 – TX Pin 2 – VCC (Warning: do not use this pin!)Pin 3 – GNDPin 4 – RX

3. When everything else fails, JTAG is your last resort before having to flash the chip externally. But before being able to do so it is convenient to solder some pins on the JTAG port, because the manufacturer left those out.4. In order to prevent accidental writing to the flash chip a jumper exists. If not closed, the JTAG cannot write to the flash

chip. This means that a jumper needs to be soldered. Because the two pins are really small, I just soldered a small wire. Later on, instead of de-soldering it, I cut the wires open, obtaining two small and fragile pins, which can be closed without further soldering.5. This is the most difficult part of the JTAG retrofitting, as you do need proper equipment. I used a hot air soldering station to obtain two 103 resistors from an old motherboard. Using the same hot air station, I soldered these two miniscule resistors to the AZBox PCB, close to the JTAG port.6. The parallel JTAG adapter used in this process consists of soldering a total of four 100 Ohm resistors to a male DB25 connector. These are soldered each to pin 2, pin 3, pin 4 and pin 13. Finally, pins 20 to 25 have to be shunted. From each resistor and from the shunted pins, connect wires, as short as possible, to the pins of the JTAG port on the AZBox PCB. Connect the wires like in diagram right.7. Connect the wires according to this drawing8. If TTL recovery seemed like open heart surgery, JTAG flashing is equivalent to brain surgery. Extra care has to be taken to avoid that any wire touches the receiver on the wrong spot. To prevent that the casing of the open DB25 connector

touches the receiver, I used a bit of paper. Put something heavy on the parallel port cable, to prevent the cable from accidentally moving, which could make the thin wires go off. The receiver has to be turned on during the JTAG process, so beware that there is live current on the open receiver. However, AZBox receivers normally use an external power supply, so you should not get hurt, even if you touch the receiver. This is not the case on receivers with build-in power supply. In these cases you have to be extra careful and advise other people in the house to not get near the receiver.

Page 4: Vitor s Workshop

1

2

3 4

150 TELE-audiovision International — The World‘s Largest Digital TV Trade Magazine — 07-08/2013 — www.TELE-audiovision.com

Putty1. Before starting Putty you need to figure out which COM-port was assigned to the USB adapter. The easiest way to do so is to open the device manager and check on the Ports (COM & LPT) section, what the port attributed to the Prolific USB-to-Serial is.2. Open Putty and configure the session to use the Serial port. Configure it to match the port number and set the Speed

to 115200 baud (bits per second). Then click the Open button to start the session. Finally, you can turn on the receiver.3. If the boot loader has not been whipped you should be greeted by YAMON. You can stop the boot procedure of the receiver with CTRL-C, but if the kernel is corrupt or erased YAMON will stop anyway.4. The next step is to setup the network. You need three commands:

- “setenv ipaddr 192.168.xxx.yyy” will set the receiver’s IP address. Replace

xxx and yyy with suitable values for your network. Remember that xxx must be a unique value.- “setenv subnetmask 255.255.255.0” will set the receiver’s subnet mask, which usually is 255.255.255.0.- “setenv gateway 192.168.xxx.zzz” will set the gateway. This is normally the IP address of your router.

If these three steps have been correctly done you can initialize the network with “net init” and start it with “net up”.

zum Computer zu senden. Außerdem kann man den Flash-Speicher löschen, auslesen und programmieren. Schließ-lich ist es auch möglich, die Ausführung von Programmen an einer beliebigen RAM-Speicheradresse zu starten.

Die Vorgehensweise besteht immer darin, mit Putty den Startvorgang von YAMON mit CTRL+C zu unterbrechen. Nun wird die Netzwerk-Schnittstelle konfiguriert und aktiviert. Anschlie-ßend startet man auf dem Computer

einen TFTP-Server und holt sich über YAMON ein Notfall-Image in den RAM-Speicher. Dieses wird gestartet und der Receiver bootet in ein minimalistisches Linux Betriebssystem. Nun kopiert man wie üblich mit FTP ein Notfall-Image zu-sammen mit dem „update“-Programm nach/tmp. Die Rechte des „update“-Programms müssen geändert werden, damit es ausgeführt werden kann. Star-tet man „update“ mit dem Namen des Notfall-Image als Argument, wird der

Receiver neu geflasht und kann danach wie üblich über USB und AZUp mit der gewünschten Firmware geflasht wer-den. Gesagt, getan, schon beim ersten Versuch hatte ich Erfolg: meine AZBox Ultra HD startet nun, wie anfangs ge-wünscht, mit der aktuellen E2 OpenRSI Firmware.

Trotzdem war ich nicht zufrieden, denn ich fand die Recovery-Prozedur zu kompliziert. Das muss doch einfacher gehen, dachte ich mir. Denn wenn man

Page 5: Vitor s Workshop

1 2

3

4

5

6 7

8 9

10 11

12

152 153TELE-audiovision International — The World‘s Largest Digital TV Trade Magazine — 07-08/2013 — www.TELE-audiovision.com www.TELE-audiovision.com — 07-08/2013 — TELE-audiovision International — 全球发行量最大的数字电视杂志

TTL Recovery1. To do the recovery, you need to enter YAMON as described before and then it is essential to configure and start the network adapter of the AZBox.2. Now we want to load the recovery image called “vmlinux.bin” contained in the recovery archives. Do not press enter, yet!3. You need to copy the required files to a folder, first.4. Now it is time to start PumpKIN, the freeware TFTP server.5. Configure the path to the folder were

you placed the recovery files for your AZBox.6. Now you can press ENTER on the Putty window and hopefully the “vmlinux.bin” file will be loaded into the RAM of the AZBox.7. Type the “go” command inside the Putty window to start the recovery Linux from RAM. The usual start-up messages appear…8. …and only a short while later, you will be prompted for the AZBOX login. Use “root” for login and you may or may not have to enter the password, which will be “azbox”.

9. If everything went well, you are now logged in.10. Change to the “/tmp” folder with “cd /tmp”.11. And then confirm your network configuration with the command “ifconfig”. It is good to have the rooter configured as a DHCP server, which automatically provides the network configuration.12. Use your favourite FTP client (we like the free FileZilla) and transfer the backup kernel and the “update” file to “/tmp” of your AZBox. Use the IP address obtained in the last step and don’t forget to specify the password, if required.

schon den YAMON-Bootloader hat soll-te es doch möglich sein, direkt mit die-sem den Flash zu bespielen. Ich machte mich also daran, genau das zu probie-ren. Mein Plan: das Notfall -Image in den RAM-Speicher laden, den Flash löschen und dann das Image im RAM erneut in den Flash schreiben. Dies würde die Recovery-Prozedur um einiges verein-fachen.

Erster Test: Image in das RAM gela-den, Flash gelöscht. Doch als ich das Image im RAM flashen wollte verwei-gerte YAMON diesen Befehl. Warum, war mir zu diesem Zeitpunkt noch nicht klar. Macht nichts, dachte ich. Erst mal den Receiver neu starten und dann die eingangs beschriebene Prozedur wie-derholen. Von wegen! Im Eifer des Ge-fechts habe ich doch glatt den GESAM-TEN Flashspeicher gelöscht, Bootloader inbegriffen. Nun mußte ich doch daran denken, das Gerät als Ziegelstein zu be-nutzen. Oder etwa nicht?

ben und einer Entlötpumpe entfernt. Der Trick: um das Loch freizumachen, muss man erst neues Lötzinn hinzufü-gen. Dadurch, dass das Volumen an zu entfernendem Lötzinn grösser ist bleibt es etwas länger flüssig, so dass man den Lötkolben entfernen kann und mit der Pumpe das noch flüssige Lötzinn ent-fernt. Ist nur wenig Lötzinn vorhanden erstarrt es sofort und die Pumpe bewirkt nichts.

Die Pins anzulöten war einfach, für den Jumper benutze ich einen dünnen gebogenen Draht. Man braucht eigent-lich nur das schon auf der Platine vor-handene Lötzinn zu erhitzen um den Draht anzulöten.

Letzte Hürde: die Widerstände. Woher soll man diese überhaupt bekommen? Hier zahlt es sich aus, alte Motherboards nicht wegzuwerfen. Die notwendigen Widerstände kommen auf solchen Plati-nen oft vor, so dass man sie einfach aus-löten kann. Doch mit einem normalen

Aber wie war das mit JTAG? In der TELE-audiovision 10-11/2011 beschrieb ich den Einsatz des JTAG Interfaces. Ginge es denn damit? Doch schnell wurde mir klar, was dafür alles notwendig ist:

- Die JTAG-Pins sind nicht bestückt und zugelötet. Erst muss man das Lötzinn entfernen und Pins einlöten.

- Ein Jumper muss angebracht werden, der den Schreib-schutz des Flash-Speichers deaktiviert. Es handelt sich um die Brücke R309 in der Nähe des Prozessors.

- Zwei SMD-Widerstände des Typs 103 (vierfache Ausfüh-rung) müssen eingelötet werden.

- Das notwenige JTAG-Interface für den Parallel-Port muss angefertigt werden. Es werden nur 4 100K Widerstände be-nutzt und natürlich ein DB25-Stecker.

Kein Problem, dachte ich mir, und habe mich sogleich an meine Werkbank gesetzt. Das Lötzinn wird mit einem Lötkol-

Page 6: Vitor s Workshop

13 14

15 16

1 2

3 4

5

154 155TELE-audiovision International — The World‘s Largest Digital TV Trade Magazine — 07-08/2013 — www.TELE-audiovision.com www.TELE-audiovision.com — 07-08/2013 — TELE-audiovision International — 全球发行量最大的数字电视杂志

TTL Recovery13. In the Putty window, confirm you received the files with the “ls” command. Notice that the “update” file is listed in grey. This means that it cannot be executed!14. Use the “chmod 755 update” command to change the privileges, so that “update” can be executed.15. Repeat the “ls” command: “update” is now listed in green, meaning that it can be executed.16. Execute the command “./update backup_kernel_344” to flash the backup kernel into the flash. This will take a few minutes and the receiver will then restart automatically. It may be necessary to turn the receiver off and on again. It will boot with a kernel that can be upgraded using the normal procedure with a USB pen and AZUp. Congratulations! The receiver is alive again.

Lötkolben kommt man nicht weit. Viel besser ist es, eine Heissluft-Lötstation zu besitzen. Diese sind gar nicht mal so teuer und machen sich schnell bezahlt wenn es darum geht, Chips auszulö-ten oder kleinste SMD-Bauteile anzulö-ten. Ab 150 Euro bekommt man schon brauchbare Modelle.

In wenigen Sekunden hatte ich mit der Heissluft-Lötstation zwei passende Widerstände mit der Beschriftung 103 von irgendeinem alten Motherboard ausgelötet und auf die AZBox-Platine gelötet. Schön ist die Tatsache, dass der winzige Widerstand dank der Oberflä-chenspannung des Lötzinns korrekt auf die Kontakte angezogen wird. Mit dem Auge ist es nicht einfach, dies zu prü-

fen. Es ist also doch etwas einfacher als es aussieht. Das JTAG-Interface war in Minuten fertig und schon konnte es los-gehen. Mit der OpenSource OpenOCD Software wird der Flashvorgang aus-geführt. Doch schnell kam die Ernüch-terung: der Flashvorgang ist langsam. Nicht normal langsam, sondern wirklich langsam. Nach meinen Berechnungen würde der komplette Flashvorgang der 8MB zwei Wochen dauern! Deshalb habe ich mir die Firmware-Datei mit einem Hex-Editor angeschaut.

An den „geraden“ hexadezimalen Adressen erkennt man recht einfach, ob ein neuer Speicherbereich anfängt. Man muss sich den Flash-Speicher wie eine Diskette vorstellen, auf welcher verschiedene Dateien gespeichert sind. Zwischen den Dateien gibt es bis zur nächsten „geraden“ Speicheradresse immer einen freien Bereich, der entwe-der mit &H00 oder &HFF gefüllt ist. Da im Flash auch der Kernel untergebracht ist und ich einen solchen ja auch als Datei auf dem Computer hatte, konnte ich schnell vergleichen wo sich dieser im Flash befindet. Es lohnt sich auf je-den Fall mal in eine Flash-Datei reinzu-schnuppern und dafür eignet sich der OpenSource Hex-Editor „Frhed“ hervor-ragend.

Meine Untersuchung ergab, dass die 8192 KB wie folgt aufgeteilt sind:

- &H000000-&H0040000 – Erster Bootloader

- &H004000-&H0080000 – YAMON- &H008000-&H0700000 – Linux-Ker-

nel

- &H070000-&H07FFFFF – Erstes Dateisystem

Somit müsste es eigentlich ausrei-chen, nur die ersten &H80000 Bytes zu schreiben, statt die kompletten &H800000. Dieser Flashvorgang sollte in einer Nacht erfolgreich durchlaufen. Ich habe mit dem Hex-Editor deshalb die ersten &H80000 Bytes in eine neue Datei kopiert und diese mit OpenOCD geflasht.

Und tatsächlich: am nächsten Morgen konnte ich den Receiver zumindest bis zum YAMON starten. Nun spielte ich über TFTP erneut das Notfall-Image in den RAM-Speicher. Um jedoch nicht wieder den Bootloader und YAMON zu verlieren habe ich mit dem Hex-Editor die ersten &H80000 Bytes entfernt, um dann die resultierende Datei ab Speicherposition &H008000 zu flashen. Dieser Vorgang dauerte nur wenige Minuten und siehe da: der Receiver startete wieder und ich konnte nun mit AZUp ganz normal eine Firmware aufspielen – der Receiver wur-de erfolgreich zum Leben erweckt.

Damit ist der Beweis erbracht: mit Hilfe eines TTL-Adapter kann man bei Vorhandensein von YAMON jede AZBox direkt mit einem Kernel beschreiben. Mit unbelebten AZBox Receiver wird niemand ein Haus bauen können, denn man kann sie sämtlich wiederbeleben!

Dieser AZBox Ultra HD Receiver ist mir nun ganz besonders ans Herz ge-wachsen, denn nach einigen schlaflosen Nächten, einigem Löten und der JTAG-Behandlung kenne ich nun die Innereien wie bei keinem anderen Receiver.

JTAG1. If you can’t enter YAMON, because the flash has been completely wiped off then you must use the JTAG route to recover your AZBox. Download OpenOCD and copy the AZBox configurations to the correct folders. Google for “azbox jtag” and you should easily find the required files with instructions. You need a copy of the flash contents (a file with exactly 8MB), usually found with the name “az3_nor_flash.rar”. You then need to copy “azbox.cfg” to the “board” folder in the OpenOCD installation tree and “smp8634.cfg” to the “target” folder. Now open two DOS shells, using WINDOWS-R. Enter “cmd” in the pop-up window. In both windows, go into the installation folder of OpenOCD and then in the “bin” subfolder.2, 3. Arrange both windows vertically, so you can monitor both. In the upper window, enter the command “openocd –f interface\parport_dlc5.cfg –f board\azbox.cfg”. Naturally you must have the AZBox turned on and the JTAG-interface connected. Type “telnet localhost 444” in the lower window, but wait until OpenOCD starts successfully in the upper window.4. Press ENTER in the lower window. Now you can issue commands in the lower window and see the responses in both windows. Start with the following commands:

- halt- reset halt- reset init

5. If everything went well so far, you can continue with these commands:

- flash probe 0- flash erase_sector 0 0 63- flash write_image az3.bin 0 bin- flash write_bank 0 az3.bin 0x0

This will now take literally ages. The window will show the progress:Programming at ac000000, count 00800000 bytes remainingProgramming at ac000100, count 007fff00 bytes remainingProgramming at ac000200, count 007ffe00 bytes remaining

However, you do not have to wait until the whole flash is programmed. That would take almost two weeks, at least on my computers. I tried two different ones and the results were the same. All you need to do is just to flash the first &H80000 bytes, which contain the first boot loader and the YAMON ROM monitor. This means that you can simply turn off the receiver as soon as the message “Programming at ac080000, count 0077FFFF bytes remaining” appears. Once this happens and all went well, you should be able to start YAMON again. You then are back in business, as you can repeat the regular TTL flashing process. But still, I found a better way of doing it… Read on!

Page 7: Vitor s Workshop

1

2

3

4

5

6

7

156 TELE-audiovision International — The World‘s Largest Digital TV Trade Magazine — 07-08/2013 — www.TELE-audiovision.com

Flash Dump with Yamon1. The first thing you should always do with any of your receivers is to dump the flash, in case things go wrong. Start YAMON using the TTL interface and by pressing CTRL-C as prompted.

2. Configure and start the network and don’t forget to start PumpKIN.3. Use the “fwrite” command of YAMON to dump the flash into a file. 4. PumpKIN asks if we really want to receive the file. Yes we do!5. YAMON states the flash contents have

been successfully transferred.

6. And so does PumpKIN.

7. Right click on the dumped file and confirm that the file size is exactly 8MB (8.388.608 bytes). If so, you have a good backup copy of your flash.

Page 8: Vitor s Workshop

1 2

3 4

5 6

158 TELE-audiovision International — The World‘s Largest Digital TV Trade Magazine — 07-08/2013 — www.TELE-audiovision.com

Flashing in Yamon1. The dumped flash file contains both boot loaders in the first &H80000 bytes. Use your favourite HEX-editor to delete these bytes. I use the free software Frhed for this.2. Select the first byte and then shift-select the byte on position 0x7ffff. Notice that the next bytes show “-rom1fs-“ which is the label of the kernel!3. Press the DEL-key to delete the selected bytes. Confirm that you are deleting x0 to x7ffff.4. Save the resulting bytes into a new file.5. You will obtain a new file with exactly 7.864.320 bytes. It contains the complete flash image except the two boot loaders.6. This file can be written directly from within YAMON to the flash chip using the “pflash” command. Make sure that the file is loaded into &Hb0100000 and its size is &H780000. This makes the recovery process much faster, as you do not have to start Linux from RAM and then transfer files using FTP.