<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Way to Exclude softdevice and compile, NRF SDK16 example project</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/61007/way-to-exclude-softdevice-and-compile-nrf-sdk16-example-project</link><description>The goal is to be able to automate build using CMake. I am evaluating this by trying to build example project in nrfSDK 16.(I chose saadc example from nRF5_SDK\examples\peripheral\saadc) 
 The CMakeLists file and supporting scripts were taken from this</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 06 May 2020 16:24:29 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/61007/way-to-exclude-softdevice-and-compile-nrf-sdk16-example-project" /><item><title>RE: Way to Exclude softdevice and compile, NRF SDK16 example project</title><link>https://devzone.nordicsemi.com/thread/248538?ContentTypeID=1</link><pubDate>Wed, 06 May 2020 16:24:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:51a3a5fd-82ba-4cc3-bcd2-330888156736</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/1373._5F00_Verify_2D00_answer_2D00_nordic_5F00_2.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Way to Exclude softdevice and compile, NRF SDK16 example project</title><link>https://devzone.nordicsemi.com/thread/248537?ContentTypeID=1</link><pubDate>Wed, 06 May 2020 16:18:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a642c3d6-086d-4299-a0de-68606d6f3e83</guid><dc:creator>bharat</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://devzone.nordicsemi.com/members/awneil"&gt;awneil&lt;/a&gt; and &lt;a href="https://devzone.nordicsemi.com/members/amanda"&gt;Amanda Hsieh&lt;/a&gt;, Thanks for your replies.&lt;/p&gt;
&lt;p&gt;Issue was that, CMake script had the -DSOFTDEVICE_PRESENT &lt;a href="https://cmake.org/cmake/help/v3.0/command/add_definitions.html"&gt;compile definition &lt;/a&gt;flag. Once I got rid of this flag, I could proceed with build and it did not required headers from the softdevice library.&lt;/p&gt;
&lt;p&gt;Using the CMake script below, I was able to generate binaries and hex.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;cmake_minimum_required(VERSION 3.6)

# check if all the necessary tools paths have been provided.
if (NOT NRF5_SDK_PATH)
    message(FATAL_ERROR &amp;quot;The path to the nRF5 SDK (NRF5_SDK_PATH) must be set.&amp;quot;)
endif ()

#if (NOT NRFJPROG)
#    message(FATAL_ERROR &amp;quot;The path to the nrfjprog utility (NRFJPROG) must be set.&amp;quot;)
#endif ()

# convert toolchain path to bin path
if(DEFINED ARM_NONE_EABI_TOOLCHAIN_PATH)
    set(ARM_NONE_EABI_TOOLCHAIN_BIN_PATH ${ARM_NONE_EABI_TOOLCHAIN_PATH}/bin)
endif()

# check if the nRF target has been set
if (NRF_TARGET MATCHES &amp;quot;nrf51&amp;quot;)

elseif (NRF_TARGET MATCHES &amp;quot;nrf52&amp;quot;)

elseif (NOT NRF_TARGET)
    message(FATAL_ERROR &amp;quot;nRF target must be defined&amp;quot;)
else ()
    message(FATAL_ERROR &amp;quot;Only nRF51 and rRF52 boards are supported right now&amp;quot;)
endif ()

# must be set in file (not macro) scope (in macro would point to parent CMake directory)
set(DIR_OF_nRF5x_CMAKE ${CMAKE_CURRENT_LIST_DIR})

macro(nRF5x_toolchainSetup)
    include(${DIR_OF_nRF5x_CMAKE}/arm-gcc-toolchain.cmake)
endmacro()

