Skip to content
Merged
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
6 changes: 3 additions & 3 deletions .github/workflows/utest_auto_run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ jobs:

- { UTEST: "RISCV", RTT_BSP: "bsp/qemu-virt64-riscv", QEMU_ARCH: "riscv64", QEMU_MACHINE: "virt", SD_FILE: "None", KERNEL: "standard", "SMP_RUN":"" }
- { UTEST: "RISCV-rtsmart", RTT_BSP: "bsp/qemu-virt64-riscv", QEMU_ARCH: "riscv64", QEMU_MACHINE: "virt", SD_FILE: "None", KERNEL: "rtsmart", "SMP_RUN":"" }
# - { UTEST: "RISCV-smp", RTT_BSP: "bsp/qemu-virt64-riscv", QEMU_ARCH: "riscv64", QEMU_MACHINE: "virt", SD_FILE: "None", KERNEL: "standard", "SMP_RUN":"smp" }
- { UTEST: "XUANTIE-rtsmart", RTT_BSP: "bsp/xuantie/virt64/c906", QEMU_ARCH: "riscv64", QEMU_MACHINE: "virt", SD_FILE: "sd.bin", KERNEL: "rtsmart", "SMP_RUN":"" }
- { UTEST: "RISCV-smp", RTT_BSP: "bsp/qemu-virt64-riscv", QEMU_ARCH: "riscv64", QEMU_MACHINE: "virt", SD_FILE: "None", KERNEL: "standard", "SMP_RUN":"smp" }
- { UTEST: "XUANTIE-rtsmart", RTT_BSP: "bsp/xuantie/virt64/c906", QEMU_ARCH: "riscv64", QEMU_MACHINE: "virt", SD_FILE: "sd.bin", KERNEL: "rtsmart", "SMP_RUN":"" }

- { UTEST: "AARCH64", RTT_BSP: "bsp/qemu-virt64-aarch64", QEMU_ARCH: "aarch64", QEMU_MACHINE: "virt", SD_FILE: "sd.bin", KERNEL: "standard", "SMP_RUN":"" }
- { UTEST: "AARCH64-rtsmart", RTT_BSP: "bsp/qemu-virt64-aarch64", QEMU_ARCH: "aarch64", QEMU_MACHINE: "virt", SD_FILE: "sd.bin", KERNEL: "rtsmart", "SMP_RUN":"" }
# - { UTEST: "AARCH64-smp", RTT_BSP: "bsp/qemu-virt64-aarch64", QEMU_ARCH: "aarch64", QEMU_MACHINE: "virt", SD_FILE: "sd.bin", KERNEL: "standard", "SMP_RUN":"smp" }
- { UTEST: "AARCH64-smp", RTT_BSP: "bsp/qemu-virt64-aarch64", QEMU_ARCH: "aarch64", QEMU_MACHINE: "virt", SD_FILE: "sd.bin", KERNEL: "standard", "SMP_RUN":"smp" }

config_file:
- "default.cfg"
Expand Down
20 changes: 20 additions & 0 deletions bsp/qemu-virt64-riscv/SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,25 @@ if GetDepend('__STACKSIZE__'): stack_size = GetDepend('__STACKSIZE__')
stack_lds.write('__STACKSIZE__ = %d;\n' % stack_size)
stack_lds.close()

# Obtain the number of harts from rtconfig.h and write
# it into link_cpus.lds for the linker script
try:
with open('rtconfig.h', 'r') as f:
rtconfig_content = f.readlines()
except FileNotFoundError:
cpus_nr = 1
else:
cpus_nr = 1 # default value
for line in rtconfig_content:
line = line.strip()
if line.startswith('#define') and 'RT_CPUS_NR' in line:
parts = line.split()
if len(parts) >= 3 and parts[2].isdigit():
cpus_nr = int(parts[2])
break

with open('link_cpus.lds', 'w') as cpus_lds:
cpus_lds.write(f'RT_CPUS_NR = {cpus_nr};\n')

# make a building
DoBuilding(TARGET, objs)
9 changes: 9 additions & 0 deletions bsp/qemu-virt64-riscv/driver/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
#include "plic.h"
#include "stack.h"

