modify author description and fix bug of compiler errors,add readme for gap8

This commit is contained in:
Wang_Weigen
2021-09-03 14:24:41 +08:00
parent b22f9a3851
commit 6b7a233511
29 changed files with 364 additions and 833 deletions
+175
View File
@@ -0,0 +1,175 @@
# 从零开始构建矽璓工业物联操作系统:使用risc-v架构的gapuino 开发板
[XiUOS](http://xuos.io/) (X Industrial Ubiquitous Operating System) 矽璓工业物联操作系统是一款面向工业物联场景的泛在操作系统,来自泛在操作系统研究计划。所谓泛在操作系统(UOS: Ubiquitous Operating Systems),是支持互联网时代人机物融合泛在计算应用模式的新型操作系统,是传统操作系统概念的泛化与延伸。在泛在操作系统技术体系中,不同的泛在计算设备和泛在应用场景需要符合各自特性的不同UOS,XiUOS即是面向工业物联场景的一种UOS,主要由一个极简的微型实时操作系统(RTOS)内核和其上的智能工业物联框架构成,支持工业物联网(IIoT: Industrial Internet of Things)应用。
## 开发环境搭建
### 推荐使用:
**操作系统:** ubuntu18.04 [https://ubuntu.com/download/desktop](https://ubuntu.com/download/desktop)
**开发工具推荐使用 VSCode ,VScode下载地址为:** VSCode [https://code.visualstudio.com/](https://code.visualstudio.com/),推荐下载地址为 [http://vscode.cdn.azure.cn/stable/3c4e3df9e89829dce27b7b5c24508306b151f30d/code_1.55.2-1618307277_amd64.deb](http://vscode.cdn.azure.cn/stable/3c4e3df9e89829dce27b7b5c24508306b151f30d/code_1.55.2-1618307277_amd64.deb)
### 依赖包安装:
```
$ sudo apt install build-essential pkg-config
$ sudo apt install gcc make libncurses5-dev openssl libssl-dev bison flex libelf-dev autoconf libtool gperf libc6-dev git
```
**源码下载:** XiUOS [https://forgeplus.trustie.net/projects/xuos/xiuos](https://forgeplus.trustie.net/projects/xuos/xiuos)
新建一个空文件夹并进入文件夹中,并下载源码,具体命令如下:
```c
mkdir test && cd test
git clone https://git.trustie.net/xuos/xiuos.git
```
打开源码文件包可以看到以下目录:
| 名称 | 说明 |
| -- | -- |
| application | 应用代码 |
| board | 板级支持包 |
| framework | 应用框架 |
| fs | 文件系统 |
| kernel | 内核源码 |
| resources | 驱动文件 |
| tool | 系统工具 |
使用VScode打开代码,具体操作步骤为:在源码文件夹下打开系统终端,输入`code .`即可打开VScode开发环境,如下图所示:
![vscode](img/vscode.jpg)
### 裁减配置工具的下载
裁减配置工具:
**工具地址:** kconfig-frontends [https://forgeplus.trustie.net/projects/xuos/kconfig-frontends](https://forgeplus.trustie.net/projects/xuos/kconfig-frontends)
```c
mkdir kfrontends && cd kfrontends
git clone https://git.trustie.net/xuos/kconfig-frontends.git
```
下载源码后按以下步骤执行软件安装:
```c
cd kconfig-frontends
./xs_build.sh
```
### 编译工具链:
RISC-V: riscv-none-embed-,默认安装到Ubuntu的/opt/,下载源码并解压。[下载网址 http://101.36.126.201:8011/gnu-mcu-eclipse.tar.bz2](http://101.36.126.201:8011/gnu-mcu-eclipse.tar.bz2)
```shell
$ tar -xjf gnu-mcu-eclipse.tar.bz2 -C /opt/
```
将上述解压的编译工具链的路径添加到board/hifive1-rev-B/config.mk文件当中,例如:
```
export CROSS_COMPILE ?=/opt/gnu-mcu-eclipse/riscv-none-gcc/8.2.0-2.1-20190425-1021/bin/riscv-none-embed-
```
若已存在`export CROSS_COMPILE ?=xxxx` 应该将原有的语句注释,再写入上面的语句。
# 在gapuino board 上创建第一个应用
## 1.gapuino board 简介
| 硬件 | 描述 |
| -- | -- |
|芯片型号| gap8 |
|架构| RV32IMAC |
|主频| 200+MHz |
|片内SRAM| 512KB |
| 外设 | UART、SPI、I2C |
XiUOS板级当前支持使用UART。
## 2. 代码编写与编译说明
编辑环境:`VScode`
编译工具链:`riscv-none-embed-gcc`
使用`VScode`打开工程的方法有多种,本文介绍一种快捷键,在项目目录下将`code .`输入终端即可打开目标项目
修改`applications`文件夹下`main.c`
在输出函数中写入 Hello, world! \n 完成代码编辑。
编译步骤:
1.在VScode终端下执行以下命令,生成配置文件
```
make BOARD=gapuino menuconfig
```
2.在menuconfig界面配置需要关闭和开启的功能,按回车键进入下级菜单,按Y键选中需要开启的功能,按N键选中需要关闭的功能,配置结束后选择Exit保存并退出
![menuconfig](img/menuconfig.png)
3.继续执行以下命令,进行编译
```
make BOARD=gapuino
```
4.如果编译正确无误,build文件夹下会产生XiUOS_gapuino.elf、XiUOS_gapuino.bin文件。
>注:最后可以执行以下命令,清除配置文件和编译生成的文件
```
make BOARD=gapuino distclean
```
## 3. 烧写及执行
gapuino支持jtag,可以通过jtag进行烧录和调试。
调试烧写需要下载gap sdk和openocd,下载配置方法参见以下文档:
https://greenwaves-technologies.com/setting-up-sdk/
在SDK 和openocd安装完成以后,按照如下步骤进行调试:
1、进入sdk目录路径下
```
cd ~/gap_sdk
```
2、在当前终端输入
```
source sourceme.sh
```
出现如下图所示的界面,输入7选择单板名称;
![choose](./img/choose_board.png)
3、先按开发板的复位键,再在当前终端输入
```
gap8-openocd -f interface/ftdi/gapuino_ftdi.cfg -f target/gap8.tcl -f tcl/jtag_boot_entry.tcl
```
在当前终端连接openocd,连接如下图所示:
![openocd](./img/openocd.png)
4、打开一个新的终端,输入以下命令打开终端串口:
```
sudo apt install screen
screen /dev/ttyUSB0 115200
```
5、打开一个新的终端,进入编译生成的elf路径,输入例如:
```
riscv32-unknown-elf-gdb build/XiUOS_gapuino.elf -ex "target remote localhost:3333"
```
结果如下图所示:
![gdb](./img/gdb_load.png)
6、再输入load,最后输入continue命令即可在串口终端看到系统运行界面,如下图所示:
![terminal](./img/terminal.png)
-89
View File
@@ -1,89 +0,0 @@
README
======
gapuino is an evaluation board for GAP8, a 1+8-core DSP-like RISC-V
MCU. GAP8 features a RI5CY core called Fabric Controller(FC), and a
cluster of 8 RI5CY cores that runs at a bit slower speed. GAP8 is an
implementation of the opensource PULP platform, a Parallel-Ultra-Low-
Power design.
The port is currently very minimal, though additional support may be
added in the future to address more of the board peripherals.
Supported:
- USB UART (console port)
- uDMA on SOC domain
- FLL clock scaling
Not supported:
- SPI, I2C, I2S, CPI, LVDS, Hyper-bus on the uDMA subsystem
- the sensor board
- the 8-core cluster
- the Hardware convolution engine
See also:
gapuino board and the sensor board:
https://gwt-website-files.s3.amazonaws.com/gapuino_um.pdf
https://gwt-website-files.s3.amazonaws.com/gapuino_multisensor_um.pdf
GAP8 datasheet:
https://gwt-website-files.s3.amazonaws.com/gap8_datasheet.pdf
Contents
========
- Environment Setup
- Configurations
- Execute
Environment Setup
=================
First, setup the gap_sdk from GreenwavesTechnologies' github repo.
Follow the README to setup the toolchain and environment.
https://github.com/GreenWaves-Technologies/gap_sdk/
Configurations
==============
Each gapuino configuration is maintained in a sub-directory and can
be selected as follow:
tools/configure.sh gapuino:<subdir>
Where <subdir> is one of the following:
nsh
---
This is an NSH example that uses the UART connected to FT2232 as
the console. Default UART settings are 115200, 8N1.
Execute
=======
You may download the ELF to the board by `plpbridge` in gap_sdk.
Remember to first `cd` to the gap_sdk/ and `source sourceme.sh`, so
that you have the $GAP_SDK_HOME environment variable.
Use the following command to download and run the ELF through JTAG:
$GAP_SDK_HOME/install/workstation/bin/plpbridge \
--cable=ftdi@digilent --boot-mode=jtag --chip=gap \
--binary=nuttx \
load ioloop reqloop start wait
As for debugging, the following command download the ELF and opens
a gdbserver on port 1234:
$GAP_SDK_HOME/install/workstation/bin/plpbridge \
--cable=ftdi@digilent --boot-mode=jtag --chip=gap \
--binary=nuttx \
load ioloop gdb wait
And then launch the gdb on another terminal:
riscv32-unknown-elf-gdb nuttx
...
(gdb) target remote :1234
Remote debugging using :1234
IRQ_U_Vector_Base () at chip/startup_gap8.S:293
293 j reset_handler /* 32 */
(gdb)
And then enjoy yourself debugging with the CLI gdb :-)
+3 -13
View File
@@ -12,10 +12,10 @@
/**
* @file board.c
* @brief support hifive1-rev-B-board init configure and start-up
* @brief support gap8 init configure and start-up
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021-04-25
* @date 2021-09-02
*/
#include <board.h>
@@ -27,14 +27,10 @@ extern void entry(void);
extern int InitHwUart(void);
extern void irqinitialize(void);
extern void timer_initialize(void);
extern void up_serialinit(void);
extern void gapuino_sysinit(void);
extern unsigned int __bss_end__;
extern void test_dma_txstart(char c, uint32_t size);
extern void test_gap8_uartinit();
extern void gapuino_sysinit(void);
void GapuinoStart(uint32_t mhartid)
{
gapuino_sysinit();
@@ -42,8 +38,6 @@ void GapuinoStart(uint32_t mhartid)
}
void InitBoardHardware(void)
{
x_base newstat;
x_base oldstat;
irqinitialize();
InitBoardMemory(MEMORY_START_ADDRESS, MEMORY_END_ADDRESS);
@@ -51,10 +45,6 @@ void InitBoardHardware(void)
InitHwUart();
InstallConsole("uart0", "uart0_drv", "uart0_dev0");
// asm volatile("nop");
// asm volatile ("csrr %0, 0x300": "=r" (oldstat));
// newstat = oldstat | (0x8);
// asm volatile("csrw mstatus, %0" : /* no output */ : "r" (newstat));
KPrintf("console init completed.\n");
KPrintf("board initialization......\n");
+30 -47
View File
@@ -1,57 +1,40 @@
/****************************************************************************
* boards/risc-v/gap8/gapuino/include/board.h
*
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
* Author: hhuysqt <1020988872@qq.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file board.h
* @brief define gapuino-board init configure and start-up function
* @version 1.0
* @author AIIT XUOS Lab
* @date 2021-09-02
*/
/*************************************************
File name: board.h
Description: define gapuino-board init configure and start-up function
Others:
History:
1. Date: 2021-09-02
Author: AIIT XUOS Lab
Modification:
1. define gapuino-board InitBoardHardware
2. define gapuino-board data and bss struct
*************************************************/
#ifndef BOARD_H__
#define BOARD_H__
/****************************************************************************
* Included Files
****************************************************************************/
#include <xsconfig.h>
#include <stdint.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
#ifndef __ASSEMBLY__
#undef EXTERN
Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

+11 -48
View File
@@ -1,39 +1,14 @@
/****************************************************************************
* boards/risc-v/gap8/gapuino/scripts/ld.script
*
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
* Author: hhuysqt <1020988872@qq.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/* Not needed, but we need separate linker scripts anyway */
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
OUTPUT_ARCH( riscv )
SEARCH_DIR(.)
@@ -133,18 +108,6 @@ SECTIONS
.bss :
{
/* . = ALIGN(4);
_sbss = .;
__bss_start__ = .;
_fbss = .;
*(.bss)
*(.bss.*)
*(.sbss)
*(.sbss.*)
*(COMMON)
. = ALIGN(4);
__bss_end__ = .;
_ebss = .; */
__bss_start = ABSOLUTE(.);
_fbss = .;
@@ -13,14 +13,6 @@ menuconfig BSP_USING_SYSCLOCK
source "$BSP_DIR/third_party_driver/sys_clock/Kconfig"
endif
menuconfig BSP_USING_HWTIMER
bool "Using HWTIMER device"
default n
select RESOURCES_HWTIMER
if BSP_USING_HWTIMER
source "$BSP_DIR/third_party_driver/timer/Kconfig"
endif
menuconfig BSP_USING_UART
bool "Using UART device"
default y
@@ -1,8 +1,5 @@
SRC_FILES :=
ifeq ($(CONFIG_BSP_USING_DMA),y)
SRC_DIR += udma
endif
SRC_DIR := timer
ifeq ($(CONFIG_BSP_USING_GPIO),y)
SRC_DIR += gpio
@@ -16,10 +13,6 @@ ifeq ($(CONFIG_BSP_USING_SYSCLOCK),y)
SRC_DIR += sys_clock
endif
ifeq ($(CONFIG_BSP_USING_HWTIMER),y)
SRC_DIR += timer
endif
ifeq ($(CONFIG_BSP_USING_UART),y)
SRC_DIR += uart
endif
@@ -45,7 +45,7 @@
* https://greenwavesdev2.wpengine.com/sdk-manuals/
* @version 1.1
* @author AIIT XUOS Lab
* @date 2021-07-27
* @date 2021-09-02
*/
/****************************************************************************
@@ -34,6 +34,25 @@
*
****************************************************************************/
/**
* @file: gap8_fll.c
* @brief: support gap8 clk
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2021-09-02
*/
/*************************************************
File name: hardware_gpio.c
Description: support gap8 clk
Others:
History:
1. Date: 2021-09-02
Author: AIIT XUOS Lab
Modification:
*************************************************/
/****************************************************************************
* FC can run up to 250MHz@1.2V, and 150MHz@1.0V. While the default voltage
* of PMU is 1.2V, it's okay to boost up without considering PMU.
@@ -33,6 +33,25 @@
*
****************************************************************************/
/**
* @file: gapuino_sysinit.c
* @brief: support gap8 clk
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2021-09-02
*/
/*************************************************
File name: gapuino_sysinit.c
Description: support gap8 clk
Others:
History:
1. Date: 2021-09-02
Author: AIIT XUOS Lab
Modification:
*************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
@@ -34,6 +34,25 @@
*
****************************************************************************/
/**
* @file: hardware_hwtimer.c
* @brief: support gap8 tick interrupt
* @version: 1.0
* @author: AIIT XUOS Lab
* @date: 2021-09-02
*/
/*************************************************
File name: hardware_hwtimer.c
Description: support gap8 tick interrupt
Others:
History:
1. Date: 2021-09-02
Author: AIIT XUOS Lab
Modification:
add tick interrupt isr
*************************************************/
/****************************************************************************
* FC core has a 64-bit basic timer, able to split into 2 32-bit timers,
* with identicle memory map and 2 IRQ channels, for both FC core and
@@ -88,7 +107,7 @@ void gap8_timisr(int irq, void *arg)
****************************************************************************/
/****************************************************************************
* Name: up_timer_initialize
* Name: timer_initialize
*
* Description:
* Initialize the timer based on the frequency of source clock and ticks
@@ -15,7 +15,7 @@
* @brief support gap8-board uart function and register to bus framework
* @version 1.1
* @author AIIT XUOS Lab
* @date 2021-07-23
* @date 2021-09-02
*/
#include <xiuos.h>
@@ -55,7 +55,7 @@
* https://greenwavesdev2.wpengine.com/sdk-manuals/
* @version 1.1
* @author AIIT XUOS Lab
* @date 2021-07-27
* @date 2021-09-02
*/
/****************************************************************************