RISC-V Port of ChibiOS

This forum is about you. Feel free to discuss anything is related to embedded and electronics, your awesome projects, your ideas, your announcements, not necessarily related to ChibiOS but to embedded in general. This forum is NOT for support.
psyco
Posts: 21
Joined: Fri May 22, 2020 1:40 am
Been thanked: 11 times

RISC-V Port of ChibiOS

Postby psyco » Fri May 22, 2020 2:28 am

As a fun / educational experience, I decided to learn about the inner workings of ChibiOS / RTOSes / MCU architectures in general. I went for the extra challenge of porting ChibiOS to RISC-V as I didn't find anything previously done on this.

https://github.com/psycowithespn/ChibiOS-RISC-V

I targeted the SparkFun RED-V RedBoard with a SiFive FE310. Currently, the only peripheral driver is a serial port. I'm using the dedicated global system timer to operate in tickless mode. There are some issues with slow core clocks failing the tests, but that may be expected. I still need to look into that.

If I manage to get more time to work on this and knock out some bugs, I'll be happy to submit it to the contrib repo. The repo is currently set up to live next to a ChibiOS root.

For future challenges, I have my eyes set on something like the Kendryte K210, a dual core RISC-V with different privileges levels that has developing linux support (and more than 16K of ram).

Test report of the FE310 running at 320 MHz:

Code: Select all

*** ChibiOS/RT Test Suite
***
*** Compiled:     May 21 2020 - 21:19:45
*** Platform:     FE310-G002
*** Test Board:   Generic Board
***
*** Text size:    46896 bytes
*** RO data size: 9492 bytes
*** Data size:    220 bytes
*** BSS size:     7600 bytes

