<?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>How to run app directly after burning bootloader?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/49505/how-to-run-app-directly-after-burning-bootloader</link><description>Hi, 
 
 I am using NRF52832 and SDK 11 
 I tried to include DFU function into the device. I merged bootloader (from modified bootloader example), application, softdevice into one HEX file, and use nRFgo Studio to burn the HEX into the device. But after</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 10 Jul 2019 06:32:12 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/49505/how-to-run-app-directly-after-burning-bootloader" /><item><title>RE: How to run app directly after burning bootloader?</title><link>https://devzone.nordicsemi.com/thread/197494?ContentTypeID=1</link><pubDate>Wed, 10 Jul 2019 06:32:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d16b8ac8-a367-4fb6-b065-eb8f8e6cf6bf</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi, older versions of nrfjprog may require you to specify the device family.&amp;nbsp; But you&amp;#39;re right, 0x3FC00 is for the nRF51 while 0x7F000 is the default address for nRF52. Sorry for the confusion.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to run app directly after burning bootloader?</title><link>https://devzone.nordicsemi.com/thread/197465?ContentTypeID=1</link><pubDate>Tue, 09 Jul 2019 17:17:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c61cd7a8-022b-4951-b1dd-9f511c89d01a</guid><dc:creator>floatcloud</dc:creator><description>&lt;p&gt;Vidar, I add the parameter&amp;nbsp;-f NRF52 then it solved the ERROR.&lt;/p&gt;
