Skip to content

Commit

Permalink
Merge pull request #84 from nanoframework/import-cmake-build
Browse files Browse the repository at this point in the history
Import cmake build
  • Loading branch information
josesimoes authored Jan 26, 2017
2 parents 759ce7c + 7c0883a commit 2400f86
Show file tree
Hide file tree
Showing 118 changed files with 15,200 additions and 62 deletions.
16 changes: 8 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# ignore all ZIP files

*.zip



# ignore stcube_repository folder

stcube_repository/*

# except CMakeLists file

!stcube_repository/CMakeLists.txt

# ignore build folder
build/*

# ignore cmake-variants file (will change frequently per user/board setup, use should derive content from cmake-variants.TEMPLATE.json)
cmake-variants.json

# ignore build folder
# ignore C/C++ launch file (will change frequently per user/board setup, use should derive content from launch.TEMPLATE.json)
.vscode/launch.json

build/*
# ignore cmaketools user preferences file
.vscode/.cmaketools.json
62 changes: 62 additions & 0 deletions .vscode/launch.TEMPLATE.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "name the launch configuration 1 (booter) here",
"type": "cppdbg",
"request": "launch",
"miDebuggerPath": "<path-to-gdb-insie-the-gcc-toolchain-mind-the-forward-slash>",
"targetArchitecture": "ARM",
"program": "${workspaceRoot}/build/nanoBooter.hex",

"setupCommands": [
{"text": "target extended-remote localhost:3333"},
{"text": "monitor reset halt"},
{"text": "monitor flash write_image erase \"${workspaceRoot}/build/nanoBooter.hex\" "},
{"text": "file <path-to-nanoBooter-elf-file-in-the-build-folder-mind-the-forward-slash>"},
{"text": "monitor reset halt"}
],

"customLaunchSetupCommands": [
{"text": "monitor reset halt"}
],

"launchCompleteCommand": "exec-continue",
"debugServerPath": "C:/Program Files (x86)/openocd-0.10.0/bin/openocd.exe",
"debugServerArgs": "-s \"C:/Program Files (x86)/openocd-0.10.0/scripts/\" -f interface/<interface-config-file>.cfg -f board/<board-config-file>.cfg",
"serverStarted": "Info\\ :\\ [\\w\\d\\.]*:\\ hardware",
"filterStderr": true,
"externalConsole": true,
"cwd": "${cwd}"
},

{
"name": "name the launch configuration 2 (CLR) here",
"type": "cppdbg",
"request": "launch",
"miDebuggerPath": "<path-to-gdb-insie-the-gcc-toolchain-mind-the-forward-slash>",
"targetArchitecture": "ARM",
"program": "${workspaceRoot}/build/nanoCLR.hex",

"setupCommands": [
{"text": "target extended-remote localhost:3333"},
{"text": "monitor reset halt"},
{"text": "monitor flash write_image erase \"${workspaceRoot}/build/nanoBooter.hex\" "},
{"text": "file <path-to-nanoCLR-elf-file-in-the-build-folder-mind-the-forward-slash>"},
{"text": "monitor reset halt"}
],

"customLaunchSetupCommands": [
{"text": "monitor reset halt"}
],

"launchCompleteCommand": "exec-continue",
"debugServerPath": "C:/Program Files (x86)/openocd-0.10.0/bin/openocd.exe",
"debugServerArgs": "-s \"C:/Program Files (x86)/openocd-0.10.0/scripts/\" -f interface/<interface-config-file>.cfg -f board/<board-config-file>.cfg",
"serverStarted": "Info\\ :\\ [\\w\\d\\.]*:\\ hardware",
"filterStderr": true,
"externalConsole": true,
"cwd": "${cwd}"
}
]
}
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"cmake.generator": "NMake Makefiles",
"files.associations": {}
}
21 changes: 21 additions & 0 deletions CMake/ChibiOS.CMakeLists.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
cmake_minimum_required(VERSION 2.8.2)

project(ChibiOS-download NONE)

include(ExternalProject)

# download ChibiOS source from official SVN repo
ExternalProject_Add(
ChibiOS
PREFIX ChibiOS
SOURCE_DIR ${CMAKE_BINARY_DIR}/ChibiOS_Source
GIT_REPOSITORY https://github.com/ChibiOS/ChibiOS/
GIT_TAG ${CHIBIOS_GIT_TAG} # target specified branch
GIT_SHALLOW 1 # download only the tip of the branch, not the complete history
TIMEOUT 10
LOG_DOWNLOAD 1
# Disable all other steps
INSTALL_COMMAND ""
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
)
19 changes: 19 additions & 0 deletions CMake/FreeRTOS.CMakeLists.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 2.8.2)

project(FreeRTOS-download NONE)

include(ExternalProject)

# download FreeRTOS source from official SVN repo
ExternalProject_Add(
FreeRTOS
PREFIX FreeRTOS
SOURCE_DIR ${CMAKE_BINARY_DIR}/FreeRTOS_Source
SVN_REPOSITORY ${FREERTOS_SVN_REPOSITORY}/FreeRTOS/Source
TIMEOUT 10
LOG_DOWNLOAD 1
# Disable all other steps
INSTALL_COMMAND ""
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
)
11 changes: 11 additions & 0 deletions CMake/Modules/CHIBIOS_STM32F0xx_GCC_options.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#################################################################
# WHEN ADDING A NEW SERIES add the appropriate GCC options bellow
#################################################################

set(CMAKE_C_FLAGS "-mthumb -mcpu=cortex-m0 -fno-builtin -std=c11 -g -Wall -ffunction-sections -fdata-sections -fomit-frame-pointer -mlong-calls -mabi=aapcs -fno-exceptions -fno-unroll-loops -ftree-vectorize -specs=nano.specs" CACHE INTERNAL "c compiler flags")
set(CMAKE_CXX_FLAGS "-mthumb -mcpu=cortex-m0 -std=c++11 -ffunction-sections -fdata-sections -fomit-frame-pointer -mlong-calls -mabi=aapcs -fno-exceptions -fno-unroll-loops -ftree-vectorize -specs=nano.specs" CACHE INTERNAL "cxx compiler flags")
set(CMAKE_ASM_FLAGS "-c -mthumb -mcpu=cortex-m0 -g -Wa,--no-warn -x assembler-with-cpp " CACHE INTERNAL "asm compiler flags")

set(CMAKE_EXE_LINKER_FLAGS " -mthumb -mcpu=cortex-m0 -static -mabi=aapcs -Wl,-gc-sections" CACHE INTERNAL "executable linker flags")
set(CMAKE_MODULE_LINKER_FLAGS " -mthumb -mcpu=cortex-m0 -specs=nano.specs " CACHE INTERNAL "module linker flags")
set(CMAKE_SHARED_LINKER_FLAGS " -mthumb -mcpu=cortex-m0 -specs=nano.specs " CACHE INTERNAL "shared linker flags")
131 changes: 131 additions & 0 deletions CMake/Modules/CHIBIOS_STM32F0xx_sources.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# from startup_stm32f0xx.mk
# List of the ChibiOS generic STM32F0xx startup and CMSIS files.

################################################################################
# WHEN ADDING A NEW BOARD add the source code file for the STM32F0xx\platform.mk
################################################################################

set(CHIBIOS_PORT_SRCS
# startup code
crt1.c
vectors.c
crt0_v6m.s

nvic.c
hal_lld.c
ext_lld_isr.c
adc_lld.c
can_lld.c
dac_lld.c
stm32_dma.c
ext_lld.c
pal_lld.c
i2c_lld.c
rtc_lld.c
i2s_lld.c
spi_lld.c
gpt_lld.c
icu_lld.c
pwm_lld.c
st_lld.c
serial_lld.c
uart_lld.c
usb_lld.c
wdg_lld.c

# RT
chcore.c
chcore_v6m.c
chcoreasm_v6m.s
)

foreach(SRC_FILE ${CHIBIOS_PORT_SRCS})
set(CHIBIOS_SRC_FILE SRC_FILE-NOTFOUND)
find_file(CHIBIOS_SRC_FILE ${SRC_FILE}
PATHS

${PROJECT_BINARY_DIR}/ChibiOS_Source/os/hal/ports/STM32/STM32F0xx
${PROJECT_BINARY_DIR}/ChibiOS_Source/os/hal/ports/STM32/LLD/ADCv1
${PROJECT_BINARY_DIR}/ChibiOS_Source/os/hal/ports/STM32/LLD/CANv1
${PROJECT_BINARY_DIR}/ChibiOS_Source/os/hal/ports/STM32/LLD/DACv1
${PROJECT_BINARY_DIR}/ChibiOS_Source/os/hal/ports/STM32/LLD/DMAv1
${PROJECT_BINARY_DIR}/ChibiOS_Source/os/hal/ports/STM32/LLD/EXTIv1
${PROJECT_BINARY_DIR}/ChibiOS_Source/os/hal/ports/STM32/LLD/GPIOv2
${PROJECT_BINARY_DIR}/ChibiOS_Source/os/hal/ports/STM32/LLD/I2Cv2
${PROJECT_BINARY_DIR}/ChibiOS_Source/os/hal/ports/STM32/LLD/RTCv2
${PROJECT_BINARY_DIR}/ChibiOS_Source/os/hal/ports/STM32/LLD/SPIv2
${PROJECT_BINARY_DIR}/ChibiOS_Source/os/hal/ports/STM32/LLD/TIMv1
${PROJECT_BINARY_DIR}/ChibiOS_Source/os/hal/ports/STM32/LLD/USARTv2
${PROJECT_BINARY_DIR}/ChibiOS_Source/os/hal/ports/STM32/LLD/USBv1
${PROJECT_BINARY_DIR}/ChibiOS_Source/os/hal/ports/STM32/LLD/xWDGv1

${PROJECT_BINARY_DIR}/ChibiOS_Source/os/hal/ports/common/ARMCMx
${PROJECT_BINARY_DIR}/ChibiOS_Source/os/rt/ports/ARMCMx
${PROJECT_BINARY_DIR}/ChibiOS_Source/os/rt/ports/ARMCMx/compilers/GCC
${PROJECT_BINARY_DIR}/ChibiOS_Source/os/common/ports/ARMCMx/compilers/GCC/

CMAKE_FIND_ROOT_PATH_BOTH
)
# message("${SRC_FILE} >> ${CHIBIOS_SRC_FILE}") # debug helper
list(APPEND CHIBIOS_SOURCES ${CHIBIOS_SRC_FILE})
endforeach()


list(APPEND CHIBIOS_INCLUDE_DIRS ${PROJECT_BINARY_DIR}/ChibiOS_Source/os/common/ports/ARMCMx/devices/STM32F0xx)
list(APPEND CHIBIOS_INCLUDE_DIRS ${PROJECT_BINARY_DIR}/ChibiOS_Source/os/ext/CMSIS/ST/STM32F0xx)

list(APPEND CHIBIOS_INCLUDE_DIRS ${PROJECT_BINARY_DIR}/ChibiOS_Source/os/hal/ports/STM32/LLD/ADCv1)
list(APPEND CHIBIOS_INCLUDE_DIRS ${PROJECT_BINARY_DIR}/ChibiOS_Source/os/hal/ports/STM32/LLD/CANv1)
list(APPEND CHIBIOS_INCLUDE_DIRS ${PROJECT_BINARY_DIR}/ChibiOS_Source/os/hal/ports/STM32/LLD/DACv1)
list(APPEND CHIBIOS_INCLUDE_DIRS ${PROJECT_BINARY_DIR}/ChibiOS_Source/os/hal/ports/STM32/LLD/DMAv1)
list(APPEND CHIBIOS_INCLUDE_DIRS ${PROJECT_BINARY_DIR}/ChibiOS_Source/os/hal/ports/STM32/LLD/EXTIv1)
list(APPEND CHIBIOS_INCLUDE_DIRS ${PROJECT_BINARY_DIR}/ChibiOS_Source/os/hal/ports/STM32/LLD/GPIOv2)
list(APPEND CHIBIOS_INCLUDE_DIRS ${PROJECT_BINARY_DIR}/ChibiOS_Source/os/hal/ports/STM32/LLD/I2Cv2)
list(APPEND CHIBIOS_INCLUDE_DIRS ${PROJECT_BINARY_DIR}/ChibiOS_Source/os/hal/ports/STM32/LLD/RTCv2)
list(APPEND CHIBIOS_INCLUDE_DIRS ${PROJECT_BINARY_DIR}/ChibiOS_Source/os/hal/ports/STM32/LLD/SPIv2)
list(APPEND CHIBIOS_INCLUDE_DIRS ${PROJECT_BINARY_DIR}/ChibiOS_Source/os/hal/ports/STM32/LLD/TIMv1)
list(APPEND CHIBIOS_INCLUDE_DIRS ${PROJECT_BINARY_DIR}/ChibiOS_Source/os/hal/ports/STM32/LLD/USARTv2)
list(APPEND CHIBIOS_INCLUDE_DIRS ${PROJECT_BINARY_DIR}/ChibiOS_Source/os/hal/ports/STM32/LLD/USBv1)
list(APPEND CHIBIOS_INCLUDE_DIRS ${PROJECT_BINARY_DIR}/ChibiOS_Source/os/hal/ports/STM32/LLD/xWDGv1)


#######################################################################################################################################
# WHEN ADDING A NEW BOARD add the respective IF clause bellow along with the default linker file name (without extension)
#######################################################################################################################################

# linker file
if(${CHIBIOS_BOARD} STREQUAL "ST_NUCLEO_F072RB")
set(DEFAULT_LINKER_FILE_NAME "STM32F072xB")
elseif(${CHIBIOS_BOARD} STREQUAL "ST_NUCLEO_F091RC")
set(DEFAULT_LINKER_FILE_NAME "STM32F091xC")
endif()

#######################################################################################################################################
# this function sets the linker options including the default linker file
# if the target uses a specific linker file use the function CHIBIOS_SET_LINKER_OPTIONS_AND_FILE
function(CHIBIOS_SET_LINKER_OPTIONS TARGET)

get_target_property(TARGET_LD_FLAGS ${TARGET} LINK_FLAGS)
if(TARGET_LD_FLAGS)
set(TARGET_LD_FLAGS "-T${PROJECT_BINARY_DIR}/ChibiOS_Source/os/common/ports/ARMCMx/compilers/GCC/ld/${DEFAULT_LINKER_FILE_NAME}.ld ${TARGET_LD_FLAGS}")
else()
set(TARGET_LD_FLAGS "-T${PROJECT_BINARY_DIR}/ChibiOS_Source/os/common/ports/ARMCMx/compilers/GCC/ld/${DEFAULT_LINKER_FILE_NAME}.ld")
endif()
set_target_properties(${TARGET} PROPERTIES LINK_FLAGS ${TARGET_LD_FLAGS})

endfunction()

#######################################################################################################################################
# this function sets the linker options AND a specific linker file (full path and name, including extension)
# if the target uses the default linker file use the function CHIBIOS_SET_LINKER_OPTIONS
function(CHIBIOS_SET_LINKER_OPTIONS_AND_FILE TARGET LINKER_FILE_NAME)

get_target_property(TARGET_LD_FLAGS ${TARGET} LINK_FLAGS)
if(TARGET_LD_FLAGS)
set(TARGET_LD_FLAGS "-T${LINKER_FILE_NAME} ${TARGET_LD_FLAGS}")
else()
set(TARGET_LD_FLAGS "-T${LINKER_FILE_NAME}")
endif()
set_target_properties(${TARGET} PROPERTIES LINK_FLAGS ${TARGET_LD_FLAGS})

endfunction()
11 changes: 11 additions & 0 deletions CMake/Modules/CHIBIOS_STM32F4xx_GCC_options.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#################################################################
# WHEN ADDING A NEW SERIES add the appropriate GCC options bellow
#################################################################

set(CMAKE_C_FLAGS "-mthumb -fno-builtin -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -Wall -std=c11 -w -ffunction-sections -falign-functions=16 -fdata-sections -fsingle-precision-constant -fomit-frame-pointer -mlong-calls -fdollars-in-identifiers -mabi=aapcs -fno-exceptions -fno-unroll-loops -mstructure-size-boundary=8 -ffast-math -ftree-vectorize -specs=nano.specs" CACHE INTERNAL "c compiler flags")
set(CMAKE_CXX_FLAGS "-mthumb -fno-builtin -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -Wall -std=c++11 -w -fcheck-new -fno-rtti -falign-functions=16 -fsingle-precision-constant -fno-use-cxa-atexit -fno-threadsafe-statics -ffunction-sections -fdata-sections -fomit-frame-pointer -mlong-calls -fdollars-in-identifiers -mabi=aapcs -fno-exceptions -fno-unroll-loops -mstructure-size-boundary=8 -ffast-math -ftree-vectorize -specs=nano.specs" CACHE INTERNAL "cxx compiler flags")
set(CMAKE_ASM_FLAGS "-mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -x assembler-with-cpp" CACHE INTERNAL "asm compiler flags")

set(CMAKE_EXE_LINKER_FLAGS " -Wl,--gc-sections -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -mabi=aapcs" CACHE INTERNAL "executable linker flags")
set(CMAKE_MODULE_LINKER_FLAGS " -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -mabi=aapcs" CACHE INTERNAL "module linker flags")
set(CMAKE_SHARED_LINKER_FLAGS " -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -mabi=aapcs" CACHE INTERNAL "shared linker flags")
Loading

0 comments on commit 2400f86

Please sign in to comment.