Multicore Heterogeneous OS ( Linux, RTOS), is it possible?

I am looking to try out Multicore Heterogeneous OS

  1. Linux on the U740 core
  2. FreeRTOS on the S7 core

There are number of issues to overcome:-

  1. Compiling FreeRTOS from the Freedom-e-sdk for the S7 core ( Requires BSP)

  1. Using linux to create a shared memory space for the S7 and U740 cores. Perhaps NMAP will be ok.
  2. Copying the FreeRTOS binary to the shared memory.
  3. Kick starting the S7 core to use the starting address of the FreeRTOS binary
  4. Beyond that a mechanism is needed for inter-core communication.

OR

  1. Using the Linux Remote Processor Framework might be possible ( Apparently the S7 core is detected in the linux device tree)
  2. int rproc_boot(struct rproc *rproc) etc…
  3. Beyond that a mechanism is needed for inter-core communication.

I assume the above is possible. Hopefully within the next 2 weeks I will have my hands on a board to try this out. Any thoughts, advice would be appreciated.

Have you thought about how to handle platform interrupts?

Thinking about it, but no progress yet.

This thread reminds me of a discussion from last summer: How about the S7 core? I don’t know if anything ever came of it, so this probably isn’t helpful, just FYI.

Thanks, I saw that discussion.

This company has a demo on YouTube. They appear to have FreeRTOS running on the unmatched board.

[デモ動画 HiFive UnmatchedボードでFreeRTOSデモ - YouTube]

[[RISC-V技術ブログ連載第14回] SiFive最新リリース HiFive Unmatchedボードのご紹介⑩ ~HiFive UnmatchedでFreeRTOSを動かす~ | DTSインサイト|技術ブログ]

Unmatched does have a BSP.
The FreeRTOS demos can be built using Freedom-e-sdk via FreedomStudio. And the core can be selected using FreedomStudio.

freedom-e-sdk/bsp/sifive-hifive-unmatched at master · sifive/freedom-e-sdk (github.com)

So the build is possible and the previous web site link indicates FreeRTOS can be run on the S7 core.

Still some way to go before I achieving my objective.

Next step:-

  1. Use Linux to load the FreeRTOS on the S7 core.

Looking around, one approach is as follows:-

A. Create a memory device using the device tree in Linux. This would match the execution start address of the S7 core.

The binary can then be copied to memory using the cat command, on the command line in Linux.

The memory device requires a mailbox. It needs a method to start and stop the S7 core. I guess this will be achieved by interrupts and register settings.

I have seen examples for the Raspberry PI and zephyr, however I am not use where to start with the S7 core.

I have been looking through the documentation for the unmatched board, and to be honest I am not sure what kind of register I should be looking for. A core reset register, a program counter register.

Tomorrow, I finally have a board, so I can do some practical experiments.

1 Like

I plan to do a very similar project using linux on one core, freertos on a second and an enclave to protect everything with PMP.

I don’t have an unmatched board yet, so I’m using qemu.
The multicore-hello example is useful in that it shows how to start the 4 cores from a single elf file. Plus using the hardware lock.

The example-freertos-pmp-blinky shows how to run freertos on one of the main cores, Im not planning on putting it on the 5th core (that will be bare-metal). It also demonstrates PMP protection and moving from machine mode to user mode.

These examples should enable us to build the system we are looking for.

The FreeRTOS blinky sample code is up and running on the S7 core ( Freedom-studio).

Not much development is required.

  1. Just set the the hart that wil be used in the FreeRTOS linker file.
  2. Comment out all LED code ( doesn’t seem to work on the unmatched board)
  3. And if you just wish to see only the S7 core running, set the MAX number of cores to 1

I successfully got FreeRTOS up and running with Linux.

The key points

  • Modifying OpenSBI, so the S7 core jumps to an appropriate address ( this jump can be triggered from the Linux kernel)
  • Adding a wait loop, into which the S7 core waits until it receives a kick to branch into the bare metal code (FreeRTOS)
  • A command line load application which loads the bare metal application into reserved memory (written using libmetal)
  • A kick application which forces the S7 core to jump to the bare metal code ( written using libmetal)

As a POC, it works quite well.

1 Like

Linux OpenAMP <-> FreeRTOS OpenAMP

Managed to get OpenAMP up and running on the Linux and FreeRTOS (S7 core) and demonstrated a simple Ping-Echo application. It uses polling, so bypasses the use of interrupts.

My short adventure with the unmatched board finishes here.

Just a suggestion, but it would be cool if you documented your patches and recipes somewhere.