<?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 15.3 Secure Serial UART Bootloader does not handle NRF_DFU_OP_OBJECT_WRITE (data)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/45627/sdk-15-3-secure-serial-uart-bootloader-does-not-handle-nrf_dfu_op_object_write-data</link><description>Hi, 
 I am currently trying to use SDK 15.3 secure serial UART bootloader (from the example in nRF5_SDK_15.3.0_59ac345\examples\dfu\secure_bootloader\pca10040_uart) on a custom chip embedding an nRF52832 and a GSM chip, communicating between themselves</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 03 May 2019 11:48:42 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/45627/sdk-15-3-secure-serial-uart-bootloader-does-not-handle-nrf_dfu_op_object_write-data" /><item><title>RE: SDK 15.3 Secure Serial UART Bootloader does not handle NRF_DFU_OP_OBJECT_WRITE (data)</title><link>https://devzone.nordicsemi.com/thread/185165?ContentTypeID=1</link><pubDate>Fri, 03 May 2019 11:48:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e1548a2f-efd6-431c-a450-c4d4da38263d</guid><dc:creator>Pierre B.</dc:creator><description>&lt;p&gt;The NRF_UARTE -&amp;gt; ERRORSCR register indicates OVERRUN, FRAMING and BREAK error when going into error, so I&amp;#39;m having trouble determining the orignal issue that provoked it.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/7506.uart.JPG" /&gt;&lt;/p&gt;