&lt;p&gt;Also,&amp;nbsp;&lt;span&gt;--memwr 0x3FC00&amp;nbsp;seems for NRF51? I read the code and found that the address should be&amp;nbsp;0x7F000 for NRF52, correct?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to run app directly after burning bootloader?</title><link>https://devzone.nordicsemi.com/thread/197456?ContentTypeID=1</link><pubDate>Tue, 09 Jul 2019 16:26:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d90f3bb0-ac96-49fe-bd2f-df480a9a23cd</guid><dc:creator>floatcloud</dc:creator><description>&lt;p&gt;I tried&amp;nbsp;nrfjprog -s SerialNumber --memwr 0x3FC00 --val 1, but no luck. Still return&amp;nbsp;&lt;span&gt;ERROR:&amp;nbsp;There is no debugger connected to the PC with the given serial number&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to run app directly after burning bootloader?</title><link>https://devzone.nordicsemi.com/thread/197454?ContentTypeID=1</link><pubDate>Tue, 09 Jul 2019 16:18:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1eea50e4-12d0-4de2-a20f-c2f48f9acfd1</guid><dc:creator>floatcloud</dc:creator><description>&lt;p&gt;Hi Vidar,&lt;/p&gt;
&lt;p&gt;Thanks for your reply.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;But both &amp;quot;nrfjprog --memwr 0x3FC00 --val 1&amp;quot; and &amp;quot;&lt;/span&gt;&lt;span&gt;nrfjprog -r&amp;quot; return ERROR:&amp;nbsp;There is no debugger connected to the PC with the given serial number.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;However, if I use &amp;quot;nrfjprog -f NRF52 --program &amp;quot;C:\myfile.hex&amp;quot; --verify --chiperase&amp;quot; command to program the chip, then it won&amp;#39;t ask about serial number and can sucessfully download the file to the chip.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to run app directly after burning bootloader?</title><link>https://devzone.nordicsemi.com/thread/197400?ContentTypeID=1</link><pubDate>Tue, 09 Jul 2019 13:24:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:395ac8c3-083c-4838-903c-5981dbfb37ab</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;On startup, the bootloader will check if there is a valid app in bank 0 (&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v11.0.0/bledfu_memory_banks.html?cp=5_5_10_4_2_3_3_2_0#bledfu_dual_bank"&gt;memory layout&lt;/a&gt;) by checking the value of p_bootloader_settings-&amp;gt;bank_0 stored in the bootloader settings page @ 0x3FC00. It will&amp;nbsp;only boot the app if the bank code ==&amp;nbsp;BANK_VALID_APP (0x01).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The settings page is managed by the bootloader when you do DFU&amp;nbsp;and it will set the bank0 code to&amp;nbsp;BANK_VALID_APP after a successful application update. However, it will not be set&amp;nbsp;if you program sd+bl+app with a debugger so the bootloader will not know that a valid application is present in bank 0. But you can mark the application as valid by setting the flag manually valid with&amp;nbsp;&lt;a href="https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Command-Line-Tools"&gt;nrfjprog&lt;/a&gt;&amp;nbsp;after you&amp;#39;ve programmed everything&amp;nbsp;:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;gt; nrfjprog --memwr 0x3FC00 --val 1 (BANK_VALID_APP)&lt;/p&gt;
&lt;p&gt;&amp;gt; nrfjprog -r // Reset device - app should start on subsequent boot&lt;/p&gt;
&lt;p&gt;Also, since you are using SDK 11 with nRF52,&amp;nbsp;it&amp;#39;s important that you use a more recent version of system_nrf52.c that includes workaround for errata &lt;a href="https://infocenter.nordicsemi.com/topic/errata_nRF52832_Rev2/ERR/nRF52832/Rev2/latest/anomaly_832_108.html?cp=3_1_1_0_1_30"&gt;#108&lt;/a&gt;. This file is distributed with our &lt;a href="https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-MDK"&gt;MDK&lt;/a&gt;.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to run app directly after burning bootloader?</title><link>https://devzone.nordicsemi.com/thread/197214?ContentTypeID=1</link><pubDate>Mon, 08 Jul 2019 18:00:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ee545562-a616-4f6e-bc2b-04905e52a72b</guid><dc:creator>floatcloud</dc:creator><description>&lt;p&gt;&lt;span&gt;I tried to get rid of the dfu_start&amp;nbsp; = app_reset; part and test furtuer.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I found that the problem seemed to be caused by function bootloader_app_is_valid(DFU_BANK_0_REGION_START) returns false.&lt;/p&gt;
&lt;p&gt;And anyone knows how to fix this?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to run app directly after burning bootloader?</title><link>https://devzone.nordicsemi.com/thread/197209?ContentTypeID=1</link><pubDate>Mon, 08 Jul 2019 16:56:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:badaf181-afed-4609-8a3d-0d846e3089c3</guid><dc:creator>floatcloud</dc:creator><description>&lt;p&gt;Does it have something to do with the bootloader code here:&amp;nbsp; &amp;nbsp; dfu_start&amp;nbsp; = app_reset;&amp;nbsp; &amp;nbsp;?&lt;/p&gt;
&lt;p&gt;Sorry I am not very familiar with the bootloader code.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to run app directly after burning bootloader?</title><link>https://devzone.nordicsemi.com/thread/197207?ContentTypeID=1</link><pubDate>Mon, 08 Jul 2019 16:52:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d3f6c99c-f7ea-46e0-a22b-81a33a292a60</guid><dc:creator>floatcloud</dc:creator><description>&lt;p&gt;My full bootloader code here:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;#define IS_SRVC_CHANGED_CHARACT_PRESENT 1&amp;nbsp;&lt;/p&gt;
&lt;p&gt;#define BOOTLOADER_BUTTON BSP_BUTTON_3&lt;br /&gt;#define UPDATE_IN_PROGRESS_LED BSP_LED_2&lt;/p&gt;
&lt;p&gt;#define APP_TIMER_PRESCALER 0&amp;nbsp;&lt;br /&gt;#define APP_TIMER_OP_QUEUE_SIZE 4&lt;/p&gt;
&lt;p&gt;#define SCHED_MAX_EVENT_DATA_SIZE MAX(APP_TIMER_SCHED_EVT_SIZE, 0)&amp;nbsp;&lt;/p&gt;
&lt;p&gt;#define SCHED_QUEUE_SIZE 20&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;void assert_nrf_callback(uint16_t line_num, const uint8_t * p_file_name)&lt;br /&gt;{&lt;br /&gt; app_error_handler(0xDEADBEEF, line_num, p_file_name);&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;static void leds_init(void)&lt;br /&gt;{&lt;br /&gt; nrf_gpio_range_cfg_output(LED_START, LED_STOP);&lt;br /&gt; nrf_gpio_pins_set(LEDS_MASK);&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;static void timers_init(void)&lt;br /&gt;{&lt;br /&gt; APP_TIMER_APPSH_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, true);&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;static void buttons_init(void)&lt;br /&gt;{&lt;br /&gt; nrf_gpio_cfg_sense_input(BOOTLOADER_BUTTON,&lt;br /&gt; BUTTON_PULL, &lt;br /&gt; NRF_GPIO_PIN_SENSE_LOW);&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;static void sys_evt_dispatch(uint32_t event)&lt;br /&gt;{&lt;br /&gt; pstorage_sys_event_handler(event);&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;static void ble_stack_init(bool init_softdevice)&lt;br /&gt;{&lt;br /&gt; uint32_t err_code;&lt;br /&gt; sd_mbr_command_t com = {SD_MBR_COMMAND_INIT_SD, };&lt;br /&gt; nrf_clock_lf_cfg_t clock_lf_cfg = NRF_CLOCK_LFCLKSRC;&lt;/p&gt;
&lt;p&gt;if (init_softdevice)&lt;br /&gt; {&lt;br /&gt; err_code = sd_mbr_command(&amp;amp;com);&lt;br /&gt; APP_ERROR_CHECK(err_code);&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; err_code = sd_softdevice_vector_table_base_set(BOOTLOADER_REGION_START);&lt;br /&gt; APP_ERROR_CHECK(err_code);&lt;br /&gt; &lt;br /&gt; SOFTDEVICE_HANDLER_APPSH_INIT(&amp;amp;clock_lf_cfg, true);&lt;/p&gt;
&lt;p&gt;&lt;br /&gt; ble_enable_params_t ble_enable_params;&lt;br /&gt;&lt;br /&gt; err_code = softdevice_enable_get_default_config(1, 1, &amp;amp;ble_enable_params);&lt;br /&gt; APP_ERROR_CHECK(err_code);&lt;/p&gt;
&lt;p&gt;ble_enable_params.gatts_enable_params.service_changed = IS_SRVC_CHANGED_CHARACT_PRESENT;&lt;br /&gt; err_code = softdevice_enable(&amp;amp;ble_enable_params);&lt;br /&gt; APP_ERROR_CHECK(err_code);&lt;br /&gt; &lt;br /&gt; err_code = softdevice_sys_evt_handler_set(sys_evt_dispatch);&lt;br /&gt; APP_ERROR_CHECK(err_code);&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;static void scheduler_init(void)&lt;br /&gt;{&lt;br /&gt; APP_SCHED_INIT(SCHED_MAX_EVENT_DATA_SIZE, SCHED_QUEUE_SIZE);&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;int main(void)&lt;br /&gt;{&lt;br /&gt; uint32_t err_code;&lt;br /&gt; bool dfu_start = false;&lt;br /&gt; bool app_reset = (NRF_POWER-&amp;gt;GPREGRET == BOOTLOADER_DFU_START);&lt;/p&gt;
&lt;p&gt;if (app_reset)&lt;br /&gt; {&lt;br /&gt; NRF_POWER-&amp;gt;GPREGRET = 0;&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; leds_init();&lt;/p&gt;
&lt;p&gt;&lt;br /&gt; APP_ERROR_CHECK_BOOL(*((uint32_t *)NRF_UICR_BOOT_START_ADDRESS) == BOOTLOADER_REGION_START);&lt;br /&gt; APP_ERROR_CHECK_BOOL(NRF_FICR-&amp;gt;CODEPAGESIZE == CODE_PAGE_SIZE);&lt;/p&gt;
&lt;p&gt;&lt;br /&gt; timers_init();&lt;br /&gt; buttons_init();&lt;/p&gt;
&lt;p&gt;(void)bootloader_init();&lt;/p&gt;
&lt;p&gt;if (bootloader_dfu_sd_in_progress())&lt;br /&gt; {&lt;br /&gt; nrf_gpio_pin_clear(UPDATE_IN_PROGRESS_LED);&lt;/p&gt;
&lt;p&gt;err_code = bootloader_dfu_sd_update_continue();&lt;br /&gt; APP_ERROR_CHECK(err_code);&lt;/p&gt;
&lt;p&gt;ble_stack_init(!app_reset);&lt;br /&gt; scheduler_init();&lt;/p&gt;
&lt;p&gt;err_code = bootloader_dfu_sd_update_finalize();&lt;br /&gt; APP_ERROR_CHECK(err_code);&lt;/p&gt;
&lt;p&gt;nrf_gpio_pin_set(UPDATE_IN_PROGRESS_LED);&lt;br /&gt; }&lt;br /&gt; else&lt;br /&gt; {&lt;br /&gt;&lt;br /&gt; ble_stack_init(!app_reset);&lt;br /&gt; scheduler_init();&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;dfu_start = app_reset;&lt;br /&gt;&lt;br /&gt; &lt;br /&gt; &lt;br /&gt; &lt;br /&gt; if (dfu_start || (!bootloader_app_is_valid(DFU_BANK_0_REGION_START)))&lt;br /&gt; {&lt;br /&gt; nrf_gpio_pin_clear(UPDATE_IN_PROGRESS_LED);&lt;/p&gt;
&lt;p&gt;&lt;br /&gt; err_code = bootloader_dfu_start();&lt;br /&gt; APP_ERROR_CHECK(err_code);&lt;/p&gt;
&lt;p&gt;nrf_gpio_pin_set(UPDATE_IN_PROGRESS_LED);&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;if (bootloader_app_is_valid(DFU_BANK_0_REGION_START) &amp;amp;&amp;amp; !bootloader_dfu_sd_in_progress())&lt;br /&gt; {&lt;br /&gt;&lt;br /&gt; bootloader_app_start(DFU_BANK_0_REGION_START);&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; NVIC_SystemReset();&lt;br /&gt;}&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>