<?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>sdk 12 bootloader erased after programming</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/17358/sdk-12-bootloader-erased-after-programming</link><description>Hi, 
 I&amp;#39;m trying to load the secure_debug bootloader for the nrf52 with the SD 132 3.0 and an aplication.
But when I load the aplication the bootloader gets erased or overwritten...
I&amp;#39;m using Keil, and my process is:
1-Program the softdevice 3.
2</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 02 Dec 2016 10:42:33 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/17358/sdk-12-bootloader-erased-after-programming" /><item><title>RE: sdk 12 bootloader erased after programming</title><link>https://devzone.nordicsemi.com/thread/66741?ContentTypeID=1</link><pubDate>Fri, 02 Dec 2016 10:42:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b2f59e3a-489f-4741-946f-9cc2b2fc6902</guid><dc:creator>Aleksander Nowakowski</dc:creator><description>&lt;p&gt;Some other bugs I found in the experimental buttonless module:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;The characteristic should have the Write property.
Add:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;char_md.char_props.write = 1;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;to ble_dfu.c file after line 90.&lt;/p&gt;
&lt;ol start="2"&gt;
&lt;li&gt;Change:&lt;/li&gt;
&lt;/ol&gt;
&lt;blockquote&gt;
&lt;p&gt;if (rsp_code == BLE_DFU_ENTER_BOOTLOADER
&amp;amp;&amp;amp; p_evt_write-&amp;gt;data[0] == BLE_DFU_ENTER_BOOTLOADER)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;to&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;if (rsp_code == DFU_RSP_SUCCESS
&amp;amp;&amp;amp; p_evt_write-&amp;gt;data[0] == BLE_DFU_ENTER_BOOTLOADER)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;in the same file around line 249. BLE_DFU_ENTER_BOOTLOADER and DFU_RSP_SUCCESS accidentally have the same value = 0x01.&lt;/p&gt;
&lt;p&gt;Optional:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Try to ignore methods documentation :) It has texts like this: &amp;quot;Handle write events to the &lt;strong&gt;Location and Navigation Service Control Point&lt;/strong&gt; characteristic.&amp;quot; or &amp;quot;Function for adding &lt;strong&gt;RX&lt;/strong&gt; characteristic.&amp;quot;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Rename &lt;em&gt;rx_char_add&lt;/em&gt; method. The name was copied from UART example, which has RX characteristic. I would say cp_char_add (control_point) would be better.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: sdk 12 bootloader erased after programming</title><link>https://devzone.nordicsemi.com/thread/66740?ContentTypeID=1</link><pubDate>Wed, 02 Nov 2016 11:37:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7234d5f0-421a-4ad0-a050-a92bc3510c42</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Happy to help :) I would appreciate if you could mark the answer as correct/accepted by clicking the checkmark in the circle to the left of the answer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: sdk 12 bootloader erased after programming</title><link>https://devzone.nordicsemi.com/thread/66739?ContentTypeID=1</link><pubDate>Wed, 02 Nov 2016 11:33:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4342ad6d-a741-4aec-83c0-4b368482c3c2</guid><dc:creator>vea45</dc:creator><description>&lt;p&gt;Perfect! This was the bug! Now the code don&amp;#39;t overwrites the bootloader! Thank you!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: sdk 12 bootloader erased after programming</title><link>https://devzone.nordicsemi.com/thread/66738?ContentTypeID=1</link><pubDate>Thu, 27 Oct 2016 13:11:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:94ba670f-207a-4462-a49e-9f5bf1d034bd</guid><dc:creator>vea45</dc:creator><description>&lt;p&gt;First I flash the SD and then the bootloader, on the nrfGo the bootloader appears with 32kB of size and address: 0x78000, but with the parameters that you said before the aplication overwrites the bootloader anyway...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: sdk 12 bootloader erased after programming</title><link>https://devzone.nordicsemi.com/thread/66737?ContentTypeID=1</link><pubDate>Thu, 27 Oct 2016 13:08:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3b418f6c-5543-470f-94f4-653deed56780</guid><dc:creator>vea45</dc:creator><description>&lt;p&gt;My aplication parameteters are:
IROM1: 0x1F000, 0x59000     IRAM1:0x20002148, 0xDED8.&lt;/p&gt;
&lt;p&gt;My Bootloader parameters for the debug one:
IROM1:0x73000, 0xB000      IRAM1:0x20002C00, 0xD380.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: sdk 12 bootloader erased after programming</title><link>https://devzone.nordicsemi.com/thread/66735?ContentTypeID=1</link><pubDate>Thu, 27 Oct 2016 13:01:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b46b64b1-85b2-42e8-85bb-0c1f6d2f7527</guid><dc:creator>vea45</dc:creator><description>&lt;p&gt;Yes, I&amp;#39;m trying also with the buttonless example...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: sdk 12 bootloader erased after programming</title><link>https://devzone.nordicsemi.com/thread/66734?ContentTypeID=1</link><pubDate>Thu, 27 Oct 2016 11:34:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c083bef8-cb8f-40c6-be95-d1d9b2fa0d55</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Are you using the experimental buttonless example application?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: sdk 12 bootloader erased after programming</title><link>https://devzone.nordicsemi.com/thread/66736?ContentTypeID=1</link><pubDate>Thu, 27 Oct 2016 06:55:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:723d9129-24fd-4cbf-8ad0-48825602b0f4</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;The IROM and IRAM settings for an application using the S132 v3.0.0 with no bootloader are:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;IROM1 Start: 0x1F000 Size: 0x61000
IRAM1 Start: 0x20002128 Size: 0xDED8
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The Secure Bootloader start address is &lt;code&gt;0x78000&lt;/code&gt; and &lt;code&gt;0x1F000&lt;/code&gt; + &lt;code&gt;0x61000&lt;/code&gt; = &lt;code&gt;0x80000&lt;/code&gt;. Thus,  you have to alter the application IROM settings so that the application does not overwrite the bootloader, i.e.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;IROM1 Start: 0x1F000 Size: 0x59000
IRAM1 Start: 0x20002128 Size: 0xDED8
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you&amp;#39;re using GCC you have to alter the application linker script in the armgcc folder, i.e.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;MEMORY
{
  FLASH (rx) : ORIGIN = 0x1f000, LENGTH = 0x59000
  RAM (rwx) :  ORIGIN = 0x20002128, LENGTH = 0xded8
}
&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;p&gt;&lt;strong&gt;EDIT 28.10.16:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Its another bug in the buttonless DFU example. It reserves a codepage at 0x7E000 for MBR parameters, which is not necessary and should not been added.  The nRF52 flash algorithm in Keil will see this and perform a sector erase from 0x7F000 to 0x1F000 before flashing the application.&lt;/p&gt;
&lt;p&gt;Thus, the entire section in nrf_dfu_settings.c may should be commented out. However, be sure that you do &lt;strong&gt;not&lt;/strong&gt; compile the secure bootloader with this section commented out, as it also uses this file!&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#if defined ( NRF52 )

