# RISC-V RV32E

**URL:** <https://forums.freertos.org/t/risc-v-rv32e/8044>\
**Category:** Kernel\
**Created:** [September 6, 2019, 12:35pm UTC](https://forums.freertos.org/t/risc-v-rv32e/8044 "2019-09-06T12:35:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [September 6, 2019, 12:35pm UTC](https://forums.freertos.org/t/risc-v-rv32e/8044/1 "2019-09-06T12:35:36Z")

</div>

**[nakane1chome](https://sourceforge.net/u/nakane1chome/)** wrote on [Friday, September 06, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/67c2189c2d/#f03f):

Has anyone adapted the RISC-V port for rv32ec base ISA?  
I’ve started to do it but not had time to do much verification (that was more to do with the lack of a CLINT on my core, the new mtimer changes look helpful) . If no one else is working on it I’ll see if I can complete it and contribute back.

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [September 6, 2019, 2:21pm UTC](https://forums.freertos.org/t/risc-v-rv32e/8044/2 "2019-09-06T14:21:32Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Friday, September 06, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/67c2189c2d/#f03f/d617):

It is not something we have looked at yet, and it is definitely of  
interest. We have made a few changes to the RISC-V port recently, and  
the mtimer change you mention below has also been made but not checked  
in yet. After that there is still one change outstanding, which is to  
pass software interrupts out to the application - it would be great if  
we can stay in sync on these changes and the code you are creating. Do  
you think it would be possible to have the ‘E’ profile as a build time  
option in the existing port files?

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [September 8, 2019, 2:19pm UTC](https://forums.freertos.org/t/risc-v-rv32e/8044/3 "2019-09-08T14:19:01Z")

</div>

**[nakane1chome](https://sourceforge.net/u/nakane1chome/)** wrote on [Sunday, September 08, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/67c2189c2d/#f03f/d617/82d4):

Yes, the ‘rv32e’ is similar enough to the other base ISAs that the same port code can be used.

In portASM.S I simply made the load\_x and store\_x statements for x16 to x31 conditional on `#ifndef __riscv_32e`.

For the stack frame size I updated the macro portCONTEXT\_SIZE, and then defined that according to if \_\_riscv\_32e was defined. (14 registers for rv32e vs 30 registers for other base ABIs).

In pxPortInitialiseStack I also needed to make a change to reduce the space for x11-x31 to x11-x15.

It’s probably possible to test this out on an rv32i core by compiling the code using `-march=rv32e` and `-mabi=ilp32e` .

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [September 9, 2019, 12:16am UTC](https://forums.freertos.org/t/risc-v-rv32e/8044/4 "2019-09-09T00:16:31Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Monday, September 09, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/67c2189c2d/#f03f/d617/82d4/409d):

Thanks for the info - and the tip on how to test without an ‘e’ board  
myself.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [September 10, 2019, 6:19am UTC](https://forums.freertos.org/t/risc-v-rv32e/8044/5 "2019-09-10T06:19:18Z")

</div>

**[kj-lin](https://sourceforge.net/u/kj-lin/)** wrote on [Tuesday, September 10, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/67c2189c2d/#6da7):

By the way, besides making load\_x and store\_x statements for x16 to x31 conditional and reducing the space for x11-x31 to x11-x15 in pxPortInitialiseStack(), RV32E should have the portBYTE\_ALIGNMENT definition to 8 in portmacro.h file.  
RV32E is based on RISC-V EABI and should be 8-byte stack aligned insead of RV32/RV64 16-byte aligned.

```
  #ifdef __riscv_32e
        #define portBYTE_ALIGNMENT 8
  #else
        #define portBYTE_ALIGNMENT 16
   #endif
```
