[fix] fix cmake files
This commit is contained in:
parent
72ccc03bf9
commit
064e9c91f7
@ -7,16 +7,33 @@ PROJECT(${BOARD} C CXX ASM)
|
||||
|
||||
include_directories(${CMAKE_SOURCE_DIR}/common/misc)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/bsp/bsp_common/platform)
|
||||
|
||||
if(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/bsp/board/${BOARD})
|
||||
include_directories(${CMAKE_SOURCE_DIR}/bsp/board/${BOARD})
|
||||
else()
|
||||
message(FATAL_ERROR "${CMAKE_SOURCE_DIR}/bsp/board/${BOARD} is not exist")
|
||||
endif()
|
||||
|
||||
add_subdirectory(common)
|
||||
add_subdirectory(components/fatfs)
|
||||
add_subdirectory(components/usb_stack)
|
||||
add_subdirectory(drivers/${mcu}_driver)
|
||||
|
||||
if(${SUPPORT_SHELL} STREQUAL "ENABLE")
|
||||
add_subdirectory(components/shell)
|
||||
if(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/drivers/${mcu}_driver)
|
||||
add_subdirectory(drivers/${mcu}_driver)
|
||||
else()
|
||||
message(FATAL_ERROR "${CMAKE_SOURCE_DIR}/drivers/${mcu}_driver is not exist")
|
||||
endif()
|
||||
|
||||
if(${SUPPORT_SHELL} STREQUAL "y")
|
||||
add_subdirectory(components/shell)
|
||||
endif()
|
||||
|
||||
if(${SUPPORT_FREERTOS} STREQUAL "y")
|
||||
add_subdirectory(components/freertos)
|
||||
endif()
|
||||
|
||||
if(${SUPPORT_LVGL} STREQUAL "y")
|
||||
add_subdirectory(components/lvgl)
|
||||
endif()
|
||||
|
||||
search_application(${CMAKE_SOURCE_DIR}/examples)
|
||||
|
10
Makefile
10
Makefile
@ -4,8 +4,18 @@ CHIP?=bl702
|
||||
INTERFACE?=jlink
|
||||
BAUDRATE ?=12000
|
||||
|
||||
SUPPORT_SHELL?=n
|
||||
SUPPORT_FREERTOS?=n
|
||||
SUPPORT_LVGL?=n
|
||||
SUPPORT_FLOAT?=n
|
||||
|
||||
export BOARD
|
||||
export APP
|
||||
export SUPPORT_SHELL
|
||||
export SUPPORT_FREERTOS
|
||||
export SUPPORT_LVGL
|
||||
export SUPPORT_FLOAT
|
||||
|
||||
# The command to remove a file.
|
||||
RM = cmake -E rm -rf
|
||||
|
||||
|
@ -31,34 +31,35 @@ file(GLOB_RECURSE sources
|
||||
|
||||
#aux_source_directory(. sources)
|
||||
list(APPEND ADD_SRCS ${sources})
|
||||
list(REMOVE_ITEM ADD_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/libc/src/strtox.c" "${CMAKE_CURRENT_SOURCE_DIR}/libc/src/atox.c")
|
||||
list(REMOVE_ITEM ADD_SRCS
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/libc/src/strtox.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/libc/src/atox.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/libc/src/stdlib.c")
|
||||
#######################################################
|
||||
|
||||
########### Add required/dependent components #########
|
||||
#list(APPEND ADD_REQUIREMENTS BSP_${BOARD}_Driver)
|
||||
#list(APPEND ADD_REQUIREMENTS xxx)
|
||||
#######################################################
|
||||
|
||||
############ Add static libs ##########################
|
||||
# if(CONFIG_COMPONENT1_INCLUDE_STATIC_LIB)
|
||||
# list(APPEND ADD_STATIC_LIB "lib/libtest.a")
|
||||
# list(APPEND ADD_STATIC_LIB "libxxx.a")
|
||||
# endif()
|
||||
#######################################################
|
||||
|
||||
############ Add dynamic libs #########################
|
||||
# list(APPEND ADD_DYNAMIC_LIB "lib/arch/v831/libmaix_nn.so"
|
||||
# "lib/arch/v831/libmaix_cam.so"
|
||||
# list(APPEND ADD_DYNAMIC_LIB "libxxx.so"
|
||||
# )
|
||||
#######################################################
|
||||
|
||||
############ Add global compile option ################
|
||||
#add components denpend on this component
|
||||
# list(APPEND ADD_DEFINITIONS -D${BOARD} -DARCH_RISCV)
|
||||
# list(APPEND ADD_DEFINITIONS -Dxxx)
|
||||
#######################################################
|
||||
|
||||
############ Add private compile option ################
|
||||
#add compile option for this component that won't affect other modules
|
||||
#list(APPEND ADD_DEFINITIONS_PRIVATE -D${BOARD}_DRIVER)
|
||||
# list(APPEND ADD_DEFINITIONS_PRIVATE -Dxxx)
|
||||
#######################################################
|
||||
|
||||
|
||||
generate_library()
|
||||
|
@ -6,12 +6,6 @@ list(APPEND ADD_INCLUDE
|
||||
|
||||
################# Add private include #################
|
||||
# list(APPEND ADD_PRIVATE_INCLUDE
|
||||
# "${CMAKE_SOURCE_DIR}/BSP_Common/ring_buffer"
|
||||
# "${CMAKE_SOURCE_DIR}/BSP_Driver/BSP_${BOARD}_Driver/StdDriver/Inc"
|
||||
# "${CMAKE_SOURCE_DIR}/BSP_Driver/BSP_${BOARD}_Driver/StdDriver/Inc"
|
||||
# "${CMAKE_SOURCE_DIR}/BSP_Driver/BSP_${BOARD}_Driver/Peripherals"
|
||||
# "${CMAKE_SOURCE_DIR}/BSP_Driver/BSP_${BOARD}_Driver/RISCV/Device/Bouffalo/${BOARD}/Startup"
|
||||
# "${CMAKE_SOURCE_DIR}/BSP_Driver/BSP_${BOARD}_Driver/RISCV/Core/Include"
|
||||
# )
|
||||
#######################################################
|
||||
|
||||
@ -23,30 +17,27 @@ list(APPEND ADD_SRCS ${sources})
|
||||
#######################################################
|
||||
|
||||
########### Add required/dependent components #########
|
||||
#list(APPEND ADD_REQUIREMENTS BSP_${BOARD}_Driver BSP_Common)
|
||||
#list(APPEND ADD_REQUIREMENTS xxx)
|
||||
#######################################################
|
||||
|
||||
############ Add static libs ##########################
|
||||
# if(CONFIG_COMPONENT1_INCLUDE_STATIC_LIB)
|
||||
# list(APPEND ADD_STATIC_LIB "lib/libtest.a")
|
||||
# list(APPEND ADD_STATIC_LIB "libxxx.a")
|
||||
# endif()
|
||||
#######################################################
|
||||
|
||||
############ Add dynamic libs #########################
|
||||
# list(APPEND ADD_DYNAMIC_LIB "lib/arch/v831/libmaix_nn.so"
|
||||
# "lib/arch/v831/libmaix_cam.so"
|
||||
# )
|
||||
# list(APPEND ADD_DYNAMIC_LIB "libxxx.so")
|
||||
#######################################################
|
||||
|
||||
############ Add global compile option ################
|
||||
#add components denpend on this component
|
||||
# list(APPEND ADD_DEFINITIONS -DAAAAA222=1
|
||||
# -DAAAAA333=1)
|
||||
# list(APPEND ADD_DEFINITIONS -Dxxx)
|
||||
#######################################################
|
||||
|
||||
############ Add private compile option ################
|
||||
#add compile option for this component that won't affect other modules
|
||||
# list(APPEND ADD_DEFINITIONS_PRIVATE -DAAAAA=1)
|
||||
# list(APPEND ADD_DEFINITIONS_PRIVATE -Dxxx)
|
||||
#######################################################
|
||||
|
||||
generate_library()
|
||||
|
@ -2,17 +2,12 @@
|
||||
list(APPEND ADD_INCLUDE
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/portable/gcc/risc-v/${mcu}"
|
||||
)
|
||||
#######################################################
|
||||
|
||||
################# Add private include #################
|
||||
# list(APPEND ADD_PRIVATE_INCLUDE
|
||||
# "${CMAKE_SOURCE_DIR}/BSP_Common/ring_buffer"
|
||||
# "${CMAKE_SOURCE_DIR}/BSP_Driver/BSP_${BOARD}_Driver/StdDriver/Inc"
|
||||
# "${CMAKE_SOURCE_DIR}/BSP_Driver/BSP_${BOARD}_Driver/StdDriver/Inc"
|
||||
# "${CMAKE_SOURCE_DIR}/BSP_Driver/BSP_${BOARD}_Driver/Peripherals"
|
||||
# "${CMAKE_SOURCE_DIR}/BSP_Driver/BSP_${BOARD}_Driver/RISCV/Device/Bouffalo/${BOARD}/Startup"
|
||||
# "${CMAKE_SOURCE_DIR}/BSP_Driver/BSP_${BOARD}_Driver/RISCV/Core/Include"
|
||||
# )
|
||||
#######################################################
|
||||
|
||||
@ -24,7 +19,9 @@ file(GLOB_RECURSE sources "${CMAKE_CURRENT_SOURCE_DIR}/croutine.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/queue.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/tasks.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/timers.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/portable/MemMang/heap_5.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/portable/memmang/heap_5.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/portable/gcc/risc-v/${mcu}/port.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/portable/gcc/risc-v/${mcu}/portASM.S"
|
||||
)
|
||||
list(APPEND ADD_SRCS ${sources})
|
||||
# aux_source_directory(src ADD_SRCS)
|
||||
@ -32,30 +29,28 @@ list(APPEND ADD_SRCS ${sources})
|
||||
#######################################################
|
||||
|
||||
########### Add required/dependent components #########
|
||||
#list(APPEND ADD_REQUIREMENTS BSP_${BOARD}_Driver)
|
||||
#list(APPEND ADD_REQUIREMENTS xxx)
|
||||
#######################################################
|
||||
|
||||
############ Add static libs ##########################
|
||||
# if(CONFIG_COMPONENT1_INCLUDE_STATIC_LIB)
|
||||
# list(APPEND ADD_STATIC_LIB "lib/libtest.a")
|
||||
# list(APPEND ADD_STATIC_LIB "libxxx.a")
|
||||
# endif()
|
||||
#######################################################
|
||||
|
||||
############ Add dynamic libs #########################
|
||||
# list(APPEND ADD_DYNAMIC_LIB "lib/arch/v831/libmaix_nn.so"
|
||||
# "lib/arch/v831/libmaix_cam.so"
|
||||
# list(APPEND ADD_DYNAMIC_LIB "libxxx.so"
|
||||
# )
|
||||
#######################################################
|
||||
|
||||
############ Add global compile option ################
|
||||
#add components denpend on this component
|
||||
# list(APPEND ADD_DEFINITIONS -DAAAAA222=1
|
||||
# -DAAAAA333=1)
|
||||
list(APPEND ADD_DEFINITIONS -DportasmHANDLE_INTERRUPT=FreeRTOS_Interrupt_Handler)
|
||||
#######################################################
|
||||
|
||||
############ Add private compile option ################
|
||||
#add compile option for this component that won't affect other modules
|
||||
# list(APPEND ADD_DEFINITIONS_PRIVATE -DAAAAA=1)
|
||||
# list(APPEND ADD_DEFINITIONS_PRIVATE -Dxxx)
|
||||
#######################################################
|
||||
|
||||
generate_library()
|
||||
|
@ -20,30 +20,28 @@ list(APPEND ADD_SRCS ${sources})
|
||||
#######################################################
|
||||
|
||||
########### Add required/dependent components #########
|
||||
#list(APPEND ADD_REQUIREMENTS BSP_${BOARD}_Driver)
|
||||
#list(APPEND ADD_REQUIREMENTS xxx)
|
||||
#######################################################
|
||||
|
||||
############ Add static libs ##########################
|
||||
# if(CONFIG_COMPONENT1_INCLUDE_STATIC_LIB)
|
||||
# list(APPEND ADD_STATIC_LIB "lib/libtest.a")
|
||||
# list(APPEND ADD_STATIC_LIB "libxxx.a")
|
||||
# endif()
|
||||
#######################################################
|
||||
|
||||
############ Add dynamic libs #########################
|
||||
# list(APPEND ADD_DYNAMIC_LIB "lib/arch/v831/libmaix_nn.so"
|
||||
# "lib/arch/v831/libmaix_cam.so"
|
||||
# list(APPEND ADD_DYNAMIC_LIB "libxxx.so"
|
||||
# )
|
||||
#######################################################
|
||||
|
||||
############ Add global compile option ################
|
||||
#add components denpend on this component
|
||||
#list(APPEND ADD_DEFINITIONS -D${BOARD} -DARCH_RISCV)
|
||||
# list(APPEND ADD_DEFINITIONS -Dxxx)
|
||||
#######################################################
|
||||
|
||||
############ Add private compile option ################
|
||||
#add compile option for this component that won't affect other modules
|
||||
#list(APPEND ADD_DEFINITIONS_PRIVATE -D${BOARD}_DRIVER)
|
||||
# list(APPEND ADD_DEFINITIONS_PRIVATE -Dxxx)
|
||||
#######################################################
|
||||
|
||||
|
||||
generate_library()
|
||||
|
@ -6,6 +6,7 @@ list(APPEND ADD_INCLUDE
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/class/hid"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/class/msc"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/class/video"
|
||||
#"${CMAKE_CURRENT_SOURCE_DIR}/class/vendor"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/class/winusb"
|
||||
)
|
||||
#######################################################
|
||||
@ -24,30 +25,28 @@ list(APPEND ADD_SRCS ${sources})
|
||||
#######################################################
|
||||
|
||||
########### Add required/dependent components #########
|
||||
#list(APPEND ADD_REQUIREMENTS BSP_${BOARD}_Driver)
|
||||
#list(APPEND ADD_REQUIREMENTS xxx)
|
||||
#######################################################
|
||||
|
||||
############ Add static libs ##########################
|
||||
# if(CONFIG_COMPONENT1_INCLUDE_STATIC_LIB)
|
||||
# list(APPEND ADD_STATIC_LIB "lib/libtest.a")
|
||||
# list(APPEND ADD_STATIC_LIB "libxxx.a")
|
||||
# endif()
|
||||
#######################################################
|
||||
|
||||
############ Add dynamic libs #########################
|
||||
# list(APPEND ADD_DYNAMIC_LIB "lib/arch/v831/libmaix_nn.so"
|
||||
# "lib/arch/v831/libmaix_cam.so"
|
||||
# list(APPEND ADD_DYNAMIC_LIB "libxxx.so"
|
||||
# )
|
||||
#######################################################
|
||||
|
||||
############ Add global compile option ################
|
||||
#add components denpend on this component
|
||||
# list(APPEND ADD_DEFINITIONS -DAAAAA222=1
|
||||
# -DAAAAA333=1)
|
||||
# list(APPEND ADD_DEFINITIONS -Dxxx)
|
||||
#######################################################
|
||||
|
||||
############ Add private compile option ################
|
||||
#add compile option for this component that won't affect other modules
|
||||
# list(APPEND ADD_DEFINITIONS_PRIVATE -DAAAAA=1)
|
||||
# list(APPEND ADD_DEFINITIONS_PRIVATE -Dxxx)
|
||||
#######################################################
|
||||
|
||||
generate_library()
|
||||
|
@ -1,4 +1,4 @@
|
||||
PHONY := __build
|
||||
__build:
|
||||
cmake -DBOARD=$(BOARD) -DSUPPORT_SHELL=DISABLE -DAPP=$(APP) ..
|
||||
cmake -DBOARD=$(BOARD) -DSUPPORT_SHELL=$(SUPPORT_SHELL) -DSUPPORT_FREERTOS=$(SUPPORT_FREERTOS) -DSUPPORT_LVGL=$(SUPPORT_LVGL) -DSUPPORT_FLOAT=$(SUPPORT_FLOAT) -DAPP=$(APP) ..
|
||||
make -j
|
||||
|
@ -10,21 +10,25 @@
|
||||
# -g Produce debugging information in the operating system’s native format.
|
||||
# -Os Optimize for size. -Os enables all -O2 optimizations.
|
||||
# -flto Runs the standard link-time optimizer.
|
||||
|
||||
SET(MARCH "rv32imafc")
|
||||
SET(MCPU "riscv-e24")
|
||||
if(${SUPPORT_FLOAT} STREQUAL "y")
|
||||
SET(MARCH "rv32imafc")
|
||||
SET(MABI "ilp32f")
|
||||
else()
|
||||
SET(MARCH "rv32imac")
|
||||
SET(MABI "ilp32")
|
||||
endif()
|
||||
SET(MCU_FLAG "-march=${MARCH} -mabi=${MABI}")
|
||||
|
||||
SET(COMMON_FLAGS "-O2 -g3 -fshort-enums -fno-common \
|
||||
SET(COMMON_FLAGS "-Os -g3 -fshort-enums -fno-common \
|
||||
-fms-extensions -ffunction-sections -fdata-sections -fstrict-volatile-bitfields \
|
||||
-Wall -Wshift-negative-value -Wchar-subscripts -Wformat -Wuninitialized -Winit-self -fno-jump-tables \
|
||||
-Wignored-qualifiers -Wswitch-default -Wunused -Wundef -msmall-data-limit=4")
|
||||
-Wall -Wshift-negative-value -Wchar-subscripts -Wformat -Wuninitialized -Winit-self \
|
||||
-Wignored-qualifiers -Wunused -Wundef -msmall-data-limit=4")
|
||||
|
||||
# compiler: language specific flags
|
||||
set(CMAKE_C_FLAGS "${MCU_FLAG} ${COMMON_FLAGS} -std=c99" CACHE INTERNAL "c compiler flags")
|
||||
set(CMAKE_C_FLAGS_DEBUG "-Og -g" CACHE INTERNAL "c compiler flags: Debug")
|
||||
set(CMAKE_C_FLAGS_RELEASE "-Os -flto" CACHE INTERNAL "c compiler flags: Release")
|
||||
set(CMAKE_C_FLAGS_RELEASE "-Os" CACHE INTERNAL "c compiler flags: Release")
|
||||
|
||||
# message("")
|
||||
# message("-----------------------------------------------------------------------------------------------------------------------------------------------------")
|
||||
@ -37,7 +41,7 @@ set(CMAKE_C_FLAGS_RELEASE "-Os -flto" CACHE INTERNAL "c compiler flags: Release"
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${MCU_FLAG} ${COMMON_FLAGS} -std=c++11 " CACHE INTERNAL "cxx compiler flags")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-Og -g" CACHE INTERNAL "cxx compiler flags: Debug")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-Os -flto" CACHE INTERNAL "cxx compiler flags: Release")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-Os" CACHE INTERNAL "cxx compiler flags: Release")
|
||||
|
||||
# message("")
|
||||
# message("-----------------------------------------------------------------------------------------------------------------------------------------------------")
|
||||
@ -50,7 +54,7 @@ set(CMAKE_CXX_FLAGS_RELEASE "-Os -flto" CACHE INTERNAL "cxx compiler flags: Rele
|
||||
|
||||
set(CMAKE_ASM_FLAGS "${MCU_FLAG} ${COMMON_FLAGS}" CACHE INTERNAL "asm compiler flags")
|
||||
set(CMAKE_ASM_FLAGS_DEBUG "-Og -g" CACHE INTERNAL "asm compiler flags: Debug")
|
||||
set(CMAKE_ASM_FLAGS_RELEASE "-Os -flto" CACHE INTERNAL "asm compiler flags: Release")
|
||||
set(CMAKE_ASM_FLAGS_RELEASE "-Os" CACHE INTERNAL "asm compiler flags: Release")
|
||||
|
||||
# message("")
|
||||
# message("-----------------------------------------------------------------------------------------------------------------------------------------------------")
|
||||
@ -64,7 +68,12 @@ set(CMAKE_ASM_FLAGS_RELEASE "-Os -flto" CACHE INTERNAL "asm compiler flags: Rele
|
||||
# --specs=nano.specs Link with newlib-nano.
|
||||
# --specs=nosys.specs No syscalls, provide empty implementations for the POSIX system calls.
|
||||
|
||||
if(${SUPPORT_SHELL} STREQUAL "ENABLE")
|
||||
if(${SUPPORT_FLOAT} STREQUAL "y")
|
||||
add_definitions(-DBFLB_PRINT_FLOAT_SUPPORT)
|
||||
else()
|
||||
endif()
|
||||
|
||||
if(${SUPPORT_SHELL} STREQUAL "y")
|
||||
add_definitions(-DSHELL_SUPPORT)
|
||||
else()
|
||||
endif()
|
||||
|
@ -114,6 +114,7 @@ function(generate_bin)
|
||||
set(HEX_FILE ${OUTPUT_DIR}/main.hex)
|
||||
set(BIN_FILE ${OUTPUT_DIR}/main.bin)
|
||||
set(MAP_FILE ${OUTPUT_DIR}/main.map)
|
||||
set(ASM_FILE ${OUTPUT_DIR}/main.asm)
|
||||
|
||||
if(TARGET_REQUIRED_SRCS)
|
||||
list(APPEND SRCS ${TARGET_REQUIRED_SRCS})
|
||||
@ -143,7 +144,7 @@ function(generate_bin)
|
||||
# Add libs
|
||||
target_link_libraries(${target_name}.elf ${mcu}_driver)
|
||||
|
||||
if(${SUPPORT_SHELL} STREQUAL "ENABLE")
|
||||
if(${SUPPORT_SHELL} STREQUAL "y")
|
||||
target_link_libraries(${target_name}.elf shell)
|
||||
else()
|
||||
include_directories(${CMAKE_SOURCE_DIR}/components/shell)
|
||||
@ -157,6 +158,7 @@ function(generate_bin)
|
||||
|
||||
add_custom_command(TARGET ${target_name}.elf POST_BUILD
|
||||
COMMAND ${CMAKE_OBJCOPY} -Obinary $<TARGET_FILE:${target_name}.elf> ${BIN_FILE}
|
||||
COMMAND ${CMAKE_OBJDUMP} -d -S $<TARGET_FILE:${target_name}.elf> >${ASM_FILE}
|
||||
# COMMAND ${CMAKE_OBJCOPY} -Oihex $<TARGET_FILE:${mainname}.elf> ${HEX_FILE}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${BIN_FILE} ${CMAKE_SOURCE_DIR}/tools/bflb_flash_tool/img/project.bin
|
||||
COMMENT "Generate ${BIN_FILE}\r\nCopy ${BIN_FILE} into download path")
|
||||
|
Reference in New Issue
Block a user