rt-thread-official/bsp/nuclei/gd32vf103_rvstar
Huaqi Fang ee4cabe69f [BSP][Nuclei] Add Nuclei RISC-V Processor support
* Nuclei RISC-V Processor support is added both RV32 and RV64
* Nuclei RVSTAR BSP is added, UART driver is added
* MSH works well in RVSTAR board

---------------------------

Squashed commit of the following:

commit b7368bc2ed
Author: Huaqi Fang <578567190@qq.com>
Date:   Fri Apr 17 14:38:54 2020 +0800

    [BSP][Nuclei] Pretty source code

    Signed-off-by: Huaqi Fang <578567190@qq.com>

commit 2c42a997f7
Author: Huaqi Fang <578567190@qq.com>
Date:   Thu Apr 16 15:51:03 2020 +0800

    [libcpu] Remove ARCH_NUCLEI in libcpu kconfig

    Signed-off-by: Huaqi Fang <578567190@qq.com>

commit 915ad4c076
Author: Huaqi Fang <578567190@qq.com>
Date:   Thu Apr 16 15:50:00 2020 +0800

    [BSP][Nuclei] Remove ARCH_NUCLEI in bsp KConfig

    Signed-off-by: Huaqi Fang <578567190@qq.com>

commit fe43869c79
Author: Huaqi Fang <578567190@qq.com>
Date:   Wed Apr 15 12:43:20 2020 +0800

    [BSP][NUCLEI] Simply application main.c

    Remove previous complicated application of gd32vf103_rvstar

    Signed-off-by: Huaqi Fang <578567190@qq.com>

commit 8fd31727bc
Author: Huaqi Fang <578567190@qq.com>
Date:   Wed Apr 15 12:38:04 2020 +0800

    [BSP][NUCLEI] Format application and board source code

    Signed-off-by: Huaqi Fang <578567190@qq.com>

commit b432308b20
Author: Huaqi Fang <578567190@qq.com>
Date:   Wed Apr 15 11:58:28 2020 +0800

    [BSP][Nuclei] Format source code of drivers of gd32vf103

    Signed-off-by: Huaqi Fang <578567190@qq.com>

commit 7366173d74
Author: Huaqi Fang <578567190@qq.com>
Date:   Wed Apr 15 11:54:02 2020 +0800

    [LIBCPU][NUCLEI] Optimize nuclei cpu portable code

    Signed-off-by: Huaqi Fang <578567190@qq.com>

commit 8c2cd4745b
Author: Huaqi Fang <578567190@qq.com>
Date:   Tue Apr 14 15:45:42 2020 +0800

    nuclei: Update README.md

    Signed-off-by: Huaqi Fang <578567190@qq.com>

commit fa8a2f24ea
Author: Huaqi Fang <578567190@qq.com>
Date:   Tue Apr 14 14:06:54 2020 +0800

    nuclei: Add gpio driver not tested

    Signed-off-by: Huaqi Fang <578567190@qq.com>

commit 1be40bc50b
Author: Huaqi Fang <578567190@qq.com>
Date:   Thu Apr 9 14:55:22 2020 +0800

    Nuclei: Update README.md

    Signed-off-by: Huaqi Fang <578567190@qq.com>

commit 4c8beb204b
Author: Huaqi Fang <578567190@qq.com>
Date:   Thu Apr 9 10:20:25 2020 +0800

    Nuclei: Change idle stack size from 256 to 396 bytes

    If changed to 396 bytes, then debug optimization level changed
    from O2 to O0, and the application can run successfully without
    stack overflow issue of tidle0 task
    warning: tidle0 stack is close to end of stack address.

    Signed-off-by: Huaqi Fang <578567190@qq.com>

commit da2bcf5c56
Author: Huaqi Fang <578567190@qq.com>
Date:   Thu Apr 9 10:11:40 2020 +0800

    nuclei: Remove unused kconfig

    Signed-off-by: Huaqi Fang <578567190@qq.com>

commit 0b932c677a
Author: Huaqi Fang <578567190@qq.com>
Date:   Thu Apr 9 09:32:22 2020 +0800

    nuclei: optimize drivers support

    Signed-off-by: Huaqi Fang <578567190@qq.com>

