36 Commits

Author SHA1 Message Date
7cc6e31688 add entry_threadx.s 2025-11-27 15:41:56 +01:00
dd071a3d30 updates bsp and beautifies test_fw.c 2025-11-21 17:43:36 +01:00
109cc2a7ad updates bsp 2025-11-21 14:46:40 +01:00
89e4d58c9e complete IRQ setup 2025-11-21 12:00:19 +01:00
2d2a64aa7a updates BSP 2025-11-21 11:26:46 +01:00
f8fa382b62 add test_fw 2025-11-14 15:24:08 +01:00
2e7ef7285e fixes dhrystone compile options comment 2025-09-13 15:25:11 +02:00
dbb68b5fb1 fixes dhrystone compile options 2025-09-13 15:23:52 +02:00
df513d4465 fixes missing dhrystone link option 2025-09-12 22:34:09 +02:00
00ecea2bd6 fixes BSP location path 2025-09-12 08:35:43 +02:00
c068d6dbd3 removes build_ in jenkins 2025-07-25 16:08:40 +02:00
578857997e add --isa for 64-bit and removes debug line in jenkins 2025-07-25 16:05:03 +02:00
56081dcb6f adds hello running on ISS in jenkins 2025-07-25 15:46:25 +02:00
b68c2226d9 corrects output path of generate_iss in jenkins 2025-07-25 15:26:53 +02:00
925e312608 adds TGC-ISS prefix in jenkins 2025-07-25 14:15:10 +02:00
74275ddab4 enables ISS build in jenkins 2025-07-25 13:45:21 +02:00
0dafde8a4c corrects typo of anyOf in jenkins 2025-07-25 12:32:20 +02:00
a5cf27744a hides 64-bit fw compilation for moonlight/tgc_vp and disables it in jenkin pipeline 2025-07-25 12:21:02 +02:00
f46a211a8d adds fw-common-clean target 2025-07-15 07:41:03 +02:00
57fff5c09b updates for TGC-ISS in Jenkinfile 2025-07-04 20:06:47 +02:00
e39264632f updates for TGC-ISS in Jenkinfile 2025-07-04 19:57:52 +02:00
630f9993d6 updates for TGC-ISS in Jenkinfile 2025-07-04 19:49:39 +02:00
9249f34038 corrects typo for TGC-ISS repo checkout in Jenkinfile 2025-07-04 19:40:28 +02:00
b14442d722 corrects typo for TGC-ISS repo checkout in Jenkinfile 2025-07-04 19:38:21 +02:00
58e2dcfaf8 adds TGC-ISS repo checkout in Jenkinfile 2025-07-04 19:35:00 +02:00
a7559066f4 updates Jenkinfile 2025-07-04 19:13:27 +02:00
10eb3c88fc updates Jenkinfile 2025-07-04 19:11:45 +02:00
90720804ba updates Jenkinfile 2025-07-04 19:08:21 +02:00
4975a8273c enabled make in jenkinfiles and update bsp 2025-07-04 19:05:34 +02:00
ed4ab31837 updates Jenkinsfile 2025-07-04 10:02:21 +02:00
21391f1f01 updates Jenkinsfile 2025-07-04 09:43:15 +02:00
21f97e9bc3 disables make flow in Jenkins to test cmake flow 2025-07-04 09:09:53 +02:00
d715d50dfb adds cmake_flow in Jenkinsfile 2025-07-04 08:59:01 +02:00
a2cd38fbd5 updates bsp 2025-06-17 19:42:46 +02:00
c7cd0843b8 uses inherits in preset json for benchmarks and corrects typo for 64bit 2025-06-06 14:38:14 +02:00
83b2105c38 corrects type in inherits Preset 2025-06-06 13:54:51 +02:00
11 changed files with 562 additions and 156 deletions

View File