#ifdef RT_USING_SMP
#include "interrupt.h"
#endif /* RT_USING_SMP */

#ifdef RT_USING_SMART
#include "riscv_mmu.h"
#include "mmu.h"
Expand Down Expand Up @@ -89,6 +93,11 @@ void rt_hw_board_init(void)

rt_hw_tick_init();

#ifdef RT_USING_SMP
/* ipi init */
rt_hw_ipi_init();
#endif /* RT_USING_SMP */

#ifdef RT_USING_COMPONENTS_INIT
rt_components_board_init();
#endif
Expand Down
2 changes: 1 addition & 1 deletion bsp/qemu-virt64-riscv/driver/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extern unsigned int __bss_end;
#define RT_HW_HEAP_BEGIN ((void *)&__bss_end)
#define RT_HW_HEAP_END ((void *)(RT_HW_HEAP_BEGIN + 64 * 1024 * 1024))
#define RT_HW_PAGE_START RT_HW_HEAP_END
#define RT_HW_PAGE_END ((void *)(KERNEL_VADDR_START + (256 * 1024 * 1024 - VIRT64_SBI_MEMSZ)))
#define RT_HW_PAGE_END ((void *)(KERNEL_VADDR_START + (128 * 1024 * 1024 - VIRT64_SBI_MEMSZ)))

void rt_hw_board_init(void);
void rt_init_user_mem(struct rt_thread *thread, const char *name,
Expand Down
28 changes: 22 additions & 6 deletions bsp/qemu-virt64-riscv/link.lds
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/

INCLUDE "link_stacksize.lds"
INCLUDE "link_cpus.lds"

OUTPUT_ARCH( "riscv" )

Expand Down Expand Up @@ -121,12 +122,9 @@ SECTIONS
{
. = ALIGN(64);
__stack_start__ = .;

. += __STACKSIZE__;
__stack_cpu0 = .;

. += __STACKSIZE__;
__stack_cpu1 = .;
/* Dynamically allocate stack areas according to RT_CPUS_NR */
. += (__STACKSIZE__ * RT_CPUS_NR);
__stack_end__ = .;
} > SRAM

.sbss :
Expand All @@ -138,6 +136,24 @@ SECTIONS
*(.scommon)
} > SRAM

.percpu (NOLOAD) :
{
/* 2MB Align for MMU early map */
. = ALIGN(0x200000);
PROVIDE(__percpu_start = .);

*(.percpu)

/* 2MB Align for MMU early map */
. = ALIGN(0x200000);

PROVIDE(__percpu_end = .);

/* Clone the area */
. = __percpu_end + (__percpu_end - __percpu_start) * (RT_CPUS_NR - 1);
PROVIDE(__percpu_real_end = .);
} > SRAM

.bss :
{
*(.bss)
Expand Down
1 change: 1 addition & 0 deletions bsp/qemu-virt64-riscv/link_cpus.lds
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
RT_CPUS_NR = 8;
28 changes: 22 additions & 6 deletions bsp/qemu-virt64-riscv/link_smart.lds
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/

INCLUDE "link_stacksize.lds"
INCLUDE "link_cpus.lds"

OUTPUT_ARCH( "riscv" )

Expand Down Expand Up @@ -122,12 +123,9 @@ SECTIONS
{
. = ALIGN(64);
__stack_start__ = .;

. += __STACKSIZE__;
__stack_cpu0 = .;

. += __STACKSIZE__;
__stack_cpu1 = .;
/* Dynamically allocate stack areas according to RT_CPUS_NR */
. += (__STACKSIZE__ * RT_CPUS_NR);
__stack_end__ = .;
} > SRAM

.sbss :
Expand All @@ -139,6 +137,24 @@ SECTIONS
*(.scommon)
} > SRAM

.percpu (NOLOAD) :
{
/* 2MB Align for MMU early map */
. = ALIGN(0x200000);
PROVIDE(__percpu_start = .);

*(.percpu)

/* 2MB Align for MMU early map */
. = ALIGN(0x200000);

PROVIDE(__percpu_end = .);

/* Clone the area */
. = __percpu_end + (__percpu_end - __percpu_start) * (RT_CPUS_NR - 1);
PROVIDE(__percpu_real_end = .);
} > SRAM