&lt;p&gt;Ok well if there is no other way with the SDK 15.3 bootloader I&amp;#39;ll do that then.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK 15.3 Secure Serial UART Bootloader does not handle NRF_DFU_OP_OBJECT_WRITE (data)</title><link>https://devzone.nordicsemi.com/thread/185140?ContentTypeID=1</link><pubDate>Fri, 03 May 2019 10:44:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3156250d-9a3a-4cbd-aad0-9dbb12408cf8</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Have you tried to check what the error source is in NRF_UARTE-&amp;gt;ERRORSCR? I think it&amp;#39;s a bit strange that it happens when sending the CRC since you use flow control.&lt;/p&gt;
&lt;p&gt;Yes, you don&amp;#39;t want any padding. Maybe you can re-use some of the buffer handling used in SDK 12.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK 15.3 Secure Serial UART Bootloader does not handle NRF_DFU_OP_OBJECT_WRITE (data)</title><link>https://devzone.nordicsemi.com/thread/185123?ContentTypeID=1</link><pubDate>Fri, 03 May 2019 09:55:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d7b6c27a-8602-4450-b3cc-e4459b52009a</guid><dc:creator>Pierre B.</dc:creator><description>&lt;p&gt;I am using flow control yes. The GSM chip waits for the CRC reception and validation before proceeding with the next step (execute command) also yes, that is how I first detected this issue.&lt;/p&gt;
&lt;p&gt;Ok I will try that and update the results, though I am not sure how to implement this without a zero-padding like solution which would mess with the data.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK 15.3 Secure Serial UART Bootloader does not handle NRF_DFU_OP_OBJECT_WRITE (data)</title><link>https://devzone.nordicsemi.com/thread/185080?ContentTypeID=1</link><pubDate>Fri, 03 May 2019 08:17:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bebb2d7f-f71c-4315-8503-4ba79bad728f</guid><dc:creator>Vidar Berg</dc:creator><description>[quote userid="77752" url="~/f/nordic-q-a/45627/sdk-15-3-secure-serial-uart-bootloader-does-not-handle-nrf_dfu_op_object_write-data/185066"]Did it work on your side with RX_BUF_SIZE = 128 ? Because in this case I have a NRF_DRV_UART_EVT_ERROR when trying to send CRC via UART after the reception of the first 4096 bytes of data.[/quote]
&lt;p&gt;Yes, 128 worked for me.&amp;nbsp;I&amp;#39;m using flow control, are you? When waiting for the CRC, does the GSM controller wait for the CRC and validate it before proceeding with the execute command?&amp;nbsp;&lt;span&gt;NRF_DRV_UART_EVT_ERROR indicate that you received invalid data (framing error,etc)&lt;/span&gt;&lt;/p&gt;
[quote userid="77752" url="~/f/nordic-q-a/45627/sdk-15-3-secure-serial-uart-bootloader-does-not-handle-nrf_dfu_op_object_write-data/185066"]Is there any way to modify the write function so it can work with non-multiple of 4 values for RX_BUF_SIZE and so data packets size (such as 127) ? It was the case in the SDK 12.1 example bootloader.[/quote]
&lt;p&gt;&lt;span&gt;Not the write function itself. The length must be a multiple of 4. But you could create a new buffer for immediate storage of the data, then make sure the data length passed to&amp;nbsp;nrf_fstorage_write is always a multiple of 4.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK 15.3 Secure Serial UART Bootloader does not handle NRF_DFU_OP_OBJECT_WRITE (data)</title><link>https://devzone.nordicsemi.com/thread/185066?ContentTypeID=1</link><pubDate>Fri, 03 May 2019 07:55:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ca6453e4-c113-4a37-a3c7-d53b7e4c5672</guid><dc:creator>Pierre B.</dc:creator><description>&lt;p&gt;Hi, &lt;/p&gt;
&lt;p&gt;Thank you for your answer, I did find out about RX_BUF_SIZE having to be a multiple of 4 (UPDATE of my previous post), and then I also found this PARAM_CHECK line you are talking about, and I was surprised that it does not do anything when RX_BUF_SIZE = 127, because as you said it should have failed there...&lt;/p&gt;
&lt;p&gt;I have two questions from there:&lt;/p&gt;
&lt;p&gt;- Did it work on your side with RX_BUF_SIZE = 128 ? Because in this case I have a NRF_DRV_UART_EVT_ERROR when trying to send CRC via UART after the reception of the first 4096 bytes of data.&lt;/p&gt;
&lt;p&gt;- Is there any way to modify the write function so it can work with non-multiple of 4 values for RX_BUF_SIZE and so data packets size (such as 127) ? It was the case in the SDK 12.1 example bootloader.&lt;/p&gt;
&lt;p&gt;Thank you !&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK 15.3 Secure Serial UART Bootloader does not handle NRF_DFU_OP_OBJECT_WRITE (data)</title><link>https://devzone.nordicsemi.com/thread/185043?ContentTypeID=1</link><pubDate>Fri, 03 May 2019 07:20:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c9523751-a3c8-41d1-9411-4714fe0640a4</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I have tested Softdevice and app update with different MTU sizes but not been able to replicate the hardfault:&lt;/p&gt;
&lt;p&gt;Setup:&lt;/p&gt;
&lt;p&gt;- nrfutil 5.2.0&lt;/p&gt;
&lt;p&gt;- sdk 15.3.0&lt;/p&gt;
&lt;p&gt;- UART Serial bootloader - debug version&lt;/p&gt;
&lt;p&gt;I did, however, observe that the&amp;nbsp;RX_BUF_SIZE is passed as length to nrf_fstorage_write() so the size must be a multiple of 4, the&amp;nbsp;&amp;nbsp;NRF_FSTORAGE_PARAM_CHECK(!(len % p_fs-&amp;gt;p_flash_info-&amp;gt;program_unit), NRF_ERROR_INVALID_LENGTH); check will fail otherwise. Didn&amp;#39;t this check fail on your side when you set the RX_BUF_SIZE to 127?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK 15.3 Secure Serial UART Bootloader does not handle NRF_DFU_OP_OBJECT_WRITE (data)</title><link>https://devzone.nordicsemi.com/thread/183777?ContentTypeID=1</link><pubDate>Thu, 25 Apr 2019 11:45:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:12a13acb-e280-46a2-8716-8f38d0efaece</guid><dc:creator>Pierre B.</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;All right thank you, still working on it on my side also.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK 15.3 Secure Serial UART Bootloader does not handle NRF_DFU_OP_OBJECT_WRITE (data)</title><link>https://devzone.nordicsemi.com/thread/183760?ContentTypeID=1</link><pubDate>Thu, 25 Apr 2019 11:30:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ac8c6aa4-5223-48bc-8267-8c7030c4a937</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thanks for the update. This stack frame looks more correct. I will try to replicate then debug this on my side to see if I can find the root cause. I&amp;#39;ll keep you posted.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK 15.3 Secure Serial UART Bootloader does not handle NRF_DFU_OP_OBJECT_WRITE (data)</title><link>https://devzone.nordicsemi.com/thread/183332?ContentTypeID=1</link><pubDate>Wed, 24 Apr 2019 08:02:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:24094c5f-559b-46d1-97b7-c5d6e3a7c334</guid><dc:creator>Pierre B.</dc:creator><description>&lt;p&gt;Hi Vidar, thank you for your help.&lt;/p&gt;
&lt;p&gt;No progress in the meantime no, I used 100 bytes data packet to continue my project, but it can&amp;#39;t be a final solution...&lt;/p&gt;
&lt;p&gt;By default, a delay of 100 ms is present between every data packet sent by the GSM chip to the NRF52, and I tried increasing this delay (up to 1000ms), but it doesn&amp;#39;t change anything.&lt;/p&gt;
&lt;p&gt;Here are the results shown by the SDK 15.2 Hardfault Handler (I am still going into HardFault when handling, so writing, the second 127 bytes data packet received whith RX_BUF_SIZE = 127):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;lt;error&amp;gt; hardfault: HARD FAULT at 0x00076F90
&amp;lt;error&amp;gt; hardfault:   R0:  0x0263DB00  R1:  0x4001E504  R2:  0x0000001F  R3:  0x00000001
&amp;lt;error&amp;gt; hardfault:   R12: 0x0007AD89  LR:  0x0007ADB9  PSR: 0x81000000
&amp;lt;error&amp;gt; hardfault: Cause: Data bus error (PC value stacked for the exception return points to the instruction that caused the fault).
&amp;lt;error&amp;gt; hardfault: Bus Fault Address: 0x0002607F&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The PC value points to this line in the code:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/PC.JPG" /&gt;&lt;/p&gt;
&lt;p&gt;The LR value points to this line in the code:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/LR.JPG" /&gt;&lt;/p&gt;
&lt;p&gt;And BFAR value, which I&amp;#39;m guessing represents the address where the value should be written:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/BFAR.JPG" /&gt;&lt;/p&gt;
&lt;p&gt;More precisely, the HardFault PC points to the &amp;quot;STR&amp;quot; assembly instruction, that is supposed to store (at the address r5+(r4&amp;lt;&amp;lt;2)) the data and that causes the fault here:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/STR.JPG" /&gt;&lt;/p&gt;
&lt;p&gt;I checked the assembly code for the same C instruction in my SDK 12.1 Serial Bootloader, that works with 127 bytes packets, and I see no difference in the assembly code, except for the registers used:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/Assembly.JPG" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;UPDATE:&lt;/p&gt;
&lt;p&gt;After running some tests, it seems that this issue may have to do with the size of sent data packets, in bytes, being a multiple of 4. It actually works for 124 bytes data packets with RX_BUF_SIZE &amp;gt;= 124. It also works with 128 bytes data packets with RX_BUF_SIZE = 128, but for this precise case I get a NRF_DRV_UART_EVT_ERROR when trying to send CRC via UART after the reception of the first 4096 bytes of data.&lt;/p&gt;
&lt;p&gt;Any reason for a non divisible per 4 size not working ? Could it come from the fact that the packet length is at some point divided by 4 to equal the number of words ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK 15.3 Secure Serial UART Bootloader does not handle NRF_DFU_OP_OBJECT_WRITE (data)</title><link>https://devzone.nordicsemi.com/thread/183299?ContentTypeID=1</link><pubDate>Wed, 24 Apr 2019 05:59:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:330f0098-beb3-4f90-8295-3510a4ddf11e</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Hung asked me to follow up on this case as he&amp;#39;s out of office this week. There has been a while since the last update, have you had any progress in the meantime?&lt;/p&gt;
&lt;p&gt;As a test, I think it would be interesting if you could try adding a delay between every packet on the controller side and see if that makes a difference (w 127 byte MTU). Also, the stack frame from the hardfault handler appears to be incorrect. The LR value is not pointing to a valid address but is a typical value for xPSR.&amp;nbsp;It might be&amp;nbsp;worth trying the hardfault handler included in the SDK, I&amp;#39;m not familiar with the ARM version, but this implementation will detect stack overflow as well.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Do the following to use the SDK Hardfault handler:&lt;/p&gt;
&lt;p&gt;Add&amp;nbsp;&amp;nbsp;&amp;quot;\nRF5_SDK_15.2.0_9412b96\components\libraries\hardfault\nrf52\handler\hardfault_handler_keil.c&amp;quot; and &amp;quot;\nRF5_SDK_15.2.0_9412b96\components\libraries\hardfault\hardfault_implementation.c&amp;quot; to the project and build with&amp;nbsp;&lt;span&gt;HARDFAULT_HANDLER_ENABLED=1&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Vidar&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK 15.3 Secure Serial UART Bootloader does not handle NRF_DFU_OP_OBJECT_WRITE (data)</title><link>https://devzone.nordicsemi.com/thread/181797?ContentTypeID=1</link><pubDate>Fri, 12 Apr 2019 08:44:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ac864f39-f592-4018-8378-b9709b1085ef</guid><dc:creator>Pierre B.</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I agree, hence my update. Serial bootloader + MBR gives me the same hard fault at the same point (second data packet received).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK 15.3 Secure Serial UART Bootloader does not handle NRF_DFU_OP_OBJECT_WRITE (data)</title><link>https://devzone.nordicsemi.com/thread/181795?ContentTypeID=1</link><pubDate>Fri, 12 Apr 2019 08:38:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:82201a48-5af4-45aa-89c5-6fc0198dda1b</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Pierre,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Shouldn&amp;#39;t we focus on solving the 127 bytes byte issue first ? Could you try to test just updating the APP without the SD ?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I&amp;#39;m don&amp;#39;t think we support updating SD+APP from a non-softdevice bootloader. You can merge the softdevice and app and then updating it as an app. But we can solve this after we solve the 127 bytes packet issue.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK 15.3 Secure Serial UART Bootloader does not handle NRF_DFU_OP_OBJECT_WRITE (data)</title><link>https://devzone.nordicsemi.com/thread/181783?ContentTypeID=1</link><pubDate>Fri, 12 Apr 2019 08:02:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7c25d672-a6c4-4ccb-917a-d537debdd720</guid><dc:creator>Pierre B.</dc:creator><description>&lt;p&gt;I tried to do that, problem is I will have an error &lt;strong&gt;NRF_DFU_EXT_ERROR_SD_VERSION_FAILURE&lt;/strong&gt; as the package generated that contains APP+SD (6.1.0) needs a &lt;strong&gt;--sd-req&lt;/strong&gt; &lt;strong&gt;0xXX &lt;/strong&gt;parameter, even though there will be no SoftDevice programmed on my flash, only the MBR. So when comparing the required SD version and the one (not) installed, it throws this error.&lt;/p&gt;
&lt;p&gt;Is there a way to do a APP+SD DFU with only bootloader and MBR programmed ?&lt;/p&gt;
&lt;p&gt;UPDATE:&lt;/p&gt;
&lt;p&gt;It does work if my package only contains SD (6.1.0). So I programmed bootloader settings and MBR hex files on the flash memory using nrfjprog, than launched debug of the bootloader, and I still have the exact same Hard Fault with bootloader + MBR only.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK 15.3 Secure Serial UART Bootloader does not handle NRF_DFU_OP_OBJECT_WRITE (data)</title><link>https://devzone.nordicsemi.com/thread/181684?ContentTypeID=1</link><pubDate>Thu, 11 Apr 2019 15:27:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c132dde9-4409-4368-af23-805b43a80eee</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;That hardfault is more likely an softdevice assert.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Please try to test using the stock serial bootloader + MBR not serial bootloader + softdevice.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK 15.3 Secure Serial UART Bootloader does not handle NRF_DFU_OP_OBJECT_WRITE (data)</title><link>https://devzone.nordicsemi.com/thread/181509?ContentTypeID=1</link><pubDate>Thu, 11 Apr 2019 09:14:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:adce858b-919b-4743-83fd-44506fea32a3</guid><dc:creator>Pierre B.</dc:creator><description>&lt;p&gt;Ok yes thank you debugging works with the SDK 15.2 bootloader.&lt;/p&gt;
&lt;p&gt;So with RX_BUF_SIZE = 127 and the GSM whip sending 127 bytes data packet (so the configuration for which I have this issue), the code get stuck in an infinite loop in an &lt;strong&gt;hardfault_handler &lt;/strong&gt;in the startup file &lt;strong&gt;arm_startup_nrf52.s&lt;/strong&gt; :&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/5657.Capture.JPG" /&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ll try to obtain some more information as to the source that provokes this hardfault.&lt;/p&gt;
&lt;p&gt;UPDATE: I used a code given by ARM in order to get the registers that provoked this HardFault:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;quot;RTE_Components.h&amp;quot;             // Component selection
#include CMSIS_device_header            // Include device header file from
#include &amp;quot;stdio.h&amp;quot;                      // include stdio library for printf output
#include &amp;quot;project_configuration.h&amp;quot;      // Header file for test case configuration

