Skip to content

Add support for SOPHGO SoCs and Milk-V boards #69594

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

xingrz
Copy link
Member

@xingrz xingrz commented Feb 29, 2024

This PR ports Zephyr to SOPHGO platforms, including 3 new SoCs and 2 boards:

Board Identifier SoC
Milk-V Duo milkv_duo/cv1800b/c906_1 CV1800B
Milk-V Duo (256M variant) milkv_duo/sg2002/c906_1 SG2002
Milk-V Duo S milkv_duos/sg2002/c906_1 SG2000

The CV1800B is a member of the SOPHGO CV180X series. It's a multi-core RV64 SoC, consists with a 1GHz T-Head C906 RV64 big core running Linux, and a 700MHz C906 RV64 little core running RTOS.

The SG2000/SG2002 is a successor of CV1800B, belonging to the CV181x series. It features a 1GHz ARM Cortex-A53 big core, a 1GHz T-Head C906 RV64 big core, and a 700MHz C906 RV64 little core.

This PR uses the cpuclusters field introduced by HWMv2 to distinguish between different cores within SOPHGO SoCs. The core names are based on SOPHGO’s official Technical Programming Manual (TPM):

Identifier Description
a53 ARM Cortex-A53 big core (available only on SG200x series, selected via BOOT GPIO)
c906_0 T-Head C906 big core (always available on CV1800B; selected via BOOT GPIO on SG200x)
c906_1 T-Head C906 little core (the one supported by this PR)

This PR brings Zephyr support to the C906 little core (the coprocessor), and lays the groundwork for future support of the A53/C906 big cores.

TODOs

@xingrz xingrz force-pushed the milkv-duo/hwmv2/dev branch 4 times, most recently from 1850acb to 3528150 Compare February 29, 2024 07:57
@nordicjm nordicjm added DNM This PR should not be merged (Do Not Merge) hwmv2-likely-conflict labels Feb 29, 2024
@xingrz xingrz force-pushed the milkv-duo/hwmv2/dev branch 6 times, most recently from 3a60a91 to 2a7c3f9 Compare March 1, 2024 08:16
@xingrz xingrz force-pushed the milkv-duo/hwmv2/dev branch from 2a7c3f9 to a6cdd36 Compare March 1, 2024 11:00
@xingrz xingrz force-pushed the milkv-duo/hwmv2/dev branch 2 times, most recently from 7e31aea to eb20e38 Compare March 1, 2024 14:32
@zephyrbot

This comment was marked as outdated.

@xingrz xingrz force-pushed the milkv-duo/hwmv2/dev branch from e17cef5 to f903fd7 Compare May 13, 2025 03:20
@kartben kartben requested a review from Copilot May 13, 2025 06:03
Copilot

This comment was marked as off-topic.

@xingrz xingrz force-pushed the milkv-duo/hwmv2/dev branch from f903fd7 to 2165da4 Compare May 13, 2025 06:13
@xingrz xingrz force-pushed the milkv-duo/hwmv2/dev branch from 2165da4 to 27d2570 Compare May 27, 2025 17:59
xingrz and others added 15 commits May 28, 2025 10:07
T-Head is a semiconductor chip business entity of Alibaba Group.

Signed-off-by: Chen Xingyu <hi@xingrz.me>
SOPHGO is a company focus on development of TPU and RISC-V processors.

Signed-off-by: Chen Xingyu <hi@xingrz.me>
MilkV is a RISC-V MCU company located in Shenzhen, China.

Signed-off-by: Chen Xingyu <hi@xingrz.me>
C906 is a RISC-V CPU designed by T-Head. This commit introduces its DTS
binding for later use.

Signed-off-by: Chen Xingyu <hi@xingrz.me>
This commit adapts the existing RISC-V Machine Timer driver to support the
T-Head C906 core, which lacks a standard memory-mapped `MTIME` register.

Changes include:

* Added `mtime-is-32bits` and `mtimecmp-is-32bits` properties to support
  SoCs where `MTIME`/`MTIMECMP` must be accessed as two separate 32-bit
  registers, even on 64-bit platforms.
* Added `mtime-is-csr` property to allow reading the timer value from the
  `time` CSR instead of a memory-mapped `MTIME` register.
* Made the `MTIME` register address optional in DTS; register addresses are
  now resolved by `reg-names` instead of relying on index position.

Signed-off-by: Chen Xingyu <hi@xingrz.me>
CV180x is a series of RV64 SoCs developed by SOPHGO (formerly CVITEK),
based on T-Head C906 CPU.

Co-authored-by: honglin leng <a909204013@gmail.com>
Signed-off-by: Chen Xingyu <hi@xingrz.me>
SG2000, also named "CV1813H". SG2002, also named "CV1812CP". Both of them
are multi-core SoCs developed by SOPHGO, belonging to the CV181x series.

Signed-off-by: Chen Xingyu <hi@xingrz.me>
This commit introduces a pin-controller driver for the CVI series SoCs by
SOPHGO.

