-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
xingrz
wants to merge
15
commits into
zephyrproject-rtos:main
Choose a base branch
from
xingrz:milkv-duo/hwmv2/dev
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,921
−5
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
8c393e3
dts: vendor-prefixes: Add thead
xingrz 53cbe69
dts: vendor-prefixes: Add sophgo
xingrz 4d620e7
dts: vendor-prefixes: Add milkv
xingrz ae4c85c
dts: bindings: Add T-Head C906 CPU
xingrz 9375f68
drivers: timer: riscv_machine_timer: Add support for T-Head C906
xingrz 354af7e
dts/soc: sophgo: Add SOPHGO CV1800B
xingrz b9eda39
dts/soc: sophgo: Add SOPHGO SG2000/SG2002
xingrz 5f0b7a7
drivers: pinctrl: Add pinctrl driver for SOPHGO CVI series
xingrz 34255cb
drivers: pwm: Add PWM driver for SOPHGO CVI series
xingrz 175cfcc
drivers: mbox: Add mailbox driver for SOPHGO CVI series
lenghonglin c448c20
scripts: runners: Add cvi-fiptool
xingrz fd967a4
boards: milkv: Bring up Milk-V Duo
xingrz 2e00e82
boards: milkv: Bring up Milk-V Duo S
xingrz ddc6fad
tests: drivers: pwm: Add overlay for Milk-V boards
xingrz 4788d88
MAINTAINERS: Add SOPHGO platform and assign myself as maintainer
xingrz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
board_set_flasher_ifnset(cvi-fiptool) | ||
board_finalize_runner_args(cvi-fiptool) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Copyright (c) 2023-2024 Chen Xingyu <hi@xingrz.me> | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
config BOARD_MILKV_DUO | ||
select SOC_CV1800B if BOARD_MILKV_DUO_CV1800B_C906_1 | ||
select SOC_SG2002 if BOARD_MILKV_DUO_SG2002_C906_1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
include(${ZEPHYR_BASE}/boards/common/cvi-fiptool.board.cmake) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
board: | ||
name: milkv_duo | ||
full_name: Duo | ||
vendor: milkv | ||
socs: | ||
- name: cv1800b | ||
- name: sg2002 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
.. zephyr:board:: milkv_duo | ||
|
||
Overview | ||
******** | ||
|
||
See https://milkv.io/duo | ||
|
||
Supported Features | ||
================== | ||
|
||
.. zephyr:board-supported-hw:: | ||
|
||
Programming and Debugging | ||
************************* | ||
|
||
Prepare a TF card and follow the instructions in the `official SDK`_ to build | ||
and flash the image. | ||
|
||
After that, you will get a ``fip.bin`` file at the root of the TF card, where | ||
the RTOS image is packed. | ||
|
||
The following steps demonstrate how to build the blinky sample and update the | ||
``fip.bin`` file on the TF card. | ||
|
||
.. zephyr-app-commands:: | ||
:zephyr-app: samples/basic/blinky | ||
:board: milkv_duo/cv1800b/c906_1 | ||
:goals: build flash | ||
:flash-args: --fiptool /path/to/duo-buildroot-sdk/fsbl/plat/cv180x/fiptool.py --fip-bin /path/to/tfcard/fip.bin | ||
|
||
Eject the TF card and insert it into the board. Power on the board and you will | ||
see the LED blinking. | ||
|
||
.. note:: | ||
|
||
Notes for the official buildroot SDK | ||
|
||
1. The Linux running on the big core uses UART0 (GP12/GP13) for the console, | ||
while to avoid conflict, the Zephyr application (in the default board | ||
configuration) uses UART1 (GP0/GP1). | ||
2. Pin multiplexing can be handled either by U-Boot or Zephyr. To utilize | ||
Zephyr's pin multiplexing, enable :kconfig:option:`CONFIG_PINCTRL` and | ||
recompile U-Boot without the PINMUX configs. The source code for the | ||
PINMUX configs varies by SoC: | ||
|
||
* For Duo (CV1800B), see `PINMUX configs (Duo)`_ | ||
* For Duo 256M (SG2002), see `PINMUX configs (Duo 256M)`_ | ||
|
||
Note that U-Boot boots several seconds after Zephyr. | ||
3. By default, the Linux running on the big core will blink the LED on the | ||
board. To demonstrate Zephyr (specifically, the ``samples/basic/blinky`` | ||
sample), you should remove the script from the Linux filesystem located at | ||
``/mnt/system/blink.sh``. | ||
|
||
.. _official SDK: | ||
https://github.com/milkv-duo/duo-buildroot-sdk | ||
|
||
.. _PINMUX configs (Duo): | ||
https://github.com/milkv-duo/duo-buildroot-sdk/blob/develop/build/boards/cv180x/cv1800b_milkv_duo_sd/u-boot/cvi_board_init.c | ||
|
||
.. _PINMUX configs (Duo 256M): | ||
https://github.com/milkv-duo/duo-buildroot-sdk/blob/develop/build/boards/cv181x/cv1812cp_milkv_duo256m_sd/u-boot/cvi_board_init.c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Copyright (c) 2023-2024 Chen Xingyu <hi@xingrz.me> | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
&pinctrl { | ||
uart1_default: uart1_default { | ||
group1 { | ||
pinmux = <CVI_PINMUX(IIC0_SCL, UART1_TX)>, /* GP0 */ | ||
<CVI_PINMUX(IIC0_SDA, UART1_RX)>; /* GP1 */ | ||
}; | ||
}; | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright (c) 2023-2024 Chen Xingyu <hi@xingrz.me> | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/dts-v1/; | ||
|
||
#include <sophgo/cv180x.dtsi> | ||
#include <zephyr/dt-bindings/gpio/gpio.h> | ||
|
||
#include "milkv_duo-pinctrl.dtsi" | ||
|
||
/ { | ||
model = "Milk-V Duo coprocessor"; | ||
compatible = "milkv,duo"; | ||
|
||
chosen { | ||
zephyr,sram = &sram; | ||
zephyr,console = &uart1; | ||
zephyr,shell-uart = &uart1; | ||
}; | ||
|
||
aliases { | ||
led0 = &led; | ||
}; | ||
|
||
leds { | ||
compatible = "gpio-leds"; | ||
|
||
led: led { | ||
gpios = <&gpioc 24 GPIO_ACTIVE_HIGH>; | ||
}; | ||
}; | ||
|
||
soc { | ||
/* | ||
* Memory region reserved for the RTOS core. | ||
* | ||
* Keep in sync with FREERTOS_ADDR and FREERTOS_SIZE in | ||
* build/boards/cv180x/cv1800b_milkv_duo_sd/memmap.py | ||
* | ||
* see: https://github.com/milkv-duo/duo-buildroot-sdk | ||
*/ | ||
sram: memory@83f40000 { | ||
compatible = "mmio-sram"; | ||
reg = <0x83f40000 DT_SIZE_K(768)>; | ||
}; | ||
}; | ||
}; | ||
|
||
&gpioc { | ||
status = "okay"; | ||
}; | ||
|
||
&uart1 { | ||
status = "okay"; | ||
pinctrl-0 = <&uart1_default>; | ||
pinctrl-names = "default"; | ||
current-speed = <115200>; | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
identifier: milkv_duo/cv1800b/c906_1 | ||
name: Milk-V Duo coprocessor | ||
type: mcu | ||
arch: riscv | ||
toolchain: | ||
- zephyr | ||
ram: 768 | ||
supported: | ||
- clock | ||
- gpio | ||
- interrupt-controller | ||
- mailbox | ||
- pinctrl | ||
- pwm | ||
- serial |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Copyright (c) 2023-2024 Chen Xingyu <hi@xingrz.me> | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
CONFIG_XIP=n | ||
|
||
CONFIG_GPIO=y | ||
CONFIG_SERIAL=y | ||
|
||
CONFIG_CONSOLE=y | ||
CONFIG_UART_CONSOLE=y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright (c) 2024 Chen Xingyu <hi@xingrz.me> | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/dts-v1/; | ||
|
||
#include <sophgo/cv181x.dtsi> | ||
#include <zephyr/dt-bindings/gpio/gpio.h> | ||
|
||
#include "milkv_duo-pinctrl.dtsi" | ||
|
||
/ { | ||
model = "Milk-V Duo 256M coprosessor"; | ||
compatible = "milkv,duo"; | ||
|
||
chosen { | ||
zephyr,sram = &sram; | ||
zephyr,console = &uart1; | ||
zephyr,shell-uart = &uart1; | ||
}; | ||
|
||
aliases { | ||
led0 = &led; | ||
}; | ||
|
||
leds { | ||
compatible = "gpio-leds"; | ||
|
||
led: led { | ||
gpios = <&pwr_gpio 2 GPIO_ACTIVE_HIGH>; | ||
}; | ||
}; | ||
|
||
soc { | ||
/* | ||
* Memory region reserved for the RTOS core. | ||
* | ||
* Keep in sync with FREERTOS_ADDR and FREERTOS_SIZE in | ||
* build/boards/cv181x/cv1812cp_milkv_duo256m_sd/memmap.py | ||
* | ||
* see: https://github.com/milkv-duo/duo-buildroot-sdk | ||
*/ | ||
sram: memory@8fe00000 { | ||
compatible = "mmio-sram"; | ||
reg = <0x8fe00000 DT_SIZE_M(2)>; | ||
}; | ||
}; | ||
}; | ||
|
||
&pwr_gpio { | ||
status = "okay"; | ||
}; | ||
|
||
&uart1 { | ||
status = "okay"; | ||
pinctrl-0 = <&uart1_default>; | ||
pinctrl-names = "default"; | ||
current-speed = <115200>; | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
identifier: milkv_duo/sg2002/c906_1 | ||
xingrz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
name: Milk-V Duo 256M coprocessor | ||
type: mcu | ||
arch: riscv | ||
toolchain: | ||
- zephyr | ||
ram: 2048 | ||
supported: | ||
- clock | ||
- gpio | ||
- interrupt-controller | ||
- mailbox | ||
- pinctrl | ||
- pwm | ||
- serial |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Copyright (c) 2024 Chen Xingyu <hi@xingrz.me> | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
CONFIG_XIP=n | ||
|
||
CONFIG_GPIO=y | ||
CONFIG_SERIAL=y | ||
|
||
CONFIG_CONSOLE=y | ||
CONFIG_UART_CONSOLE=y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Copyright (c) 2024 Chen Xingyu <hi@xingrz.me> | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
config BOARD_MILKV_DUOS | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will need changing to be explicit about the 906_1 core eventually. Not sure if you want to plan ahead and adjust the naming now, or just refactor when we are that support. Raising it here as a note more than anything. |
||
select SOC_SG2000 if BOARD_MILKV_DUOS_SG2000_C906_1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
include(${ZEPHYR_BASE}/boards/common/cvi-fiptool.board.cmake) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
board: | ||
name: milkv_duos | ||
full_name: Duo S | ||
vendor: milkv | ||
socs: | ||
- name: sg2000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
.. zephyr:board:: milkv_duos | ||
|
||
Overview | ||
******** | ||
|
||
See https://milkv.io/duo-s | ||
|
||
Supported Features | ||
================== | ||
|
||
.. zephyr:board-supported-hw:: | ||
|
||
Programming and Debugging | ||
************************* | ||
|
||
Prepare a TF card and follow the instructions in the `official SDK`_ to build | ||
and flash the image. | ||
|
||
After that, you will get a ``fip.bin`` file at the root of the TF card, where | ||
the RTOS image is packed. | ||
|
||
The following steps demonstrate how to build the blinky sample and update the | ||
``fip.bin`` file on the TF card. | ||
|
||
.. zephyr-app-commands:: | ||
:zephyr-app: samples/basic/blinky | ||
:board: milkv_duos/sg2000/c906_1 | ||
:goals: build flash | ||
:flash-args: --fiptool /path/to/duo-buildroot-sdk/fsbl/plat/cv181x/fiptool.py --fip-bin /path/to/tfcard/fip.bin | ||
|
||
Eject the TF card and insert it into the board. Power on the board and you will | ||
see the LED blinking. | ||
|
||
.. note:: | ||
|
||
Notes for the official buildroot SDK | ||
|
||
1. The Linux running on the big core uses UART0 (A16/A17) for the console, | ||
while to avoid conflict, the Zephyr application (in the default board | ||
configuration) uses UART2 (A19/A18). | ||
2. Pin multiplexing can be handled either by U-Boot or Zephyr. To utilize | ||
Zephyr's pin multiplexing, enable :kconfig:option:`CONFIG_PINCTRL` and | ||
recompile U-Boot without the `PINMUX configs`_. Note that U-Boot boots | ||
several seconds after Zephyr. | ||
|
||
.. _official SDK: | ||
https://github.com/milkv-duo/duo-buildroot-sdk | ||
|
||
.. _PINMUX configs: | ||
https://github.com/milkv-duo/duo-buildroot-sdk/blob/develop/build/boards/cv181x/cv1813h_milkv_duos_sd/u-boot/cvi_board_init.c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Copyright (c) 2024 Chen Xingyu <hi@xingrz.me> | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
&pinctrl { | ||
uart1_default: uart1_default { | ||
group1 { | ||
pinmux = <CVI_PINMUX(JTAG_CPU_TMS, UART1_TX)>, /* A19 */ | ||
<CVI_PINMUX(JTAG_CPU_TCK, UART1_RX)>; /* A18 */ | ||
}; | ||
}; | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.