Gresb Ethernet/Spacewire Bridge: Gaisler
Gresb Ethernet/Spacewire Bridge: Gaisler
Table of contents
1 Introduction.............................................................................................................................. 3
1.1 System overview...................................................................................................................................... 3
2 Installation................................................................................................................................ 4
2.1 Power....................................................................................................................................................... 4
2.2 Ethernet ................................................................................................................................................... 4
2.3 SpaceWire links....................................................................................................................................... 4
2.4 GRESB Console ...................................................................................................................................... 4
3 Operation.................................................................................................................................. 5
3.1 Overview ................................................................................................................................................. 5
3.2 Host to SpaceWire packet transmission .................................................................................................. 8
3.3 SpaceWire to host packet reception......................................................................................................... 8
3.4 Packet Sniffing reception......................................................................................................................... 9
3.5 GRESB configuration.............................................................................................................................. 9
3.6 GRESB status query .............................................................................................................................. 10
3.7 GRESB network settings....................................................................................................................... 12
3.8 Host software......................................................................................................................................... 13
3.8.1 GRMON.................................................................................................................................. 13
3.8.2 SpaceWire IP tunnel software ................................................................................................. 14
3.9 GRESB embedded web server .............................................................................................................. 15
4 Optional CAN 2.0B interface................................................................................................. 18
4.1 Overview ............................................................................................................................................... 18
4.2 CAN message transmission and reception ............................................................................................ 18
4.3 CAN configuration ................................................................................................................................ 19
4.3.1 Bus timing configuration (option = 0) .................................................................................... 19
4.3.2 Acceptance filter configuration (option = 1 and 2) ................................................................. 20
4.4 CAN status ............................................................................................................................................ 21
4.5 Software................................................................................................................................................. 22
5 Interfaces................................................................................................................................ 23
5.1 Front panel............................................................................................................................................. 23
5.2 Back panel ............................................................................................................................................. 23
5.3 Connector pin-out tables ....................................................................................................................... 25
3
1 Introduction
10/100 Mbit
Ethernet
SpaceWire
The bridge can be configured with a static ip address or use the built-in DHCP client to automatically
acquire an IP address when connected to an ethernet network. An embedded web server displays
information about the system and lets the user configure the GRESB. The configured IP address is
printed on the serial console (J2 connector) during boot.
4
2 Installation
2.1 Power
The GRESB is powered from an external +5V adapted, which should be connected to J11 in the back
panel.
2.2 Ethernet
The connection to the ethernet network should be done using a standard network cable, inserted in the
RJ45 connector (J3) in the front panel.
Host Computer
J11 2.5 mm
Power Jack
3 Operation
3.1 Overview
Each virtual SpaceWire link consists of a pair of TCP sockets, one for transmit data and one for
received data. Table 1 lists the ports allocated for each virtual link. The GRESB listens for incoming
connections on these ports. A host computer should connect to a virtual link using the standard con-
nect() socket call. All communication on these ports follow a simple protocol described in chapter 3.2
and 3.3.
Port Function
3000 Virtual link 0 transmit
3001 Virtual link 0 receive
3002 Virtual link 1 transmit
3003 Virtual link 1 receive
3004 Virtual link 2 transmit
3005 Virtual link 2 receive
3006 Virtual link 3 transmit
3007 Virtual link 3 receive
3008 Virtual link 4 transmit
3009 Virtual link 4 receive
3010 Virtual link 5 transmit
3011 Virtual link 5 receive
3064 Traffic Sniffer
80 Web server
When a packet is received on any link (real or virtual) the destination node address is used to index the
routing table in the GRESB. Each entry in the table consists of the following data:
Field Description
Link type SpaceWire or virtual link.
Link ID Link number. 0-2 for SpW links and 0-5 for virtual links.
Header deletion If enabled, delete the first byte in the SpW packet. Makes path addressing possible.
Enabled Enable the route. If disabled all packets to the node address are dropped.
Sniff If enabled, the packet will also be sent to the Traffic Sniffer Port if opened
If the route is not enabled or if the destination link is not active (i.e not in run state or not connected)
the packet is dropped. Otherwise the packet is sent to the link specified in the routing table. Packets
that are forwarded to a SpaceWire link are put in a transmit queue. Each SpaceWire link has a separate
queue so a busy or slow link will not hinder incoming packets destined to another SpaceWire link.
While the GRESB is transmitting a packet to a virtual link (i.e sending data on one of the virtual
receive TCP sockets) it will not process any new packets from the link on which the packet arrived.
Up to 32 incoming SpaceWire packets (with a maximum size of 128 KB) per link are buffered by the
bridge allowing high speed bursts of data. When the buffers are full the SpaceWire flow control capa-
bilities are used to ensure that no packets are dropped.
6
Header
Node address Link type Link ID deletion Enabled
0 - - - No
1-3 SpaceWire 0-2 Yes Yes
4-10 - - - No
11-13 SpaceWire 0-2 No Yes
14-31 - - - No
32-37 Virtual 0-5 No Yes
254 SpaceWire 0 No Yes
Figure 3 shows how the routing works in the four possible situations, virtual (TCP) link to SpW link,
SpW to TCP, SpW to SpW and TCP to TCP. In separate routing table mode, each port (TCP and
SpaceWire) has it own configurable routing table, the routing still works exactly the same. The default
routing table mode is however to have a single global routing table for all ports.
7
A packet with Destination Node Address (DNA) 33 is received on virtual link 5. The destination link
is looked up in the routing table. It is destined to virtual link 0 and the GRESB will start transmitting
the packet on the appropriate socket.
A packet destined for a virtual link will be dropped if the associated socket is not in a connected state.
In a similar manner a packet will be dropped if the outgoing SpaceWire link is not in run state. When
forwarding to a virtual link, any detected errors (such as error end of packet and truncated packets) are
indicated in the GRESB protocol header. Since this header is not added when forwarding to another
SpaceWire link any possible error information is lost in SpaceWire to SpaceWire routing.
The SpaceWire links have a maximum bit rate of 100 Mbit/s. The transmission bit rate can be divided
by any integer between 1-255 thus giving rates of 100, 50, 33.33, 25, 20, etc. A startup bit rate of 10
Mbit/s as required by the SpaceWire standard is used. When a link enters run state its bit rate will be
changed to the bit rate configured by the user (which defaults to 10 Mbits/s).
The bridge has a built-in web server on port 80 where the routing table can be modified easily and
where current status and configuration is displayed. Its features are further described in chapter 3.9.
Header
1 byte 3 bytes up to 128Kbytes
The maximum size of a SpaceWire packet that can be handled by the bridge is 128 Kbytes. It is up to
the host application to correctly create the SpaceWire packets with address, protocol id and data.
When sending RMAP commands the host has to format the SpaceWire packets according to the
RMAP protocol including checksums.
Header
6 bits 1 bit 1 bit 3 bytes up to 128Kbytes
The receive TCP port should never be written. If SpaceWire data is received while the TCP port is not
bound, the data will be discarded.
The Sniff TCP port should never be written. If SpaceWire data is received while the TCP port is not
bound, the data will be discarded.
Header
1 byte 2 bytes 1 byte 4 bytes
The two bytes following the protocol ID are reserved for future use and should be set to zero. The last
byte in the header holds the option to be configured. After the header comes a 4 byte value field which
also needs to be in network byte order. The different options and their possible values are listed below.
The link number should be 0-2 for SpaceWire links and 0-5 for virtual links.
If header deletion is enabled the first byte will be removed from the SpaceWire packet as it is routed to
its destination link. This needs to be done for path addressing
If the specified route is disabled all packets to that destination node address will be dropped.
Port Type and Port Number is used to identify which routing table is configured. If default routing
table mode is used both these fields should be set to zero to indicate the first routing table (SPW0).
To save the changed routing table to flash a packet with the most significant bit of the value field set to
1 should be sent. When this bit is set all other bits are ignored. After a save the new settings can be
viewed on the web interface.
Header
1 byte 2 bytes 1 byte 4 bytes
The two bytes following the protocol ID are reserved for future use and should be set to zero. The last
byte in the header holds the option to be configured. After the header comes a 4 byte value field which
also needs to be in network byte order. The different options and their possible values are listed below.
Word Description
0 Number of packets received
1 Size of data received (MB)
2 Number of packets with EEP received
3 Number of truncated packets received
4 Number of packets transmitted
5 Size of data transmitted (MB)
Word Description
0 Number of packets routed to node address
1 Number of packets destined to node address that were dropped
Bit 7-0 Bit 3 Bit 2 Bit 1 Bit 0 Bit 7-0 Bit 7-0
- 1= 1 = Enabled 1 = Header 1 = SpW link Link number Node address
Sniffer 0 = Disabled deletion 0 = Virtual link
enable
Command:
Command: /bin/ethspw &
=========================================
GR Ethernet to SpaceWire bridge started
It is possible to change the network settings through the console using the ‘netcfg’ command:
Set the ip and static configuration: netcfg ip <ip address>
Set the netmask and static configuration: netcfg nm <netmask>
Set the gateway and static configuration: netcfg gw <gateway>
Switch to DHCP: netcfg dhcp
Switch to static configuration: netcfg static
The netcfg command changes the network parameters stored in the FLASH memory. A reboot is nec-
essary for the changes to take effect.
13
The send command connects to a virtual link and transmits a file from the host to the GRESB where it
is routed to the desired node. The file is sent in packets of size 32 KBytes. If another packet size is
needed change the SPW_PACKETSIZE in send.c accordingly.
The recv command connects to a virtual link and receives data which is routed to that link. The data is
saved into the file <filename>. The recv program never exits, it must be killed with a ctrl-c.
The set_clkdiv and set_route sends configuration packets configuring the clock divisor and the rout-
ing table.
The sniff command connects to the sniff port of the GRESB logs packet traffic from TCP/SPW ports
which has the destination address sniff field enabled. The packets are stored to file.
Examples:
1. To send a file to SpaceWire node address 10 from virtual link 0
send 192.168.0.103 0 10 file.dat
3. To set the transmission bit rate of SpaceWire link 0 to 50 Mbits/s, divide the clock by 2:
set_clkdiv 192.168.0.103 0 2
4. To create a route for node address 40 to SpaceWire link 2 with no header deletion.
set_route 192.168.0.103 0 40 2 spw 0 1
Source code for the API and example applications is provided on the CD.
The host software can be compiled on either linux or windows/cygwin hosts. The software should be
compiled as follows:
gcc -O2 send.c ethspw_api.c -o send
gcc -O2 recv.c ethspw_api.c -o recv
gcc -O2 set_clkdiv.c ethspw_api.c -o set_clkdiv
gcc -O2 set_route.c ethspw_api.c -o set_route
gcc -O2 get_route.c ethspw_api.c -o get_route
gcc -O2 get_status.c ethspw_api.c -o get_status
gcc -O2 get_linkstats.c ethspw_api.c -o get_linkstats
gcc -O2 get_nodestats.c ethspw_api.c -o get_nodestats
gcc -O2 sniff.c ethspw_api.c -o sniff
3.8.1 GRMON
Targets equipped with a SpaceWire core with RMAP support can be debugged through the GRMON
debug monitor using the GRESB. GRMON will connect on a virtual link and send RMAP packets to
14
the specified destination node address. For the specified source node address a return route to the vir-
tual link on which GRMON is connected must be set up.
To debug with GRMON through the bridge start with the -gresb switch and use the following
switches to set the needed parameters:
-ip <ipnum> Connect to the bridge using the IP address ipnum. Default is 192.168.0.51.
-link <linknum> Connect to virtual link linknum on the bridge. Defaults to 0.
-dna <dna> The destination node address of the target. Defaults to 0xFE.
-sna <sna> The source node address to set in the RMAP packets. Defaults to 32.
-dkey <key> The destination key used by the targets RMAP interface. Defaults to 0.
-clkdiv <div> Divide the transmitter bit rate by div. If not specified, the current setting
is used.
Example
The following example shows how to connect to a target which has the SpaceWire default node
address 0xFE using virtual link 0:
grmon -gresb -ip 192.168.0.50 -dna 0xfe -sna 32 -link 0
Since the default routing table routes packets with node address 0xFE to SpaceWire link 0 and packets
with node address 32 to virtual link 0 this command can be used without modifying the default rout-
ing table.
It is also possible to connect with GRMON using the USB port of the bridge. Use the -grusb switch
instead of -gresb and leave out -ip and -sna. Before connecting through USB the bridge needs to be
reset and the USB cable connected. Wait until the GRESB has booted (10 s) before starting GRMON.
The bridge needs to be reset when switching between using USB and ethernet and the USB cable
needs to be plugged in after the reset.
When using USB the GRMON binary has to be owned by the superuser (root) and have s (set user or
group ID on execution) permission bit set (chmod +s grmon).
The server binary on the CD is named spw_tunn_serv and has the possible command line parameters
listed in table 15.
Parameter Description
-ip <ip> The IP address of the GRESB to which the server shall connect.
-link <nr> The virtual link of the GRESB to which the server shall connect. Default 0.
-log <log file> Enable the packet log. Each packet sent through the tunnel will be described in <log file>.
-data <data file> [P] Enable the packet data log. The content of each packet will be stored in <data file>. The for-
mat of the packet data log follows the GRESB SpW receive protocol. If the optional P is
added after the filename only the real payload will be logged, i.e. the headers as well as the
first 2 bytes of the SpW packet (node address and protocol id) will not be stored.
Parameter Description
-ip <ip> The IP address of the GRESB to which the client shall connect.
-link <nr> The virtual link of the GRESB to which the client shall connect. Default 0.
-rip <rip> The IP of the host running the server application.
-log <log file> Enable the packet log. Each packet sent through the tunnel will be described in <log file>.
-data <data file> [P] Enable the packet data log. The content of each packet will be stored in <data file>. The for-
mat of the packet data log follows the GRESB SpW receive protocol. If the optional P is
added after the filename only the real payload will be logged, i.e. the headers as well as the
first 2 bytes of the SpW packet (node address and protocol id) will not be stored.
And leave out the -rip parameter when connecting with the client. This makes the client connect to the
ports on the localhost (127.0.0.1) which are listened on by the SSH application. SSH forwards any
data sent by the client to the server and vice versa.
On the network configuration page DHCP or static configuration can be selected and the static ip/net-
mask can be specified. These settings are stored in flash when the submit button is pressed. For the
changes to take effect the bridge needs to be rebooted which can be done by pressing the “Reboot”
checkbox on the page before pressing submit. Figure 9 below shows this page.
From the routing table configuration page the whole routing table can be viewed and any entry can be
modified too suit the user’s needs. It is also possible to reset the table to its default state. Please note
17
that any changes made to the routing table through the socket interface will not show up on the web
interface until they have been saved.
It is possible to update the GRESB’s firmware through the web interface. Updates will be made avail-
able on Gaisler Research’s web site. The firmware images are protected by a checksum and will be
stored in RAM and validated before programmed to flash memory. It is very important not to turn the
power off while the flash is being programmed. Always wait until confirmation has been given that
the programming is done.
18
4.1 Overview
When the bridge is equipped with a CAN controller it uses the ports listed in table 17 in addition to
the previously listed ports.
Port Function
4000 CAN transmit
4001 CAN receive
Data received on the CAN transmit port will be interpreted based on the first byte which acts as a pro-
tocol ID. Table 18 lists the available protocols. The receive port must only be read from and the data
received is always (protocol 0) messages.
The CAN bridge have receive and transmit buffers which buffer up to 200 CAN messages of maxi-
mum size. When the receive buffer is full any incoming messages will be lost.
Protocol ID Description
0 Message transmission protocol
1 Configuration protocol
2 Status protocol
Bits (MSB-LSB)
Byte # Description 7 6 5 4 3 2 1 0
0 Protocol ID = 0 Prot ID 7-0
1 Control FF RTR - - DLC (max 8 bytes)
2-5 ID (32 bit word in network byte ID 28-0 (bits 31-29 are ignored)
order)
6-13 Data byte 1 - DLC Data byte n 7-0
The control byte specifies Frame Format (FF), standard (FF=0) or extended (FF=1), Remote Transmit
Request frame (RTR=1) and the Data Length Code (DLC). The 4 byte ID field holds the CAN identi-
fier and should use a maximum of 11 bits for standard frames and 29 bits for extended. As many data
bytes as specified by the DLC must be sent/read to finish the transfer.
19
After the protocol ID comes the option field which specifies what option to configure. The value to set
for this option is specified in a 4 byte field which needs to be in network byte order when sent. Avail-
able options are listed in table 20.
Option Description
0 Configure bus timing
1 Configure acceptance code
2 Configure acceptance mask
These configurations all use a synchronization jump width of 3 and has a single sample point located
at 68-70% of the bit time.
The baud rate in KBps should be specified in the value field as a 4 byte word in network byte order.
Any other value than those listed above are interpreted as a direct setting of BTR0 and BTR1, e.g. if
value is 0x807F then BTR0 will be set to 0x80 and BTR1 to 0x7F.
The CAN bus bit period is determined by the CAN system clock and time segment 1 and 2 as shown
in the equations below:
ttseg1 = tscl * (TSEG1+1)
ttseg2 = tscl * (TSEG2+1)
tbit = ttseg1 + ttseg2 + tscl
The additional tscl term comes from the initial sync segment.
Sampling is done between TSEG1 and TSEG2 in the bit period.
When receiving a standard frame the code is compared against the incoming message in the following
way:
Bits 31-21 are compared to ID.28-18
Bit 20 is compared to the RTR bit.
Bits 19 -16 are unused.
Bits 15-8 are compared to data byte 1.
Bits 7-0 are compared to data byte 2.
The corresponding bits of the mask selects if the results of the comparison doesn’t matter. A set bit in
the mask means don’t care.
When receiving an extended frame the comparison works in the following manner:
Bits 31-3 are compared to ID.28-0
Bit 2 is compared to the RTR bit.
Bits 1-0 are unused.
The corresponding bits in the mask selects if the results of the comparison doesn’t matter. A set bit in
the mask means don’t care.
21
1 byte 1 byte
Prot=2 option=0
The status web page on a CAN equipped bridge also displays this information.
SR is the contents of the CAN controller status register and it has the bit interpretation shown in table
24.
The baud rate is sent as two bytes (MSB first). If it does not match one of the pre configured values it
should be interpreted as BTR0 followed by BTR1.
TXERR and RXERR are the values of the CAN controller’s transmit and receive error counters.
The error code is the value of the CAN controller’s Error Code Capture register which should be inter-
preted as below.
When a bus error occurs the error code capture register is set according to what kind of error occurred,
if it was while transmitting or receiving and where in the frame it happened. The ECC register will not
change value until it has been read out.
ECC.7-6 Description
0 Bit error
1 Form error
2 Stuff error
3 Other
ECC.4-0 Description
0x03 Start of frame
0x02 ID.28 - ID.21
0x06 ID.20 - ID.18
0x04 Bit SRTR
0x05 Bit IDE
0x07 ID.17 - ID.13
0x0F ID.12 - ID.5
0x0E ID.4 - ID.0
0x0C Bit RTR
0x0D Reserved bit 1
0x09 Reserved bit 0
0x0B Data length code
0x0A Data field
0x08 CRC sequence
0x18 CRC delimiter
0x19 Acknowledge slot
0x1B Acknowledge delimiter
0x1A End of frame
0x12 Intermission
0x11 Active error flag
0x16 Passive error flag
0x13 Tolerate dominant bits
0x17 Error delimiter
0x1C Overload flag
4.5 Software
An API for communicating with the CAN equipped bridge and example applications are provided on
the CD.
23
5 Interfaces
The CAN connector conform to the recommendations of CiA-DS-102 and CiA DR-303-1. The phys-
ical driver is SN65HVD230, which is compatible with the requirements of the ISO-11898-2 standard
two-wire balanced signaling scheme, supporting speeds up to 1 Mbps. End node termination is pro-
vided using 120 Ohm (nominal) resistance.
Information furnished by Aeroflex Gaisler is believed to be accurate and reliable.
However, no responsibility is assumed by Aeroflex Gaisler for its use, nor for any infringements of patents or
other rights of third parties which may result from its use.
No license is granted by implication or otherwise under any patent or patent rights of Aeroflex Gaisler.