ECPi. Assembly   View      

These instructions tell you how to assemble an ECPi Camera from an Ice Pi Zero, an Raspberry Pi Zero, some headers, a camera and a camera cable.

You need a Raspberry Pi Zero, an IcePi Zero available from CrowdSupply or Electrow, any Raspberry Pi Camera version 2 or 3, a camera cable and a male and a female header. The camera cable should convert between the standard 24 pin camera flexible printed cable socket and the Raspberry Pi Zero's 15 pin FPC socket.

Soldering

The default solution is to do soldering. Just remember that "Solder is not glue."

The standard header configuration is male headers on the RPI Zero facing up, and female headers on the PI Hat, the IcePi Zero, facing down. We do it the other way around. The RPi Zero can get very hot, so best to have it on top. Also the IcePi Zero is the more expensive component, so if you are doing risky hammer headers, or press fit, best to assenbke the expensive part with the more stable female header.

Hammer Headers

You can solder the headers, or if you are not comfortable with your soldering skills, you can use the Pimoni Hammer headers. Here is a blog posing about how to do it, scroll all the way down for how to do the female hat header. But It is hard to do the hammering right the first time.

If you are concerned about using hammer headers, here is an article reviewing the product. Basically it and the comments say that it works fine, and has some plusses and minuses. Pimoroni and the above article tested the electrical characteristics and all is fine. Be careful to apply equal pressure everywhere and to not bend the board. A vice would be the best way to do it.

Press Fit

Soldering is not practical for high volumne applications. In the automotive industry the fittings are press fit, solder does not survive temperature cycling. But the holes are a particular size, and the gold platting is a little thicker.

I am moving to the press fit approach. You just have to find the right size vice. The tricky part is the male headers. The pins do not provide stability. Adding a female to female header on them makes them much easier to align.

Note that the back of the IcePi Zero is not flat. It has two buttons and multiple resistors. So to use the hammer header techique, you need to flip it over, much like is shown at the bottom of this page.


RPi Zero Configuration   View      

There are two parts to configuring the RPI Zero. Defining the hardware connectivity and controlling the hardware.

Both are controlled from /boot/firmware/config.txt

The hardware connectivity is defined using two device tree overlays.

dpi24.dts tells the output pins to read the DPI data from the GPU. The code repository will contain dpi23.dts, where pin 4 has been excluded from the list.

If you use a shared oscillator, there is also a need for an overlay to set the pin 4 to transmit the osciallator clock.

Here is what claude.ai says to add to the config.txt file. enable_dpi_lcd=1 dpi_group=2 dpi_mode=87 dpi_output_format=0x6f005 dpi_timings=640 0 16 96 48 480 0 10 2 33 0 0 0 60 0 25000000 1 dtoverlay=dpi24x

#The dpi_timings fields in order:

# 640   — horizontal active pixels
# 0     — hsync polarity (0 = negative)
# 16    — horizontal front porch
# 96    — hsync pulse width
# 48    — horizontal back porch
# 480   — vertical active lines
# 0     — vsync polarity (0 = negative)
# 10    — vertical front porch
# 2     — vsync pulse width
# 33    — vertical back porch
# 0 0 0 — offsets/pixel rep (unused)
# 60    — frame rate
# 0     — interlaced (no)
# 25000000 — pixel clock (25 MHz)
# 1     — aspect ratio (4:3)

# Pixel clock is 25 MHz — close to the standard 25.175 MHz. 
# Most displays accept this.

ECPi Clocks   View      

There are three different ways to coordinate the clocks on the ECP5 and the Raspberry Pi Zero

  1. They can be in lock step, at the same frequency and in phase.
  2. They can be at the same frequency but out of phase.
  3. They can be at different frequencies.

For low frequencies the ECP5 may be able to use the RPI Zero's pixel clock. The pixel clock would drive the ECP5's PLL, which compensates for the delay introduced by the clock tree, aligning the ECP5's clock phase with the RPi's pixel clock. In reality, it may not be able to generate a PLL lock, but it is such a simple and low resource solution, that it is worth trying.

Option 2, same frequency but different phase is not possible, details in the sub section.

