<?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>BusFault exception when debugging nrf9160 with segger ozone</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/70958/busfault-exception-when-debugging-nrf9160-with-segger-ozone</link><description>Hi, 
 I have written one application with logging disabled to save power. 
 However, when I tried to debug the code with Ozone, during startup, it raises BusFault exception. 
 According to call stack, it happened after calling nordisemi_nrf91_init in</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 26 Feb 2021 22:57:19 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/70958/busfault-exception-when-debugging-nrf9160-with-segger-ozone" /><item><title>RE: BusFault exception when debugging nrf9160 with segger ozone</title><link>https://devzone.nordicsemi.com/thread/296666?ContentTypeID=1</link><pubDate>Fri, 26 Feb 2021 22:57:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:12985000-00b1-486b-a4fd-8a64e59730cf</guid><dc:creator>LordLucan</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Just to follow up on this. I too had exactly the same problem when I started using Ozone. Again the documentation from Nordic on this is not exactly stellar on what to do. Nordic suggested to use Ozone but then you&amp;#39;re left to your own devices to work out why it hard faults all the time when you reset.&lt;/p&gt;
&lt;p&gt;Anyway, here&amp;#39;s what I had to do to get Ozone working. As the answer below suggests you have to edit the generated .jdebug project file. There is a jump table at address 0 which needs to be read in order to get the starting PC and SP addresses. So all I had to do to get this working was to set VectorTableAddr = 0; in _SetupTarget.&lt;/p&gt;
&lt;p&gt;So my _SetupTarget looks like this.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void _SetupTarget(void) {
  unsigned int SP;
  unsigned int PC;
  unsigned int VectorTableAddr;

  VectorTableAddr = 0; // &amp;lt;- change this to 0
  //
  // Set up initial stack pointer
  //
  SP = Target.ReadU32(VectorTableAddr);
  if (SP != 0xFFFFFFFF) {
    Target.SetReg(&amp;quot;SP&amp;quot;, SP);
  }
  //
  // Set up entry point PC
  //
  PC = Target.ReadU32(VectorTableAddr + 4);
  if (PC != 0xFFFFFFFF) {
    Target.SetReg(&amp;quot;PC&amp;quot;, PC);
  } else {
    Util.Error(&amp;quot;Project script error: failed to set up entry point PC&amp;quot;, 1);
  }
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Hopefully this should work for you. It did for me on the nrf9160dk with the bootloader. As suggested below you can see the addresses that the debugger is using to set the PC and SP to on a reset. So you can hopefully work out what you need to set.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Paul&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BusFault exception when debugging nrf9160 with segger ozone</title><link>https://devzone.nordicsemi.com/thread/293030?ContentTypeID=1</link><pubDate>Fri, 05 Feb 2021 08:11:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3d85eb79-14e5-4426-9311-452ac54da656</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What does the &amp;quot;console&amp;quot; show now?&lt;/p&gt;
&lt;p&gt;In your original image, you can clearly see that it does not load from address 0:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1612512650589v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Here it uses 0x18200 as the base address, even when you do a reset from ozone. This will cause faults.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BusFault exception when debugging nrf9160 with segger ozone</title><link>https://devzone.nordicsemi.com/thread/292987?ContentTypeID=1</link><pubDate>Thu, 04 Feb 2021 19:16:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bab6e777-4bc2-40b3-a272-09e6e64745a6</guid><dc:creator>feng niao</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thanks for the response, but seems that does not fix the issue. Still get the same error.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BusFault exception when debugging nrf9160 with segger ozone</title><link>https://devzone.nordicsemi.com/thread/291443?ContentTypeID=1</link><pubDate>Wed, 27 Jan 2021 08:41:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5676f3ea-f6ab-4724-87c5-6c8af1b38d7f</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Ozone loads the start address and MSP from the .elf file itself, and not from the start of the flash (ie: the secure &amp;quot;spm&amp;quot; image), which will give you some strange behavior if you do not use &amp;quot;attach to running target&amp;quot;.&lt;/p&gt;
&lt;p&gt;You can fix this by editing the ozone project (save as -&amp;gt; open the file in a editor) and manually pointing the project to load the SP and PC from address 0.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Please see this page on how to change this:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://wiki.segger.com/Debug_on_a_Target_with_Bootloader"&gt;https://wiki.segger.com/Debug_on_a_Target_with_Bootloader&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Note: you should edit the two function&amp;nbsp;&lt;i&gt;AfterTargetDownload()&lt;/i&gt;&lt;span&gt;&amp;nbsp;and&amp;nbsp;&lt;/span&gt;&lt;i&gt;AfterTargetReset()&lt;/i&gt;&lt;span&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Originally, you will see this line:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;VectorTableAddr = Elf.GetBaseAddr();&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Which should be changed to:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;VectorTableAddr =&amp;nbsp;0;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Could you try this, and see if the debug session gives another behavior?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Kind regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Håkon&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>