diff --git a/bsp/qemu-virt64-riscv/.config b/bsp/qemu-virt64-riscv/.config index debc4ca311a..67de44eef6e 100644 --- a/bsp/qemu-virt64-riscv/.config +++ b/bsp/qemu-virt64-riscv/.config @@ -272,7 +272,6 @@ CONFIG_RT_DFS_ELM_MUTEX_TIMEOUT=3000 CONFIG_RT_USING_DFS_DEVFS=y CONFIG_RT_USING_DFS_ROMFS=y -# CONFIG_RT_USING_DFS_ROMFS_USER_ROOT is not set # CONFIG_RT_USING_DFS_CROMFS is not set # CONFIG_RT_USING_DFS_TMPFS is not set # CONFIG_RT_USING_DFS_MQUEUE is not set @@ -1434,7 +1433,6 @@ CONFIG_RT_USING_ADT_REF=y # # RISC-V QEMU virt64 configs # -CONFIG_RISCV_S_MODE=y CONFIG_BSP_USING_VIRTIO=y CONFIG_BSP_USING_VIRTIO_BLK=y CONFIG_BSP_USING_VIRTIO_NET=y diff --git a/bsp/qemu-virt64-riscv/driver/Kconfig b/bsp/qemu-virt64-riscv/driver/Kconfig index 590de38f4ad..ba9a2650e19 100644 --- a/bsp/qemu-virt64-riscv/driver/Kconfig +++ b/bsp/qemu-virt64-riscv/driver/Kconfig @@ -1,9 +1,5 @@ menu "RISC-V QEMU virt64 configs" -config RISCV_S_MODE - bool "RT-Thread run in RISC-V S-Mode(supervisor mode)" - default y - config BSP_USING_VIRTIO bool "Using VirtIO" default y diff --git a/bsp/qemu-virt64-riscv/rtconfig.h b/bsp/qemu-virt64-riscv/rtconfig.h index d68cf44446c..221ee5eb9bc 100644 --- a/bsp/qemu-virt64-riscv/rtconfig.h +++ b/bsp/qemu-virt64-riscv/rtconfig.h @@ -519,7 +519,6 @@ /* RISC-V QEMU virt64 configs */ -#define RISCV_S_MODE #define BSP_USING_VIRTIO #define BSP_USING_VIRTIO_BLK #define BSP_USING_VIRTIO_NET diff --git a/libcpu/risc-v/common64/README.md b/libcpu/risc-v/common64/README.md index 1d027216f19..5e7ea4bf92e 100644 --- a/libcpu/risc-v/common64/README.md +++ b/libcpu/risc-v/common64/README.md @@ -33,7 +33,7 @@ | 选项 | 默认值 | 说明 | | --------------- | --- | ---------------------------------------------------------------------------------------------------- | -| RISCV_S_MODE | 打开 | 系统启动后是否运行在S态,关闭时系统将运行在M态;目前系统存在bug尚不可直接运行在M态,故此开关必须打开 | +| RISCV_VIRT64_S_MODE | 打开 | 系统启动后是否运行在S态,关闭时系统将运行在M态;目前系统存在bug尚不可直接运行在M态,故此开关必须打开 | | RT_USING_SMART | 关闭 | 是否开启RTThread SMART版本,开启后系统运行在S+U态,且会开启MMU页表(satp);关闭时系统仅运行在S态,MMU关闭(satp为bare translation) | | ARCH_USING_ASID | 关闭 | MMU是否支持asid | diff --git a/libcpu/risc-v/virt64/plic.c b/libcpu/risc-v/virt64/plic.c index f222146f34d..8aab8b1292b 100644 --- a/libcpu/risc-v/virt64/plic.c +++ b/libcpu/risc-v/virt64/plic.c @@ -52,7 +52,7 @@ void plic_irq_enable(int irq) { int hart = __raw_hartid(); *(uint32_t *)PLIC_ENABLE(hart) = ((*(uint32_t *)PLIC_ENABLE(hart)) | (1 << irq)); -#ifdef RISCV_S_MODE +#ifdef RISCV_VIRT64_S_MODE set_csr(sie, read_csr(sie) | MIP_SEIP); #else set_csr(mie, read_csr(mie) | MIP_MEIP); diff --git a/libcpu/risc-v/virt64/plic.h b/libcpu/risc-v/virt64/plic.h index 314210c66b5..a13b6d96222 100644 --- a/libcpu/risc-v/virt64/plic.h +++ b/libcpu/risc-v/virt64/plic.h @@ -30,7 +30,10 @@ extern size_t plic_base; #define PLIC_ENABLE_STRIDE 0x80 #define PLIC_CONTEXT_STRIDE 0x1000 -#ifndef RISCV_S_MODE +/* RT-Thread runs in S-mode on virt64 by default */ +#define RISCV_VIRT64_S_MODE + +#ifndef RISCV_VIRT64_S_MODE #define PLIC_MENABLE_OFFSET (0x2000) #define PLIC_MTHRESHOLD_OFFSET (0x200000) #define PLIC_MCLAIM_OFFSET (0x200004) diff --git a/tools/building.py b/tools/building.py index 5c8e3941984..c64c393ba00 100644 --- a/tools/building.py +++ b/tools/building.py @@ -210,15 +210,16 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [ envm = utils.ImportModule('env_utility') # from env import GetSDKPath exec_path = envm.GetSDKPath(rtconfig.CC) - if 'gcc' in rtconfig.CC: - exec_path = os.path.join(exec_path, 'bin') - - if os.path.exists(exec_path): - Env['log'].debug('set CC to ' + exec_path) - rtconfig.EXEC_PATH = exec_path - os.environ['RTT_EXEC_PATH'] = exec_path - else: - Env['log'].debug('No Toolchain found in path(%s).' % exec_path) + if exec_path != None: + if 'gcc' in rtconfig.CC: + exec_path = os.path.join(exec_path, 'bin') + + if os.path.exists(exec_path): + Env['log'].debug('set CC to ' + exec_path) + rtconfig.EXEC_PATH = exec_path + os.environ['RTT_EXEC_PATH'] = exec_path + else: + Env['log'].debug('No Toolchain found in path(%s).' % exec_path) except Exception as e: # detect failed, ignore Env['log'].debug(e) diff --git a/tools/env_utility.py b/tools/env_utility.py index 608ef4fa156..d950d077334 100644 --- a/tools/env_utility.py +++ b/tools/env_utility.py @@ -55,6 +55,15 @@ def GetSDKPath(name): sdk_pkgs = GetSDKPackagePath() if sdk_pkgs: + # read env/tools/scripts/sdk_cfg.json for curstomized SDK path + if os.path.exists(os.path.join(sdk_pkgs, '..', 'sdk_cfg.json')): + with open(os.path.join(sdk_pkgs, '..', 'sdk_cfg.json'), 'r', encoding='utf-8') as f: + sdk_cfg = json.load(f) + for item in sdk_cfg: + if item['name'] == name: + sdk = os.path.join(sdk_pkgs, item['path']) + return sdk + # read packages.json under env/tools/scripts/packages with open(os.path.join(sdk_pkgs, 'pkgs.json'), 'r', encoding='utf-8') as f: # packages_json = f.read() @@ -68,7 +77,8 @@ def GetSDKPath(name): package = json.load(f) if package['name'] == name: - return os.path.join(sdk_pkgs, package['name'] + '-' + item['ver']) + sdk = os.path.join(sdk_pkgs, package['name'] + '-' + item['ver']) + return sdk # not found named package return None