commit 0431f6f01f
Author: Huaqi Fang <578567190@qq.com>
Date:   Wed Apr 8 19:28:02 2020 +0800

    tools: Update mkdist.py for nuclei bsp

    Signed-off-by: Huaqi Fang <578567190@qq.com>

commit 0e1f502edf
Author: Huaqi Fang <578567190@qq.com>
Date:   Wed Apr 8 18:46:58 2020 +0800

    nuclei: optimize rvstar support directory

    Signed-off-by: Huaqi Fang <578567190@qq.com>

commit 1131f6e648
Author: Huaqi Fang <578567190@qq.com>
Date:   Wed Apr 8 18:37:24 2020 +0800

    nuclei: update kconfig

    Signed-off-by: Huaqi Fang <578567190@qq.com>

commit ad81c1d3bf
Author: Huaqi Fang <578567190@qq.com>
Date:   Wed Apr 8 15:43:00 2020 +0800

    nuclei: Rename board name

    Signed-off-by: Huaqi Fang <578567190@qq.com>

commit d780138a1a
Author: Huaqi Fang <578567190@qq.com>
Date:   Tue Apr 7 09:36:19 2020 +0800

    libcpu: Add Nuclei arch option in KConfig

    Signed-off-by: Huaqi Fang <578567190@qq.com>

commit 60320d34b1
Author: Huaqi Fang <578567190@qq.com>
Date:   Fri Apr 3 16:51:01 2020 +0800

    nuclei: Update nuclei sdk of rt-thread support

    Signed-off-by: Huaqi Fang <578567190@qq.com>

commit a042b806ef
Author: Huaqi Fang <578567190@qq.com>
Date:   Fri Apr 3 11:34:09 2020 +0800

    nuclei: modify application for not print anything

    Signed-off-by: Huaqi Fang <578567190@qq.com>

commit 2a9603adcb
Author: Huaqi Fang <578567190@qq.com>
Date:   Fri Apr 3 11:31:01 2020 +0800

    nuclei: Add .gitignore for nuclei bsp

    Signed-off-by: Huaqi Fang <578567190@qq.com>

commit 34aaf6aeba
Author: Huaqi Fang <578567190@qq.com>
Date:   Fri Apr 3 11:28:06 2020 +0800

    nuclei_sdk: update link script of rvstar to contain rt-thread needed sections

            /* section information for finsh shell */
            . = ALIGN(4);
            __fsymtab_start = .;
            KEEP(*(FSymTab))
            __fsymtab_end = .;

            . = ALIGN(4);
            __vsymtab_start = .;
            KEEP(*(VSymTab))
            __vsymtab_end = .;

            /* section information for initial. */
            . = ALIGN(4);
            __rt_init_start = .;
            KEEP(*(SORT(.rti_fn*)))
            __rt_init_end = .;

    The above code placed in rodata section

    Signed-off-by: Huaqi Fang <578567190@qq.com>

commit 3451466e9d
Author: Huaqi Fang <578567190@qq.com>
Date:   Fri Apr 3 10:04:42 2020 +0800

    bsp: Add initial commit of nuclei rvstar board bsp

    Signed-off-by: Huaqi Fang <578567190@qq.com>

Signed-off-by: Huaqi Fang <578567190@qq.com>
2020-04-17 21:07:29 +08:00
..
applications [BSP][Nuclei] Add Nuclei RISC-V Processor support 2020-04-17 21:07:29 +08:00
board [BSP][Nuclei] Add Nuclei RISC-V Processor support 2020-04-17 21:07:29 +08:00
.config [BSP][Nuclei] Add Nuclei RISC-V Processor support 2020-04-17 21:07:29 +08:00
Kconfig [BSP][Nuclei] Add Nuclei RISC-V Processor support 2020-04-17 21:07:29 +08:00
README.md [BSP][Nuclei] Add Nuclei RISC-V Processor support 2020-04-17 21:07:29 +08:00
SConscript [BSP][Nuclei] Add Nuclei RISC-V Processor support 2020-04-17 21:07:29 +08:00
SConstruct [BSP][Nuclei] Add Nuclei RISC-V Processor support 2020-04-17 21:07:29 +08:00
rtconfig.h [BSP][Nuclei] Add Nuclei RISC-V Processor support 2020-04-17 21:07:29 +08:00
rtconfig.py [BSP][Nuclei] Add Nuclei RISC-V Processor support 2020-04-17 21:07:29 +08:00

