<?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>Custom service + DFU</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/23410/custom-service-dfu</link><description>I&amp;#39;ve used DFU alongside with HRS and it seems to work fine. 
 This time I&amp;#39;m using a custom service and I&amp;#39;m trying to add a DFU alongside. They just don&amp;#39;t seem to play well together. 
 How can a custom service mess up the DFU service? I&amp;#39;ve been through</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 12 Jul 2017 04:12:32 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/23410/custom-service-dfu" /><item><title>RE: Custom service + DFU</title><link>https://devzone.nordicsemi.com/thread/92011?ContentTypeID=1</link><pubDate>Wed, 12 Jul 2017 04:12:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9f00a579-1897-4218-813a-b8d388fb8f85</guid><dc:creator>ypearson</dc:creator><description>&lt;p&gt;Fixed, thanks for responding to my question :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Custom service + DFU</title><link>https://devzone.nordicsemi.com/thread/92013?ContentTypeID=1</link><pubDate>Tue, 11 Jul 2017 13:19:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:abf0bb44-0c85-4447-b90c-5de1e1885a40</guid><dc:creator>ypearson</dc:creator><description>&lt;p&gt;I just re-started the merge now it works, I was just a lot more methodical this time around (it only took 3 tries). I&amp;#39;m using SDK 12.2, so the bootloader libs need to be updated&lt;/p&gt;
&lt;p&gt;Here were the steps (see other posts about modifying the bootloader files)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;modified:   sdk/components/ble/ble_services/ble_dfu/ble_dfu.c
modified:   sdk/components/libraries/bootloader/ble_dfu/nrf_ble_dfu.c
modified:   sdk/components/libraries/bootloader/dfu/nrf_dfu.c
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Add missing C files for my particular project:&lt;/p&gt;
&lt;p&gt;$(SDK_ROOT)/components/libraries/scheduler/app_scheduler.c &lt;br /&gt;
$(SDK_ROOT)/components/libraries/crc32/crc32.c &lt;br /&gt;
$(SDK_ROOT)/components/libraries/fds/fds.c &lt;br /&gt;
$(SDK_ROOT)/components/libraries/util/sdk_mapped_flags.c &lt;br /&gt;
$(PROJ_DIR)/nrf_dfu_flash_buttonless.c &lt;br /&gt;
$(SDK_ROOT)/components/ble/common/ble_conn_state.c &lt;br /&gt;
$(SDK_ROOT)/components/ble/ble_services/ble_dfu/ble_dfu.c &lt;br /&gt;
$(SDK_ROOT)/components/ble/peer_manager/gatt_cache_manager.c &lt;br /&gt;
$(SDK_ROOT)/components/ble/peer_manager/gatts_cache_manager.c &lt;br /&gt;
$(SDK_ROOT)/components/ble/peer_manager/id_manager.c &lt;br /&gt;
$(SDK_ROOT)/components/ble/nrf_ble_gatt/nrf_ble_gatt.c &lt;br /&gt;
$(SDK_ROOT)/components/ble/peer_manager/peer_data.c &lt;br /&gt;
$(SDK_ROOT)/components/ble/peer_manager/peer_data_storage.c &lt;br /&gt;
$(SDK_ROOT)/components/ble/peer_manager/peer_database.c &lt;br /&gt;
$(SDK_ROOT)/components/ble/peer_manager/peer_id.c &lt;br /&gt;
$(SDK_ROOT)/components/ble/peer_manager/peer_manager.c &lt;br /&gt;
$(SDK_ROOT)/components/ble/peer_manager/pm_buffer.c &lt;br /&gt;
$(SDK_ROOT)/components/ble/peer_manager/pm_mutex.c &lt;br /&gt;
$(SDK_ROOT)/components/ble/peer_manager/security_dispatcher.c &lt;br /&gt;
$(SDK_ROOT)/components/ble/peer_manager/security_manager.c \&lt;/p&gt;
&lt;p&gt;I believe the peer manger stuff is needed for DFU just for the fds_init() call&lt;/p&gt;
&lt;p&gt;Edit sdk_config.h to add these changes:&lt;/p&gt;
&lt;p&gt;#define CRC32_ENABLED 1
#define PEER_MANAGER_ENABLED 1
#define APP_SCHEDULER_ENABLED 1
#define FDS_ENABLED 1&lt;/p&gt;
&lt;p&gt;Next is to add DFU service to my custom service module&lt;/p&gt;
&lt;p&gt;Add the following stock functions (body not pasted here):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void advertising_start(void)
static void ble_dfu_evt_handler(ble_dfu_t * p_dfu, ble_dfu_evt_t * p_evt)
static void pm_evt_handler(pm_evt_t const * p_evt)
static void sys_evt_dispatch(uint32_t sys_evt)
static void peer_manager_init(bool erase_bonds)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Add the following to ble_stack_init&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; ble_enable_params.common_enable_params.vs_uuid_count   = 2;
// Register with the SoftDevice handler module for BLE events.
err_code = softdevice_sys_evt_handler_set(sys_evt_dispatch);
APP_ERROR_CHECK(err_code);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Add the following to services_init()&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ble_dfu_init_t dfus_init;

