Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
217 changes: 183 additions & 34 deletions bsp/xuantie/xiaohui/c908/.config

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions bsp/xuantie/xiaohui/c908/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,16 @@ PKGS_DIR := packages
select ARCH_RISCV64
select RT_USING_COMPONENTS_INIT
select RT_USING_USER_MAIN
select ARCH_MM_MMU
select RT_USING_CACHE
select ARCH_USING_BSP_SBI
select ARCH_REMAP_KERNEL if RT_USING_SMART
default y

config __STACKSIZE__
int "stack size for interrupt"
default 65536

menu "CPU Architecture Features"

menuconfig ENABLE_FPU
Expand Down
66 changes: 35 additions & 31 deletions bsp/xuantie/xiaohui/c908/SConstruct
Original file line number Diff line number Diff line change
@@ -1,54 +1,58 @@
import os
import sys
import rtconfig
from SCons.Script import *
import platform
import subprocess

if os.getenv('RTT_ROOT'):
RTT_ROOT = os.getenv('RTT_ROOT')
else:
RTT_ROOT = os.path.normpath(os.getcwd() + '/../../../..')
from rtconfig import RTT_ROOT
import sys

sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
def generate_ldscript(input, output):
if not os.path.exists(input):
print('Error: file', input, 'not found')
return

if os.path.exists(output):
os.remove(output)

if rtconfig.PLATFORM == 'gcc':

gcc_cmd = os.path.join(rtconfig.EXEC_PATH, rtconfig.CC)

# gcc -E -P -x c $input -o $output
if (platform.system() == 'Windows'):
child = subprocess.Popen([gcc_cmd, '-E', '-P', '-x', 'c', input, '-o', output], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
else:
child = subprocess.Popen(gcc_cmd + f' -E -P -x c {input} -o {output}', stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)

child.communicate()

print(output, 'is generated from', input)

try:
from building import *
except:
print('Cannot found RT-Thread root directory, please check RTT_ROOT')
print(RTT_ROOT)
exit(-1)
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, CFLAGS = rtconfig.CFLAGS,
AR = rtconfig.AR, ARFLAGS = '-rc',
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')

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'
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu = False)

SDK_LIB = libraries_path_prefix
Export('SDK_LIB')

# prepare building environment
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=True)

bsp_vdir = 'build'
library_vdir = 'build/libraries'

# common include drivers
objs.extend(SConscript(os.path.join(libraries_path_prefix, 'SConscript'), variant_dir=library_vdir, duplicate=0))
generate_ldscript('link.lds', 'link.lds.generated')

# make a building
DoBuilding(TARGET, objs)

Clean(TARGET, 'link.lds.generated')
Clean(TARGET, 'build')
9 changes: 8 additions & 1 deletion bsp/xuantie/xiaohui/c908/applications/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ import os

cwd = GetCurrentDir()
CPPPATH = [cwd]
src = ['main.c']
src = ['main.c', 'mnt.c', 'mmu_demo.c']

# romfs_data.c is generated by tools/mkromfs.py.
# Fall back to the placeholder image when it is absent.
if os.path.exists(os.path.join(cwd, 'romfs_data.c')):
src += ['romfs_data.c']
else:
src += ['romfs.c']

group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)

Expand Down
18 changes: 6 additions & 12 deletions bsp/xuantie/xiaohui/c908/applications/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,11 @@
* 2025-04-21 Wangshun first version
*/

#include <rtthread.h>
#include <rtdevice.h>
#include "pre_main.h"
#include <rtthread.h>

int main(void)
{
rt_kprintf("Hello RT-Thread!\r\n");
#ifdef RT_USING_SMP
extern void smp_example(void);
smp_example();
#endif
return 0;
}
int main(void)
{
rt_kprintf("Hello RT-Thread!\r\n");
return 0;
}

Loading