Why Linux can't use both RISC-V cores?

I think Duo is a great board, and I’m planning to use CV1800B SoC in one of my upcoming projects. But the thing that makes me scratch my head is that only first RISC-V core (1GHz one) can be used to run Linux, while the other one (700 MHz one) may only run simpler RTOS. I was curious why is that and tried to look for a reason for that limitation, but found nothing. This post of a Milk-V representative simply states that second core just won’t run Linux, even if it’s not used to run RTOS. But otherwise there are no information whatsoever that clarify the reason for which second core would not be usable on Linux. CV1800B datasheet also doesn’t contain any information on that matter.

So, what is technical reason that second RISC-V core can’t be used under Linux? Both cores are described as C906, so they should have identical structure under the hood. The only visible difference is in their speed, but I don’t think that’s enough of a reason for one core to be completely unusable under Linux just because it’s slower. In fact, desktop CPUs tend to have variable speeds for each of their core depending on the workload and the system somehow manages it. So then again - what limits the second core so that Linux could not use it?

2 Likes

It is a separate computer. In your desktop computer, there’s a lot of mechanisms in action to enable multicore processing.

Also, feel free to imagine dual-core operation of an ARM + RISC-V combination in Duo 256M / Duo S.

If it is a separate cpu, can it be used like a gpu - to process all ones graphics needs?

1 Like

It is a separate computer

What do you mean “separate computer”?

Also, feel free to imagine dual-core operation of an ARM + RISC-V combination in Duo 256M / Duo S

I’m not talking about these though. I know running same OS on two different architecture cores would not be possible.

I mean it is rather yet another computer alongside the main one, than a secondary core of the same CPU.

All the work required for making them work together you will have to implement yourself.

EDIT: But it doesn’t mean I don’t like your thinking.

Hey mate, just jumping in a bit here.

While they are both C906, that is just the name of the cores design by Xuantie that implements the RISC-V 64-bit architecture. It does not mean they are the same at all, as the implementation can be with different features turned on and off depending on the use case. Most processor designs from any ISA are like this, but not all MCU/SOC designers combine them as such - it requires a specific use case, like Milk-V have done with their Duo series. With this implementation, they are operating in two different domains, thus at the most basic level: if one crashes, the other doesn’t.

On to your query re the technical reason.
The primary C906 core is 1GHz and off the top of my head its specification is RV64IMAFDCV. Note that the ‘V’ there as it’s the RVV 0.71 ‘T-Head’ extensions from what I know, not the real RVV implementation - albeit apparently just as good. Those ‘IMADFC’ extensions though, which can also be summarised as ‘GC’ as best I know, are essentially the minimum requirements for running Linux in most cases. Technically you can probably run Linux on RV64IMAF but that’d be a custom build/patching most likely.

The second core in these SOCs is both C906 and 700MHz as you stated, but a different configuration of that design. It firstly lacks an L2 cache like the main core has, which is going to add notable hinderance to the core trying to make use of the DDR subsystem aka RAM. Secondly though, this is RV64IMFD from what I recall. This means it’s lacking Atomic instructions, and 16-bit compressed instructions. Both of these are essentially mandatory to run Linux.

So the way this is instead designed, is that the lesser core can run RTOS applications, such as FreeRTOS, Arduino, or your own custom code to provide ancillary, low power or watchdog services. It can then communicate with the primary OS core via the implemented mailbox.

I hope that helps clarify the why and how for you :blush:

6 Likes

Yes, that is essentially exactly what it does :smile:

1 Like

Do you remember where did you read that by any chances ?

That was from me using it, not from reading. Might have even been RV64IMAC.

I did a quick Google search though and found the Duo Arduino code (that runs on the smaller core) is compiled with -march=rv64imfd, so I think I was right the first time.

Ref: duo-arduino/platform.txt at dev · milkv-duo/duo-arduino · GitHub

2 Likes

The freertos code from the duo-buildroot-sdk is compiled with -march=rv64imafdc.

From my experience, I can confirm that the atomic instructions don’t work. But the compressed instructions seem to work, if I understand objdump -d output correctly (I see a lot of instructions that only use 16 bits)

1 Like

Is it? Didn’t know that! Might be a mistake, especially if atomic instructions definitely don’t work and the Arduino code is rv64imfd. Good find though.

And yeah I am not 100% sure if Linux would work without atomics, but I am guessing not!

1 Like

From my experience, I can confirm that the atomic instructions don’t work.

After more experiment, only atomic operation on hardware register make the software crash. But I don’t know if atomics on normal memory just appears to works but are not synchronized or really work.

Ping @Platima

1 Like

Very interesting. No clue here though sorry mate. You’d probably need to have a good read of duo-files/duo/datasheet/CV1800B-CV1801B-Preliminary-Datasheet-full-en.pdf at main · milkv-duo/duo-files · GitHub

My understanding was just based on a bit of reading over the months, and then some quick Googling.

2 Likes

Further to this, I’ve found from looking into C906B vs C906L, that the little core has no MMU. So whether or not it has C or A extensions, no data or instruction cache, and no MMU, so not sure if memory sharing would work and I don’t think there’s any way a Linux kernel would run on it.

2 Likes

The Linux kernel needs an MMU for its basic functions. RTOS doesn’t need an MMU.

You can run a Linux without an MMU for use on microcontrollers. So theoretically one might be able to run a second Linux kernel on the second core, it could be a fun experiment if it could run mailbox.

https://www.kernel.org/doc/html/latest/admin-guide/mm/nommu-mmap.html

3 Likes

Also, the a in rv64imafdc signifies support for atomics. And if the core didn’t support atomics I don’t think RTOS would run.

1 Like

Yeah RV64IMAFDC is the primary core though, from what I could find and cited earlier, the C906L might be IMFD, although one user apparently saw 16-bit instructions working signififying the C extension.

Either way without MMU the point is moot.

1 Like