// Initialize the Device Firmware Update Service.
memset(&amp;amp;dfus_init, 0, sizeof(dfus_init));

dfus_init.evt_handler                               = ble_dfu_evt_handler;
dfus_init.ctrl_point_security_req_write_perm        = SEC_SIGNED;
dfus_init.ctrl_point_security_req_cccd_write_perm   = SEC_SIGNED;

err_code = ble_dfu_init(&amp;amp;m_dfus, &amp;amp;dfus_init);
APP_ERROR_CHECK(err_code);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Add the following to vle_evt_dispatch()&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ble_dfu_on_ble_evt(&amp;amp;m_dfus, p_ble_evt);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Add the following to the BLE init function call&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;peer_manager_init(true);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Update the linker script&lt;/p&gt;
&lt;p&gt;SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)&lt;/p&gt;
&lt;p&gt;MEMORY
{
FLASH (rx) : ORIGIN = 0x1f000, LENGTH = 0x59000
RAM (rwx) :  ORIGIN = 0x20002138, LENGTH = 0xdec8
BOOTLOADER_SETTINGS (rw) : ORIGIN = 0x0007F000, LENGTH = 0x1000
}&lt;/p&gt;
&lt;p&gt;SECTIONS
{
.bootloaderSettings(NOLOAD) :
{&lt;/p&gt;
&lt;p&gt;} &amp;gt; BOOTLOADER_SETTINGS&lt;/p&gt;
&lt;p&gt;.fs_data :
{
PROVIDE(__start_fs_data = .);
KEEP(&lt;em&gt;(.fs_data))
PROVIDE(__stop_fs_data = .);
} &amp;gt; RAM
.pwr_mgmt_data :
{
PROVIDE(__start_pwr_mgmt_data = .);
KEEP(&lt;/em&gt;(.pwr_mgmt_data))
PROVIDE(__stop_pwr_mgmt_data = .);
} &amp;gt; RAM
} INSERT AFTER .data;&lt;/p&gt;
&lt;p&gt;INCLUDE &amp;quot;nrf5x_common.ld&amp;quot;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Custom service + DFU</title><link>https://devzone.nordicsemi.com/thread/92012?ContentTypeID=1</link><pubDate>Tue, 11 Jul 2017 10:22:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2d9f9b83-bdc1-4e11-8775-6a9e93552366</guid><dc:creator>himanshu pande</dc:creator><description>&lt;p&gt;Then what exactly is the error you get?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Custom service + DFU</title><link>https://devzone.nordicsemi.com/thread/92008?ContentTypeID=1</link><pubDate>Tue, 11 Jul 2017 09:04:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f0a2471f-6e1c-498b-ba76-29158c833610</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Could you elaborate on what you mean by &amp;quot;they do not play well together&amp;quot;? Do you get any error codes when you try to add the DFU service?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Custom service + DFU</title><link>https://devzone.nordicsemi.com/thread/92010?ContentTypeID=1</link><pubDate>Tue, 11 Jul 2017 02:35:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eb2f5b31-97c4-4a3f-8bfc-af7050e4faa8</guid><dc:creator>ypearson</dc:creator><description>&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Yep, changed to 2&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;I think I got that setup right, but perhaps not (The linker script works ok with DFU &amp;amp; HRS)&lt;/p&gt;
&lt;p&gt;FLASH (rx) : ORIGIN = 0x1f000, LENGTH = 0x59000
RAM (rwx) :  ORIGIN = 0x20002138, LENGTH = 0xdec8
BOOTLOADER_SETTINGS (rw) : ORIGIN = 0x0007F000, LENGTH = 0x1000&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Yep, got that too&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;4)Yep got that too&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Custom service + DFU</title><link>https://devzone.nordicsemi.com/thread/92009?ContentTypeID=1</link><pubDate>Tue, 11 Jul 2017 01:31:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:057391ec-b983-4b16-bf87-11c3ec276b27</guid><dc:creator>himanshu pande</dc:creator><description>&lt;p&gt;Here are the steps I used to get DFU service working with a custom profile:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Make sure you bump the uuid count by 1 for the DFU.(Guess you have already done that)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Make sure linker is adjusted to accommodate the increase in size because of the DFU service
(The softdevice flashes a warning with amount of adjustment to be made)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Make sure you get the nrf_dfu_flash_buttonless.c compiled along with the rest of your files&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;ble_dfu_init is called from your services_init and ble_dfu_on_ble_evt is added to your ble_evt_dispatch&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>