Compare commits
	
		
			4 Commits
		
	
	
		
			fddf608418
			...
			1629b165b5
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 1629b165b5 | |||
| a2e932c56f | |||
| cde5ae627c | |||
| 85304d1a43 | 
 Submodule bare-metal-bsp updated: f419b1a3e6...fbe6560e79
									
								
							
							
								
								
									
										1
									
								
								benchmarks/dhrystone/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								benchmarks/dhrystone/.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -1,2 +1,3 @@
 | 
				
			|||||||
dhrystone
 | 
					dhrystone
 | 
				
			||||||
/dhrystone.dis
 | 
					/dhrystone.dis
 | 
				
			||||||
 | 
					build/
 | 
				
			||||||
@@ -1,58 +1,21 @@
 | 
				
			|||||||
cmake_minimum_required(VERSION 3.12)
 | 
					cmake_minimum_required(VERSION 3.21)
 | 
				
			||||||
project(dhrystone C)
 | 
					project(dhrystone C)
 | 
				
			||||||
 | 
					set(TARGET dhrystone)
 | 
				
			||||||
 | 
					set(CMAKE_BUILD_TYPE Release)
 | 
				
			||||||
 | 
					set(ITERATIONS 50000) # 20000 for TGC
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Include BSP libwrap
 | 
					add_executable(${TARGET} dhry_1.c dhry_2.c dhry_stubs.c)
 | 
				
			||||||
include(${BSP_BASE}/libwrap/CMakeLists.txt)
 | 
					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)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Source files
 | 
					set(BOARD "iss" CACHE STRING "Target board")
 | 
				
			||||||
set(SOURCES
 | 
					add_subdirectory(../../bare-metal-bsp bsp)
 | 
				
			||||||
    dhry_1.c
 | 
					target_link_libraries(${TARGET} PRIVATE bsp)
 | 
				
			||||||
    dhry_2.c
 | 
					target_link_options(${TARGET} PRIVATE LINKER:--wrap=scanf)
 | 
				
			||||||
    dhry_stubs.c
 | 
					include(CMakePrintHelpers)
 | 
				
			||||||
)
 | 
					cmake_print_properties(TARGETS ${TARGET} PROPERTIES COMPILE_DEFINITIONS COMPILE_OPTIONS LINK_OPTIONS INTERFACE_LINK_OPTIONS)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Create executable
 | 
					add_custom_command(TARGET ${TARGET} POST_BUILD
 | 
				
			||||||
add_executable(dhrystone ${SOURCES})
 | 
					        COMMAND ${CMAKE_OBJDUMP} -S  ${TARGET}.elf > ${TARGET}.dis
 | 
				
			||||||
 | 
					        COMMENT "Creating disassembly for ${TARGET}")
 | 
				
			||||||
# Include directories
 | 
					 | 
				
			||||||
