build/cmake: add initial KERNEL mode support

Currently only FLAT mode development can enjoy cmake build system. This
patch tries to add initial kernel mode support. It can build NuttX kernel
and libproxies.a, the latter will be further checked though.

This can already help to build an AMP remote node image as it can share
userland apps living in the AMP master node.

Major changes:

- in top folder:
  - CMakeLists.txt    adjust for KERNEL mode, separate from PROTECTED mode.
- in `syscall`:
  - CMakeLists.txt    add mksyscall target for stubs/proxies generation
- in `syscall/stubs`:
  - CMakeLists.txt    use dependency to mksyscall
- in `syscall/proxies`:
  - CMakeLists.txt    use dependency to mksyscall
- in `arch`:
  - CMakeLists.txt    separate KERNEL from PROTECTED mode.
- in `arch/risc-v/src`:
  - CMakeLists.txt    separate from PROTECTED mode, add sub folders.
- in `arch/risc-v/common`:
  - CMakeLists.txt    add sources and sub-folders for KERNEL mode.
- in `arch/risc-v/k230`:
  - CMakeLists.txt    add sources for KERNEL mode.
- in `boards/risc-v/k230/canmv230/src`:
  - CMakeLists.txt    adjust k230 specific scripts for kernel mode.

New additions:

- in `arch/risc-v/src/nuttsbi/`           add CMakeLists.txt
- in `arch/risc-v/src/common/supervisor/` add CMakeLists.txt

Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
This commit is contained in:
Yanfeng Liu
2024-03-14 15:00:46 +08:00
committed by archer
parent 8bf6b17cc0
commit ea8682572c
11 changed files with 118 additions and 25 deletions

View File

@@ -550,11 +550,15 @@ endif()
# Add apps/ to the build (if present)
if(EXISTS ${NUTTX_APPS_DIR}/CMakeLists.txt)
add_subdirectory(${NUTTX_APPS_DIR} apps)
else()
message(
STATUS "Application directory not found at ${NUTTX_APPS_DIR}, skipping")
if(NOT CONFIG_BUILD_KERNEL)
if(EXISTS ${NUTTX_APPS_DIR}/CMakeLists.txt)
add_subdirectory(${NUTTX_APPS_DIR} apps)
else()
message(
STATUS "Application directory not found at ${NUTTX_APPS_DIR}, skipping")
endif()
endif()
# Link step ##################################################################
@@ -597,11 +601,15 @@ endif()
file(TOUCH ${CMAKE_BINARY_DIR}/nuttx.manifest)
get_property(nuttx_kernel_libs GLOBAL PROPERTY NUTTX_KERNEL_LIBRARIES)
get_property(nuttx_extra_libs GLOBAL PROPERTY NUTTX_EXTRA_LIBRARIES)
if(CONFIG_BUILD_FLAT)
get_property(nuttx_system_libs GLOBAL PROPERTY NUTTX_SYSTEM_LIBRARIES)
endif()
get_property(nuttx_apps_libs GLOBAL PROPERTY NUTTX_APPS_LIBRARIES)
get_property(nuttx_extra_libs GLOBAL PROPERTY NUTTX_EXTRA_LIBRARIES)
if(NOT CONFIG_BUILD_KERNEL)
get_property(nuttx_apps_libs GLOBAL PROPERTY NUTTX_APPS_LIBRARIES)
endif()
set(nuttx_libs ${nuttx_kernel_libs} ${nuttx_system_libs} ${nuttx_apps_libs})
@@ -734,7 +742,7 @@ endif()
# Userspace portion ##########################################################
if(NOT CONFIG_BUILD_FLAT)
if(CONFIG_BUILD_PROTECTED)
add_executable(nuttx_user)
get_property(nuttx_system_libs GLOBAL PROPERTY NUTTX_SYSTEM_LIBRARIES)
@@ -779,3 +787,8 @@ if(NOT CONFIG_BUILD_FLAT)
# TODO: could also merge elf binaries
endif()
if(CONFIG_BUILD_KERNEL)
# TODO: generate nuttx-export-xxx.tar.gz for userland development
endif()