• Stars
    star
    211
  • Rank 186,867 (Top 4 %)
  • Language
    C
  • License
    Other
  • Created almost 12 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Etnaviv is a project to build a FOSS driver for the Vivante GCxxx series of embedded GPUs - laanwj's personal fork - upstream is https://github.com/etnaviv/etna_viv

Introduction

Project Etnaviv is an open source user-space driver for the Vivante GCxxx series of embedded GPUs.

This repository contains reverse-engineering and debugging tools, and rnndb register documentation. It is not necessary to use this repository when building the driver.

Instead, use:

SoCs with Vivante GPU

ARM-based:

  • Marvell 88SV331x has a GC530
  • Marvell Armada 510 has a GC600: CuBox
  • Marvell Armada 610 has a GC860: OLPC XO-1.75
  • Marvell Armada 1500 has a GC1000: Google TV
  • Marvell PXA2128 has a GC2000 (OLPC XO-4)
  • Rockchip 2918 has a GC800: some Arnova tablets
  • Freescale i.MX6 Quad and Dual have a GC2000 + GC320 + GC355
  • Freescale i.MX6 QuadPlus and DualPlus have a GC3000 + GC320 + GC355
  • Freescale i.MX6 DualLite and Solo have a GC880 + GC320
  • Freescale i.MX6 SoloLite has GC320 + GC355 (no 3D)
  • Actions Semiconductor ATM7029 has a GC1000

MIPS-based:

  • Ingenic JZ4760 has a GC200 (2D only)
  • Ingenic JZ4770 has a GC860: GCW Zero

See also wikipedia.

For the Vivante GPUs on many platforms feature bits have been determined, these can be found in doc/gpus_comparison.html.

Contents

The repository contains various tools and documentation related to figuring out how to program Vivante GCxxx GPU cores.

Debugging support

Etnaviv comes with a GDB plugin for etna driver debugging. GDB 7.5+ with Python support (usually enabled by default in distributions) is needed for it to work. This plugin adds a few custom commands.

Usage (from gdb):

source /path/to/etnaviv_gdb.py

Commands:

  • gpu-state [<prefix>] gpu-state uniforms

    Show full GPU state by default or a subset of the registers with a certain prefix. The special prefix 'uniforms' shows the shader uniforms.

  • gpu-dis

    Disassemble the currently bound fragment and vertex shaders.

  • gpu-trace

    Trace and dump all submitted command buffers. This is similar to dumping to FDR (using one of the hook mechanisms) and then running dump_cmdstream, however this works on the fly.

    Along with each command the physical address is printed, this should come in handy for searching back the physical address that the GPU is stuck on according to the kernel.

    Usage: gpu-trace <on|off> Enable/disable cmdbuffer trace gpu-trace stop <on|off> Enable/disable stopping on every commit gpu-trace output stdout Set tracing output to stdout (default) gpu-trace output file Set tracing output to file

These commands automatically find the gallium pipe and screen from the current Mesa context.

State map

Map of documentation for known render state and registers. Mapped in rules-ng-ng (envytools) format:

rnndb/state.xml     Top-level database, global state
rnndb/state_hi.xml  Host interface registers
rnndb/state_2d.xml  2D engine state
rnndb/state_3d.xml  3D engine state
rnndb/state_vg.xml  VG engine state (stub)
rnndb/state_common.xml  Common, shared state defines

Other scattered bits of documentation about the hardware and ISA can be found in doc/hardware.md.

ISA documentation

Vivante has a unified, fixed-size, predictable instruction format with explicit inputs and outputs. This does simplify code generation, compared to a weird flow pipe system like the Mali 200/400. Shader (both vertex and fragment) instruction set description in rules-ng-ng format can be found here:

rnndb/isa.xml

Some written down notes, and examples of disassembled shaders can be found here:

doc/isa.md

Assembler and disassembler

A basic disassembler for the shader instructions (to a custom format) can be found in the tools directory:

tools/disasm.py <shader.bin>

This can be used to disassemble shaders extracted using dump_cmdstream.py --dump-shaders.

There is also an assembler, which accepts the same syntax that is produced by the disassembler:

tools/asm.py <shader.asm> [-o <shader.bin>]

Command stream format

Like other modern GPUs, the primary means of programming the chip is through a command stream interpreted by a DMA engine. This "Front End" takes care of distributing state changes through the individual modules of the GPU, kicking off primitive rendering, synchronization, and also supports basic flow control (branch, call, return).

Most of the relevant bits of this command stream have been deciphered.

The command stream format represented in rules-ng-ng XML format can be found here:

rnndb/cmdstream.xml

Command stream interception

A significant part of reverse engineering was done by intercepting command streams while running GL demos and examples.

