Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Platform/rt-kernel.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ add_definitions(

# Common includes
list (APPEND INCLUDES
${RTK}/bsp/${BSP}/include
${BSP_DIR}/include
${RTK}/include
${RTK}/include/arch/${ARCH}
${RTK}/lwip/src/include
Expand All @@ -67,7 +67,8 @@ set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${INCLUDES})
add_link_options(
-nostartfiles
-L${RTK}/lib/${ARCH}/${VARIANT}/${CPU}
-T${RTK}/bsp/${BSP}/${BSP}.ld
-L${BSP_LIBDIR}
-T${BSP_DIR}/${BSP}.ld
-Wl,--gc-sections
)

Expand All @@ -93,7 +94,6 @@ list (APPEND LIBS
-lpwm
-ladc
-ldac
-ltrace
-lcounter
-lshell
-llua
Expand Down
20 changes: 17 additions & 3 deletions toolchain/rt-kernel.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,22 @@ if (NOT DEFINED ENV{COMPILERS})
endif()

# Get environment variables
set(RTK $ENV{RTK} CACHE STRING
set(RTK $ENV{RTK} CACHE PATH
"Location of rt-kernel tree")
set(COMPILERS $ENV{COMPILERS} CACHE STRING
set(COMPILERS $ENV{COMPILERS} CACHE PATH
"Location of compiler toolchain")
set(BSP $ENV{BSP} CACHE STRING
"The name of the BSP to build for")

if (NOT DEFINED ENV{BSP_DIR})
set(ENV{BSP_DIR} ${RTK}/bsp/${BSP})
endif()

set(BSP_DIR $ENV{BSP_DIR} CACHE PATH
"The location of the BSP to build for, may be out-of-tree from the rt-kernel")

# Check that bsp.mk exists
set(BSP_MK_FILE ${RTK}/bsp/${BSP}/${BSP}.mk)
set(BSP_MK_FILE ${BSP_DIR}/${BSP}.mk)
if (NOT EXISTS ${BSP_MK_FILE})
message(FATAL_ERROR "Failed to open ${BSP_MK_FILE}")
endif()
Expand All @@ -80,6 +87,13 @@ set(VARIANT ${CMAKE_MATCH_1} CACHE STRING "")
string(REGEX MATCH "CROSS_GCC=([A-Za-z0-9_\-]*)" _ ${BSP_MK})
set(CROSS_GCC ${CMAKE_MATCH_1} CACHE STRING "")

if (NOT DEFINED ENV{BSP_LIBDIR})
set(ENV{BSP_DIR} ${RTK}/lib/${ARCH}/${VARIANT}/${CPU})
endif()

set(BSP_LIBDIR $ENV{BSP_LIBDIR} CACHE PATH
"The location of the BSP library, may be out-of-tree from the rt-kernel")

# Set cross-compiler toolchain
set(CMAKE_C_COMPILER ${COMPILERS}/${CROSS_GCC}/bin/${CROSS_GCC}-gcc)
set(CMAKE_CXX_COMPILER ${CMAKE_C_COMPILER})
Expand Down