Posted on Leave a comment

netpp node ‘Dual’ Firmware

Die netpp-Firmware besteht aus einem binären Abbild im Konfigurations-Flash, welche die Funktionalität und Identität der auf dem netpp node programmierbaren Hardware definiert. Sie unterstützt von Haus aus die Möglichkeit, zwei Varianten einer Firmware und des zugehörigen Betriebssystems zu speichern. Die Möglichkeiten dieser doppelten Konfiguration sind im netpp node quick start (englisch) beschrieben und werden hier im Detail erläutert.

Wir verwenden im Folgenden die Begriffe ‘Slot’ (Steckplatz) für den Speicherplatz der Konfiguration.

Im Standard-Fall wird der netpp node mit einem Bootloader in Slot 0 beim Einstecken der Stromversorgung gestartet. Der Bootloader überprüft die im Flash gespeicherte Variable ‘SysCtrl.BootMode’, falls sie von 0 abweicht, wird das System neu gestartet und die Hardware/Software-Konfiguration aus Slot 1 geladen.

Durch eine ungünstige Konfiguration oder beim Ausprobieren neuer Firmware-Versionen kann u.U. das System nicht mehr zugänglich für eine Neukonfiguration sein. Deshalb lässt sich der netpp node wie folgt  in den Urzustand versetzen:

  1. SW2 drücken und halten
  2. SW1 kurz drücken, warten bis alle LEDs kurz aufleuchten
  3. SW2 loslassen

Im Urzustand gilt die netpp URL: UDP:192.168.0.5:2016

Wichtig: Der Urzustand sollte nicht im aktiven Fabrik-Netz bei mehreren nodes hergestellt werden, da sonst Adresskollisionen auftreten können.

Bootloader

Der Bootloader bietet minimale Funktionalität:

  • Programmierung der Netzwerkparameter
  • Flash-Zugriff zum Update der Firmware per Netzwerk

Normalerweise enthält auch die komplexere, kundenspezifische Firmware die Bootloader-Komponenten im ‘Service-Modus’, damit Neuprogrammierung aus dem laufenden Betrieb heraus erfolgen kann, ohne den Urzustand herstellen zu müssen.

Wird der Bootloader durch Überschreiben des entsprechenden Flash-Speichers beschädigt, startet das System nicht und besitzt keine Identität, über die es per Netzwerk angesprochen werden kann. Dann ist Neuprogrammierung über den Programmieradapter (bzw. eingebauten USB-Adapter, falls vorhanden) notwendig.

Szenarien

Prototyping-Modus

Bevor die Firmware in der Anlage final eingesetzt wird, empfiehlt es sich, SysCtrl.BootMode auf 0 zu lassen (Standard-Auslieferung), die zu testende Firmware in Slot 1 zu programmieren und explizit zu booten. Dies geschieht, indem die Property SysCtrl.Reboot auf ‘1’ gesetzt wird, z.B. per Kommandozeile:

netpp UDP:192.168.0.22:2016 SysCtrl.Reboot 1

Beim nächsten Reset oder Unterbruch der Stromversorgung startet das System wieder aus Slot 0.

Soll schliesslich das System automatisch in Slot 1 booten, sind die netpp-Properties wie folgt zu setzen:

SysCtrl.BootMode  1
SysCtrl.StoreNV   1

Wird anschliessend SysCtrl.Reboot auf 0 gesetzt (Slot 0), bootet das System zwar zunächst in Slot 0, lädt aber bei korrekter Firmware in Slot 1 diese nach.

Redundante Firmware

Sicherheitsrelevante Firmware benutzt u.U. einen Hardware-Watchdog, um bei einem Programmfehler oder unerlaubter Intrusion einen Neustart auszulösen. Dabei wird der Reset aus Slot 0 ausgeführt.

Da der Bootloader durch eigene, angepasste Firmware ersetzt werden kann, sind folgende Szenarien möglich:

  • Safety-Konfiguration: BootMode = 1
    • ‘Goldene’ Firmware in Slot 0: Bei einem Fehler wird auf diese Version ‘zurückgefallen’ (Fail-Safe)
    • ‘Aktive’ Firmware in Slot 1: Diese Version wird im laufenden Betrieb genutzt
  • Test-Konfiguration: BootMode = 0
    • ‘Aktive’, stabile Firmware in Slot 0
    • Test-Firmware (in Entwicklung) in Slot 1

Da die Konfigurationslogik aus der Bootloader-Routine angesprochen wird, kann sie durch den Benutzer modifiziert werden, so sind also eigene Konfigurationsoptionen möglich.

Es wird empfohlen, in der Entwicklungsphase die Bootloader-Default-Properties beizubehalten. So kann per SysCtrl.Reboot 0 oder 1 zwischen den Slots im laufenden Betrieb umgeschaltet werden.

