Trying embedded Rust on the Pinecil GD32VF103 RISC-V device.

Overview

Pinecil GD32VF103 RISC-V Rust Demos

Pinecil running OLED demo animation

My personal collection of Rust demos running on the PINE64 Pinecil portable soldering iron, featuring a GD32VF103TBU6 Risc-V microcontroller.

I do not guarantee the correctness of any code in this repository.

How to use

Prerequisite

Obviously you'll need a Pinecil and a computer, and the USB Type-C cable to connect the two.

A not-too-outdated Rust compiler is expected. I am using rustc 1.50.0.

You need to add the relevant Rust compiler target:

$ rustup target add riscv32imac-unknown-none-elf

You will also need a GNU binutils objcopy capable of producing a raw binary file from an ELF file for flashing. Generally any objcopy tools should work, but I've mostly been using riscv-nuclei-elf-objcopy from the Nuclei RISC-V toolchain.

At last, you will need a tool to flash the resulting binary onto the device. If you have ever updated the firmware of your Pinecil, you should already have such a tool.

Optional goodies

  • An official Pinecil breakout board is strongly recommended since it allows you to connect the UART and/or a JTAG debugger.
  • A device to connect to the 3.3V UART is needed to make use of the UART, such as a USB to UART adapter, a single board computer like Raspberry Pi, or even an Arduino. Beware that if using a 5V UART device, you should not connect the TX pin of your device to the RX pin of the Pinecil directly, as the RX pin on the Pinecil is not 5V-tolerant. You can use a resistor voltage divider to convert the voltage level.
  • It may be nice to have a debugging setup using a JTAG debugger. If you use a JTAG, you probably also want OpenOCD and GDB. (Also check out my notes on connecting JTAG.)
  • An LED and a current-limiting resistor can be used to provide a binary output, as a simple indicator, or just to get started with a simple blinking LED demo.
  • Jumper wires with DuPont connectors to connect the pins, and a breadboard to go with it.
  • A multimeter is almost necessary for any electronics work.
  • A digital oscilloscope or a logic analyzer can also come in handy.

Running the demos

Building a demo is simple. This:

$ cargo build -p demo-00-blinky-raw-pointer --release

... will build the demo "00-blinky-raw-pointer" and produce the ELF file target/riscv32imac-unknown-none-elf/release/demo-00-blinky-raw-pointer.

To produce a flashable firmware binary, use objcopy:

$ riscv-nuclei-elf-objcopy -O binary target/riscv32imac-unknown-none-elf/release/demo-00-blinky-raw-pointer firmware.bin

The resulting firmware.bin can be flashed with dfu-util or the "GD32 Dfu Tool". The official firmware updater is also capable of flashing the file, since it uses dfu-util under the hood.

In the folder of each demo there is a readme file which provides some background information and special instructions.

Further reading

Licence

All code and resources in this repository are released under the MIT License, unless otherwise specified.

Rust and the Rust logo are trademarks owned by the Rust Foundation.

Ferris the crab is created by Karen Rustad Tölva and has been released into the Public Domain.


Copyright (c) 2021 Alvin Wong

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

You might also like...
A library for extracting #[no_mangle] pub extern "C" functions (https://docs.rust-embedded.org/book/interoperability/rust-with-c.html#no_mangle)

A library for extracting #[no_mangle] pub extern "C" functions In order to expose a function with C binary interface for interoperability with other p

An embedded key-value storage for learning purpose, which is based on the idea of SSTable / LSM-tree.

Nouzdb An embedded key-value storage for learning purpose, which is based on the idea of SSTable / LSM-tree. Plan Implement a memtable. Implement the

Quickly set up a `probe-run` + `defmt` + `flip-link` embedded project

app-template Quickly set up a probe-run + defmt + flip-link embedded project Dependencies 1. flip-link: $ cargo install flip-link 2. probe-run: $ # ma

Key-value store for embedded systems, for raw NOR flash, using an LSM-Tree.

