Skip to content

Commit 0f26ffa

Browse files
committed
add ls2k bsp
1 parent 0f57faa commit 0f26ffa

File tree

23 files changed

+1606
-16
lines changed

23 files changed

+1606
-16
lines changed

bsp/ls2kdev/.config

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

bsp/ls2kdev/Kconfig

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
source "$RTT_DIR/Kconfig"
22+
source "$RTT_DIR/libcpu/mips/common/Kconfig"
23+
source "$PKGS_DIR/Kconfig"
24+
25+
config SOC_LS2K1000
26+
bool
27+
select ARCH_MIPS64
28+
select RT_USING_COMPONENTS_INIT
29+
select RT_USING_USER_MAIN
30+
select RT_USING_DEVICE
31+
default y
32+

bsp/ls2kdev/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
ls2k 板级支持包
2+
3+
4+
---
5+
6+
## 1. 简介
7+
8+
本bsp在龙芯派上运行

bsp/ls2kdev/SConscript

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from building import *
2+
3+
cwd = GetCurrentDir()
4+
objs = []
5+
list = os.listdir(cwd)
6+
7+
for d in list:
8+
path = os.path.join(cwd, d)
9+
if os.path.isfile(os.path.join(path, 'SConscript')):
10+
objs = objs + SConscript(os.path.join(d, 'SConscript'))
11+
12+
Return('objs')

bsp/ls2kdev/SConstruct

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import os
2+
import sys
3+
import rtconfig
4+
5+
from rtconfig import RTT_ROOT
6+
7+
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
8+
from building import *
9+
10+
TARGET = 'rtthread.' + rtconfig.TARGET_EXT
11+
12+
rtconfig.AFLAGS += ' -I' + str(Dir('#'))
13+
14+
DefaultEnvironment(tools=[])
15+
env = Environment(tools = ['mingw'],
16+
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
17+
CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
18+
AR = rtconfig.AR, ARFLAGS = '-rc',
19+
LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
20+
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
21+
22+
Export('RTT_ROOT')
23+
Export('rtconfig')
24+
25+
26+
# prepare building environment
27+
objs = PrepareBuilding(env, RTT_ROOT)
28+
29+
rtconfig.LFLAGS += " -Ttext 0xffffffff80200000"
30+
env.Replace(LINKFLAGS = rtconfig.LFLAGS)
31+
32+
if GetDepend('RT_USING_FPU'):
33+
env['CCFLAGS'] = env['CCFLAGS'].replace('-msoft-float', '-mhard-float')
34+
env['ASFLAGS'] = env['ASFLAGS'].replace('-msoft-float', '-mhard-float')
35+
env['CXXFLAGS'] = env['CXXFLAGS'].replace('-msoft-float', '-mhard-float')
36+
env['LINKFLAGS'] = env['LINKFLAGS'].replace('-msoft-float', '-mhard-float')
37+
38+
# make a building
39+
DoBuilding(TARGET, objs)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from building import *
2+
3+
cwd = GetCurrentDir()
4+
src = Glob('*.c')
5+
6+
group = DefineGroup('Applications', src, depend = [''])
7+
8+
Return('group')

bsp/ls2kdev/applications/main.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright (c) 2006-2020, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2020-04-05 bigmagic first version
9+
*/
10+
11+
#include <rtthread.h>
12+
13+
int main(int argc, char** argv)
14+
{
15+
rt_kprintf("ls2k1000:hello rtthread!\n");
16+
return 0;
17+
}

bsp/ls2kdev/drivers/SConscript

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from building import *
2+
3+
cwd = GetCurrentDir()
4+
src = Glob('*.c') + Glob('*.cpp') + Glob('*_gcc.S')
5+
6+
CPPPATH = [cwd]
7+
8+
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH)
9+
10+
Return('group')

bsp/ls2kdev/drivers/board.c

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/*
2+
* Copyright (c) 2006-2020, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2020-04-05 bigmagic Initial version
9+
*/
10+
11+
#include <rtthread.h>
12+
#include <rthw.h>
13+
14+
#include "mips_regs.h"
15+
#include "exception.h"
16+
#include "drv_uart.h"
17+
#include "board.h"
18+
/**
19+
* this function will reset CPU
20+
*
21+
*/
22+
void rt_hw_cpu_reset(void)
23+
{
24+
rt_kprintf("reboot system...\n");
25+
while (1);
26+
}
27+
28+
/**
29+
* this function will shutdown CPU
30+
*
31+
*/
32+
void rt_hw_cpu_shutdown(void)
33+
{
34+
rt_kprintf("shutdown...\n");
35+
36+
while (1);
37+
}
38+
39+
40+
/**
41+
* This is the timer interrupt service routine.
42+
*/
43+
void rt_hw_timer_handler(void)
44+
{
45+
unsigned int count;
46+
47+
count = read_c0_compare();
48+
write_c0_compare(count);
49+
write_c0_count(0);
50+
/* increase a OS tick */
51+
rt_tick_increase();
52+
}
53+
54+
/**
55+
* This function will initial OS timer
56+
*/
57+
void rt_hw_timer_init(void)
58+
{
59+
write_c0_compare(CPU_HZ/2/RT_TICK_PER_SECOND);
60+
write_c0_count(0);
61+
mips_unmask_cpu_irq(7);
62+
}
63+
64+
/**
65+
* Board level initialization
66+
*/
67+
void rt_hw_board_init(void)
68+
{
69+
rt_hw_exception_init();
70+
/* init hardware interrupt */
71+
rt_hw_interrupt_init();
72+
73+
#ifdef RT_USING_FPU
74+
/* init hardware fpu */
75+
rt_hw_fpu_init();
76+
#endif
77+
78+
#ifdef RT_USING_SERIAL
79+
/* init hardware UART device */
80+
rt_hw_uart_init();
81+
/* set console device */
82+
rt_console_set_device("uart");
83+
#endif
84+
85+
#ifdef RT_USING_HEAP
86+
rt_system_heap_init((void*)RT_HW_HEAP_BEGIN, (void*)RT_HW_HEAP_END);
87+
#endif
88+
89+
/* init operating system timer */
90+
rt_hw_timer_init();
91+
92+
93+
#ifdef RT_USING_COMPONENTS_INIT
94+
rt_components_board_init();
95+
#endif
96+
97+
rt_kprintf("Current SR: 0x%08x\n", read_c0_status());
98+
99+
}

bsp/ls2kdev/drivers/board.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright (c) 2006-2020, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2020-04-05 bigmagic the first version
9+
*/
10+
11+
#ifndef BOARD_H__
12+
#define BOARD_H__
13+
14+
#include <stdint.h>
15+
16+
extern unsigned char __bss_end;
17+
18+
#define CPU_HZ (100 * 1000 * 1000)
19+
#define RT_HW_HEAP_BEGIN (void*)&__bss_end
20+
#define RT_HW_HEAP_END (void*)(RT_HW_HEAP_BEGIN + 64 * 1024 * 1024)
21+
22+
void rt_hw_board_init(void);
23+
24+
#endif

0 commit comments

Comments
 (0)