sync branch rt-smart. (#6641)
* Synchronize the code of the rt mart branch to the master branch.
* TTY device
* Add lwP code from rt-smart
* Add vnode in DFS, but DFS will be re-write for rt-smart
* There are three libcpu for rt-smart:
* arm/cortex-a, arm/aarch64
* riscv64
Co-authored-by: Rbb666 <zhangbingru@rt-thread.com>
Co-authored-by: zhkag <zhkag@foxmail.com>
3
.github/workflows/action.yml
vendored
@@ -38,7 +38,7 @@ jobs:
|
||||
- {RTT_BSP: "apm32/apm32f103xe-minibroard", RTT_TOOL_CHAIN: "sourcery-arm"}
|
||||
- {RTT_BSP: "apollo2", RTT_TOOL_CHAIN: "sourcery-arm"}
|
||||
- {RTT_BSP: "asm9260t", RTT_TOOL_CHAIN: "sourcery-arm"}
|
||||
- {RTT_BSP: "ft2004", RTT_TOOL_CHAIN: "sourcery-arm"}
|
||||
# - {RTT_BSP: "ft2004", RTT_TOOL_CHAIN: "sourcery-arm"}
|
||||
- {RTT_BSP: "at91/at91sam9g45", RTT_TOOL_CHAIN: "sourcery-arm"}
|
||||
- {RTT_BSP: "at91/at91sam9260", RTT_TOOL_CHAIN: "sourcery-arm"}
|
||||
- {RTT_BSP: "allwinner_tina", RTT_TOOL_CHAIN: "sourcery-arm"}
|
||||
@@ -108,7 +108,6 @@ jobs:
|
||||
- {RTT_BSP: "nrf5x/nrf52833", RTT_TOOL_CHAIN: "sourcery-arm"}
|
||||
- {RTT_BSP: "nrf5x/nrf52840", RTT_TOOL_CHAIN: "sourcery-arm"}
|
||||
- {RTT_BSP: "qemu-vexpress-a9", RTT_TOOL_CHAIN: "sourcery-arm"}
|
||||
- {RTT_BSP: "qemu-vexpress-gemini", RTT_TOOL_CHAIN: "sourcery-arm"}
|
||||
- {RTT_BSP: "sam7x", RTT_TOOL_CHAIN: "sourcery-arm"}
|
||||
- {RTT_BSP: "stm32/stm32f072-st-nucleo", RTT_TOOL_CHAIN: "sourcery-arm"}
|
||||
- {RTT_BSP: "stm32/stm32f091-st-nucleo", RTT_TOOL_CHAIN: "sourcery-arm"}
|
||||
|
||||
3
bsp/allwinner/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# allwinner-bsp
|
||||
|
||||
针对全志芯片的rt-smart bsp,包括D1/D1s(RISC-V64)
|
||||
11
bsp/allwinner/d1/.gitignore
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
__pycache__/
|
||||
*.bin
|
||||
*.elf
|
||||
*.map
|
||||
build/
|
||||
.sconsign.dblite
|
||||
cconfig.h
|
||||
.vscode/
|
||||
rtconfig.pyc
|
||||
*.old
|
||||
sdcard.bat
|
||||
47
bsp/allwinner/d1/Kconfig
Normal file
@@ -0,0 +1,47 @@
|
||||
mainmenu "RT-Thread Project Configuration"
|
||||
|
||||
config BSP_DIR
|
||||
string
|
||||
option env="BSP_ROOT"
|
||||
default "."
|
||||
|
||||
config RTT_DIR
|
||||
string
|
||||
option env="RTT_ROOT"
|
||||
default "../../.."
|
||||
|
||||
config PKGS_DIR
|
||||
string
|
||||
option env="PKGS_ROOT"
|
||||
default "packages"
|
||||
|
||||
source "$RTT_DIR/Kconfig"
|
||||
source "$PKGS_DIR/Kconfig"
|
||||
|
||||
config BOARD_allwinnerd1
|
||||
bool
|
||||
select ARCH_RISCV64
|
||||
select RT_USING_COMPONENTS_INIT
|
||||
select RT_USING_USER_MAIN
|
||||
select RT_USING_CACHE
|
||||
select ARCH_MM_MMU
|
||||
default y
|
||||
|
||||
config RT_USING_USERSPACE
|
||||
bool
|
||||
default y
|
||||
|
||||
config ENABLE_FPU
|
||||
bool "Enable FPU"
|
||||
default y
|
||||
|
||||
config RT_USING_USERSPACE_32BIT_LIMIT
|
||||
bool "Enable userspace 32bit limit"
|
||||
default n
|
||||
|
||||
config __STACKSIZE__
|
||||
int "stack size for interrupt"
|
||||
default 4096
|
||||
|
||||
source "../libraries/drivers/Kconfig"
|
||||
source "../libraries/Kconfig"
|
||||
84
bsp/allwinner/d1/README.md
Normal file
@@ -0,0 +1,84 @@
|
||||
# RT-Thread全志D1移植
|
||||
|
||||
全志 d1-allwinner-nezha 属于 riscv64 平台
|
||||
|
||||
## 编译环境搭建
|
||||
|
||||
- 拉取 RT-Thread Smart的代码仓库 `git clone https://gitee.com/guozhanxin/rtthread-smart.git`
|
||||
|
||||
### windows 环境
|
||||
|
||||
- 打开 RT-Thread ENV 工具
|
||||
|
||||
- 进入 tools 目录 `cd tools`
|
||||
|
||||
- 拉取 `riscv64`平台的编译工具 `python get_toolchain.py riscv64`
|
||||
|
||||
- 返回上级目录 `cd ..`
|
||||
|
||||
- 设置环境变量 `./smart-env.bat`
|
||||
|
||||
### ubuntu 环境
|
||||
|
||||
- 打开 ubuntu shell 终端
|
||||
|
||||
- 进入 tools 目录 `cd tools`
|
||||
|
||||
- 拉取 `riscv64`平台的编译工具 `python get_toolchain.py riscv64`
|
||||
|
||||
- 返回上级目录 `cd ..`
|
||||
|
||||
- 设置环境变量 `source smart-env.sh riscv64`
|
||||
|
||||
### 编译环境验证
|
||||
|
||||
- 输入:`riscv64-unknown-linux-musl-gcc -v`
|
||||
|
||||
## 开发与编译
|
||||
|
||||
- windows 下使用RT-Thread ENV 工具, `menuconfig` 配置工程,`scons` 编译工程
|
||||
|
||||
- ubuntu 下 使用shell 终端: `scons --menuconfig` 配置工程, `scons` 编译工程
|
||||
|
||||
|
||||
## 下载验证
|
||||
|
||||
- 编译完后,通过:mkimage 生成 img 镜像文件,这个img 镜像文件可以使用 U-boot 引导启动
|
||||
|
||||
- 启动方式一般有:SD卡启动、NandFlash启动、网络引导启动
|
||||
|
||||
- windows 下使用全志的:`AllwinnertechPhoeniSuitRelease20201225`
|
||||
|
||||
- 可以使用 xfel 工具进行烧写NandFlash
|
||||
|
||||
## 运行效果
|
||||
|
||||
```c
|
||||
## Booting kernel from Legacy Image at 45000000 ...
|
||||
Image Name:
|
||||
Image Type: RISC-V Linux Kernel Image (uncompressed)
|
||||
Data Size: 249576 Bytes = 243.7 KiB
|
||||
Load Address: 45000000
|
||||
Entry Point: 45000000
|
||||
Verifying Checksum ... OK
|
||||
[01.861]
|
||||
Starting kernel ...
|
||||
heap: [0x45077bb0 - 0x48277bb0]
|
||||
\ | /
|
||||
- RT - Thread Smart Operating System
|
||||
/ | \ 5.0.0 build Jun 18 2022
|
||||
2006 - 2020 Copyright by rt-thread team
|
||||
file system initialization done!
|
||||
Hello RISC-V
|
||||
msh />
|
||||
|
||||
```
|
||||
|
||||
## 参考文档
|
||||
|
||||
- [https://club.rt-thread.org/ask/article/389ac36250b57737.html](https://club.rt-thread.org/ask/article/389ac36250b57737.html)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# for module compiling
|
||||
import os
|
||||
Import('RTT_ROOT')
|
||||
from building import *
|
||||
|
||||
cwd = str(Dir('#'))
|
||||
cwd = GetCurrentDir()
|
||||
objs = []
|
||||
list = os.listdir(cwd)
|
||||
|
||||
63
bsp/allwinner/d1/SConstruct
Normal file
@@ -0,0 +1,63 @@
|
||||
import os
|
||||
import sys
|
||||
import rtconfig
|
||||
|
||||
from rtconfig import RTT_ROOT
|
||||
import sys
|
||||
|
||||
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
|
||||
from building import *
|
||||
|
||||
TARGET = 'rtthread.' + rtconfig.TARGET_EXT
|
||||
|
||||
DefaultEnvironment(tools=[])
|
||||
env = Environment(tools = ['mingw'],
|
||||
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
|
||||
CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
|
||||
CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS,
|
||||
AR = rtconfig.AR, ARFLAGS = '-rc',
|
||||
LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
|
||||
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
|
||||
env['ASCOM'] = env['ASPPCOM']
|
||||
|
||||
Export('RTT_ROOT')
|
||||
Export('rtconfig')
|
||||
|
||||
rtconfig.CPU='c906'
|
||||
rtconfig.VENDOR="t-head"
|
||||
rtconfig.ARCH='risc-v'
|
||||
|
||||
SDK_ROOT = os.path.abspath('./')
|
||||
|
||||
if os.path.exists(SDK_ROOT + '/libraries'):
|
||||
libraries_path_prefix = SDK_ROOT + '/libraries'
|
||||
else:
|
||||
libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries'
|
||||
|
||||
SDK_LIB = libraries_path_prefix
|
||||
Export('SDK_LIB')
|
||||
|
||||
# prepare building environment
|
||||
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu = False)
|
||||
|
||||
d1_library = 'sunxi-hal'
|
||||
rtconfig.BSP_LIBRARY_TYPE = d1_library
|
||||
|
||||
# include libraries
|
||||
objs.extend(SConscript(os.path.join(libraries_path_prefix, d1_library, 'SConscript')))
|
||||
|
||||
# include drivers
|
||||
objs.extend(SConscript(os.path.join(libraries_path_prefix, 'drivers', 'SConscript')))
|
||||
|
||||
# include libos
|
||||
objs.extend(SConscript(os.path.join(libraries_path_prefix, 'libos', 'SConscript')))
|
||||
|
||||
stack_size = 4096
|
||||
|
||||
stack_lds = open('link_stacksize.lds', 'w')
|
||||
if GetDepend('__STACKSIZE__'): stack_size = GetDepend('__STACKSIZE__')
|
||||
stack_lds.write('__STACKSIZE__ = %d;' % stack_size)
|
||||
stack_lds.close()
|
||||
|
||||
# make a building
|
||||
DoBuilding(TARGET, objs)
|
||||
9
bsp/allwinner/d1/applications/SConscript
Normal file
@@ -0,0 +1,9 @@
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
src = Glob('*.c') + Glob('*.cpp')
|
||||
CPPPATH = [cwd]
|
||||
|
||||
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
||||
@@ -5,16 +5,16 @@
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2013-03-30 Bernard the first verion
|
||||
*/
|
||||
|
||||
#ifndef __UART_H__
|
||||
#define __UART_H__
|
||||
|
||||
#include <board.h>
|
||||
|
||||
int rt_hw_uart_init(void);
|
||||
|
||||
#endif
|
||||
#include <rtthread.h>
|
||||
#include <rthw.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printf("Hello RISC-V\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
21
bsp/allwinner/d1/applications/mnt.c
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <rtthread.h>
|
||||
|
||||
#ifdef RT_USING_DFS
|
||||
#include <dfs_fs.h>
|
||||
#include <dfs_romfs.h>
|
||||
|
||||
int mnt_init(void)
|
||||
{
|
||||
|
||||
rt_thread_mdelay(200);
|
||||
|
||||
if (dfs_mount("boot", "/", "elm", 0, 0) != 0)
|
||||
{
|
||||
rt_kprintf("Dir /boot mount failed!\n");
|
||||
}
|
||||
|
||||
rt_kprintf("file system initialization done!\n");
|
||||
return 0;
|
||||
}
|
||||
INIT_ENV_EXPORT(mnt_init);
|
||||
#endif
|
||||
13
bsp/allwinner/d1/applications/romfs.c
Normal file
@@ -0,0 +1,13 @@
|
||||
#include <dfs_romfs.h>
|
||||
|
||||
static const struct romfs_dirent _romfs_root[] = {
|
||||
{ROMFS_DIRENT_DIR, "etc", RT_NULL, 0},
|
||||
{ROMFS_DIRENT_DIR, "mnt", RT_NULL, 0},
|
||||
{ROMFS_DIRENT_DIR, "boot", RT_NULL, 0},
|
||||
{ROMFS_DIRENT_DIR, "boot-resource", RT_NULL, 0},
|
||||
{ROMFS_DIRENT_DIR, "bin", RT_NULL, 0}
|
||||
};
|
||||
|
||||
const struct romfs_dirent romfs_root = {
|
||||
ROMFS_DIRENT_DIR, "/", (rt_uint8_t *)_romfs_root, sizeof(_romfs_root) / sizeof(_romfs_root[0])};
|
||||
|
||||
0
bsp/allwinner/d1/board/Kconfig
Normal file
19
bsp/allwinner/d1/board/SConscript
Normal file
@@ -0,0 +1,19 @@
|
||||
# RT-Thread building script for component
|
||||
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
src = Glob('*.c')
|
||||
CPPPATH = [cwd]
|
||||
|
||||
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH)
|
||||
|
||||
objs = [group]
|
||||
|
||||
list = os.listdir(cwd)
|
||||
|
||||
for item in list:
|
||||
if os.path.isfile(os.path.join(cwd, item, 'SConscript')):
|
||||
objs = objs + SConscript(os.path.join(item, 'SConscript'))
|
||||
|
||||
Return('objs')
|
||||
127
bsp/allwinner/d1/board/board.c
Normal file
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-01-30 lizhirui first version
|
||||
*/
|
||||
|
||||
#include <rthw.h>
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
|
||||
#include "board.h"
|
||||
#include "tick.h"
|
||||
|
||||
#include "drv_uart.h"
|
||||
#include "encoding.h"
|
||||
#include "stack.h"
|
||||
#include "sbi.h"
|
||||
#include "riscv.h"
|
||||
#include "stack.h"
|
||||
|
||||
#include "hal_gpio.h"
|
||||
#include "hal_clk.h"
|
||||
#include "hal_uart.h"
|
||||
#include "hal_dma.h"
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#include "riscv_mmu.h"
|
||||
#include "mmu.h"
|
||||
#include "page.h"
|
||||
#include "lwp_arch.h"
|
||||
|
||||
//这个结构体描述了buddy system的页分配范围
|
||||
rt_region_t init_page_region =
|
||||
{
|
||||
(rt_size_t)RT_HW_PAGE_START,
|
||||
(rt_size_t)RT_HW_PAGE_END
|
||||
};
|
||||
|
||||
//内核页表
|
||||
volatile rt_size_t MMUTable[__SIZE(VPN2_BIT)] __attribute__((aligned(4 * 1024)));
|
||||
rt_mmu_info mmu_info;
|
||||
|
||||
#endif
|
||||
|
||||
//初始化BSS节区
|
||||
void init_bss(void)
|
||||
{
|
||||
unsigned int *dst;
|
||||
|
||||
dst = &__bss_start;
|
||||
while (dst < &__bss_end)
|
||||
{
|
||||
*dst++ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void __rt_assert_handler(const char *ex_string, const char *func, rt_size_t line)
|
||||
{
|
||||
rt_kprintf("(%s) assertion failed at function:%s, line number:%d \n", ex_string, func, line);
|
||||
asm volatile("ebreak":::"memory");
|
||||
}
|
||||
|
||||
//BSP的C入口
|
||||
void primary_cpu_entry(void)
|
||||
{
|
||||
extern void entry(void);
|
||||
|
||||
//初始化BSS
|
||||
init_bss();
|
||||
//关中断
|
||||
rt_hw_interrupt_disable();
|
||||
rt_assert_set_hook(__rt_assert_handler);
|
||||
//启动RT-Thread Smart内核
|
||||
entry();
|
||||
}
|
||||
|
||||
|
||||
//这个初始化程序由内核主动调用,此时调度器还未启动,因此在此不能使用依赖线程上下文的函数
|
||||
void rt_hw_board_init(void)
|
||||
{
|
||||
#ifdef RT_USING_USERSPACE
|
||||
rt_page_init(init_page_region);
|
||||
rt_hw_mmu_map_init(&mmu_info,(void *)USER_VADDR_START, USER_VADDR_TOP - USER_VADDR_START, (rt_size_t *)MMUTable, 0);
|
||||
rt_hw_mmu_kernel_map_init(&mmu_info, 0x00000000UL, USER_VADDR_START - 1);
|
||||
//将低1GB MMIO区域设置为无Cache与Strong Order访存模式
|
||||
MMUTable[0] &= ~PTE_CACHE;
|
||||
MMUTable[0] &= ~PTE_SHARE;
|
||||
MMUTable[0] |= PTE_SO;
|
||||
rt_hw_mmu_switch((void *)MMUTable);
|
||||
#endif
|
||||
/* initalize interrupt */
|
||||
rt_hw_interrupt_init();
|
||||
#ifdef RT_USING_HEAP
|
||||
rt_kprintf("heap: [0x%08x - 0x%08x]\n", (rt_ubase_t) RT_HW_HEAP_BEGIN, (rt_ubase_t) RT_HW_HEAP_END);
|
||||
/* initialize memory system */
|
||||
rt_system_heap_init(RT_HW_HEAP_BEGIN, RT_HW_HEAP_END);
|
||||
#endif
|
||||
/* init hal hardware */
|
||||
hal_clock_init();
|
||||
hal_gpio_init();
|
||||
hal_uart_init(0);
|
||||
hal_dma_init();
|
||||
|
||||
/* init rtthread hardware */
|
||||
rt_hw_uart_init();
|
||||
rt_hw_tick_init();
|
||||
|
||||
#ifdef RT_USING_CONSOLE
|
||||
/* set console device */
|
||||
rt_console_set_device("uart");
|
||||
#endif /* RT_USING_CONSOLE */
|
||||
|
||||
#ifdef RT_USING_COMPONENTS_INIT
|
||||
rt_components_board_init();
|
||||
#endif
|
||||
}
|
||||
|
||||
void rt_hw_cpu_reset(void)
|
||||
{
|
||||
sbi_shutdown();
|
||||
while(1);
|
||||
}
|
||||
MSH_CMD_EXPORT_ALIAS(rt_hw_cpu_reset, reboot, reset machine);
|
||||
27
bsp/allwinner/d1/board/board.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-01-30 lizhirui first version
|
||||
*/
|
||||
|
||||
#ifndef BOARD_H__
|
||||
#define BOARD_H__
|
||||
|
||||
#include <rtconfig.h>
|
||||
|
||||
extern unsigned int __bss_start;
|
||||
extern unsigned int __bss_end;
|
||||
|
||||
#define RT_HW_HEAP_BEGIN ((void *)&__bss_end)
|
||||
#define RT_HW_HEAP_END ((void *)(((rt_size_t)RT_HW_HEAP_BEGIN) + 50 * 1024 * 1024))
|
||||
#define RT_HW_PAGE_START RT_HW_HEAP_END
|
||||
#define RT_HW_PAGE_END ((void *)(((rt_size_t)RT_HW_PAGE_START) + 50 * 1024 * 1024))
|
||||
|
||||
void rt_hw_board_init(void);
|
||||
void rt_init_user_mem(struct rt_thread *thread, const char *name, unsigned long *entry);
|
||||
|
||||
#endif
|
||||
2
bsp/allwinner/d1/generateimg.sh
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
mkimage -A riscv -O linux -T kernel -C none -a 0x45000000 -e 0x45000000 -d rtthread.bin rtthread.img
|
||||
195
bsp/allwinner/d1/link.lds
Normal file
@@ -0,0 +1,195 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2020, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2020/12/12 bernard The first version
|
||||
*/
|
||||
|
||||
INCLUDE "link_stacksize.lds"
|
||||
|
||||
OUTPUT_ARCH( "riscv" )
|
||||
|
||||
/*
|
||||
* Memory layout:
|
||||
* 0x10200000 - 0x10201000: Bootloader
|
||||
* 0x10201000 - 0x10A00000: Kernel
|
||||
* 0x10A00000 - 0x11200000: Heap
|
||||
*/
|
||||
|
||||
MEMORY
|
||||
{
|
||||
SRAM : ORIGIN = 0x45000000, LENGTH = 0x7FF000
|
||||
}
|
||||
|
||||
ENTRY(_start)
|
||||
SECTIONS
|
||||
{
|
||||
. = 0x45000000 ;
|
||||
|
||||
/* __STACKSIZE__ = 4096; */
|
||||
|
||||
.start :
|
||||
{
|
||||
*(.start);
|
||||
} > SRAM
|
||||
|
||||
. = ALIGN(8);
|
||||
|
||||
.text :
|
||||
{
|
||||
*(.text) /* remaining code */
|
||||
*(.text.*) /* remaining code */
|
||||
*(.rodata) /* read-only data (constants) */
|
||||
*(.rodata*)
|
||||
*(.glue_7)
|
||||
*(.glue_7t)
|
||||
*(.gnu.linkonce.t*)
|
||||
|
||||
/* section information for finsh shell */
|
||||
. = ALIGN(8);
|
||||
__fsymtab_start = .;
|
||||
KEEP(*(FSymTab))
|
||||
__fsymtab_end = .;
|
||||
. = ALIGN(8);
|
||||
__vsymtab_start = .;
|
||||
KEEP(*(VSymTab))
|
||||
__vsymtab_end = .;
|
||||
. = ALIGN(8);
|
||||
|
||||
/* section information for initial. */
|
||||
. = ALIGN(8);
|
||||
__rt_init_start = .;
|
||||
KEEP(*(SORT(.rti_fn*)))
|
||||
__rt_init_end = .;
|
||||
. = ALIGN(8);
|
||||
|
||||
__rt_utest_tc_tab_start = .;
|
||||
KEEP(*(UtestTcTab))
|
||||
__rt_utest_tc_tab_end = .;
|
||||
|
||||
. = ALIGN(8);
|
||||
_etext = .;
|
||||
} > SRAM
|
||||
|
||||
.eh_frame_hdr :
|
||||
{
|
||||
*(.eh_frame_hdr)
|
||||
*(.eh_frame_entry)
|
||||
} > SRAM
|
||||
.eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } > SRAM
|
||||
|
||||
. = ALIGN(8);
|
||||
|
||||
.data :
|
||||
{
|
||||
*(.data)
|
||||
*(.data.*)
|
||||
|
||||
*(.data1)
|
||||
*(.data1.*)
|
||||
|
||||
. = ALIGN(8);
|
||||
PROVIDE( __global_pointer$ = . + 0x800 );
|
||||
|
||||
*(.sdata)
|
||||
*(.sdata.*)
|
||||
} > SRAM
|
||||
|
||||
. = ALIGN(8);
|
||||
.ctors :
|
||||
{
|
||||
PROVIDE(__ctors_start__ = .);
|
||||
KEEP(*(SORT(.init_array.*)))
|
||||
KEEP(*(.init_array))
|
||||
PROVIDE(__ctors_end__ = .);
|
||||
} > SRAM
|
||||
|
||||
.dtors :
|
||||
{
|
||||
PROVIDE(__dtors_start__ = .);
|
||||
KEEP(*(SORT(.fini_array.*)))
|
||||
KEEP(*(.fini_array))
|
||||
PROVIDE(__dtors_end__ = .);
|
||||
} > SRAM
|
||||
|
||||
/* stack for dual core */
|
||||
.stack :
|
||||
{
|
||||
. = ALIGN(64);
|
||||
__stack_start__ = .;
|
||||
|
||||
. += __STACKSIZE__;
|
||||
__stack_cpu0 = .;
|
||||
|
||||
. += __STACKSIZE__;
|
||||
__stack_cpu1 = .;
|
||||
} > SRAM
|
||||
|
||||
. = ALIGN(8);
|
||||
|
||||
.osdebug :
|
||||
{
|
||||
_osdebug_start = .;
|
||||
. += 87K;
|
||||
_osdebug_end = .;
|
||||
} > SRAM
|
||||
|
||||
. = ALIGN(8);
|
||||
|
||||
.sbss :
|
||||
{
|
||||
__bss_start = .;
|
||||
*(.sbss)
|
||||
*(.sbss.*)
|
||||
*(.dynsbss)
|
||||
*(.scommon)
|
||||
} > SRAM
|
||||
|
||||
.bss :
|
||||
{
|
||||
*(.bss)
|
||||
*(.bss.*)
|
||||
*(.dynbss)
|
||||
*(COMMON)
|
||||
__bss_end = .;
|
||||
} > SRAM
|
||||
|
||||
_end = .;
|
||||
|
||||
/* Stabs debugging sections. */
|
||||
.stab 0 : { *(.stab) }
|
||||
.stabstr 0 : { *(.stabstr) }
|
||||
.stab.excl 0 : { *(.stab.excl) }
|
||||
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||
.stab.index 0 : { *(.stab.index) }
|
||||
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||
.comment 0 : { *(.comment) }
|
||||
/* DWARF debug sections.
|
||||
* Symbols in the DWARF debugging sections are relative to the beginning
|
||||
* of the section so we begin them at 0. */
|
||||
/* DWARF 1 */
|
||||
.debug 0 : { *(.debug) }
|
||||
.line 0 : { *(.line) }
|
||||
/* GNU DWARF 1 extensions */
|
||||
.debug_srcinfo 0 : { *(.debug_srcinfo) }
|
||||
.debug_sfnames 0 : { *(.debug_sfnames) }
|
||||
/* DWARF 1.1 and DWARF 2 */
|
||||
.debug_aranges 0 : { *(.debug_aranges) }
|
||||
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||
/* DWARF 2 */
|
||||
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
|
||||
.debug_abbrev 0 : { *(.debug_abbrev) }
|
||||
.debug_line 0 : { *(.debug_line) }
|
||||
.debug_frame 0 : { *(.debug_frame) }
|
||||
.debug_str 0 : { *(.debug_str) }
|
||||
.debug_loc 0 : { *(.debug_loc) }
|
||||
.debug_macinfo 0 : { *(.debug_macinfo) }
|
||||
/* SGI/MIPS DWARF 2 extensions */
|
||||
.debug_weaknames 0 : { *(.debug_weaknames) }
|
||||
.debug_funcnames 0 : { *(.debug_funcnames) }
|
||||
.debug_typenames 0 : { *(.debug_typenames) }
|
||||
.debug_varnames 0 : { *(.debug_varnames) }
|
||||
}
|
||||
1
bsp/allwinner/d1/link_stacksize.lds
Normal file
@@ -0,0 +1 @@
|
||||
__STACKSIZE__ = 16384;
|
||||
351
bsp/allwinner/d1/rtconfig.h
Normal file
@@ -0,0 +1,351 @@
|
||||
#ifndef RT_CONFIG_H__
|
||||
#define RT_CONFIG_H__
|
||||
|
||||
/* Automatically generated file; DO NOT EDIT. */
|
||||
/* RT-Thread Project Configuration */
|
||||
|
||||
/* RT-Thread Kernel */
|
||||
|
||||
#define RT_NAME_MAX 20
|
||||
#define RT_USING_SMART
|
||||
#define RT_ALIGN_SIZE 8
|
||||
#define RT_THREAD_PRIORITY_256
|
||||
#define RT_THREAD_PRIORITY_MAX 256
|
||||
#define RT_TICK_PER_SECOND 100
|
||||
#define RT_USING_HOOK
|
||||
#define RT_USING_IDLE_HOOK
|
||||
#define RT_IDLE_HOOK_LIST_SIZE 4
|
||||
#define IDLE_THREAD_STACK_SIZE 16384
|
||||
#define RT_USING_TIMER_SOFT
|
||||
#define RT_TIMER_THREAD_PRIO 4
|
||||
#define RT_TIMER_THREAD_STACK_SIZE 16384
|
||||
#define RT_DEBUG
|
||||
|
||||
/* Inter-Thread communication */
|
||||
|
||||
#define RT_USING_SEMAPHORE
|
||||
#define RT_USING_MUTEX
|
||||
#define RT_USING_EVENT
|
||||
#define RT_USING_MAILBOX
|
||||
#define RT_USING_MESSAGEQUEUE
|
||||
|
||||
/* Memory Management */
|
||||
|
||||
#define RT_USING_MEMPOOL
|
||||
#define RT_USING_SMALL_MEM
|
||||
#define RT_USING_MEMTRACE
|
||||
#define RT_USING_HEAP
|
||||
|
||||
/* Kernel Device Object */
|
||||
|
||||
#define RT_USING_DEVICE
|
||||
#define RT_USING_CONSOLE
|
||||
#define RT_CONSOLEBUF_SIZE 256
|
||||
#define RT_CONSOLE_DEVICE_NAME "uart"
|
||||
#define RT_VER_NUM 0x50000
|
||||
#define ARCH_CPU_64BIT
|
||||
#define RT_USING_CACHE
|
||||
#define ARCH_MM_MMU
|
||||
#define RT_USING_USERSPACE
|
||||
#define KERNEL_VADDR_START 0x150000000
|
||||
#define PV_OFFSET 0x0
|
||||
#define ARCH_RISCV
|
||||
#define ARCH_RISCV64
|
||||
|
||||
/* RT-Thread Components */
|
||||
|
||||
#define RT_USING_COMPONENTS_INIT
|
||||
#define RT_USING_USER_MAIN
|
||||
#define RT_MAIN_THREAD_STACK_SIZE 16384
|
||||
#define RT_MAIN_THREAD_PRIORITY 10
|
||||
|
||||
/* C++ features */
|
||||
|
||||
|
||||
/* Command shell */
|
||||
|
||||
#define RT_USING_FINSH
|
||||
#define RT_USING_MSH
|
||||
#define FINSH_USING_MSH
|
||||
#define FINSH_THREAD_NAME "tshell"
|
||||
#define FINSH_USING_HISTORY
|
||||
#define FINSH_HISTORY_LINES 5
|
||||
#define FINSH_USING_SYMTAB
|
||||
#define FINSH_USING_DESCRIPTION
|
||||
#define FINSH_THREAD_PRIORITY 20
|
||||
#define FINSH_THREAD_STACK_SIZE 8192
|
||||
#define FINSH_CMD_SIZE 80
|
||||
#define FINSH_ARG_MAX 10
|
||||
|
||||
/* Device virtual file system */
|
||||
|
||||
#define RT_USING_DFS
|
||||
#define DFS_USING_WORKDIR
|
||||
#define DFS_FILESYSTEMS_MAX 8
|
||||
#define DFS_FILESYSTEM_TYPES_MAX 4
|
||||
#define DFS_FD_MAX 32
|
||||
#define RT_USING_DFS_ELMFAT
|
||||
|
||||
/* elm-chan's FatFs, Generic FAT Filesystem Module */
|
||||
|
||||
#define RT_DFS_ELM_CODE_PAGE 437
|
||||
#define RT_DFS_ELM_WORD_ACCESS
|
||||
#define RT_DFS_ELM_USE_LFN_3
|
||||
#define RT_DFS_ELM_USE_LFN 3
|
||||
#define RT_DFS_ELM_MAX_LFN 255
|
||||
#define RT_DFS_ELM_DRIVES 8
|
||||
#define RT_DFS_ELM_MAX_SECTOR_SIZE 512
|
||||
#define RT_DFS_ELM_REENTRANT
|
||||
#define RT_USING_DFS_DEVFS
|
||||
#define RT_USING_DFS_ROMFS
|
||||
|
||||
/* Device Drivers */
|
||||
|
||||
#define RT_USING_DEVICE_IPC
|
||||
#define RT_UNAMED_PIPE_NUMBER 64
|
||||
#define RT_PIPE_BUFSZ 512
|
||||
#define RT_USING_SYSTEM_WORKQUEUE
|
||||
#define RT_SYSTEM_WORKQUEUE_STACKSIZE 8192
|
||||
#define RT_SYSTEM_WORKQUEUE_PRIORITY 23
|
||||
#define RT_USING_SERIAL
|
||||
#define RT_SERIAL_USING_DMA
|
||||
#define RT_SERIAL_RB_BUFSZ 64
|
||||
#define RT_USING_TTY
|
||||
#define RT_USING_HWTIMER
|
||||
#define RT_USING_I2C
|
||||
#define RT_USING_I2C_BITOPS
|
||||
#define RT_USING_PIN
|
||||
#define RT_USING_NULL
|
||||
#define RT_USING_ZERO
|
||||
#define RT_USING_RANDOM
|
||||
#define RT_USING_PWM
|
||||
#define RT_USING_RTC
|
||||
#define RT_USING_WDT
|
||||
#define RT_USING_TOUCH
|
||||
|
||||
/* Using USB */
|
||||
|
||||
|
||||
/* POSIX layer and C standard library */
|
||||
|
||||
#define RT_USING_LIBC
|
||||
#define RT_USING_MUSL
|
||||
#define RT_USING_POSIX
|
||||
#define RT_USING_POSIX_CLOCKTIME
|
||||
|
||||
/* Network */
|
||||
|
||||
/* Socket abstraction layer */
|
||||
|
||||
#define RT_USING_SAL
|
||||
|
||||
/* protocol stack implement */
|
||||
|
||||
#define SAL_USING_LWIP
|
||||
#define SAL_USING_POSIX
|
||||
|
||||
/* Network interface device */
|
||||
|
||||
#define RT_USING_NETDEV
|
||||
#define NETDEV_USING_IFCONFIG
|
||||
#define NETDEV_USING_PING
|
||||
#define NETDEV_USING_NETSTAT
|
||||
#define NETDEV_USING_AUTO_DEFAULT
|
||||
#define NETDEV_IPV4 1
|
||||
#define NETDEV_IPV6 0
|
||||
|
||||
/* light weight TCP/IP stack */
|
||||
|
||||
#define RT_USING_LWIP
|
||||
#define RT_USING_LWIP212
|
||||
#define RT_LWIP_MEM_ALIGNMENT 4
|
||||
#define RT_LWIP_IGMP
|
||||
#define RT_LWIP_ICMP
|
||||
#define RT_LWIP_DNS
|
||||
#define RT_LWIP_DHCP
|
||||
#define IP_SOF_BROADCAST 1
|
||||
#define IP_SOF_BROADCAST_RECV 1
|
||||
|
||||
/* Static IPv4 Address */
|
||||
|
||||
#define RT_LWIP_IPADDR "192.168.1.30"
|
||||
#define RT_LWIP_GWADDR "192.168.1.1"
|
||||
#define RT_LWIP_MSKADDR "255.255.255.0"
|
||||
#define RT_LWIP_UDP
|
||||
#define RT_LWIP_TCP
|
||||
#define RT_LWIP_RAW
|
||||
#define RT_MEMP_NUM_NETCONN 8
|
||||
#define RT_MEMP_NUM_TCPIP_MSG_API 16
|
||||
#define RT_MEMP_NUM_TCPIP_MSG_INPKT 16
|
||||
#define RT_LWIP_PBUF_NUM 16
|
||||
#define RT_LWIP_PBUF_STRUCT_NUM 16
|
||||
#define RT_LWIP_NETBUF_NUM 16
|
||||
#define RT_LWIP_RAW_PCB_NUM 4
|
||||
#define RT_LWIP_UDP_PCB_NUM 4
|
||||
#define RT_UDP_RECVMBOX_SIZE 16
|
||||
#define RT_RECV_BUFSIZE_DEFAULT 64
|
||||
#define RT_LWIP_TCP_PCB_NUM 4
|
||||
#define RT_LWIP_TCP_SEG_NUM 40
|
||||
#define RT_LWIP_TCP_SND_BUF 8196
|
||||
#define RT_LWIP_TCP_WND 8196
|
||||
#define RT_TCP_RECVMBOX_SIZE 16
|
||||
#define RT_LWIP_TCPTHREAD_PRIORITY 10
|
||||
#define RT_LWIP_TCPTHREAD_MBOX_SIZE 8
|
||||
#define RT_LWIP_TCPTHREAD_STACKSIZE 8192
|
||||
#define RT_LWIP_ETHTHREAD_PRIORITY 12
|
||||
#define RT_LWIP_ETHTHREAD_STACKSIZE 8192
|
||||
#define RT_LWIP_ETHTHREAD_MBOX_SIZE 8
|
||||
#define RT_LWIP_REASSEMBLY_FRAG
|
||||
#define LWIP_NETIF_STATUS_CALLBACK 1
|
||||
#define LWIP_NETIF_LINK_CALLBACK 1
|
||||
#define SO_REUSE 1
|
||||
#define LWIP_SO_RCVTIMEO 1
|
||||
#define LWIP_SO_SNDTIMEO 1
|
||||
#define LWIP_SO_RCVBUF 1
|
||||
#define LWIP_SO_LINGER 0
|
||||
#define LWIP_NETIF_LOOPBACK 0
|
||||
#define RT_LWIP_USING_PING
|
||||
|
||||
/* AT commands */
|
||||
|
||||
|
||||
/* VBUS(Virtual Software BUS) */
|
||||
|
||||
|
||||
/* Utilities */
|
||||
|
||||
#define RT_USING_LWP
|
||||
#define RT_LWP_MAX_NR 30
|
||||
#define LWP_TASK_STACK_SIZE 16384
|
||||
#define RT_CH_MSG_MAX_NR 1024
|
||||
#define LWP_CONSOLE_INPUT_BUFFER_SIZE 1024
|
||||
#define LWP_TID_MAX_NR 64
|
||||
#define RT_LWP_SHM_MAX_NR 64
|
||||
|
||||
/* RT-Thread online packages */
|
||||
|
||||
/* IoT - internet of things */
|
||||
|
||||
|
||||
/* Wi-Fi */
|
||||
|
||||
/* Marvell WiFi */
|
||||
|
||||
|
||||
/* Wiced WiFi */
|
||||
|
||||
|
||||
/* IoT Cloud */
|
||||
|
||||
|
||||
/* security packages */
|
||||
|
||||
|
||||
/* language packages */
|
||||
|
||||
/* JSON: JavaScript Object Notation, a lightweight data-interchange format */
|
||||
|
||||
|
||||
/* XML: Extensible Markup Language */
|
||||
|
||||
|
||||
/* multimedia packages */
|
||||
|
||||
/* LVGL: powerful and easy-to-use embedded GUI library */
|
||||
|
||||
|
||||
/* u8g2: a monochrome graphic library */
|
||||
|
||||
|
||||
/* PainterEngine: A cross-platform graphics application framework written in C language */
|
||||
|
||||
|
||||
/* tools packages */
|
||||
|
||||
|
||||
/* system packages */
|
||||
|
||||
/* enhanced kernel services */
|
||||
|
||||
|
||||
/* acceleration: Assembly language or algorithmic acceleration packages */
|
||||
|
||||
|
||||
/* CMSIS: ARM Cortex-M Microcontroller Software Interface Standard */
|
||||
|
||||
|
||||
/* Micrium: Micrium software products porting for RT-Thread */
|
||||
|
||||
|
||||
/* peripheral libraries and drivers */
|
||||
|
||||
|
||||
/* Kendryte SDK */
|
||||
|
||||
|
||||
/* AI packages */
|
||||
|
||||
|
||||
/* miscellaneous packages */
|
||||
|
||||
/* project laboratory */
|
||||
|
||||
/* samples: kernel and components samples */
|
||||
|
||||
|
||||
/* entertainment: terminal games and other interesting software packages */
|
||||
|
||||
|
||||
/* Arduino libraries */
|
||||
|
||||
|
||||
/* Sensor libraries */
|
||||
|
||||
|
||||
/* Display libraries */
|
||||
|
||||
|
||||
/* Timing libraries */
|
||||
|
||||
|
||||
/* Project libraries */
|
||||
|
||||
#define BOARD_allwinnerd1
|
||||
#define ENABLE_FPU
|
||||
#define __STACKSIZE__ 16384
|
||||
|
||||
/* General Drivers Configuration */
|
||||
|
||||
/* General Purpose UARTs */
|
||||
|
||||
#define BSP_USING_WDT
|
||||
#define BSP_USING_RTC
|
||||
#define RT_USING_SUNXI_HAL
|
||||
|
||||
/* UART Devices */
|
||||
|
||||
#define DRIVERS_UART
|
||||
|
||||
/* CCMU Devices */
|
||||
|
||||
#define DRIVERS_CCMU
|
||||
#define DRIVERS_SUNXI_CLK
|
||||
|
||||
/* DMA Devices */
|
||||
|
||||
#define DRIVERS_DMA
|
||||
|
||||
/* GPIO Devices */
|
||||
|
||||
#define DRIVERS_GPIO
|
||||
|
||||
/* Video support for sunxi */
|
||||
|
||||
|
||||
/* SDMMC Devices */
|
||||
|
||||
|
||||
/* TWI Devices */
|
||||
|
||||
|
||||
#endif
|
||||
56
bsp/allwinner/d1/rtconfig.py
Normal file
@@ -0,0 +1,56 @@
|
||||
import os
|
||||
|
||||
# toolchains options
|
||||
ARCH ='risc-v'
|
||||
VENDOR ='t-head'
|
||||
CPU ='c906'
|
||||
CROSS_TOOL ='gcc'
|
||||
|
||||
RTT_ROOT = os.getenv('RTT_ROOT') or os.path.join(os.getcwd(),'..','..','..')
|
||||
|
||||
if os.getenv('RTT_CC'):
|
||||
CROSS_TOOL = os.getenv('RTT_CC')
|
||||
|
||||
if CROSS_TOOL == 'gcc':
|
||||
PLATFORM = 'gcc'
|
||||
EXEC_PATH = r'/opt/riscv64_musl/bin'
|
||||
else:
|
||||
print('Please make sure your toolchains is GNU GCC!')
|
||||
exit(0)
|
||||
|
||||
if os.getenv('RTT_EXEC_PATH'):
|
||||
EXEC_PATH = os.getenv('RTT_EXEC_PATH')
|
||||
|
||||
BUILD = 'debug'
|
||||
|
||||
if PLATFORM == 'gcc':
|
||||
# toolchains
|
||||
#PREFIX = 'riscv64-unknown-elf-'
|
||||
PREFIX = os.getenv('RTT_CC_PREFIX') or 'riscv64-unknown-linux-musl-'
|
||||
CC = PREFIX + 'gcc'
|
||||
CXX = PREFIX + 'g++'
|
||||
AS = PREFIX + 'gcc'
|
||||
AR = PREFIX + 'ar'
|
||||
LINK = PREFIX + 'gcc'
|
||||
TARGET_EXT = 'elf'
|
||||
SIZE = PREFIX + 'size'
|
||||
OBJDUMP = PREFIX + 'objdump'
|
||||
OBJCPY = PREFIX + 'objcopy'
|
||||
|
||||
DEVICE = ' -mcmodel=medany -march=rv64imafdc -mabi=lp64'
|
||||
CFLAGS = DEVICE + ' -fvar-tracking -ffreestanding -fno-common -ffunction-sections -fdata-sections -fstrict-volatile-bitfields '
|
||||
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp'
|
||||
LFLAGS = DEVICE + ' -nostartfiles -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,_start -T link.lds' + ' -lsupc++ -lgcc -static'
|
||||
CPATH = ''
|
||||
LPATH = ''
|
||||
|
||||
if BUILD == 'debug':
|
||||
CFLAGS += ' -O0 -ggdb'
|
||||
AFLAGS += ' -ggdb'
|
||||
else:
|
||||
CFLAGS += ' -O2 -Os'
|
||||
|
||||
CXXFLAGS = CFLAGS
|
||||
|
||||
DUMP_ACTION = OBJDUMP + ' -D -S $TARGET > rtthread.asm\n'
|
||||
POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n'
|
||||
957
bsp/allwinner/d1s/.config
Normal file
11
bsp/allwinner/d1s/.gitignore
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
__pycache__/
|
||||
*.bin
|
||||
*.elf
|
||||
*.map
|
||||
build/
|
||||
.sconsign.dblite
|
||||
cconfig.h
|
||||
.vscode/
|
||||
rtconfig.pyc
|
||||
*.old
|
||||
sdcard.bat
|
||||
47
bsp/allwinner/d1s/Kconfig
Normal file
@@ -0,0 +1,47 @@
|
||||
mainmenu "RT-Thread Project Configuration"
|
||||
|
||||
config BSP_DIR
|
||||
string
|
||||
option env="BSP_ROOT"
|
||||
default "."
|
||||
|
||||
config RTT_DIR
|
||||
string
|
||||
option env="RTT_ROOT"
|
||||
default "../../.."
|
||||
|
||||
config PKGS_DIR
|
||||
string
|
||||
option env="PKGS_ROOT"
|
||||
default "packages"
|
||||
|
||||
source "$RTT_DIR/Kconfig"
|
||||
source "$PKGS_DIR/Kconfig"
|
||||
|
||||
config BOARD_allwinnerd1s
|
||||
bool
|
||||
select ARCH_RISCV64
|
||||
select RT_USING_COMPONENTS_INIT
|
||||
select RT_USING_USER_MAIN
|
||||
select RT_USING_CACHE
|
||||
select ARCH_MM_MMU
|
||||
default y
|
||||
|
||||
config RT_USING_USERSPACE
|
||||
bool
|
||||
default y
|
||||
|
||||
config ENABLE_FPU
|
||||
bool "Enable FPU"
|
||||
default y
|
||||
|
||||
config RT_USING_USERSPACE_32BIT_LIMIT
|
||||
bool "Enable userspace 32bit limit"
|
||||
default n
|
||||
|
||||
config __STACKSIZE__
|
||||
int "stack size for interrupt"
|
||||
default 4096
|
||||
|
||||
source "../libraries/drivers/Kconfig"
|
||||
source "../libraries/Kconfig"
|
||||
283
bsp/allwinner/d1s/README-M7.md
Normal file
@@ -0,0 +1,283 @@
|
||||
# 基于柿饼M7运行 RT-Smart
|
||||
|
||||
## 准备工作
|
||||
|
||||
#### 开发环境
|
||||
|
||||
推荐使用 ubuntu20.04(虚拟机/docker/服务器) + Window10/11
|
||||
|
||||
- ubuntu:用于编译、开发、打包镜像
|
||||
- windows:用于下载打包好的镜像
|
||||
|
||||
#### 常用工具
|
||||
|
||||
**Ubuntu:**
|
||||
|
||||
```bash
|
||||
sudo apt install libncurses5-dev scons gcc qemu-system
|
||||
```
|
||||
|
||||
- qemu:用于仿真运行RISC-V程序
|
||||
- gcc:用于编译menucofig的程序
|
||||
- libncurses5-dev :menucofig功能依赖此库
|
||||
- scons:编译RT-Smart需要的构建工具
|
||||
|
||||
**Windows:**
|
||||
|
||||
- vscode:windows上安装,用于远程连接ubuntu系统,可以在win上体验原生的linux开发环境。
|
||||
- MobaXterm:终端工具,可以ssh远程ubuntu系统,也可以通过串口连接柿饼M7模块
|
||||
- env_riscv_1.1.3.zip:针对risc-v平台的ENV工具。
|
||||
|
||||
#### 相关仓库权限
|
||||
|
||||
- https://gitee.com/rtthread/rt-thread :rtthread内核仓库,以submodule的形式存在于rtthread-smart仓库中,这里使用的是rt-smart分支
|
||||
|
||||
获取上面的仓库权限,并将rtthread-smart克隆到ubuntu系统目录下。目录结构如下所示:
|
||||
|
||||
在做好上面的准备后,就可以真正的开始搭建RT-Smart的开发环境了。
|
||||
|
||||
## 模拟仿真环境搭建
|
||||
|
||||
在真实的硬件上开发之前,可以先搭建基于QEMU的模拟仿真环境。
|
||||
|
||||
参考这篇文章,完成 qemu-riscv64 上 RT-Smart 环境搭建:https://gitee.com/guozhanxin/rtthread-smart/tree/master/docs/risc-v64
|
||||
|
||||
最后能够在 qemu-riscv64 上正常运行RT-Smart系统,并运行一个 `hello.elf` 用户态应用。
|
||||
|
||||
```
|
||||
msh /bin>hello.elf
|
||||
msh /bin>hello world!
|
||||
```
|
||||
|
||||
## 真实硬件环境搭建
|
||||
|
||||
#### 硬件连接
|
||||
|
||||
按照下图中的连接方式,为开发板供电,并使用USB转TTL工具连接串口调试。
|
||||
|
||||
<img src="figures/board.png" style="zoom:50%;" />
|
||||
|
||||
#### 驱动安装
|
||||
|
||||
1. 按住下载模式按钮的情况下为开发板上电。
|
||||
|
||||
2. 解压tools目录下fel驱动安装.zip文件。参照如下所示的“驱动安装示意图”,安装fel驱动。
|
||||
|
||||

|
||||
|
||||
#### 连接串口工具
|
||||
|
||||
打开 MobaXterm 终端工具,并连接到对应的端口,波特率为:500000。
|
||||
|
||||
> 注意:如果系统没有固件的话,不会有任何输出,是正常现象。
|
||||
|
||||
<img src="figures/mobaxterm.png" alt="1662708288766" style="zoom: 50%;" />
|
||||
|
||||
#### 制作系统固件
|
||||
|
||||
参照 qemu-riscv64 上编译内核的步骤,配置环境变量,并使用 scons 命令编译 RT-Smart 内核
|
||||
|
||||
编译完内核之后,会自动执行打包命令 `./mksdimg.sh` 打包出sd.bin镜像文件。此文件将在后面的步骤中借助下载工具,下载到 D1s 上运行。
|
||||
|
||||
#### 烧录系统内核
|
||||
|
||||
我们借助fel工具烧录系统内核。
|
||||
|
||||
1. 解压tools目录下的 xfel_v1.2.9.7z 文件,里面包含三个文件
|
||||
|
||||
```shell
|
||||
boot0_sdcard_sun20iw1p1_f133.bin ---- 第一次烧录需要烧录此boot文件
|
||||
sd.bin ---- 打包好的系统内核镜像
|
||||
xfel.exe ---- 烧录工具
|
||||
```
|
||||
|
||||
2. 解压tools目录下 env_riscv_1.1.3.zip 文件,打开env工具,并进入解压好的 xfel_v1.2.9 目录下。运行下面的命令烧录系统内核
|
||||
|
||||
- 烧录boot镜像: xfel.exe write 8192 boot0_sdcard_sun20iw1p1_f133.bin
|
||||
- 烧录内核镜像: xfel.exe sd write 57344 sd.bin
|
||||
- 复位系统: xfel.exe reset
|
||||
|
||||
> 注意:执行烧录命令前,需要使开发板处于fel下载模式(按住下载按钮并上电)
|
||||
|
||||
日志如下所示:
|
||||
|
||||
```shell
|
||||
11714@DESKTOP-VEL6MD9 E:\workspace\d1s-smart\env_riscv_1.1.3
|
||||
> cd E:\workspace\d1s-smart\xfel_v1.2.9
|
||||
|
||||
11714@DESKTOP-VEL6MD9 E:\workspace\d1s-smart\xfel_v1.2.9
|
||||
> xfel.exe write 8192 boot0_sdcard_sun20iw1p1_f133.bin
|
||||
ERROR: Can't found any FEL device ---- 如果开发板没有处于fel下载模式的话,会提示错误。
|
||||
|
||||
## 第一次使用需要先烧录boot镜像文件
|
||||
11714@DESKTOP-VEL6MD9 E:\workspace\d1s-smart\xfel_v1.2.9
|
||||
> xfel.exe write 8192 boot0_sdcard_sun20iw1p1_f133.bin
|
||||
100% [================================================] 48.000 KB, 364.927 KB/s
|
||||
|
||||
## 烧录内核镜像文件
|
||||
11714@DESKTOP-VEL6MD9 E:\workspace\d1s-smart\xfel_v1.2.9
|
||||
> xfel.exe sd write 57344 sd.bin
|
||||
write 7240Kbytes
|
||||
swap buf:00023E00,len=512, cmdlen=512
|
||||
Found SD card 126877696 bytes
|
||||
100% [================================================] 7.070 MB, 219.468 KB/s
|
||||
|
||||
## 复位系统
|
||||
11714@DESKTOP-VEL6MD9 E:\workspace\d1s-smart\xfel_v1.2.9
|
||||
> xfel.exe reset
|
||||
usb bulk recv error
|
||||
```
|
||||
|
||||
如果此时连接着 MobaXterm 终端工具,可以看到系统以及正常启动,并可以通过 **msh** 命令和系统交互了。
|
||||
|
||||
```bash
|
||||
[I/I2C] I2C bus [i2c2] registered
|
||||
|
||||
\ | /
|
||||
- RT - Thread Smart Operating System
|
||||
/ | \ 5.0.0 build Oct 20 2022
|
||||
2006 - 2020 Copyright by rt-thread team
|
||||
lwIP-2.0.2 initialized!
|
||||
winusb class register done.
|
||||
set samplerate:48000
|
||||
set samplebits:16
|
||||
set channels:2
|
||||
set volume:80%
|
||||
hal_sdc_create 0
|
||||
card_detect insert
|
||||
Initial card success. capacity :121MB
|
||||
sdmmc bytes_per_secotr:200, sector count:3c800
|
||||
found part[0], begin: 8388608, size: 90.0MB
|
||||
found partition:sd0 of mbr at offset 0000000000004000, size:000000000002d000
|
||||
found part[1], begin: 102760448, size: 23.0MB
|
||||
found partition:sd1 of mbr at offset 0000000000031000, size:000000000000b800
|
||||
hal_sdc_create 1
|
||||
card_detect insert
|
||||
Initial card success. capacity :7624MB
|
||||
sdmmc bytes_per_secotr:200, sector count:ee4000
|
||||
found part[0], begin: 512, size: 4194303.1023GB
|
||||
found partition:sd0 of mbr at offset 0000000000000001, size:ffffffffffffffff
|
||||
[I/sal.skt] Socket Abstraction Layer initialize success.
|
||||
[D/FAL] (fal_flash_init:47) Flash device | sdcard0 | addr: 0x00000000 | len: 0x07900000 | blk_size: 0x00000200 |initialized finish.
|
||||
```
|
||||
|
||||
#### 运行用户态应用(可选)
|
||||
|
||||
在 D1s 上运行系统应用有两种方式:一种是制作 `sdroot.bin` 并借助 `xfel工具` 烧录到 `sdmmc` 对应的位置上;二是使用 romfs 的方式,和内核镜像编译在一起,然后整个的烧录到 `sdmmc` 上。
|
||||
|
||||
**1、借助 romfs 运行用户态应用**
|
||||
|
||||
romfs 方式优点:打包、调试方便,无需外部 emmc 挂载文件系统,使能 romfs 文件系统即可使用,缺点是 romfs 是只读文件系统。
|
||||
|
||||
这部分可以参考 qemu-riscv64 上运行用户态应用的部分。使用 python 命令将 userapps 下 root 目录下的用户态应用打包为 `romfs.c` ,并重新编译系统内核,重复上面的系统内核烧录步骤。最后复位并运行系统。参照下面的运行日志,运行对应的用户态应用。
|
||||
|
||||
```bash
|
||||
msh />cd bin
|
||||
msh /bin>ls
|
||||
Directory /bin:
|
||||
syslogd.elf 423024
|
||||
ping.elf 368104
|
||||
webserver.elf 510216
|
||||
hello.elf 366096
|
||||
em.elf 601336
|
||||
pong.elf 367024
|
||||
syslog.elf 391128
|
||||
vi.elf 528096
|
||||
hdc_test.elf 367520
|
||||
ntp.elf 392168
|
||||
mmapctrl.elf 366992
|
||||
pmq.elf 371600
|
||||
webclient.elf 413784
|
||||
lwIPKit.elf 998504
|
||||
msh /bin>hello.elf
|
||||
msh /bin>hello world!
|
||||
```
|
||||
|
||||
**2、在存储设备上运行用户态应用**
|
||||
|
||||
sdroot.bin 挂载方式优点:使用 emmc 存储设备的文件系统是可读可写的,更加灵活方便。
|
||||
|
||||
首先下载 RT-Smart 用户态应用代码:
|
||||
|
||||
```
|
||||
git clone https://github.com/RT-Thread/userapps.git
|
||||
```
|
||||
|
||||

|
||||
|
||||
拷贝之前克隆好的 rtthread rt-smart 分支的仓库到 `userapps` 目录下,进入 `userapps` 目录,使用 scons 编译用户态程序,然后运行 `./mksdcard.sh` 打包脚本,将生成的 `sdroot.bin` 复制到 window 下存在 `xfel.exe ` 的目录下,使用以下命令即可烧录用户态程序到存储设备 :
|
||||
|
||||
```bash
|
||||
xfel.exe sd write 8388608 sdroot.bin
|
||||
```
|
||||
|
||||
参照下面的运行日志,运行对应的用户态应用:
|
||||
|
||||
```C
|
||||
msh />ls
|
||||
Directory /:
|
||||
bin <DIR>
|
||||
data <DIR>
|
||||
Directory /bin:
|
||||
syslogd.elf 423024
|
||||
ping.elf 368104
|
||||
webserver.elf 510216
|
||||
hello.elf 366096
|
||||
em.elf 601336
|
||||
pong.elf 367024
|
||||
syslog.elf 391128
|
||||
vi.elf 528096
|
||||
hdc_test.elf 367520
|
||||
ntp.elf 392168
|
||||
mmapctrl.elf 366992
|
||||
pmq.elf 371600
|
||||
webclient.elf 413784
|
||||
lwIPKit.elf 998504
|
||||
msh /bin>hello.elf
|
||||
msh /bin>hello world!
|
||||
```
|
||||
|
||||
## D1S-EMMC 分区示意图
|
||||
|
||||

|
||||
|
||||
## Q&A
|
||||
|
||||
Q:使用 `VSCode` 发现有些已经定义的宏变灰,头文件报错:
|
||||
|
||||
A:打开 `VSCode`,按下 “Crtl+Shift+P” 打开 `VSCode` 的控制台,然后输入 “C/C++: **Edit configurations(JSON)** ”,打开 C/C++编辑配置文件,添加如下配置选项
|
||||
|
||||
```json
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Linux",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/**",
|
||||
"${workspaceFolder}/bsp/allwinner/d1s",
|
||||
"${workspaceFolder}/include",
|
||||
"${workspaceFolder}/components/drivers/include",
|
||||
"${workspaceFolder}/bsp/allwinner/libraries/sunxi-hal/include"
|
||||
],
|
||||
"defines": [],
|
||||
"compilerPath": "/usr/bin/gcc",
|
||||
"cStandard": "gnu17",
|
||||
"cppStandard": "gnu++14",
|
||||
"intelliSenseMode": "linux-gcc-x64"
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Q:开机后,出现了 **mount** 失败的错误
|
||||
|
||||

|
||||
|
||||
A:原因是没有下载 all_bin/sdroot.bin(用户态) 固件导致,重新烧录 all_bin/sdroot.bin 到 8388608 地址后,即可 mount 成功,,烧录命令如下:
|
||||
|
||||
```bash
|
||||
xfel.exe sd write 8388608 all.bin/sdroot.bin
|
||||
```
|
||||
183
bsp/allwinner/d1s/README-MQ.md
Normal file
@@ -0,0 +1,183 @@
|
||||
# 基于麻雀D1运行 RT-Smart
|
||||
|
||||
### 下载代码
|
||||
|
||||
下载 RT-Smart 用户态应用代码:
|
||||
|
||||
```
|
||||
git clone https://github.com/RT-Thread/userapps.git
|
||||
```
|
||||
|
||||

|
||||
|
||||
进入到 `userapps` 目录,克隆 RT-Thread rt-smart 分支
|
||||
|
||||
```shell
|
||||
git clone -b rt-smart https://gitee.com/rtthread/rt-thread.git
|
||||
```
|
||||
|
||||

|
||||
|
||||
### 配置工具链
|
||||
|
||||
在 userapps\tools 目录下运行 `get_toolchain.py` 的脚本,会下载对应的工具链并展开到 userapps\tools\gun_gcc 目录。后面的工具链名称可以是 arm | riscv64。
|
||||
|
||||
因为 D1S 是 RISCV-64 架构的,所以输入下面的命令:
|
||||
|
||||
```
|
||||
python3 get_toolchain.py riscv64
|
||||
```
|
||||
|
||||
在 userapps 目录下,运行 `smart-env.sh` 配置工具链路径,目前支持的参数可以是 arm | riscv64
|
||||
|
||||
```
|
||||
source smart-env.sh riscv64
|
||||
```
|
||||
|
||||

|
||||
|
||||
|
||||
### 编译内核程序
|
||||
|
||||
进入 `rt-thread/bsp/allwinner/d1s` 目录下,执行以下命令拉取一下软件包
|
||||
|
||||
* 注:若系统没有安装 env,需要手动输入 `scons --menuconfig` 命令手动下载 env
|
||||
|
||||
```shell
|
||||
source ~/.env/env.sh
|
||||
pkgs --update
|
||||
```
|
||||
|
||||
使用 scons 命令进行编译,编译成功后会在 `userapps/rt-thread/bsp/allwinner/d1s` 目录下生成 sd.bin,这个文件就是我们需要烧录到开发板中的文件,它包括了 uboot.dtb,opensbi,rtthread.bin。
|
||||
|
||||
### 烧录程序
|
||||
|
||||
1、首先准备一张容量在 128G 以内的空白 TF卡
|
||||
|
||||
2、使用 fdisk 分区。将 TF卡 挂载到 ubuntu 系统后,使用 df 查看设备路径。笔者使用的 32GB TF卡,扇区大小 512 字节,我们需要预留前 8M 的空间,那么计算得知分区扇区开始于:16384,使用命令:`sudo fdisk /dev/sdb`,选择:o,n,p,1,16384,回车。
|
||||
|
||||
```shell
|
||||
Command (m for help): o
|
||||
Created a new DOS disklabel with disk identifier 0x3668b987.
|
||||
|
||||
Command (m for help): n
|
||||
Partition type
|
||||
p primary (0 primary, 0 extended, 4 free)
|
||||
e extended (container for logical partitions)
|
||||
Select (default p): p
|
||||
Partition number (1-4, default 1): 1
|
||||
First sector (2048-62410751, default 2048): 16384
|
||||
Last sector, +sectors or +size{K,M,G,T,P} (16384-62410751, default 62410751):
|
||||
|
||||
Created a new partition 1 of type 'Linux' and of size 29.8 GiB.
|
||||
|
||||
Command (m for help): w
|
||||
The partition table has been altered.
|
||||
```
|
||||
|
||||
正确的分区效果如下:
|
||||
|
||||

|
||||
|
||||
然后格式化 sdb1 分区为 fat32 格式:
|
||||
|
||||
```shell
|
||||
$ sudo mkfs -t fat /dev/sdb1
|
||||
```
|
||||
|
||||
这里可以使用 **Gparted** 工具可视化查看一下分区状况:
|
||||
|
||||

|
||||
|
||||
3、接下来使用以下命令烧录 RT-SMART 内核:
|
||||
|
||||
```shell
|
||||
sudo dd if=boot0_sdcard_sun20iw1p1.bin of=/dev/sdb bs=1024 seek=8
|
||||
sudo dd if=sd.bin of=/dev/sdb bs=1024 seek=56
|
||||
```
|
||||
|
||||
* 注:**boot0_sdcard_sun20iw1p1.bin** 文件在 `userapps/rt-thread/bsp/allwinner/d1s/tools` 路径下
|
||||
* 这里的 /dev/sdb 设备要根据自己的选择
|
||||
|
||||
下面是烧录成功的显示:
|
||||
|
||||

|
||||
|
||||
### 启动 RT-Smart
|
||||
|
||||
方式二(TF 卡)启动:
|
||||
|
||||
此时将 TF 卡放入开发板,串口0(底部排针的7,8脚),串口波特率 500000,然后上电,如下 RT-Smart 已经成功启动
|
||||
|
||||

|
||||
|
||||
```shell
|
||||
\ | /
|
||||
- RT - Thread Smart Operating System
|
||||
/ | \ 5.0.0 build Nov 1 2022
|
||||
2006 - 2022 Copyright by rt-thread team
|
||||
lwIP-2.0.2 initialized!
|
||||
hal_sdc_create 0
|
||||
card_detect insert
|
||||
Initial card success. capacity :30436MB
|
||||
sdmmc bytes_per_secotr:200, sector count:3b72400
|
||||
found part[0], begin: 8388608, size: 29.732GB
|
||||
found partition:sd0 of mbr at offset 0000000000004000, size:0000000003b6e400
|
||||
hal_sdc_create 1
|
||||
card_detect insert
|
||||
Initial card failed!!
|
||||
[E/drv-sdmmc] init sdmmc failed!
|
||||
[E/drv-sdmmc] sdmmc_init failed!
|
||||
[I/sal.skt] Socket Abstraction Layer initialize success.
|
||||
[D/FAL] (fal_flash_init:47) Flash device | sdcard0 | addr: 0x00000000 | len: 0x76e480000 | blk_size: 0x00000200 |initialized finish.
|
||||
[I/FAL] ==================== FAL partition table ====================
|
||||
[I/FAL] | name | flash_dev | offset | length |
|
||||
[I/FAL] -------------------------------------------------------------
|
||||
[I/FAL] | download | sdcard0 | 0x00800000 | 0x00800000 |
|
||||
[I/FAL] | easyflash | sdcard0 | 0x01000000 | 0x00100000 |
|
||||
[I/FAL] | filesystem | sdcard0 | 0x01100000 | 0x00c00000 |
|
||||
[I/FAL] =============================================================
|
||||
[I/FAL] RT-Thread Flash Abstraction Layer initialize success.
|
||||
Hello RISC-V
|
||||
[W/DBG] disp:[parser_disp_init_para 575]of_property_read screen1_output_type fail
|
||||
msh />Mount "sd0p0" on "/" success
|
||||
msh />
|
||||
```
|
||||
|
||||
### 编译用户态程序
|
||||
|
||||
进入 `userapps` 目录下,使用 scons 编译用户态程序,编译好的文件会生成在 `root/bin` 目录下。
|
||||
|
||||

|
||||
|
||||
### 运行用户态程序
|
||||
|
||||
从 `root/bin` 目录下拷贝出 hello 程序,到 TF卡 的文件系统中。
|
||||
|
||||

|
||||
|
||||
拔出 TF 卡,插入到开发板,上电。即可体验属于自己的 helloworld 程序了。
|
||||
|
||||
```shell
|
||||
msh /bin>ls
|
||||
Directory /bin:
|
||||
dbkit_client.elf 616960
|
||||
elmFATKit.elf 373880
|
||||
em.elf 585504
|
||||
hdc_test.elf 339976
|
||||
hello.elf 339624
|
||||
lvgl.elf 1382168
|
||||
lwIPKit.elf 976784
|
||||
mmapctrl.elf 339976
|
||||
ntp.elf 363560
|
||||
ping.elf 344208
|
||||
pmq.elf 345176
|
||||
pong.elf 339624
|
||||
syslog.elf 364736
|
||||
syslogd.elf 377560
|
||||
vi.elf 446568
|
||||
webclient.elf 358048
|
||||
msh /bin>
|
||||
msh /bin>hello.elf
|
||||
msh /bin>hello world!
|
||||
```
|
||||
4
bsp/allwinner/d1s/README.md
Normal file
@@ -0,0 +1,4 @@
|
||||
# 全志 D1s 运行 RT-Smart
|
||||
|
||||
* [基于柿饼M7运行 RT-Smart](./README-M7.md)
|
||||
* [基于麻雀MQ运行 RT-Smart](./README-MQ.md)
|
||||
14
bsp/allwinner/d1s/SConscript
Normal file
@@ -0,0 +1,14 @@
|
||||
# for module compiling
|
||||
import os
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
objs = []
|
||||
list = os.listdir(cwd)
|
||||
|
||||
for d in list:
|
||||
path = os.path.join(cwd, d)
|
||||
if os.path.isfile(os.path.join(path, 'SConscript')):
|
||||
objs = objs + SConscript(os.path.join(d, 'SConscript'))
|
||||
|
||||
Return('objs')
|
||||
101
bsp/allwinner/d1s/SConstruct
Normal file
@@ -0,0 +1,101 @@
|
||||
import os
|
||||
import sys
|
||||
import rtconfig
|
||||
import platform
|
||||
import subprocess
|
||||
import uuid
|
||||
|
||||
from rtconfig import RTT_ROOT
|
||||
import sys
|
||||
|
||||
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
|
||||
from building import *
|
||||
|
||||
TARGET = 'rtthread.' + rtconfig.TARGET_EXT
|
||||
|
||||
DefaultEnvironment(tools=[])
|
||||
env = Environment(tools = ['mingw'],
|
||||
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
|
||||
CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
|
||||
CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS,
|
||||
AR = rtconfig.AR, ARFLAGS = '-rc',
|
||||
LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
|
||||
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
|
||||
env['ASCOM'] = env['ASPPCOM']
|
||||
|
||||
Export('RTT_ROOT')
|
||||
Export('rtconfig')
|
||||
|
||||
rtconfig.CPU='c906'
|
||||
rtconfig.VENDOR="t-head"
|
||||
rtconfig.ARCH='risc-v'
|
||||
|
||||
SDK_ROOT = os.path.abspath('../')
|
||||
|
||||
if os.path.exists(SDK_ROOT + '/libraries'):
|
||||
libraries_path_prefix = SDK_ROOT + '/libraries'
|
||||
else:
|
||||
libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries'
|
||||
|
||||
SDK_LIB = libraries_path_prefix
|
||||
Export('SDK_LIB')
|
||||
|
||||
# prepare building environment
|
||||
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu = False)
|
||||
|
||||
# set spawn
|
||||
def ourspawn(sh, escape, cmd, args, e):
|
||||
filename = str(uuid.uuid4())
|
||||
newargs = ' '.join(args[1:])
|
||||
cmdline = cmd + " " + newargs
|
||||
if (len(cmdline) > 16 * 1024):
|
||||
f = open(filename, 'w')
|
||||
f.write(' '.join(args[1:]).replace('\\', '/'))
|
||||
f.close()
|
||||
# exec
|
||||
cmdline = cmd + " @" + filename
|
||||
proc = subprocess.Popen(cmdline, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE, shell = False, env = e)
|
||||
data, err = proc.communicate()
|
||||
rv = proc.wait()
|
||||
def res_output(_output, _s):
|
||||
if len(_s):
|
||||
if isinstance(_s, str):
|
||||
_output(_s)
|
||||
elif isinstance(_s, bytes):
|
||||
_output(str(_s, 'UTF-8'))
|
||||
else:
|
||||
_output(str(_s))
|
||||
res_output(sys.stderr.write, err)
|
||||
res_output(sys.stdout.write, data)
|
||||
if os.path.isfile(filename):
|
||||
os.remove(filename)
|
||||
return rv
|
||||
|
||||
if platform.system() == 'Windows':
|
||||
env['SPAWN'] = ourspawn
|
||||
|
||||
hal_library = 'sunxi-hal'
|
||||
rtconfig.BSP_LIBRARY_TYPE = hal_library
|
||||
|
||||
# include libraries
|
||||
objs.extend(SConscript(os.path.join(libraries_path_prefix, hal_library, 'SConscript')))
|
||||
|
||||
# include drivers
|
||||
objs.extend(SConscript(os.path.join(libraries_path_prefix, 'drivers', 'SConscript')))
|
||||
|
||||
# include libos
|
||||
objs.extend(SConscript(os.path.join(libraries_path_prefix, 'libos', 'SConscript')))
|
||||
|
||||
if rtconfig.PLATFORM == 'gcc':
|
||||
env['LINKCOM'] = '$LINK -o $TARGET $LINKFLAGS $__RPATH $SOURCES $_LIBDIRFLAGS -Wl,--start-group $_LIBFLAGS -Wl,--end-group'
|
||||
|
||||
stack_size = 4096
|
||||
|
||||
stack_lds = open('link_stacksize.lds', 'w')
|
||||
if GetDepend('__STACKSIZE__'): stack_size = GetDepend('__STACKSIZE__')
|
||||
stack_lds.write('__STACKSIZE__ = %d;' % stack_size)
|
||||
stack_lds.close()
|
||||
|
||||
# make a building
|
||||
DoBuilding(TARGET, objs)
|
||||
9
bsp/allwinner/d1s/applications/SConscript
Normal file
@@ -0,0 +1,9 @@
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
src = Glob('*.c') + Glob('*.cpp')
|
||||
CPPPATH = [cwd]
|
||||
|
||||
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
||||
23
bsp/allwinner/d1s/applications/main.c
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2022, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printf("Hello RISC-V\n");
|
||||
|
||||
#ifdef BSP_USING_LCD
|
||||
extern int rt_hw_lcd_init(void);
|
||||
rt_hw_lcd_init();
|
||||
#endif // BSP_USING_LCD
|
||||
|
||||
return 0;
|
||||
}
|
||||
130
bsp/allwinner/d1s/applications/mnt.c
Normal file
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* COPYRIGHT (C) 2012-2022, Shanghai Real-Thread Technology Co., Ltd
|
||||
* All rights reserved.
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2018-02-08 RT-Thread the first version
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
#include <unistd.h>
|
||||
#include "drv_pin.h"
|
||||
|
||||
#ifdef BSP_USING_SDMMC
|
||||
#include "drv_sdmmc.h"
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_FAL
|
||||
#include "fal.h"
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_DFS
|
||||
#include <dfs_fs.h>
|
||||
|
||||
#define SD_CHECK_PIN GET_PIN(GPIO_PORT_G, GPIO_PIN_3)
|
||||
|
||||
int sd_check_thread_entry(void *p)
|
||||
{
|
||||
rt_uint8_t old_sd_check = 0;
|
||||
|
||||
/* 挂载sd0分区 */
|
||||
if (RT_NULL != rt_device_find("sd0p0"))
|
||||
{
|
||||
if (dfs_mount("sd0p0", "/", "elm", 0, 0) == 0)
|
||||
{
|
||||
rt_kprintf("Mount \"sd0p0\" on \"/\" success\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
rt_kprintf("Mount \"sd0p0\" on \"/\" fail\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* 挂载sd1分区 */
|
||||
if (RT_NULL != rt_device_find("sd0p1"))
|
||||
{
|
||||
if (dfs_mount("sd0p1", "/", "elm", 0, 0) == 0)
|
||||
{
|
||||
rt_kprintf("Mount \"sd0p1\" on \"/\" success\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
rt_kprintf("Mount \"sd0p1\" on \"/data\" fail\n");
|
||||
}
|
||||
}
|
||||
|
||||
while (1)
|
||||
{
|
||||
#ifdef SD_CARD_CHECK
|
||||
if (!rt_pin_read(SD_CHECK_PIN) && !old_sd_check) // mount
|
||||
#else
|
||||
if (!old_sd_check) // mount
|
||||
#endif
|
||||
{
|
||||
sd_mmc1_init();
|
||||
/* 挂载sd2分区 */
|
||||
if (RT_NULL != rt_device_find("sd1p0"))
|
||||
{
|
||||
|
||||
if (access("/mnt", 0) != 0)
|
||||
{
|
||||
mkdir("/mnt", 0777);
|
||||
}
|
||||
|
||||
if (dfs_mount("sd1p0", "/mnt", "elm", 0, 0) == 0)
|
||||
{
|
||||
rt_kprintf("Mount \"sd1p0\" on \"/mnt\" success\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
rt_kprintf("Mount \"sd1p0\" on \"/mnt\" fail\n");
|
||||
}
|
||||
}
|
||||
old_sd_check = 1;
|
||||
}
|
||||
#ifdef SD_CARD_CHECK
|
||||
else if (rt_pin_read(SD_CHECK_PIN) && old_sd_check) // unmount
|
||||
{
|
||||
if (RT_NULL != rt_device_find("sd1p0"))
|
||||
{
|
||||
|
||||
if (dfs_unmount("/mnt") == 0)
|
||||
{
|
||||
rt_kprintf("unMount \"sd1p0\" on \"/mnt\" success\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
rt_kprintf("unMount \"sd1p0\" on \"/mnt\" fail\n");
|
||||
}
|
||||
}
|
||||
sd_mmc1_deinit();
|
||||
old_sd_check = 0;
|
||||
}
|
||||
#endif
|
||||
rt_thread_delay(RT_TICK_PER_SECOND);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mnt_init(void)
|
||||
{
|
||||
#ifdef RT_USING_FAL
|
||||
{
|
||||
rt_thread_t thread = NULL;
|
||||
|
||||
rt_pin_mode(SD_CHECK_PIN, PIN_MODE_INPUT_PULLUP);
|
||||
|
||||
thread = rt_thread_create("sd", sd_check_thread_entry, NULL, 4096, 21, 10);
|
||||
if (thread == NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
rt_thread_startup(thread);
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
INIT_ENV_EXPORT(mnt_init);
|
||||
#endif
|
||||
19
bsp/allwinner/d1s/board/SConscript
Normal file
@@ -0,0 +1,19 @@
|
||||
# RT-Thread building script for component
|
||||
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
src = Glob('*.c')
|
||||
CPPPATH = [cwd]
|
||||
|
||||
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH)
|
||||
|
||||
objs = [group]
|
||||
|
||||
list = os.listdir(cwd)
|
||||
|
||||
for item in list:
|
||||
if os.path.isfile(os.path.join(cwd, item, 'SConscript')):
|
||||
objs = objs + SConscript(os.path.join(item, 'SConscript'))
|
||||
|
||||
Return('objs')
|
||||
118
bsp/allwinner/d1s/board/board.c
Normal file
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2022, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-01-30 lizhirui first version
|
||||
*/
|
||||
|
||||
#include <rthw.h>
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
|
||||
#include "board.h"
|
||||
#include "tick.h"
|
||||
|
||||
#include "drv_uart.h"
|
||||
#include "encoding.h"
|
||||
#include "stack.h"
|
||||
#include "sbi.h"
|
||||
#include "riscv.h"
|
||||
#include "stack.h"
|
||||
|
||||
#include "hal_gpio.h"
|
||||
#include "hal_clk.h"
|
||||
#include "hal_uart.h"
|
||||
#include "hal_dma.h"
|
||||
|
||||
#ifdef RT_USING_USERSPACE
|
||||
#include "riscv_mmu.h"
|
||||
#include "mmu.h"
|
||||
#include "page.h"
|
||||
#include "lwp_arch.h"
|
||||
|
||||
// 这个结构体描述了buddy system的页分配范围
|
||||
rt_region_t init_page_region =
|
||||
{
|
||||
(rt_size_t)RT_HW_PAGE_START,
|
||||
(rt_size_t)RT_HW_PAGE_END};
|
||||
|
||||
// 内核页表
|
||||
volatile rt_size_t MMUTable[__SIZE(VPN2_BIT)] __attribute__((aligned(4 * 1024)));
|
||||
rt_mmu_info mmu_info;
|
||||
|
||||
#endif
|
||||
|
||||
// 初始化BSS节区
|
||||
void init_bss(void)
|
||||
{
|
||||
unsigned int *dst;
|
||||
|
||||
dst = &__bss_start;
|
||||
while (dst < &__bss_end)
|
||||
{
|
||||
*dst++ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void __rt_assert_handler(const char *ex_string, const char *func, rt_size_t line)
|
||||
{
|
||||
rt_kprintf("(%s) assertion failed at function:%s, line number:%d \n", ex_string, func, line);
|
||||
asm volatile("ebreak" ::
|
||||
: "memory");
|
||||
}
|
||||
|
||||
// BSP的C入口
|
||||
void primary_cpu_entry(void)
|
||||
{
|
||||
extern void entry(void);
|
||||
|
||||
// 初始化BSS
|
||||
init_bss();
|
||||
// 关中断
|
||||
rt_hw_interrupt_disable();
|
||||
rt_assert_set_hook(__rt_assert_handler);
|
||||
// 启动RT-Thread Smart内核
|
||||
entry();
|
||||
}
|
||||
|
||||
// 这个初始化程序由内核主动调用,此时调度器还未启动,因此在此不能使用依赖线程上下文的函数
|
||||
void rt_hw_board_init(void)
|
||||
{
|
||||
#ifdef RT_USING_USERSPACE
|
||||
rt_page_init(init_page_region);
|
||||
rt_hw_mmu_map_init(&mmu_info, (void *)USER_VADDR_START, USER_VADDR_TOP - USER_VADDR_START, (rt_size_t *)MMUTable, 0);
|
||||
rt_hw_mmu_kernel_map_init(&mmu_info, 0x00000000UL, USER_VADDR_START - 1);
|
||||
// 将低1GB MMIO区域设置为无Cache与Strong Order访存模式
|
||||
MMUTable[0] &= ~PTE_CACHE;
|
||||
MMUTable[0] &= ~PTE_SHARE;
|
||||
MMUTable[0] |= PTE_SO;
|
||||
rt_hw_mmu_switch((void *)MMUTable);
|
||||
#endif
|
||||
/* initalize interrupt */
|
||||
rt_hw_interrupt_init();
|
||||
#ifdef RT_USING_HEAP
|
||||
rt_kprintf("heap: [0x%08x - 0x%08x]\n", (rt_ubase_t)RT_HW_HEAP_BEGIN, (rt_ubase_t)RT_HW_HEAP_END);
|
||||
/* initialize memory system */
|
||||
rt_system_heap_init(RT_HW_HEAP_BEGIN, RT_HW_HEAP_END);
|
||||
#endif
|
||||
/* init hal hardware */
|
||||
hal_clock_init();
|
||||
hal_gpio_init();
|
||||
hal_dma_init();
|
||||
|
||||
/* init rtthread hardware */
|
||||
rt_hw_uart_init();
|
||||
rt_hw_tick_init();
|
||||
|
||||
#ifdef RT_USING_CONSOLE
|
||||
/* set console device */
|
||||
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
|
||||
#endif /* RT_USING_CONSOLE */
|
||||
|
||||
#ifdef RT_USING_COMPONENTS_INIT
|
||||
rt_components_board_init();
|
||||
#endif
|
||||
}
|
||||
31
bsp/allwinner/d1s/board/board.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2022, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-01-30 lizhirui first version
|
||||
*/
|
||||
|
||||
#ifndef BOARD_H__
|
||||
#define BOARD_H__
|
||||
|
||||
#include <rtconfig.h>
|
||||
|
||||
extern unsigned int __bss_start;
|
||||
extern unsigned int __bss_end;
|
||||
|
||||
#define RAM_SIZE (64 * 1024 * 1024)
|
||||
#define RAM_BASE (0x40000000)
|
||||
#define RAM_END (RAM_BASE + RAM_SIZE)
|
||||
|
||||
#define RT_HW_HEAP_BEGIN ((void *)&__bss_end)
|
||||
#define RT_HW_HEAP_END ((void *)(((rt_size_t)RT_HW_HEAP_BEGIN) + 16 * 1024 * 1024))
|
||||
#define RT_HW_PAGE_START RT_HW_HEAP_END
|
||||
#define RT_HW_PAGE_END ((void *)(RAM_END))
|
||||
|
||||
void rt_hw_board_init(void);
|
||||
void rt_init_user_mem(struct rt_thread *thread, const char *name, unsigned long *entry);
|
||||
|
||||
#endif
|
||||
BIN
bsp/allwinner/d1s/figures/MQ1.png
Normal file
|
After Width: | Height: | Size: 49 KiB |
BIN
bsp/allwinner/d1s/figures/MQ2.png
Normal file
|
After Width: | Height: | Size: 26 KiB |
BIN
bsp/allwinner/d1s/figures/MQ3.png
Normal file
|
After Width: | Height: | Size: 29 KiB |
BIN
bsp/allwinner/d1s/figures/MQ4.png
Normal file
|
After Width: | Height: | Size: 59 KiB |
BIN
bsp/allwinner/d1s/figures/MQ5.png
Normal file
|
After Width: | Height: | Size: 44 KiB |
BIN
bsp/allwinner/d1s/figures/MQ6.png
Normal file
|
After Width: | Height: | Size: 42 KiB |
BIN
bsp/allwinner/d1s/figures/MQ7.png
Normal file
|
After Width: | Height: | Size: 28 KiB |
BIN
bsp/allwinner/d1s/figures/MQ8.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
bsp/allwinner/d1s/figures/MQ9.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
bsp/allwinner/d1s/figures/board.png
Normal file
|
After Width: | Height: | Size: 13 MiB |
BIN
bsp/allwinner/d1s/figures/ddr_partition.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
bsp/allwinner/d1s/figures/emmc_partition.png
Normal file
|
After Width: | Height: | Size: 6.5 KiB |
BIN
bsp/allwinner/d1s/figures/error_name.png
Normal file
|
After Width: | Height: | Size: 102 KiB |
BIN
bsp/allwinner/d1s/figures/fel_driver.png
Normal file
|
After Width: | Height: | Size: 602 KiB |
BIN
bsp/allwinner/d1s/figures/lwip.png
Normal file
|
After Width: | Height: | Size: 55 KiB |