Skip to content

Latest commit

 

History

History
324 lines (219 loc) · 14.7 KB

readme.md

File metadata and controls

324 lines (219 loc) · 14.7 KB

Logo

PiWire

A comphrehensive guide to installing/utilizing PiWire

SatCat5 GitHub · Contributing to SatCat5 · General SatCat5 FAQ's

Table of Contents
  1. About The Project
  2. Getting Started
  3. Software Installation
  4. Supplemental
  5. Troubleshooting

About The Project

Pi-Wire is a tool that turns a Raspberry Pi into a SatCat5 adapter. It allows a conventional Ethernet network to connect directly to a SatCat5 device, using either SPI or UART protocols. This allows a low-cost adapter to connect a conventional Ethernet network to a SatCat5 switch or a SatCat5 device.

The name is intended to indicate that the device acts as close as possible to a wire. Ideally, it simply allows every packet through, verbatim, and doesn't act like an independent device.

Initial development was by 2019 summer interns Henry Haase and Louis Stromeyer and continued by 2021 summer intern Giuliana Hofheins. Current point of contact is Alex Utter.

The instructions below assume a Raspberry Pi 3+ running stock Raspbian (2021 May 7 build).

Getting Started

Components and Materials

Raspberry Pi Configuration

  1. If the heatsinks are not preinstalled on the SoC, memory, and GPU, they should be applied so the Raspberry Pi does not thermal throttle. The heat sinks are included in the Canakit package. Peel off the underside of the heat sinks and apply as shown below.

heatsinks

  1. Install the coin cell into the RTC module, with the positive terminal of the battery aligned with the positive marking on top of the PiRTC.

RTC

  1. Download Raspberry Pi Imager and Raspberry Pi OS. "Raspberry Pi OS with desktop and recommended software" is the reccomended OS.

  2. Plug in the USB SD card reader into PC, with the 32 CB microSD card inserted. Open the Raspberry Pi Imager, and etch the OS onto the microSD card. Eject after installation is finished.

imager

  1. Place the 32 GB microSD into it's slot on the bottom of the Pi. Proceed by hooking up the monitor into the microHDMI0 port and the keyboard/mouse into USB 2/3 ports. Once the power source is plugged into the USB C, the Pi should immediately boot.

Arty FPGA Configuration

  1. Connect the Raspberry Pi and the Arty FPGA by using male to female jumper wires, the Raspberry Pi pins and the PMOD ports found on the FPGA.
Default Pinout for Protocols
PMOD Pins UART Mode SPI Mode
PMOD 1 CTSb = RPi pin 6 (Ground) CSb = RPi pin 24 (SPI0-CS0)
PMOD 2 TxD = RPi pin 8 (UART0-Tx) MOSI = RPi pin 19 (SPI0-MOSI)
PMOD 3 RxD = RPi pin 10 (UART0-Rx) MISO = RPi pin 21 (SPI0-MISO)
PMOD 4 RTSb = No-connect / Unused SCK = RPi pin 23 (SPI0-SCLK)
PMOD 5 GND = RPi pin 14 (Ground) GND = RPi pin 25 (Ground)
PMOD 6 VCC = No-connect / Unused VCC = No-connect / Unused

Software Installation

  1. Download code as zip file from SatCat5 Repository. Extract all files once downloaded.

github

  1. The easiest way to run Pi-Wire is to build it using the Raspberry Pi itself. Open the Raspberry Pi terminal. From the /test/pi_wire folder, compile and run using the following commands:
pi@raspberrypi:~ $ cd /home/pi/Desktop/satcat5-main/test/pi_wire $ make all
pi@raspberrypi:~/Desktop/satcat5-main/test/pi_wire $ sudo ./pi_wire both

compileterminal

  1. At this point, "both" can be replaced by "spi" or "uart" depending on protocol preference. ** Note, adjust path as needed depending on where the code is stored. Easiest way to confirm path is to copy it by right clicking on "test" folder in the Pi file finder. At this point, the program is running accordingly!

Supplemental

Oscilloscope Visualization

An oscilloscope is an electronic device that graphically displays signal voltages as a function of time. To visualize transmitted bytes and confirm the Raspberry Pi is sending data, the oscilloscope can be connected to correct GPIO pins for either SPI or UART protocols

  1. Acquire an oscilloscope and probes. Connect the probes into channels one and two on the scope.
Oscilloscope/Pi Connections
Scope Channel UART mode SPI Mode
Channel 1 TxD = RPi pin 8 (UART0-Tx) SCK = RPi pin 23 (SPI0-SCLK)
Channel 2 RxD = RPi pin 10 (UART0-Rx) MISO = RPi pin 21 (SPI0-MISO)
  1. To confirm data is being sent over UART Raspberry Pi pins with an oscilloscope, first connect hardware using information from the above table.

  2. From Raspberry Pi terminal, run the following command. The "50" is the baud rate, and can be adjusted to any of the typical rates (110, 300, 600,1200, 2400, 4800, 9600, 14400, 19200, 38400, 57600, 115200, 128000).

