Skip to content

Commit 7f330c7

Browse files
GFWisshitDystopia
authored andcommitted
Add support for architecture sparc-v8 and soc bm3803.
1 parent 3ff0c07 commit 7f330c7

File tree

26 files changed

+2429
-0
lines changed

26 files changed

+2429
-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/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: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* File : board.c
3+
* This file is part of RT-Thread RTOS
4+
* COPYRIGHT (C) 2020, Shenzhen Academy of Aerospace Technology
5+
*
6+
* The license and distribution terms for this file may be
7+
* found in the file LICENSE in this distribution or at
8+
* http://www.rt-thread.org/license/LICENSE
9+
*
10+
* Change Logs:
11+
* Date Author Notes
12+
* 2020-10-16 Dystopia the first version
13+
*/
14+
15+
#include <rthw.h>
16+
#include <rtthread.h>
17+
#include <finsh.h>
18+
19+
#include "board.h"
20+
#include <interrupt.h>
21+
22+
extern int __bss_end;
23+
24+
static void rt_hw_timer_isr(int vector, void* param)
25+
{
26+
rt_tick_increase();
27+
/* timer interrupt cleared by hardware */
28+
}
29+
30+
int rt_hw_timer_init(void)
31+
{
32+
unsigned int counter = 1000000 / RT_TICK_PER_SECOND;
33+
volatile struct lregs *regs = (struct lregs*)PREGS;
34+
35+
regs->scalercnt = CPU_FREQ / 1000000 - 1;
36+
regs->scalerload = CPU_FREQ / 1000000 - 1;
37+
regs->timercnt2 = counter - 1;
38+
regs->timerload2 = counter - 1;
39+
40+
rt_hw_interrupt_install(TIMER2_TT, rt_hw_timer_isr, RT_NULL, "tick");
41+
rt_hw_interrupt_umask(TIMER2_TT);
42+
43+
/* start timer */
44+
regs->timerctrl2 = 0x7;
45+
46+
return 0;
47+
}
48+
INIT_BOARD_EXPORT(rt_hw_timer_init);
49+
50+
/**
51+
* This function will initialize beaglebone board
52+
*/
53+
void rt_hw_board_init(void)
54+
{
55+
rt_system_heap_init((void*)&__bss_end, (void*)&__bss_end + 0x01000000);
56+
rt_components_board_init();
57+
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
58+
}

bsp/bm3803/applications/board.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* File : board.h
3+
* This file is part of RT-Thread RTOS
4+
* COPYRIGHT (C) 2020, Shenzhen Academy of Aerospace Technology
5+
*
6+
* The license and distribution terms for this file may be
7+
* found in the file LICENSE in this distribution or at
8+
* http://www.rt-thread.org/license/LICENSE
9+
*
10+
* Change Logs:
11+
* Date Author Notes
12+
* 2020-10-16 Dystopia the first version
13+
*/
14+
15+
#ifndef __BOARD_H__
16+
#define __BOARD_H__
17+
18+
#include <bm3803.h>
19+
20+
#define CPU_FREQ 90000000
21+
22+
void rt_hw_board_init(void);
23+
24+
#endif

bsp/bm3803/applications/main.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include <stdint.h>
2+
#include <stdio.h>
3+
#include <stdlib.h>
4+
5+
int main(void)
6+
{
7+
printf("hello rt-thread\n");
8+
return 0;
9+
}

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+
}

bsp/bm3803/drivers/SConscript

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import copy
2+
Import('RTT_ROOT')
3+
Import('rtconfig')
4+
from building import *
5+
6+
cwd = GetCurrentDir()
7+
src = Glob('*.c')
8+
9+
# remove no need file.
10+
if GetDepend('RT_USING_LWIP') == False:
11+
src_need_remove = ['dm9000.c'] # need remove file list.
12+
SrcRemove(src, src_need_remove)
13+
14+
if GetDepend('RT_USING_DFS') == False:
15+
src_need_remove = ['sd.c'] # need remove file list.
16+
SrcRemove(src, src_need_remove)
17+
18+
CPPPATH = [cwd]
19+
20+
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH)
21+
22+
Return('group')

0 commit comments

Comments
 (0)