threadx icon indicating copy to clipboard operation
threadx copied to clipboard

riscv gnu port

Open saw235 opened this issue 4 years ago • 9 comments

Are there any plans for a risc-v gnu port? I am trying to port the risc-v iar port into gnu but is running into issues mapping the iar directives as well as understanding in general what needs to be ported.

The things that are ported between each platform seems to be very inconsistent (or not well documented) unlike FreeRTOS which has a well defined set of things that needs to be ported in each platform. Particularly, there's no template for tx_port.h and each of the ports seems to port a different set of threadx api.

saw235 avatar Oct 27 '20 03:10 saw235

All you really need to do is translate the assembly from IAR to GCC. ThreadX has the same API across all platforms.

Yes, at some point (probably next year) we'll be porting RISC-V to GCC.

goldscott avatar Oct 27 '20 03:10 goldscott

I see. But how do I know what some of these directives do?

For example: PUBLIC seems to easily translate to .global here, but EXTWEAK and REQUIRE doesn't seems to map easily to anything.

    PUBLIC  _tx_timer_interrupt_handler
    PUBLIC  __minterrupt_000007
    EXTWEAK __require_minterrupt_vector_table
_tx_timer_interrupt_handler:
__minterrupt_000007:
    REQUIRE __require_minterrupt_vector_table

There's also some references to external symbols like __get_interrupt_state and __istate_t which I couldn't wrap my head around what it is actually doing. In some other gnu ports, it is just saving the masked mstatus.

#define TX_INTERRUPT_SAVE_AREA                  __istate_t interrupt_save;
#define TX_DISABLE                              {interrupt_save = __get_interrupt_state();__disable_interrupt();};
#define TX_RESTORE                              {__set_interrupt_state(interrupt_save);};

saw235 avatar Oct 27 '20 10:10 saw235

Do you really want to do the gnu port yourself?

You'll have to look in the assembler documentation for these directives.

These are intrinsic functions provided by the compiler.

IAR and GCC will have different directives and intrinsic names, so you'll have to look in their respective documentation for the equivalents.

goldscott avatar Oct 27 '20 17:10 goldscott

Hey @saw235 Did you manage to do the port?

mrdiogodias avatar May 19 '21 15:05 mrdiogodias

In case someone comes across this question, I've managed to the port to gnu. I'm not sure it is 100% correct but it worked well for me and maybe it can help someone out there.

mrdiogodias avatar Jun 04 '21 13:06 mrdiogodias

Any news? @TiejunMS

Linjieqiang avatar Dec 13 '21 12:12 Linjieqiang

Nope.

TiejunMS avatar Dec 14 '21 16:12 TiejunMS

@hihigupt any comment on this?

goldscott avatar Dec 14 '21 17:12 goldscott

https://github.com/azure-rtos/threadx/pull/153 @goldscott

Linjieqiang avatar Dec 17 '21 02:12 Linjieqiang

@Linjieqiang @mrdiogodias @saw235 - hi all, a 32-bit and 64-bit GNU RISC-V port is coming soon. It's in the testing phase now.

goldscott avatar Oct 28 '22 15:10 goldscott