#if HARDFAULT_HANDLER == 1

void HardFault_Handler_C(unsigned long * svc_args, unsigned int lr_value);
 
// HardFault handler wrapper in assembly language.
// It extracts the location of stack frame and passes it to the handler written
// in C as a pointer. We also extract the LR value as second parameter.
__asm void HardFault_Handler(void)
{
	TST    LR, #4
	ITE    EQ
	MRSEQ  R0, MSP
	MRSNE  R0, PSP
	MOV    R1, LR
	B      __cpp(HardFault_Handler_C)
}	
 
 
// HardFault handler in C, with stack frame location and LR value extracted
// from the assembly wrapper as input parameters
void HardFault_Handler_C(unsigned long * hardfault_args, unsigned int lr_value)
{
  unsigned long stacked_r0;
  unsigned long stacked_r1;
  unsigned long stacked_r2;
  unsigned long stacked_r3;
  unsigned long stacked_r12;
  unsigned long stacked_lr;
  unsigned long stacked_pc;
  unsigned long stacked_psr;
  unsigned long cfsr;
  unsigned long bus_fault_address;
  unsigned long memmanage_fault_address;
  
  bus_fault_address       = SCB-&amp;gt;BFAR;
  memmanage_fault_address = SCB-&amp;gt;MMFAR;
  cfsr                    = SCB-&amp;gt;CFSR;
 
  stacked_r0  = ((unsigned long) hardfault_args[0]);
  stacked_r1  = ((unsigned long) hardfault_args[1]);
  stacked_r2  = ((unsigned long) hardfault_args[2]);
  stacked_r3  = ((unsigned long) hardfault_args[3]);
  stacked_r12 = ((unsigned long) hardfault_args[4]);
  stacked_lr  = ((unsigned long) hardfault_args[5]);
  stacked_pc  = ((unsigned long) hardfault_args[6]);
  stacked_psr = ((unsigned long) hardfault_args[7]);
 
  printf (&amp;quot;[HardFault]\n&amp;quot;);
  printf (&amp;quot;- Stack frame:\n&amp;quot;); 
  printf (&amp;quot; R0  = %x\n&amp;quot;, stacked_r0);
  printf (&amp;quot; R1  = %x\n&amp;quot;, stacked_r1);
  printf (&amp;quot; R2  = %x\n&amp;quot;, stacked_r2);
  printf (&amp;quot; R3  = %x\n&amp;quot;, stacked_r3);
  printf (&amp;quot; R12 = %x\n&amp;quot;, stacked_r12);
  printf (&amp;quot; LR  = %x\n&amp;quot;, stacked_lr);
  printf (&amp;quot; PC  = %x\n&amp;quot;, stacked_pc);
  printf (&amp;quot; PSR = %x\n&amp;quot;, stacked_psr);
  printf (&amp;quot;- FSR/FAR:\n&amp;quot;);  
  printf (&amp;quot; CFSR = %x\n&amp;quot;, cfsr);
  printf (&amp;quot; HFSR = %x\n&amp;quot;, SCB-&amp;gt;HFSR);
  printf (&amp;quot; DFSR = %x\n&amp;quot;, SCB-&amp;gt;DFSR);
  printf (&amp;quot; AFSR = %x\n&amp;quot;, SCB-&amp;gt;AFSR);
	if (cfsr &amp;amp; 0x0080) printf (&amp;quot; MMFAR = %x\n&amp;quot;, memmanage_fault_address);
	if (cfsr &amp;amp; 0x8000) printf (&amp;quot; BFAR = %x\n&amp;quot;, bus_fault_address);
  printf (&amp;quot;- Misc\n&amp;quot;); 
  printf (&amp;quot; LR/EXC_RETURN= %x\n&amp;quot;, lr_value);
 	
  while(1); // endless loop
}
#endif
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Results:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/5153.Capture2.JPG" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;SCB -&amp;gt; CFSR = 0x00008200 (&amp;quot;cfsr&amp;quot;)&lt;/p&gt;
&lt;p&gt;PC = 0x00070240 (&amp;quot;stacked_pc&amp;quot;)&lt;/p&gt;
&lt;p&gt;SCB -&amp;gt; BFAR = 0x00074031 (&amp;quot;bus_fault_address&amp;quot;)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So apparently this Hard Fault is forced and actually comes from a Bus Fault, generated at the address BFAR and where at this point PC was 0x0007024.&lt;/p&gt;
&lt;p&gt;This is precisely the moment the code enters &lt;strong&gt;write() &lt;/strong&gt;function from &lt;strong&gt;nrf_fstorage_nvmc.c &lt;/strong&gt;file:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/5280.Capture.JPG" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK 15.3 Secure Serial UART Bootloader does not handle NRF_DFU_OP_OBJECT_WRITE (data)</title><link>https://devzone.nordicsemi.com/thread/181496?ContentTypeID=1</link><pubDate>Thu, 11 Apr 2019 08:51:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f88c418c-deb3-4c63-9f1c-089a1817665e</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;The CPU has to be stalled at some place , right ?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you want to debug I would suggest to start with SDK v15.2 instead of 15.3. In v15.3 we changed the location of the bootloader start address making it slightly harder to re-flash the bootloader. Have a look &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/44768/sdk-15-3-cannot-program-default-bootloader/181430#181430"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To be able to debug you would need to make sure the optimization level is set to 0. If the size of the flash dedicated for bootloader is not big enough you would need to move the bootloader down in the flash address to make more space for it.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK 15.3 Secure Serial UART Bootloader does not handle NRF_DFU_OP_OBJECT_WRITE (data)</title><link>https://devzone.nordicsemi.com/thread/181125?ContentTypeID=1</link><pubDate>Tue, 09 Apr 2019 15:01:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c7d2b18f-38c9-4a1d-ba4b-e75448c05f4d</guid><dc:creator>Pierre B.</dc:creator><description>&lt;p&gt;Thank you for your answer, I tried debug mode indeed in order to see if and where the CPU would be stuck, but for some reason I can&amp;#39;t seem to be able to go into debug mode. I created a ticket for this issue (&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/45910/debugging-serial-uart-bootloader-sdk-15-3"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/45910/debugging-serial-uart-bootloader-sdk-15-3&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;What would be this timing problem you mentioned that could explain the maximum of a 100 bytes size for a data packet ?&lt;/p&gt;
&lt;p&gt;I understand, thank you for your time ! I will also try to work on this debugger issue.&lt;/p&gt;
&lt;p&gt;Though I do think that what my GSM chip is doing as DFU master is exactly the same thing that your Python script does, if you were to use it as DFU master.&lt;/p&gt;
&lt;p&gt;UPDATE: after test, it does not seem that CPU is going to any of the app error handler function.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK 15.3 Secure Serial UART Bootloader does not handle NRF_DFU_OP_OBJECT_WRITE (data)</title><link>https://devzone.nordicsemi.com/thread/181095?ContentTypeID=1</link><pubDate>Tue, 09 Apr 2019 13:49:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9a09f705-db24-484d-9a72-35257e3d48f8</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Yes an MBR is needed for the bootloader to&amp;nbsp;do DFU update itself as well as to receive the interrupt vector forwarding.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you don&amp;#39;t initiate the softdevice (calling sd_mbr_command() with&amp;nbsp;SD_MBR_COMMAND_INIT_SD) , it shouldn&amp;#39;t be a problem to access the flash directly using NVMC.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Note that if you use an GPIO to detect if you can get to point 1 or point 2, you should also check if there is any assertion that interrupt the process. Please check if the CPU get to any of the app error handler function.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Have you tried to test using debug mode ? And the check where the CPU is at when it stuck ?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It&amp;#39;s a little bit harder for us to reproduce the issue here to test what you described (due to that we need to customize the DFU master). We will try to find time to test but it&amp;#39;s a bit busy here.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK 15.3 Secure Serial UART Bootloader does not handle NRF_DFU_OP_OBJECT_WRITE (data)</title><link>https://devzone.nordicsemi.com/thread/180826?ContentTypeID=1</link><pubDate>Mon, 08 Apr 2019 14:53:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6ee90b77-07b8-402c-b138-b050bde62767</guid><dc:creator>Pierre B.</dc:creator><description>&lt;p&gt;Well, SoftDevice 6.1.1 is programmed on the chip before downloading bootloader, because without it bootloader alone doesn&amp;#39;t seem to do anything, but the purpose of this bootloader will be at some point to download and write into memory this SoftDevice 6.1.1 in order to replace an older one. So I guess it is supposed to be able to work without it, and the fact that it can not seem to for now is also an issue.&lt;/p&gt;
&lt;p&gt;Plus my SDK 12.1 serial bootloader was using &lt;strong&gt;nrf_nvmc_write_words()&lt;/strong&gt; also.&lt;/p&gt;
&lt;p&gt;What would be this timing problem ?&lt;/p&gt;
&lt;p&gt;UPDATE: Bootloader works without SoftDevice if I add MBR hex file to bootloader (nRF5_SDK_15.3.0_59ac345\components\softdevice\mbr\nrf52832\hex)&lt;strong&gt;.&lt;/strong&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK 15.3 Secure Serial UART Bootloader does not handle NRF_DFU_OP_OBJECT_WRITE (data)</title><link>https://devzone.nordicsemi.com/thread/180819?ContentTypeID=1</link><pubDate>Mon, 08 Apr 2019 14:35:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fb741836-57ab-4589-8c0f-45160fd8a83f</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Oh, I was not aware that you have the softdevice. Was the softdevice&amp;nbsp;initialized when you call&amp;nbsp;&lt;strong&gt;nrf_nvmc_write_words() ?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;If the softdevice is initialized you would need to nrf_fstorage_sd.c instead of nrf_fstorage_nvmc.c. There could be a chance that the timing needed to write 64 bytes was OK with the softdevice but not 100 bytes.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK 15.3 Secure Serial UART Bootloader does not handle NRF_DFU_OP_OBJECT_WRITE (data)</title><link>https://devzone.nordicsemi.com/thread/180546?ContentTypeID=1</link><pubDate>Fri, 05 Apr 2019 15:22:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ace43e3d-f9c9-4957-bed2-a20e5272f37f</guid><dc:creator>Pierre B.</dc:creator><description>&lt;p&gt;With RX_BUF_SIZE = 127 and GSM chip sending 100 bytes data packets, &lt;strong&gt;m_slip.current_index &lt;br /&gt;&lt;/strong&gt;= 101 bytes, so 100 bytes payload + 1 command byte.&lt;/p&gt;
&lt;p&gt;I agree printing out the log would be preferable but one of my issue previously stated is that I can not: the log is printed with quite an important delay, and as the MCU seems to crash after receiving the 2nd data packet, I can&amp;#39;t access debug logs after a certain point.&lt;/p&gt;
&lt;p&gt;I detect it because my custom board has a buzzer that I can use to know when the code reaches certain points, and I used it on point 1 and point 2. That is kow I know that as some point the code reaches point 1 but never point 2.&lt;/p&gt;
&lt;p&gt;I found the issue is from &lt;strong&gt;nrf_nvmc_write_words ()&lt;/strong&gt; &lt;strong&gt;&lt;/strong&gt;using the method previously stated.&lt;/p&gt;
&lt;p&gt;Could it be a problem related to the presence of a SoftDevice with the bootloader ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK 15.3 Secure Serial UART Bootloader does not handle NRF_DFU_OP_OBJECT_WRITE (data)</title><link>https://devzone.nordicsemi.com/thread/180541?ContentTypeID=1</link><pubDate>Fri, 05 Apr 2019 15:10:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3bb8d4be-cc79-426e-950d-c2dcf1d71771</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;&lt;strong&gt;sizeof(m_slip.p_buffer)&lt;/strong&gt; is only the size of the pointer, not the size of the array, you should find the size of the&amp;nbsp;packet in&amp;nbsp;m_slip.current_index.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;How do you detect that it stuck in point 1 can can&amp;#39;t get to point 2 ? I don&amp;#39;t think it would stuck in&amp;nbsp;wait_for_flash_ready(). It only checks the hardware register and we haven&amp;#39;t seen any case the hardware (writing to flash) wouldn&amp;#39;t work.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I would suggest to print out log instead of line stepping .&lt;/p&gt;
&lt;p&gt;How do you find&amp;nbsp;that the issue is from &lt;strong&gt;nrf_nvmc_write_words () ?&amp;nbsp;&lt;/strong&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK 15.3 Secure Serial UART Bootloader does not handle NRF_DFU_OP_OBJECT_WRITE (data)</title><link>https://devzone.nordicsemi.com/thread/180434?ContentTypeID=1</link><pubDate>Fri, 05 Apr 2019 08:12:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a7aafb96-deec-4150-827a-ff7fe997dfa3</guid><dc:creator>Pierre B.</dc:creator><description>&lt;p&gt;UPDATE: With RX_BUF_SIZE = 127 and GSM chip sending 100 bytes data packets, on_rx_complete() pass to nrf_dfu_serial_on_packet_received() a length of 101 bytes &lt;strong&gt;(m_slip.current_index), &lt;/strong&gt;and the length of m_slip.p_buffer is 4 &lt;strong&gt;(sizeof(m_slip.p_buffer))&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;It also appears that the issue come specifically from &lt;strong&gt;nrf_nvmc_write_words() &lt;/strong&gt;in &lt;strong&gt;nrf_nvmc.c &lt;/strong&gt;file.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static inline void wait_for_flash_ready(void)
{
    while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy) {}
}

