All Projects → cbiffle → m4vga-rs

cbiffle / m4vga-rs

Licence: BSD-2-Clause license
VGA-style video output for STM32F4 processors, in Rust

Programming Languages

rust
11053 projects
assembly
5116 projects

Projects that are alternatives of or similar to m4vga-rs

Cortex M Quickstart
Template to develop bare metal applications for Cortex-M microcontrollers
Stars: ✭ 372 (+204.92%)
Mutual labels:  microcontroller, cortex-m, no-std
Cortex M
Low level access to Cortex-M processors
Stars: ✭ 379 (+210.66%)
Mutual labels:  microcontroller, cortex-m, no-std
Cortex M Rtic
Real-Time Interrupt-driven Concurrency (RTIC) framework for ARM Cortex-M microcontrollers
Stars: ✭ 623 (+410.66%)
Mutual labels:  microcontroller, cortex-m, no-std
alloc-cortex-m
A heap allocator for Cortex-M processors
Stars: ✭ 139 (+13.93%)
Mutual labels:  microcontroller, cortex-m, no-std
stm32f103xx
DEPRECATED
Stars: ✭ 31 (-74.59%)
Mutual labels:  microcontroller, cortex-m, no-std
Svd2rust
Generate Rust register maps (`struct`s) from SVD files
Stars: ✭ 347 (+184.43%)
Mutual labels:  microcontroller, cortex-m
Distortos
object-oriented C++ RTOS for microcontrollers
Stars: ✭ 354 (+190.16%)
Mutual labels:  microcontroller, cortex-m
rustBoot
rustBoot is a standalone bootloader written entirely in `Rust`, designed to run on anything from a microcontroller to a system on chip. It can be used to boot into bare-metal firmware or Linux.
Stars: ✭ 99 (-18.85%)
Mutual labels:  microcontroller, cortex-m
mdepx
MDEPX — A BSD-style RTOS
Stars: ✭ 17 (-86.07%)
Mutual labels:  microcontroller, cortex-m
Modm
modm: a C++20 library generator for AVR and ARM Cortex-M devices
Stars: ✭ 375 (+207.38%)
Mutual labels:  microcontroller, cortex-m
Pyocd
Open source Python library for programming and debugging Arm Cortex-M microcontrollers
Stars: ✭ 550 (+350.82%)
Mutual labels:  microcontroller, cortex-m
Tock
A secure embedded operating system for microcontrollers
Stars: ✭ 3,258 (+2570.49%)
Mutual labels:  microcontroller, cortex-m
M7M01 MuEukaron
An capability-based microkernel general-purpose operating system focusing on scalability, predictability, mixed-criticality and recoverability. THIS PROJECT IS IN PREVIEW STATE CURRENTLY
Stars: ✭ 79 (-35.25%)
Mutual labels:  microcontroller, cortex-m
zmu
zmu - Emulator for Microcontroller Systems
Stars: ✭ 70 (-42.62%)
Mutual labels:  microcontroller, cortex-m
rnk
rnk is a RTOS targeting ARM architecture.
Stars: ✭ 22 (-81.97%)
Mutual labels:  microcontroller, cortex-m
Daplink
Stars: ✭ 1,162 (+852.46%)
Mutual labels:  microcontroller, cortex-m
Utensor
TinyML AI inference library
Stars: ✭ 1,295 (+961.48%)
Mutual labels:  microcontroller, cortex-m
DemOS
Free, simple, extremely lightweight, stackless, cooperative, co-routine system (OS) for microcontrollers
Stars: ✭ 18 (-85.25%)
Mutual labels:  microcontroller, cortex-m
xForth
Experimental Forth cross compiler for tiny devices
Stars: ✭ 53 (-56.56%)
Mutual labels:  microcontroller, cortex-m
Xpcc
DEPRECATED, use our successor library https://modm.io instead
Stars: ✭ 177 (+45.08%)
Mutual labels:  microcontroller, cortex-m

m4vga-rs

Build Status

This crate provides 800x600 60fps graphics on the STM32F407 microcontroller. The observant reader will note that the STM32F407 has no video hardware, or enough RAM to hold an 800x600 color image. So how does m4vga get high-res color video out of it?

Magic.

Recording of the tunnel demo on a small monitor

This is a rewrite of my C++ library m4vgalib, plus ports of my collection of m4vgalib demos. It is still a work in progress. (If you're curious, see my notes on the port.)

(As of quite recently, several of the demos also compile for another platform without video hardware: WebAssembly.)

Why this is interesting

Mostly because it's really hard. I've got four CPU cycles per pixel to work with, and any variation in timing will corrupt the display.

The Demos

The demo main files live in m4demos/src/bin, though the core implementations of several of the demos have migrated into the fx directory.

  • conway: full-screen Conway's Game of Life at 60fps -- that's 28.8 million cell updates per second, for a budget of 5 cycles per update (not counting video generation).

  • hires_text: 80x37 text mode. Each character has adjustable foreground and background colors. This is boring to watch but technically interesting.

  • horiz_tp: generates a display calibration pattern of vertical stripes. This also demonstrates how to write a simple m4vga-based demo in 40 lines of code.

  • poly3: a tumbling dodecahedron made of solid polygons, with basic lighting.

  • rook: high-resolution 3D wireframe model with thousands of polygons, plus scrolling text. (The model is from my chess set).

  • rotozoom: old-school texture transform effect providing rotation and scaling. This is chunky (400x300) to save RAM...which is still too much data to double-buffer. This uses a trick to prevent tearing.

  • tunnel: demoscene "tunnel zoomer" effect drawing shaded textured graphics at 60fps. (This one is also 400x300, but it's hard to notice at speed.)

  • xor_pattern: fullscreen procedural texture with smooth scrolling. Demonstrates how to add a custom assembly language raster function.

Building it

All of this is tested only on Linux, but it should work on Mac -- though you'll have to translate the commands below to your package manager of choice.

Web target

I recently made the core of m4vga portable, and I'm gradually porting demos to run on WebAssembly. While this is less exciting than running on a real, resource-starved microcontroller, it gives you a way to test out the code without having to move a bunch of wires around.

First, follow the Rust WASM setup guide here. In short, you will need Rust, wasm-pack, and npm. (Debian/Ubuntu users: the ancient npm in apt will not work.)

Now:

$ wasm-pack build -- -p m4vga-wasm-demos
$ (cd www; npm run start)

Point a browser at http://localhost:8080/ and you should be able to view the demos!

Microcontroller target

You will need an STM32F407-based board to run this on; I use the STM32F4-Discovery because it's really cheap. Hook it up to a VGA connector according to my instructions for C++.

I recommend following the setup chapters from the Rust Embedded book. In particular, you need to have Rust and you need to make Rust aware of the cross compilation target we're using here:

$ rustup target add thumbv7em-none-eabihf

You will also need a GNU ARM toolchain to compile the assembly language routines. On Arch:

$ sudo pacman -S arm-none-eabi-{gcc,newlib}

On Ubuntu, the system ships an ancient version of GCC, but since we're only assembling this is okay:

$ sudo apt-get install gcc-arm-none-eabi

Now you should be able to compile everything by entering:

$ cargo build --release

This will deposit several demo binaries in target/thumbv7em-none-eabihf/release/.

And if you start openocd (tested with version 0.10) in this directory, it will pick up the openocd.cfg file automagically, and (from a separate terminal) you can flash one of the demos by typing:

$ cargo run --release --bin horiz_tp
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].