b9e4fcfc68
整合libcpu/riscv中的移植文件 提供一份公共代码于common 在提交本pr时,除hpmicro的内核,rv32内核bsp已完成去除大部分的冗余,大部分代码采用common中的实现。本pr的作用是进一步统一common中的文件,从而提供一份公用代码,新移植的RV32内核的BSP可以全部使用common代码。 - 在common中提供一份公用文件:interrupt_gcc.S - 修改原有的文件,将原有的中断中上下文切换代码替换为interrupt_gcc.S - 基于上述修改,修改仓库中risc-v内核的BSP与移植相关的部分 (主要包含中断入口函数 中断栈等) - 在common中提供一份公用文件:trap_common.c;提供统一中断入口函数,中断入口函数初始化,中断入口注册等函数,并完善异常时的信息输出 - 在common中提供一份公用文件:rt_hw_stack_frame.h;将栈帧结构体剥离,供用户使用 - 在上述工作完成后,在上述工作的基础上测试仓库中risc-v内核的BSP - 完善函数中的命名,完善中断栈的获取 - 提供一份详细的基于现有common文件的移植指南 #### 在什么测试环境下测试通过 - 1.CH32V307V-R1-R0 - 2.CH32V208W-R0-1V4 - 3.HPM6750EVKMINI - 4.GD32VF103V-EVAL - 5.qemu(CORE-V-MCU ) > 与上述开发板使用同样芯片的BSP均测试通过 在CH32V307V-R1-R0与HPM6750EVKMINI上基于现有移植文件进行多线程复杂场景下的长时间测试,测试过程系统运行正常。 |
||
---|---|---|
.. | ||
applications | ||
board | ||
figures | ||
.config | ||
Kconfig | ||
SConscript | ||
SConstruct | ||
readme.md | ||
readme_EN.md | ||
rtconfig.h | ||
rtconfig.py |
readme_EN.md
Core-V-MCU BSP Description
English| Chinese
1 MCU Introduction
The purpose of Core-V-MCU is to show cv32e40p, which is a fully validated RISC-V kernel provided by Open Hardware Group (OpenHW). The cv32e40p core is connected to a group of representative peripherals.
Core-V-MCU resources:
- 2xUART
- 2xI2C master
- 1xI2C slave
- 2xQSPI master
- 1xCAMERA
- 1xSDIO
- 4xPWM
- eFPGA with 4 math units
For more information, please visitIntroduction to Core-V-MCU
More resources,please visitOpenHW official website
2 Compilation Description
The board level package supports the RISC-V GCC development environment. The specific version information is as follows:
IDE/Compiler | Tested version |
---|---|
GCC | riscv32-unknown-elf-gcc |
3 Instruction for user
This chapter is provided for users who use RT Thread on the Core-V-MCU. At present, the Core-V-MCU has no actual hardware and uses QEMU to implement simulation. The qemu used in this article is compiled under the ubuntu18.04 environment.
3.1 Compile BSP with Env
This section explains how to use Env tools to compile BSP projects.
3.1.1 编译BSP
-
Preparation 1:Download GCC compilation tool chain under Linux environment),put the downloaded tool chain in your Linux environment.
-
Preparation 2:Install ENV under Linux environment, and run the following command on the console.
wget https://gitee.com/RT-Thread-Mirror/env/raw/master/install_ubuntu.sh chmod 777 install_ubuntu.sh ./install_ubuntu.sh --gitee
-
Preparation 3:Compile qemu provided by PLCT lab in Linux environment,Refer to the compilation method given in README.rst to compile qemu in the Linux environment, or use theqemu.
-
Windows environment download RT Thread最新源码,This step can also be completed in the Linux environment.
-
Download in the Windows environment Open the Env tool under the current BSP root directory and execute the following command to compile, 'scons -- exec path=tool chain path'. The tool chain under Windows can be downloaded directly using RT Studio. The path of the tool chain is configured according to the user's specific environment. This step can also be completed in the Linux environment. The example command is as follows:
scons --exec-path=D:\RT-ThreadStudio\repo\Extract\ToolChain_Support_Packages \RISC-V\RISC-V-GCC-RV32\2022-04-12\bin
Compile directly while specifying the tool chain location, and then generate the rtthread.elf file.
![compilation result of core-v-mcu ](figures/compilation result of core-v-mcu .png)
-
Try running rtthread.elf, copy the rtthread.elf generated in the previous step to the bin file directory of the compiled qemu tool, and execute the following command:
./qemu-system-riscv32 -M core_v_mcu -bios none -kernel rtthread.elf -nographic -monitor none -serial stdio
The operation results are as follows:
7.Run the following command to generate a complete, copyable project.
scons --dist
Copy the generated independent project to the Linux environment.
3.2Compile and run the project in the Linux environment
3.2.1 Configuration project
1.Found in the complete project root directory copied abovertconfig.h,remove the precompiled command from the file**#ifndef RT_CONFIG_H__,#define RT_CONFIG_H__,#ifndef RT_CONFIG_H__,#endif**,be sure to perform this step, or an error will be reported during compilation.
![remove ifdef](figures/remove ifdef.png)
2.Line the following command to generate the makefile project
scons --target=makefile
3.Enter **make ** at the command line to compile the project
4.Run the following command to start qemu and compile rtthread.elf,/home/wangshun/bin/qemu-riscv/bin/qemu-system-riscv32
is the tool chain path of the Linux environment. It is set here as the user's tool chain path.
/home/wangshun/bin/qemu-riscv/bin/qemu-system-riscv32 -M core_v_mcu -bios none -kernel rtthread.elf -nographic -monitor none -serial stdio
BSP supports the Finsh component of RT-Thread. Enter the commandversion
to view the version information of RT-Thread. Click Tap to view the supported commands. The running results are as follows:
So far, the configuration and running test of RT-Thread project based on Core-V-MCU have been completed.
3.3 Import the RT Thread project into OpenHW's Core V-IDE
1.Download and Installcore-v-sdk,according README.mdto install the IDE in a Linux environment。
2.Create a workspace folder in the home directory, and open the IDE to use the workspace folder as the working path.
3.ChooseImport projects Option
:
4.ChooseExisting Code as Makefile Project
:
![makefile project](figures/makefile project.png)
5.The settings are as follows:
6.Project configuration settings:
7.Modify compilation command:
8.Clear the files compiled from the project and recompile the project:
9.Run the following command in the root directory of the project compiled with IDE, and the result is consistent with that of 3.2.1. The project under IDE will be configured. So far, the import and running tests of the RT-Thread project imported from IDE to Core-V-MCU have been completed.
3.4调试配置
1.Debug Configurations settings:
2.Double clickGDB OpenOCD Debugging
,build debug configuration options:
3.Import on chip peripheral register file:
PATH:OpenHW/CORE-V-SDKv0.0.0.4/registers/csr
,the specific path is configured according to the SDK path installed by the user。
![register file](figures/register file.png)
3.Import on chip peripheral register file:
PATH/home/wangshun/OpenHW/CORE-V-SDKv0.0.0.4/registers/peripheral
,the specific path is configured according to the SDK path installed by the user.
3.Configure the QEMU running environment:
CancleStart OpenOCD locally
,the configuration parameters are as follows:
4.Run the following commands:
/home/wangshun/bin/qemu-riscv/bin/qemu-system-riscv32 -M core_v_mcu -bios none -kernel rtthread.elf -nographic -monitor none -serial stdio -s -S
5.Click debug to start debugging:
4.CLI components
The FreeRTOS project provided by OPENHW supports a CLI component for testing. To ensure compatibility with the original CLI when using RT Thread again, the original CLI is made into an independent software package. At the same time, the software package automatically opens the FreeRTOS compatibility layer, so the software package can support the original CLI components and still use FreeRTOS interface functions.
4.1使用方法
Enable CorevMCU with menuconfig configuration in ENV tool_ CL software package, place the sample code in example. c at the prompt of main. c. The steps to use menuconfig configuration are as follows:
RT-Thread online packages
miscellaneous packages --->
[*] CorevMCU_CLI