Update GCC RISC-V QEMU project to support new RISC-V port and vector mode (#780)
parent
2b956b97c7
commit
673d3d7eea
@ -0,0 +1,70 @@
|
||||
# Emulating generic RISC-V 32bit machine on QEMU
|
||||
|
||||
## Requirements
|
||||
|
||||
1. GNU RISC-V toolchains (tested on pre-built Sifive GNU Embedded Toolchain — v2020.12.8)
|
||||
- https://www.sifive.com/software
|
||||
1. qemu-riscv32-system (tested on pre-built Sifive QEMU — v2020.08.1)
|
||||
- https://www.sifive.com/software
|
||||
1. Linux OS (tested on Ubuntu 20.04.3 LTS)
|
||||
|
||||
|
||||
## How to build
|
||||
|
||||
Add path of toolchain that is described above section, such as:
|
||||
|
||||
```
|
||||
$ export PATH="/YOUR_PATH/riscv64-unknown-elf/bin:${PATH}"
|
||||
```
|
||||
|
||||
For release build:
|
||||
|
||||
```
|
||||
$ make -C build/gcc/
|
||||
```
|
||||
|
||||
For debug build:
|
||||
|
||||
```
|
||||
$ make -C build/gcc/ DEBUG=1
|
||||
```
|
||||
|
||||
To clean build artifacts:
|
||||
|
||||
```
|
||||
$ make -C build/gcc/ clean
|
||||
```
|
||||
|
||||
If the build was successful, the RTOSDemo.elf executable will be located in the build/gcc/output directory.
|
||||
|
||||
|
||||
## How to run
|
||||
|
||||
```
|
||||
$ qemu-system-riscv32 -nographic -machine virt -net none \
|
||||
-chardev stdio,id=con,mux=on -serial chardev:con \
|
||||
-mon chardev=con,mode=readline -bios none \
|
||||
-smp 4 -kernel ./build/gcc/output/RTOSDemo.elf
|
||||
```
|
||||
|
||||
|
||||
## How to debug with gdb
|
||||
|
||||
Append -s and -S options to the previous qemu command.
|
||||
|
||||
- -s: enable to attach gdb to QEMU at port 1234
|
||||
- -S: start and halted CPU (wait for attach from gdb)
|
||||
|
||||
It is recommended to use the 'debug build' so that gdb can automatically map symbols.
|
||||
Run these commands after starting the QEMU with above options:
|
||||
|
||||
```
|
||||
$ riscv64-unknown-elf-gdb -x build/gcc/gdbinit
|
||||
```
|
||||
|
||||
|
||||
## Description
|
||||
|
||||
This demo just prints Tx/Rx message of queue to serial port, use no
|
||||
other hardware and use only primary core (currently hart 0).
|
||||
Other cores are simply going to wfi state and execute nothing else.
|
@ -0,0 +1,7 @@
|
||||
target remote localhost:1234
|
||||
set arch riscv:rv32
|
||||
set remotetimeout 250
|
||||
flushregs
|
||||
file ./output/RTOSDemo.elf
|
||||
load
|
||||
tb main
|
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* FreeRTOS V202112.00
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
.balign 128, 0
|
||||
.option norvc
|
||||
.global freertos_vector_table
|
||||
freertos_vector_table:
|
||||
IRQ_0:
|
||||
j freertos_risc_v_exception_handler
|
||||
IRQ_1:
|
||||
j freertos_risc_v_interrupt_handler
|
||||
IRQ_2:
|
||||
j freertos_risc_v_interrupt_handler
|
||||
IRQ_3:
|
||||
j freertos_risc_v_interrupt_handler
|
||||
IRQ_4:
|
||||
j freertos_risc_v_interrupt_handler
|
||||
IRQ_5:
|
||||
j freertos_risc_v_interrupt_handler
|
||||
IRQ_6:
|
||||
j freertos_risc_v_interrupt_handler
|
||||
IRQ_7:
|
||||
j freertos_risc_v_mtimer_interrupt_handler
|
||||
IRQ_8:
|
||||
j freertos_risc_v_interrupt_handler
|
||||
IRQ_9:
|
||||
j freertos_risc_v_interrupt_handler
|
||||
IRQ_10:
|
||||
j freertos_risc_v_interrupt_handler
|
||||
IRQ_11:
|
||||
j freertos_risc_v_interrupt_handler
|
||||
IRQ_12:
|
||||
j freertos_risc_v_interrupt_handler
|
||||
IRQ_13:
|
||||
j freertos_risc_v_interrupt_handler
|
||||
IRQ_14:
|
||||
j freertos_risc_v_interrupt_handler
|
||||
IRQ_15:
|
||||
j freertos_risc_v_interrupt_handler
|
@ -1 +1 @@
|
||||
Subproject commit 9efca75d1ebfc6c02f9e004c199dffa327267a09
|
||||
Subproject commit d5a10e45958148d437ae5096835a118be58e6df9
|
Loading…
Reference in New Issue