macro(nRF5x_setup)
    if(NOT DEFINED ARM_GCC_TOOLCHAIN)
        message(FATAL_ERROR &amp;quot;The toolchain must be set up before calling this macro&amp;quot;)
    endif()
    # language standard/version settings
    set(CMAKE_C_STANDARD 99)
    set(CMAKE_CXX_STANDARD 98)

        if(NOT DEFINED NRF5_LINKER_SCRIPT)
            set(NRF5_LINKER_SCRIPT &amp;quot;${CMAKE_SOURCE_DIR}/gcc_nrf52.ld&amp;quot;)
        endif()
        set(CPU_FLAGS &amp;quot;-mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16&amp;quot;)
        add_definitions(-DCONFIG_GPIO_AS_PINRESET -DFLOAT_ABI_HARD -DNRF52840_XXAA -DBOARD_PCA10056 -DBSP_DEFINES_ONLY) 

    set(COMMON_FLAGS &amp;quot; -MP -MD -mthumb -mabi=aapcs -Wall -g3 -ffunction-sections -fdata-sections -fno-strict-aliasing -fno-builtin --short-enums ${CPU_FLAGS}&amp;quot;)

    # compiler/assambler/linker flags
    set(CMAKE_C_FLAGS &amp;quot;${COMMON_FLAGS}&amp;quot;)
    set(CMAKE_C_FLAGS_DEBUG &amp;quot;${CMAKE_C_FLAGS_DEBUG} -O1&amp;quot;)
    set(CMAKE_C_FLAGS_RELEASE &amp;quot;${CMAKE_C_FLAGS_RELEASE} -O3&amp;quot;)
    set(CMAKE_CXX_FLAGS &amp;quot;${COMMON_FLAGS}&amp;quot;)
    set(CMAKE_CXX_FLAGS_DEBUG &amp;quot;${CMAKE_CXX_FLAGS_DEBUG} -O1&amp;quot;)
    set(CMAKE_CXX_FLAGS_RELEASE &amp;quot;${CMAKE_CXX_FLAGS_RELEASE} -O3&amp;quot;)
    set(CMAKE_ASM_FLAGS &amp;quot;-MP -MD -std=c99 -x assembler-with-cpp&amp;quot;)
    


    set(CMAKE_EXE_LINKER_FLAGS &amp;quot;-mthumb -mabi=aapcs -std=gnu++98 -std=c99 -L ${NRF5_SDK_PATH}/modules/nrfx/mdk -T${NRF5_LINKER_SCRIPT} ${CPU_FLAGS} -Wl,--gc-sections --specs=nano.specs -lc -lnosys -lm&amp;quot;)

    # note: we must override the default cmake linker flags so that CMAKE_C_FLAGS are not added implicitly
    set(CMAKE_C_LINK_EXECUTABLE &amp;quot;${CMAKE_C_COMPILER} &amp;lt;LINK_FLAGS&amp;gt; &amp;lt;OBJECTS&amp;gt; -o &amp;lt;TARGET&amp;gt; &amp;lt;LINK_LIBRARIES&amp;gt;&amp;quot;)
    set(CMAKE_CXX_LINK_EXECUTABLE &amp;quot;${CMAKE_C_COMPILER} &amp;lt;LINK_FLAGS&amp;gt; &amp;lt;OBJECTS&amp;gt; -lstdc++ -o &amp;lt;TARGET&amp;gt; &amp;lt;LINK_LIBRARIES&amp;gt;&amp;quot;)

    # basic board definitions and drivers
    include_directories(
            &amp;quot;${NRF5_SDK_PATH}/components&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/modules/nrfx/mdk&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/components/libraries/pwr_mgmt&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/components/libraries/strerror&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/components/toolchain/cmsis/include&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/components/libraries/util&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/components/libraries/balloc&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/components/libraries/ringbuf&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/modules/nrfx/hal&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/components/libraries/bsp&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/components/libraries/log&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/modules/nrfx&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/components/libraries/experimental_section_vars&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/integration/nrfx/legacy&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/components/libraries/mutex&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/components/libraries/delay&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/integration/nrfx&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/components/drivers_nrf/nrf_soc_nosd&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/external/segger_rtt&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/components/boards&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/components/libraries/memobj&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/modules/nrfx/drivers/include&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/components/libraries/log/src&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/external/fprintf&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/components/libraries/atomic&amp;quot;
    )

    list(APPEND SDK_SOURCE_FILES
            &amp;quot;${NRF5_SDK_PATH}/modules/nrfx/mdk/gcc_startup_nrf52.S&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/components/libraries/log/src/nrf_log_backend_rtt.c&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/components/libraries/log/src/nrf_log_backend_serial.c&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/components/libraries/log/src/nrf_log_backend_uart.c&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/components/libraries/log/src/nrf_log_default_backends.c&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/components/libraries/log/src/nrf_log_frontend.c&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/components/libraries/log/src/nrf_log_str_formatter.c&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/components/boards/boards.c&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/components/libraries/util/app_error.c&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/components/libraries/util/app_error_handler_gcc.c&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/components/libraries/util/app_error_weak.c&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/components/libraries/util/app_util_platform.c&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/components/libraries/util/nrf_assert.c&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/components/libraries/atomic/nrf_atomic.c&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/components/libraries/balloc/nrf_balloc.c&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/external/fprintf/nrf_fprintf.c&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/external/fprintf/nrf_fprintf_format.c&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/components/libraries/memobj/nrf_memobj.c&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/components/libraries/pwr_mgmt/nrf_pwr_mgmt.c&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/components/libraries/ringbuf/nrf_ringbuf.c&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/components/libraries/experimental_section_vars/nrf_section_iter.c&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/components/libraries/strerror/nrf_strerror.c&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/integration/nrfx/legacy/nrf_drv_ppi.c&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/integration/nrfx/legacy/nrf_drv_uart.c&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/modules/nrfx/soc/nrfx_atomic.c&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/modules/nrfx/drivers/src/nrfx_ppi.c&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/modules/nrfx/drivers/src/prs/nrfx_prs.c&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/modules/nrfx/drivers/src/nrfx_saadc.c&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/modules/nrfx/drivers/src/nrfx_timer.c&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/modules/nrfx/drivers/src/nrfx_uart.c&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/modules/nrfx/drivers/src/nrfx_uarte.c&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/external/segger_rtt/SEGGER_RTT.c&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/external/segger_rtt/SEGGER_RTT_Syscalls_GCC.c&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/external/segger_rtt/SEGGER_RTT_printf.c&amp;quot;
            &amp;quot;${NRF5_SDK_PATH}/modules/nrfx/mdk/system_nrf52840.c&amp;quot;
            )