Option 3 is the traditional solution, it will work at higher frequencies, but it does consume some of the scarce resources on the 20K LUT ECP5 embedded in the ICEPi Zero. The basic idea is to run the two chips at different frequencies, but use Clock Domain Crossing FIFO queues to transmit data between the two chips. The FPGA then has to generate its own Vsync, HSync and blank signals. Such counters do not take up much space.


▼
 Shared Pixel Clock

▼
 Same Frequency From a Shared Clock

▼
 Clock Domain Crossing

▼
 Clock Reference Materials

ECPI Power   View      

Connecting the two boards together can fry the power circuitry. This page describes what to do, and what not to do.

There are three types of pins in the RPI Zero 40 pin header.

  • Ground. The ground pins should always be connected.
  • Power. The simple solution is to never connect power pins. Clip them.
  • Signal. This one is trickiest.

Power

The simplet solution is to always cut the power pins, but leave the ground pins in place. Then power up the IcePi Zero first, then the Raspberry Pi. Power down the Raspberry Pi, then the IcePi Zero. The reason is that the ICEPi is receiving signals, and the RPI zero has pull up down resistors, so everything should be stable on start up.

Signals

The default state for all RPi Zero Bank 0 pins will be inputs with either a pull up or pull down. The default pull state can be found in the BCM2835 peripherals specificaion section 6.2 table 6-31 (see the "Pull" column). It will require positive software configuration to change the state of these pins.

Table of altenative functions

If they have pull up or pull down resistors, there is no metastability, there is no problem.

The one exception to this rule is ID_SC and ID_SD. GPIO0 (ID_SD) and GPIO1 (ID_SC) will be switched to ALT0 (I2C-0) mode and probed for an EEPROM at boot time. These pins will revert to inputs once the probe sequence has completed.

The one problem is on pins that are used for eeprom configuration. They expect a signal, We need to set a weak pull up or pull down resiston on the FPGA. Which one? And then disable it once the system starts operating it. This command partially solves this problem.

force_eeprom_read=0

Then the two EEPROM pins start off in their default state. But GPIO1, pin 28 in default state does not have a pull up nor down resistor, so best to set it as pull up or pull down until there is a lock on the PLL.

Thank you very much for the people on Discord who raised this topic.


ECPi USB   View      

Your computer can talk to the Raspberry Pi Zero over USB using either a serial tty connection, or an ethernet connection. The later supports file transfers.

This requires editing /media/dell/bootfs/config.txt abd /media/dell/bootfs/cmdline.txt.

Add the following last line to config.txt

dtoverlay=dwc2

Claude.ai says this does the following:

The Pi Zero's USB port is wired to a chip called the DWC2 (DesignWare USB 2.0 OTG controller). "OTG" means On-The-Go — the port can act as either:

  • a USB host (like a normal PC USB port, so you can plug in a keyboard/mouse/flash drive), or
  • a USB device/peripheral (so the Pi itself appears as a USB device when plugged into another computer — a flash drive, a network adapter, a serial modem, etc.)

By default, the Pi's firmware treats that port as a host. The dtoverlay=dwc2 line loads a device tree overlay — a small chunk of hardware description that tells Linux "hey, configure the DWC2 controller to run in USB peripheral/gadget mode instead."

Once that's active, Linux's USB gadget subsystem can bind different "personalities" to that port — a network card (g_ether), a serial port (g_serial), a mass storage device (g_mass_storage), etc. dtoverlay=dwc2 just switches the controller into the mode where gadget drivers can attach; it doesn't pick which gadget by itself — that's what the modules-load=dwc2,g_serial part in cmdline.txt does.

So the division of labor is:

config.txt → tells the hardware/firmware to put the USB controller in peripheral mode cmdline.txt → tells the kernel to load the specific gadget driver (serial, in your case) on top of it

cmdline.txt — this is one single line, no newlines. Find rootwait and insert right after it:

modules-load=dwc2,g_serial

So a stock line like:

console=serial0,115200 console=tty1 root=PARTUUID=xxxxxxxx-02 rootfstype=ext4 fsck.repair=yes rootwait

becomes:

