Skip to content

Commit

Permalink
Added basic setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Teivaz committed Jan 15, 2020
0 parents commit 69c23cb
Show file tree
Hide file tree
Showing 12 changed files with 16,022 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
20 changes: 20 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Cortex Debug",
"cwd": "${workspaceRoot}",
"executable": "./build/program.elf",
"request": "launch",
"type": "cortex-debug",
"servertype": "openocd",
"svdFile": "STM32L0x1.svd",
"configFiles": [
"board.cfg"
]
}
]
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"C_Cpp.default.configurationProvider": "vector-of-bool.cmake-tools"
}
63 changes: 63 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
cmake_minimum_required(VERSION 3.12)

set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/toolchain.cmake")

project("cmake-stm32")

set(CMAKE_C_STANDARD "99")
enable_language(ASM)

file(GLOB_RECURSE sources "src/*.[c|s]")

add_executable("${PROJECT_NAME}" ${sources})
set_target_properties("${PROJECT_NAME}" PROPERTIES OUTPUT_NAME "program.elf")

set(c_compile_definitions "STM32L011xx")
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
list(APPEND c_compile_definitions "DEBUG" "_DEBUG")
else()
list(APPEND c_compile_definitions "NDEBUG")
endif()

set(asm_compile_options
"-mcpu=cortex-m0plus"
"-g3"
"-c"
"-x"
"assembler-with-cpp"
"--specs=nano.specs"
"-mfloat-abi=soft"
"-mthumb"
)

set(c_compile_options
"-mcpu=cortex-m0plus"
"-std=gnu99"
"-g3"
"-c"
"-O0"
"-ffunction-sections"
"-fdata-sections"
"-Wall"
"-fstack-usage"
"--specs=nano.specs"
"-mfloat-abi=soft"
"-mthumb"
)

set(link_flags
"-mcpu=cortex-m0plus \
-T\"${CMAKE_CURRENT_LIST_DIR}/stm32l011f4.ld\" \
--specs=nosys.specs -Wl,-Map=\"${PROJECT_NAME}.map\" \
-Wl,--gc-sections \
-static \
--specs=nano.specs \
-mfloat-abi=soft \
-mthumb \
-Wl,--start-group -lc -lm -Wl,--end-group"
)

target_compile_options("${PROJECT_NAME}" PUBLIC "$<$<COMPILE_LANGUAGE:C>:${c_compile_options}>")
target_compile_options("${PROJECT_NAME}" PUBLIC "$<$<COMPILE_LANGUAGE:ASM>:${asm_compile_options}>")
target_compile_definitions("${PROJECT_NAME}" PUBLIC "$<$<COMPILE_LANGUAGE:C>:${c_compile_definitions}>")
set_target_properties("${PROJECT_NAME}" PROPERTIES LINK_FLAGS "${link_flags}")
Loading

0 comments on commit 69c23cb

Please sign in to comment.