endmacro(nRF5x_setup)

# adds a target for comiling and flashing an executable
macro(nRF5x_addExecutable EXECUTABLE_NAME SOURCE_FILES)
    # executable
    add_executable(${EXECUTABLE_NAME} ${SDK_SOURCE_FILES} ${SOURCE_FILES})
    set_target_properties(${EXECUTABLE_NAME} PROPERTIES SUFFIX &amp;quot;.out&amp;quot;)
    #set_target_properties(${EXECUTABLE_NAME} PROPERTIES LINK_FLAGS &amp;quot;-lc -lnosys -lm&amp;quot;)

    # additional POST BUILD setps to create the .bin and .hex files
    add_custom_command(TARGET ${EXECUTABLE_NAME}
            POST_BUILD
            COMMAND ${CMAKE_SIZE_UTIL} ${EXECUTABLE_NAME}.out
            COMMAND ${CMAKE_OBJCOPY} -O binary ${EXECUTABLE_NAME}.out &amp;quot;${EXECUTABLE_NAME}.bin&amp;quot;
            COMMAND ${CMAKE_OBJCOPY} -O ihex ${EXECUTABLE_NAME}.out &amp;quot;${EXECUTABLE_NAME}.hex&amp;quot;
            COMMENT &amp;quot;post build steps for ${EXECUTABLE_NAME}&amp;quot;)
endmacro()

&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This script, tries to mimic the Makefile for the Saadc project as much as possible.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/amanda"&gt;Amanda Hsieh&lt;/a&gt;, now that i have and example built with cmake, I will proceed with cmake for my project with NRF.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Again, Thanks both.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Way to Exclude softdevice and compile, NRF SDK16 example project</title><link>https://devzone.nordicsemi.com/thread/248378?ContentTypeID=1</link><pubDate>Wed, 06 May 2020 09:30:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:df8c719f-a975-4131-928a-413aa192c1a2</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user=""]Is there a way to exclude softdevice and compile this[/quote]
&lt;p&gt;&amp;nbsp;As Andrew&amp;#39;s said, you could not compile the softdevice, but you can the&amp;nbsp;&lt;span&gt;pre-built binary.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]Also, I am successfully able to compile the saadc example using armgcc Makefile at&amp;nbsp;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;nRF5_SDK\examples\peripheral\saadc\pca10056\blank\armgcc\. This file does not include any softdevice and still is able to generate hex files. I am looking for a solution similar to this.&lt;/span&gt;[/quote]
&lt;p&gt;&amp;nbsp;You could use the examples under nRF5_SDK_16.0.0_98a08e2\examples\peripheral&lt;span&gt;\PCA#\&lt;/span&gt;blank. They don&amp;#39;t use the softdevice.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;-Amanda H.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Way to Exclude softdevice and compile, NRF SDK16 example project</title><link>https://devzone.nordicsemi.com/thread/248010?ContentTypeID=1</link><pubDate>Mon, 04 May 2020 18:44:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7249ef20-d5aa-4da1-a22f-d70746ce2011</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;Surely, what that error tells you is that you haven&amp;#39;t set your include paths correctly ?&lt;/p&gt;
[quote userid="90023" url="~/f/nordic-q-a/61007/way-to-exclude-softdevice-and-compile-nrf-sdk16-example-project"]Is there a way to exclude softdevice and compile this[/quote]
&lt;p&gt;This doesn&amp;#39;t make sense.&lt;/p&gt;
&lt;p&gt;The SoftDevice is never part of the build: it is supplied as a pre-built binary - there is nothing to compile!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>