Skip to content

Commit 49439bf

Browse files
Fixes to the RISC-V32 architecture port layer for Clang.
1 parent 888f7a4 commit 49439bf

File tree

5 files changed

+17
-83
lines changed

5 files changed

+17
-83
lines changed

ports/risc-v32/clang/README.md

Lines changed: 0 additions & 58 deletions
This file was deleted.

ports/risc-v32/clang/example_build/qemu_virt/demo_threadx.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ UINT status;
228228
/* Send message to queue 0. */
229229
status = tx_queue_send(&queue_0, &thread_1_messages_sent, TX_WAIT_FOREVER);
230230

231+
tx_thread_sleep(2);
232+
231233
/* Check completion status. */
232234
if (status != TX_SUCCESS) {
233235
puts("[Thread 1] ERROR: Failed to send message!");
@@ -257,6 +259,8 @@ UINT status;
257259
/* Retrieve a message from the queue. */
258260
status = tx_queue_receive(&queue_0, &received_message, TX_WAIT_FOREVER);
259261

262+
tx_thread_sleep(2);
263+
260264
/* Check completion status and make sure the message is what we
261265
expected. */
262266
if ((status != TX_SUCCESS) || (received_message != thread_2_messages_received)){

ports/risc-v32/clang/example_build/qemu_virt/tx_initialize_low_level.S

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@
6767
.extern _tx_thread_context_restore
6868
trap_entry:
6969
#if defined(__riscv_float_abi_single) || defined(__riscv_float_abi_double)
70-
addi sp, sp, -65*REGBYTES // Allocate space for all registers - with floating point enabled
70+
addi sp, sp, -65*4 // Allocate space for all registers - with floating point enabled
7171
#else
72-
addi sp, sp, -32*REGBYTES // Allocate space for all registers - without floating point enabled
72+
addi sp, sp, -32*4 // Allocate space for all registers - without floating point enabled
7373
#endif
7474

75-
STORE x1, 28*REGBYTES(sp) // Store RA, 28*REGBYTES(because call will override ra [ra is a calle register in riscv])
75+
sw x1, 28*4(sp) // Store RA, 28*4(because call will override ra [ra is a calle register in riscv])
7676

7777
call _tx_thread_context_save
7878

ports/risc-v32/clang/inc/tx_port.h

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -53,25 +53,7 @@
5353
#ifndef TX_PORT_H
5454
#define TX_PORT_H
5555

56-
#ifdef __ASSEMBLER__
57-
58-
59-
#if __riscv_xlen == 64
60-
# define SLL32 sllw
61-
# define STORE sd
62-
# define LOAD ld
63-
# define LWU lwu
64-
# define LOG_REGBYTES 3
65-
#else
66-
# define SLL32 sll
67-
# define STORE sw
68-
# define LOAD lw
69-
# define LWU lw
70-
# define LOG_REGBYTES 2
71-
#endif
72-
#define REGBYTES (1 << LOG_REGBYTES)
73-
74-
#else /*not __ASSEMBLER__ */
56+
#ifndef __ASSEMBLER__
7557

7658
/* Include for memset. */
7759
#include <string.h>

ports/risc-v32/clang/readme_threadx.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@
77

88
Prerequisites
99
- Install a RISC-V32 bare-metal Clang toolchain
10-
- Install a RISC-V32 bare-metal GNU toolchain with riscv32-unknown-elf prefix
11-
- Common source: https://github.com/riscv-collab/riscv-gnu-toolchain
10+
- Install a RISC-V32 bare-metal GNU toolchain with riscv32-unknown-elf prefix.
11+
Common source: https://github.com/riscv-collab/riscv-gnu-toolchain
1212

13-
Verify the Clang toolchaing:
13+
The GNU toolchain is needed because the Clang toolchain does not include some
14+
standard headers and libraries, i.e. "string.h".
15+
16+
Verify the Clang toolchain:
1417
clang --version
1518

1619
Verify the GCC toolchain:
@@ -21,6 +24,9 @@ CMake-based build (recommended)
2124

2225
From the ThreadX top-level directory:
2326

27+
Set environment variable "GCC_INSTALL_PREFIX" with the location of the
28+
GNU toolchain, i.e., export GCC_INSTALL_PREFIX=/opt/riscv_rv32ima
29+
2430
cmake -Bbuild -GNinja -DCMAKE_TOOLCHAIN_FILE=cmake/riscv32_clang.cmake .
2531
cmake --build ./build/
2632

0 commit comments

Comments
 (0)