============================================================================
=== Test Sequence 1 (Information)
----------------------------------------------------------------------------
--- Test Case 1.1 (Port Info)
--- Architecture:                       RISCV Architecture
--- Compiler:                           GCC 8.3.0
--- Port Info:                          no info
--- Natural alignment:                  4
--- Stack alignment:                    16
--- Working area alignment:             16
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 1.2 (Kernel Info)
--- Product:                            ChibiOS/RT
--- Stable Flag:                        0
--- Version String:                     6.1.0
--- Major Number:                       6
--- Minor Number:                       1
--- Patch Number:                       0
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 1.3 (Kernel Settings)
--- CH_CFG_ST_RESOLUTION:               64
--- CH_CFG_ST_FREQUENCY:                32768
--- CH_CFG_INTERVALS_SIZE:              64
--- CH_CFG_TIME_TYPES_SIZE:             32
--- CH_CFG_ST_TIMEDELTA:                2
--- CH_CFG_TIME_QUANTUM:                0
--- CH_CFG_MEMCORE_SIZE:                0
--- CH_CFG_NO_IDLE_THREAD:              0
--- CH_CFG_OPTIMIZE_SPEED:              1
--- CH_CFG_USE_TM:                      1
--- CH_CFG_USE_REGISTRY:                1
--- CH_CFG_USE_WAITEXIT:                1
--- CH_CFG_USE_SEMAPHORES:              1
--- CH_CFG_USE_SEMAPHORES_PRIORITY:     0
--- CH_CFG_USE_MUTEXES:                 1
--- CH_CFG_USE_MUTEXES_RECURSIVE:       0
--- CH_CFG_USE_CONDVARS:                1
--- CH_CFG_USE_CONDVARS_TIMEOUT:        1
--- CH_CFG_USE_EVENTS:                  1
--- CH_CFG_USE_EVENTS_TIMEOUT:          1
--- CH_CFG_USE_MESSAGES:                1
--- CH_CFG_USE_MESSAGES_PRIORITY:       0
--- CH_CFG_USE_DYNAMIC:                 1
--- CH_DBG_STATISTICS:                  0
--- CH_DBG_SYSTEM_STATE_CHECK:          0
--- CH_DBG_ENABLE_CHECKS:               0
--- CH_DBG_ENABLE_ASSERTS:              0
--- CH_DBG_TRACE_MASK:                  255
--- CH_DBG_TRACE_BUFFER_SIZE:           128
--- CH_DBG_ENABLE_STACK_CHECK:          0
--- CH_DBG_FILL_THREADS:                0
--- CH_DBG_THREADS_PROFILING:           0
--- Result: SUCCESS
============================================================================
=== Test Sequence 2 (System layer and port interface)
----------------------------------------------------------------------------
--- Test Case 2.1 (System integrity functionality)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 2.2 (Critical zones functionality)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 2.3 (Interrupts handling functionality)
--- Result: SUCCESS
============================================================================
=== Test Sequence 3 (Time and Intervals Functionality)
----------------------------------------------------------------------------
--- Test Case 3.1 (System Tick Counter functionality)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 3.2 (Time ranges functionality)
--- Result: SUCCESS
============================================================================
=== Test Sequence 4 (Threads Functionality)
----------------------------------------------------------------------------
--- Test Case 4.1 (Thread Sleep functionality)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 4.2 (Ready List functionality, threads priority order)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 4.3 (Priority change test)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 4.4 (Priority change test with Priority Inheritance)
--- Result: SUCCESS
============================================================================
=== Test Sequence 5 (Suspend/Resume)
----------------------------------------------------------------------------
--- Test Case 5.1 (Suspend and Resume functionality)
--- Result: SUCCESS
============================================================================
=== Test Sequence 6 (Counter Semaphores)
----------------------------------------------------------------------------
--- Test Case 6.1 (Semaphore primitives, no state change)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 6.2 (Semaphore enqueuing test)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 6.3 (Semaphore timeout test)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 6.4 (Testing chSemAddCounterI() functionality)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 6.5 (Testing chSemWaitSignal() functionality)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 6.6 (Testing Binary Semaphores special case)
--- Result: SUCCESS
============================================================================
=== Test Sequence 7 (Mutexes, Condition Variables and Priority Inheritance)
----------------------------------------------------------------------------
--- Test Case 7.1 (Priority enqueuing test)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 7.2 (Priority return verification)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 7.3 (Repeated locks, non recursive scenario)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 7.4 (Condition Variable signal test)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 7.5 (Condition Variable broadcast test)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 7.6 (Condition Variable priority boost test)
--- Result: SUCCESS
============================================================================
=== Test Sequence 8 (Synchronous Messages)
----------------------------------------------------------------------------
--- Test Case 8.1 (Messages Server loop)
--- Result: SUCCESS
============================================================================
=== Test Sequence 9 (Event Sources and Event Flags)
----------------------------------------------------------------------------
--- Test Case 9.1 (Events registration)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 9.2 (Event Flags dispatching)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 9.3 (Events Flags wait using chEvtWaitOne())
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 9.4 (Events Flags wait using chEvtWaitAny())
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 9.5 (Events Flags wait using chEvtWaitAll())
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 9.6 (Events Flags wait timeouts)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 9.7 (Broadcasting using chEvtBroadcast())
--- Result: SUCCESS
============================================================================
=== Test Sequence 10 (Dynamic threads)
----------------------------------------------------------------------------
--- Test Case 10.1 (Threads creation from Memory Heap)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 10.2 (Threads creation from Memory Pool)
--- Result: SUCCESS
============================================================================
=== Test Sequence 11 (Benchmarks)
----------------------------------------------------------------------------
--- Test Case 11.1 (Messages performance #1)
--- Score : 1494985 msgs/S, 2989970 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.2 (Messages performance #2)
--- Score : 1280596 msgs/S, 2561192 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.3 (Messages performance #3)
--- Score : 1273062 msgs/S, 2546124 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.4 (Context Switch performance)
--- Score : 5247960 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.5 (Threads performance, full cycle)
--- Score : 948193 threads/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.6 (Threads performance, create/exit only)
--- Score : 1173128 threads/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.7 (Mass reschedule performance)
--- Score : 419898 reschedules/S, 2519388 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.8 (Round-Robin voluntary reschedule)
--- Score : 3201400 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.9 (Virtual Timers set/reset performance)
--- Score : 1627170 timers/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.10 (Semaphores wait/signal performance)
--- Score : 6559884 wait+signal/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.11 (Mutexes lock/unlock performance)
--- Score : 4595496 lock+unlock/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.12 (RAM Footprint)
--- System: 136 bytes
--- Thread: 68 bytes
--- Timer : 24 bytes
--- Semaph: 12 bytes
--- Mutex : 16 bytes
--- CondV.: 8 bytes
--- EventS: 4 bytes
--- EventL: 20 bytes
--- MailB.: 40 bytes
--- Result: SUCCESS
----------------------------------------------------------------------------

Final result: SUCCESS

*** ChibiOS OS Library Test Suite
***
*** Compiled:     May 21 2020 - 21:19:45
*** Platform:     FE310-G002
*** Test Board:   Generic Board
***
*** Text size:    46896 bytes
*** RO data size: 9492 bytes
*** Data size:    220 bytes
*** BSS size:     7600 bytes

============================================================================
=== Test Sequence 1 (Information)
----------------------------------------------------------------------------
--- Test Case 1.1 (Port Info)
--- Architecture:                       RISCV Architecture
--- Compiler:                           GCC 8.3.0
--- Port Info:                          no info
--- Natural alignment:                  4
--- Stack alignment:                    16
--- Working area alignment:             16
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 1.2 (OS Library Info)
--- Product:                            ChibiOS/LIB
--- Stable Flag:                        0
--- Version String:                     1.2.0
--- Major Number:                       1
--- Minor Number:                       2
--- Patch Number:                       0
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 1.3 (OS Library Settings)
--- CH_CFG_USE_MAILBOXES:               1
--- CH_CFG_USE_MEMCORE:                 1
--- CH_CFG_USE_HEAP:                    1
--- CH_CFG_USE_MEMPOOLS:                1
--- CH_CFG_USE_OBJ_FIFOS:               1
--- CH_CFG_USE_PIPES:                   1
--- CH_CFG_USE_OBJ_CACHES:              1
--- CH_CFG_USE_DELEGATES:               1
--- CH_CFG_USE_FACTORY:                 1
--- CH_CFG_FACTORY_MAX_NAMES_LENGTH:    8
--- CH_CFG_FACTORY_OBJECTS_REGISTRY:    1
--- CH_CFG_FACTORY_GENERIC_BUFFERS:     1
--- CH_CFG_FACTORY_SEMAPHORES:          1
--- CH_CFG_FACTORY_MAILBOXES:           1
--- CH_CFG_FACTORY_OBJ_FIFOS:           1
--- CH_CFG_FACTORY_PIPES:               1
--- Result: SUCCESS
============================================================================
=== Test Sequence 2 (Mailboxes)
----------------------------------------------------------------------------
--- Test Case 2.1 (Mailbox normal API, non-blocking tests)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 2.2 (Mailbox I-Class API, non-blocking tests)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 2.3 (Mailbox timeouts)
--- Result: SUCCESS
============================================================================
=== Test Sequence 3 (Pipes)
----------------------------------------------------------------------------
--- Test Case 3.1 (Pipes normal API, non-blocking tests)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 3.2 (Pipe timeouts)
--- Result: SUCCESS
============================================================================
=== Test Sequence 4 (Jobs Queues)
----------------------------------------------------------------------------
--- Test Case 4.1 (Dispatcher test)
--- Result: SUCCESS
============================================================================
=== Test Sequence 5 (Thread Delegates)
----------------------------------------------------------------------------
--- Test Case 5.1 (Dispatcher test)
--- Result: SUCCESS
============================================================================
=== Test Sequence 6 (Objects Caches)
----------------------------------------------------------------------------
--- Test Case 6.1 (Cache initialization)
--- Result: SUCCESS
============================================================================
=== Test Sequence 7 (Memory Pools)
----------------------------------------------------------------------------
--- Test Case 7.1 (Loading and emptying a memory pool)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 7.2 (Loading and emptying a guarded memory pool without waiting)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 7.3 (Guarded Memory Pools timeout)
--- Result: SUCCESS
============================================================================
=== Test Sequence 8 (Memory Heaps)
----------------------------------------------------------------------------
--- Test Case 8.1 (Allocation and fragmentation)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 8.2 (Default Heap)
--- Result: SUCCESS
============================================================================
=== Test Sequence 9 (Objects Factory)
----------------------------------------------------------------------------
--- Test Case 9.1 (Objects Registry)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 9.2 (Dynamic Buffers Factory)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 9.3 (Dynamic Semaphores Factory)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 9.4 (Dynamic Mailboxes Factory)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 9.5 (Dynamic Objects FIFOs Factory)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 9.6 (Dynamic Pipes Factory)
--- Result: SUCCESS
----------------------------------------------------------------------------

Final result: SUCCESS

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: RISC-V Port of ChibiOS

Postby Giovanni » Fri May 22, 2020 5:42 am

Well, this is very interesting, something I wanted to do but never got enough time...

Time to get one of those boards.

Giovanni

electronic_eel
Posts: 77
Joined: Sat Mar 19, 2016 8:07 pm
Been thanked: 17 times

Re: RISC-V Port of ChibiOS

Postby electronic_eel » Fri May 22, 2020 9:34 pm

I don't know if you are aware of it, but Gigadevice has the GD32VF103 available. This is interesting for ChibiOS I think, because it is a RISC-V mcu which contains the well-known peripherals from the STM32F103. So a port would "just" need to take care of the processor core, the peripherals are already supported in HAL.

Some boards with GD32VF103 are available from Seeed studio.

psyco
Posts: 21
Joined: Fri May 22, 2020 1:40 am
Been thanked: 11 times

Re: RISC-V Port of ChibiOS

Postby psyco » Sat May 23, 2020 12:29 am

I did see the Gigadevice ones. I avoided anything with STM32 in the name so doing this didn't feel just like work. However, I didn't consider the HAL would be almost drop in on those. I'll pick one up to play around with that.

There's still some oddness I need to knock out with this port before it becomes useful.


Return to “User Projects”

Who is online

Users browsing this forum: No registered users and 8 guests