-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b4d3006
commit 47d4d3c
Showing
229 changed files
with
35,361 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#Build & install directories | ||
build/ | ||
packages/ | ||
install/ | ||
|
||
rtthread.* | ||
|
||
__pycache__ | ||
.config.old |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
mainmenu "RT-Thread Project Configuration" | ||
|
||
config BSP_DIR | ||
string | ||
option env="BSP_ROOT" | ||
default "." | ||
|
||
config RTT_DIR | ||
string | ||
option env="RTT_ROOT" | ||
default "../../rt-thread" | ||
|
||
config PKGS_DIR | ||
string | ||
option env="PKGS_ROOT" | ||
default "packages" | ||
|
||
source "$RTT_DIR/Kconfig" | ||
source "$PKGS_DIR/Kconfig" | ||
rsource "board/Kconfig" | ||
|
||
config BOARD_fpgac908 | ||
bool | ||
select ARCH_RISCV64 | ||
select RT_USING_COMPONENTS_INIT | ||
select RT_USING_USER_MAIN | ||
select RT_USING_CACHE | ||
select ARCH_MM_MMU | ||
select ARCH_RISCV_FPU_D | ||
select ARCH_REMAP_KERNEL if RT_USING_SMART | ||
default y | ||
|
||
config __STACKSIZE__ | ||
int "stack size for interrupt" | ||
default 4096 | ||
|
||
config C908_PLIC_PHY_ADDR | ||
int "PLIC base address" | ||
default 0xF00000000 | ||
|
||
config BSP_ROOTFS_TYPE_CROMFS | ||
bool "Use CROMFS as ROOTFS" | ||
select RT_USING_DFS_CROMFS | ||
select PKG_USING_ZLIB | ||
select PKG_USING_ZLIB_LATEST_VERSION | ||
default y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# rt-smart canaan porting | ||
|
||
## 下载依赖的软件包 | ||
|
||
在软件包无需变更的情况下只须执行一次 | ||
``` | ||
source ~/.env/env.sh | ||
pkgs --update | ||
``` | ||
|
||
## 将根文件系统编译进内核 | ||
|
||
为了方便测试,这里将根文件系统制作成CROMFS格式转换成C代码编译进内核。 | ||
|
||
1. 在 https://github.com/RT-Thread/userapps 页面下载riscv64预编译镜像 | ||
2. 解压后将其中的ext4.img挂载到一个目录中 | ||
``` | ||
sudo mount ext4.img dir | ||
``` | ||
3. 删除其中一些不必要的文件以减小内核体积 | ||
``` | ||
du -ha # 查看文件大小 | ||
sudo rm -rf dir/www dir/usr/share/fonts dir/tc | ||
``` | ||
4. 生成cromfs文件 | ||
工具位于 https://github.com/RT-Thread/userapps/tree/main/tools/cromfs | ||
``` | ||
sudo ./cromfs-tool-x64 dir crom.img ./ # 将生成的cromfs_data.c放入applications目录 | ||
``` | ||
|
||
## 编译 | ||
|
||
### 一步完成 | ||
``` | ||
export RTT_EXEC_PATH=/mnt/e/tools/riscv64gc/bin # 你自己的编译器路径 | ||
scons -j8 all=1 | ||
``` | ||
|
||
### 分步完成 | ||
* 1. 编译RT-Thread | ||
``` | ||
export RTT_EXEC_PATH=/mnt/e/tools/riscv64gc/bin # 你自己的编译器路径 | ||
scons -j8 | ||
``` | ||
|
||
* 2. 编译opensbi & 生成烧录文件 | ||
``` | ||
./mkfm.sh /mnt/e/tools/riscv64gc/bin/riscv64-unknown-linux-musl- # 你自己的编译器 | ||
``` | ||
此处会把`rtthread.bin`编译进opensbi | ||
|
||
|
||
## 烧录rtt_system.bin | ||
|
||
1. 参照 https://github.com/kendryte/k230_sdk 烧入预编译镜像 | ||
2. 通过另一个核上运行的linux烧录rtt | ||
``` | ||
ifconfig eth0 up;ifconfig eth0 192.168.2.2;cd /tmp;tftp -r rtt_system.bin -g 192.168.2.20;dd if=rtt_system.bin of=/dev/mmcblk1p1;reboot | ||
``` | ||
|
||
## 用uboot从sd卡fat分区加载rtt_system.bin | ||
|
||
在`快起`特性关闭的情况下,从小核控制台进入uboot操作界面,输入如下命令: | ||
``` | ||
fatload mmc 1:4 $ramdisk_addr rtt_system.bin;k230_boot mem $ramdisk_addr 0x$filesize | ||
``` | ||
|
||
`备注`: 随后RT-Thread启动界面显示在大核控制台。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
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') | ||
|
||
# prepare building environment | ||
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu = False) | ||
|
||
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from building import * | ||
|
||
cwd = GetCurrentDir() | ||
src = Glob('*.c') | ||
CPPPATH = [cwd] | ||
|
||
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH) | ||
|
||
Return('group') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright (c) 2006-2021, RT-Thread Development Team | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Change Logs: | ||
* Date Author Notes | ||
*/ | ||
|
||
#include <rtthread.h> | ||
#include <rthw.h> | ||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
int main(void) | ||
{ | ||
printf("Hello RISC-V\n"); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include <rtthread.h> | ||
|
||
#ifdef RT_USING_DFS | ||
#include <dfs_fs.h> | ||
|
||
rt_weak uint8_t *cromfs_get_partition_data(uint32_t *len) | ||
{ | ||
return RT_NULL; | ||
} | ||
|
||
static int mnt_cromfs(void) | ||
{ | ||
uint32_t length = 0; | ||
uint8_t *data = cromfs_get_partition_data(&length); | ||
int ret = -1; | ||
|
||
if (data && length) | ||
{ | ||
ret = dfs_mount(NULL, "/", "crom", 0, data); | ||
} | ||
|
||
return ret; | ||
} | ||
|
||
int mnt_init(void) | ||
{ | ||
rt_err_t ret; | ||
|
||
ret = mnt_cromfs(); | ||
if (ret != RT_EOK) | ||
{ | ||
rt_kprintf("CromFS mount failed!\n"); | ||
return ret; | ||
} | ||
|
||
mkdir("/dev/shm", 0x777); | ||
|
||
if (dfs_mount(RT_NULL, "/dev/shm", "tmp", 0, 0) != 0) | ||
{ | ||
rt_kprintf("Dir /dev/shm mount failed!\n"); | ||
} | ||
|
||
#ifdef BSP_SD_SDIO_DEV | ||
while (mmcsd_wait_cd_changed(100) != MMCSD_HOST_PLUGED) | ||
; | ||
|
||
if (dfs_mount(BSP_SD_MNT_DEVNAME, "/mnt", "elm", 0, 0) != 0) | ||
{ | ||
rt_kprintf("Dir /mnt mount failed!\n"); | ||
} | ||
#endif | ||
|
||
rt_kprintf("file system initialization done!\n"); | ||
|
||
return 0; | ||
} | ||
INIT_ENV_EXPORT(mnt_init); | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
menu "Drivers Configuration" | ||
|
||
menuconfig BSP_USING_SDIO | ||
bool "Enable SDIO" | ||
select RT_USING_SDIO | ||
default n | ||
|
||
if BSP_USING_SDIO | ||
config BSP_USING_SDIO0 | ||
bool "Enable SDIO0" | ||
default n | ||
|
||
if BSP_USING_SDIO0 | ||
config BSP_SDIO0_EMMC | ||
bool "Enable eMMC" | ||
default y | ||
|
||
config BSP_SDIO0_1V8 | ||
bool "Enable 1.8V" | ||
default y | ||
endif | ||
|
||
config BSP_USING_SDIO1 | ||
bool "Enable SDIO1" | ||
default y | ||
|
||
config BSP_SD_SDIO_DEV | ||
int "SDIO device SdCard on" | ||
range 0 1 | ||
default 1 | ||
|
||
config BSP_SD_MNT_DEVNAME | ||
string "The name of the SD-BlkDev to be mounted" | ||
default "sd13" | ||
endif | ||
|
||
|
||
endmenu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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') |
Oops, something went wrong.