ekv Key-value store for embedded systems, for raw NOR flash, using an LSM-Tree. Features None yet TODO Everything Minimum supported Rust version (MSRV

Leetcode Solutions in Rust, Advent of Code Solutions in Rust and more

RUST GYM Rust Solutions Leetcode Solutions in Rust AdventOfCode Solutions in Rust This project demostrates how to create Data Structures and to implem

Simple autoclicker written in Rust, to learn the Rust language.

RClicker is an autoclicker written in Rust, written to learn more about the Rust programming language. RClicker was was written by me to learn more ab

Rust programs written entirely in Rust

mustang Programs written entirely in Rust Mustang is a system for building programs built entirely in Rust, meaning they do not depend on any part of

Rust 核心库和标准库的源码级中文翻译,可作为 IDE 工具的智能提示 (Rust core library and standard library translation. can be used as IntelliSense for IDE tools)

Rust 标准库中文版 这是翻译 Rust 库 的地方, 相关源代码来自于 https://github.com/rust-lang/rust。 如果您不会说英语,那么拥有使用中文的文档至关重要,即使您会说英语,使用母语也仍然能让您感到愉快。Rust 标准库是高质量的,不管是新手还是老手,都可以从中

clone of grep cli written in Rust. From Chapter 12 of the Rust Programming Language book

minigrep is a clone of the grep cli in rust Minigrep will find a query string in a file. To test it out, clone the project and run cargo run body poem

Owner
alvinhochun
alvinhochun
This Repo Contains my Week Long Journey Trying to Learn Rust Programming Language 🦀.

the-rust-way This Repo Contains my Week Long Journey Trying to Learn Rust Programming Language ?? . ?? Thanks to all Wonderful Contributors Thanks a l

Kanishk Pachauri 7 Oct 20, 2022
A Rust implementation of HyperLogLog trying to be parsimonious with memory.

?? HyperLogLog-rs This is a Rust library that provides an implementation of the HyperLogLog (HLL) algorithm, trying to be parsimonious with memory. Wh

Luca Cappelletti 10 May 16, 2023
Shows how to implement USB device on RP2040 in Rust, in a single file, with no hidden parts.

Rust RP2040 USB Device Example This is a worked example of implementing a USB device on the RP2040 microcontroller, in Rust. It is designed to be easy

Cliff L. Biffle 9 Dec 7, 2022
Rust wrapper for the LeapC Ultraleap (Leap Motion) hand tracking device API.

LeapRS LeapRS is a safe wrapper for LeapC, the Leap Motion C API. It uses the generated binding provided by leap-sys. This is an API for accessing Lea

Pierre Lulé 4 Oct 10, 2022
Serialize & deserialize device tree binary using serde

serde_device_tree Use serde framework to deserialize Device Tree Blob binary files; no_std compatible. Use this library Run example: cargo run --examp

Luo Jia 20 Aug 20, 2022
rusty-riscy is a performance testing and system resource monitoring tool written in Rust to benchmark RISC-V processors.

rusty-riscy rusty-riscy is a performance testing and system resource monitoring tool written in Rust to benchmark RISC-V processors. Objectives To cre

Suhas KV 4 May 3, 2022
Low level access to T-Head Xuantie RISC-V processors

XuanTie Low level access to T-Head XuanTie RISC-V processors Contributing We welcome contribution! Please send an issue or pull request if you are rea

Luo Jia 30 Aug 24, 2022
Message Signaled Interrupts for RISC-V

RISC-V MSI Test in Rust Testing the new MSIs added by the draft Advanced Interrupt Architecture (AIA) specification. Blog Posts First blog post: 30-Ju

Stephen Marz 5 Jul 5, 2022
A fast and secure RISC-V based virtual machine

PolkaVM PolkaVM is a general purpose user-level RISC-V based virtual machine. This project is still unfinished and is a very heavy work-in-progress! D

Koute 31 Sep 4, 2023
Repo for apps for the Pocket RISC-V core for Analogue Pocket/OpenFPGA. Multiple branches.

This is a repo meant to host Rust programs for agg23's Pocket RISC-V platform. While Rust can be built out of the openfpga-litex repo directly, this r

null 3 Dec 12, 2023