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

适配 Milk-V Duo #1

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

Conversation

xingrz
Copy link

@xingrz xingrz commented Feb 25, 2024

各位好,

这里是 Team ID 66 的你走线如丁似蛋队,由 @xingrz@lenghonglin 组成。这是我们团队在《RISC-V 软件移植及优化锦标赛:Zephyr 移植和演示》的答卷。

该 PR 适配了如下外设:

外设 Kconfig 选项 Devicetree compatible
Mailbox CONFIG_MBOX sophgo,cv18xx-mailbox
Pinctrl CONFIG_PINCTRL sophgo,cv180x-pinctrl
GPIO CONFIG_GPIO snps,designware-gpio
PWM CONFIG_PWM sophgo,cv180x-pwm
UART CONFIG_SERIAL ns16550
PLIC N/A sifive,plic-1.0.0
CLINT N/A sifive,clint0

以下外设虽在题目中有所提及,但官方 SDK 中未给出 FreeRTOS 实现,按照手册简单尝试后亦无法按预期工作,我们认为它们对小核不可用,因此暂未适配:

  • ADC
  • SPI
  • I²C

复现步骤

官方 SDK 构建出镜像并烧录到 TF 卡中。使用下列命令将 TF 卡中的小核固件替换为编译出来的 zephyr.bin

python3 /path/to/duo-buildroot-sdk/fsbl/plat/cv180x/fiptool.py \
    -v genfip "/path/to/tfcard/fip.bin" \
    --OLD_FIP="/path/to/tfcard/fip.bin" \
    --BLCP_2ND="build/zephyr/zephyr.bin"

注意事项

  1. 大核 Linux 默认使用 UART0 (GP12/GP13) 作为控制台输出;本次适配的 Zephyr board 使用 UART1 (GP0/GP1) 作为日志输出及 shell;
  2. 你需要重新编译官方的 Buildroot SDK 去除所有 PINMUX 设置,否则 U-Boot 启动后会覆盖 Zephyr 的 pinctrl 配置 (包括 UART1);
  3. 官方 SDK 编译的 Linux 默认会闪烁 Milk-V Duo 上的 LED,需要进入 Linux 后手动删除 /mnt/system/blink.sh 文件。

已验证的示例

samples/basic/blinky

涉及:GPIO,SysTick (CLINT 中断)

west build -b milkv_duo -s samples/basic/blinky -p

samples/subsys/shell/shell_module

涉及:UART (interrupt driven),PLIC 中断,PINMUX

west build -b milkv_duo -s samples/subsys/shell/shell_module -p

tests/drivers/pwm/pwm_api

涉及:PWM,PINMUX

west build -b milkv_duo -s tests/drivers/pwm/pwm_api -p

可从开发板 GP4 引脚观察到 PWM 输出。

samples/boards/milkv_duo/mbox

涉及:Mailbox (大小核通讯)

west build -b milkv_duo -s samples/boards/milkv_duo/mbox -p

如有任何问题请联系,
谢谢!

xingrz and others added 14 commits January 3, 2024 10:34
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 introduces the existing RISC-V Machine Timer driver to CV180x:

* Though it's a RV64I CPU, the MTIMECMP register can only be access in
  32-bit.
* `MTIME` should be read with a `rdtime` instruction, instead of memory
  access.

Signed-off-by: Chen Xingyu <hi@xingrz.me>
On some platforms, such as T-HEAD C906, edge-triggered interrupts are not
supported, and the `TRIG_TYPE` register does not exist. Accessing such a
register causes mcause 5 (Load access fault).

This commit introduces a Kconfig option to prevent such faults. On
platforms that do not support edge-triggered interrupts, this option should
be set to `n`. For backward compatibility reasons, this option is set to
`y` by default.

Co-authored-by: honglin leng <a909204013@gmail.com>
Signed-off-by: Chen Xingyu <hi@xingrz.me>
Getting the IRQ number with `DT_*IRQN` helpers instead of directly getting
the `irq` DT prop, so the multi-level interrupts are correctly encoded.

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>
This commit introduces a pin-controller driver for the CV180x series.

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 CV180x.

Signed-off-by: Chen Xingyu <hi@xingrz.me>
This implements a mailbox driver for CV18xx, a multi-core SoC 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>
Milk-V Duo is a tiny development board shipped with SOPHGO CV1800B.

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

Signed-off-by: Chen Xingyu <hi@xingrz.me>
This commit adds a mbox sample for the Milk-V Duo, a board equipped with
the SOPHGO CV1800B SoC.

The CV1800B is a multi-core SoC that consists of two C906 cores. The big
core, referred to as C906B, runs Linux, while the little core, referred to
as C906L, runs an RTOS.

This sample receives mailbox requests from the big core running the
official SDK's mailbox sample, prints the request body, and performs
example operations such as LED control.

Signed-off-by: honglin leng <a909204013@gmail.com>
@xingrz xingrz changed the title 适配 SOPHGO CV1800B 适配 Milk-V Duo Feb 25, 2024
@shiptux
Copy link

shiptux commented Mar 26, 2024

尊敬的参赛选手,您好。
本次锦标赛您所提交的 PR 初步复测结果如 https://github.com/plctlab/rvspoc/blob/main/Results/Verifications/P2307/README.md 所示。如有任何异议请回复本条评论。如确认无误请回复 “确认无误”,感谢您的配合。

@lenghonglin
Copy link

lenghonglin commented Mar 26, 2024

@shiptux 你好,我们查看了https://github.com/plctlab/rvspoc/tree/main/Results/Verifications/P2307 的验证结果,有一点需要提出申诉。
在验证结果中,任务切换功能是正常工作的,只是我们没有写在PR里面,麻烦工作人员对该samples/synchronization进行验证。

另外,按照组委会的建议,我们正在将贡献提交给Zephyr官方。参见 zephyrproject-rtos#69594

@shiptux
Copy link

shiptux commented Mar 26, 2024

@shiptux 你好,我们查看了https://github.com/plctlab/rvspoc/tree/main/Results/Verifications/P2307 的验证结果,有一点需要提出申诉。 在验证结果中,任务切换功能是正常工作的,只是我们没有写在PR里面,麻烦工作人员对该samples/synchronization进行验证。

另外,按照组委会的建议,我们正在将贡献提交给Zephyr官方。参见 zephyrproject-rtos#69594

您好,我们会在下午对此项进行复测,并将结果更新。感谢您的回复。

shiptux added a commit to shiptux/rvspoc that referenced this pull request Mar 26, 2024
shiptux added a commit to rv2036/rvspoc that referenced this pull request Mar 26, 2024
@shiptux
Copy link

shiptux commented Mar 26, 2024

参赛者 您好,我们已经在将复核结果更新在了。https://github.com/plctlab/rvspoc/blob/main/Results/Verifications/P2307/README.md 请您再次确认是否有误。

@lenghonglin
Copy link

参赛者 您好,我们已经在将复核结果更新在了。https://github.com/plctlab/rvspoc/blob/main/Results/Verifications/P2307/README.md 请您再次确认是否有误。

确认无误

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants