Skip to content

Commit 0633951

Browse files
authored
Merge pull request #3965 from GFWisshit/sparc-v8
Add support for architecture sparc-v8 and soc bm3803.
2 parents 0f34110 + c3040ad commit 0633951

File tree

27 files changed

+2469
-0
lines changed

27 files changed

+2469
-0
lines changed

bsp/bm3803/.config

Lines changed: 456 additions & 0 deletions
Large diffs are not rendered by default.

bsp/bm3803/Kconfig

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
mainmenu "RT-Thread Configuration"
2+
3+
config BSP_DIR
4+
string
5+
option env="BSP_ROOT"
6+
default "."
7+
8+
config RTT_DIR
9+
string
10+
option env="RTT_ROOT"
11+
default "../.."
12+
13+
# you can change the RTT_ROOT default "../.." to your rtthread_root,
14+
# example: default "F:/git_repositories/rt-thread"
15+
16+
config PKGS_DIR
17+
string
18+
option env="PKGS_ROOT"
19+
default "packages"
20+
21+
config ENV_DIR
22+
string
23+
option env="ENV_ROOT"
24+
default "/"
25+
26+
source "$RTT_DIR/Kconfig"
27+
source "$PKGS_DIR/Kconfig"
28+
29+
config SOC_BM3803
30+
bool
31+
select RT_USING_COMPONENTS_INIT
32+
select RT_USING_USER_MAIN
33+
default y
34+
35+
config RT_USING_UART1
36+
bool "Using RT_USING_UART1"
37+
default y
38+

bsp/bm3803/README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# BM3803板级支持包
2+
3+
## 1. 简介
4+
5+
BM3803是中国航天科技集团公司第九研究院第七七二研究所推出的基于SPARC V8内核的抗辐射32位处理器
6+
包括如下硬件特性:
7+
8+
| 硬件 | 描述 |
9+
| -- | -- |
10+
|芯片型号| BM3803 |
11+
|CPU| SPARC V8 |
12+
|主频| 50 - 100MHz |
13+
|SRAM | 2MB |
14+
15+
## 2. 编译说明
16+
17+
| 环境 | 说明 |
18+
| --- | --- |
19+
|PC操作系统|Windows|
20+
|编译器|sparc-gaisler-elf-gcc|
21+
|构建工具|scons|
22+
1) 下载源码
23+
```
24+
git clone https://github.com/RT-Thread/rt-thread.git
25+
```
26+
2) 下载编译工具和调试工具
27+
```
28+
下载对应的编译工具链 https://www.gaisler.com/index.php/downloads/compilers
29+
下载对应的调试工具 https://www.gaisler.com/index.php/downloads/debug-tools
30+
```
31+
3) 通过env配置工程
32+
```
33+
打开env工具,并切换到bsp/bm3803目录
34+
输入menuconfig进行配置并保存
35+
```
36+
4) 编译
37+
```
38+
配置rtconfig.py中的EXEC_PATH为对应的编译工具目录
39+
输入scons进行编译
40+
```
41+
如果编译正确无误,会产生rtthread-bm3803.elf、rtthread.bin文件。可以使用rtthread-bm3803.elf进行调试。
42+
43+
5) 调试
44+
```
45+
调试环境配置请参考 https://www.gaisler.com/eclipse/qsg_sw_ide.pdf
46+
```

bsp/bm3803/SConscript

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# for module compiling
2+
import os
3+
Import('RTT_ROOT')
4+
5+
cwd = str(Dir('#'))
6+
objs = []
7+
list = os.listdir(cwd)
8+
9+
for d in list:
10+
path = os.path.join(cwd, d)
11+
if os.path.isfile(os.path.join(path, 'SConscript')):
12+
objs = objs + SConscript(os.path.join(d, 'SConscript'))
13+
14+
Return('objs')

bsp/bm3803/SConstruct

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import os
2+
import sys
3+
import rtconfig
4+
5+
if os.getenv('RTT_ROOT'):
6+
RTT_ROOT = os.getenv('RTT_ROOT')
7+
else:
8+
RTT_ROOT = os.path.normpath(os.getcwd() + '/../..')
9+
10+
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
11+
from building import *
12+
13+
TARGET = 'rtthread-bm3803.' + rtconfig.TARGET_EXT
14+
15+
DefaultEnvironment(tools=[])
16+
env = Environment(tools = ['mingw'],
17+
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
18+
CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
19+
CXX= rtconfig.CXX, CXXFLAGS = rtconfig.CFLAGS,
20+
AR = rtconfig.AR, ARFLAGS = '-rc',
21+
LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
22+
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
23+
24+
Export('RTT_ROOT')
25+
Export('rtconfig')
26+
27+
# prepare building environment
28+
objs = PrepareBuilding(env, RTT_ROOT)
29+
30+
# make a building
31+
DoBuilding(TARGET, objs)

bsp/bm3803/applications/SConscript

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Import('RTT_ROOT')
2+
Import('rtconfig')
3+
from building import *
4+
5+
cwd = os.path.join(str(Dir('#')), 'applications')
6+
src = Glob('*.c')
7+
CPPPATH = [cwd, str(Dir('#'))]
8+
9+
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)
10+
11+
Return('group')

bsp/bm3803/applications/board.c

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright (c) 2020, Shenzhen Academy of Aerospace Technology
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2020-10-16 Dystopia the first version
9+
*/
10+
11+
#include <rthw.h>
12+
#include <rtthread.h>
13+
#include <finsh.h>
14+
15+
#include "board.h"
16+
#include <interrupt.h>
17+
18+
extern int __bss_end;
19+
20+
static void rt_hw_timer_isr(int vector, void *param)
21+
{
22+
rt_tick_increase();
23+
/* timer interrupt cleared by hardware */
24+
}
25+
26+
int rt_hw_timer_init(void)
27+
{
28+
unsigned int counter = 1000000 / RT_TICK_PER_SECOND;
29+
volatile struct lregs *regs = (struct lregs *)PREGS;
30+
31+
regs->scalercnt = CPU_FREQ / 1000000 - 1;
32+
regs->scalerload = CPU_FREQ / 1000000 - 1;
33+
regs->timercnt2 = counter - 1;
34+
regs->timerload2 = counter - 1;
35+
36+
rt_hw_interrupt_install(TIMER2_TT, rt_hw_timer_isr, RT_NULL, "tick");
37+
rt_hw_interrupt_umask(TIMER2_TT);
38+
39+
/* start timer */
40+
regs->timerctrl2 = 0x7;
41+
42+
return 0;
43+
}
44+
INIT_BOARD_EXPORT(rt_hw_timer_init);
45+
46+
/**
47+
* This function will initialize beaglebone board
48+
*/
49+
void rt_hw_board_init(void)
50+
{
51+
rt_system_heap_init((void *)&__bss_end, (unsigned char *)&__bss_end + 0x01000000);
52+
rt_components_board_init();
53+
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
54+
}

bsp/bm3803/applications/board.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright (c) 2020, Shenzhen Academy of Aerospace Technology
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2020-10-16 Dystopia the first version
9+
*/
10+
11+
#ifndef __BOARD_H__
12+
#define __BOARD_H__
13+
14+
#include <bm3803.h>
15+
16+
#define CPU_FREQ 90000000
17+
18+
void rt_hw_board_init(void);
19+
20+
#endif

bsp/bm3803/applications/main.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright (c) 2020, Shenzhen Academy of Aerospace Technology
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2020-10-16 Dystopia the first version
9+
*/
10+
11+
#include <stdint.h>
12+
#include <stdio.h>
13+
#include <stdlib.h>
14+
15+
int main(void)
16+
{
17+
printf("hello rt-thread\n");
18+
return 0;
19+
}

bsp/bm3803/bm3803.lds

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
OUTPUT_ARCH(sparc)
2+
SECTIONS
3+
{
4+
. = 0x40000000;
5+
6+
__text_start = .;
7+
.text :
8+
{
9+
*(.vectors)
10+
*(.text)
11+
*(.text.*)
12+
13+
/* section information for finsh shell */
14+
. = ALIGN(4);
15+
__fsymtab_start = .;
16+
KEEP(*(FSymTab))
17+
__fsymtab_end = .;
18+
. = ALIGN(4);
19+
__vsymtab_start = .;
20+
KEEP(*(VSymTab))
21+
__vsymtab_end = .;
22+
. = ALIGN(4);
23+
24+
/* section information for modules */
25+
. = ALIGN(4);
26+
__rtmsymtab_start = .;
27+
KEEP(*(RTMSymTab))
28+
__rtmsymtab_end = .;
29+
30+
/* section information for initialization */
31+
. = ALIGN(4);
32+
__rt_init_start = .;
33+
KEEP(*(SORT(.rti_fn*)))
34+
__rt_init_end = .;
35+
} =0
36+
__text_end = .;
37+
38+
__rodata_start = .;
39+
.rodata : { *(.rodata) *(.rodata.*) }
40+
__rodata_end = .;
41+
42+
. = ALIGN(4);
43+
.ctors :
44+
{
45+
PROVIDE(__ctors_start__ = .);
46+
KEEP(*(SORT(.ctors.*)))
47+
KEEP(*(.ctors))
48+
PROVIDE(__ctors_end__ = .);
49+
}
50+
51+
.dtors :
52+
{
53+
PROVIDE(__dtors_start__ = .);
54+
KEEP(*(SORT(.dtors.*)))
55+
KEEP(*(.dtors))
56+
PROVIDE(__dtors_end__ = .);
57+
}
58+
59+
. = ALIGN(8);
60+
__data_start = .;
61+
.data :
62+
{
63+
*(.data)
64+
*(.data.*)
65+
}
66+
__data_end = .;
67+
68+
. = ALIGN(8);
69+
__bss_start = .;
70+
.bss :
71+
{
72+
*(.bss)
73+
*(.bss.*)
74+
*(COMMON)
75+
. = ALIGN(4);
76+
}
77+
. = ALIGN(4);
78+
__bss_end = .;
79+
80+
/* Stabs debugging sections. */
81+
.stab 0 : { *(.stab) }
82+
.stabstr 0 : { *(.stabstr) }
83+
.stab.excl 0 : { *(.stab.excl) }
84+
.stab.exclstr 0 : { *(.stab.exclstr) }
85+
.stab.index 0 : { *(.stab.index) }
86+
.stab.indexstr 0 : { *(.stab.indexstr) }
87+
.comment 0 : { *(.comment) }
88+
89+
_end = .;
90+
}

0 commit comments

Comments
 (0)