Skip to content

codeljo/riscv-bare-metal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


RISC-V Bare Metal Programming

Supported Devices
Requirements
Build

Supported Devices

  • ESP32-C2
  • ESP32-C3
  • ESP32-C6
  • ESP32-H2
  • Coming soon - Raspberry Pi Pico 2 (RP2350)

Requirements

  1. RISC-V Cross Compiler
  2. Make
  3. esptool

Install Cross Compiler

Linux


apt install gcc-riscv64-unknown-elf



macOS


brew tap riscv-software-src/riscv
brew install riscv-tools



Windows, macOS, Linux


The xPack GNU RISC-V Embedded GCC
A standalone cross-platform (Windows, macOS, GNU/Linux) binary distribution of GNU RISC-V Embedded GCC.
https://github.com/xpack-dev-tools/riscv-none-elf-gcc-xpack



Install Make

Linux


apt install make


macOS


brew install make


Windows


https://github.com/xpack-dev-tools/windows-build-tools-xpack/



Install Python

Note: Optional as there are binary releases of esptool available below.

Linux


Python is usually installed by default.
Open a terminal and type: python


apt install python

Linux, macOS, Windows


https://www.python.org/downloads/



Install esptool

Linux, macOS, Windows


Binary Release
https://github.com/espressif/esptool/releases

Python Version
https://docs.espressif.com/projects/esptool/en/latest/esp32/installation.html
pip install esptool



Build Instructions

Configure build environment variables

Linux / macOS:
export BMV_CC=riscv64-unknown-elf-gcc
export BMV_ESPTOOL=esptool
export BMV_CHIP=esp32c3
export BMV_PORT=/dev/ttyACM0

Windows:
set BMV_CC=riscv-none-elf-gcc
set BMV_ESPTOOL=esptool
set BMV_CHIP=esp32c3
set BMV_PORT=COM3

Note: BMV_CC, BMV_ESPTOOL must specify the full path if they are not in your PATH.
Binary:
export BMV_ESPTOOL=/opt/riscv/esptool/esptool
Python:
export BMV_ESPTOOL="python /opt/riscv/esptool/esptool.py"
Open a command prompt, and change to the root directory of this project.

build:
make -C examples/blink/

flash:
make -C examples/blink/ flash

help:
make -C examples/blink help

Usage

Environment Variables

variable default valid values
BMV_CC riscv64-unknown-elf-gcc riscv64-unknown-elf-gcc, riscv-none-elf-gcc, clang, ...
BMV_ESPTOOL esptool esptool, "python esptool.py"
BMV_CHIP esp32c3 esp32c2, esp32c3, esp32c6, esp32h2
BMV_PORT /dev/ttyACM0 /dev/ttyUSB0, /dev/ttyACM0, ..., COM1, COM2, ...

Environment Override

make -C examples/blink clean flash BMV_CC=clang BMV_ESPTOOL=/opt/riscv/esptool/esptool BMV_CHIP=esp32c3 BMV_PORT=/dev/ttyACM0

Show available make commands

make -C examples/blink help