Git Product home page Git Product logo

fomu-flash's Introduction

Fomu FPGA Tools

The EVT version of Fomu is a "stretch" PCB with a Raspberry Pi header. Additionally, the factory test jig for production versions of Fomu has pins that match up with a test jig with the same pinout.

These tools can be used to control an FPGA and its accompanying SPI flash chip.

Building

To build this repository, simply run make.

Test Jig Setup

The EVT boards can be attached directly to the Raspberry Pi as a "hat". When building a test jig, attach wires according to the following image:

Raspberry Pi Pinout

The only pins that are required are 5V, GND, CRESET, SPI_MOSI, SPI_MISO, SPI_CLK, and SPI_CS.

The Pi's hardware SPI interface must be enabled in the kernel- use raspi-config or add dtparam=spi=on to /boot/config.txt and reboot before using. You can improve performance by attaching SPI_IO2 and SPI_IO3 and running fomu-flash in quad/qpi mode by specifying -t 4 or -t q.

You can get serial interaction by connecting the UART pins, but they are not necessary for flashing.

Loading a Bitstream

The most basic usecase is to load a program into configuration RAM. This is a very quick process, and can be used for rapid prototyping.

To load top.bin, use the -f argument:

# ./fomu-flash -f top.bin

This will reset the FPGA, reset the SPI flash, load the bitstream into the FPGA, and then start running the program.

Programming SPI Flash

To write a binary file to SPI flash, use -w:

# ./fomu-flash -w top.bin   # Write top.bin to SPI Flash
# ./fomu-flash -r           # Reset the FPGA

This will erase just enough of the SPI to hold the new binary file, then flash the binary to SPI.

It will not reset the FPGA. To do that, you must re-run with -r.

Verifying SPI flash

You can verify the SPI flash was programmed with the -v command:

# ./tomu-flash -v top.bin

Checking SPI Flash was Written

You can "peek" at 256 bytes of SPI with -p [offset]. This can be used to quickly verify that something was written.

Patching ROM

fomu-flash supports patching ROM. To do this, you must synthesize your bitstream with a fixed random ROM contents. This is so fomu-flash has something to look for.

The Python code for this would look like:

def xorshift32(x):
    x = x ^ (x << 13) & 0xffffffff
    x = x ^ (x >> 17) & 0xffffffff
    x = x ^ (x << 5)  & 0xffffffff
    return x & 0xffffffff

def get_rand(x):
    out = 0
    for i in range(32):
        x = xorshift32(x)
        if (x & 1) == 1:
            out = out | (1 << i)
    return out & 0xffffffff

def get_bit(x):
    return (256 * (x & 7)) + (x >> 3)

And the corresponding C code looks like:

uint32_t xorshift32(uint32_t x)
{
	/* Algorithm "xor" from p. 4 of Marsaglia, "Xorshift RNGs" */
	x = x ^ (x << 13);
	x = x ^ (x >> 17);
	x = x ^ (x << 5);
	return x;
}

uint32_t get_rand(uint32_t x) {
    uint32_t out = 0;
    int i;
    for (i = 0; i < 32; i++) {
        x = xorshift32(x);
        if ((x & 1) == 1)
            out = out | (1 << i);
    }
    return out;
}

static uint32_t fill_rand(uint32_t *bfr, int count) {
    int i;
    uint32_t last = 1;
    for (i = 0; i < count / 4; i++) {
        last = get_rand(last);
        bfr[i] = last;
    }
    return i;
}

Currently, fomu-flash only supports 8192-byte ROMs, though there is no reason why it can't be extended to other sizes.

Specify a ROM to load on the command line with -l.

fomu-flash's People

Contributors

xobs avatar tari avatar osresearch avatar mattvenn avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.