.bss :
{
*(.bss)
Expand Down
16 changes: 14 additions & 2 deletions bsp/qemu-virt64-riscv/qemu-dbg.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
qemu-system-riscv64 -nographic -machine virt -m 256M -kernel rtthread.bin -s -S \
QEMU_CMD="qemu-system-riscv64 -nographic -machine virt -m 256M -kernel rtthread.bin -s -S"

if grep -q "#define RT_USING_SMP" ./rtconfig.h 2>/dev/null; then
hart_num=$(grep "RT_CPUS_NR = [0-9]*;" ./link_cpus.lds | awk -F'[=;]' '{gsub(/ /, "", $2); print $2}')
if [ -z "$hart_num" ]; then
hart_num=1
fi
QEMU_CMD="$QEMU_CMD -smp $hart_num"
fi

QEMU_CMD="$QEMU_CMD \
-drive if=none,file=sd.bin,format=raw,id=blk0 -device virtio-blk-device,drive=blk0,bus=virtio-mmio-bus.0 \
-netdev user,id=tap0 -device virtio-net-device,netdev=tap0,bus=virtio-mmio-bus.1 \
-device virtio-serial-device -chardev socket,host=127.0.0.1,port=4321,server=on,wait=off,telnet=on,id=console0 -device virtserialport,chardev=console0
-device virtio-serial-device -chardev socket,host=127.0.0.1,port=4321,server=on,wait=off,telnet=on,id=console0 -device virtserialport,chardev=console0"

eval $QEMU_CMD
17 changes: 15 additions & 2 deletions bsp/qemu-virt64-riscv/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,20 @@ if [ ! -f $path_image ]; then
exit
fi

qemu-system-riscv64 -nographic -machine virt -m 256M -kernel rtthread.bin \
QEMU_CMD="qemu-system-riscv64 -nographic -machine virt -m 256M -kernel rtthread.bin"

if grep -q "#define RT_USING_SMP" ./rtconfig.h 2>/dev/null; then
hart_num=$(grep "RT_CPUS_NR = [0-9]*;" ./link_cpus.lds 2>/dev/null | awk -F'[=;]' '{gsub(/ /, "", $2); print $2}')
if [ -z "$hart_num" ] || [ "$hart_num" -lt 1 ]; then
echo "Warning: Invalid or missing RT_CPUS_NR, defaulting to 1"
hart_num=1
fi
QEMU_CMD="$QEMU_CMD -smp $hart_num"
fi

QEMU_CMD="$QEMU_CMD \
-drive if=none,file=$path_image,format=raw,id=blk0 -device virtio-blk-device,drive=blk0,bus=virtio-mmio-bus.0 \
-netdev user,id=tap0 -device virtio-net-device,netdev=tap0,bus=virtio-mmio-bus.1 \
-device virtio-serial-device -chardev socket,host=127.0.0.1,port=4321,server=on,wait=off,telnet=on,id=console0 -device virtserialport,chardev=console0
-device virtio-serial-device -chardev socket,host=127.0.0.1,port=4321,server=on,wait=off,telnet=on,id=console0 -device virtserialport,chardev=console0"

eval $QEMU_CMD
6 changes: 6 additions & 0 deletions components/dfs/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ endif
default y

if RT_USING_DFS_V1
config RT_USING_DFS_9PFS
bool "Using Plan 9 remote filesystem"
select RT_USING_ADT_BITMAP
depends on RT_USING_MEMHEAP
default n

config RT_USING_DFS_ISO9660
bool "Using ISO9660 filesystem"
depends on RT_USING_MEMHEAP
Expand Down
11 changes: 11 additions & 0 deletions components/dfs/dfs_v1/filesystems/9pfs/SConscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# RT-Thread building script for component

from building import *

cwd = GetCurrentDir()
src = Glob('*.c')
CPPPATH = [cwd]

group = DefineGroup('Filesystem', src, depend = ['RT_USING_DFS', 'RT_USING_DFS_9PFS'], CPPPATH = CPPPATH)

Return('group')
Loading