diff --git a/bare-metal-bsp b/bare-metal-bsp index f419b1a..6cd7ea8 160000 --- a/bare-metal-bsp +++ b/bare-metal-bsp @@ -1 +1 @@ -Subproject commit f419b1a3e6e9e8075d7e937ac5b1e1fb4829a976 +Subproject commit 6cd7ea887ad0f2d5ae692405ba0bbd2b6ee75646 diff --git a/hello-world/CMakeLists.txt b/hello-world/CMakeLists.txt index b1db947..51e1a58 100644 --- a/hello-world/CMakeLists.txt +++ b/hello-world/CMakeLists.txt @@ -1,75 +1,12 @@ -cmake_minimum_required(VERSION 3.12) +cmake_minimum_required(VERSION 3.21) project(hello-world C) +set(TARGET hello) +add_executable(${TARGET} hello.c) -# Set default board to iss if not specified -if(NOT DEFINED BOARD) - set(BOARD "iss" CACHE STRING "Target board") -endif() +set(BOARD "iss" CACHE STRING "Target board") +add_subdirectory(../bare-metal-bsp bsp) +target_link_libraries(${TARGET} PRIVATE bsp) - -# Source files -set(SOURCES - 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} -# $ -# #$ -# ) - -# 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 -) +add_custom_command(TARGET ${TARGET} POST_BUILD + COMMAND ${CMAKE_OBJDUMP} -S ${TARGET}.elf > ${TARGET}.dis + COMMENT "Creating disassembly for ${TARGET}")