You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: The code is in **pure AVR C**. Arduino IDE is just used as *serial terminal*.
3
9
4
10
## What is this?
5
11
This is a port of [mini-rv32ima](https://github.com/cnlohr/mini-rv32ima) (a minimum RISC-V emulator, capable of booting Linux) on atmega328p (the core of Arduino UNO, a 8-bit AVR microcontroller). So basically, this code is for **booting Linux on Arduino UNO**.
@@ -12,7 +18,7 @@ The idea is really simple: you have an Arduino UNO (or atmega328p) to run the em
12
18
The code is written in pure C (and not Arduino) to reduce Arduino overhead (if any). It initializes UART, SPI, SD card, and a digital input-pullup pin for triggering emulator state dump. Finally, it initialize cache, then mini-rv32ima and let the emulator does its works.
13
19
14
20
## How fast is it?
15
-
About ~~175Hz - 205Hz~~~~426 - 600Hz~~600 - 700 Hzwith `-O3` code on an Arduino UNO based on atmega328p, clocked at 16MHz, with a class 4 SDHC card connected via 1-bit SPI interface.
21
+
About ~~175Hz - 205Hz~~~~426 - 600Hz~~most of the time 700 Hz, peak 1500Hz, lowest 70Hz with `-O3` code on an Arduino UNO based on atmega328p, clocked at 16MHz, with a class 4 SDHC card connected via 1-bit SPI interface. Complete boot time (from start to shell) is about 15 hours and 44 minutes.
16
22
17
23
Update 24/9/2023: The speed is double/tripled by implementing icache
18
24
@@ -41,7 +47,7 @@ The pinout is really simple. On Arduino UNO, it should be:
41
47
### Preparing the SD card
42
48
- First, you will need an SD card. Any type larger than 12MB.
43
49
> [!WARNING]
44
-
> You should backup all your files, since doing this SD card preperation will destroy your SD card's filesystem.
50
+
> You should backup all your files, since doing this SD card preparation will destroy your SD card's filesystem.
45
51
- Then you need some tool to directly write a file to SD card. On Windows, you can use [HDD Raw Copy Tool](https://hddguru.com/software/HDD-Raw-Copy-Tool/), on *nix you can use `dd if=file.bin of=/dev/sdX conv=notrunc`.
46
52
- Download the file [`arv32.bin`](https://github.com/raspiduino/arv32-opt/raw/main/rv32.bin) file.
47
53
- Write it directly to the SD card using the tools in step 2.
@@ -81,8 +87,6 @@ arv32-opt: mini-rv32ima on Arduino UNO
81
87
SD card initialized successfully!
82
88
```
83
89
84
-
and (optionally, but normally, if your board is fast enough) the line `Currently at 0xB8` after these 2 lines.
85
-
86
90
> [!IMPORTANT]
87
91
> The `Preparing the SD card` section must be repeated every time you boot your emulator. Otherwise it might not boot (if Linux has initialized enough and start cleaning the memory). This might be fixed in the future.
88
92
@@ -91,37 +95,36 @@ and (optionally, but normally, if your board is fast enough) the line `Currently
91
95
92
96
You can also dump the state of the emulator while it's running. Just connect a button to `GND` and then connect pin 9 to the button. When you click the button, state will be dump, and you should see something like this:
Dump completed. Emulator will continue when B1 is set back to HIGH
126
+
mcause: 0x80000007
127
+
extraflags: 0x019446E3
125
128
```
126
129
`Effective emulated speed` is the number of instructions the emulator can execute in 1 second at that time. `dtime` is the time difference between current time and the last time you dump the status. `dcycle` is the number of cycle (instructions) excuted from the last time you dump the status until now.
127
130
<br>`Registers x0 - x31` sections show registers from `x0` to `x31`, listed in order from left to right then from top down.
0 commit comments