Fehlerszenarien

  • Bei SysCtrl.BootMode 1 und aktivem Watchdog in Slot 1 können im Prinzip Endlos-Neustart-Schleifen auftreten. Diese können durch SW2 unterbrochen werden, d.h. das System startet dann mit Slot 0.
  • Wenn im Wartungs-Modus (ServiceMode.ChallengeResponse) die IP-Adresse verändert wird, kann u.U. beim Zusammenbrechen der Verbindung das Gerät aus Sicherheitsgründen nicht mehr ansprechbar sein. In diesem Fall ist ein Reset (SW1) notwendig.
Posted on Leave a comment

NHW codec tests

Original PNGs

LOW8 quantization

LOW19 quantization

Posted on Leave a comment

Lattice VIP MJPEG streaming

The EVDK or VIP from Lattice Semiconductor (Embedded Vision Development Kit) is a stereo camera reference design for development of machine vision or surveillance applications. It is based on a ECP5 FPGA as main processing unit and a CrossLink (LIF-MD6000) for sensor interface conversion. As an add-on, a GigE and USB vision capable output board can be purchased and is required for this demo.

The image acquisition board of the VIP is equipped with two rolling shutter sensors IMX214 from Sony. Unfortunately, their register map is not publicly available. The on board CrossLink unit translates video data coming through two MIPI interfaces into a parallel video stream which is easier to handle by the processor board. There are two different default firmware images for the CrossLink:

  1. Stereo mode: both sensor’s images are merged at half the x resolution (cropped)
  2. Mono mode: Only image data coming from Sensor CN2 is forwarded

The CrossLink bit files are available at Lattice Semi after registration [ Link ]

The MJPEG streaming bit file is available for free [ MJPEG-Streaming-Bitfile-for-VIP ].

JPEG-Streaming

As reference receiver for the JPEG RFC2435 stream we use the gstreamer pipeline framework. Create a script as follows:

caps="application/x-rtp, media=\(string\)video,"
caps="$caps clock-rate=\(int\)90000,"
caps="$caps encoding-name=\(string\)JPEG"

gst-launch-1.0 -v udpsrc \
caps="$caps" \
port=2020 \
! rtpjpegdepay \
! jpegdec \
! autovideosink

When calling this script under Linux (as well as under Windows) gstreamer runs a RTP MJPEG decoding pipeline and displays the video strom as soon as it arrives. The stream must then be configured on the VIP.

Stream configuration

  1. Connect USB programmer cable to VIP processor board. Then start a terminal (like minicom) with serial parameters 115200 bps, 8N1
  2. Connect to /dev/ttyUSB1 (Linux) or the corresponding virtual COM port on Windows
  3. Load ECP5 MJPEG encoder reference design (bit file) onto the target using the Diamond Programmer
  4. On the console, configure address of receiver:
    r 192.168.0.2
  5. Verify ARP reply:
    # Got ARP reply: 44 ac de ad be ef
  6. Start JPEG-Video, e.g. 1920×1080 @ 12fps (slow bit rate):
    j 2

If the JPEG stream stops, the reason is mostly a bottleneck in encoding. Under certain circumstances, FIFO overflows can be provoked by holding a colorful cloth in front of the camera. Also, a fully white saturation may fill up the FIFOs in this demo. The JPEG encoder is configured to allow up to five overflows before terminating the stream. For detailed error analysis, see documentation of MJPEG Encoder.

Sensor parameter configuration

The connected sensors are configured via the i2c bus:

# scan i2c-Bus (only when JPEG stream off):

i

# i2c register query (hexadecimal values):

i 100

# set i2c register:

i 100 1

Simplified sensor access (also, values are in hexadecimal notation):

Function

Command
se [Value] Exposure
sh [0|1] HDR mode
sr [Gain] Gain red
sg [Gain] Gain green
sb [Gain] Gain blue

Examples

These are JPEG images captured from the encoded stream without further conversion. They use the Crosslink firmware for stereo sensor configuration. Image errors can occur due to probable synchronization issues at a lower pixel clock.

Stereo test image (‘j 4’ command)
Broken stereo image (MIPI output frequency too low)

General Troubleshooting

  • Video does not start:
    1. Check error messages on console. If ‘Frames received’ upon video stop (‘j’) shows 0, the sensor configuration may be incorrect or the CrossLink is not properly initialized.
    2. Check for Network activity (orange LED) on GigE board
    3. Use wireshark to monitor network activity
  • Video starts, but terminates:
    1. Check error bits on console: [DEMUX], [FIFO], …
    2. Increase quantisation value (better compression):
      q 30
    3. Check for lost packets with wireshark
    4. Try direct network connection between VIP and PC (no intermediate router)
  • Broken images:
    1. Check again for error bits on console. It is also possible, that the CrossLink reference design does not properly handle the clock coming from the sensor.