Predefined pinmux values are also added. Please refer to the official
datasheet for the naming conventions of pins and signals.

Signed-off-by: Chen Xingyu <hi@xingrz.me>
This commit adds PWM driver for CVI series SoCs.

Signed-off-by: Chen Xingyu <hi@xingrz.me>
This implements a mailbox driver for CV18xx, a series of multi-core SoCs by
SOPHGO.

This driver enables the little core of CV18xx running RTOS to communicate
with its big core running Linux.

Signed-off-by: honglin leng <a909204013@gmail.com>
Signed-off-by: Chen Xingyu <hi@xingrz.me>
The SOPHGO CVI series SoCs load the RTOS kernel for the 2nd core from a
`fip.bin` located in the main storage.

This commit introduced a convenient script for updating the `fip.bin` on
the external storage mounted to the host, with the newly built
`zephyr.bin`.

Path to the `fiptool.py` from the official SDK should be provided.

Signed-off-by: Chen Xingyu <hi@xingrz.me>
Milk-V Duo is a tiny development board shipped with SOPHGO CV1800B.

Signed-off-by: Chen Xingyu <hi@xingrz.me>
Duo S is another development board by Milk-V, shipped with SOPHGO SG2000.

Signed-off-by: Chen Xingyu <hi@xingrz.me>
This commit adds an overlay to the PWM driver tests for Milk-V boards.

Signed-off-by: Chen Xingyu <hi@xingrz.me>
Also added @lenghonglin as collaborator

Signed-off-by: Chen Xingyu <hi@xingrz.me>
@xingrz xingrz force-pushed the milkv-duo/hwmv2/dev branch from 27d2570 to 4788d88 Compare May 28, 2025 02:08
Copy link

@leiche-cid
Copy link

@VynDragon @fkokosinski @henrikbrixandersen Hi, could you please go back again take a look since all CI checks have passed and all dependencies has merged. I think it's time to move forward.

@VynDragon
Copy link
Collaborator

VynDragon commented Jun 3, 2025

@VynDragon @fkokosinski @henrikbrixandersen Hi, could you please go back again take a look since all CI checks have passed and all dependencies has merged. I think it's time to move forward.

There are still some comments that weren't addressed.

Anyway I have some questions @xingrz:
Why is there no ram or flash zones defined? Or did I miss them?
And a fiptool question: If I wanted to load a custom bin instead of fsbl on the first core, should i use BL2 entry or BLCP entry?
NVM BL2 is what loads BLCP_2nd for the second core and blcp entry is a dummy on core 0.

@xingrz
Copy link
Member Author

xingrz commented Jun 3, 2025

Why is there no ram or flash zones defined? Or did I miss them?

The RAM region is defined in the board DTS, since the available memory is configurable and varies between boards.

As for flash: since Zephyr is always loaded into the second core by the BL and doesn’t run in XIP mode, I haven’t defined a flash region.

@VynDragon
Copy link
Collaborator

'

Ah and it runs from the same ram zone, okay, thank you.

Comment on lines +6 to +7
config SYS_CLOCK_HW_CYCLES_PER_SEC
default 25000000
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs to come from a DTS value

default 25000000

config NUM_IRQS
int
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not fixed

Comment on lines +6 to +8
config SYS_CLOCK_HW_CYCLES_PER_SEC
default 25000000

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above

Comment on lines +6 to +11
config SYS_CLOCK_HW_CYCLES_PER_SEC
default 25000000

config NUM_IRQS
int
default 128
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not fixed

@VynDragon
Copy link
Collaborator

@xingrz Will you be interested in also porting zephyr to core 0? I got my duo booting on NOR flash (DIP-8 W25Q64FV 🤣 ) for quick development and to have cklink jtag as well from there, zephyr bin can replace bl2.bin in fiptool and do the exact same ops easily and continue on without the need for sdcard or OS build.

@xingrz
Copy link
Member Author

xingrz commented Jun 5, 2025

@xingrz Will you be interested in also porting zephyr to core 0? I got my duo booting on NOR flash (DIP-8 W25Q64FV 🤣 ) for quick development and to have cklink jtag as well from there, zephyr bin can replace bl2.bin in fiptool and do the exact same ops easily and continue on without the need for sdcard or OS build.

@VynDragon That’s cool! But I’d prefer to keep this PR simple and focused, and leave that for someone to explore in the future.

@VynDragon
Copy link
Collaborator

VynDragon commented Jun 5, 2025

Of course, I meant past this PR, eg do you intend to continue development for this SoC and/or add support for zephyr on first core, or is it only submitting/up to the sophgo riscv hackaton thing's objectives?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Devicetree Binding PR modifies or adds a Device Tree binding area: Devicetree area: GPIO area: mbox area: Pinctrl area: Process area: PWM Pulse Width Modulation area: RISCV RISCV Architecture (32-bit & 64-bit) area: Samples Samples area: Timer Timer area: West West utility
Projects
None yet
Development

Successfully merging this pull request may close these issues.