console=serial0,115200 console=tty1 root=PARTUUID=xxxxxxxx-02 rootfstype=ext4 fsck.repair=yes rootwait modules-load=dwc2,g_serial

In the future how to connect ethernet over usb will be documented.


Raspberry Pi Chips   View      

This page evaluates the Raspberry Pi Chips from the perspective of a MIPI CSI to DPI bridge. Turns out they all work fine.

RGB888 Works on all RPI chips.

Except of course the pico. The RPi GPUs have dedicated hardware to convert the MIPI CSI input into a parallel 24 bit + controls DPI output. GPIO Documentation The Raspberry Pi Zero W is recommended. The cheapest chips are the Raspberry Pi Zero, Zero W, Zero 2, and Zero 2W. The other chips are more expensive. Communicating with the device wirelessly (W versions) frees up the USB port for an addiitonal 12Mbit/second communication with the FPGA. Since the RGB signal consumes all 28 signal pins, the additional bandwidth is most useful for the FPGA driving the cameras digital zoom. The Zero W is recommended over the Zero 2W. The Zero W is 32 bit the Zero 2 W is 64 bit, so its programs consume more of the scarce RAM.

BCM2835 used in the Raspberry Pi Zero, Raspberry Pi Zero W, Raspberry Pi Zero. The data sheet now does not even list the alternative functions.

RP3A0 used in the Raspberry Pi Zero 2 W, Raspberry Pi Zero 2 W with headers. The GPCLK0-2 overlap with the DPI0-2. Are those he high order bits, and there is a problem, or the low order bits and all is well. But it does not matter, they do that thing where the frequency jumps by 1 bit.

BCM2711: used in the compute module 4. Datasheet The GPCLK0-2 overlap with the DPI0-2. Are those he high order bits, and there is a problem, or the low order bits and all is well.

BCM2712 is the 16nm application processor used in Raspberry Pi 5, 500, 500+, and Compute Module 5.

Here is the documentation


Raspberry Pi Zero or Zero 2W?   View      

This 12 minute video is an excellent technical comparison of the two products.


Raspberry Pi Zero Details   View      

Lots of technical details and links about the Raspberry Pi Zero.

There are multiple versions of the Raspberry Pi Zero (RPI0). We recommend using the 32 bit $10 Raspberry Pi Zero which has one BCM2835 core, running the ARM1176JZF-S cpu and using these peripherals. One core is enough for this application. It is the GPU which does all of the work.

More information about the internal details can be gained from the C++ Circle library for bare metal RPI applications.

You could also choose to use the $15-20 Raspberry Pi Zero 2W w which has 4 cores using more power, but it is a 64 bit machine so its code takes up more space leaving less room for your application. Designations "H" or "with headers" means that the part comes with presoldered headers.

The Raspberry Pi form factor header has 40 header pins, with 12 power and ground pins leaving 28 pins for the 24 bit DPI output, clock, horizontal sync, vertical sync and blank. That supports RGB888.

Problem with the Raspberry Pi 4 clock


IcePi Zero's DVI Demo   View      

The IcePi Zero's DVI demo will not scale to larger resolutions.

The IcePi Zero’s DVI demo generates a 640 x 480 pixel image using a 25Mhz Pixel clock, a 250MHz TMDS clock, and a Single Data Rate (SDR) signal. The ECP5 PLL has a maximum VCO of 800 MHz, meaning that this approach would only scale to a 3x higher pixel clock. In reality, it would not even reach that number. The published maximum frequency for ECP5 is 400 Mhz, but with over clocking it can go higher. ULX3S’s DVI demo maximum output is 1920x1200@50Hz pixel clock 600Mhz TMDSa clock. But that is on a 6 layer board with better signal integrity than the IcePi Zero’s 4 layer board. Maybe IcePi Zero could double its pixel clock, but tripling would not work. Instead it needs to be rewritten with a Double Data Rate (DDR) approach. The best approach would be to port SplineDrive to the IcePi Zero, and then update both the upstream SplineDrive and the original IcePi Zero repositories.

The reason to not use the ULX gateware is that the code is in VHDL with a Verilog wrapper. Best to have everything in the same language.



Built with the Forest WIki.
User contributed content is licensed under a Creative Commons CC By 4.0 License.