-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
52 lines (38 loc) · 1.35 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
cmake_minimum_required(VERSION 3.28)
project(freertos LANGUAGES ASM C CXX VERSION 1.0)
# Include the ARM toolchain
include(gcc-arm-none-eabi.cmake)
set(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/STM32F446RETX_FLASH.ld)
file(GLOB_RECURSE FREERTOS_SOURCES
${CMAKE_SOURCE_DIR}/Sources/*.c
${CMAKE_SOURCE_DIR}/Core/Startup/*.c
${CMAKE_SOURCE_DIR}/FreeRTOS/*.c
)
# message(STATUS ${FREERTOS_SOURCES})
# Create the main executable target
add_executable(${PROJECT_NAME} ${SOURCES} ${FREERTOS_SOURCES})
# Include directories
target_include_directories(${PROJECT_NAME} PUBLIC
${CMAKE_SOURCE_DIR}/Core/CMSIS/Include
${CMAKE_SOURCE_DIR}/Core/CMSIS/Device
${CMAKE_SOURCE_DIR}/Includes
${CMAKE_SOURCE_DIR}/FreeRTOS/include
${CMAKE_SOURCE_DIR}/FreeRTOS/portable/GCC/ARM_CM4F
)
target_compile_definitions(${PROJECT_NAME} PUBLIC STM32F446xx)
# Set compiler options (e.g., enable debugging)
target_compile_options(${PROJECT_NAME} PUBLIC -g)
# Set linker options
target_link_options(${PROJECT_NAME} PUBLIC
-T${LINKER_SCRIPT}
-Wl,-Map=${PROJECT_NAME}.map
-Wl,--print-memory-usage
-Wl,--gc-sections
)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_OBJCOPY} -Obinary ${PROJECT_NAME}.elf ${PROJECT_NAME}.bin
)
add_custom_target(flash
COMMAND st-flash write ${PROJECT_NAME}.bin 0x08000000
COMMAND st-flash reset
)