README.md

芯来科技RVSTAR开发板

简介

RVSTAR开发板 是由芯来科技公司推出的基于采用芯来科技RISC-V架构处理器芯片的GD32VF103的开发板。

更多关于 RVSTAR开发板 开发板的详细资料请参见 RVSTAR开发板快速入门

板载资源

硬件 描述
内核 Nuclei N205
架构 32-bit RV32IMAC
主频 108 MHz

工具安装

安装工具链

请根据安装Nuclei RISC-V GCC Toolchain和OpenOCD 来安装依赖的工具。

添加环境变量

将Nuclei RISC-V GCC Toolchain和OpenOCD的环境变量进行设置。

Windows

假设工具安装在 D:\Software\Nuclei目录下, 则可以修改系统环境变量PATH, 将D:\Software\Nuclei\gcc\bin;D:\Software\Nuclei\openocd\bin;增加到PATH中。

或者在ENV工具命令行中运行

set PATH=D:\Software\Nuclei\gcc\bin;D:\Software\Nuclei\openocd\bin;%PATH%

Linux

假设工具安装在 ~/Software/Nuclei目录下, 通过在Linux的.bashrc增加如下一行代码 来添加环境变量。

export PATH=~/Software/Nuclei/gcc/bin:~/Software/Nuclei/openocd/bin:$PATH

或者在ENV工具命令行中运行

export PATH=~/Software/Nuclei/gcc/bin:~/Software/Nuclei/openocd/bin:$PATH

注意: 对应的RISC-V GCC和OPENOCD的路径请替换成自己安装的路径。

烧写及执行

驱动设置

编译程序

下载好RT-Thread的代码和ENV工具以后。

按照ENV工具的教程, 在rt-thread\bsp\nuclei\gd32vf103_rvstar目录打开ENV工具命令行。

注意: 请确保Nuclei GCC和Nuclei OpenOCD的路径设置正确无误。

  1. 运行 pkgs --update来下载最新的依赖的Nuclei SDK开发包
  2. 可选: 运行 menuconfig来进行内核配置
  3. 运行 scons -c清理之前的编译结果
  4. 运行 scons来进行代码的编译

下载程序

在保证程序能够正常编译后, 在相同ENV终端执行scons --run upload进行代码的下载。

正常下载的输出如下:

scons: Reading SConscript files ...
Supported downloaded modes for board gd32vf103v_rvstar are flashxip, chosen downloaded mode is flashxip
Upload application rtthread.elf using openocd and gdb
riscv-nuclei-elf-gdb rtthread.elf -ex "set remotetimeout 240"                     -ex "target remote | openocd --pipe -f D:/workspace/Sourcecode/rt-thread/bsp/nuclei/gd32vf103_rvstar/packages/nuclei_sdk-latest/SoC/gd32vf103/Board/gd32vf103v_rvstar/openocd_gd32vf103.cfg"                     --batch -ex "monitor halt" -ex "monitor flash protect 0 0 last off" -ex "load"                     -ex "monitor resume" -ex "monitor shutdown" -ex "quit"
D:\Software\Nuclei\gcc\bin\riscv-nuclei-elf-gdb.exe: warning: Couldn't determine a path for the index cache directory.

Nuclei OpenOCD, 64-bit Open On-Chip Debugger 0.10.0+dev-00014-g0eae03214 (2019-12-12-07:43)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
rt_thread_idle_entry (parameter=0x0) at D:\workspace\Sourcecode\rt-thread\src\idle.c:251
251                 if (idle_hook_list[i] != RT_NULL)
cleared protection for sectors 0 through 127 on flash bank 0

Loading section .init, size 0x264 lma 0x8000000
Loading section .text, size 0x140de lma 0x8000280
Loading section .rodata, size 0x37c0 lma 0x8014360
Loading section .data, size 0x404 lma 0x8017b20
Start address 0x800015c, load size 98054
Transfer rate: 8 KB/sec, 10894 bytes/write.
shutdown command invoked
A debugging session is active.

        Inferior 1 [Remote target] will be detached.

