Hello, I’ve done some work on going baremetal with the CV1800B (on a milkV duo).
My starting point was this thread: 使用 Opensbi 引导自己的操作系统
After that, the source code in the official repo was also useful.
I can now run code on both C906 cores. I use the method described in the post above, so that means the FSBL gets loaded first, and in turn configures the hardware and loads your own code. Clocks and the DDR controller get configured for you. Actually, you have access to SBI (OpenSBI) calls, but I haven’t used that yet.
On the main core, your code will run in the S-mode. On the second core, it will run in the M-mode.
Here are a few remarks:
- In this setup, the CPU clock for the main core is 850 MHz, and 594 MHz for the second core. You can change that using clock management registers.
- The CLINT registers are not accessible from the S-mode, because they are protected with PMP. This kind of bites, as the C906 defines a set of CLINT registers specific to the S-mode, but the whole CLINT area is protected. Probably out of simplicity. That means you can’t configure the CLINT timer from S-mode. But there’s a SBI call for that. It’s just not very efficient.
- Interrupts and exceptions are delegated to the S-mode on the main core. That works fine.
- The second core doesn’t seem to be able to access RAM outside of its “allocated” 768KB, which is placed at the very top of the RAM. I’ve tried sharing some RAM at a lower address, between the two cores, but it doesn’t seem to work. The odd thing is that accesses from the second core, outside of these upper 768KB, do not trigger any exception, but they just seem to have zero effect. A bit odd. And pretty inconvenient.
- The CV1800B datasheet (preliminary) is good to have, but it lacks a lot of information. There’s nothing about the Mailbox and nothing about the Pinmux.
- I’ve downloaded datasheets for the SG2000 and SG2002, which are very similar to the CV1800B, and these do add some doc about the Pinmux. So that helps. But, still nothing about the Mailbox, apparently. So all you have it to dig into the source code in the repo.
- Regarding sharing RAM and the Mailbox, you may precisely object that the Mailbox is made for sharing data between cores. But as far as I got it, there’s only 8 bytes of data in the Mailbox, so that’s very limited.
So, a few questions now:
- Is there any hope of getting updated datasheets with the missing information, at some point in the future?
- Is there, in particular, any documentation about how memory is mapped for the second core, which looks very opaque to me? Can anyone give me more info about why only the upper 768KB of RAM are accessible by the second core, if there’s any means to access any other area in RAM? And/or is there any way of using more RAM for the second core?