pi@raspberrypi:~ $ stty /dev/ttyAMA0 50
  • Note: Some of the higher baud rates will be more difficult to visualize on the scope. It is recommended to use between 50-9600.
  1. Choose "autoset" on the oscilloscope. It will most likely be on a timescale too small to visualize packets, so adjust with the third channel knob.

  2. To send a specific packet, run the following commands. The contents of the echo can be any string of characters. These bytes will be displayed on the scope as high/low voltages.

pi@raspberrypi:~ $ stty /dev/ttyAMA0 50
pi@raspberrypi:~ $ echo "asdfghjkl" > /dev/ttyAMA0
  • Note: At higher baud rates these packets resemble spikes. Decrease time scale to visualize more clearly

packetscope

Loopback Testing

To test serial protocols, it is beneficial to utlize loopback testing. This tests the packets sent/received through shorting the transceiving/receiving pins.

SPI

This information is from Raspberry Pi SPI Loopback Testing

  1. Short the MOSI (RPi Pin 19,GPIO Pin 10) and MISO (RPi pin 21, GPIO Pin 09) pins.

short

  1. Download code from spidev-test. Confirm that spidev-test lists "spidev0.0" as the primary SPI device.
pi@raspberrypi:~ $ wget https://raw.githubusercontent.com/rm-hull/spidev-test/master/spidev_test.c
  1. Compile the code using the command;
pi@raspberrypi:~ $ gcc -o spidev_test spidev_test.c
  1. Run the code.
pi@raspberrypi:~ $ ./spidev_test -D /dev/spidev0.0

spitest1

  1. If the hex characters are are '00', SPI is not functioning. Refer to Troubleshooting if this is the case.

spitest1

Debug Verbose

To see the packets being sent/received as pi_wire is running, we can set the debugging verbosity level to different settings. In /test/pi_wire in slip.cpp, set the #define DEBUG_VERBOSE 0 to either #define DEBUG_VERBOSE 1 or #define DEBUG_VERBOSE 2. Compile and build, and be sure to run make all before running pi_wire.

debugverbose

Troubleshooting

Serial Device Configuration

  1. If any of the three initialized devices fail to initialize, verify the devices listed in lines 40-42 of main.cpp.
#define UART_DEV    "/dev/ttyAMA0"
#define ETH_DEV     "eth0"
#define SPI_DEV     "/dev/spidev0.0"
  1. Confirm that SPI is enabled using the following command;
pi@raspberrypi:~ $ ls /dev/*spi*

If /dev/spidev0.0 /dev/spidev0.1 is not outputted, then continue to "SPI configuration" SPI Configuration

  1. Run the following code. Confirm that dtparam=spi=on is uncommented.
pi@raspberrypi:~ $ sudo nano /boot/config.txt
  1. To confirm correct UART settings, run the following. Confirm that serial0 -> ttyAMA0. If not, refer to UART Configuration
pi@raspberrypi:~ $ ls -l /dev/serial*

SPI Configuration

Serial Peripheral Interfacing is not enabled by default. In order to utilize this program, please refer to the following steps.

  1. From Start Menu > Preferences > Raspberry Pi Configuration > Interfaces ensure that both SPI and Serial Port are enabled. After this, reboot to ensure that these changes take effect.

    1b. An alternative is to reconfigure through terminal.

    1. Run sudo raspi-config
    2. Select Interface Options > SPI
    3. Enable SPI Interface
    4. If it prompts you to automatically load kernel, also select yes
    5. Finish and reboot
  2. Refer back to Step 2 of Serial Device Configuration to confirm.

UART Configuration

The two UART peripherals utilized by Raspberry Pi are ttyS0 and ttyAMA0. While ttyAMA0 offers the full set of features and is the default Serial0 on earlier models of RPi, it is now used for Bluetooth purposes on the later models while the less capable ttyS0 is set aside for the Linux serial console. To utilize Pi Wire, the full set of capabilities of the serial peripheral ttyAMA0 are needed.

  1. Run sudo nano /boot/cmdline.txt from terminal. Remove console=serial0,115200.
  2. Run sudo nano /boot/config.txt. Remove or comment out enable_uart=0 and/or enable_uart=1.
  3. For RPi's with Bluetooth modules, ensure that dtoverlay=pi3-disable-bt, dtoverlay=pi3-miniuart-bt, core_freq=250 are all added to /boot/config.txt.
    1. Disable services that initializes bluetooth by running sudo systemctl disable hciuart.
  4. reboot

Test UART ports by referencing Supplemental.

Copyright Notice

Copyright 2019-2021 The Aerospace Corporation.

This file is a part of SatCat5, licensed under CERN-OHL-W v2 or later.

You may redistribute and modify SatCat5 and make products using it under the weakly reciprocal variant of the CERN Open Hardware License, version 2 or (at your option) any later weakly reciprocal version.

SatCat5 is distributed WITHOUT ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING OF MERCHANTABILITY, SATISFACTORY QUALITY, AND FITNESS FOR A PARTICULAR PURPOSE. Please see (https:/cern.ch/cern-ohl) for applicable conditions.