target_include_directories(dhrystone PRIVATE
 | 
					 | 
				
			||||||
    ${BSP_BASE}/include
 | 
					 | 
				
			||||||
    ${BSP_BASE}/drivers
 | 
					 | 
				
			||||||
    ${BSP_BASE}/env
 | 
					 | 
				
			||||||
    ${CMAKE_CURRENT_SOURCE_DIR}
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Link with libwrap
 | 
					 | 
				
			||||||
target_link_libraries(dhrystone PRIVATE
 | 
					 | 
				
			||||||
    LIBWRAP_TGC
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Add compile definitions
 | 
					 | 
				
			||||||
target_compile_definitions(dhrystone PRIVATE
 | 
					 | 
				
			||||||
    BOARD_${BOARD}
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Set compile options
 | 
					 | 
				
			||||||
target_compile_options(dhrystone PRIVATE
 | 
					 | 
				
			||||||
    -march=${RISCV_ARCH}_zicsr_zifencei
 | 
					 | 
				
			||||||
    -mabi=${RISCV_ABI}
 | 
					 | 
				
			||||||
    -mcmodel=medany
 | 
					 | 
				
			||||||
    -ffunction-sections
 | 
					 | 
				
			||||||
    -fdata-sections
 | 
					 | 
				
			||||||
    -O2  # Optimization level for benchmarking
 | 
					 | 
				
			||||||
    -DTIME  # Enable time measurement
 | 
					 | 
				
			||||||
    -DNOENUM  # Disable enum usage as per dhrystone requirements
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Set linker options
 | 
					 | 
				
			||||||
target_link_options(dhrystone PRIVATE
 | 
					 | 
				
			||||||
    -T${BSP_BASE}/env/${BOARD}/link.ld
 | 
					 | 
				
			||||||
    -nostartfiles
 | 
					 | 
				
			||||||
    -Wl,--gc-sections
 | 
					 | 
				
			||||||
    ${LIBWRAP_TGC_LDFLAGS}
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Install target
 | 
					 | 
				
			||||||
install(TARGETS dhrystone
 | 
					 | 
				
			||||||
    RUNTIME DESTINATION bin
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,6 +17,7 @@ endif
 | 
				
			|||||||
# '-lgcc -lm' are needed to add softfloat routines
 | 
					# '-lgcc -lm' are needed to add softfloat routines
 | 
				
			||||||
CFLAGS  := -g -O3 -DITERATIONS=$(ITERATIONS) -DHZ=32768 -DTIME -DNO_INIT -fno-inline -fno-builtin-printf -fno-common -Wno-implicit \
 | 
					CFLAGS  := -g -O3 -DITERATIONS=$(ITERATIONS) -DHZ=32768 -DTIME -DNO_INIT -fno-inline -fno-builtin-printf -fno-common -Wno-implicit \
 | 
				
			||||||
 -funroll-loops -fpeel-loops -fgcse-sm -fgcse-las
 | 
					 -funroll-loops -fpeel-loops -fgcse-sm -fgcse-las
 | 
				
			||||||
 | 
					LDFLAGS := -Wl,--wrap=scanf
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TOOL_DIR=$(dir $(compiler))
 | 
					TOOL_DIR=$(dir $(compiler))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										1
									
								
								hello-world/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								hello-world/.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -1,2 +1,3 @@
 | 
				
			|||||||
/hello
 | 
					/hello
 | 
				
			||||||
/hello.dis
 | 
					/hello.dis
 | 
				
			||||||
 | 
					build/
 | 
				
			||||||
@@ -1,75 +1,12 @@
 | 
				
			|||||||
cmake_minimum_required(VERSION 3.12)
 | 
					cmake_minimum_required(VERSION 3.21)
 | 
				
			||||||
project(hello-world C)
 | 
					project(hello-world C)
 | 
				
			||||||
 | 
					set(TARGET hello)
 | 
				
			||||||
 | 
					add_executable(${TARGET} hello.c)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Set default board to iss if not specified
 | 
					set(BOARD "iss" CACHE STRING "Target board")
 | 
				
			||||||
if(NOT DEFINED BOARD)
 | 
					add_subdirectory(../bare-metal-bsp bsp)
 | 
				
			||||||
    set(BOARD "iss" CACHE STRING "Target board")
 | 
					target_link_libraries(${TARGET} PRIVATE bsp)
 | 
				
			||||||
endif()
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					add_custom_command(TARGET ${TARGET} POST_BUILD
 | 
				
			||||||
# Source files
 | 
					        COMMAND ${CMAKE_OBJDUMP} -S  ${TARGET}.elf > ${TARGET}.dis
 | 
				
			||||||
set(SOURCES
 | 
					        COMMENT "Creating disassembly for ${TARGET}")
 | 
				
			||||||
    hello.c
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
message(STATUS "Building for board: ${BOARD}")
 | 
					 | 
				
			||||||
message(STATUS "liu:${PROJECT_NAME} ")
 | 
					 | 
				
			||||||
message(STATUS "Using board-specific files from: ${BSP_BASE}/env/${BOARD}")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Create executable with all objects
 | 
					 | 
				
			||||||
add_executable(${PROJECT_NAME} 
 | 
					 | 
				
			||||||
    ${SOURCES}   
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
set_target_properties(${PROJECT_NAME}  PROPERTIES SUFFIX ".elf")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Link with board library
 | 
					 | 
				
			||||||
#target_link_libraries(${PROJECT_NAME}  PRIVATE 
 | 
					 | 
				
			||||||
# libwrap
 | 
					 | 
				
			||||||
# ${BOARD}
 | 
					 | 
				
			||||||
# $<TARGET_OBJECTS:asm_obj>
 | 
					 | 
				
			||||||
# #$<TARGET_OBJECTS:env_start>
 | 
					 | 
				
			||||||
# )
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Include directories
 | 
					 | 
				
			||||||
target_include_directories(${PROJECT_NAME}  PRIVATE
 | 
					 | 
				
			||||||
    ${BSP_BASE}/include
 | 
					 | 
				
			||||||
    ${BSP_BASE}/drivers
 | 
					 | 
				
			||||||
    ${BSP_BASE}/env
 | 
					 | 
				
			||||||
    ${BSP_BASE}/env/${BOARD}
 | 
					 | 
				
			||||||
    ${BSP_BASE}/libwrap
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Add compile definitions
 | 
					 | 
				
			||||||
target_compile_definitions(${PROJECT_NAME}  PRIVATE
 | 
					 | 
				
			||||||
    BOARD_${BOARD}
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# link global_compile_options to this target ????
 | 
					 | 
				
			||||||
#target_link_libraries(${PROJECT_NAME} PRIVATE global_compile_options)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
get_target_property(WRAP_LIBRARY_PATH libwrap ARCHIVE_OUTPUT_DIRECTORY)
 | 
					 | 
				
			||||||
get_target_property(BOARDLIBRARY_PATH ${BOARD} ARCHIVE_OUTPUT_DIRECTORY)
 | 
					 | 
				
			||||||
## TODDO ???
 | 
					 | 
				
			||||||
set(ASM_OBJ_LIB "${BOARDLIBRARY_PATH}/CMakeFiles/asm_obj.dir")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
message(STATUS "in hello_world WRAP_LIBRARY_PATH : ${WRAP_LIBRARY_PATH}, BOARDLIBRARY_PATH : ${BOARDLIBRARY_PATH} ASM_OBJ_LIB: ${ASM_OBJ_LIB} ")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Set linker options
 | 
					 | 
				
			||||||
target_link_options(${PROJECT_NAME}  PRIVATE
 | 
					 | 
				
			||||||
    --verbose 
 | 
					 | 
				
			||||||
    -L${ASM_OBJ_LIB}
 | 
					 | 
				
			||||||
    -L${WRAP_LIBRARY_PATH}
 | 
					 | 
				
			||||||
    -L${BOARDLIBRARY_PATH}  
 | 
					 | 
				
			||||||
    ${ASM_OBJ_LIB}/start.S.o 
 | 
					 | 
				
			||||||
    ${ASM_OBJ_LIB}/entry.S.o 
 | 
					 | 
				
			||||||
    -L/scratch/hongyu/workarea/Firmwares/build/bare-metal-bsp/env/CMakeFiles/asm_obj.dir 
 | 
					 | 
				
			||||||
    -g -Wl,--wrap=printf -march=rv32imc -mabi=ilp32 -L../bare-metal-bsp/env/ -Wl,--wrap=malloc -Wl,--wrap=open -Wl,--wrap=lseek -Wl,--wrap=_lseek -Wl,--wrap=read -Wl,--wrap=_read -Wl,--wrap=write -Wl,--wrap=_write -Wl,--wrap=fstat -Wl,--wrap=_fstat -Wl,--wrap=stat -Wl,--wrap=close -Wl,--wrap=_close -Wl,--wrap=link -Wl,--wrap=unlink -Wl,--wrap=execve -Wl,--wrap=fork -Wl,--wrap=getpid -Wl,--wrap=kill -Wl,--wrap=wait -Wl,--wrap=isatty -Wl,--wrap=times -Wl,--wrap=sbrk -Wl,--wrap=_sbrk -Wl,--wrap=exit -Wl,--wrap=_exit -Wl,--wrap=puts -Wl,--wrap=_puts -Wl,--wrap=printf -Wl,--wrap=sprintf -L. -Wl,--start-group -llibwrap -liss -lc -Wl,--end-group  -T /scratch/hongyu/workarea/Firmwares/bare-metal-bsp/env/iss/link.lds -Wl,--no-warn-rwx-segments -Wl,-Map=hello.map  -nostartfiles  -o hello.elf
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Install target
 | 
					 | 
				
			||||||
install(TARGETS ${PROJECT_NAME} 
 | 
					 | 
				
			||||||
    RUNTIME DESTINATION bin
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user