All Projects → gergoerdi → chirp8-avr

gergoerdi / chirp8-avr

Licence: other
CHIP-8 implementation in Rust targeting AVR microcontrollers

Programming Languages

rust
11053 projects
C++
36643 projects - #6 most used programming language
c
50402 projects - #5 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to chirp8-avr

Tinygo
Go compiler for small places. Microcontrollers, WebAssembly (WASM/WASI), and command-line tools. Based on LLVM.
Stars: ✭ 9,068 (+22570%)
Mutual labels:  avr, microcontroller
Xpcc
DEPRECATED, use our successor library https://modm.io instead
Stars: ✭ 177 (+342.5%)
Mutual labels:  avr, microcontroller
Avr Cheat Sheet
AVR cheat sheet for the ATmega328p
Stars: ✭ 64 (+60%)
Mutual labels:  avr, microcontroller
Platformio Core
PlatformIO is a professional collaborative platform for embedded development 👽 A place where Developers and Teams have true Freedom! No more vendor lock-in!
Stars: ✭ 5,539 (+13747.5%)
Mutual labels:  avr, microcontroller
DemOS
Free, simple, extremely lightweight, stackless, cooperative, co-routine system (OS) for microcontrollers
Stars: ✭ 18 (-55%)
Mutual labels:  avr, microcontroller
Minicore
Arduino hardware package for ATmega8, ATmega48, ATmega88, ATmega168, ATmega328 and ATmega328PB
Stars: ✭ 546 (+1265%)
Mutual labels:  avr, microcontroller
Avr8js
Arduino (8-bit AVR) simulator, written in JavaScript and runs in the browser / Node.js
Stars: ✭ 102 (+155%)
Mutual labels:  avr, microcontroller
terminal
Terminal inside the microcontroller (cli for mcu)
Stars: ✭ 31 (-22.5%)
Mutual labels:  avr, microcontroller
xForth
Experimental Forth cross compiler for tiny devices
Stars: ✭ 53 (+32.5%)
Mutual labels:  avr, microcontroller
IntrOS
Free cooperative operating system (OS) for microcontrollers
Stars: ✭ 38 (-5%)
Mutual labels:  avr, microcontroller
Mightycore
Arduino hardware package for ATmega1284, ATmega644, ATmega324, ATmega324PB, ATmega164, ATmega32, ATmega16 and ATmega8535
Stars: ✭ 413 (+932.5%)
Mutual labels:  avr, microcontroller
DigiOS
Mini OS emulator for Digispark (an Attiny85 based microcontroller).
Stars: ✭ 46 (+15%)
Mutual labels:  avr, microcontroller
Modm
modm: a C++20 library generator for AVR and ARM Cortex-M devices
Stars: ✭ 375 (+837.5%)
Mutual labels:  avr, microcontroller
Attinycore
Arduino core for ATtiny 1634, 828, x313, x4, x41, x5, x61, x7 and x8
Stars: ✭ 974 (+2335%)
Mutual labels:  avr, microcontroller
Great-Cow-BASIC-Demonstration-Sources
Demonstration files for Great Cow BASIC - a compiler for Microchip and AVR 8-bit microcontrollers
Stars: ✭ 18 (-55%)
Mutual labels:  avr, microcontroller
Reactorforge
High power induction heating platform
Stars: ✭ 90 (+125%)
Mutual labels:  avr, microcontroller
Blog
A set of various projects based on ESP8266, ESP32, ATtiny13, ATtiny85, ATtiny2313, ATmega8, ATmega328, ATmega32, STM32 and more.
Stars: ✭ 198 (+395%)
Mutual labels:  avr, microcontroller
libavrutil
Easy to use, lightweight and unified library for performing common microcontroller tasks
Stars: ✭ 21 (-47.5%)
Mutual labels:  avr, microcontroller
avr-ds18b20
AVR library for controlling DS18B20 temperature sensors
Stars: ✭ 52 (+30%)
Mutual labels:  avr, microcontroller
risc8
Mostly AVR compatible FPGA soft-core
Stars: ✭ 19 (-52.5%)
Mutual labels:  microcontroller

CHIP-8 implementation for a very simple breadboard toy

This is a CHIP-8 virtual machine implementation running on AVR.

Its big party trick is that it is written in Rust: it is the first non-trivial Rust application running on AVR. You can read about its development process in my blog post. The CHIP-8 VM itself is implemented in a separate, portable crate written in idiomatic Rust fashion, heavily using algebraic data types and pattern matching; this crate can then be used both to build an SDL-based desktop app and also this crate running on AVR microcontrollers.

The intended hardware is a simple circuit with very few components:

  • AVR ATMega328P microcontroller
  • PCD8522 84x48 monochrome LCD
  • Microchip 23K640 serial RAM
  • 4x4 keypad
  • 10K resistors (4 pcs)
  • 10K trimpot

All of these components come in throughhole versions so it is very easy to build it on a breadboard. NOTE THE RAM CHIP DOESN'T SUPPORT 5 Volts. The board is meant to be powered at 3.3 Volts. An Arduino Uno is going to fry the RAM chip.

Schematics Photo of breadboard version

Building

AVR support in Rust is not yet available its mainline version, and there are some questionable hacks that I had to add to work around some compiler bugs and missing features. All this means you'll need to build very specific versions of LLVM and Rust to be able to compile this crate. Also, because of some remaining bugs in the LLVM AVR backend, Rust's stock libcore cannot be compiled yet; we need to use Xargo to link to a slightly stripped down version.

1. Build branch of LLVM with AVR support + kludges

$ git clone -b avr-rust-demo https://github.com/avr-rust/llvm.git llvm-avr
$ mkdir -p build/llvm
$ cd build/llvm
$ cmake ../../llvm-avr -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=AVR -DLLVM_TARGETS_TO_BUILD=X86
$ make
$ cd ../...

2. Build branch of rustc with AVR support

$ git clone -b avr-support https://github.com/avr-rust/rust.git rust-avr
$ mkdir -p build/rust
$ cd build/rust
$ ../../rust-avr/configure --llvm-root=$(realpath ../llvm)
$ make
$ cd ../..

3. Register freshly-built Rust AVR toolchain with rustup (needed to work around a Xargo bug)

$ rustup toolchain link avr-toolchain $(realpath build/rust/build/x86_64-unknown-linux-gnu/stage1
$ rustup default avr-toolchain

4. Build chip8-avr and all its dependencies using Xargo

$ git clone https://github.com/gergoerdi/rust-avr-chip8-avr chip8-avr
$ cd chip8-avr
$ sh build.sh

Running

The above process will result in the AVR ELF executable target/avr-atmega328p/release/chip8-avr.elf. This executable can be uploaded to the ATMega328P via an AVR programmer; or if you use something like an Arduino Pro 3.3V or an Adafruit Trinket Pro 3.3V, you can upload it directly via USB.

Another way of trying it out is simulation: I've implemented a SimAVR-based simulator for the above schematics that almost runs in real time, as an interactive SDL app.

What's next?

There is no shortage of Rust and LLVM bugs and missing features in the AVR backends, if you want to help out.

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].