diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2016-09-04 22:12:32 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2016-09-04 22:12:32 +0200 |
commit | d807f0ab00ec7b833c8688f0b08b7ecdf9b8d52b (patch) | |
tree | 6e913d0effc92483b0f4110b7003e81aea425bad | |
download | mcu.cmake-d807f0ab00ec7b833c8688f0b08b7ecdf9b8d52b.tar.gz mcu.cmake-d807f0ab00ec7b833c8688f0b08b7ecdf9b8d52b.tar.bz2 mcu.cmake-d807f0ab00ec7b833c8688f0b08b7ecdf9b8d52b.tar.xz mcu.cmake-d807f0ab00ec7b833c8688f0b08b7ecdf9b8d52b.zip |
o Initial import of mcu.cmake containing old Intel Quark D2000 cmake code and new NRF51 code.
The Intel code is not useful and the NRF code needs to be updated to support NRF52 chips.
-rw-r--r-- | README.md | 51 | ||||
-rw-r--r-- | intel-quark-d2000.cmake | 207 | ||||
-rw-r--r-- | intel/d2000.cmake | 11 | ||||
-rw-r--r-- | intel/gdb.cmake | 4 | ||||
-rw-r--r-- | intel/intel.tmp.txt | 48 | ||||
-rw-r--r-- | intel/openocd.cmake | 6 | ||||
-rw-r--r-- | intel/qmsi.cmake | 27 | ||||
-rw-r--r-- | mcu.cmake | 9 | ||||
-rw-r--r-- | nrf51.cmake | 25 | ||||
-rw-r--r-- | nrf51/utils.cmake | 74 |
10 files changed, 462 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..2e9ab8f --- /dev/null +++ b/README.md @@ -0,0 +1,51 @@ +# About + +`mcu.cmake` is a CMake library/toolchain helping with integrating the chip vendors SDKs into your CMake-based builds. + +## Goals and considerations + +* Make microcontroller projects look and feel as much as possible as any other c/c++ project +* Use as much as possible of the chip vendor's SDK +* Make the CMake code as uniform as feasible between platforms, but allow for platform-specific options and features. + +# Recommended layout + +For single target builds: + + * A top-level CMake file for your project that sets the current target. + * A copy of mcu.cmake under the project directory + * A single build directory + + + /CMakeLists.txt + /mcu.cmake/ + /build/ + +To build the project the developers would execute something like this: + + git clone --recursive + mkdir build + cd build + cmake .. + +For builds that can build for different targets: + + * A top-level CMake file with all general rules + * A copy of mcu.cmake under the project directory + * A per-configuration settings file that is used when creating the build directory + * A build directory per configuration + + + /CMakeLists.txt + /mcu.cmake/ + /target-a.cmake + /target-b.cmake + /build-a + /build-b + +To build the project the developers would execute something like this: + + git clone --recursive + mkdir build + cd build + cmake -C ../target-a.cmake .. diff --git a/intel-quark-d2000.cmake b/intel-quark-d2000.cmake new file mode 100644 index 0000000..03925a7 --- /dev/null +++ b/intel-quark-d2000.cmake @@ -0,0 +1,207 @@ +if (${INTEL_QUARK_TOOLCHAIN_LOADED}) + return() +endif () +set(INTEL_QUARK_TOOLCHAIN_LOADED TRUE) + +include(CMakeForceCompiler) + +set(TRIPLE "i586-intel-elfiamcu") + +if (NOT IS_DIRECTORY "${ISSM_DIR}") + message(FATAL_ERROR "ISSM_DIR has to be set to a directory:" ${ISSM_DIR}) + set(ISSM_DIR CACHE PATH "The path to Intes ISSM") +endif () + +if (NOT INTEL_QUARK_CHIP) + set(INTEL_QUARK_CHIP CACHE STRING "The Intel Quark chip to build for") + message(FATAL_ERROR "INTEL_QUARK_CHIP has to be set before including the toolchain file") +endif () + +get_filename_component(toolchain_dir "${CMAKE_TOOLCHAIN_FILE}" DIRECTORY) + +macro(export_variable NAME) + set(${NAME} "${${NAME}}" PARENT_SCOPE) +endmacro() + +set(CMAKE_SYSTEM_NAME Generic) +set(CMAKE_SYSTEM_PROCESSOR intel) +set(CMAKE_CROSSCOMPILING 1) + +set(TARGET_FLAGS "-march=lakemont -mtune=lakemont -miamcu -msoft-float") +set(BASE_FLAGS "-std=c90 -Wall -Wextra -Werror -Wno-unused-parameter") + +set(INCLUDES "") + +# TODO: these directories should be validated +#list(APPEND includes "${ISSM_DIR}/firmware/bsp/1.0/include") +#list(APPEND includes "${ISSM_DIR}/firmware/bsp/1.0/board/drivers") + +if (INTEL_QUARK_CHIP STREQUAL D2000) + include("${toolchain_dir}/intel/d2000.cmake") + d2000_init() + + include("${toolchain_dir}/intel/openocd.cmake") + openocd_init() + + include("${toolchain_dir}/intel/gdb.cmake") + gdb_init() + + include("${toolchain_dir}/intel/qmsi.cmake") + qmsi_init() +elseif (INTEL_QUARK_CHIP STREQUAL SE) +# list(APPEND includes "${ISSM_DIR}/firmware/bsp/1.0/soc/quark_se/include") +endif () + +# IPP Library +#file(GLOB_RECURSE ipp_sources ${ISSM_DIR}/firmware/lib/ipp/1.0.0/*.c) +add_library(ipp STATIC IMPORTED) +set_property(TARGET ipp PROPERTY IMPORTED_LOCATION "${ISSM_DIR}/firmware/lib/ipp/1.0.0/lib/libippsq.a") +#target_include_directories(ipp PUBLIC "${ISSM_DIR}/firmware/lib/ipp/1.0.0/include") +set_property(TARGET ipp APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${ISSM_DIR}/firmware/lib/ipp/1.0.0/include") +#target_compile_definitions(ipp PUBLIC -D__IPP_ENABLED__) +#target_compile_options(ipp PUBLIC -Wno-empty-body) +#target_link_libraries(ipp INTERFACE qmsi) + +# Compilation +# -O0 +# -g +# -DDEBUG +# -fmessage-length=0 +# -I../include +# -fno-asynchronous-unwind-tables +# -I../drivers +# -I../drivers/include +# +# -DSPI_IRQ_MST +# -I../soc/quark_d2000/include +# -c +# -o ../drivers/debug/quark_d2000/obj/qm_i2c.o +# ../drivers/qm_i2c.c + +# Linking +# i586-intel-elfiamcu-gcc +# -nostdlib +# -L./bsp/build/debug/quark_d2000/libqmsi/lib +# -Xlinker -T./bsp/soc/quark_d2000/quark_d2000.ld +# -Xlinker -A +# -Xlinker --oformat +# -Xlinker -Map=./debug/quark_d2000/obj/accel_test.map +# -o ./debug/quark_d2000/obj/accel_test.elf +# ./debug/quark_d2000/obj/main.o +# ./bsp/sys/debug/quark_d2000/obj/app_entry.o +# ./bsp/sys/debug/quark_d2000/obj/newlib-syscalls.o +# ./bsp/board/drivers/debug/quark_d2000/obj/bmc150.o +# -L/home/trygvis/intel/issm_2016.0.019/firmware/lib/ipp/1.0.0/lib +# -lippsq +# -lc +# -lnosys +# -lsoftfp +# -lgcc +# -lqmsi + +set(o_level "$<TARGET_PROPERTY:O_LEVEL>") +add_compile_options("$<$<BOOL:${o_level}>:-O${o_level}>$<$<NOT:$<BOOL:${o_level}>>:-O3>") +unset(o_level) + +#include_directories("${includes}") +set(CMAKE_C_FLAGS "${BASE_FLAGS} ${TARGET_FLAGS} " CACHE STRING "c flags") +set(CMAKE_CXX_FLAGS "${BASE_FLAGS} ${TARGET_FLAGS} -fno-exceptions -fno-rtti -felide-constructors -std=c++14" CACHE STRING "c++ flags") + +# ${CMAKE_C_FLAGS} is prepended to this string +set(LD_FILE) +set(linker_flags "") +set(linker_flags "${linker_flags} -nostdlib") +set(linker_flags "${linker_flags} -Xlinker -A") +set(linker_flags "${linker_flags} -Xlinker --oformat") + +#set(LINKER_LIBS "-larm_cortexM4l_math -lm") + +# http://stackoverflow.com/questions/16588097/cmake-separate-linker-and-compiler-flags +set(CMAKE_EXE_LINKER_FLAGS "${linker_flags}" CACHE STRING "linker flags" FORCE) +#unset(linker_flags) + +set(GCC "${ISSM_DIR}/tools/compiler/bin/${TRIPLE}-gcc") +#set(GCC "/usr/bin/clang++-3.9") + +if (NOT EXISTS "${GCC}") + message(FATAL_ERROR "Could not find ${TRIPLE}-gcc. Is $ISSM_DIR set correctly?") +endif () + +# No C++ support for D2000 +# set(GXX "${ISSM_DIR}/tools/compiler/bin/${TRIPLE}-g++") +# if(NOT EXISTS "${GXX}") +# message(FATAL_ERROR "Could not find ${TRIPLE}-g++. Is $ISSM_DIR set correctly?") +# endif() +# cmake_force_cxx_compiler("${GXX}" GNU) + +cmake_force_c_compiler("${GCC}" GNU) +#cmake_force_c_compiler("${GCC}" LLVM) + +# search for programs in the build elfinfo directories +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +# for libraries and headers in the target directories +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +function(toolchain_target TARGET) + add_dependencies("${TARGET}" elfinfo) + target_link_libraries("${TARGET}" PUBLIC ipp) + target_link_libraries("${TARGET}" PUBLIC softfp) + target_link_libraries("${TARGET}" PUBLIC c) + target_link_libraries("${TARGET}" PUBLIC g) + target_compile_definitions("${TARGET}" PUBLIC -D__IPP_ENABLED__) + target_link_libraries("${TARGET}" PUBLIC "-Xlinker" "-T${ld_file}") +endfunction() + +# elfinfo tools + +get_filename_component(ELFINFO_SOURCE_DIR "${toolchain_dir}/elfinfo" ABSOLUTE) +get_filename_component(ELFINFO_INSTALL_DIR "${CMAKE_BINARY_DIR}/elfinfo" ABSOLUTE) + +include(ExternalProject) +ExternalProject_Add(elfinfo + SOURCE_DIR "${ELFINFO_SOURCE_DIR}" + DOWNLOAD_COMMAND "" + UPDATE_COMMAND "" + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${ELFINFO_INSTALL_DIR}) + +function(add_extra_commands target_name) + # add_custom_command(TARGET ${target_name} POST_BUILD + # COMMAND mkdir -p ${target_name}-info && arm-none-eabi-objdump -D ${target_name} > ${target_name}-info/${target_name}.asm) + # add_custom_command(TARGET ${target_name} POST_BUILD + # COMMAND mkdir -p ${target_name}-info && arm-none-eabi-nm -C ${target_name} > ${target_name}-info/${target_name}.nm) + # add_custom_command(TARGET ${target_name} POST_BUILD + # COMMAND mkdir -p ${target_name}-info && arm-none-eabi-size ${target_name} > ${target_name}-info/${target_name}.size) + # add_custom_command(TARGET ${target_name} POST_BUILD + # COMMAND mkdir -p ${target_name}-info && arm-none-eabi-readelf -a ${target_name} > ${target_name}-info/${target_name}.readelf) + # add_custom_command(TARGET ${target_name} POST_BUILD + # COMMAND mkdir -p ${target_name}-info && arm-none-eabi-objcopy -O ihex ${target_name} ${target_name}-info/${target_name}.hex) + # add_custom_command(TARGET ${target_name} POST_BUILD + # COMMAND mkdir -p ${target_name}-info && arm-none-eabi-objcopy -O binary ${target_name} ${target_name}-info/${target_name}.bin) + + foreach(area ${mcu_text_areas}) + set(text_segments "${text_segments}" "-t" "${area}") + endforeach() + foreach(area ${mcu_data_areas}) + set(data_segments "${data_segments}" "-d" "${area}") + endforeach() + + add_custom_command(TARGET ${target_name} DEPENDS elfinfo POST_BUILD + COMMAND "${ELFINFO_INSTALL_DIR}/bin/elfinfo" -f ${target_name} ${text_segments} ${data_segments}) + + add_custom_target(${target_name}-openocd + DEPENDS ${target_name} + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" + COMMAND ${openocd_bin} -s ${openocd_scripts} -f board/quark_d2000_onboard.cfg) + + add_custom_target(${target_name}-gdb + DEPENDS ${target_name} + COMMAND ${gdb_bin} + -ex "target remote localhost:3333" + -ex "monitor gdb_breakpoint_override hard" + -ex "set remotetimeout 30" + -ex "monitor clk32M" + -ex "monitor reset halt" + ${target_name} + ) +endfunction() diff --git a/intel/d2000.cmake b/intel/d2000.cmake new file mode 100644 index 0000000..2ddca80 --- /dev/null +++ b/intel/d2000.cmake @@ -0,0 +1,11 @@ +function(d2000_init) + list(APPEND includes "${ISSM_DIR}/firmware/bsp/1.0/soc/quark_d2000/include") + set(includes "${includes}" PARENT_SCOPE) + set(ld_file "${ISSM_DIR}/firmware/bsp/1.0/soc/quark_d2000/quark_d2000.ld" PARENT_SCOPE) + + list(APPEND mcu_text_areas 0x00180000:20k) + export_variable(mcu_text_areas) + + list(APPEND mcu_data_areas 0x00280000:5k) + export_variable(mcu_data_areas) +endfunction() diff --git a/intel/gdb.cmake b/intel/gdb.cmake new file mode 100644 index 0000000..b6840cb --- /dev/null +++ b/intel/gdb.cmake @@ -0,0 +1,4 @@ +function(gdb_init) + set(gdb_bin "${ISSM_DIR}/tools/debugger/gdb/gdb-ia") + export_variable(gdb_bin) +endfunction() diff --git a/intel/intel.tmp.txt b/intel/intel.tmp.txt new file mode 100644 index 0000000..f028e68 --- /dev/null +++ b/intel/intel.tmp.txt @@ -0,0 +1,48 @@ +22:58:42 **** Build of configuration build_debug for project accel_test **** +make +APP_NAME = accel_test +SOC = quark_d2000 +APP_DIR = . +BUILD = debug +make -C ./bsp/drivers SOC=quark_d2000 +make[1]: Entering directory '/home/trygvis/intel/workspace/accel_test/bsp/drivers' +BUILD = debug +i586-intel-elfiamcu-gcc -O0 -g -DDEBUG -std=c90 -Wall -Wextra -Werror -Wno-unused-parameter -fmessage-length=0 -I../include -fno-asynchronous-unwind-tables -I../drivers -I../drivers/include -march=lakemont -mtune=lakemont -miamcu -msoft-float -DSPI_IRQ_MST -I../soc/quark_d2000/include -c -o ../drivers/debug/quark_d2000/obj/qm_flash.o ../drivers/qm_flash.c +i586-intel-elfiamcu-gcc -O0 -g -DDEBUG -std=c90 -Wall -Wextra -Werror -Wno-unused-parameter -fmessage-length=0 -I../include -fno-asynchronous-unwind-tables -I../drivers -I../drivers/include -march=lakemont -mtune=lakemont -miamcu -msoft-float -DSPI_IRQ_MST -I../soc/quark_d2000/include -c -o ../drivers/debug/quark_d2000/obj/qm_aon_counters.o ../drivers/qm_aon_counters.c +i586-intel-elfiamcu-gcc -O0 -g -DDEBUG -std=c90 -Wall -Wextra -Werror -Wno-unused-parameter -fmessage-length=0 -I../include -fno-asynchronous-unwind-tables -I../drivers -I../drivers/include -march=lakemont -mtune=lakemont -miamcu -msoft-float -DSPI_IRQ_MST -I../soc/quark_d2000/include -c -o ../drivers/debug/quark_d2000/obj/qm_init.o ../drivers/qm_init.c +i586-intel-elfiamcu-gcc -O0 -g -DDEBUG -std=c90 -Wall -Wextra -Werror -Wno-unused-parameter -fmessage-length=0 -I../include -fno-asynchronous-unwind-tables -I../drivers -I../drivers/include -march=lakemont -mtune=lakemont -miamcu -msoft-float -DSPI_IRQ_MST -I../soc/quark_d2000/include -c -o ../drivers/debug/quark_d2000/obj/qm_pinmux.o ../drivers/qm_pinmux.c +i586-intel-elfiamcu-gcc -O0 -g -DDEBUG -std=c90 -Wall -Wextra -Werror -Wno-unused-parameter -fmessage-length=0 -I../include -fno-asynchronous-unwind-tables -I../drivers -I../drivers/include -march=lakemont -mtune=lakemont -miamcu -msoft-float -DSPI_IRQ_MST -I../soc/quark_d2000/include -c -o ../drivers/debug/quark_d2000/obj/qm_comparator.o ../drivers/qm_comparator.c +i586-intel-elfiamcu-gcc -O0 -g -DDEBUG -std=c90 -Wall -Wextra -Werror -Wno-unused-parameter -fmessage-length=0 -I../include -fno-asynchronous-unwind-tables -I../drivers -I../drivers/include -march=lakemont -mtune=lakemont -miamcu -msoft-float -DSPI_IRQ_MST -I../soc/quark_d2000/include -c -o ../drivers/debug/quark_d2000/obj/qm_interrupt.o ../drivers/qm_interrupt.c +i586-intel-elfiamcu-gcc -O0 -g -DDEBUG -std=c90 -Wall -Wextra -Werror -Wno-unused-parameter -fmessage-length=0 -I../include -fno-asynchronous-unwind-tables -I../drivers -I../drivers/include -march=lakemont -mtune=lakemont -miamcu -msoft-float -DSPI_IRQ_MST -I../soc/quark_d2000/include -c -o ../drivers/debug/quark_d2000/obj/qm_adc.o ../drivers/qm_adc.c +i586-intel-elfiamcu-gcc -O0 -g -DDEBUG -std=c90 -Wall -Wextra -Werror -Wno-unused-parameter -fmessage-length=0 -I../include -fno-asynchronous-unwind-tables -I../drivers -I../drivers/include -march=lakemont -mtune=lakemont -miamcu -msoft-float -DSPI_IRQ_MST -I../soc/quark_d2000/include -c -o ../drivers/debug/quark_d2000/obj/qm_spi.o ../drivers/qm_spi.c +i586-intel-elfiamcu-gcc -O0 -g -DDEBUG -std=c90 -Wall -Wextra -Werror -Wno-unused-parameter -fmessage-length=0 -I../include -fno-asynchronous-unwind-tables -I../drivers -I../drivers/include -march=lakemont -mtune=lakemont -miamcu -msoft-float -DSPI_IRQ_MST -I../soc/quark_d2000/include -c -o ../drivers/debug/quark_d2000/obj/qm_gpio.o ../drivers/qm_gpio.c +i586-intel-elfiamcu-gcc -O0 -g -DDEBUG -std=c90 -Wall -Wextra -Werror -Wno-unused-parameter -fmessage-length=0 -I../include -fno-asynchronous-unwind-tables -I../drivers -I../drivers/include -march=lakemont -mtune=lakemont -miamcu -msoft-float -DSPI_IRQ_MST -I../soc/quark_d2000/include -c -o ../drivers/debug/quark_d2000/obj/qm_fpr.o ../drivers/qm_fpr.c +i586-intel-elfiamcu-gcc -O0 -g -DDEBUG -std=c90 -Wall -Wextra -Werror -Wno-unused-parameter -fmessage-length=0 -I../include -fno-asynchronous-unwind-tables -I../drivers -I../drivers/include -march=lakemont -mtune=lakemont -miamcu -msoft-float -DSPI_IRQ_MST -I../soc/quark_d2000/include -c -o ../drivers/debug/quark_d2000/obj/qm_rar.o ../drivers/qm_rar.c +i586-intel-elfiamcu-gcc -O0 -g -DDEBUG -std=c90 -Wall -Wextra -Werror -Wno-unused-parameter -fmessage-length=0 -I../include -fno-asynchronous-unwind-tables -I../drivers -I../drivers/include -march=lakemont -mtune=lakemont -miamcu -msoft-float -DSPI_IRQ_MST -I../soc/quark_d2000/include -c -o ../drivers/debug/quark_d2000/obj/qm_pwm.o ../drivers/qm_pwm.c +i586-intel-elfiamcu-gcc -O0 -g -DDEBUG -std=c90 -Wall -Wextra -Werror -Wno-unused-parameter -fmessage-length=0 -I../include -fno-asynchronous-unwind-tables -I../drivers -I../drivers/include -march=lakemont -mtune=lakemont -miamcu -msoft-float -DSPI_IRQ_MST -I../soc/quark_d2000/include -c -o ../drivers/debug/quark_d2000/obj/qm_power.o ../drivers/qm_power.c +i586-intel-elfiamcu-gcc -O0 -g -DDEBUG -std=c90 -Wall -Wextra -Werror -Wno-unused-parameter -fmessage-length=0 -I../include -fno-asynchronous-unwind-tables -I../drivers -I../drivers/include -march=lakemont -mtune=lakemont -miamcu -msoft-float -DSPI_IRQ_MST -I../soc/quark_d2000/include -c -o ../drivers/debug/quark_d2000/obj/qm_uart.o ../drivers/qm_uart.c +i586-intel-elfiamcu-gcc -O0 -g -DDEBUG -std=c90 -Wall -Wextra -Werror -Wno-unused-parameter -fmessage-length=0 -I../include -fno-asynchronous-unwind-tables -I../drivers -I../drivers/include -march=lakemont -mtune=lakemont -miamcu -msoft-float -DSPI_IRQ_MST -I../soc/quark_d2000/include -c -o ../drivers/debug/quark_d2000/obj/qm_identification.o ../drivers/qm_identification.c +i586-intel-elfiamcu-gcc -O0 -g -DDEBUG -std=c90 -Wall -Wextra -Werror -Wno-unused-parameter -fmessage-length=0 -I../include -fno-asynchronous-unwind-tables -I../drivers -I../drivers/include -march=lakemont -mtune=lakemont -miamcu -msoft-float -DSPI_IRQ_MST -I../soc/quark_d2000/include -c -o ../drivers/debug/quark_d2000/obj/qm_pic_timer.o ../drivers/qm_pic_timer.c +i586-intel-elfiamcu-gcc -O0 -g -DDEBUG -std=c90 -Wall -Wextra -Werror -Wno-unused-parameter -fmessage-length=0 -I../include -fno-asynchronous-unwind-tables -I../drivers -I../drivers/include -march=lakemont -mtune=lakemont -miamcu -msoft-float -DSPI_IRQ_MST -I../soc/quark_d2000/include -c -o ../drivers/debug/quark_d2000/obj/qm_scss.o ../drivers/qm_scss.c +i586-intel-elfiamcu-gcc -O0 -g -DDEBUG -std=c90 -Wall -Wextra -Werror -Wno-unused-parameter -fmessage-length=0 -I../include -fno-asynchronous-unwind-tables -I../drivers -I../drivers/include -march=lakemont -mtune=lakemont -miamcu -msoft-float -DSPI_IRQ_MST -I../soc/quark_d2000/include -c -o ../drivers/debug/quark_d2000/obj/qm_rtc.o ../drivers/qm_rtc.c +i586-intel-elfiamcu-gcc -O0 -g -DDEBUG -std=c90 -Wall -Wextra -Werror -Wno-unused-parameter -fmessage-length=0 -I../include -fno-asynchronous-unwind-tables -I../drivers -I../drivers/include -march=lakemont -mtune=lakemont -miamcu -msoft-float -DSPI_IRQ_MST -I../soc/quark_d2000/include -c -o ../drivers/debug/quark_d2000/obj/qm_i2c.o ../drivers/qm_i2c.c +i586-intel-elfiamcu-gcc -O0 -g -DDEBUG -std=c90 -Wall -Wextra -Werror -Wno-unused-parameter -fmessage-length=0 -I../include -fno-asynchronous-unwind-tables -I../drivers -I../drivers/include -march=lakemont -mtune=lakemont -miamcu -msoft-float -DSPI_IRQ_MST -I../soc/quark_d2000/include -c -o ../drivers/debug/quark_d2000/obj/qm_wdt.o ../drivers/qm_wdt.c +i586-intel-elfiamcu-gcc -O0 -g -DDEBUG -std=c90 -Wall -Wextra -Werror -Wno-unused-parameter -fmessage-length=0 -I../include -fno-asynchronous-unwind-tables -I../drivers -I../drivers/include -march=lakemont -mtune=lakemont -miamcu -msoft-float -DSPI_IRQ_MST -I../soc/quark_d2000/include -c -o ../drivers/debug/quark_d2000/obj/qm_mpr.o ../drivers/qm_mpr.c +i586-intel-elfiamcu-ar rcs ../build/debug/quark_d2000/libqmsi/lib/libqmsi.a ../drivers/debug/quark_d2000/obj/qm_flash.o ../drivers/debug/quark_d2000/obj/qm_aon_counters.o ../drivers/debug/quark_d2000/obj/qm_init.o ../drivers/debug/quark_d2000/obj/qm_pinmux.o ../drivers/debug/quark_d2000/obj/qm_comparator.o ../drivers/debug/quark_d2000/obj/qm_interrupt.o ../drivers/debug/quark_d2000/obj/qm_adc.o ../drivers/debug/quark_d2000/obj/qm_spi.o ../drivers/debug/quark_d2000/obj/qm_gpio.o ../drivers/debug/quark_d2000/obj/qm_fpr.o ../drivers/debug/quark_d2000/obj/qm_rar.o ../drivers/debug/quark_d2000/obj/qm_pwm.o ../drivers/debug/quark_d2000/obj/qm_power.o ../drivers/debug/quark_d2000/obj/qm_uart.o ../drivers/debug/quark_d2000/obj/qm_identification.o ../drivers/debug/quark_d2000/obj/qm_pic_timer.o ../drivers/debug/quark_d2000/obj/qm_scss.o ../drivers/debug/quark_d2000/obj/qm_rtc.o ../drivers/debug/quark_d2000/obj/qm_i2c.o ../drivers/debug/quark_d2000/obj/qm_wdt.o ../drivers/debug/quark_d2000/obj/qm_mpr.o +make[1]: Leaving directory '/home/trygvis/intel/workspace/accel_test/bsp/drivers' +i586-intel-elfiamcu-gcc -I/home/trygvis/intel/issm_2016.0.019/firmware/lib/ipp/1.0.0/include -D__IPP_ENABLED__=1 -DPRINTF_ENABLE -DPUTS_ENABLE -O0 -g -DDEBUG -std=c90 -Wall -Wextra -Werror -Wno-unused-parameter -fmessage-length=0 -I./bsp/include -fno-asynchronous-unwind-tables -I./bsp/build/debug/quark_d2000/libqmsi/include -march=lakemont -mtune=lakemont -miamcu -msoft-float -DSPI_IRQ_MST -I./bsp/soc/quark_d2000/include -I./bsp/board/drivers -c -o debug/quark_d2000/obj/main.o main.c +i586-intel-elfiamcu-gcc -I/home/trygvis/intel/issm_2016.0.019/firmware/lib/ipp/1.0.0/include -D__IPP_ENABLED__=1 -DPRINTF_ENABLE -DPUTS_ENABLE -O0 -g -DDEBUG -std=c90 -Wall -Wextra -Werror -Wno-unused-parameter -fmessage-length=0 -I./bsp/include -fno-asynchronous-unwind-tables -I./bsp/build/debug/quark_d2000/libqmsi/include -march=lakemont -mtune=lakemont -miamcu -msoft-float -DSPI_IRQ_MST -I./bsp/soc/quark_d2000/include -I./bsp/board/drivers -c -o bsp/sys/debug/quark_d2000/obj/app_entry.o bsp/sys/app_entry.c +i586-intel-elfiamcu-gcc -I/home/trygvis/intel/issm_2016.0.019/firmware/lib/ipp/1.0.0/include -D__IPP_ENABLED__=1 -DPRINTF_ENABLE -DPUTS_ENABLE -O0 -g -DDEBUG -std=c90 -Wall -Wextra -Werror -Wno-unused-parameter -fmessage-length=0 -I./bsp/include -fno-asynchronous-unwind-tables -I./bsp/build/debug/quark_d2000/libqmsi/include -march=lakemont -mtune=lakemont -miamcu -msoft-float -DSPI_IRQ_MST -I./bsp/soc/quark_d2000/include -I./bsp/board/drivers -c -o bsp/sys/debug/quark_d2000/obj/newlib-syscalls.o bsp/sys/newlib-syscalls.c +i586-intel-elfiamcu-gcc -I/home/trygvis/intel/issm_2016.0.019/firmware/lib/ipp/1.0.0/include -D__IPP_ENABLED__=1 -DPRINTF_ENABLE -DPUTS_ENABLE -O0 -g -DDEBUG -std=c90 -Wall -Wextra -Werror -Wno-unused-parameter -fmessage-length=0 -I./bsp/include -fno-asynchronous-unwind-tables -I./bsp/build/debug/quark_d2000/libqmsi/include -march=lakemont -mtune=lakemont -miamcu -msoft-float -DSPI_IRQ_MST -I./bsp/soc/quark_d2000/include -I./bsp/board/drivers -c -o bsp/board/drivers/debug/quark_d2000/obj/bmc150.o bsp/board/drivers/bmc150/bmc150.c +i586-intel-elfiamcu-gcc -nostdlib -L./bsp/build/debug/quark_d2000/libqmsi/lib -Xlinker -T./bsp/soc/quark_d2000/quark_d2000.ld \ + -Xlinker -A \ + -Xlinker --oformat \ + -Xlinker -Map=./debug/quark_d2000/obj/accel_test.map \ + -o ./debug/quark_d2000/obj/accel_test.elf ./debug/quark_d2000/obj/main.o ./bsp/sys/debug/quark_d2000/obj/app_entry.o ./bsp/sys/debug/quark_d2000/obj/newlib-syscalls.o ./bsp/board/drivers/debug/quark_d2000/obj/bmc150.o -L/home/trygvis/intel/issm_2016.0.019/firmware/lib/ipp/1.0.0/lib -lippsq -lc -lnosys -lsoftfp -lgcc -lqmsi +i586-intel-elfiamcu-size ./debug/quark_d2000/obj/accel_test.elf + text data bss dec hex filename + 17659 716 304 18679 48f7 ./debug/quark_d2000/obj/accel_test.elf +i586-intel-elfiamcu-objcopy -O binary ./debug/quark_d2000/obj/accel_test.elf debug/quark_d2000/bin/accel_test.bin + +22:58:43 Build Finished (took 1s.121ms) + diff --git a/intel/openocd.cmake b/intel/openocd.cmake new file mode 100644 index 0000000..e7ce892 --- /dev/null +++ b/intel/openocd.cmake @@ -0,0 +1,6 @@ +function(openocd_init) + set(openocd_bin "${ISSM_DIR}/tools/debugger/openocd/bin/openocd") + export_variable(openocd_bin) + set(openocd_scripts "${ISSM_DIR}/tools/debugger/openocd/scripts") + export_variable(openocd_scripts) +endfunction() diff --git a/intel/qmsi.cmake b/intel/qmsi.cmake new file mode 100644 index 0000000..0cffa5e --- /dev/null +++ b/intel/qmsi.cmake @@ -0,0 +1,27 @@ +function(qmsi_init) +endfunction() + +function(qmsi_create TARGET_SUFFIX) + set(qmsi qmsi_${TARGET_SUFFIX}) + set(bmc qmsi_bmc_${TARGET_SUFFIX}) + message("Creating QMSI targets ${qmsi} and ${bmc}") + + file(GLOB_RECURSE qmsi_sources + ${ISSM_DIR}/firmware/bsp/1.0/drivers/*.c + ${ISSM_DIR}/firmware/bsp/1.0/sys/*.c) + add_library(${qmsi} STATIC ${qmsi_sources}) + target_include_directories(${qmsi} PUBLIC "${ISSM_DIR}/firmware/bsp/1.0/include") + target_include_directories(${qmsi} PUBLIC "${ISSM_DIR}/firmware/bsp/1.0/drivers/include") + + message("INTEL_QUARK_CHIP=${INTEL_QUARK_CHIP}") + if (INTEL_QUARK_CHIP STREQUAL D2000) + target_include_directories(${qmsi} PUBLIC "${ISSM_DIR}/firmware/bsp/1.0/soc/quark_d2000/include") + elseif (INTEL_QUARK_CHIP STREQUAL SE) + target_include_directories(${qmsi} PUBLIC "${ISSM_DIR}/firmware/bsp/1.0/soc/quark_se/include") + endif () + + file(GLOB_RECURSE bmc_sources ${ISSM_DIR}/firmware/bsp/1.0/board/drivers/bmc150/*.c) + add_library(${bmc} STATIC ${bmc_sources}) + target_link_libraries(${bmc} PUBLIC ${qmsi}) + target_include_directories(${bmc} PUBLIC "${ISSM_DIR}/firmware/bsp/1.0/board/drivers") +endfunction() diff --git a/mcu.cmake b/mcu.cmake new file mode 100644 index 0000000..e5408b4 --- /dev/null +++ b/mcu.cmake @@ -0,0 +1,9 @@ +if (NOT MCU_CHIP) + message(FATAL_ERROR "Missing required argument CHIP.") +elseif (MCU_CHIP MATCHES nrf51822) + set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/nrf51.cmake") +elseif (MCU_CHIP MATCHES D2000) + set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/intel-quark-d2000.toolchain.cmake") +else () + message(FATAL_ERROR "Unsupported MCU_CHIP setting: ${MCU_CHIP}") +endif () diff --git a/nrf51.cmake b/nrf51.cmake new file mode 100644 index 0000000..4145f91 --- /dev/null +++ b/nrf51.cmake @@ -0,0 +1,25 @@ +set(MCU_NRF51_LOADED TRUE CACHE BOOL INTERNAL) + +include(${CMAKE_CURRENT_LIST_DIR}/nrf51/utils.cmake) + +mcu_nrf51_detect_sdk() + +find_program(ARM_CC arm-none-eabi-gcc ${TOOLCHAIN_DIR}/bin) +find_program(ARM_CXX arm-none-eabi-g++ ${TOOLCHAIN_DIR}/bin) +find_program(ARM_OBJCOPY arm-none-eabi-objcopy ${TOOLCHAIN_DIR}/bin) +find_program(ARM_SIZE_TOOL arm-none-eabi-size ${TOOLCHAIN_DIR}/bin) + +#message("ARM_CC=${ARM_CC}") +#message("ARM_CXX=${ARM_CXX}") +#message("ARM_OBJCOPY=${ARM_OBJCOPY}") +#message("ARM_SIZE_TOOL=${ARM_SIZE_TOOL}") + +# Old style, before 3.6 +#include(CMakeForceCompiler) +#CMAKE_FORCE_C_COMPILER(${ARM_CC} GNU) +#CMAKE_FORCE_CXX_COMPILER(${ARM_CXX} GNU) + +# New style, 3.6+ +set(CMAKE_C_COMPILER ${ARM_CC}) +set(CMAKE_CXX_COMPILER ${ARM_CXX}) +set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) diff --git a/nrf51/utils.cmake b/nrf51/utils.cmake new file mode 100644 index 0000000..ec92b78 --- /dev/null +++ b/nrf51/utils.cmake @@ -0,0 +1,74 @@ +function(mcu_add_executable TARGET) + target_sources(${TARGET} PUBLIC + "${MCU_NRF51_SDK_PATH}/components/toolchain/system_nrf51.c" + "${MCU_NRF51_SDK_PATH}/components/toolchain/gcc/gcc_startup_nrf51.S") + target_include_directories(${TARGET} PUBLIC + ${MCU_NRF51_SDK_PATH}/components/device + ${MCU_NRF51_SDK_PATH}/components/toolchain + ${MCU_NRF51_SDK_PATH}/components/toolchain/gcc) + + target_compile_definitions(${TARGET} PUBLIC NRF51) + + target_compile_options(${TARGET} PUBLIC "-mcpu=cortex-m0" "-mthumb" "-mabi=aapcs" "--std=gnu99" "-Wall" "-mfloat-abi=soft") + + target_include_directories(${TARGET} PUBLIC + ${MCU_NRF51_SDK_PATH}/components/toolchain/cmsis/include) + + target_link_libraries(${TARGET} PUBLIC "-L${MCU_NRF51_SDK_PATH}/components/toolchain/gcc") + target_link_libraries(${TARGET} PUBLIC "-T${MCU_NRF51_SDK_PATH}/components/toolchain/gcc/nrf51_xxac.ld") +endfunction() + +function(mcu_nrf51_add_softdevice TARGET SOFTDEVICE) + + if (SOFTDEVICE STREQUAL s130) + string(TOUPPER D_SOFTDEVICE ${SOFTDEVICE}) + target_include_directories(${TARGET} PUBLIC ${MCU_NRF51_SDK_PATH}/components/softdevice/${SOFTDEVICE}/headers) + else () + message(FATAL_ERROR "Unsupported softdevice: ${SOFTDEVICE}") + endif () + + target_compile_definitions(${TARGET} PUBLIC ${D_SOFTDEVICE}) + target_compile_definitions(${TARGET} PUBLIC SOFTDEVICE_PRESENT) +endfunction() + +# Toolchain files are executed many times when detecting c/c++ compilers, but it will only read the cache on the first +# exeuction so the paths has to be saved to the environment as it is shared between executions. +function(mcu_nrf51_detect_sdk) + if (MCU_NRF51_SDK_PATH) + # message("NRF51 SDK already found: ${MCU_NRF51_SDK_PATH}") + return() + endif () + + set(MCU_NRF51_SDK_PATH "$ENV{_MCU_NRF51_SDK_PATH}") + + if (MCU_NRF51_SDK_PATH) + # message("NRF51 SDK already found from ENV: ${MCU_NRF51_SDK_PATH}") + return() + endif () + + message("Detecting NRF51 SDK") + + if (NOT MCU_NRF51_SDK) + message(FATAL_ERROR "MCU_NRF51_SDK parameter cannot be empty.") + endif () + + # message("MCU_NRF51_SDK=${MCU_NRF51_SDK}") + get_filename_component(MCU_NRF51_SDK_PATH "${MCU_NRF51_SDK}" ABSOLUTE) + # message("MCU_NRF51_SDK_PATH=${MCU_NRF51_SDK_PATH}") + + set(ENV{_MCU_NRF51_SDK_PATH} "${MCU_NRF51_SDK_PATH}") + + set(NOTES ${MCU_NRF51_SDK_PATH}/documentation/release_notes.txt) + + if (NOT EXISTS ${NOTES}) + message(FATAL_ERROR "Could not find 'documentation/release_notes.txt' under NRF SDK path: ${NOTES}") + endif () + + file(READ ${NOTES} NOTES LIMIT 100) + + # message("NOTES: ${NOTES}") + message("MCU_NRF51_SDK_VERSION: ${MCU_NRF51_VERSION}") + + # string(SUBSTRING <string> <begin> <length> <output variable>) + set(MCU_NRF51_SDK_PATH "${MCU_NRF51_SDK_PATH}" CACHE PATH "" FORCE) +endfunction() |