|
| 1 | +# RISCV32 clang port |
| 2 | + |
| 3 | +This is basically a copy of the RISC64 gnu port. |
| 4 | +The only major modification was changing the load double word (ld) |
| 5 | +and store double double (sd) word with load word (ld) and store word (sd). |
| 6 | + |
| 7 | +I also added support for semihosting so the example can be executed on QEMU. |
| 8 | + |
| 9 | +## How to build |
| 10 | + |
| 11 | +cd to the folder where this repo is cloned and run the following commands: |
| 12 | + |
| 13 | +``` |
| 14 | +cd /threadx/ports/risc-v32/clang/example_build/qemu_virt |
| 15 | +./build_libthreadx.sh |
| 16 | +./build_threadx_sample.sh |
| 17 | +``` |
| 18 | + |
| 19 | +The first script will build the ThreadX libraries. |
| 20 | +You can find the library in <threadx repo>/build/libthreadx.a. |
| 21 | + |
| 22 | +The second script will build the demo application. |
| 23 | +You can find the demo application in <threadx repo>/ports/risc-v32/clang/example_build/qemu_virt/build/demo_threadx.elf |
| 24 | + |
| 25 | +## How to run using QEMU |
| 26 | + |
| 27 | +cd to the folder where this repo is cloned and run the following command: |
| 28 | + |
| 29 | +``` |
| 30 | +docker run --rm -it -p 1234:1234 -v $(pwd):/threadx -w /threadx ghcr.io/quintauris-tech/qemu-system-riscv32-v10:latest bash |
| 31 | +``` |
| 32 | + |
| 33 | +The commands assumes that this repo is clone into a folder named "threadx" |
| 34 | + |
| 35 | +``` |
| 36 | +cd /threadx/ports/risc-v32/clang/example_build/qemu_virt |
| 37 | +
|
| 38 | +qemu-system-riscv32 -machine virt -m 16M -bios ./build/demo_threadx.elf -display none -chardev stdio,id=stdio0 -semihosting-config enable=on,userspace=on,chardev=stdio0 -gdb tcp::1234 |
| 39 | +``` |
| 40 | + |
| 41 | +This should print output from different threads. In the QEMU output you should see output like the following: |
| 42 | + |
| 43 | +``` |
| 44 | +[Thread] : thread_xxxx_entry is here! |
| 45 | +``` |
| 46 | + |
| 47 | +You can use option -S with qemu-system-riscv32 to debug. |
| 48 | + |
| 49 | +In this case run debugger as /opt/riscv_rv32ima_zicsr/bin/riscv32-unknown-elf-gdb <repo>/ports/risc-v32/gnu/example_build/qemu_virt/build/demo_threadx.elf |
| 50 | + |
| 51 | +``` |
| 52 | +target remote :1234 |
| 53 | +``` |
| 54 | + |
| 55 | +to connect to the target. Enter 'c' to continue execution. |
| 56 | + |
| 57 | + |
| 58 | + |
0 commit comments