@@ -9,6 +9,15 @@ if(DEFINED LINK_TARGET)
endif()
message(STATUS "Building firmware using ${BOARD} board configuration and isa ${ISA}")
add_custom_target(fw-common ALL
COMMAND make -C hello-world BOARD=${BOARD} ISA=${ISA} ${LNK} && make -C benchmarks/dhrystone BOARD=${BOARD} ISA=${ISA} ${LNK} && make -C benchmarks/coremark BOARD=${BOARD} ISA=${ISA} ${LNK}
COMMAND make -C ${CMAKE_CURRENT_SOURCE_DIR}/hello-world BOARD=${BOARD} ISA=${ISA} ${LNK}
COMMAND make -C ${CMAKE_CURRENT_SOURCE_DIR}/benchmarks/dhrystone BOARD=${BOARD} ISA=${ISA} ${LNK}
COMMAND make -C ${CMAKE_CURRENT_SOURCE_DIR}/benchmarks/coremark BOARD=${BOARD} ISA=${ISA} ${LNK}
USES_TERMINAL
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
add_custom_target(fw-common-clean
COMMAND make -C ${CMAKE_CURRENT_SOURCE_DIR}/hello-world BOARD=${BOARD} ISA=${ISA} ${LNK} clean
COMMAND make -C ${CMAKE_CURRENT_SOURCE_DIR}/benchmarks/dhrystone BOARD=${BOARD} ISA=${ISA} ${LNK} clean
COMMAND make -C ${CMAKE_CURRENT_SOURCE_DIR}/benchmarks/coremark BOARD=${BOARD} ISA=${ISA} ${LNK} clean
USES_TERMINAL
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})

122
Jenkinsfile vendored
View File

