Skip to content
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

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

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions MAINTAINERS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3524,6 +3524,26 @@ Silabs SiM3U Platforms:
description: >-
SiM3U SoCs, dts files, and related drivers. Boards based on SiM3U SoCs.

SOPHGO Platforms:
status: maintained
maintainers:
- xingrz
collaborators:
- lenghonglin
files:
- boards/common/cvi-fiptool.board.cmake
- boards/milkv/duo/
- boards/milkv/duo256m/
- boards/milkv/duos/
- dts/riscv/sophgo/
- dts/bindings/*/sophgo,*
- drivers/*/*.sophgo
- drivers/*/*_sophgo_*.c
- scripts/west_commands/runners/cvi_fiptool.py
- soc/sophgo/
labels:
- "platform: SOPHGO"

Intel Platforms (X86):
status: maintained
maintainers:
Expand Down
4 changes: 4 additions & 0 deletions boards/common/cvi-fiptool.board.cmake
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)
5 changes: 5 additions & 0 deletions boards/milkv/duo/Kconfig.milkv_duo
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright (c) 2023-2024 Chen Xingyu <[email protected]>
# SPDX-License-Identifier: Apache-2.0

config BOARD_MILKV_DUO
select SOC_CV1800B
3 changes: 3 additions & 0 deletions boards/milkv/duo/board.cmake
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)
5 changes: 5 additions & 0 deletions boards/milkv/duo/board.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
board:
name: milkv_duo
vendor: milkv
socs:
- name: cv1800b
89 changes: 89 additions & 0 deletions boards/milkv/duo/doc/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
.. _duo:

Milk-V Duo
##########

Overview
********

See https://milkv.io/duo

Supported Features
==================
The Milk-V Duo board configuration supports the following hardware features:

.. list-table::
:header-rows: 1

* - Peripheral
- Kconfig option
- Devicetree compatible
* - Mailbox
- :kconfig:option:`CONFIG_MBOX`
- :dtcompatible:`sophgo,cvi-mailbox`
* - Pin controller
- :kconfig:option:`CONFIG_PINCTRL`
- :dtcompatible:`sophgo,cvi-pinctrl`
* - GPIO
- :kconfig:option:`CONFIG_GPIO`
- :dtcompatible:`snps,designware-gpio`
* - PWM
- :kconfig:option:`CONFIG_PWM`
- :dtcompatible:`sophgo,cvi-pwm`
* - UART
- :kconfig:option:`CONFIG_SERIAL`
- :dtcompatible:`ns16550`
* - PLIC
- N/A
- :dtcompatible:`sifive,plic-1.0.0`
* - SysTick
- N/A
- :dtcompatible:`thead,machine-timer`

Other hardware features have not been enabled yet for this board.

The default configuration can be found in
:zephyr_file:`boards/milkv/duo/milkv_duo_defconfig`.

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
: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`_. 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:
https://github.com/milkv-duo/duo-buildroot-sdk/blob/develop/build/boards/cv180x/cv1800b_milkv_duo_sd/u-boot/cvi_board_init.c
13 changes: 13 additions & 0 deletions boards/milkv/duo/milkv_duo-pinctrl.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright (c) 2023-2024 Chen Xingyu <[email protected]>
* 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 */
};
};
};
60 changes: 60 additions & 0 deletions boards/milkv/duo/milkv_duo.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright (c) 2023-2024 Chen Xingyu <[email protected]>
* 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";
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>;
};
14 changes: 14 additions & 0 deletions boards/milkv/duo/milkv_duo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
identifier: milkv_duo
name: Milk-V Duo
type: mcu
arch: riscv
toolchain:
- zephyr
supported:
- clock
- gpio
- interrupt-controller
- mailbox
- pinctrl
- pwm
- serial
10 changes: 10 additions & 0 deletions boards/milkv/duo/milkv_duo_defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) 2023-2024 Chen Xingyu <[email protected]>
# SPDX-License-Identifier: Apache-2.0

CONFIG_XIP=n

CONFIG_GPIO=y
CONFIG_SERIAL=y

CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
5 changes: 5 additions & 0 deletions boards/milkv/duo256m/Kconfig.milkv_duo256m
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright (c) 2024 Chen Xingyu <[email protected]>
# SPDX-License-Identifier: Apache-2.0

config BOARD_MILKV_DUO256M
select SOC_SG2002
3 changes: 3 additions & 0 deletions boards/milkv/duo256m/board.cmake
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)
5 changes: 5 additions & 0 deletions boards/milkv/duo256m/board.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
board:
name: milkv_duo256m
vendor: milkv
socs:
- name: sg2002
89 changes: 89 additions & 0 deletions boards/milkv/duo256m/doc/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
.. _duo256m:

Milk-V Duo 256M
###############

Overview
********

See https://milkv.io/duo

Supported Features
==================
The Milk-V Duo 256M board configuration supports the following hardware features:

.. list-table::
:header-rows: 1

* - Peripheral
- Kconfig option
- Devicetree compatible
* - Mailbox
- :kconfig:option:`CONFIG_MBOX`
- :dtcompatible:`sophgo,cvi-mailbox`
* - Pin controller
- :kconfig:option:`CONFIG_PINCTRL`
- :dtcompatible:`sophgo,cvi-pinctrl`
* - GPIO
- :kconfig:option:`CONFIG_GPIO`
- :dtcompatible:`snps,designware-gpio`
* - PWM
- :kconfig:option:`CONFIG_PWM`
- :dtcompatible:`sophgo,cvi-pwm`
* - UART
- :kconfig:option:`CONFIG_SERIAL`
- :dtcompatible:`ns16550`
* - PLIC
- N/A
- :dtcompatible:`sifive,plic-1.0.0`
* - SysTick
- N/A
- :dtcompatible:`thead,machine-timer`

Other hardware features have not been enabled yet for this board.

The default configuration can be found in
:zephyr_file:`boards/milkv/duo256m/milkv_duo256m_defconfig`.

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_duo256m
: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 (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`_. 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:
https://github.com/milkv-duo/duo-buildroot-sdk/blob/develop/build/boards/cv181x/cv1812cp_milkv_duo256m_sd/u-boot/cvi_board_init.c
13 changes: 13 additions & 0 deletions boards/milkv/duo256m/milkv_duo256m-pinctrl.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright (c) 2024 Chen Xingyu <[email protected]>
* 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 */
};
};
};
Loading
Loading