/**@brief   This variable reserves a codepage for mbr parameters, to ensure the compiler doesn&amp;#39;t
 *          locate any code or variables at his location.
 */
    
    
#if defined ( __CC_ARM )

    uint8_t m_mbr_params_page[CODE_PAGE_SIZE]       __attribute__((at(NRF_MBR_PARAMS_PAGE_ADDRESS))) __attribute__((used));

#elif defined ( __GNUC__ )

    uint8_t m_mbr_params_page[CODE_PAGE_SIZE]       __attribute__ ((section(&amp;quot;.mbrParamsPage&amp;quot;)));

#elif defined ( __ICCARM__ )

    __no_init uint8_t m_mbr_params_page[CODE_PAGE_SIZE]     @ NRF_MBR_PARAMS_PAGE_ADDRESS;

#else

    #error Not a valid compiler/linker for m_mbr_params_page placement.

#endif


/**@brief   This variable makes the linker script write the mbr parameters page address to the
 *          UICR register. This value will be written in the HEX file and thus written to the
 *          UICR when the bootloader is flashed into the chip.
 */
 
#if defined ( __CC_ARM )
    uint32_t m_uicr_mbr_params_page_address __attribute__((at(NRF_UICR_MBR_PARAMS_PAGE_ADDRESS)))
                                                    = NRF_MBR_PARAMS_PAGE_ADDRESS;

#elif defined ( __GNUC__ )
    volatile uint32_t m_uicr_mbr_params_page_address    __attribute__ ((section(&amp;quot;.uicrMbrParamsPageAddress&amp;quot;)))
                                                    = NRF_MBR_PARAMS_PAGE_ADDRESS;
#elif defined ( __ICCARM__ )

    __root    const uint32_t m_uicr_mbr_params_page_address @ NRF_UICR_MBR_PARAMS_PAGE_ADDRESS
                                                    = NRF_MBR_PARAMS_PAGE_ADDRESS;

#else

    #error Not a valid compiler/linker for m_mbr_params_page placement.

#endif

#endif // defined ( NRF52 )
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: sdk 12 bootloader erased after programming</title><link>https://devzone.nordicsemi.com/thread/66733?ContentTypeID=1</link><pubDate>Thu, 27 Oct 2016 06:45:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ef0f8635-f7e1-4107-a7a1-95eb526f61c3</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Could you post the IROM and IROM settings (Keil) or the linker script (GCC) for the application?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>