Skip to content

Latest commit

 

History

History
123 lines (86 loc) · 3.2 KB

README.md

File metadata and controls

123 lines (86 loc) · 3.2 KB

RISC-V Online

1 2 3 4 5

RISC-V Assembly Web Interpreter written in C++ for the Raspberry Pi Pico W.

Building from source

Requirements

  • CMake
  • Make
  • GCC/G++ or equivalent (supports c++17)
  • Raspberry Pi Pico W
  • Boost (Header-only)

Configure:

cmake -G Ninja .

Build:

ninja

Testing:

cd src/test
cmake .
make
make test

How to use:

Setup Wi-Fi

The board will try to connect by default to an open Wi-Fi named "RISC-V Online". This can be best setup using a phone's network tethering ability, such as on Android. Create this Wi-Fi network, name it "RISC-V Online" and make it open.

Flashing

There should now be a *.uf2 file located in you binary tree : src/*.uf2

After locating it, plug in the MCU while holding the button on board, drag and drop that file.

Access web UI

You now need to find the IP address of the board, which is best done just checking the list of connection in your AP. If using android tethering, this should be in your settings next to the AP settings.

Syntax

The builtin web interface support very basic assembly parsing:

  lui x5, 2
  add x5, 1
  jal x0, -32 # Repeat add forever

load/store

Loading storing from memory is supported. To allocate stack memory, you would usually use .data directives in assembly language. To achieve zeroed memory regions, you have to leave some lines empty, to act as padding.

  lui x1, 0x2
  sw x1, 0(x0)

Direct web-API access

RISC-V Online has two API endpoints:

POST /submit
POST /return

To submit an emulation state/job, the payload would look like this:

id=26&ram=0|cs7|&ra=0&sp=0&gp=0&tp=cn4&t0=0&t1=0&t2=0&fp=0&s1=0&a0=0&a1=0&a2=0&a3=0&a4=0&a5=0&a6=0&a7=0&s2=0&s3=0&s4=0&s5=0&s6=0&s7=0&s8=0&s9=0&s10=0&s11=0&t3=0&t4=0&t5=0&t6=0&pc=w&prog=0&

We send the register states, a random ID and program encoded in the ram.

To encode the RAM, you need to encode each 32-bit memory regions as an integer, then, represented base 36. Each of these memory regions will be suffixed by the | delimiter. Concatenating all of these, and sending them within the ram parameter/field via POST. Everything being sent to /submit.

To retrieve back the result, just POST the original ID

id=26

to /return.

This will return a JSON object with all the original fields updated. On error, from submit or during execution, this will return an empty object, { }.

TODO:

  • Fix GitHub workflows, Ubuntu doesn't automatically pick up latest compiler, need to download it from ARM website.