Skip to content

Commit a32f4b5

Browse files
committed
2 parents 667f9a1 + aae9102 commit a32f4b5

File tree

4 files changed

+1092
-3
lines changed

4 files changed

+1092
-3
lines changed

README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ This is a simple and readable **RISC-V RV32IMAC emulator** written in pure Pytho
1414
- **Supports memory-mapped IO** and provides a **UART peripheral** using a pseudo-terminal, and a **memory-mapped block device** backed by an image file
1515
- **Passes all `rv32ui`, `rv32mi`, `rv32um`, `rv32ua`, and `rv32uc` unit tests** provided by [RISC-V International](https://github.com/riscv-software-src/riscv-tests)
1616
- **Supports logging** of register values, function calls, system calls, traps, invalid memory accesses, and violations of invariants
17+
- **GDB remote debugging support** via GDB Remote Serial Protocol (RSP) with breakpoints, single-stepping, register/memory inspection
1718
- Runs [MicroPython](https://micropython.org/), [CircuitPython](https://circuitpython.org/) with emulated peripherals, and [FreeRTOS](https://www.freertos.org/) with preemptive multitasking
19+
- **Browser-based emulation** via [Pyodide](https://pyodide.org/), try it [here](https://ccattuto.github.io/riscv-python/)
1820
- Self-contained, modular, extensible codebase. Provides a **Python API** enabling users to control execution, inspect state, and script complex tests directly in Python.
1921

2022
## 🔧 Requirements
@@ -37,6 +39,7 @@ pip install -r requirements.txt
3739
├── machine.py # Host logic (executable loading, invariants check)
3840
├── peripherals.py # Peripherals (UART, block device)
3941
├── syscalls.py # System calls and terminal I/O
42+
├── gdbstub.py # GDB Remote Serial Protocol implementation
4043
├── Makefile # Builds ELF/binary targets
4144
├── start_bare.S # Minimal startup code
4245
├── start_newlib.S # Startup code for Newlib-nano
@@ -90,6 +93,9 @@ pip install -r requirements.txt
9093
| `--raw-tty` | Enable raw terminal mode |
9194
| `--no-color` | Remove ANSI colors in debugging output |
9295
| `--log LOG_FILE` | Log debug information to file `LOG_FILE` |
96+
| `--gdb` | Enable GDB remote debugging (integrates with all other features) |
97+
| `--gdb-port PORT` | GDB server port (default: 1234) |
98+
| `--gdb-host HOST` | GDB server host (default: localhost) |
9399
| `--help` | Show usage help and available options |
94100

95101
### Compiling Examples
@@ -236,7 +242,23 @@ Example Python programs using programmatic access to the emulator are provided i
236242
PYTHONPATH=. python tests/test_api_simple.py
237243
```
238244

239-
## 🌐 Running Programs in the Browser
245+
### 🐛 GDB Remote Debugging
246+
247+
The emulator includes GDB remote debugging support. Add the `--gdb` flag to enable it:
248+
249+
```bash
250+
./riscv-emu.py --gdb prebuilt/test_bare1.elf
251+
```
252+
253+
Then connect with GDB, e.g.:
254+
```bash
255+
riscv64-unknown-elf-gdb prebuilt/test_bare1.elf
256+
(gdb) target remote localhost:1234
257+
```
258+
259+
All standard GDB commands work (breakpoints, stepping, register/memory inspection). CSRs can be accessed via monitor commands: `monitor csr mstatus`, `monitor csr mtvec 0x1000`.
260+
261+
### 🌐 Running Programs in the Browser
240262

241263
The emulator can run in a web browser thanks to [Pyodide](https://pyodide.org/). See `advanced/webapp/`.
242264

0 commit comments

Comments
 (0)