Command stream interception functionality (libvivhook and viv_interpose.so) moved to the libvivhook repository. The tools to parse and dump intercepted command streams will remain in this repository.

Command stream dumper

Other tools live in:

tools/

The most useful ones, aside from the assembler and disassembler mentioned before are:

  • dump_cmdstream.py Decodes and dumps the intercepted command stream in human readable format, making use of rnndb state maps.

  • fdr_dump_mem.py Extract areas of video memory, images, and command buffers at certain points of execution.

Vivante GPL kernel drivers

These have been moved to https://github.com/etnaviv/vivante_kernel_drivers

Envytools fork

Envytools is a set of tools aimed at developers of the open source NVIDIA driver Nouveau, however some parts such as rnndb can be applied more generally. The repository contains a slightly modified subset of envytools for header generation from the state / command stream / ISA rnndb files, so they can be used from the C code (etna), build with

cd envytools
mkdir build
cd build
cmake ..
make
cd ../..

Then generate the headers with

rnndb/gen_headers.sh

Contact

There is a freedesktop.org mailing list for the project.

There is also a Google group for development discussion for this project at etnaviv-devel, but we are in process of switching to the above freedesktop mailing list.

We usually hang out in #etnaviv on irc.freenode.net.

Authors

  • Wladimir J. van der Laan
  • Steven J. Hill (kernel driver help)
  • Christian Gmeiner (beginnings of GC2000 support)
  • MichaÅ‚ ÅšciubidÅ‚o (GC880 support)
  • Maarten ter Huurne (GCW kernel driver, v4_uapi interface)

Thanks

  • Luc Verhaegen (libv) of Lima project (basic framework, general idea)
  • Nouveau developers (rnndb, envytools)

More Repositories

1

k210-sdk-stuff

Kendryte K210 / MaixGo stuff
C
132
star
2

decuda

Decuda and cudasm, the CUDA binary utilities package. Low-level tools for NVidia G80 GPUs.
Python
87
star
3

bitcoin-submittx

Stand-alone Bitcoin transaction submission tool
Python
71
star
4

cln4rust

Crate that provides an RPC binding from rust code to the c-lightning daemon
Rust
60
star
5

sundog

A port of the Atari ST game SunDog: Frozen Legacy (1984) by FTL software
C
59
star
6

bitcoin-qt

Original Bitcoin-Qt repository. No longer used, Bitcoin-Qt was merged upstream.
C++
55
star
7

dwarf_to_c

Tool to recover C headers (types, function signatures) from DWARF debug data
Python
40
star
8

mesa

Laanwj's fork of the FOSS OpenGL ES1 and ES2 driver for Vivante GCxxxx series. This has been merged upstream: https://cgit.freedesktop.org/mesa/drm/ : this repo is for historical purposes only
C
26
star
9

yosys-ice-experiments

Experiments for iCEstick evaluation board with iCE40HX-1k FPGA - using open source toolchain
Verilog
14
star
10

Purecoin

Git mirror of Haskell Bitcoin implementation "Purecoin" by Russell O'Connor (darcs http://r6.ca/Purecoin)
Haskell
11
star
11

hw2view

Viewer for Relic Entertainment Homeworld 2 backgrounds
Python
10
star
12

ast_pickler

Proof of concept serialization library that generates the Python code to construct objects.
Python
9
star
13

blockdb-troubleshoot

Bitcoin block database troubleshooting tools
C++
9
star
14

gltron

gltron - patched for SDL2/etnaviv
C
8
star
15

gcw0_vpu_poc

Proof of concept for using the Ingenic JZ4770 vpu core on GCW Zero
C
8
star
16

deluge

My changes and fixes to Deluge torrent
JavaScript
7
star
17

rust-riscv-disasm

RISC-V disassembler crate for Rust
Rust
6
star
18

etnaviv_gpu_tests

Etnaviv GPU tests: This repository contains various tests for Vivante GPUs based on the Etnaviv DRM driver
C
6
star
19

pmodoled

Demo: Drive a Digilent pmodOLED module from a HiFive board through SPI
C
5
star
20

xray6502

Python
5
star
21

crcbench

Benchmark CRC32C performance with specific instructions on various architectures
C++
5
star
22

sxflash

Ethernet-based flasher/unbricker for Silex boards (such as the Belkin Homebase F5L049)
C
4
star
23

mesatest_gles

Simple Open GL ES 2 programs for exercising the etnaviv Mesa driver
C
4
star
24

guix-mes

Personal fork of GNU Mes
Scheme
3
star
25

psindustrializer

Power Station Industrializer is a program for generating percussion sounds for musical purposes
C
3
star
26

laanwj

2
star
27

linux-freedreno-a20x

Linux freedreno a20x
C
2
star
28

nips-json

Machine-readable versions of nostr NIPs tables
Python
2
star