...

void nrf_nvmc_write_words(uint32_t address, const uint32_t * src, uint32_t num_words)
{
    uint32_t i;

    // Enable write.
    NRF_NVMC-&amp;gt;CONFIG = NVMC_CONFIG_WEN_Wen;
    __ISB();
    __DSB();
    
    //Point 1
    
    for (i = 0; i &amp;lt; num_words; i++)
    {
        ((uint32_t*)address)[i] = src[i];
        wait_for_flash_ready();
    }

    //Point 2
    
    NRF_NVMC-&amp;gt;CONFIG = NVMC_CONFIG_WEN_Ren;
    __ISB();
    __DSB();
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The first time nRF52 receives a 127 bytes data packet with WRITE command (line 30 of the GSM log), code gets to //&lt;strong&gt;P&lt;/strong&gt;&lt;strong&gt;oint 1 &lt;/strong&gt;and to //&lt;strong&gt;P&lt;/strong&gt;&lt;strong&gt;oint 2&lt;/strong&gt; without any visible issue. But for the second packet (line 32 of the GSM log), code gets to &lt;strong&gt;//Point 1 &lt;/strong&gt;but never to &lt;strong&gt;//Point2. &lt;/strong&gt;It would seem that it is stuck waiting for flash to be ready this time.&lt;/p&gt;
&lt;p&gt;Any possible reason for that ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK 15.3 Secure Serial UART Bootloader does not handle NRF_DFU_OP_OBJECT_WRITE (data)</title><link>https://devzone.nordicsemi.com/thread/180360?ContentTypeID=1</link><pubDate>Thu, 04 Apr 2019 15:31:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5ee366b2-179b-432b-9df9-4efd7d8ba26f</guid><dc:creator>Pierre B.</dc:creator><description>&lt;p&gt;So apparently, whatever the value of RX_BUF_SIZE (127 or higher), the max length in bytes of data packet I can send is between 100 and 110 per packet. It works with 100 bytes data packets, but not with 110 bytes data packets.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK 15.3 Secure Serial UART Bootloader does not handle NRF_DFU_OP_OBJECT_WRITE (data)</title><link>https://devzone.nordicsemi.com/thread/180340?ContentTypeID=1</link><pubDate>Thu, 04 Apr 2019 13:49:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9d5d5967-c64b-4c64-bb67-6b608fc38f99</guid><dc:creator>Pierre B.</dc:creator><description>&lt;p&gt;When RX_BUF_SIZE = 127 and the GSM chip sends 127 bytes data packets, just like in the log attached to my original post, the code goes into on_rx_complete() only for the first two chunks of data (lines 30 and 32 of the log), it doesn&amp;#39;t anymore after that.&lt;/p&gt;
&lt;p&gt;I can not have any more details as I can&amp;#39;t have access to the nRF52 log from this part.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>