cleans up CMakeLists

This commit is contained in:
Eyck-Alexander Jentzsch 2024-06-14 10:11:30 +02:00
parent 9105f5fb14
commit 0df111f945
3 changed files with 3 additions and 115 deletions

View File

@ -6,14 +6,14 @@ if (NOT DEFINED ISA)
endif()
message(STATUS "Building firmware using ${BOARD} board configuration")
add_custom_target(fw-hello-world ALL
COMMAND make -C ${riscvfw_SOURCE_DIR}/hello-world BOARD=${BOARD} ISA=${ISA}
COMMAND make -C hello-world BOARD=${BOARD} ISA=${ISA}
USES_TERMINAL
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
add_custom_target(fw-dhrystone ALL
COMMAND make -C ${riscvfw_SOURCE_DIR}/benchmarks/dhrystone BOARD=${BOARD} ISA=${ISA}
COMMAND make -C benchmarks/dhrystone BOARD=${BOARD} ISA=${ISA}
USES_TERMINAL
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
add_custom_target(fw-coremark ALL
COMMAND make -C ${riscvfw_SOURCE_DIR}/benchmarks/coremark BOARD=${BOARD} ISA=${ISA}
COMMAND make -C benchmarks/coremark BOARD=${BOARD} ISA=${ISA}
USES_TERMINAL
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})

View File

@ -1,91 +0,0 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.13 FATAL_ERROR)
SET(BOARD "iss" CACHE STRING "board to be compiled for")
OPTION(SEMIHOSTING "Enable Semihosting" ON)
SET(RISCV_ARCH "rv32imc" CACHE STRING "arch")
SET(RISCV_ABI "ilp32" CACHE STRING "abi")
EXECUTE_PROCESS(
COMMAND which riscv64-unknown-elf-gcc
OUTPUT_VARIABLE COMPILER
OUTPUT_STRIP_TRAILING_WHITESPACE)
GET_FILENAME_COMPONENT(TOOL_DIR ${COMPILER} DIRECTORY)
SET(TRIPLET "riscv64-unknown-elf")
SET(CMAKE_C_COMPILER ${TOOL_DIR}/${TRIPLET}-gcc)
SET(CMAKE_CXX_COMPILER ${TOOL_DIR}/${TRIPLET}-g++)
SET(CMAKE_ASM_COMPILER ${TOOL_DIR}/${TRIPLET}-gcc)
SET(CMAKE_LINKER ${TOOL_DIR}/${TRIPLET}-ld)
SET(CMAKE_OBJCOPY ${TOOL_DIR}/${TRIPLET}-objcopy)
SET(CMAKE_AR ${TOOL_DIR}/${TRIPLET}-ar)
PROJECT(semihosting_test)
SET(BSP_BASE "../bare-metal-bsp")
SET(ENV_DIR ${BSP_BASE}/env)
SET(PLATFORM_DIR ${ENV_DIR}/${BOARD})
SET(SEMIHOSTING TRUE)
INCLUDE(${BSP_BASE}/libwrap/CMakeLists.txt)
INCLUDE_DIRECTORIES(
${BSP_BASE}/include
${BSP_BASE}/drivers
${BSP_BASE}/libwrap/semihosting
${PLATFORM_DIR}
${ENV_DIR}
)
# Source files
SET(ASM_SRCS
${ENV_DIR}/entry.S
${ENV_DIR}/start.S
)
SET(C_SRCS
${PLATFORM_DIR}/init.c
test.c
)
SET_SOURCE_FILES_PROPERTIES(${ASM_SRCS} PROPERTIES LANGUAGE C)
# Compiler Flags
SET(COMMON_FLAGS "")
# GCC Version Check
EXECUTE_PROCESS(
COMMAND ${CMAKE_C_COMPILER} --version
OUTPUT_VARIABLE GCC_VERSION
)
IF(GCC_VERSION MATCHES "9.2")
LIST(APPEND COMMON_FLAGS "-march=${RISCV_ARCH}")
ELSE()
LIST(APPEND COMMON_FLAGS "-march=${RISCV_ARCH}_zicsr_zifencei")
ENDIF()
LIST(APPEND COMMON_FLAGS "-mabi=${RISCV_ABI}" "-mcmodel=medany" "-DBOARD_${BOARD}")
# Compiler Options
ADD_COMPILE_OPTIONS("${COMMON_FLAGS}")
IF(SEMIHOSTING)
ADD_DEFINITIONS(-DSEMIHOSTING=1)
ELSE ()
ADD_DEFINITIONS(-DSEMIHOSTING=0)
ENDIF()
ADD_EXECUTABLE(${PROJECT_NAME} ${ASM_SRCS} ${C_SRCS} ${SRC_FILES})
TARGET_LINK_LIBRARIES(${PROJECT_NAME} PUBLIC ${LIBWRAP_TGC_LDFLAGS} LIBWRAP_TGC)
# Linker Flags
TARGET_LINK_LIBRARIES(${PROJECT_NAME}
PUBLIC
-march=${RISCV_ARCH} -mabi=${RISCV_ABI}
-T../${PLATFORM_DIR}/link.lds #TODO Path
-Wl,-Map=${PROJECT_NAME}.map
-nostartfiles
-L${ENV_DIR}
)

View File

@ -1,21 +0,0 @@
#include <stdint.h>
#include <stdio.h>
#include <unistd.h>
#include "platform.h"
#include "encoding.h"
#include "semihosting.h"
int main()
{
char new[]="/scratch/gabriel/Documents/test_file";
//puts(new);
//char buf[10];
printf("TEST!!!");
//int fh = open(new, 0, 0);
//unlink(new);
//read(fh, buf, 10);
//printf(buf);
//read(fh, buf, 10);
return 0;
}