@@ -2,7 +2,7 @@ void checkout_project() {
checkout([
$class: 'GitSCM',
branches: [
[name: '*/main']
[name: '*/develop']
],
extensions: [
[$class: 'CleanBeforeCheckout'],
@@ -15,6 +15,24 @@ void checkout_project() {
])
}
void checkout_iss_project(String repoUrl, String branch = 'develop') {
checkout([
$class: 'GitSCM',
branches: [
[name: "*/${branch}"]
],
extensions: [
[$class: 'CleanBeforeCheckout'],
[$class: 'SubmoduleOption', disableSubmodules: false, parentCredentials: true, recursiveSubmodules: true, reference: '', trackingSubmodules: false, shallow: true]
],
submoduleCfg: [],
userRemoteConfigs: [
[credentialsId: 'gitea-jenkins', url: repoUrl]
]
])
}
void checkout_develop() {
dir("bare-metal-bsp") {
withCredentials([usernamePassword(credentialsId: 'gitea-jenkins', usernameVariable: 'GIT_USERNAME', passwordVariable: 'GIT_PASSWORD')]) {
@@ -29,6 +47,14 @@ void make_hello(board) {
sh("make -C hello-world/ clean")
}
void cmake_hello(board,build_type,core_type) {
def flavor ="${board}_${build_type}_${core_type}"
if (core_type=="32")
flavor ="${board}_${build_type}"
sh("cmake -B ${flavor} --preset=${flavor}")
sh("cmake --build ${flavor}")
}
pipeline {
agent { docker {
image 'ubuntu-riscv'
@@ -48,12 +74,13 @@ pipeline {
stage('make rtl') {steps { make_hello("rtl")}}
stage('make ehrenberg') {steps { make_hello("ehrenberg")}}
stage('make tgc_vp') {steps { make_hello("tgc_vp")}}*/
stage('make hello-world') {
matrix {
axes {
axis{
name 'BOARD'
values 'iss', 'hifive1', 'TGCP', 'ehrenberg', 'rtl', 'tgc_vp'
values 'iss', 'moonlight', 'tgc_vp'
}
}
stages {
@@ -72,10 +99,91 @@ pipeline {
}
}
}
}
post {
failure {
sh("make -C hello-world/ clean")
stage('CMAKE flow for hello-world') {
matrix {
axes {
axis{
name 'BOARD'
values 'ISS', 'Moonlight', 'TGC_VP'
}
axis{
name 'BUILD_TYPE'
values 'Debug', 'Release'
}
axis{
name 'CORE_TYPE'
values '32', '64'
}
}
stages {
stage('Force sequential') {
options {
lock("One Board at a time")
}
when{
not {
anyOf {
expression { BOARD == 'Moonlight' && CORE_TYPE =='64'}
expression { BOARD == 'TGC_VP' && CORE_TYPE =='64'}
}
}
}
stages {
stage("CMAKE") {
steps {
dir("hello-world"){
cmake_hello("${BOARD}","${BUILD_TYPE}","${CORE_TYPE}")
}
}
}
}
}
}
}
}
}
stage("Checkout TGC-ISS, TGC-Compliance and TGC-GEN"){
steps {
dir("TGC-ISS"){
sh 'rm -rf * .??* '
checkout_iss_project("https://git.minres.com/TGFS/TGC-ISS.git", "develop")
dir("TGC-COMPLIANCE"){
checkout_iss_project("https://git.minres.com/TGFS/TGC-COMPLIANCE.git", "master")
}
dir("TGC-GEN"){
checkout_iss_project("https://git.minres.com/TGFS/TGC-GEN.git", "develop")
}
}
}
}
stage("Generate cores and build TGC-ISS"){
steps {
sh 'rm -rf *@tmp'
sh '''
for core in RV32GC; do
for backend in interp; do
TGC-ISS/TGC-GEN/scripts/generate_iss.sh -o TGC-ISS/dbt-rise-tgc/ -c $core -b ${backend} TGC-ISS/TGC-GEN/CoreDSL/${core}.core_desc
done
done
for core in RV64GC; do
for backend in interp; do
TGC-ISS/TGC-GEN/scripts/generate_iss.sh -o TGC-ISS/dbt-rise-tgc/ -c $core -b ${backend} TGC-ISS/TGC-GEN/CoreDSL/${core}.core_desc
done
done
'''
sh 'conan profile detect --force'
sh 'rm -rf TGC-ISS/build'
sh 'cmake -S TGC-ISS/. -B TGC-ISS/build --preset Release -DWITH_ASMJIT=ON -DWITH_TCC=ON -DWITH_LLVM=OFF'
sh 'cmake --build TGC-ISS/build -j'
sh 'TGC-ISS/build/dbt-rise-tgc/tgc-sim --isa ?'
}
}
stage("start to run hello FW on ISS") {
steps {
sh 'TGC-ISS/build/dbt-rise-tgc/tgc-sim -f hello-world/ISS_Debug/hello.elf'
sh 'TGC-ISS/build/dbt-rise-tgc/tgc-sim -f hello-world/ISS_Debug_64/hello.elf --isa=rv64gc'
}
}
}
}

View File

@@ -10,100 +10,109 @@
},
"configurePresets": [
{
"name": "ISS_Debug",
"name": "32imc",
"hidden": true,
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"BOARD": "iss",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
}
}
},
{
"name": "64imc",
"hidden": true,
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
}
},
{
"name": "iss",
"hidden": true,
"cacheVariables": {
"BOARD": "iss"
}
},
{
"name": "moonlight",
"hidden": true,
"cacheVariables": {
"BOARD": "moonlight"
}
},
{
"name": "tgc_vp",
"hidden": true,
"cacheVariables": {
"BOARD": "tgc_vp"
}
},
{
"name": "rtl",
"hidden": true,
"cacheVariables": {
"BOARD": "rtl"
}
},
{
"name": "debug",
"hidden": true,
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "release",
"hidden": true,
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "ISS_Debug",
"inherits": ["iss", "debug", "32imc"]
},
{
"name": "Moonlight_Debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"BOARD": "moonlight",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
}
"inherits": ["moonlight", "debug", "32imc"]
},
{
"name": "TGC_Debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"BOARD": "tgc_vp",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
}
"name": "TGC_VP_Debug",
"inherits": ["tgc_vp", "debug", "32imc"]
},
{
"name": "ISS_Debug_64",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"BOARD": "iss",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
}
"inherits": ["iss", "debug", "64imc"]
},
{
"name": "Moonlight_Debug_64",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"BOARD": "moonlight",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
}
"inherits": ["moonlight", "debug", "64imc"]
},
{
"name": "TGC_Debug_64",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"BOARD": "tgc_vp",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
}
"name": "TGC_VP_Debug_64",
"inherits": ["tgc_vp", "debug", "64imc"]
},
{
"name": "ISS_Release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BOARD": "iss",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
}
"inherits": ["iss", "release", "32imc"]
},
{
"name": "Moonlight_Release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BOARD": "moonlight",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
}
"inherits": ["moonlight", "release", "32imc"]
},
{
"name": "TGC_Release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BOARD": "tgc_vp",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
}
"name": "TGC_VP_Release",
"inherits": ["tgc_vp", "release", "32imc"]
},
{
"name": "ISS_Release_64",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BOARD": "iss",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
}
"inherits": ["iss", "release", "64imc"]
},
{
"name": "Moonlight_Release_64",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BOARD": "moonlight",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
}
"inherits": ["moonlight", "release", "64imc"]
},
{
"name": "TGC_Release_64",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BOARD": "tgc_vp",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
}
"name": "TGC_VP_Release_64",
"inherits": ["tgc_vp", "release", "64imc"]
}
]
}

View File

@@ -2,18 +2,27 @@ cmake_minimum_required(VERSION 3.21)
project(dhrystone C)
set(TARGET dhrystone)
set(ITERATIONS 50000)
set(ITERATIONS 50000 CACHE STRING "")
set(FREQ 100e6 CACHE STRING "")
set(CMAKE_C_FLAGS_RELEASE -O3)
add_executable(${TARGET} dhry_1.c dhry_2.c dhry_stubs.c)
target_include_directories(${TARGET} PRIVATE ${CMAKE_CURRENT_LIST_DIR})
target_compile_options(${TARGET} PRIVATE -fno-inline -fno-builtin-printf -fno-common -Wno-implicit -funroll-loops -fpeel-loops -fgcse-sm -fgcse-las)
target_compile_definitions(${TARGET} PRIVATE ITERATIONS=${ITERATIONS} HZ=32768 TIME NO_INIT)
target_compile_options(${TARGET} PRIVATE
-Wno-implicit -fno-builtin-printf
-finline -fno-common -funroll-loops -fpeel-loops
-finline-functions -finline-limit=1000
-fgcse-sm -fgcse-las
-falign-functions=16 -falign-jumps=4 -falign-loops=4
-freorder-blocks-and-partition -fno-if-conversion2 -fno-crossjumping)
target_compile_definitions(${TARGET} PRIVATE ITERATIONS=${ITERATIONS} HZ=${FREQ} TIME NO_INIT)
set(BOARD "iss" CACHE STRING "Target board")
add_subdirectory(../../bare-metal-bsp bsp)
target_link_libraries(${TARGET} PRIVATE bsp)
target_link_options(${TARGET} PRIVATE LINKER:-Map=${TARGET}.map)
target_link_options(${TARGET} PRIVATE LINKER:-Map=${TARGET}.map -Wl,--wrap=scanf)
add_custom_command(TARGET ${TARGET} POST_BUILD
COMMAND ${CMAKE_OBJDUMP} -S ${TARGET}.elf > ${TARGET}.dis
COMMAND ${CMAKE_OBJDUMP} -S ${TARGET}.elf > ${TARGET}.dis
COMMENT "Creating disassembly for ${TARGET}")

View File

@@ -10,100 +10,109 @@
},
"configurePresets": [
{
"name": "ISS_Debug",
"name": "32imc",
"hidden": true,
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"BOARD": "iss",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
}
}
},
{
"name": "64imc",
"hidden": true,
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
}
},
{
"name": "iss",
"hidden": true,
"cacheVariables": {
"BOARD": "iss"
}
},
{
"name": "moonlight",
"hidden": true,
"cacheVariables": {
"BOARD": "moonlight"
}
},
{
"name": "tgc_vp",
"hidden": true,
"cacheVariables": {
"BOARD": "tgc_vp"
}
},
{
"name": "rtl",
"hidden": true,
"cacheVariables": {
"BOARD": "rtl"
}
},
{
"name": "debug",
"hidden": true,
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "release",
"hidden": true,
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "ISS_Debug",
"inherits": ["iss", "debug", "32imc"]
},
{
"name": "Moonlight_Debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"BOARD": "moonlight",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
}
"inherits": ["moonlight", "debug", "32imc"]
},
{
"name": "TGC_Debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"BOARD": "tgc_vp",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
}
"name": "TGC_VP_Debug",
"inherits": ["tgc_vp", "debug", "32imc"]
},
{
"name": "ISS_Debug_64",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"BOARD": "iss",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
}
"inherits": ["iss", "debug", "64imc"]
},
{
"name": "Moonlight_Debug_64",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"BOARD": "moonlight",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
}
"inherits": ["moonlight", "debug", "64imc"]
},
{
"name": "TGC_Debug_64",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"BOARD": "tgc_vp",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
}
"name": "TGC_VP_Debug_64",
"inherits": ["tgc_vp", "debug", "64imc"]
},
{
"name": "ISS_Release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BOARD": "iss",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
}
"inherits": ["iss", "release", "32imc"]
},
{
"name": "Moonlight_Release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BOARD": "moonlight",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
}
"inherits": ["moonlight", "release", "32imc"]
},
{
"name": "TGC_Release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BOARD": "tgc_vp",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
}
"name": "TGC_VP_Release",
"inherits": ["tgc_vp", "release", "32imc"]
},
{
"name": "ISS_Release_64",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BOARD": "iss",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
}
"inherits": ["iss", "release", "64imc"]
},
{
"name": "Moonlight_Release_64",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BOARD": "moonlight",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
}
"inherits": ["moonlight", "release", "64imc"]
},
{
"name": "TGC_Release_64",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BOARD": "tgc_vp",
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
}
"name": "TGC_VP_Release_64",
"inherits": ["tgc_vp", "release", "64imc"]
}
]
}

View File

@@ -13,14 +13,14 @@
"name": "32imc",
"hidden": true,
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/../bare-metal-bsp/cmake/rv32imc.cmake"
}
},
{
"name": "64imc",
"hidden": true,
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64imc.cmake"
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/../bare-metal-bsp/cmake/rv64gc.cmake"
}
},
{
@@ -38,7 +38,7 @@
}
},
{
"name": "tgc-vp",
"name": "tgc_vp",
"hidden": true,
"cacheVariables": {
"BOARD": "tgc_vp"
@@ -67,51 +67,56 @@
},
{
"name": "ISS_Debug",
"inherits": ["iss", "debug", "rv32imc"]
"inherits": ["iss", "debug", "32imc"]
},
{
"name": "Moonlight_Debug",
"inherits": ["moonlight", "debug", "rv32imc"]
"inherits": ["moonlight", "debug", "32imc"]
},
{
"name": "TGC_VP_Debug",
"inherits": ["tgc_vp", "debug", "rv32imc"]
"inherits": ["tgc_vp", "debug", "32imc"]
},
{
"name": "ISS_Debug_64",
"inherits": ["iss", "debug", "rv64imc"]
"inherits": ["iss", "debug", "64imc"]
},
{
"name": "Moonlight_Debug_64",
"inherits": ["moonlight", "debug", "rv64imc"]
"hidden": true,
"inherits": ["moonlight", "debug", "64imc"]
},
{
"name": "TGC_VP_Debug_64",
"inherits": ["tgc_vp", "debug", "rv64imc"]
"hidden": true,
"inherits": ["tgc_vp", "debug", "64imc"]
},
{
"name": "ISS_Release",
"inherits": ["iss", "release", "rv32imc"]
"inherits": ["iss", "release", "32imc"]
},
{
"name": "Moonlight_Release",
"inherits": ["moonlight", "release", "rv32imc"]
"inherits": ["moonlight", "release", "32imc"]
},
{
"name": "TGC_VP_Release",
"inherits": ["tgc_vp", "release", "rv32imc"]
"inherits": ["tgc_vp", "release", "32imc"]
},
{
"name": "ISS_Release_64",
"inherits": ["iss", "release", "rv64imc"]
"name": "ISS_Release_64",
"inherits": ["iss", "release", "64imc"]
},
{
"name": "Moonlight_Release_64",
"inherits": ["moonlight", "release", "rv64imc"]
"hidden": true,
"inherits": ["moonlight", "release", "64imc"]
},
{
"name": "TGC_VP_Release_64",
"inherits": ["tgc_vp", "release", "rv64imc"]
"hidden": true,
"inherits": ["tgc_vp", "release", "64imc"]
}
]
}

40
test_fw/CMakeLists.txt Normal file
View File

@@ -0,0 +1,40 @@
cmake_minimum_required(VERSION 3.21)
project(test_fw C)
set(TARGET test_fw)
add_executable(${TARGET} test_fw.c)
# Paths to ThreadX
set(THREADX_DIR "/scratch/hongyu/workarea/ThreadX/threadx/") # change to where ThreadX is located
set(THREADX_LIB "${THREADX_DIR}/build_liu/libthreadx.a")
set(BOARD "iss" CACHE STRING "Target board")
target_compile_options(test_fw PRIVATE
-msmall-data-limit=0
)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../bare-metal-bsp bsp)
target_link_libraries(${TARGET} PRIVATE
-Wl,--start-group
startup
runtime
wrap
${THREADX_LIB}
-Wl,--end-group
)
target_link_options(${TARGET} PRIVATE LINKER:-Map=${TARGET}.map)
#target_link_libraries(${TARGET} PRIVATE ${THREADX_LIB})
target_include_directories(${TARGET} PRIVATE
${THREADX_DIR}/common/inc
${THREADX_DIR}/ports/risc-v64/gnu/inc
)
add_custom_command(TARGET ${TARGET} POST_BUILD
COMMAND ${CMAKE_OBJDUMP} -S ${TARGET}.elf > ${TARGET}.dis
COMMENT "Creating disassembly for ${TARGET}")

122
test_fw/CMakePresets.json Normal file
View File

@@ -0,0 +1,122 @@
{
"version": 3,
"vendor": {
"conan": {}
},
"cmakeMinimumRequired": {
"major": 3,
"minor": 24,
"patch": 0
},
"configurePresets": [
{
"name": "32imc",
"hidden": true,
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/../bare-metal-bsp/cmake/rv32imc.cmake"
}
},
{
"name": "64imc",
"hidden": true,
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/../bare-metal-bsp/cmake/rv64gc.cmake"
}
},
{
"name": "iss",
"hidden": true,
"cacheVariables": {
"BOARD": "iss"
}
},
{
"name": "moonlight",
"hidden": true,
"cacheVariables": {
"BOARD": "moonlight"
}
},
{
"name": "riscv_vp",
"hidden": true,
"cacheVariables": {
"BOARD": "riscv_vp",
"LINKER_SCRIPT": "/scratch/hongyu/workarea/Firmwares/bare-metal-bsp/env/riscv_vp/flash.lds"
}
},
{
"name": "rtl",
"hidden": true,
"cacheVariables": {
"BOARD": "rtl"
}
},
{
"name": "debug",
"hidden": true,
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "release",
"hidden": true,
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "ISS_Debug",
"inherits": ["iss", "debug", "32imc"]
},
{
"name": "Moonlight_Debug",
"inherits": ["moonlight", "debug", "32imc"]
},
{
"name": "riscv_vp_Debug",
"inherits": ["riscv_vp", "debug", "32imc"]
},
{
"name": "ISS_Debug_64",
"inherits": ["iss", "debug", "64imc"]
},
{
"name": "Moonlight_Debug_64",
"hidden": true,
"inherits": ["moonlight", "debug", "64imc"]
},
{
"name": "riscv_vp_Debug_64",
"inherits": ["riscv_vp", "debug", "64imc"]
},
{
"name": "ISS_Release",
"inherits": ["iss", "release", "32imc"]
},
{
"name": "Moonlight_Release",
"inherits": ["moonlight", "release", "32imc"]
},
{
"name": "riscv_vp_Release",
"inherits": ["riscv_vp", "release", "32imc"]
},
{
"name": "ISS_Release_64",
"inherits": ["iss", "release", "64imc"]
},
{
"name": "Moonlight_Release_64",
"hidden": true,
"inherits": ["moonlight", "release", "64imc"]
},
{
"name": "riscv_vp_Release_64",
"hidden": true,
"inherits": ["riscv_vp", "release", "64imc"]
}
]
}

53
test_fw/entry_threadx.S Normal file
View File

@@ -0,0 +1,53 @@
// See LICENSE for license details
#ifndef ENTRY_S
#define ENTRY_S
#include "encoding.h"
#include "bits.h"
msg:
.string "enter trap_entry of entry_threadx!\n"
.section .text.entry
.align 2
.global trap_entry
.extern _tx_thread_context_save
.extern _tx_thread_context_restore
trap_entry:
#if defined(__riscv_float_abi_single) || defined(__riscv_float_abi_double)
addi sp, sp, -65*REGBYTES // Allocate space for all registers - with floating point enabled
#else
addi sp, sp, -32*REGBYTES // Allocate space for all registers - without floating point enabled
#endif
STORE x1, 28*REGBYTES(sp) // Store RA, 28*REGBYTES(because call will override ra [ra is a calle register in riscv])
#la a0, msg # a0 = pointer to string
#jal ra, puts # call puts(msg)
call _tx_thread_context_save
# la a0, msg # a0 = pointer to string
# jal ra, puts # call puts(msg)
csrr a0, mcause
csrr a1, mepc
mv a2, sp // which sp is needed? sp of interrupted context or the sp of _tx_thread_context_save???
addi sp, sp, -8
sd ra, 0(sp)
call handle_trap
ld ra, 0(sp)
addi sp, sp, 8
call _tx_thread_context_restore
//.weak handle_trap
//handle_trap:
//1:
// j 1b
#endif

42
test_fw/test_fw.c Normal file
View File

@@ -0,0 +1,42 @@
#include "encoding.h"
#include "platform.h"
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
void handle_m_time_interrupt() {
uint64_t time = get_aclint_mtime(aclint);
time += MTIMER_NEXT_TICK_INC;
set_aclint_mtimecmp(aclint, time);
puts("m_time_irq");
}
int main() {
puts("in main");
// avoid getting interrupt upon enabling MIP/MIE_MTI
set_aclint_mtimecmp(aclint, 0xffffffffffffffff);
// enable global interrupt
csr_set_bits_mstatus(MSTATUS_MIE_BIT_MASK);
puts("after enable MSTATUS_MIE/MPP");
// enable MIE
csr_set_bits_mie(MIE_MTI_BIT_MASK | MIE_MSI_BIT_MASK | MIE_MEI_BIT_MASK);
puts("after enable MIE");
uint64_t time = get_aclint_mtime(aclint);
printf("in main() get_aclint_mtime return %lu \n", (uint32_t)time);
set_aclint_mtime(aclint, 9);
time = get_aclint_mtime(aclint);
printf("in main() get_aclint_mtime after set 9, return %lu \n", (uint32_t)time);
set_aclint_mtimecmp(aclint, (time + 3));
puts("set mtimecmp");
uint64_t timecmp = get_aclint_mtimecmp(aclint);
printf("in main() get_aclint_mtimecmp return %d \n", timecmp);
puts(" finshed ");
return 0;
}