Quit anyway? (y or n) [answered Y; input not from terminal]
Remote communication error.  Target disconnected.: Success.

下载程序之后, 连接串口(115200-N-8-1), 可以看到 RT-Thread 的输出信息:

initialize rti_board_start:0 done

 \ | /
- RT -     Thread Operating System
 / | \     4.0.3 build Apr  9 2020
 2006 - 2020 Copyright by rt-thread team
do components initialization.
initialize rti_board_end:0 done
initialize dfs_init:0 done
initialize libc_system_init:0 done
initialize finsh_system_init:0 done
msh />

在串口终端(我这里使用的是TeraTerm)输入ps即可查看当前线程工作情况:

msh />ps
thread   pri  status      sp     stack size max used left tick  error
-------- ---  ------- ---------- ----------  ------  ---------- ---
thread01  19  suspend 0x00000158 0x0000018c    87%   0x00000005 000
thread00  19  suspend 0x00000158 0x0000018c    87%   0x00000005 000
tshell    20  running 0x00000258 0x00001000    18%   0x00000004 000
tidle0    31  ready   0x000000a8 0x0000018c    59%   0x0000000e 000
timer      4  suspend 0x000000f8 0x00000200    49%   0x00000009 000
main      10  suspend 0x00000168 0x00000800    36%   0x00000006 000
msh />

调试程序

在保证程序编译成功后, 在相同ENV终端执行scons --run debug进行代码在命令行下进行GDB调试。

正常的调试输出如下:

scons: Reading SConscript files ...
Supported downloaded modes for board gd32vf103v_rvstar are flashxip, chosen downloaded mode is flashxip
Debug application rtthread.elf using openocd and gdb
riscv-nuclei-elf-gdb rtthread.elf -ex "set remotetimeout 240"                     -ex "target remote | openocd --pipe -f D:/workspace/Sourcecode/rt-thread/bsp/nuclei/gd32vf103_rvstar/packages/nuclei_sdk-latest/SoC/gd32vf103/Board/gd32vf103v_rvstar/openocd_gd32vf103.cfg"
D:\Software\Nuclei\gcc\bin\riscv-nuclei-elf-gdb.exe: warning: Couldn't determine a path for the index cache directory.
GNU gdb (GDB) 8.3.0.20190516-git
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=i686-w64-mingw32 --target=riscv-nuclei-elf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from rtthread.elf...
Remote debugging using | openocd --pipe -f D:/workspace/Sourcecode/rt-thread/bsp/nuclei/gd32vf103_rvstar/packages/nuclei_sdk-latest/SoC/gd32vf103/Board/gd32vf103v_rvstar/openocd_gd32vf103.cfg Nuclei OpenOCD, 64-bit Open On-Chip Debugger 0.10.0+dev-00014-g0eae03214 (2019-12-12-07:43)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
rt_thread_idle_entry (parameter=0x0) at D:\workspace\Sourcecode\rt-thread\src\idle.c:249
249             for (i = 0; i < RT_IDLE_HOOK_LIST_SIZE; i++)
(gdb)
(gdb) b main.c:35
Breakpoint 1 at 0x8000290: file applications\main.c, line 35.
(gdb) c
Continuing.
Note: automatically using hardware breakpoints for read-only addresses.

Breakpoint 1, thread_entry (parameter=0x0) at applications\main.c:35
35              rt_thread_mdelay(500);
(gdb)

调试例子参见如下文档:

为了更方便的进行调试, 也可以下载Nuclei Studio集成开发环境, 创建一个Debug Configuration, 选择编译好的 ELF文件, 然后配置OPENOCD和GDB即可, OPENOCD配置文件路径为bsp\nuclei\gd32vf103_rvstar\packages\nuclei_sdk-latest\SoC\gd32vf103\Board\gd32vf103v_rvstar\openocd_gd32vf103.cfg

驱动支持情况

驱动 支持情况 备注
UART 支持 RV-STAR板载串口是UART4

注:

  • 适配RT-Thread的驱动框架的代码在 ../libraries/gd32vf103/HAL_Drivers目录下。
  • 如果有开发者想适配更多的驱动, 请在对应目录下增加驱动适配支持。

联系人信息

维护人: